aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-07-06 15:37:42 -0700
committerJunio C Hamano <gitster@pobox.com>2011-07-06 15:37:42 -0700
commit4d9e42f8f11c57b32b976a943c8ddaf6214e64b8 (patch)
treef1aee1490288aa30fb62a981696389d9b5e3e992
parentc5bcf1f9f6d3429ab9a09e07e28362e7d189005b (diff)
parentea02eef096d4bfcbb83e76cfab0fcb42dbcad35e (diff)
downloadgit-4d9e42f8f11c57b32b976a943c8ddaf6214e64b8.tar.gz
git-4d9e42f8f11c57b32b976a943c8ddaf6214e64b8.tar.xz
Merge commit 'v1.6.0' into jc/checkout-reflog-fix
* commit 'v1.6.0': (2063 commits) GIT 1.6.0 git-p4: chdir now properly sets PWD environment variable in msysGit Improve error output of git-rebase t9300: replace '!' with test_must_fail Git.pm: Make File::Spec and File::Temp requirement lazy Documentation: document the pager.* configuration setting git-stash: improve synopsis in help and manual page Makefile: building git in cygwin 1.7.0 git-am: ignore --binary option bash-completion: Add non-command git help files to bash-completion Fix t3700 on filesystems which do not support question marks in names Utilise our new p4_read_pipe and p4_write_pipe wrappers Add p4 read_pipe and write_pipe wrappers bash completion: Add '--merge' long option for 'git log' bash completion: Add completion for 'git mergetool' git format-patch documentation: clarify what --cover-letter does bash completion: 'git apply' should use 'fix' not 'strip' t5304-prune: adjust file mtime based on system time rather than file mtime test-parse-options: use appropriate cast in length_callback Fix escaping of glob special characters in pathspecs ... Conflicts: builtin-checkout.c
-rw-r--r--.gitattributes2
-rw-r--r--.gitignore6
-rw-r--r--.mailmap11
-rw-r--r--Documentation/.gitattributes1
-rw-r--r--Documentation/.gitignore2
-rw-r--r--Documentation/CodingGuidelines16
-rw-r--r--Documentation/Makefile25
-rw-r--r--Documentation/RelNotes-1.5.2.txt2
-rw-r--r--Documentation/RelNotes-1.5.3.3.txt2
-rw-r--r--Documentation/RelNotes-1.5.3.txt6
-rw-r--r--Documentation/RelNotes-1.5.4.1.txt17
-rw-r--r--Documentation/RelNotes-1.5.4.2.txt43
-rw-r--r--Documentation/RelNotes-1.5.4.3.txt27
-rw-r--r--Documentation/RelNotes-1.5.4.4.txt66
-rw-r--r--Documentation/RelNotes-1.5.4.5.txt56
-rw-r--r--Documentation/RelNotes-1.5.4.6.txt43
-rw-r--r--Documentation/RelNotes-1.5.4.txt51
-rw-r--r--Documentation/RelNotes-1.5.5.1.txt44
-rw-r--r--Documentation/RelNotes-1.5.5.2.txt27
-rw-r--r--Documentation/RelNotes-1.5.5.3.txt12
-rw-r--r--Documentation/RelNotes-1.5.5.4.txt7
-rw-r--r--Documentation/RelNotes-1.5.5.5.txt11
-rw-r--r--Documentation/RelNotes-1.5.5.txt207
-rw-r--r--Documentation/RelNotes-1.5.6.1.txt28
-rw-r--r--Documentation/RelNotes-1.5.6.2.txt40
-rw-r--r--Documentation/RelNotes-1.5.6.3.txt52
-rw-r--r--Documentation/RelNotes-1.5.6.4.txt47
-rw-r--r--Documentation/RelNotes-1.5.6.5.txt29
-rw-r--r--Documentation/RelNotes-1.5.6.txt115
-rw-r--r--Documentation/RelNotes-1.6.0.txt258
-rw-r--r--Documentation/SubmittingPatches72
-rw-r--r--Documentation/asciidoc.conf1
-rw-r--r--Documentation/blame-options.txt8
-rwxr-xr-xDocumentation/cat-texi.perl2
-rw-r--r--Documentation/config.txt454
-rw-r--r--Documentation/diff-generate-patch.txt2
-rw-r--r--Documentation/diff-options.txt24
-rw-r--r--Documentation/everyday.txt6
-rw-r--r--Documentation/fetch-options.txt48
-rw-r--r--Documentation/git-add.txt100
-rw-r--r--Documentation/git-am.txt66
-rw-r--r--Documentation/git-annotate.txt4
-rw-r--r--Documentation/git-apply.txt50
-rw-r--r--Documentation/git-archimport.txt16
-rw-r--r--Documentation/git-archive.txt12
-rw-r--r--Documentation/git-bisect.txt77
-rw-r--r--Documentation/git-blame.txt20
-rw-r--r--Documentation/git-branch.txt94
-rw-r--r--Documentation/git-bundle.txt83
-rw-r--r--Documentation/git-cat-file.txt48
-rw-r--r--Documentation/git-check-attr.txt6
-rw-r--r--Documentation/git-check-ref-format.txt6
-rw-r--r--Documentation/git-checkout-index.txt45
-rw-r--r--Documentation/git-checkout.txt36
-rw-r--r--Documentation/git-cherry-pick.txt35
-rw-r--r--Documentation/git-cherry.txt16
-rw-r--r--Documentation/git-citool.txt6
-rw-r--r--Documentation/git-clean.txt14
-rw-r--r--Documentation/git-clone.txt32
-rw-r--r--Documentation/git-commit-tree.txt18
-rw-r--r--Documentation/git-commit.txt123
-rw-r--r--Documentation/git-config.txt62
-rw-r--r--Documentation/git-count-objects.txt9
-rw-r--r--Documentation/git-cvsexportcommit.txt28
-rw-r--r--Documentation/git-cvsimport.txt38
-rw-r--r--Documentation/git-cvsserver.txt114
-rw-r--r--Documentation/git-daemon.txt78
-rw-r--r--Documentation/git-describe.txt50
-rw-r--r--Documentation/git-diff-files.txt12
-rw-r--r--Documentation/git-diff-index.txt36
-rw-r--r--Documentation/git-diff-tree.txt36
-rw-r--r--Documentation/git-diff.txt20
-rw-r--r--Documentation/git-fast-export.txt41
-rw-r--r--Documentation/git-fast-import.txt129
-rw-r--r--Documentation/git-fetch-pack.txt36
-rw-r--r--Documentation/git-fetch.txt8
-rw-r--r--Documentation/git-filter-branch.txt96
-rw-r--r--Documentation/git-fmt-merge-msg.txt30
-rw-r--r--Documentation/git-for-each-ref.txt32
-rw-r--r--Documentation/git-format-patch.txt136
-rw-r--r--Documentation/git-fsck-objects.txt2
-rw-r--r--Documentation/git-fsck.txt15
-rw-r--r--Documentation/git-gc.txt62
-rw-r--r--Documentation/git-get-tar-commit-id.txt10
-rw-r--r--Documentation/git-grep.txt43
-rw-r--r--Documentation/git-gui.txt36
-rw-r--r--Documentation/git-hash-object.txt11
-rw-r--r--Documentation/git-help.txt142
-rw-r--r--Documentation/git-http-fetch.txt4
-rw-r--r--Documentation/git-http-push.txt10
-rw-r--r--Documentation/git-imap-send.txt8
-rw-r--r--Documentation/git-index-pack.txt17
-rw-r--r--Documentation/git-init-db.txt2
-rw-r--r--Documentation/git-init.txt30
-rw-r--r--Documentation/git-instaweb.txt35
-rw-r--r--Documentation/git-log.txt16
-rw-r--r--Documentation/git-lost-found.txt4
-rw-r--r--Documentation/git-ls-files.txt42
-rw-r--r--Documentation/git-ls-remote.txt16
-rw-r--r--Documentation/git-ls-tree.txt24
-rw-r--r--Documentation/git-mailinfo.txt15
-rw-r--r--Documentation/git-mailsplit.txt8
-rw-r--r--Documentation/git-merge-base.txt12
-rw-r--r--Documentation/git-merge-file.txt20
-rw-r--r--Documentation/git-merge-index.txt24
-rw-r--r--Documentation/git-merge-one-file.txt8
-rw-r--r--Documentation/git-merge-tree.txt4
-rw-r--r--Documentation/git-merge.txt122
-rw-r--r--Documentation/git-mergetool.txt44
-rw-r--r--Documentation/git-mktag.txt4
-rw-r--r--Documentation/git-mktree.txt6
-rw-r--r--Documentation/git-mv.txt11
-rw-r--r--Documentation/git-name-rev.txt18
-rw-r--r--Documentation/git-pack-objects.txt32
-rw-r--r--Documentation/git-pack-redundant.txt14
-rw-r--r--Documentation/git-pack-refs.txt10
-rw-r--r--Documentation/git-parse-remote.txt6
-rw-r--r--Documentation/git-patch-id.txt6
-rw-r--r--Documentation/git-peek-remote.txt10
-rw-r--r--Documentation/git-prune-packed.txt6
-rw-r--r--Documentation/git-prune.txt35
-rw-r--r--Documentation/git-pull.txt129
-rw-r--r--Documentation/git-push.txt142
-rw-r--r--Documentation/git-quiltimport.txt6
-rw-r--r--Documentation/git-read-tree.txt79
-rw-r--r--Documentation/git-rebase.txt84
-rw-r--r--Documentation/git-receive-pack.txt22
-rw-r--r--Documentation/git-reflog.txt28
-rw-r--r--Documentation/git-relink.txt4
-rw-r--r--Documentation/git-remote.txt37
-rw-r--r--Documentation/git-repack.txt41
-rw-r--r--Documentation/git-repo-config.txt2
-rw-r--r--Documentation/git-request-pull.txt8
-rw-r--r--Documentation/git-rerere.txt46
-rw-r--r--Documentation/git-reset.txt27
-rw-r--r--Documentation/git-rev-list.txt22
-rw-r--r--Documentation/git-rev-parse.txt159
-rw-r--r--Documentation/git-revert.txt39
-rw-r--r--Documentation/git-rm.txt75
-rw-r--r--Documentation/git-send-email.txt89
-rw-r--r--Documentation/git-send-pack.txt26
-rw-r--r--Documentation/git-sh-setup.txt6
-rw-r--r--Documentation/git-shell.txt6
-rw-r--r--Documentation/git-shortlog.txt28
-rw-r--r--Documentation/git-show-branch.txt16
-rw-r--r--Documentation/git-show-index.txt6
-rw-r--r--Documentation/git-show-ref.txt35
-rw-r--r--Documentation/git-show.txt16
-rw-r--r--Documentation/git-stash.txt88
-rw-r--r--Documentation/git-status.txt21
-rw-r--r--Documentation/git-stripspace.txt7
-rw-r--r--Documentation/git-submodule.txt136
-rw-r--r--Documentation/git-svn.txt219
-rw-r--r--Documentation/git-symbolic-ref.txt11
-rw-r--r--Documentation/git-tag.txt36
-rw-r--r--Documentation/git-tar-tree.txt10
-rw-r--r--Documentation/git-unpack-file.txt4
-rw-r--r--Documentation/git-unpack-objects.txt9
-rw-r--r--Documentation/git-update-index.txt66
-rw-r--r--Documentation/git-update-ref.txt12
-rw-r--r--Documentation/git-update-server-info.txt13
-rw-r--r--Documentation/git-upload-archive.txt4
-rw-r--r--Documentation/git-upload-pack.txt8
-rw-r--r--Documentation/git-var.txt10
-rw-r--r--Documentation/git-verify-pack.txt14
-rw-r--r--Documentation/git-verify-tag.txt10
-rw-r--r--Documentation/git-web--browse.txt124
-rw-r--r--Documentation/git-whatchanged.txt19
-rw-r--r--Documentation/git-write-tree.txt12
-rw-r--r--Documentation/git.txt111
-rw-r--r--Documentation/gitattributes.txt97
-rw-r--r--Documentation/gitcli.txt79
-rw-r--r--Documentation/gitcore-tutorial.txt (renamed from Documentation/core-tutorial.txt)324
-rw-r--r--Documentation/gitcvs-migration.txt (renamed from Documentation/cvs-migration.txt)62
-rw-r--r--Documentation/gitdiffcore.txt (renamed from Documentation/diffcore.txt)69
-rw-r--r--Documentation/gitglossary.txt25
-rw-r--r--Documentation/githooks.txt (renamed from Documentation/hooks.txt)131
-rw-r--r--Documentation/gitignore.txt40
-rw-r--r--Documentation/gitk.txt23
-rw-r--r--Documentation/gitmodules.txt2
-rw-r--r--Documentation/gitrepository-layout.txt (renamed from Documentation/repository-layout.txt)61
-rw-r--r--Documentation/gittutorial-2.txt (renamed from Documentation/tutorial-2.txt)76
-rw-r--r--Documentation/gittutorial.txt (renamed from Documentation/tutorial.txt)150
-rw-r--r--Documentation/glossary-content.txt (renamed from Documentation/glossary.txt)26
-rw-r--r--Documentation/howto/rebase-from-internal-branch.txt2
-rw-r--r--Documentation/howto/rebuild-from-update-hook.txt2
-rw-r--r--Documentation/howto/revert-branch-rebase.txt2
-rw-r--r--Documentation/howto/separating-topic-branches.txt2
-rw-r--r--Documentation/howto/setup-git-server-over-http.txt45
-rw-r--r--Documentation/howto/update-hook-example.txt90
-rw-r--r--Documentation/i18n.txt4
-rwxr-xr-xDocumentation/install-doc-quick.sh2
-rw-r--r--Documentation/manpage-1.72.xsl21
-rw-r--r--Documentation/merge-config.txt40
-rw-r--r--Documentation/merge-options.txt28
-rw-r--r--Documentation/merge-strategies.txt7
-rw-r--r--Documentation/pretty-formats.txt33
-rw-r--r--Documentation/pretty-options.txt3
-rw-r--r--Documentation/pull-fetch-param.txt14
-rw-r--r--Documentation/rev-list-options.txt226
-rw-r--r--Documentation/technical/api-builtin.txt15
-rw-r--r--Documentation/technical/api-diff.txt2
-rw-r--r--Documentation/technical/api-history-graph.txt179
-rw-r--r--Documentation/technical/api-parse-options.txt204
-rw-r--r--Documentation/technical/api-path-list.txt9
-rw-r--r--Documentation/technical/api-remote.txt123
-rw-r--r--Documentation/technical/api-revision-walking.txt60
-rw-r--r--Documentation/technical/api-run-command.txt172
-rw-r--r--Documentation/technical/api-strbuf.txt239
-rw-r--r--Documentation/technical/api-string-list.txt128
-rw-r--r--Documentation/technical/pack-format.txt16
-rw-r--r--Documentation/technical/racy-git.txt2
-rw-r--r--Documentation/urls-remotes.txt93
-rw-r--r--Documentation/urls.txt23
-rw-r--r--Documentation/user-manual.txt223
-rwxr-xr-xGIT-VERSION-GEN17
-rw-r--r--INSTALL33
-rw-r--r--Makefile690
l---------RelNotes2
-rw-r--r--abspath.c104
-rw-r--r--alias.c77
-rw-r--r--archive-tar.c121
-rw-r--r--archive-zip.c110
-rw-r--r--archive.c320
-rw-r--r--archive.h29
-rw-r--r--attr.c57
-rw-r--r--branch.c64
-rw-r--r--branch.h2
-rw-r--r--builtin-add.c148
-rw-r--r--builtin-apply.c1106
-rw-r--r--builtin-archive.c176
-rw-r--r--builtin-blame.c584
-rw-r--r--builtin-branch.c208
-rw-r--r--builtin-bundle.c2
-rw-r--r--builtin-cat-file.c131
-rw-r--r--builtin-check-attr.c2
-rw-r--r--builtin-checkout-index.c4
-rw-r--r--builtin-checkout.c292
-rw-r--r--builtin-clean.c65
-rw-r--r--builtin-clone.c602
-rw-r--r--builtin-commit-tree.c104
-rw-r--r--builtin-commit.c513
-rw-r--r--builtin-config.c80
-rw-r--r--builtin-count-objects.c2
-rw-r--r--builtin-describe.c125
-rw-r--r--builtin-diff-files.c46
-rw-r--r--builtin-diff-index.c4
-rw-r--r--builtin-diff-tree.c4
-rw-r--r--builtin-diff.c72
-rw-r--r--[-rwxr-xr-x]builtin-fast-export.c182
-rw-r--r--builtin-fetch-pack.c135
-rw-r--r--builtin-fetch.c178
-rw-r--r--builtin-fmt-merge-msg.c178
-rw-r--r--builtin-for-each-ref.c13
-rw-r--r--builtin-fsck.c347
-rw-r--r--builtin-gc.c86
-rw-r--r--builtin-grep.c42
-rw-r--r--builtin-http-fetch.c7
-rw-r--r--builtin-init-db.c255
-rw-r--r--builtin-log.c441
-rw-r--r--builtin-ls-files.c10
-rw-r--r--builtin-ls-remote.c8
-rw-r--r--builtin-ls-tree.c21
-rw-r--r--builtin-mailinfo.c763
-rw-r--r--builtin-mailsplit.c40
-rw-r--r--builtin-merge-base.c30
-rw-r--r--builtin-merge-file.c5
-rw-r--r--builtin-merge-recursive.c547
-rw-r--r--builtin-merge.c1143
-rw-r--r--builtin-mv.c81
-rw-r--r--builtin-name-rev.c132
-rw-r--r--builtin-pack-objects.c523
-rw-r--r--builtin-pack-refs.c123
-rw-r--r--builtin-prune-packed.c3
-rw-r--r--builtin-prune.c95
-rw-r--r--builtin-push.c66
-rw-r--r--builtin-read-tree.c59
-rw-r--r--builtin-reflog.c311
-rw-r--r--builtin-remote.c712
-rw-r--r--builtin-rerere.c397
-rw-r--r--builtin-reset.c114
-rw-r--r--builtin-rev-list.c113
-rw-r--r--builtin-rev-parse.c138
-rw-r--r--builtin-revert.c82
-rw-r--r--builtin-rm.c16
-rw-r--r--builtin-send-pack.c36
-rw-r--r--builtin-shortlog.c303
-rw-r--r--builtin-show-branch.c14
-rw-r--r--builtin-show-ref.c13
-rw-r--r--builtin-symbolic-ref.c4
-rw-r--r--builtin-tag.c88
-rw-r--r--builtin-tar-tree.c2
-rw-r--r--builtin-unpack-objects.c187
-rw-r--r--builtin-update-index.c8
-rw-r--r--builtin-update-ref.c40
-rw-r--r--builtin-upload-archive.c20
-rw-r--r--builtin-verify-pack.c67
-rw-r--r--builtin-verify-tag.c19
-rw-r--r--builtin-write-tree.c75
-rw-r--r--builtin.h14
-rw-r--r--bundle.c22
-rw-r--r--cache-tree.c64
-rw-r--r--cache-tree.h5
-rw-r--r--cache.h212
-rwxr-xr-xcheck_bindir13
-rw-r--r--color.c14
-rw-r--r--color.h11
-rw-r--r--combine-diff.c30
-rw-r--r--commit.c187
-rw-r--r--commit.h26
-rw-r--r--compat/fnmatch.c488
-rw-r--r--compat/fnmatch.h84
-rw-r--r--compat/fopen.c37
-rw-r--r--compat/mingw.c1042
-rw-r--r--compat/mingw.h238
-rw-r--r--compat/qsort.c62
-rw-r--r--compat/regex.c4927
-rw-r--r--compat/regex.h490
-rw-r--r--compat/snprintf.c53
-rw-r--r--compat/winansi.c345
-rw-r--r--config.c303
-rw-r--r--config.mak.in5
-rw-r--r--configure.ac62
-rw-r--r--connect.c34
-rwxr-xr-xcontrib/completion/git-completion.bash756
-rw-r--r--contrib/emacs/git-blame.el12
-rw-r--r--contrib/emacs/git.el205
-rwxr-xr-xcontrib/examples/git-checkout.sh18
-rwxr-xr-xcontrib/examples/git-clone.sh (renamed from git-clone.sh)68
-rwxr-xr-xcontrib/examples/git-commit.sh6
-rwxr-xr-xcontrib/examples/git-merge.sh (renamed from git-merge.sh)40
-rwxr-xr-xcontrib/examples/git-remote.perl (renamed from git-remote.perl)21
-rwxr-xr-xcontrib/examples/git-rerere.perl284
-rwxr-xr-xcontrib/examples/git-svnimport.perl2
-rwxr-xr-xcontrib/examples/git-tag.sh2
-rwxr-xr-xcontrib/fast-import/git-p4455
-rw-r--r--contrib/fast-import/git-p4.txt68
-rwxr-xr-xcontrib/fast-import/import-zips.py72
-rwxr-xr-xcontrib/hg-to-git/hg-to-git.py47
-rw-r--r--contrib/hooks/post-receive-email5
-rw-r--r--contrib/hooks/pre-auto-gc-battery36
-rw-r--r--contrib/hooks/update-paranoid16
-rwxr-xr-xcontrib/stats/packinfo.pl2
-rw-r--r--contrib/thunderbird-patch-inline/README20
-rwxr-xr-xcontrib/thunderbird-patch-inline/appp.sh55
-rwxr-xr-xcontrib/workdir/git-new-workdir2
-rw-r--r--convert.c80
-rw-r--r--copy.c27
-rw-r--r--csum-file.c7
-rw-r--r--csum-file.h6
-rw-r--r--daemon.c94
-rw-r--r--date.c25
-rw-r--r--decorate.c5
-rw-r--r--diff-lib.c482
-rw-r--r--diff-no-index.c263
-rw-r--r--diff.c740
-rw-r--r--diff.h32
-rw-r--r--diffcore-rename.c88
-rw-r--r--dir.c78
-rw-r--r--dir.h3
-rw-r--r--editor.c56
-rw-r--r--entry.c4
-rw-r--r--environment.c47
-rw-r--r--exec_cmd.c65
-rw-r--r--exec_cmd.h6
-rw-r--r--fast-import.c183
-rw-r--r--fetch-pack.h5
-rwxr-xr-xfixup-builtins18
-rw-r--r--fsck.c333
-rw-r--r--fsck.h32
-rwxr-xr-xgit-add--interactive.perl318
-rwxr-xr-xgit-am.sh141
-rwxr-xr-xgit-archimport.perl4
-rwxr-xr-xgit-bisect.sh200
-rw-r--r--git-compat-util.h233
-rwxr-xr-xgit-cvsexportcommit.perl94
-rwxr-xr-xgit-cvsimport.perl27
-rwxr-xr-xgit-cvsserver.perl750
-rwxr-xr-xgit-filter-branch.sh96
-rwxr-xr-xgit-gui/GIT-VERSION-GEN2
-rw-r--r--git-gui/Makefile45
-rwxr-xr-xgit-gui/git-gui.sh291
-rw-r--r--git-gui/lib/about.tcl6
-rw-r--r--git-gui/lib/blame.tcl130
-rw-r--r--git-gui/lib/branch_create.tcl3
-rw-r--r--git-gui/lib/branch_delete.tcl2
-rw-r--r--git-gui/lib/browser.tcl3
-rw-r--r--git-gui/lib/checkout_op.tcl30
-rw-r--r--git-gui/lib/choose_font.tcl2
-rw-r--r--git-gui/lib/choose_repository.tcl14
-rw-r--r--git-gui/lib/choose_rev.tcl3
-rw-r--r--git-gui/lib/commit.tcl161
-rw-r--r--git-gui/lib/console.tcl10
-rw-r--r--git-gui/lib/database.tcl4
-rw-r--r--git-gui/lib/diff.tcl163
-rw-r--r--git-gui/lib/error.tcl46
-rw-r--r--git-gui/lib/index.tcl2
-rw-r--r--git-gui/lib/merge.tcl6
-rw-r--r--git-gui/lib/option.tcl42
-rw-r--r--git-gui/lib/spellcheck.tcl414
-rw-r--r--git-gui/macosx/AppMain.tcl2
-rw-r--r--git-gui/macosx/Info.plist2
-rw-r--r--git-gui/po/README79
-rw-r--r--git-gui/po/de.po734
-rw-r--r--git-gui/po/fr.po693
-rw-r--r--git-gui/po/git-gui.pot722
-rw-r--r--git-gui/po/glossary/de.po4
-rw-r--r--git-gui/po/glossary/fr.po26
-rw-r--r--git-gui/po/hu.po624
-rw-r--r--git-gui/po/it.po731
-rw-r--r--git-gui/po/ja.po747
-rw-r--r--git-gui/po/po2msg.sh25
-rw-r--r--git-gui/po/ru.po610
-rw-r--r--git-gui/po/sv.po792
-rw-r--r--git-gui/po/zh_cn.po1466
-rw-r--r--git-gui/windows/git-gui.sh11
-rwxr-xr-xgit-instaweb.sh62
-rwxr-xr-xgit-merge-one-file.sh5
-rwxr-xr-xgit-merge-stupid.sh80
-rwxr-xr-xgit-mergetool.sh161
-rwxr-xr-xgit-pull.sh40
-rwxr-xr-xgit-quiltimport.sh26
-rwxr-xr-xgit-rebase--interactive.sh140
-rwxr-xr-xgit-rebase.sh146
-rwxr-xr-xgit-relink.perl4
-rwxr-xr-xgit-repack.sh20
-rwxr-xr-xgit-request-pull.sh2
-rwxr-xr-xgit-send-email.perl285
-rwxr-xr-xgit-sh-setup.sh30
-rwxr-xr-xgit-stash.sh93
-rwxr-xr-xgit-submodule.sh459
-rwxr-xr-xgit-svn.perl452
-rwxr-xr-xgit-web--browse.sh (renamed from git-help--browse.sh)70
-rw-r--r--git.c194
-rw-r--r--git.spec.in90
-rw-r--r--gitk-git/Makefile10
-rw-r--r--gitk-git/gitk2963
-rw-r--r--gitk-git/po/de.po599
-rw-r--r--gitk-git/po/es.po890
-rw-r--r--gitk-git/po/it.po890
-rw-r--r--gitk-git/po/sv.po915
-rw-r--r--gitweb/INSTALL89
-rw-r--r--gitweb/README137
-rw-r--r--gitweb/gitweb.css8
-rwxr-xr-xgitweb/gitweb.perl985
-rw-r--r--gitweb/test/Märchen2
-rw-r--r--gitweb/test/file with spaces4
-rw-r--r--gitweb/test/file+plus+sign6
-rw-r--r--graph.c1132
-rw-r--r--graph.h121
-rw-r--r--hash-object.c59
-rw-r--r--hash.c8
-rw-r--r--hash.h4
-rw-r--r--help.c483
-rw-r--r--http-push.c156
-rw-r--r--http-walker.c12
-rw-r--r--http.c100
-rw-r--r--http.h22
-rw-r--r--ident.c7
-rw-r--r--imap-send.c20
-rw-r--r--index-pack.c247
-rw-r--r--interpolate.c3
-rw-r--r--list-objects.c4
-rw-r--r--ll-merge.c379
-rw-r--r--ll-merge.h15
-rw-r--r--lockfile.c33
-rw-r--r--log-tree.c275
-rw-r--r--log-tree.h6
-rw-r--r--mailmap.c12
-rw-r--r--mailmap.h4
-rw-r--r--merge-index.c2
-rw-r--r--merge-tree.c58
-rw-r--r--mktag.c62
-rw-r--r--name-hash.c119
-rw-r--r--object-refs.c87
-rw-r--r--object.c12
-rw-r--r--object.h8
-rw-r--r--pack-check.c162
-rw-r--r--pack-redundant.c2
-rw-r--r--pack-refs.c117
-rw-r--r--pack-refs.h18
-rw-r--r--pack-revindex.c144
-rw-r--r--pack-revindex.h11
-rw-r--r--pack-write.c12
-rw-r--r--pack.h4
-rw-r--r--pager.c43
-rw-r--r--parse-options.c292
-rw-r--r--parse-options.h45
-rw-r--r--path-list.c104
-rw-r--r--path-list.h22
-rw-r--r--path.c196
-rw-r--r--perl/Git.pm449
-rw-r--r--perl/Makefile17
-rw-r--r--pkt-line.c15
-rw-r--r--pretty.c320
-rw-r--r--progress.c11
-rw-r--r--quote.c46
-rw-r--r--quote.h4
-rw-r--r--reachable.c13
-rw-r--r--read-cache.c330
-rw-r--r--receive-pack.c49
-rw-r--r--reflog-walk.c10
-rw-r--r--refs.c75
-rw-r--r--refs.h15
-rw-r--r--remote.c866
-rw-r--r--remote.h21
-rw-r--r--rerere.c363
-rw-r--r--rerere.h9
-rw-r--r--revision.c805
-rw-r--r--revision.h25
-rw-r--r--run-command.c163
-rw-r--r--run-command.h25
-rw-r--r--setup.c333
-rw-r--r--sha1-lookup.c171
-rw-r--r--sha1-lookup.h9
-rw-r--r--sha1_file.c713
-rw-r--r--sha1_name.c121
-rw-r--r--shallow.c5
-rw-r--r--shell.c27
-rw-r--r--shortlog.h27
-rw-r--r--show-index.c3
-rw-r--r--strbuf.c91
-rw-r--r--strbuf.h18
-rw-r--r--string-list.c134
-rw-r--r--string-list.h28
-rw-r--r--symlinks.c82
-rw-r--r--t/.gitattributes1
-rw-r--r--t/.gitignore3
-rw-r--r--t/Makefile12
-rw-r--r--t/README48
-rwxr-xr-xt/aggregate-results.sh34
-rw-r--r--t/diff-lib.sh10
-rw-r--r--t/lib-git-svn.sh39
-rw-r--r--t/lib-httpd.sh99
-rw-r--r--t/lib-httpd/apache.conf35
-rw-r--r--t/lib-httpd/ssl.cnf8
-rwxr-xr-xt/t0000-basic.sh38
-rwxr-xr-xt/t0001-init.sh54
-rwxr-xr-xt/t0002-gitfile.sh103
-rwxr-xr-xt/t0003-attributes.sh92
-rwxr-xr-xt/t0004-unwritable.sh68
-rwxr-xr-xt/t0020-crlf.sh60
-rwxr-xr-xt/t0021-conversion.sh4
-rwxr-xr-xt/t0022-crlf-rename.sh2
-rwxr-xr-xt/t0023-crlf-am.sh2
-rwxr-xr-xt/t0030-stripspace.sh196
-rwxr-xr-xt/t0040-parse-options.sh169
-rwxr-xr-xt/t0050-filesystem.sh122
-rwxr-xr-xt/t0060-path-utils.sh87
-rwxr-xr-xt/t1000-read-tree-m-3way.sh163
-rwxr-xr-xt/t1001-read-tree-m-2way.sh26
-rwxr-xr-xt/t1002-read-tree-m-u-2way.sh14
-rwxr-xr-xt/t1004-read-tree-m-u-wf.sh122
-rwxr-xr-xt/t1005-read-tree-reset.sh30
-rwxr-xr-xt/t1006-cat-file.sh244
-rwxr-xr-xt/t1007-hash-object.sh133
-rwxr-xr-xt/t1020-subdirectory.sh22
-rwxr-xr-xt/t1200-tutorial.sh8
-rwxr-xr-xt/t1300-repo-config.sh152
-rwxr-xr-xt/t1301-shared-repo.sh88
-rwxr-xr-xt/t1302-repo-version.sh5
-rwxr-xr-xt/t1303-wacky-config.sh8
-rwxr-xr-xt/t1400-update-ref.sh57
-rwxr-xr-xt/t1410-reflog.sh53
-rwxr-xr-xt/t1500-rev-parse.sh13
-rwxr-xr-xt/t1501-worktree.sh34
-rwxr-xr-xt/t1502-rev-parse-parseopt.sh43
-rwxr-xr-xt/t1503-rev-parse-verify.sh107
-rwxr-xr-xt/t1504-ceiling-dirs.sh163
-rwxr-xr-xt/t2000-checkout-cache-clash.sh4
-rwxr-xr-xt/t2002-checkout-cache-u.sh6
-rwxr-xr-xt/t2008-checkout-subdir.sh16
-rwxr-xr-xt/t2009-checkout-statinfo.sh52
-rwxr-xr-xt/t2010-checkout-ambiguous.sh50
-rwxr-xr-xt/t2100-update-cache-badpath.sh4
-rwxr-xr-xt/t2103-update-index-ignore-missing.sh89
-rwxr-xr-xt/t2200-add-update.sh19
-rwxr-xr-xt/t2201-add-update-typechange.sh140
-rwxr-xr-xt/t2202-add-addremove.sh44
-rwxr-xr-xt/t3001-ls-files-others-exclude.sh47
-rwxr-xr-xt/t3002-ls-files-dashpath.sh10
-rwxr-xr-xt/t3020-ls-files-error-unmatch.sh4
-rwxr-xr-xt/t3030-merge-recursive.sh42
-rwxr-xr-xt/t3040-subprojects-basic.sh4
-rwxr-xr-xt/t3050-subprojects-fetch.sh6
-rwxr-xr-xt/t3060-ls-files-with-tree.sh2
-rwxr-xr-xt/t3100-ls-tree-restrict.sh2
-rwxr-xr-xt/t3101-ls-tree-dirname.sh4
-rwxr-xr-xt/t3200-branch.sh314
-rwxr-xr-xt/t3201-branch-contains.sh48
-rwxr-xr-xt/t3202-show-branch-octopus.sh59
-rwxr-xr-xt/t3210-pack-refs.sh26
-rwxr-xr-xt/t3300-funny-names.sh36
-rwxr-xr-xt/t3400-rebase.sh9
-rwxr-xr-xt/t3401-rebase-partial.sh4
-rwxr-xr-xt/t3403-rebase-skip.sh10
-rwxr-xr-xt/t3404-rebase-interactive.sh145
-rwxr-xr-xt/t3405-rebase-malformed.sh4
-rwxr-xr-xt/t3406-rebase-message.sh2
-rwxr-xr-xt/t3407-rebase-abort.sh80
-rwxr-xr-xt/t3408-rebase-multi-line.sh41
-rwxr-xr-xt/t3500-cherry.sh3
-rwxr-xr-xt/t3501-revert-cherry-pick.sh9
-rwxr-xr-xt/t3502-cherry-pick-merge.sh12
-rwxr-xr-xt/t3503-cherry-pick-root.sh30
-rwxr-xr-xt/t3600-rm.sh49
-rwxr-xr-xt/t3700-add.sh61
-rwxr-xr-xt/t3701-add-interactive.sh162
-rwxr-xr-xt/t3800-mktag.sh189
-rwxr-xr-xt/t3900-i18n-commit.sh2
-rwxr-xr-xt/t3902-quoted.sh16
-rwxr-xr-xt/t3903-stash.sh112
-rwxr-xr-xt/t4006-diff-mode.sh2
-rwxr-xr-xt/t4013-diff-various.sh4
-rw-r--r--t/t4013/diff.diff_--name-status_dir2_dir1
-rw-r--r--t/t4013/diff.diff_--no-index_--name-status_dir2_dir3
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..master6
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..master^4
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..side2
-rw-r--r--t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master6
-rw-r--r--t/t4013/diff.format-patch_--inline_--stdout_initial..master6
-rw-r--r--t/t4013/diff.format-patch_--inline_--stdout_initial..master^4
-rw-r--r--t/t4013/diff.format-patch_--inline_--stdout_initial..master^^2
-rw-r--r--t/t4013/diff.format-patch_--inline_--stdout_initial..side2
-rw-r--r--t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^100
-rwxr-xr-xt/t4014-format-patch.sh142
-rwxr-xr-xt/t4015-diff-whitespace.sh63
-rwxr-xr-xt/t4016-diff-quote.sh18
-rwxr-xr-xt/t4017-diff-retval.sh22
-rwxr-xr-xt/t4018-diff-funcname.sh8
-rwxr-xr-xt/t4019-diff-wserror.sh60
-rwxr-xr-xt/t4020-diff-external.sh5
-rw-r--r--t/t4020/diff.NULbin0 -> 116 bytes
-rwxr-xr-xt/t4021-format-patch-signer-mime.sh10
-rwxr-xr-xt/t4022-diff-rewrite.sh5
-rwxr-xr-xt/t4023-diff-rename-typechange.sh6
-rwxr-xr-xt/t4024-diff-optimize-common.sh2
-rwxr-xr-xt/t4025-hunk-header.sh2
-rwxr-xr-xt/t4026-color.sh69
-rwxr-xr-xt/t4027-diff-submodule.sh60
-rwxr-xr-xt/t4028-format-patch-mime-headers.sh30
-rwxr-xr-xt/t4100-apply-stat.sh64
-rw-r--r--t/t4100/t-apply-8.expect2
-rw-r--r--t/t4100/t-apply-8.patch11
-rw-r--r--t/t4100/t-apply-9.expect2
-rw-r--r--t/t4100/t-apply-9.patch11
-rwxr-xr-xt/t4103-apply-binary.sh68
-rwxr-xr-xt/t4104-apply-boundary.sh17
-rwxr-xr-xt/t4105-apply-fuzz.sh57
-rwxr-xr-xt/t4109-apply-multifrag.sh179
-rw-r--r--t/t4109/expect-131
-rw-r--r--t/t4109/expect-223
-rw-r--r--t/t4109/expect-324
-rw-r--r--t/t4109/patch1.patch28
-rw-r--r--t/t4109/patch2.patch30
-rw-r--r--t/t4109/patch3.patch31
-rw-r--r--t/t4109/patch4.patch30
-rwxr-xr-xt/t4110-apply-scan.sh96
-rw-r--r--t/t4110/expect20
-rw-r--r--t/t4110/patch1.patch17
-rw-r--r--t/t4110/patch2.patch11
-rw-r--r--t/t4110/patch3.patch14
-rw-r--r--t/t4110/patch4.patch11
-rw-r--r--t/t4110/patch5.patch11
-rwxr-xr-xt/t4112-apply-renames.sh20
-rwxr-xr-xt/t4113-apply-ending.sh8
-rwxr-xr-xt/t4115-apply-symlink.sh4
-rwxr-xr-xt/t4116-apply-reverse.sh10
-rwxr-xr-xt/t4117-apply-reject.sh12
-rwxr-xr-xt/t4118-apply-empty-context.sh6
-rwxr-xr-xt/t4119-apply-config.sh4
-rwxr-xr-xt/t4125-apply-ws-fuzz.sh103
-rwxr-xr-xt/t4126-apply-empty.sh57
-rwxr-xr-xt/t4127-apply-same-fn.sh90
-rwxr-xr-xt/t4128-apply-root.sh43
-rwxr-xr-xt/t4150-am.sh260
-rwxr-xr-xt/t4151-am-abort.sh65
-rwxr-xr-xt/t4200-rerere.sh64
-rwxr-xr-xt/t4201-shortlog.sh7
-rwxr-xr-xt/t4202-log.sh3
-rwxr-xr-xt/t5000-tar-tree.sh39
-rwxr-xr-xt/t5100-mailinfo.sh20
-rw-r--r--t/t5100/001035
-rw-r--r--t/t5100/info00095
-rw-r--r--t/t5100/info00105
-rw-r--r--t/t5100/info00115
-rw-r--r--t/t5100/msg00092
-rw-r--r--t/t5100/msg00105
-rw-r--r--t/t5100/msg00112
-rw-r--r--t/t5100/nul-b64.expectbin0 -> 1672 bytes
-rw-r--r--t/t5100/nul-b64.in37
-rw-r--r--t/t5100/nul-plainbin0 -> 91 bytes
-rw-r--r--t/t5100/patch000913
-rw-r--r--t/t5100/patch001020
-rw-r--r--t/t5100/patch001122
-rw-r--r--t/t5100/sample.mbox93
-rwxr-xr-xt/t5300-pack-object.sh107
-rwxr-xr-xt/t5302-pack-index.sh53
-rwxr-xr-xt/t5303-pack-corruption-resilience.sh194
-rwxr-xr-xt/t5304-prune.sh115
-rwxr-xr-xt/t5305-include-tag.sh84
-rwxr-xr-xt/t5400-send-pack.sh4
-rwxr-xr-xt/t5401-update-hooks.sh27
-rwxr-xr-xt/t5402-post-merge-hook.sh4
-rwxr-xr-xt/t5404-tracking-branches.sh11
-rwxr-xr-xt/t5406-remote-rejects.sh2
-rwxr-xr-xt/t5500-fetch-pack.sh8
-rwxr-xr-xt/t5503-tagfollow.sh150
-rwxr-xr-xt/t5505-remote.sh239
-rwxr-xr-xt/t5510-fetch.sh30
-rwxr-xr-xt/t5511-refspec.sh75
-rwxr-xr-xt/t5512-ls-remote.sh10
-rwxr-xr-xt/t5513-fetch-track.sh30
-rwxr-xr-xt/t5515-fetch-merge-logic.sh35
-rw-r--r--t/t5515/refs.br-branches-default12
-rw-r--r--t/t5515/refs.br-branches-default-merge12
-rw-r--r--t/t5515/refs.br-branches-default-merge_branches-default12
-rw-r--r--t/t5515/refs.br-branches-default-octopus12
-rw-r--r--t/t5515/refs.br-branches-default-octopus_branches-default12
-rw-r--r--t/t5515/refs.br-branches-default_branches-default12
-rw-r--r--t/t5515/refs.br-branches-one12
-rw-r--r--t/t5515/refs.br-branches-one-merge12
-rw-r--r--t/t5515/refs.br-branches-one-merge_branches-one12
-rw-r--r--t/t5515/refs.br-branches-one-octopus12
-rw-r--r--t/t5515/refs.br-branches-one-octopus_branches-one12
-rw-r--r--t/t5515/refs.br-branches-one_branches-one12
-rw-r--r--t/t5515/refs.br-config-explicit15
-rw-r--r--t/t5515/refs.br-config-explicit-merge15
-rw-r--r--t/t5515/refs.br-config-explicit-merge_config-explicit15
-rw-r--r--t/t5515/refs.br-config-explicit-octopus15
-rw-r--r--t/t5515/refs.br-config-explicit-octopus_config-explicit15
-rw-r--r--t/t5515/refs.br-config-explicit_config-explicit15
-rw-r--r--t/t5515/refs.br-config-glob15
-rw-r--r--t/t5515/refs.br-config-glob-merge15
-rw-r--r--t/t5515/refs.br-config-glob-merge_config-glob15
-rw-r--r--t/t5515/refs.br-config-glob-octopus15
-rw-r--r--t/t5515/refs.br-config-glob-octopus_config-glob15
-rw-r--r--t/t5515/refs.br-config-glob_config-glob15
-rw-r--r--t/t5515/refs.br-remote-explicit15
-rw-r--r--t/t5515/refs.br-remote-explicit-merge15
-rw-r--r--t/t5515/refs.br-remote-explicit-merge_remote-explicit15
-rw-r--r--t/t5515/refs.br-remote-explicit-octopus15
-rw-r--r--t/t5515/refs.br-remote-explicit-octopus_remote-explicit15
-rw-r--r--t/t5515/refs.br-remote-explicit_remote-explicit15
-rw-r--r--t/t5515/refs.br-remote-glob15
-rw-r--r--t/t5515/refs.br-remote-glob-merge15
-rw-r--r--t/t5515/refs.br-remote-glob-merge_remote-glob15
-rw-r--r--t/t5515/refs.br-remote-glob-octopus15
-rw-r--r--t/t5515/refs.br-remote-glob-octopus_remote-glob15
-rw-r--r--t/t5515/refs.br-remote-glob_remote-glob15
-rw-r--r--t/t5515/refs.br-unconfig11
-rw-r--r--t/t5515/refs.br-unconfig_--tags_.._.git11
-rw-r--r--t/t5515/refs.br-unconfig_.._.git5
-rw-r--r--t/t5515/refs.br-unconfig_.._.git_one5
-rw-r--r--t/t5515/refs.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file11
-rw-r--r--t/t5515/refs.br-unconfig_.._.git_one_two5
-rw-r--r--t/t5515/refs.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file11
-rw-r--r--t/t5515/refs.br-unconfig_.._.git_tag_tag-one_tag_tag-three11
-rw-r--r--t/t5515/refs.br-unconfig_branches-default12
-rw-r--r--t/t5515/refs.br-unconfig_branches-one12
-rw-r--r--t/t5515/refs.br-unconfig_config-explicit15
-rw-r--r--t/t5515/refs.br-unconfig_config-glob15
-rw-r--r--t/t5515/refs.br-unconfig_remote-explicit15
-rw-r--r--t/t5515/refs.br-unconfig_remote-glob15
-rw-r--r--t/t5515/refs.master11
-rw-r--r--t/t5515/refs.master_--tags_.._.git11
-rw-r--r--t/t5515/refs.master_.._.git5
-rw-r--r--t/t5515/refs.master_.._.git_one5
-rw-r--r--t/t5515/refs.master_.._.git_one_tag_tag-one_tag_tag-three-file11
-rw-r--r--t/t5515/refs.master_.._.git_one_two5
-rw-r--r--t/t5515/refs.master_.._.git_tag_tag-one-tree_tag_tag-three-file11
-rw-r--r--t/t5515/refs.master_.._.git_tag_tag-one_tag_tag-three11
-rw-r--r--t/t5515/refs.master_branches-default12
-rw-r--r--t/t5515/refs.master_branches-one12
-rw-r--r--t/t5515/refs.master_config-explicit15
-rw-r--r--t/t5515/refs.master_config-glob15
-rw-r--r--t/t5515/refs.master_remote-explicit15
-rw-r--r--t/t5515/refs.master_remote-glob15
-rwxr-xr-xt/t5516-fetch-push.sh173
-rwxr-xr-xt/t5517-push-mirror.sh41
-rwxr-xr-xt/t5518-fetch-exit-status.sh37
-rwxr-xr-xt/t5520-pull.sh35
-rwxr-xr-xt/t5530-upload-pack-error.sh14
-rwxr-xr-xt/t5540-http-push.sh81
-rwxr-xr-xt/t5600-clone-fail-cleanup.sh12
-rwxr-xr-xt/t5601-clone.sh110
-rwxr-xr-xt/t5602-clone-remote-exec.sh26
-rwxr-xr-xt/t5700-clone-reference.sh35
-rwxr-xr-xt/t5701-clone-local.sh53
-rwxr-xr-xt/t5710-info-alternate.sh30
-rwxr-xr-xt/t6000lib.sh17
-rwxr-xr-xt/t6004-rev-list-path-optim.sh2
-rwxr-xr-xt/t6006-rev-list-format.sh2
-rwxr-xr-xt/t6008-rev-list-submodule.sh2
-rwxr-xr-xt/t6009-rev-list-parent.sh38
-rwxr-xr-xt/t6010-merge-base.sh9
-rwxr-xr-xt/t6011-rev-list-with-bad-commit.sh60
-rwxr-xr-xt/t6021-merge-criss-cross.sh4
-rwxr-xr-xt/t6023-merge-file.sh44
-rwxr-xr-xt/t6024-recursive-merge.sh12
-rwxr-xr-xt/t6025-merge-symlinks.sh21
-rwxr-xr-xt/t6027-merge-binary.sh4
-rwxr-xr-xt/t6029-merge-subtree.sh79
-rwxr-xr-xt/t6030-bisect-porcelain.sh102
-rwxr-xr-xt/t6031-merge-recursive.sh52
-rwxr-xr-xt/t6032-merge-large-rename.sh73
-rwxr-xr-xt/t6033-merge-crlf.sh52
-rwxr-xr-xt/t6040-tracking-info.sh70
-rwxr-xr-xt/t6101-rev-parse-parents.sh4
-rwxr-xr-xt/t6120-describe.sh49
-rwxr-xr-xt/t6200-fmt-merge-msg.sh70
-rwxr-xr-xt/t6300-for-each-ref.sh119
-rwxr-xr-xt/t7001-mv.sh96
-rwxr-xr-xt/t7002-grep.sh4
-rwxr-xr-xt/t7003-filter-branch.sh123
-rwxr-xr-xt/t7004-tag.sh337
-rwxr-xr-xt/t7005-editor.sh29
-rwxr-xr-xt/t7010-setup.sh165
-rwxr-xr-xt/t7101-reset.sh24
-rwxr-xr-xt/t7102-reset.sh109
-rwxr-xr-xt/t7103-reset-bare.sh2
-rwxr-xr-xt/t7104-reset.sh46
-rwxr-xr-xt/t7201-co.sh92
-rwxr-xr-xt/t7300-clean.sh72
-rwxr-xr-xt/t7400-submodule-basic.sh71
-rwxr-xr-xt/t7401-submodule-summary.sh208
-rwxr-xr-xt/t7402-submodule-rebase.sh92
-rwxr-xr-xt/t7500-commit.sh37
-rwxr-xr-xt/t7501-commit.sh78
-rwxr-xr-xt/t7502-commit.sh114
-rwxr-xr-xt/t7502-status.sh270
-rwxr-xr-xt/t7503-pre-commit-hook.sh4
-rwxr-xr-xt/t7504-commit-msg-hook.sh29
-rwxr-xr-xt/t7505-prepare-commit-msg-hook.sh159
-rwxr-xr-xt/t7506-status-submodule.sh38
-rwxr-xr-xt/t7600-merge.sh131
-rwxr-xr-xt/t7601-merge-pull-config.sh156
-rwxr-xr-xt/t7602-merge-octopus-many.sh52
-rwxr-xr-xt/t7603-merge-reduce-heads.sh63
-rwxr-xr-xt/t7604-merge-custom-message.sh37
-rwxr-xr-xt/t7605-merge-resolve.sh46
-rwxr-xr-xt/t7610-mergetool.sh46
-rwxr-xr-xt/t7701-repack-unpack-unreachable.sh81
-rwxr-xr-xt/t8003-blame.sh4
-rwxr-xr-xt/t9001-send-email.sh208
-rwxr-xr-xt/t9100-git-svn-basic.sh148
-rwxr-xr-xt/t9101-git-svn-props.sh8
-rwxr-xr-xt/t9102-git-svn-deep-rmdir.sh20
-rwxr-xr-xt/t9103-git-svn-tracked-directory-removed.sh20
-rwxr-xr-xt/t9104-git-svn-follow-parent.sh172
-rwxr-xr-xt/t9105-git-svn-commit-diff.sh32
-rwxr-xr-xt/t9106-git-svn-commit-diff-clobber.sh68
-rwxr-xr-xt/t9106-git-svn-dcommit-clobber-series.sh38
-rwxr-xr-xt/t9107-git-svn-migrate.sh124
-rwxr-xr-xt/t9108-git-svn-glob.sh113
-rwxr-xr-xt/t9108-git-svn-multi-glob.sh160
-rwxr-xr-xt/t9110-git-svn-use-svm-props.sh21
-rwxr-xr-xt/t9111-git-svn-use-svnsync-props.sh12
-rwxr-xr-xt/t9112-git-svn-md5less-file.sh6
-rwxr-xr-xt/t9113-git-svn-dcommit-new-file.sh19
-rwxr-xr-xt/t9114-git-svn-dcommit-merge.sh22
-rwxr-xr-xt/t9115-git-svn-dcommit-funky-renames.sh47
-rwxr-xr-xt/t9116-git-svn-log.sh36
-rwxr-xr-xt/t9117-git-svn-init-clone.sh30
-rwxr-xr-xt/t9118-git-svn-funky-branch-names.sh24
-rwxr-xr-xt/t9119-git-svn-info.sh84
-rwxr-xr-xt/t9120-git-svn-clone-with-percent-escapes.sh31
-rwxr-xr-xt/t9121-git-svn-fetch-renamed-dir.sh20
-rw-r--r--t/t9121/renamed-dir.dump90
-rwxr-xr-xt/t9122-git-svn-author.sh84
-rwxr-xr-xt/t9123-git-svn-rebuild-with-rewriteroot.sh32
-rwxr-xr-xt/t9124-git-svn-dcommit-auto-props.sh86
-rwxr-xr-xt/t9125-git-svn-multi-glob-branch-names.sh37
-rwxr-xr-xt/t9200-git-cvsexportcommit.sh78
-rwxr-xr-xt/t9300-fast-import.sh212
-rwxr-xr-xt/t9301-fast-export.sh115
-rwxr-xr-xt/t9400-git-cvsserver-server.sh151
-rwxr-xr-xt/t9401-git-cvsserver-crlf.sh337
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh41
-rwxr-xr-xt/t9600-cvsimport.sh27
-rwxr-xr-xt/t9700-perl-git.sh44
-rwxr-xr-xt/t9700/test.pl100
-rw-r--r--t/test-lib.sh229
-rw-r--r--tag.c11
-rw-r--r--templates/Makefile12
-rwxr-xr-x[-rw-r--r--]templates/hooks--applypatch-msg.sample (renamed from templates/hooks--applypatch-msg)2
-rwxr-xr-x[-rw-r--r--]templates/hooks--commit-msg.sample (renamed from templates/hooks--commit-msg)5
-rwxr-xr-x[-rw-r--r--]templates/hooks--post-commit.sample (renamed from templates/hooks--post-commit)2
-rw-r--r--templates/hooks--post-receive16
-rwxr-xr-xtemplates/hooks--post-receive.sample15
-rwxr-xr-x[-rw-r--r--]templates/hooks--post-update.sample (renamed from templates/hooks--post-update)2
-rwxr-xr-x[-rw-r--r--]templates/hooks--pre-applypatch.sample (renamed from templates/hooks--pre-applypatch)2
-rw-r--r--templates/hooks--pre-commit70
-rwxr-xr-xtemplates/hooks--pre-commit.sample18
-rwxr-xr-x[-rw-r--r--]templates/hooks--pre-rebase.sample (renamed from templates/hooks--pre-rebase)27
-rwxr-xr-xtemplates/hooks--prepare-commit-msg.sample36
-rwxr-xr-x[-rw-r--r--]templates/hooks--update.sample (renamed from templates/hooks--update)2
-rw-r--r--test-absolute-path.c11
-rw-r--r--test-parse-options.c40
-rw-r--r--test-path-utils.c26
-rwxr-xr-xtest-sha1.sh4
-rw-r--r--thread-utils.c48
-rw-r--r--thread-utils.h6
-rw-r--r--transport.c123
-rw-r--r--transport.h7
-rw-r--r--tree-diff.c27
-rw-r--r--tree-walk.c62
-rw-r--r--tree-walk.h23
-rw-r--r--tree.c60
-rw-r--r--tree.h4
-rw-r--r--unpack-file.c2
-rw-r--r--unpack-trees.c759
-rw-r--r--unpack-trees.h46
-rw-r--r--update-server-info.c2
-rw-r--r--upload-pack.c34
-rw-r--r--var.c13
-rw-r--r--walker.c8
-rw-r--r--walker.h6
-rw-r--r--wrapper.c198
-rw-r--r--write_or_die.c44
-rw-r--r--ws.c152
-rw-r--r--wt-status.c171
-rw-r--r--wt-status.h14
-rw-r--r--xdiff-interface.c7
-rw-r--r--xdiff/xdiff.h1
-rw-r--r--xdiff/xmerge.c70
926 files changed, 66638 insertions, 20440 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..6b9c715d2
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+* whitespace=!indent,trail,space
+*.[ch] whitespace
diff --git a/.gitignore b/.gitignore
index 7f8421dcd..a213e8e25 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+GIT-BUILD-OPTIONS
GIT-CFLAGS
GIT-GUI-VARS
GIT-VERSION-FILE
@@ -50,7 +51,6 @@ git-gc
git-get-tar-commit-id
git-grep
git-hash-object
-git-help--browse
git-http-fetch
git-http-push
git-imap-send
@@ -75,7 +75,6 @@ git-merge-one-file
git-merge-ours
git-merge-recursive
git-merge-resolve
-git-merge-stupid
git-merge-subtree
git-mergetool
git-mktag
@@ -136,12 +135,12 @@ git-upload-pack
git-var
git-verify-pack
git-verify-tag
+git-web--browse
git-whatchanged
git-write-tree
git-core-*/?*
gitk-wish
gitweb/gitweb.cgi
-test-absolute-path
test-chmtime
test-date
test-delta
@@ -149,6 +148,7 @@ test-dump-cache-tree
test-genrandom
test-match-trees
test-parse-options
+test-path-utils
test-sha1
common-cmds.h
*.tar.gz
diff --git a/.mailmap b/.mailmap
index 695739ea7..373476bdc 100644
--- a/.mailmap
+++ b/.mailmap
@@ -5,21 +5,28 @@
# same person appearing not to be so.
#
+Alexander Gavrilov <angavrilov@gmail.com>
Aneesh Kumar K.V <aneesh.kumar@gmail.com>
Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
Chris Shoemaker <c.shoemaker@cox.net>
Dana L. How <danahow@gmail.com>
Dana L. How <how@deathvalley.cswitch.com>
Daniel Barkalow <barkalow@iabervon.org>
+David D. Kilzer <ddkilzer@kilzer.net>
David KÃ¥gedal <davidk@lysator.liu.se>
+David S. Miller <davem@davemloft.net>
+Dirk Süsserott <newsletter@dirk.my1.cc>
Fredrik Kuivinen <freku045@student.liu.se>
H. Peter Anvin <hpa@bonde.sc.orionmulti.com>
H. Peter Anvin <hpa@tazenda.sc.orionmulti.com>
H. Peter Anvin <hpa@trantor.hos.anvin.org>
Horst H. von Brand <vonbrand@inf.utfsm.cl>
+İsmail Dönmez <ismail@pardus.org.tr>
+Jay Soffian <jaysoffian+git@gmail.com>
Joachim Berdal Haga <cjhaga@fys.uio.no>
Jon Loeliger <jdl@freescale.com>
Jon Seymour <jon@blackcubes.dyndns.org>
+Jonathan Nieder <jrnieder@uchicago.edu>
Junio C Hamano <junio@twinsun.com>
Karl Hasselström <kha@treskal.com>
Kent Engstrom <kent@lysator.liu.se>
@@ -29,9 +36,12 @@ Li Hong <leehong@pku.edu.cn>
Lukas Sandström <lukass@etek.chalmers.se>
Martin Langhoff <martin@catalyst.net.nz>
Michael Coleman <tutufan@gmail.com>
+Michael W. Olson <mwolson@gnu.org>
Michele Ballabio <barra_cuda@katamail.com>
Nanako Shiraishi <nanako3@bluebottle.com>
+Nanako Shiraishi <nanako3@lavabit.com>
Nguyá»…n Thái Ngá»c Duy <pclouds@gmail.com>
+Philippe Bruhat <book@cpan.org>
Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk>
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Robert Fitzsimons <robfitz@273k.net>
@@ -43,6 +53,7 @@ Steven Grimm <koreth@midwinter.com>
Theodore Ts'o <tytso@mit.edu>
Tony Luck <tony.luck@intel.com>
Uwe Kleine-König <Uwe_Zeisberger@digi.com>
+Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Uwe Kleine-König <uzeisberger@io.fsforth.de>
Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
diff --git a/Documentation/.gitattributes b/Documentation/.gitattributes
new file mode 100644
index 000000000..ddb030137
--- /dev/null
+++ b/Documentation/.gitattributes
@@ -0,0 +1 @@
+*.txt whitespace
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
index 2f938f471..d8edd9040 100644
--- a/Documentation/.gitignore
+++ b/Documentation/.gitignore
@@ -2,7 +2,9 @@
*.html
*.[1-8]
*.made
+*.texi
git.info
+gitman.info
howto-index.txt
doc.dep
cmds-*.txt
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 3b042db62..f628c1f3b 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -53,6 +53,18 @@ For shell scripts specifically (not exhaustive):
- We do not write the noiseword "function" in front of shell
functions.
+ - As to use of grep, stick to a subset of BRE (namely, no \{m,n\},
+ [::], [==], nor [..]) for portability.
+
+ - We do not use \{m,n\};
+
+ - We do not use -E;
+
+ - We do not use ? nor + (which are \{0,1\} and \{1,\}
+ respectively in BRE) but that goes without saying as these
+ are ERE elements not BRE (note that \? and \+ are not even part
+ of BRE -- making them accessible from BRE is a GNU extension).
+
For C programs:
- We use tabs to indent, and interpret tabs as taking up to
@@ -77,6 +89,8 @@ For C programs:
of "else if" statements, it can make sense to add braces to
single line blocks.
+ - We try to avoid assignments inside if().
+
- Try to make your code understandable. You may put comments
in, but comments invariably tend to stale out when the code
they were describing changes. Often splitting a function
@@ -91,7 +105,7 @@ For C programs:
- Use the API. No, really. We have a strbuf (variable length
string), several arrays with the ALLOC_GROW() macro, a
- path_list for sorted string lists, a hash map (mapping struct
+ string_list for sorted string lists, a hash map (mapping struct
objects) named "struct decorate", amongst other things.
- When you come up with an API, document it.
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 7a325462e..62269e39c 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -1,9 +1,12 @@
MAN1_TXT= \
$(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
$(wildcard git-*.txt)) \
- gitk.txt
-MAN5_TXT=gitattributes.txt gitignore.txt gitcli.txt gitmodules.txt
-MAN7_TXT=git.txt
+ gitk.txt git.txt
+MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
+ gitrepository-layout.txt
+MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
+ gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
+ gitdiffcore.txt
MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
@@ -11,17 +14,9 @@ MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
DOC_HTML=$(MAN_HTML)
-ARTICLES = tutorial
-ARTICLES += tutorial-2
-ARTICLES += core-tutorial
-ARTICLES += cvs-migration
-ARTICLES += diffcore
-ARTICLES += howto-index
-ARTICLES += repository-layout
-ARTICLES += hooks
+ARTICLES = howto-index
ARTICLES += everyday
ARTICLES += git-tools
-ARTICLES += glossary
# with their own formatting rules.
SP_ARTICLES = howto/revert-branch-rebase howto/using-merge-subtree user-manual
API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
@@ -45,6 +40,7 @@ man7dir=$(mandir)/man7
ASCIIDOC=asciidoc
ASCIIDOC_EXTRA =
+MANPAGE_XSL = callouts.xsl
INSTALL?=install
RM ?= rm -f
DOC_REF = origin/man
@@ -65,6 +61,7 @@ ASCIIDOC_EXTRA += -a asciidoc7compatible
endif
ifdef DOCBOOK_XSL_172
ASCIIDOC_EXTRA += -a docbook-xsl-172
+MANPAGE_XSL = manpage-1.72.xsl
endif
#
@@ -142,8 +139,6 @@ cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
$(PERL_PATH) ./cmd-list.perl ../command-list.txt
date >$@
-git.7 git.html: git.txt
-
clean:
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
$(RM) *.texi *.texi+ git.info gitman.info
@@ -159,7 +154,7 @@ $(MAN_HTML): %.html : %.txt
%.1 %.5 %.7 : %.xml
$(RM) $@
- xmlto -m callouts.xsl man $<
+ xmlto -m $(MANPAGE_XSL) man $<
%.xml : %.txt
$(RM) $@+ $@
diff --git a/Documentation/RelNotes-1.5.2.txt b/Documentation/RelNotes-1.5.2.txt
index 6195715dc..e8328d090 100644
--- a/Documentation/RelNotes-1.5.2.txt
+++ b/Documentation/RelNotes-1.5.2.txt
@@ -36,7 +36,7 @@ Updates since v1.5.1
expansion). These conversions apply when checking files in
or out, and exporting via git-archive.
-* The packfile format now optionally suports 64-bit index.
+* The packfile format now optionally supports 64-bit index.
This release supports the "version 2" format of the .idx
file. This is automatically enabled when a huge packfile
diff --git a/Documentation/RelNotes-1.5.3.3.txt b/Documentation/RelNotes-1.5.3.3.txt
index 2a7bfdd5c..d21384695 100644
--- a/Documentation/RelNotes-1.5.3.3.txt
+++ b/Documentation/RelNotes-1.5.3.3.txt
@@ -12,7 +12,7 @@ Fixes since v1.5.3.2
* The default shell on some FreeBSD did not execute the
argument parsing code correctly and made git unusable.
- * git-svn incorrectly spawned pager even when the user user
+ * git-svn incorrectly spawned pager even when the user
explicitly asked not to.
* sample post-receive hook overquoted the envelope sender
diff --git a/Documentation/RelNotes-1.5.3.txt b/Documentation/RelNotes-1.5.3.txt
index d03894b92..0668d3c0c 100644
--- a/Documentation/RelNotes-1.5.3.txt
+++ b/Documentation/RelNotes-1.5.3.txt
@@ -86,7 +86,7 @@ Updates since v1.5.2
- "git rev-list" learned --regexp-ignore-case and
--extended-regexp options to tweak its matching logic used
- for --grep fitering.
+ for --grep filtering.
- "git describe --contains" is a handier way to call more
obscure command "git name-rev --tags".
@@ -243,7 +243,7 @@ Updates since v1.5.2
- We used to have core.legacyheaders configuration, when
set to false, allowed git to write loose objects in a format
- that mimicks the format used by objects stored in packs. It
+ that mimics the format used by objects stored in packs. It
turns out that this was not so useful. Although we will
continue to read objects written in that format, we do not
honor that configuration anymore and create loose objects in
@@ -302,7 +302,7 @@ Updates since v1.5.2
small enough delta results it creates while looking for the
best delta candidates.
- - "git pack-objects" learned a new heuristcs to prefer delta
+ - "git pack-objects" learned a new heuristic to prefer delta
that is shallower in depth over the smallest delta
possible. This improves both overall packfile access
performance and packfile density.
diff --git a/Documentation/RelNotes-1.5.4.1.txt b/Documentation/RelNotes-1.5.4.1.txt
new file mode 100644
index 000000000..d4e44b8b0
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.1.txt
@@ -0,0 +1,17 @@
+GIT v1.5.4.1 Release Notes
+==========================
+
+Fixes since v1.5.4
+------------------
+
+ * "git-commit -C $tag" used to work but rewrite in C done in
+ 1.5.4 broke it.
+
+ * An entry in the .gitattributes file that names a pattern in a
+ subdirectory of the directory it is in did not match
+ correctly (e.g. pattern "b/*.c" in "a/.gitattributes" should
+ match "a/b/foo.c" but it didn't).
+
+ * Customized color specification was parsed incorrectly when
+ numeric color values are used. This was fixed in 1.5.4.1.
+
diff --git a/Documentation/RelNotes-1.5.4.2.txt b/Documentation/RelNotes-1.5.4.2.txt
new file mode 100644
index 000000000..21d0df59f
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.2.txt
@@ -0,0 +1,43 @@
+GIT v1.5.4.2 Release Notes
+==========================
+
+Fixes since v1.5.4
+------------------
+
+ * The configuration parser was not prepared to see string
+ valued variables misspelled as boolean and segfaulted.
+
+ * Temporary files left behind due to interrupted object
+ transfers were not cleaned up with "git prune".
+
+ * "git config --unset" was confused when the unset variables
+ were spelled with continuation lines in the config file.
+
+ * The merge message detection in "git cvsimport" did not catch
+ a message that began with "Merge...".
+
+ * "git status" suggests "git rm --cached" for unstaging the
+ earlier "git add" before the initial commit.
+
+ * "git status" output was incorrect during a partial commit.
+
+ * "git bisect" refused to start when the HEAD was detached.
+
+ * "git bisect" allowed a wildcard character in the commit
+ message expanded while writing its log file.
+
+ * Manual pages were not formatted correctly with docbook xsl
+ 1.72; added a workaround.
+
+ * "git-commit -C $tag" used to work but rewrite in C done in
+ 1.5.4 broke it. This was fixed in 1.5.4.1.
+
+ * An entry in the .gitattributes file that names a pattern in a
+ subdirectory of the directory it is in did not match
+ correctly (e.g. pattern "b/*.c" in "a/.gitattributes" should
+ match "a/b/foo.c" but it didn't). This was fixed in 1.5.4.1.
+
+ * Customized color specification was parsed incorrectly when
+ numeric color values are used. This was fixed in 1.5.4.1.
+
+ * http transport misbehaved when linked with curl-gnutls.
diff --git a/Documentation/RelNotes-1.5.4.3.txt b/Documentation/RelNotes-1.5.4.3.txt
new file mode 100644
index 000000000..b0fc67fb2
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.3.txt
@@ -0,0 +1,27 @@
+GIT v1.5.4.3 Release Notes
+==========================
+
+Fixes since v1.5.4.2
+--------------------
+
+ * RPM spec used to pull in everything with 'git'. This has been
+ changed so that 'git' package contains just the core parts,
+ and we now supply 'git-all' metapackage to slurp in everything.
+ This should match end user's expectation better.
+
+ * When some refs failed to update, git-push reported "failure"
+ which was unclear if some other refs were updated or all of
+ them failed atomically (the answer is the former). Reworded
+ the message to clarify this.
+
+ * "git clone" from a repository whose HEAD was misconfigured
+ did not set up the remote properly. Now it tries to do
+ better.
+
+ * Updated git-push documentation to clarify what "matching"
+ means, in order to reduce user confusion.
+
+ * Updated git-add documentation to clarify "add -u" operates in
+ the current subdirectory you are in, just like other commands.
+
+ * git-gui updates to work on OSX and Windows better.
diff --git a/Documentation/RelNotes-1.5.4.4.txt b/Documentation/RelNotes-1.5.4.4.txt
new file mode 100644
index 000000000..323c1a88c
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.4.txt
@@ -0,0 +1,66 @@
+GIT v1.5.4.4 Release Notes
+==========================
+
+Fixes since v1.5.4.3
+--------------------
+
+ * Building and installing with an overtight umask such as 077 made
+ installed templates unreadable by others, while the rest of the install
+ are done in a way that is friendly to umask 022.
+
+ * "git cvsexportcommit -w $cvsdir" misbehaved when GIT_DIR is set to a
+ relative directory.
+
+ * "git http-push" had an invalid memory access that could lead it to
+ segfault.
+
+ * When "git rebase -i" gave control back to the user for a commit that is
+ marked to be edited, it just said "modify it with commit --amend",
+ without saying what to do to continue after modifying it. Give an
+ explicit instruction to run "rebase --continue" to be more helpful.
+
+ * "git send-email" in 1.5.4.3 issued a bogus empty In-Reply-To: header.
+
+ * "git bisect" showed mysterious "won't bisect on seeked tree" error message.
+ This was leftover from Cogito days to prevent "bisect" starting from a
+ cg-seeked state. We still keep the Cogito safety, but running "git bisect
+ start" when another bisect was in effect will clean up and start over.
+
+ * "git push" with an explicit PATH to receive-pack did not quite work if
+ receive-pack was not on usual PATH. We earlier fixed the same issue
+ with "git fetch" and upload-pack, but somehow forgot to do so in the
+ other direction.
+
+ * git-gui's info dialog was not displayed correctly when the user tries
+ to commit nothing (i.e. without staging anything).
+
+ * "git revert" did not properly fail when attempting to run with a
+ dirty index.
+
+ * "git merge --no-commit --no-ff <other>" incorrectly made commits.
+
+ * "git merge --squash --no-ff <other>", which is a nonsense combination
+ of options, was not rejected.
+
+ * "git ls-remote" and "git remote show" against an empty repository
+ failed, instead of just giving an empty result (regression).
+
+ * "git fast-import" did not handle a renamed path whose name needs to be
+ quoted, due to a bug in unquote_c_style() function.
+
+ * "git cvsexportcommit" was confused when multiple files with the same
+ basename needed to be pushed out in the same commit.
+
+ * "git daemon" did not send early errors to syslog.
+
+ * "git log --merge" did not work well with --left-right option.
+
+ * "git svn" prompted for client cert password every time it accessed the
+ server.
+
+ * The reset command in "git fast-import" data stream was documented to
+ end with an optional LF, but it actually required one.
+
+ * "git svn dcommit/rebase" did not honor --rewrite-root option.
+
+Also included are a handful documentation updates.
diff --git a/Documentation/RelNotes-1.5.4.5.txt b/Documentation/RelNotes-1.5.4.5.txt
new file mode 100644
index 000000000..bbd130e36
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.5.txt
@@ -0,0 +1,56 @@
+GIT v1.5.4.5 Release Notes
+==========================
+
+Fixes since v1.5.4.4
+--------------------
+
+ * "git fetch there" when the URL information came from the Cogito style
+ branches/there file did not update refs/heads/there (regression in
+ 1.5.4).
+
+ * Bogus refspec configuration such as "remote.there.fetch = =" were not
+ detected as errors (regression in 1.5.4).
+
+ * You couldn't specify a custom editor whose path contains a whitespace
+ via GIT_EDITOR (and core.editor).
+
+ * The subdirectory filter to "git filter-branch" mishandled a history
+ where the subdirectory becomes empty and then later becomes non-empty.
+
+ * "git shortlog" gave an empty line if the original commit message was
+ malformed (e.g. a botched import from foreign SCM). Now it finds the
+ first non-empty line and uses it for better information.
+
+ * When the user fails to give a revision parameter to "git svn", an error
+ from the Perl interpreter was issued because the script lacked proper
+ error checking.
+
+ * After "git rebase" stopped due to conflicts, if the user played with
+ "git reset" and friends, "git rebase --abort" failed to go back to the
+ correct commit.
+
+ * Additional work trees prepared with git-new-workdir (in contrib/) did
+ not share git-svn metadata directory .git/svn with the original.
+
+ * "git-merge-recursive" did not mark addition of the same path with
+ different filemodes correctly as a conflict.
+
+ * "gitweb" gave malformed URL when pathinfo stype paths are in use.
+
+ * "-n" stands for "--no-tags" again for "git fetch".
+
+ * "git format-patch" did not detect the need to add 8-bit MIME header
+ when the user used format.header configuration.
+
+ * "rev~" revision specifier used to mean "rev", which was inconsistent
+ with how "rev^" worked. Now "rev~" is the same as "rev~1" (hence it
+ also is the same as "rev^1"), and "rev~0" is the same as "rev^0"
+ (i.e. it has to be a commit).
+
+ * "git quiltimport" did not grok empty lines, lines in "file -pNNN"
+ format to specify the prefix levels and lines with trailing comments.
+
+ * "git rebase -m" triggered pre-commit verification, which made
+ "rebase --continue" impossible.
+
+As usual, it also comes with many documentation fixes and clarifications.
diff --git a/Documentation/RelNotes-1.5.4.6.txt b/Documentation/RelNotes-1.5.4.6.txt
new file mode 100644
index 000000000..3e3c3e55a
--- /dev/null
+++ b/Documentation/RelNotes-1.5.4.6.txt
@@ -0,0 +1,43 @@
+GIT v1.5.4.6 Release Notes
+==========================
+
+I personally do not think there is any reason anybody should want to
+run v1.5.4.X series these days, because 'master' version is always
+more stable than any tagged released version of git.
+
+This is primarily to futureproof "git-shell" to accept requests
+without a dash between "git" and subcommand name (e.g. "git
+upload-pack") which the newer client will start to make sometime in
+the future.
+
+Fixes since v1.5.4.5
+--------------------
+
+ * Command line option "-n" to "git-repack" was not correctly parsed.
+
+ * Error messages from "git-apply" when the patchfile cannot be opened
+ have been improved.
+
+ * Error messages from "git-bisect" when given nonsense revisions have
+ been improved.
+
+ * reflog syntax that uses time e.g. "HEAD@{10 seconds ago}:path" did not
+ stop parsing at the closing "}".
+
+ * "git rev-parse --symbolic-full-name ^master^2" printed solitary "^",
+ but it should print nothing.
+
+ * "git apply" did not enforce "match at the beginning" correctly.
+
+ * a path specification "a/b" in .gitattributes file should not match
+ "sub/a/b", but it did.
+
+ * "git log --date-order --topo-order" did not override the earlier
+ date-order with topo-order as expected.
+
+ * "git fast-export" did not export octopus merges correctly.
+
+ * "git archive --prefix=$path/" mishandled gitattributes.
+
+As usual, it also comes with many documentation fixes and clarifications.
+
diff --git a/Documentation/RelNotes-1.5.4.txt b/Documentation/RelNotes-1.5.4.txt
index 9c864c9de..f1323b617 100644
--- a/Documentation/RelNotes-1.5.4.txt
+++ b/Documentation/RelNotes-1.5.4.txt
@@ -10,22 +10,32 @@ Removal
* As git-commit and git-status have been rewritten, "git runstatus"
helper script lost all its users and has been removed.
- * Curl library older than 7.10 is not supported by "git http-push",
- as it does not work without CURLM.
+
+Temporarily disabled
+--------------------
+
+ * "git http-push" is known not to work well with cURL library older
+ than 7.16, and we had reports of repository corruption. It is
+ disabled on such platforms for now. Unfortunately, 1.5.3.8 shares
+ the same issue. In other words, this does not mean you will be
+ fine if you stick to an older git release. For now, please do not
+ use http-push from older git with cURL older than 7.16 if you
+ value your data. A proper fix will hopefully materialize in
+ later versions.
Deprecation notices
-------------------
- * The next feature release of git (this change is scheduled for v1.6.0)
- will by default install dashed form of commands (e.g. "git-commit")
- outside of users' normal $PATH, and will install only selected
- commands ("git" itself, and "gitk") in $PATH. This implies:
+ * From v1.6.0, git will by default install dashed form of commands
+ (e.g. "git-commit") outside of users' normal $PATH, and will install
+ only selected commands ("git" itself, and "gitk") in $PATH. This
+ implies:
- Using dashed forms of git commands (e.g. "git-commit") from the
command line has been informally deprecated since early 2006, but
now it officially is, and will be removed in the future. Use
- dashless forms (e.g. "git commit") instead.
+ dash-less forms (e.g. "git commit") instead.
- Using dashed forms from your scripts, without first prepending the
return value from "git --exec-path" to the scripts' PATH, has been
@@ -34,8 +44,8 @@ Deprecation notices
- Use of dashed forms with "PATH=$(git --exec-path):$PATH; export
PATH" early in your script is not deprecated with this change.
- Users are strongly encouraged to adjust their habits and scripts now
- to prepare for this.
+ Users are strongly encouraged to adjust their habits and scripts now
+ to prepare for this change.
* The post-receive hook was introduced in March 2007 to supersede
the post-update hook, primarily to overcome the command line length
@@ -70,7 +80,7 @@ Updates since v1.5.3
* Comes with much improved gitk, with i18n.
- * Comes with "git gui" 0.9.1 with i18n.
+ * Comes with git-gui 0.9.2 with i18n.
* gitk is now merged as a subdirectory of git.git project, in
preparation for its i18n.
@@ -156,7 +166,7 @@ Updates since v1.5.3
command line in the generated log message, when told to cherry-pick a
commit by naming a tag that points at it. It does not anymore.
- * "git for-each-ref" learned %(xxxdate:<dateformat>) syntax to show the
+ * "git for-each-ref" learned %(xxxdate:<date-format>) syntax to show the
various date fields in different formats.
* "git gc --auto" is a low-impact way to automatically run a variant of
@@ -211,7 +221,7 @@ Updates since v1.5.3
* "git pull --rebase" is a different way to integrate what you fetched
into your current branch.
- * "git fast-export" produces datastream that can be fed to fast-import
+ * "git fast-export" produces data-stream that can be fed to fast-import
to reproduce the history recorded in a git repository.
* "git add -i" takes pathspecs to limit the set of files to work on.
@@ -232,8 +242,8 @@ Updates since v1.5.3
from its first parent.
* "git commit" used to unconditionally strip comment lines that
- began with '#' and removed excess blank lines. This
- behaviour has been made configurable.
+ began with '#' and removed excess blank lines. This behavior has
+ been made configurable.
* "git commit" has been rewritten in C.
@@ -317,7 +327,7 @@ Updates since v1.5.3
* "git status" from a subdirectory now shows relative paths, which
makes copy-and-pasting for git-checkout/git-add/git-rm easier. The
- traditional behaviour to show the full path relative to the top of
+ traditional behavior to show the full path relative to the top of
the work tree can be had by setting status.relativepaths
configuration variable to false.
@@ -332,7 +342,7 @@ Updates since v1.5.3
* "git help" learned "-w" option to show documentation in browsers.
- * In addition there are quite a few internal clean-ups. Notably
+ * In addition there are quite a few internal clean-ups. Notably:
- many fork/exec have been replaced with run-command API,
brought from the msysgit effort.
@@ -341,6 +351,7 @@ Updates since v1.5.3
- enhancement and more use of the strbuf API.
+ * Makefile tweaks to support HP-UX is in.
Fixes since v1.5.3
------------------
@@ -354,7 +365,7 @@ series.
* The way "git diff --check" behaves is much more consistent with the way
"git apply --whitespace=warn" works.
- * "git svn" talking with the SVN over http will correctly quote branch
+ * "git svn" talking with the SVN over HTTP will correctly quote branch
and project names.
* "git config" did not work correctly on platforms that define
@@ -364,9 +375,3 @@ series.
documentation; a workaround has been implemented.
* "git diff --color-words" colored context lines in a wrong color.
-
---
-exec >/var/tmp/1
-O=v1.5.4-rc4
-echo O=`git describe refs/heads/master`
-git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
diff --git a/Documentation/RelNotes-1.5.5.1.txt b/Documentation/RelNotes-1.5.5.1.txt
new file mode 100644
index 000000000..7de419708
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.1.txt
@@ -0,0 +1,44 @@
+GIT v1.5.5.1 Release Notes
+==========================
+
+Fixes since v1.5.5
+------------------
+
+ * "git archive --prefix=$path/" mishandled gitattributes.
+
+ * "git fetch -v" that fetches into FETCH_HEAD did not report the summary
+ the same way as done for updating the tracking refs.
+
+ * "git svn" misbehaved when the configuration file customized the "git
+ log" output format using format.pretty.
+
+ * "git submodule status" leaked an unnecessary error message.
+
+ * "git log --date-order --topo-order" did not override the earlier
+ date-order with topo-order as expected.
+
+ * "git bisect good $this" did not check the validity of the revision
+ given properly.
+
+ * "url.<there>.insteadOf" did not work correctly.
+
+ * "git clean" ran inside subdirectory behaved as if the directory was
+ explicitly specified for removal by the end user from the top level.
+
+ * "git bisect" from a detached head leaked an unnecessary error message.
+
+ * "git bisect good $a $b" when $a is Ok but $b is bogus should have
+ atomically failed before marking $a as good.
+
+ * "git fmt-merge-msg" did not clean up leading empty lines from commit
+ log messages like "git log" family does.
+
+ * "git am" recorded a commit with empty Subject: line without
+ complaining.
+
+ * when given a commit log message whose first paragraph consists of
+ multiple lines, "git rebase" squashed it into a single line.
+
+ * "git remote add $bogus_name $url" did not complain properly.
+
+Also comes with various documentation updates.
diff --git a/Documentation/RelNotes-1.5.5.2.txt b/Documentation/RelNotes-1.5.5.2.txt
new file mode 100644
index 000000000..391a7b02e
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.2.txt
@@ -0,0 +1,27 @@
+GIT v1.5.5.2 Release Notes
+==========================
+
+Fixes since v1.5.5.1
+--------------------
+
+ * "git repack -n" was mistakenly made no-op earlier.
+
+ * "git imap-send" wanted to always have imap.host even when use of
+ imap.tunnel made it unnecessary.
+
+ * reflog syntax that uses time e.g. "HEAD@{10 seconds ago}:path" did not
+ stop parsing at the closing "}".
+
+ * "git rev-parse --symbolic-full-name ^master^2" printed solitary "^",
+ but it should print nothing.
+
+ * "git commit" did not detect when it failed to write tree objects.
+
+ * "git fetch" sometimes transferred too many objects unnecessarily.
+
+ * a path specification "a/b" in .gitattributes file should not match
+ "sub/a/b".
+
+ * various gitweb fixes.
+
+Also comes with various documentation updates.
diff --git a/Documentation/RelNotes-1.5.5.3.txt b/Documentation/RelNotes-1.5.5.3.txt
new file mode 100644
index 000000000..f22f98b73
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.3.txt
@@ -0,0 +1,12 @@
+GIT v1.5.5.3 Release Notes
+==========================
+
+Fixes since v1.5.5.2
+--------------------
+
+ * "git send-email --compose" did not notice that non-ascii contents
+ needed some MIME magic.
+
+ * "git fast-export" did not export octopus merges correctly.
+
+Also comes with various documentation updates.
diff --git a/Documentation/RelNotes-1.5.5.4.txt b/Documentation/RelNotes-1.5.5.4.txt
new file mode 100644
index 000000000..2d0279ecc
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.4.txt
@@ -0,0 +1,7 @@
+GIT v1.5.5.4 Release Notes
+==========================
+
+Fixes since v1.5.5.4
+--------------------
+
+ * "git name-rev --all" used to segfault.
diff --git a/Documentation/RelNotes-1.5.5.5.txt b/Documentation/RelNotes-1.5.5.5.txt
new file mode 100644
index 000000000..30fa3615c
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.5.txt
@@ -0,0 +1,11 @@
+GIT v1.5.5.5 Release Notes
+==========================
+
+I personally do not think there is any reason anybody should want to
+run v1.5.5.X series these days, because 'master' version is always
+more stable than any tagged released version of git.
+
+This is primarily to futureproof "git-shell" to accept requests
+without a dash between "git" and subcommand name (e.g. "git
+upload-pack") which the newer client will start to make sometime in
+the future.
diff --git a/Documentation/RelNotes-1.5.5.txt b/Documentation/RelNotes-1.5.5.txt
new file mode 100644
index 000000000..293221248
--- /dev/null
+++ b/Documentation/RelNotes-1.5.5.txt
@@ -0,0 +1,207 @@
+GIT v1.5.5 Release Notes
+========================
+
+Updates since v1.5.4
+--------------------
+
+(subsystems)
+
+ * Comes with git-gui 0.10.1
+
+(portability)
+
+ * We shouldn't ask for BSD group ownership semantics by setting g+s bit
+ on directories on older BSD systems that refuses chmod() by non root
+ users. BSD semantics is the default there anyway.
+
+ * Bunch of portability improvement patches coming from an effort to port
+ to Solaris has been applied.
+
+(performance)
+
+ * On platforms with suboptimal qsort(3) implementation, there
+ is an option to use more reasonable substitute we ship with
+ our software.
+
+ * New configuration variable "pack.packsizelimit" can be used
+ in place of command line option --max-pack-size.
+
+ * "git fetch" over the native git protocol used to make a
+ connection to find out the set of current remote refs and
+ another to actually download the pack data. We now use only
+ one connection for these tasks.
+
+ * "git commit" does not run lstat(2) more than necessary
+ anymore.
+
+(usability, bells and whistles)
+
+ * Bash completion script (in contrib) are aware of more commands and
+ options.
+
+ * You can be warned when core.autocrlf conversion is applied in
+ such a way that results in an irreversible conversion.
+
+ * A catch-all "color.ui" configuration variable can be used to
+ enable coloring of all color-capable commands, instead of
+ individual ones such as "color.status" and "color.branch".
+
+ * The commands refused to take absolute pathnames where they
+ require pathnames relative to the work tree or the current
+ subdirectory. They now can take absolute pathnames in such a
+ case as long as the pathnames do not refer outside of the
+ work tree. E.g. "git add $(pwd)/foo" now works.
+
+ * Error messages used to be sent to stderr, only to get hidden,
+ when $PAGER was in use. They now are sent to stdout along
+ with the command output to be shown in the $PAGER.
+
+ * A pattern "foo/" in .gitignore file now matches a directory
+ "foo". Pattern "foo" also matches as before.
+
+ * bash completion's prompt helper function can talk about
+ operation in-progress (e.g. merge, rebase, etc.).
+
+ * Configuration variables "url.<usethis>.insteadof = <otherurl>" can be
+ used to tell "git-fetch" and "git-push" to use different URL than what
+ is given from the command line.
+
+ * "git add -i" behaves better even before you make an initial commit.
+
+ * "git am" refused to run from a subdirectory without a good reason.
+
+ * After "git apply --whitespace=fix" fixes whitespace errors in a patch,
+ a line before the fix can appear as a context or preimage line in a
+ later patch, causing the patch not to apply. The command now knows to
+ see through whitespace fixes done to context lines to successfully
+ apply such a patch series.
+
+ * "git branch" (and "git checkout -b") to branch from a local branch can
+ optionally set "branch.<name>.merge" to mark the new branch to build on
+ the other local branch, when "branch.autosetupmerge" is set to
+ "always", or when passing the command line option "--track" (this option
+ was ignored when branching from local branches). By default, this does
+ not happen when branching from a local branch.
+
+ * "git checkout" to switch to a branch that has "branch.<name>.merge" set
+ (i.e. marked to build on another branch) reports how much the branch
+ and the other branch diverged.
+
+ * When "git checkout" has to update a lot of paths, it used to be silent
+ for 4 seconds before it showed any progress report. It is now a bit
+ more impatient and starts showing progress report early.
+
+ * "git commit" learned a new hook "prepare-commit-msg" that can
+ inspect what is going to be committed and prepare the commit
+ log message template to be edited.
+
+ * "git cvsimport" can now take more than one -M options.
+
+ * "git describe" learned to limit the tags to be used for
+ naming with --match option.
+
+ * "git describe --contains" now barfs when the named commit
+ cannot be described.
+
+ * "git describe --exact-match" describes only commits that are tagged.
+
+ * "git describe --long" describes a tagged commit as $tag-0-$sha1,
+ instead of just showing the exact tagname.
+
+ * "git describe" warns when using a tag whose name and path contradict
+ with each other.
+
+ * "git diff" learned "--relative" option to limit and output paths
+ relative to the current directory when working in a subdirectory.
+
+ * "git diff" learned "--dirstat" option to show birds-eye-summary of
+ changes more concisely than "--diffstat".
+
+ * "git format-patch" learned --cover-letter option to generate a cover
+ letter template.
+
+ * "git gc" learned --quiet option.
+
+ * "git gc" now automatically prunes unreachable objects that are two
+ weeks old or older.
+
+ * "git gc --auto" can be disabled more easily by just setting gc.auto
+ to zero. It also tolerates more packfiles by default.
+
+ * "git grep" now knows "--name-only" is a synonym for the "-l" option.
+
+ * "git help <alias>" now reports "'git <alias>' is alias to <what>",
+ instead of saying "No manual entry for git-<alias>".
+
+ * "git help" can use different backends to show manual pages and this can
+ be configured using "man.viewer" configuration.
+
+ * "gitk" does not restore window position from $HOME/.gitk anymore (it
+ still restores the size).
+
+ * "git log --grep=<what>" learned "--fixed-strings" option to look for
+ <what> without treating it as a regular expression.
+
+ * "git gui" learned an auto-spell checking.
+
+ * "git push <somewhere> HEAD" and "git push <somewhere> +HEAD" works as
+ expected; they push the current branch (and only the current branch).
+ In addition, HEAD can be written as the value of "remote.<there>.push"
+ configuration variable.
+
+ * When the configuration variable "pack.threads" is set to 0, "git
+ repack" auto detects the number of CPUs and uses that many threads.
+
+ * "git send-email" learned to prompt for passwords
+ interactively.
+
+ * "git send-email" learned an easier way to suppress CC
+ recipients.
+
+ * "git stash" learned "pop" command, that applies the latest stash and
+ removes it from the stash, and "drop" command to discard the named
+ stash entry.
+
+ * "git submodule" learned a new subcommand "summary" to show the
+ symmetric difference between the HEAD version and the work tree version
+ of the submodule commits.
+
+ * Various "git cvsimport", "git cvsexportcommit", "git cvsserver",
+ "git svn" and "git p4" improvements.
+
+(internal)
+
+ * Duplicated code between git-help and git-instaweb that
+ launches user's preferred browser has been refactored.
+
+ * It is now easier to write test scripts that records known
+ breakages.
+
+ * "git checkout" is rewritten in C.
+
+ * "git remote" is rewritten in C.
+
+ * Two conflict hunks that are separated by a very short span of common
+ lines are now coalesced into one larger hunk, to make the result easier
+ to read.
+
+ * Run-command API's use of file descriptors is documented clearer and
+ is more consistent now.
+
+ * diff output can be sent to FILE * that is different from stdout. This
+ will help reimplementing more things in C.
+
+Fixes since v1.5.4
+------------------
+
+All of the fixes in v1.5.4 maintenance series are included in
+this release, unless otherwise noted.
+
+ * "git-http-push" did not allow deletion of remote ref with the usual
+ "push <remote> :<branch>" syntax.
+
+ * "git-rebase --abort" did not go back to the right location if
+ "git-reset" was run during the "git-rebase" session.
+
+ * "git imap-send" without setting imap.host did not error out but
+ segfaulted.
diff --git a/Documentation/RelNotes-1.5.6.1.txt b/Documentation/RelNotes-1.5.6.1.txt
new file mode 100644
index 000000000..4864b1644
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.1.txt
@@ -0,0 +1,28 @@
+GIT v1.5.6.1 Release Notes
+==========================
+
+Fixes since v1.5.6
+------------------
+
+* Last minute change broke loose object creation on AIX.
+
+* (performance fix) We used to make $GIT_DIR absolute path early in the
+ programs but keeping it relative to the current directory internally
+ gives 1-3 per-cent performance boost.
+
+* bash completion knows the new --graph option to git-log family.
+
+
+* git-diff -c/--cc showed unnecessary "deletion" lines at the context
+ boundary.
+
+* git-for-each-ref ignored %(object) and %(type) requests for tag
+ objects.
+
+* git-merge usage had a typo.
+
+* Rebuilding of git-svn metainfo database did not take rewriteRoot
+ option into account.
+
+* Running "git-rebase --continue/--skip/--abort" before starting a
+ rebase gave nonsense error messages.
diff --git a/Documentation/RelNotes-1.5.6.2.txt b/Documentation/RelNotes-1.5.6.2.txt
new file mode 100644
index 000000000..5902a85a7
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.2.txt
@@ -0,0 +1,40 @@
+GIT v1.5.6.2 Release Notes
+==========================
+
+Futureproof
+-----------
+
+ * "git-shell" accepts requests without a dash between "git" and
+ subcommand name (e.g. "git upload-pack") which the newer client will
+ start to make sometime in the future.
+
+Fixes since v1.5.6.1
+--------------------
+
+* "git clone" from a remote that is named with url.insteadOf setting in
+ $HOME/.gitconfig did not work well.
+
+* "git describe --long --tags" segfaulted when the described revision was
+ tagged with a lightweight tag.
+
+* "git diff --check" did not report the result via its exit status
+ reliably.
+
+* When remote side used to have branch 'foo' and git-fetch finds that now
+ it has branch 'foo/bar', it refuses to lose the existing remote tracking
+ branch and its reflog. The error message has been improved to suggest
+ pruning the remote if the user wants to proceed and get the latest set
+ of branches from the remote, including such 'foo/bar'.
+
+* "git reset file" should mean the same thing as "git reset HEAD file",
+ but we required disambiguating -- even when "file" is not ambiguous.
+
+* "git show" segfaulted when an annotated tag that points at another
+ annotated tag was given to it.
+
+* Optimization for a large import via "git-svn" introduced in v1.5.6 had a
+ serious memory and temporary file leak, which made it unusable for
+ moderately large import.
+
+* "git-svn" mangled remote nickname used in the configuration file
+ unnecessarily.
diff --git a/Documentation/RelNotes-1.5.6.3.txt b/Documentation/RelNotes-1.5.6.3.txt
new file mode 100644
index 000000000..942611299
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.3.txt
@@ -0,0 +1,52 @@
+GIT v1.5.6.3 Release Notes
+==========================
+
+Fixes since v1.5.6.2
+--------------------
+
+* Setting core.sharerepository to traditional "true" value was supposed to make
+ the repository group writable but should not affect permission for others.
+ However, since 1.5.6, it was broken to drop permission for others when umask is
+ 022, making the repository unreadable by others.
+
+* Setting GIT_TRACE will report spawning of external process via run_command().
+
+* Using an object with very deep delta chain pinned memory needed for extracting
+ intermediate base objects unnecessarily long, leading to excess memory usage.
+
+* Bash completion script did not notice '--' marker on the command
+ line and tried the relatively slow "ref completion" even when
+ completing arguments after one.
+
+* Registering a non-empty blob racily and then truncating the working
+ tree file for it confused "racy-git avoidance" logic into thinking
+ that the path is now unchanged.
+
+* The section that describes attributes related to git-archive were placed
+ in a wrong place in the gitattributes(5) manual page.
+
+* "git am" was not helpful to the users when it detected that the committer
+ information is not set up properly yet.
+
+* "git clone" had a leftover debugging fprintf().
+
+* "git clone -q" was not quiet enough as it used to and gave object count
+ and progress reports.
+
+* "git clone" marked downloaded packfile with .keep; this could be a
+ good thing if the remote side is well packed but otherwise not,
+ especially for a project that is not really big.
+
+* "git daemon" used to call syslog() from a signal handler, which
+ could raise signals of its own but generally is not reentrant. This
+ was fixed by restructuring the code to report syslog() after the handler
+ returns.
+
+* When "git push" tries to remove a remote ref, and corresponding
+ tracking ref is missing, we used to report error (i.e. failure to
+ remove something that does not exist).
+
+* "git mailinfo" (hence "git am") did not handle commit log messages in a
+ MIME multipart mail correctly.
+
+Contains other various documentation fixes.
diff --git a/Documentation/RelNotes-1.5.6.4.txt b/Documentation/RelNotes-1.5.6.4.txt
new file mode 100644
index 000000000..d8968f1ec
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.4.txt
@@ -0,0 +1,47 @@
+GIT v1.5.6.4 Release Notes
+==========================
+
+Fixes since v1.5.6.3
+--------------------
+
+* Various commands could overflow its internal buffer on a platform
+ with small PATH_MAX value in a repository that has contents with
+ long pathnames.
+
+* There wasn't a way to make --pretty=format:%<> specifiers to honor
+ .mailmap name rewriting for authors and committers. Now you can with
+ %aN and %cN.
+
+* Bash completion wasted too many cycles; this has been optimized to be
+ usable again.
+
+* Bash completion lost ref part when completing something like "git show
+ pu:Makefile".
+
+* "git-cvsserver" did not clean up its temporary working area after annotate
+ request.
+
+* "git-daemon" called syslog() from its signal handler, which was a
+ no-no.
+
+* "git-fetch" into an empty repository used to remind that the fetch will
+ be huge by saying "no common commits", but this was an unnecessary
+ noise; it is already known by the user anyway.
+
+* "git-http-fetch" would have segfaulted when pack idx file retrieved
+ from the other side was corrupt.
+
+* "git-index-pack" used too much memory when dealing with a deep delta chain.
+
+* "git-mailinfo" (hence "git-am") did not correctly handle in-body [PATCH]
+ line to override the commit title taken from the mail Subject header.
+
+* "git-rebase -i -p" lost parents that are not involved in the history
+ being rewritten.
+
+* "git-rm" lost track of where the index file was when GIT_DIR was
+ specified as a relative path.
+
+* "git-rev-list --quiet" was not quiet as advertised.
+
+Contains other various documentation fixes.
diff --git a/Documentation/RelNotes-1.5.6.5.txt b/Documentation/RelNotes-1.5.6.5.txt
new file mode 100644
index 000000000..47ca17246
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.5.txt
@@ -0,0 +1,29 @@
+GIT v1.5.6.5 Release Notes
+==========================
+
+Fixes since v1.5.6.4
+--------------------
+
+* "git cvsimport" used to spit out "UNKNOWN LINE..." diagnostics to stdout.
+
+* "git commit -F filename" and "git tag -F filename" run from subdirectories
+ did not read the right file.
+
+* "git init --template=" with blank "template" parameter linked files
+ under root directories to .git, which was a total nonsense. Instead, it
+ means "I do not want to use anything from the template directory".
+
+* "git diff-tree" and other diff plumbing ignored diff.renamelimit configuration
+ variable when the user explicitly asked for rename detection.
+
+* "git name-rev --name-only" did not work when "--stdin" option was in effect.
+
+* "git show-branch" mishandled its 8th branch.
+
+* Addition of "git update-index --ignore-submodules" that happened during
+ 1.5.6 cycle broke "git update-index --ignore-missing".
+
+* "git send-email" did not parse charset from an existing Content-type:
+ header properly.
+
+Contains other various documentation fixes.
diff --git a/Documentation/RelNotes-1.5.6.txt b/Documentation/RelNotes-1.5.6.txt
new file mode 100644
index 000000000..e143d8d61
--- /dev/null
+++ b/Documentation/RelNotes-1.5.6.txt
@@ -0,0 +1,115 @@
+GIT v1.5.6 Release Notes
+========================
+
+Updates since v1.5.5
+--------------------
+
+(subsystems)
+
+* Comes with updated gitk and git-gui.
+
+(portability)
+
+* git will build on AIX better than before now.
+
+* core.ignorecase configuration variable can be used to work better on
+ filesystems that are not case sensitive.
+
+* "git init" now autodetects the case sensitivity of the filesystem and
+ sets core.ignorecase accordingly.
+
+* cpio is no longer used; neither "curl" binary (libcurl is still used).
+
+(documentation)
+
+* Many freestanding documentation pages have been converted and made
+ available to "git help" (aka "man git<something>") as section 7 of
+ the manual pages. This means bookmarks to some HTML documentation
+ files may need to be updated (eg "tutorial.html" became
+ "gittutorial.html").
+
+(performance)
+
+* "git clone" was rewritten in C. This will hopefully help cloning a
+ repository with insane number of refs.
+
+* "git rebase --onto $there $from $branch" used to switch to the tip of
+ $branch only to immediately reset back to $from, smudging work tree
+ files unnecessarily. This has been optimized.
+
+* Object creation codepath in "git-svn" has been optimized by enhancing
+ plumbing commands git-cat-file and git-hash-object.
+
+(usability, bells and whistles)
+
+* "git add -p" (and the "patch" subcommand of "git add -i") can choose to
+ apply (or not apply) mode changes independently from contents changes.
+
+* "git bisect help" gives longer and more helpful usage information.
+
+* "git bisect" does not use a special branch "bisect" anymore; instead, it
+ does its work on a detached HEAD.
+
+* "git branch" (and "git checkout -b") can be told to set up
+ branch.<name>.rebase automatically, so that later you can say "git pull"
+ and magically cause "git pull --rebase" to happen.
+
+* "git branch --merged" and "git branch --no-merged" can be used to list
+ branches that have already been merged (or not yet merged) to the
+ current branch.
+
+* "git cherry-pick" and "git revert" can add a sign-off.
+
+* "git commit" mentions the author identity when you are committing
+ somebody else's changes.
+
+* "git diff/log --dirstat" output is consistent between binary and textual
+ changes.
+
+* "git filter-branch" rewrites signed tags by demoting them to annotated.
+
+* "git format-patch --no-binary" can produce a patch that lack binary
+ changes (i.e. cannot be used to propagate the whole changes) meant only
+ for reviewing.
+
+* "git init --bare" is a synonym for "git --bare init" now.
+
+* "git gc --auto" honors a new pre-auto-gc hook to temporarily disable it.
+
+* "git log --pretty=tformat:<custom format>" gives a LF after each entry,
+ instead of giving a LF between each pair of entries which is how
+ "git log --pretty=format:<custom format>" works.
+
+* "git log" and friends learned the "--graph" option to show the ancestry
+ graph at the left margin of the output.
+
+* "git log" and friends can be told to use date format that is different
+ from the default via 'log.date' configuration variable.
+
+* "git send-email" now can send out messages outside a git repository.
+
+* "git send-email --compose" was made aware of rfc2047 quoting.
+
+* "git status" can optionally include output from "git submodule
+ summary".
+
+* "git svn" learned --add-author-from option to propagate the authorship
+ by munging the commit log message.
+
+* new object creation and looking up in "git svn" has been optimized.
+
+* "gitweb" can read from a system-wide configuration file.
+
+(internal)
+
+* "git unpack-objects" and "git receive-pack" is now more strict about
+ detecting breakage in the objects they receive over the wire.
+
+
+Fixes since v1.5.5
+------------------
+
+All of the fixes in v1.5.5 maintenance series are included in
+this release, unless otherwise noted.
+
+And there are too numerous small fixes to otherwise note here ;-)
diff --git a/Documentation/RelNotes-1.6.0.txt b/Documentation/RelNotes-1.6.0.txt
new file mode 100644
index 000000000..de7ef166b
--- /dev/null
+++ b/Documentation/RelNotes-1.6.0.txt
@@ -0,0 +1,258 @@
+GIT v1.6.0 Release Notes
+========================
+
+User visible changes
+--------------------
+
+With the default Makefile settings, most of the programs are now
+installed outside your $PATH, except for "git", "gitk" and
+some server side programs that need to be accessible for technical
+reasons. Invoking a git subcommand as "git-xyzzy" from the command
+line has been deprecated since early 2006 (and officially announced in
+1.5.4 release notes); use of them from your scripts after adding
+output from "git --exec-path" to the $PATH is still supported in this
+release, but users are again strongly encouraged to adjust their
+scripts to use "git xyzzy" form, as we will stop installing
+"git-xyzzy" hardlinks for built-in commands in later releases.
+
+An earlier change to page "git status" output was overwhelmingly unpopular
+and has been reverted.
+
+Source changes needed for porting to MinGW environment are now all in the
+main git.git codebase.
+
+By default, packfiles created with this version uses delta-base-offset
+encoding introduced in v1.4.4. Pack idx files are using version 2 that
+allows larger packs and added robustness thanks to its CRC checking,
+introduced in v1.5.2 and v1.4.4.5. If you want to keep your repositories
+backwards compatible past these versions, set repack.useDeltaBaseOffset
+to false or pack.indexVersion to 1, respectively.
+
+We used to prevent sample hook scripts shipped in templates/ from
+triggering by default by relying on the fact that we install them as
+unexecutable, but on some filesystems, this approach does not work.
+They are now shipped with ".sample" suffix. If you want to activate
+any of these samples as-is, rename them to drop the ".sample" suffix,
+instead of running "chmod +x" on them. For example, you can rename
+hooks/post-update.sample to hooks/post-update to enable the sample
+hook that runs update-server-info, in order to make repositories
+friendly to dumb protocols (i.e. HTTP).
+
+GIT_CONFIG, which was only documented as affecting "git config", but
+actually affected all git commands, now only affects "git config".
+GIT_LOCAL_CONFIG, also only documented as affecting "git config" and
+not different from GIT_CONFIG in a useful way, is removed.
+
+The ".dotest" temporary area "git am" and "git rebase" use is now moved
+inside the $GIT_DIR, to avoid mistakes of adding it to the project by
+accident.
+
+An ancient merge strategy "stupid" has been removed.
+
+
+Updates since v1.5.6
+--------------------
+
+(subsystems)
+
+* git-p4 in contrib learned "allowSubmit" configuration to control on
+ which branch to allow "submit" subcommand.
+
+* git-gui learned to stage changes per-line.
+
+(portability)
+
+* Changes for MinGW port have been merged, thanks to Johannes Sixt and
+ gangs.
+
+* Sample hook scripts shipped in templates/ are now suffixed with
+ *.sample.
+
+* perl's in-place edit (-i) does not work well without backup files on Windows;
+ some tests are rewritten to cope with this.
+
+(documentation)
+
+* Updated howto/update-hook-example
+
+* Got rid of usage of "git-foo" from the tutorial and made typography
+ more consistent.
+
+* Disambiguating "--" between revs and paths is finally documented.
+
+(performance, robustness, sanity etc.)
+
+* index-pack used too much memory when dealing with a deep delta chain.
+ This has been optimized.
+
+* reduced excessive inlining to shrink size of the "git" binary.
+
+* verify-pack checks the object CRC when using version 2 idx files.
+
+* When an object is corrupt in a pack, the object became unusable even
+ when the same object is available in a loose form, We now try harder to
+ fall back to these redundant objects when able. In particular, "git
+ repack -a -f" can be used to fix such a corruption as long as necessary
+ objects are available.
+
+* Performance of "git-blame -C -C" operation is vastly improved.
+
+* git-clone does not create refs in loose form anymore (it behaves as
+ if you immediately ran git-pack-refs after cloning). This will help
+ repositories with insanely large number of refs.
+
+* core.fsyncobjectfiles configuration can be used to ensure that the loose
+ objects created will be fsync'ed (this is only useful on filesystems
+ that does not order data writes properly).
+
+* "git commit-tree" plumbing can make Octopus with more than 16 parents.
+ "git commit" has been capable of this for quite some time.
+
+(usability, bells and whistles)
+
+* even more documentation pages are now accessible via "man" and "git help".
+
+* A new environment variable GIT_CEILING_DIRECTORIES can be used to stop
+ the discovery process of the toplevel of working tree; this may be useful
+ when you are working in a slow network disk and are outside any working tree,
+ as bash-completion and "git help" may still need to run in these places.
+
+* By default, stash entries never expire. Set reflogexpire in [gc
+ "refs/stash"] to a reasonable value to get traditional auto-expiration
+ behaviour back
+
+* Longstanding latency issue with bash completion script has been
+ addressed. This will need to be backmerged to 'maint' later.
+
+* pager.<cmd> configuration variable can be used to enable/disable the
+ default paging behaviour per command.
+
+* "git-add -i" has a new action 'e/dit' to allow you edit the patch hunk
+ manually.
+
+* git-am records the original tip of the branch in ORIG_HEAD before it
+ starts applying patches.
+
+* git-apply can handle a patch that touches the same path more than once
+ much better than before.
+
+* git-apply can be told not to trust the line counts recorded in the input
+ patch but recount, with the new --recount option.
+
+* git-apply can be told to apply a patch to a path deeper than what the
+ patch records with --directory option.
+
+* git-archive can be told to omit certain paths from its output using
+ export-ignore attributes.
+
+* git-archive uses the zlib default compression level when creating
+ zip archive.
+
+* git-archive's command line options --exec and --remote can take their
+ parameters as separate command line arguments, similar to other commands.
+ IOW, both "--exec=path" and "--exec path" are now supported.
+
+* With -v option, git-branch describes the remote tracking statistics
+ similar to the way git-checkout reports by how many commits your branch
+ is ahead/behind.
+
+* git-branch's --contains option used to always require a commit parameter
+ to limit the branches with; it now defaults to list branches that
+ contains HEAD if this parameter is omitted.
+
+* git-branch's --merged and --no-merged option used to always limit the
+ branches relative to the HEAD, but they can now take an optional commit
+ argument that is used in place of HEAD.
+
+* git-bundle can read the revision arguments from the standard input.
+
+* git-cherry-pick can replay a root commit now.
+
+* git-clone can clone from a remote whose URL would be rewritten by
+ configuration stored in $HOME/.gitconfig now.
+
+* "git-clone --mirror" is a handy way to set up a bare mirror repository.
+
+* git-cvsserver learned to respond to "cvs co -c".
+
+* git-diff --check now checks leftover merge conflict markers.
+
+* "git-diff -p" learned to grab a better hunk header lines in
+ BibTex, Pascal/Delphi, and Ruby files and also pays attention to
+ chapter and part boundary in TeX documents.
+
+* When remote side used to have branch 'foo' and git-fetch finds that now
+ it has branch 'foo/bar', it refuses to lose the existing remote tracking
+ branch and its reflog. The error message has been improved to suggest
+ pruning the remote if the user wants to proceed and get the latest set
+ of branches from the remote, including such 'foo/bar'.
+
+* fast-export learned to export and import marks file; this can be used to
+ interface with fast-import incrementally.
+
+* fast-import and fast-export learned to export and import gitlinks.
+
+* "gitk" left background process behind after being asked to dig very deep
+ history and the user killed the UI; the process is killed when the UI goes
+ away now.
+
+* git-rebase records the original tip of branch in ORIG_HEAD before it is
+ rewound.
+
+* "git rerere" can be told to update the index with auto-reused resolution
+ with rerere.autoupdate configuration variable.
+
+* git-rev-parse learned $commit^! and $commit^@ notations used in "log"
+ family. These notations are available in gitk as well, because the gitk
+ command internally uses rev-parse to interpret its arguments.
+
+* git-rev-list learned --children option to show child commits it
+ encountered during the traversal, instead of showing parent commits.
+
+* git-send-mail can talk not just over SSL but over TLS now.
+
+* git-shortlog honors custom output format specified with "--pretty=format:".
+
+* "git-stash save" learned --keep-index option. This lets you stash away the
+ local changes and bring the changes staged in the index to your working
+ tree for examination and testing.
+
+* git-stash also learned branch subcommand to create a new branch out of
+ stashed changes.
+
+* git-status gives the remote tracking statistics similar to the way
+ git-checkout reports by how many commits your branch is ahead/behind.
+
+* "git-svn dcommit" is now aware of auto-props setting the subversion user
+ has.
+
+* You can tell "git status -u" to even more aggressively omit checking
+ untracked files with --untracked-files=no.
+
+* Original SHA-1 value for "update-ref -d" is optional now.
+
+* Error codes from gitweb are made more descriptive where possible, rather
+ than "403 forbidden" as we used to issue everywhere.
+
+(internal)
+
+* git-merge has been reimplemented in C.
+
+
+Fixes since v1.5.6
+------------------
+
+All of the fixes in v1.5.6 maintenance series are included in
+this release, unless otherwise noted.
+
+ * git-clone ignored its -u option; the fix needs to be backported to
+ 'maint';
+
+ * git-mv used to lose the distinction between changes that are staged
+ and that are only in the working tree, by staging both in the index
+ after moving such a path.
+
+ * "git-rebase -i -p" rewrote the parents to wrong ones when amending
+ (either edit or squash) was involved, and did not work correctly
+ when fast forwarding.
+
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index de08d094e..841bead9d 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -34,9 +34,9 @@ Checklist (and a short version for the impatient):
- if your name is not writable in ASCII, make sure that
you send off a message in the correct encoding.
- send the patch to the list (git@vger.kernel.org) and the
- maintainer (gitster@pobox.com). If you use
- git-send-email(1), please test it first by sending
- email to yourself.
+ maintainer (gitster@pobox.com) if (and only if) the patch
+ is ready for inclusion. If you use git-send-email(1),
+ please test it first by sending email to yourself.
Long version:
@@ -112,7 +112,12 @@ lose tabs that way if you are not careful.
It is a common convention to prefix your subject line with
[PATCH]. This lets people easily distinguish patches from other
-e-mail discussions.
+e-mail discussions. Use of additional markers after PATCH and
+the closing bracket to mark the nature of the patch is also
+encouraged. E.g. [PATCH/RFC] is often used when the patch is
+not ready to be applied but it is for discussion, [PATCH v2],
+[PATCH v3] etc. are often seen when you are sending an update to
+what you have previously sent.
"git format-patch" command follows the best current practice to
format the body of an e-mail message. At the beginning of the
@@ -157,7 +162,8 @@ Note that your maintainer does not necessarily read everything
on the git mailing list. If your patch is for discussion first,
send it "To:" the mailing list, and optionally "cc:" him. If it
is trivially correct or after the list reached a consensus, send
-it "To:" the maintainer and optionally "cc:" the list.
+it "To:" the maintainer and optionally "cc:" the list for
+inclusion.
Also note that your maintainer does not actively involve himself in
maintaining what are in contrib/ hierarchy. When you send fixes and
@@ -210,10 +216,53 @@ then you just add a line saying
This line can be automatically added by git if you run the git-commit
command with the -s option.
-Some people also put extra tags at the end. They'll just be ignored for
-now, but you can do this to mark internal company procedures or just
-point out some special detail about the sign-off.
+Notice that you can place your own Signed-off-by: line when
+forwarding somebody else's patch with the above rules for
+D-C-O. Indeed you are encouraged to do so. Do not forget to
+place an in-body "From: " line at the beginning to properly attribute
+the change to its true author (see (2) above).
+Some people also put extra tags at the end.
+
+"Acked-by:" says that the patch was reviewed by the person who
+is more familiar with the issues and the area the patch attempts
+to modify. "Tested-by:" says the patch was tested by the person
+and found to have the desired effect.
+
+------------------------------------------------
+An ideal patch flow
+
+Here is an ideal patch flow for this project the current maintainer
+suggests to the contributors:
+
+ (0) You come up with an itch. You code it up.
+
+ (1) Send it to the list and cc people who may need to know about
+ the change.
+
+ The people who may need to know are the ones whose code you
+ are butchering. These people happen to be the ones who are
+ most likely to be knowledgeable enough to help you, but
+ they have no obligation to help you (i.e. you ask for help,
+ don't demand). "git log -p -- $area_you_are_modifying" would
+ help you find out who they are.
+
+ (2) You get comments and suggestions for improvements. You may
+ even get them in a "on top of your change" patch form.
+
+ (3) Polish, refine, and re-send to the list and the people who
+ spend their time to improve your patch. Go back to step (2).
+
+ (4) The list forms consensus that the last round of your patch is
+ good. Send it to the list and cc the maintainer.
+
+ (5) A topic branch is created with the patch and is merged to 'next',
+ and cooked further and eventually graduates to 'master'.
+
+In any time between the (2)-(3) cycle, the maintainer may pick it up
+from the list and queue it to 'pu', in order to make it easier for
+people play with it without having to pick up and apply the patch to
+their trees themselves.
------------------------------------------------
MUA specific hints
@@ -252,7 +301,7 @@ If it does not apply correctly, there can be various reasons.
patch appropriately.
* Your MUA corrupted your patch; "am" would complain that
- the patch does not apply. Look at .dotest/ subdirectory and
+ the patch does not apply. Look at .git/rebase-apply/ subdirectory and
see what 'patch' file contains and check for the common
corruption patterns mentioned above.
@@ -370,6 +419,11 @@ settings but I haven't tried, yet.
mail.identity.default.compose_html => false
mail.identity.id?.compose_html => false
+(Lukas Sandström)
+
+There is a script in contrib/thunderbird-patch-inline which can help
+you include patches with Thunderbird in an easy way. To use it, do the
+steps above and then use the script as the external editor.
Gnus
----
diff --git a/Documentation/asciidoc.conf b/Documentation/asciidoc.conf
index 10c1a151a..40d43b78e 100644
--- a/Documentation/asciidoc.conf
+++ b/Documentation/asciidoc.conf
@@ -8,6 +8,7 @@
# the command.
[attributes]
+asterisk=&#42;
plus=&#43;
caret=&#94;
startsb=&#91;
diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt
index ea1007bfb..5428111d7 100644
--- a/Documentation/blame-options.txt
+++ b/Documentation/blame-options.txt
@@ -41,7 +41,8 @@ of lines before or after the line given by <start>.
-S <revs-file>::
Use revs from revs-file instead of calling linkgit:git-rev-list[1].
--p, --porcelain::
+-p::
+--porcelain::
Show in a format designed for machine consumption.
--incremental::
@@ -52,7 +53,7 @@ of lines before or after the line given by <start>.
When <rev> is not specified, the command annotates the
changes starting backwards from the working tree copy.
This flag makes the command pretend as if the working
- tree copy has the contents of he named file (specify
+ tree copy has the contents of the named file (specify
`-` to make the command read from the standard input).
-M|<num>|::
@@ -83,5 +84,6 @@ alphanumeric characters that git must detect as moving
between files for it to associate those lines with the parent
commit.
--h, --help::
+-h::
+--help::
Show help message.
diff --git a/Documentation/cat-texi.perl b/Documentation/cat-texi.perl
index e3d8e9faa..dbc133cd3 100755
--- a/Documentation/cat-texi.perl
+++ b/Documentation/cat-texi.perl
@@ -11,7 +11,7 @@ while (<STDIN>) {
if (s/^\@top (.*)/\@node $1,,,Top/) {
push @menu, $1;
}
- s/\(\@pxref{\[URLS\]}\)//;
+ s/\(\@pxref{\[(URLS|REMOTES)\]}\)//;
print TMP;
}
close TMP;
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 877eda960..676c39bb8 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -63,7 +63,7 @@ The values following the equals sign in variable assign are all either
a string, an integer, or a boolean. Boolean values may be given as yes/no,
0/1 or true/false. Case is not significant in boolean values, when
converting value to the canonical form using '--bool' type specifier;
-`git-config` will ensure that the output is "true" or "false".
+'git-config' will ensure that the output is "true" or "false".
String values may be entirely or partially enclosed in double quotes.
You need to enclose variable value in double quotes if you want to
@@ -92,7 +92,7 @@ Example
# Our diff algorithm
[diff]
- external = "/usr/local/bin/gnu-diff -u"
+ external = /usr/local/bin/diff-wrapper
renames = true
[branch "devel"]
@@ -117,9 +117,16 @@ core.fileMode::
the working copy are ignored; useful on broken filesystems like FAT.
See linkgit:git-update-index[1]. True by default.
+core.trustctime::
+ If false, the ctime differences between the index and the
+ working copy are ignored; useful when the inode change time
+ is regularly modified by something outside Git (file system
+ crawlers and some backup systems).
+ See linkgit:git-update-index[1]. True by default.
+
core.quotepath::
- The commands that output paths (e.g. `ls-files`,
- `diff`), when not given the `-z` option, will quote
+ The commands that output paths (e.g. 'ls-files',
+ 'diff'), when not given the `-z` option, will quote
"unusual" characters in the pathname by enclosing the
pathname in a double-quote pair and with backslashes the
same way strings in C source code are quoted. If this
@@ -139,6 +146,51 @@ core.autocrlf::
"text" (i.e. be subjected to the autocrlf mechanism) is
decided purely based on the contents.
+core.safecrlf::
+ If true, makes git check if converting `CRLF` as controlled by
+ `core.autocrlf` is reversible. 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
+ irreversible conversion but continue the operation.
++
+CRLF conversion bears a slight chance of corrupting data.
+autocrlf=true 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
+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
+conversion can corrupt data.
++
+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
+appropriately.
++
+Unfortunately, the desired effect of cleaning up text files with
+mixed line endings and the undesired effect of corrupting binary
+files cannot be distinguished. In both cases CRLFs are removed
+in an irreversible way. For text files this is the right thing
+to do because CRLFs are line endings, while for binary files
+converting CRLFs corrupts data.
++
+Note, this safety check does not mean that a checkout will generate a
+file identical to the original file for a different setting of
+`core.autocrlf`, but only for the current one. For example, a text
+file with `LF` would be accepted with `core.autocrlf=input` and could
+later be checked out with `core.autocrlf=true`, in which case the
+resulting file would contain `CRLF`, although the original file
+contained `LF`. However, in both work trees the line endings would be
+consistent, that is either all `LF` or all `CRLF`, but never mixed. A
+file with mixed line endings would be reported by the `core.safecrlf`
+mechanism.
+
core.symlinks::
If false, symbolic links are checked out as small plain files that
contain the link text. linkgit:git-update-index[1] and
@@ -160,10 +212,13 @@ Can be overridden by the 'GIT_PROXY_COMMAND' environment variable
handling).
core.ignoreStat::
- The working copy files are assumed to stay unchanged until you
- mark them otherwise manually - Git will not detect the file changes
- by lstat() calls. This is useful on systems where those are very
- slow, such as Microsoft Windows. See linkgit:git-update-index[1].
+ If true, commands which modify both the working tree and the index
+ will mark the updated paths with the "assume unchanged" bit in the
+ index. These marked files are then assumed to stay unchanged in the
+ working copy, until you mark them otherwise manually - Git will not
+ detect the file changes by lstat() calls. This is useful on systems
+ where those are very slow, such as Microsoft Windows.
+ See linkgit:git-update-index[1].
False by default.
core.preferSymlinkRefs::
@@ -189,7 +244,13 @@ core.worktree::
used in combination with repositories found automatically in
a .git directory (i.e. $GIT_DIR is not set).
This can be overridden by the GIT_WORK_TREE environment
- variable and the '--work-tree' command line option.
+ variable and the '--work-tree' command line option. It can be
+ a absolute path or relative path to the directory specified by
+ --git-dir or GIT_DIR.
+ Note: If --git-dir or GIT_DIR are specified but none of
+ --work-tree, GIT_WORK_TREE and core.worktree is specified,
+ the current working directory is regarded as the top directory
+ of your working tree.
core.logAllRefUpdates::
Enable the reflog. Updates to a ref <ref> is logged to the file
@@ -216,7 +277,12 @@ core.sharedRepository::
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
- reported by umask(2). See linkgit:git-init[1]. False by default.
+ 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, and thus, users with a safe umask (0077) can use
+ this option. Examples: '0660' is equivalent to 'group'. '0640' is a
+ repository that is group-readable but not group-writable.
+ 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
@@ -297,9 +363,10 @@ core.pager::
core.whitespace::
A comma separated list of common whitespace problems to
- notice. `git diff` will use `color.diff.whitespace` to
- highlight them, and `git apply --whitespace=error` will
- consider them as errors:
+ notice. 'git-diff' will use `color.diff.whitespace` to
+ highlight them, and 'git-apply --whitespace=error' will
+ consider them as errors. You can prefix `-` to disable
+ any of them (e.g. `-trailing-space`):
+
* `trailing-space` treats trailing whitespaces at the end of the line
as an error (enabled by default).
@@ -308,6 +375,18 @@ core.whitespace::
error (enabled by default).
* `indent-with-non-tab` treats a line that is indented with 8 or more
space characters as an error (not enabled by default).
+* `cr-at-eol` treats a carriage-return at the end of line as
+ part of the line terminator, i.e. with it, `trailing-space`
+ does not trigger if the character before such a carriage-return
+ is not a whitespace (not enabled by default).
+
+core.fsyncobjectfiles::
+ This boolean will enable 'fsync()' when writing object files.
++
+This is a total waste of time and effort on a filesystem that orders
+data writes properly, but can be useful for filesystems that do not use
+journalling (traditional UNIX filesystems) or that only journal metadata
+and not file contents (OS X's HFS+, or Linux ext3 with "data=writeback").
alias.*::
Command aliases for the linkgit:git[1] command wrapper - e.g.
@@ -325,31 +404,50 @@ it will be treated as a shell command. For example, defining
"gitk --all --not ORIG_HEAD".
apply.whitespace::
- Tells `git-apply` how to handle whitespaces, in the same way
+ Tells 'git-apply' how to handle whitespaces, in the same way
as the '--whitespace' option. See linkgit:git-apply[1].
branch.autosetupmerge::
- Tells `git-branch` and `git-checkout` to setup new branches
- so that linkgit:git-pull[1] will appropriately merge from that
- remote branch. Note that even if this option is not set,
+ Tells 'git-branch' and 'git-checkout' to setup new branches
+ so that linkgit:git-pull[1] will appropriately merge from the
+ starting point branch. Note that even if this option is not set,
this behavior can be chosen per-branch using the `--track`
- and `--no-track` options. This option defaults to false.
+ and `--no-track` options. The valid settings are: `false` -- no
+ automatic setup is done; `true` -- automatic setup is done when the
+ starting point is a remote branch; `always` -- automatic setup is
+ done when the starting point is either a local branch or remote
+ branch. This option defaults to true.
+
+branch.autosetuprebase::
+ When a new branch is created with 'git-branch' or 'git-checkout'
+ 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
+ other local branches.
+ When `remote`, rebase is set to true for tracked branches of
+ remote branches.
+ When `always`, rebase will be set to true for all tracking
+ branches.
+ See "branch.autosetupmerge" for details on how to set up a
+ branch to track another branch.
+ This option defaults to never.
branch.<name>.remote::
- When in branch <name>, it tells `git fetch` which remote to fetch.
- If this option is not given, `git fetch` defaults to remote "origin".
+ When in branch <name>, it tells 'git-fetch' which remote to fetch.
+ If this option is not given, 'git-fetch' defaults to remote "origin".
branch.<name>.merge::
- When in branch <name>, it tells `git fetch` the default
+ When in branch <name>, it tells 'git-fetch' the default
refspec to be marked for merging in FETCH_HEAD. The value is
handled like the remote part of a refspec, and must match a
ref which is fetched from the remote given by
"branch.<name>.remote".
- The merge information is used by `git pull` (which at first calls
- `git fetch`) to lookup the default branch for merging. Without
- this option, `git pull` defaults to merge the first refspec fetched.
+ The merge information is used by 'git-pull' (which at first calls
+ 'git-fetch') to lookup the default branch for merging. Without
+ this option, 'git-pull' defaults to merge the first refspec fetched.
Specify multiple values to get an octopus merge.
- If you wish to setup `git pull` so that it merges into <name> from
+ If you wish to setup 'git-pull' so that it merges into <name> from
another branch in the local repository, you can point
branch.<name>.merge to the desired branch, and use the special setting
`.` (a period) for branch.<name>.remote.
@@ -362,11 +460,22 @@ branch.<name>.mergeoptions::
branch.<name>.rebase::
When true, rebase the branch <name> on top of the fetched branch,
- instead of merging the default branch from the default remote.
+ instead of merging the default branch from the default remote when
+ "git pull" is run.
*NOTE*: this is a possibly dangerous operation; do *not* use
it unless you understand the implications (see linkgit:git-rebase[1]
for details).
+browser.<tool>.cmd::
+ Specify the command to invoke the specified browser. The
+ specified command is evaluated in shell with the URLs passed
+ as arguments. (See linkgit:git-web--browse[1].)
+
+browser.<tool>.path::
+ Override the path for the given tool that may be used to
+ browse HTML help (see '-w' option in linkgit:git-help[1]) or a
+ working repository in gitweb (see linkgit:git-instaweb[1]).
+
clean.requireForce::
A boolean to make git-clean do nothing unless given -f
or -n. Defaults to true.
@@ -407,12 +516,12 @@ color.diff.<slot>::
color.interactive::
When set to `always`, always use colors for interactive prompts
- and displays (such as those used by "git add --interactive").
+ and displays (such as those used by "git-add --interactive").
When false (or `never`), never. When set to `true` or `auto`, use
colors only when the output is to the terminal. Defaults to false.
color.interactive.<slot>::
- Use customized color for `git add --interactive`
+ Use customized color for 'git-add --interactive'
output. `<slot>` may be `prompt`, `header`, or `help`, for
three distinct types of normal output from interactive
programs. The values of these variables may be specified as
@@ -433,32 +542,43 @@ 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),
- or `untracked` (files which are not tracked by git). The values of
- these variables may be specified as in color.branch.<slot>.
+ `untracked` (files which are not tracked by git), or
+ `nobranch` (the color the 'no branch' warning is shown in, defaulting
+ to red). The values of these variables may be specified as in
+ color.branch.<slot>.
commit.template::
Specify a file to use as the template for new commit messages.
+color.ui::
+ When set to `always`, always use colors in all git commands which
+ are capable of colored output. When false (or `never`), never. When
+ set to `true` or `auto`, use colors only when the output is to the
+ terminal. When more specific variables of color.* are set, they always
+ take precedence over this setting. Defaults to false.
+
diff.autorefreshindex::
- When using `git diff` to compare with work tree
+ When using 'git-diff' to compare with work tree
files, do not consider stat-only change as changed.
Instead, silently run `git update-index --refresh` to
update the cached stat information for paths whose
contents in the work tree match the contents in the
index. This option defaults to true. Note that this
- affects only `git diff` Porcelain, and not lower level
- `diff` commands, such as `git diff-files`.
+ affects only 'git-diff' Porcelain, and not lower level
+ 'diff' commands, such as 'git-diff-files'.
diff.external::
If this config variable is set, diff generation is not
performed using the internal diff machinery, but using the
- given command. Note: if you want to use an external diff
- program only on a subset of your files, you might want to
- use linkgit:gitattributes[5] instead.
+ given command. Can be overridden with the `GIT_EXTERNAL_DIFF'
+ environment variable. The command is called with parameters
+ as described under "git Diffs" in linkgit:git[1]. Note: if
+ you want to use an external diff program only on a subset of
+ your files, you might want to use linkgit:gitattributes[5] instead.
diff.renameLimit::
The number of files to consider when performing the copy/rename
- detection; equivalent to the git diff option '-l'.
+ detection; equivalent to the 'git-diff' option '-l'.
diff.renames::
Tells git to detect renames. If set to any boolean value, it
@@ -491,9 +611,14 @@ format.suffix::
`.patch`. Use this variable to change that suffix (make sure to
include the dot if you want it).
+format.pretty::
+ The default pretty format for log/show/whatchanged command,
+ See linkgit:git-log[1], linkgit:git-show[1],
+ linkgit:git-whatchanged[1].
+
gc.aggressiveWindow::
The window size parameter used in the delta compression
- algorithm used by 'git gc --aggressive'. This defaults
+ algorithm used by 'git-gc --aggressive'. This defaults
to 10.
gc.auto::
@@ -507,38 +632,47 @@ gc.autopacklimit::
When there are more than this many packs that are not
marked with `*.keep` file in the repository, `git gc
--auto` consolidates them into one larger pack. The
- default value is 20. Setting this to 0 disables it.
+ default value is 50. Setting this to 0 disables it.
gc.packrefs::
- `git gc` does not run `git pack-refs` in a bare repository by
+ 'git-gc' does not run `git pack-refs` in a bare repository by
default so that older dumb-transport clients can still fetch
- from the repository. Setting this to `true` lets `git
- gc` to run `git pack-refs`. Setting this to `false` tells
- `git gc` never to run `git pack-refs`. The default setting is
+ from the repository. Setting this to `true` lets 'git-gc'
+ to run `git pack-refs`. Setting this to `false` tells
+ 'git-gc' never to run `git pack-refs`. The default setting is
`notbare`. Enable it only when you know you do not have to
support such clients. The default setting will change to `true`
at some stage, and setting this to `false` will continue to
- prevent `git pack-refs` from being run from `git gc`.
+ prevent `git pack-refs` from being run from 'git-gc'.
+
+gc.pruneexpire::
+ When 'git-gc' is run, it will call 'prune --expire 2.weeks.ago'.
+ Override the grace period with this config variable.
gc.reflogexpire::
- `git reflog expire` removes reflog entries older than
+ 'git-reflog expire' removes reflog entries older than
this time; defaults to 90 days.
gc.reflogexpireunreachable::
- `git reflog expire` removes reflog entries older than
+ 'git-reflog expire' removes reflog entries older than
this time and are not reachable from the current tip;
defaults to 30 days.
gc.rerereresolved::
Records of conflicted merge you resolved earlier are
- kept for this many days when `git rerere gc` is run.
+ kept for this many days when 'git-rerere gc' is run.
The default is 60 days. See linkgit:git-rerere[1].
gc.rerereunresolved::
Records of conflicted merge you have not resolved are
- kept for this many days when `git rerere gc` is run.
+ kept for this many days when 'git-rerere gc' is run.
The default is 15 days. See linkgit:git-rerere[1].
+rerere.autoupdate::
+ When set to true, `git-rerere` updates the index with the
+ resulting contents after it cleanly resolves conflicts using
+ previously recorded resolution. Defaults to false.
+
rerere.enabled::
Activate recording of resolved conflicts, so that identical
conflict hunks can be resolved automatically, should they
@@ -554,11 +688,24 @@ gitcvs.logfile::
Path to a log file where the CVS server interface well... logs
various stuff. See linkgit:git-cvsserver[1].
+gitcvs.usecrlfattr
+ If true, the server will look up the `crlf` attribute for
+ files to determine the '-k' modes to use. If `crlf` is set,
+ the '-k' mode will be left blank, so cvs clients will
+ treat it as text. If `crlf` is explicitly unset, the file
+ will be set with '-kb' mode, which suppresses any newline munging
+ the client might otherwise do. If `crlf` is not specified,
+ then 'gitcvs.allbinary' is used. See linkgit:gitattributes[5].
+
gitcvs.allbinary::
- If true, all files are sent to the client in mode '-kb'. This
- causes the client to treat all files as binary files which suppresses
- any newline munging it otherwise might do. A work-around for the
- fact that there is no way yet to set single files to mode '-kb'.
+ This is used if 'gitcvs.usecrlfattr' does not resolve
+ the correct '-kb' mode to use. If true, all
+ unresolved files are sent to the client in
+ mode '-kb'. This causes the client to treat them
+ as binary files, which suppresses any newline munging it
+ otherwise might do. Alternatively, if it is set to "guess",
+ then the contents of the file are examined to decide if
+ it is binary, similar to 'core.autocrlf'.
gitcvs.dbname::
Database used by git-cvsserver to cache revision information
@@ -582,11 +729,49 @@ gitcvs.dbuser, gitcvs.dbpass::
'gitcvs.dbuser' supports variable substitution (see
linkgit:git-cvsserver[1] for details).
-All gitcvs variables except for 'gitcvs.allbinary' can also be
-specified as 'gitcvs.<access_method>.<varname>' (where 'access_method'
+gitcvs.dbTableNamePrefix::
+ Database table name prefix. Prepended to the names of any
+ database tables used, allowing a single database to be used
+ for several repositories. Supports variable substitution (see
+ linkgit:git-cvsserver[1] for details). Any non-alphabetic
+ characters will be replaced with underscores.
+
+All gitcvs variables except for 'gitcvs.usecrlfattr' and
+'gitcvs.allbinary' can also be specified as
+'gitcvs.<access_method>.<varname>' (where 'access_method'
is one of "ext" and "pserver") to make them apply only for the given
access method.
+gui.commitmsgwidth::
+ Defines how wide the commit message window is in the
+ linkgit:git-gui[1]. "75" is the default.
+
+gui.diffcontext::
+ Specifies how many context lines should be used in calls to diff
+ made by the linkgit:git-gui[1]. The default is "5".
+
+gui.matchtrackingbranch::
+ Determines if new branches created with linkgit:git-gui[1] should
+ default to tracking remote branches with matching names or
+ not. Default: "false".
+
+gui.newbranchtemplate::
+ Is used as suggested name when creating new branches using the
+ linkgit:git-gui[1].
+
+gui.pruneduringfetch::
+ "true" if linkgit:git-gui[1] should prune tracking branches when
+ performing a fetch. The default value is "false".
+
+gui.trustmtime::
+ Determines if linkgit:git-gui[1] should trust the file modification
+ timestamp or not. By default the timestamps are not trusted.
+
+gui.spellingdictionary::
+ Specifies the dictionary used for spell checking commit messages in
+ the linkgit:git-gui[1]. When set to "none" spell checking is turned
+ off.
+
help.browser::
Specify the browser that will be used to display help in the
'web' format. See linkgit:git-help[1].
@@ -651,7 +836,7 @@ i18n.commitEncoding::
i18n.logOutputEncoding::
Character encoding the commit messages are converted to when
- running `git-log` and friends.
+ running 'git-log' and friends.
instaweb.browser::
Specify the program that will be used to browse your working
@@ -672,46 +857,62 @@ instaweb.port::
The port number to bind the gitweb httpd to. See
linkgit:git-instaweb[1].
+log.date::
+ Set default date-time mode for the log command. Setting log.date
+ value is similar to using 'git-log'\'s --date option. The value is one of the
+ following alternatives: {relative,local,default,iso,rfc,short}.
+ See linkgit:git-log[1].
+
log.showroot::
If true, the initial commit will be shown as a big creation event.
This is equivalent to a diff against an empty tree.
Tools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which
normally hide the root commit will now show it. True by default.
-merge.summary::
- Whether to include summaries of merged commits in newly created
- merge commit messages. False by default.
-
-merge.tool::
- Controls which merge resolution program is used by
- linkgit:git-mergetool[1]. Valid values are: "kdiff3", "tkdiff",
- "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and "opendiff".
+man.viewer::
+ Specify the programs that may be used to display help in the
+ 'man' format. See linkgit:git-help[1].
-merge.verbosity::
- Controls the amount of output shown by the recursive merge
- strategy. Level 0 outputs nothing except a final error
- message if conflicts were detected. Level 1 outputs only
- conflicts, 2 outputs conflicts and file changes. Level 5 and
- above outputs debugging information. The default is level 2.
- Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+include::merge-config.txt[]
-merge.<driver>.name::
- Defines a human readable name for a custom low-level
- merge driver. See linkgit:gitattributes[5] for details.
+man.<tool>.cmd::
+ Specify the command to invoke the specified man viewer. The
+ specified command is evaluated in shell with the man page
+ passed as argument. (See linkgit:git-help[1].)
-merge.<driver>.driver::
- Defines the command that implements a custom low-level
- merge driver. See linkgit:gitattributes[5] for details.
-
-merge.<driver>.recursive::
- Names a low-level merge driver to be used when
- performing an internal merge between common ancestors.
- See linkgit:gitattributes[5] for details.
+man.<tool>.path::
+ Override the path for the given tool that may be used to
+ display help in the 'man' format. See linkgit:git-help[1].
mergetool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.
+mergetool.<tool>.cmd::
+ Specify the command to invoke the specified merge tool. The
+ specified command is evaluated in shell with the following
+ variables available: 'BASE' is the name of a temporary file
+ containing the common base of the files to be merged, if available;
+ 'LOCAL' is the name of a temporary file containing the contents of
+ the file on the current branch; 'REMOTE' is the name of a temporary
+ file containing the contents of the file from the branch being
+ merged; 'MERGED' contains the name of the file to which the merge
+ tool should write the results of a successful merge.
+
+mergetool.<tool>.trustExitCode::
+ For a custom merge command, specify whether the exit code of
+ the merge command can be used to determine whether the merge was
+ successful. If this is not set to true then the merge target file
+ timestamp is checked and the merge assumed to have been successful
+ if the file has been updated, otherwise the user is prompted to
+ indicate the success of the merge.
+
+mergetool.keepBackup::
+ After performing a merge, the original file with conflict markers
+ can be saved as a file with a `.orig` extension. If this variable
+ is set to `false` then this file is not preserved. Defaults to
+ `true` (i.e. keep the backup files).
+
pack.window::
The size of the window used by linkgit:git-pack-objects[1] when no
window size is given on the command line. Defaults to 10.
@@ -751,15 +952,36 @@ 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
+ and set the number of threads accordingly.
pack.indexVersion::
Specify the default pack index version. Valid values are 1 for
legacy pack index used by Git versions prior to 1.5.2, and 2 for
the new pack index with capabilities for packs larger than 4 GB
as well as proper protection against the repacking of corrupted
- packs. Version 2 is selected and this config option ignored
- whenever the corresponding pack is larger than 2 GB. Otherwise
- the default is 1.
+ packs. Version 2 is the default. Note that version 2 is enforced
+ 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 `{asterisk}.idx` file,
+cloning or fetching over a non native protocol (e.g. "http" and "rsync")
+that will copy both `{asterisk}.pack` file and corresponding `{asterisk}.idx` file from the
+other side may give you a repository that cannot be accessed with your
+older version of git. If the `{asterisk}.pack` file is smaller than 2 GB, however,
+you can use linkgit:git-index-pack[1] on the *.pack file to regenerate
+the `{asterisk}.idx` file.
+
+pack.packSizeLimit::
+ The default maximum size of a pack. This setting only affects
+ packing to a file, i.e. the git:// protocol is unaffected. It
+ can be overridden by the `\--max-pack-size` option of
+ linkgit:git-repack[1].
+
+pager.<cmd>::
+ Allows to set your own pager preferences for each command, overriding
+ the default. If `\--pager` or `\--no-pager` is specified on the command
+ line, it takes precedence over this option.
pull.octopus::
The default merge strategy to use when pulling multiple branches
@@ -785,33 +1007,37 @@ remote.<name>.push::
The default set of "refspec" for linkgit:git-push[1]. See
linkgit:git-push[1].
+remote.<name>.mirror::
+ If true, pushing to this remote will automatically behave
+ as if the `\--mirror` option was given on the command line.
+
remote.<name>.skipDefaultUpdate::
If true, this remote will be skipped by default when updating
using the update subcommand of linkgit:git-remote[1].
remote.<name>.receivepack::
The default program to execute on the remote side when pushing. See
- option \--exec of linkgit:git-push[1].
+ option \--receive-pack of linkgit:git-push[1].
remote.<name>.uploadpack::
The default program to execute on the remote side when fetching. See
- option \--exec of linkgit:git-fetch-pack[1].
+ option \--upload-pack of linkgit:git-fetch-pack[1].
remote.<name>.tagopt::
- Setting this value to --no-tags disables automatic tag following when fetching
- from remote <name>
+ Setting this value to \--no-tags disables automatic tag following when
+ fetching from remote <name>
remotes.<group>::
The list of remotes which are fetched by "git remote update
<group>". See linkgit:git-remote[1].
repack.usedeltabaseoffset::
- Allow linkgit:git-repack[1] to create packs that uses
- delta-base offset. Defaults to false.
-
-show.difftree::
- The default linkgit:git-diff-tree[1] arguments to be used
- for linkgit:git-show[1].
+ 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
+ protocol such as http, then you need to set this option to
+ "false" and repack. Access from old git versions over the
+ native protocol are unaffected by this option.
showbranch.default::
The default set of branches for linkgit:git-show-branch[1].
@@ -823,6 +1049,25 @@ status.relativePaths::
relative to the repository root (this was the default for git
prior to v1.5.4).
+status.showUntrackedFiles::
+ By default, linkgit:git-status[1] and linkgit:git-commit[1] show
+ files which are not currently tracked by Git. Directories which
+ contain only untracked files, are shown with the directory name
+ only. Showing untracked files means that Git needs to lstat() all
+ all the files in the whole repository, which might be slow on some
+ systems. So, this variable controls how the commands displays
+ the untracked files. Possible values are:
++
+--
+ - 'no' - Show no untracked files
+ - 'normal' - Shows untracked files and directories
+ - 'all' - Shows also individual files in untracked directories.
+--
++
+If this variable is not specified, it defaults to 'normal'.
+This variable can be overridden with the -u|--untracked-files option
+of linkgit:git-status[1] and linkgit:git-commit[1].
+
tar.umask::
This variable can be used to restrict the permission bits of
tar archive entries. The default is 0002, which turns off the
@@ -830,6 +1075,17 @@ tar.umask::
archiving user's umask will be used instead. See umask(2) and
linkgit:git-archive[1].
+url.<base>.insteadOf::
+ Any URL that starts with this value will be rewritten to
+ start, instead, with <base>. In cases where some site serves a
+ 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
+ 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.
+
user.email::
Your email address to be recorded in any newly created commits.
Can be overridden by the 'GIT_AUTHOR_EMAIL', 'GIT_COMMITTER_EMAIL', and
@@ -847,14 +1103,16 @@ user.signingkey::
unchanged to gpg's --local-user parameter, so you may specify a key
using any method that gpg supports.
-whatchanged.difftree::
- The default linkgit:git-diff-tree[1] arguments to be used
- for linkgit:git-whatchanged[1].
-
imap::
The configuration variables in the 'imap' section are described
in linkgit:git-imap-send[1].
+receive.fsckObjects::
+ If it is set to true, git-receive-pack will check all received
+ objects. It will abort in the case of a malformed object or a
+ broken link. The result of an abort are only dangling objects.
+ Defaults to false.
+
receive.unpackLimit::
If the number of objects received in a push is below this
limit then the objects will be unpacked into loose object
diff --git a/Documentation/diff-generate-patch.txt b/Documentation/diff-generate-patch.txt
index 029c5f2b8..517e1eba3 100644
--- a/Documentation/diff-generate-patch.txt
+++ b/Documentation/diff-generate-patch.txt
@@ -96,7 +96,7 @@ index fabadb8,cc95eb0..4866510
+
or like this (when '--cc' option is used):
- diff --c file
+ diff --cc file
2. It is followed by one or more extended header lines
(this example shows a merge with two parents):
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 8d35cbd60..cba90fd27 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -58,6 +58,14 @@ endif::git-format-patch[]
number of modified files, as well as number of added and deleted
lines.
+--dirstat[=limit]::
+ Output only the sub-directories that are impacted by a diff,
+ and to what degree they are impacted. You can override the
+ default cut-off in percent (3) by "--dirstat=limit". If you
+ want to enable "cumulative" directory statistics, you can use
+ the "--cumulative" flag, which adds up percentages recursively
+ even when they have been already reported for a sub-directory.
+
--summary::
Output a condensed summary of extended header information
such as creations, renames and mode changes.
@@ -75,7 +83,8 @@ endif::git-format-patch[]
Show only names of changed files.
--name-status::
- Show only names and status of changed files.
+ Show only names and status of changed files. See the description
+ of the `--diff-filter` option on what the status letters mean.
--color::
Show colored diff.
@@ -170,6 +179,14 @@ endif::git-format-patch[]
Swap two inputs; that is, show differences from index or
on-disk file to tree contents.
+--relative[=<path>]::
+ When run from a subdirectory of the project, it can be
+ told to exclude changes outside the directory and show
+ pathnames relative to it with this option. When you are
+ not in a subdirectory (e.g. in a bare repository), you
+ can name which subdirectory to make the output relative
+ to by giving a <path> as an argument.
+
--text::
Treat all files as text.
@@ -211,6 +228,9 @@ endif::git-format-patch[]
--no-ext-diff::
Disallow external diff drivers.
+--ignore-submodules::
+ Ignore changes to submodules in the diff generation.
+
--src-prefix=<prefix>::
Show the given source prefix instead of "a/".
@@ -221,4 +241,4 @@ endif::git-format-patch[]
Do not show any source or destination prefix.
For more detailed explanation on these common options, see also
-link:diffcore.html[diffcore documentation].
+linkgit:gitdiffcore[7].
diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt
index fdbd15a18..e598cdda4 100644
--- a/Documentation/everyday.txt
+++ b/Documentation/everyday.txt
@@ -48,14 +48,12 @@ $ git gc <3>
repository health reasonably well.
<2> check how many loose objects there are and how much
disk space is wasted by not repacking.
-<3> repacks the local repository and performs other housekeeping tasks. Running
-without `--prune` is a safe operation even while other ones are in progress.
+<3> repacks the local repository and performs other housekeeping tasks.
Repack a small project into single pack.::
+
------------
$ git gc <1>
-$ git gc --prune
------------
+
<1> pack all the objects reachable from the refs into one pack,
@@ -182,7 +180,7 @@ $ git pull <3>
$ git log -p ORIG_HEAD.. arch/i386 include/asm-i386 <4>
$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <5>
$ git reset --hard ORIG_HEAD <6>
-$ git gc --prune <7>
+$ git gc <7>
$ git fetch --tags <8>
------------
+
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 61e48ccf0..d313795fd 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -1,35 +1,45 @@
--q, \--quiet::
+-q::
+--quiet::
Pass --quiet to git-fetch-pack and silence any other internally
used programs.
--v, \--verbose::
+-v::
+--verbose::
Be verbose.
--a, \--append::
+-a::
+--append::
Append ref names and object names of fetched refs to the
existing contents of `.git/FETCH_HEAD`. Without this
option old data in `.git/FETCH_HEAD` will be overwritten.
-\--upload-pack <upload-pack>::
+--upload-pack <upload-pack>::
When given, and the repository to fetch from is handled
by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
the command to specify non-default path for the command
run on the other end.
--f, \--force::
- When `git-fetch` is used with `<rbranch>:<lbranch>`
+-f::
+--force::
+ When 'git-fetch' is used with `<rbranch>:<lbranch>`
refspec, it refuses to update the local branch
`<lbranch>` unless the remote branch `<rbranch>` it
fetches is a descendant of `<lbranch>`. This option
overrides that check.
--n, \--no-tags::
- By default, `git-fetch` fetches tags that point at
- objects that are downloaded from the remote repository
- and stores them locally. This option disables this
- automatic tag following.
+ifdef::git-pull[]
+--no-tags::
+endif::git-pull[]
+ifndef::git-pull[]
+-n::
+--no-tags::
+endif::git-pull[]
+ By default, tags that point at objects that are downloaded
+ from the remote repository are fetched and stored locally.
+ This option disables this automatic tag following.
--t, \--tags::
+-t::
+--tags::
Most of the tags are fetched automatically as branch
heads are downloaded, but tags that do not point at
objects reachable from the branch heads that are being
@@ -37,18 +47,20 @@
flag lets all tags and their associated objects be
downloaded.
--k, \--keep::
+-k::
+--keep::
Keep downloaded pack.
--u, \--update-head-ok::
- By default `git-fetch` refuses to update the head which
+-u::
+--update-head-ok::
+ By default 'git-fetch' refuses to update the head which
corresponds to the current branch. This flag disables the
- check. This is purely for the internal use for `git-pull`
- to communicate with `git-fetch`, and unless you are
+ check. This is purely for the internal use for 'git-pull'
+ to communicate with 'git-fetch', and unless you are
implementing your own Porcelain you are not supposed to
use it.
-\--depth=<depth>::
+--depth=<depth>::
Deepen the history of a 'shallow' repository created by
`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])
by the specified number of commits.
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 9d2ac865d..2b6d6c865 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -8,8 +8,9 @@ git-add - Add file contents to the index
SYNOPSIS
--------
[verse]
-'git-add' [-n] [-v] [-f] [--interactive | -i] [--patch | -p] [-u] [--refresh]
- [--] <filepattern>...
+'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
+ [--all | [--update | -u]] [--refresh] [--ignore-errors] [--]
+ <filepattern>...
DESCRIPTION
-----------
@@ -50,37 +51,56 @@ OPTIONS
and `dir/file2`) can be given to add all files in the
directory, recursively.
--n, \--dry-run::
+-n::
+--dry-run::
Don't actually add the file(s), just show if they exist.
--v, \--verbose::
+-v::
+--verbose::
Be verbose.
-f::
+--force::
Allow adding otherwise ignored files.
--i, \--interactive::
+-i::
+--interactive::
Add modified contents in the working tree interactively to
the index. Optional path arguments may be supplied to limit
operation to a subset of the working tree. See ``Interactive
mode'' for details.
--p, \--patch::
+-p::
+--patch::
Similar to Interactive mode but the initial command loop is
bypassed and the 'patch' subcommand is invoked using each of
the specified filepatterns before exiting.
-u::
- Update only files that git already knows about. This is similar
+--update::
+ Update only files that git already knows about, staging modified
+ content for commit and marking deleted files for removal. This
+ is similar
to what "git commit -a" does in preparation for making a commit,
except that the update is limited to paths specified on the
- command line. If no paths are specified, all tracked files are
- updated.
+ command line. If no paths are specified, all tracked files in the
+ current directory and its subdirectories are updated.
-\--refresh::
+-A::
+--all::
+ Update files that git already knows about (same as '\--update')
+ and add all untracked files that are not ignored by '.gitignore'
+ mechanism.
+
+--refresh::
Don't add the file(s), but only refresh their stat()
information in the index.
+--ignore-errors::
+ If some files could not be added because of errors indexing
+ them, do not abort the operation, but continue adding the
+ others. The command shall still exit with non-zero status.
+
\--::
This option can be used to separate command-line options from
the list of files, (useful when filenames might be mistaken
@@ -93,26 +113,32 @@ Configuration
The optional configuration variable 'core.excludesfile' indicates a path to a
file containing patterns of file names to exclude from git-add, similar to
$GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to
-those in info/exclude. See link:repository-layout.html[repository layout].
+those in info/exclude. See linkgit:gitrepository-layout[5].
EXAMPLES
--------
-git-add Documentation/\\*.txt::
- Adds content from all `\*.txt` files under `Documentation`
- directory and its subdirectories.
+* Adds content from all `\*.txt` files under `Documentation` directory
+and its subdirectories:
++
+------------
+$ git add Documentation/\\*.txt
+------------
+
Note that the asterisk `\*` is quoted from the shell in this
example; this lets the command to include the files from
subdirectories of `Documentation/` directory.
-git-add git-*.sh::
-
- Considers adding content from all git-*.sh scripts.
- Because this example lets shell expand the asterisk
- (i.e. you are listing the files explicitly), it does not
- consider `subdir/git-foo.sh`.
+* Considers adding content from all git-*.sh scripts:
++
+------------
+$ git add git-*.sh
+------------
++
+Because this example lets shell expand the asterisk (i.e. you are
+listing the files explicitly), it does not consider
+`subdir/git-foo.sh`.
Interactive mode
----------------
@@ -167,8 +193,9 @@ update::
"Update>>". When the prompt ends with double '>>', you can
make more than one selection, concatenated with whitespace or
comma. Also you can say ranges. E.g. "2-5 7,9" to choose
- 2,3,4,5,7,9 from the list. You can say '*' to choose
- everything.
+ 2,3,4,5,7,9 from the list. If the second number in a range is
+ omitted, all remaining patches are taken. E.g. "7-" to choose
+ 7,8,9 from the list. You can say '*' to choose everything.
+
What you chose are then highlighted with '*',
like this:
@@ -207,17 +234,16 @@ patch::
and the working tree file and asks you if you want to stage
the change of each hunk. You can say:
- y - add the change from that hunk to index
- n - do not add the change from that hunk to index
- a - add the change from that hunk and all the rest to index
- d - do not the change from that hunk nor any of the rest to index
- j - do not decide on this hunk now, and view the next
- undecided hunk
- J - do not decide on this hunk now, and view the next hunk
- k - do not decide on this hunk now, and view the previous
- undecided hunk
- K - do not decide on this hunk now, and view the previous hunk
+ y - stage this hunk
+ n - do not stage this hunk
+ a - stage this and all the remaining hunks in the file
+ d - do not stage this hunk nor any of the remaining hunks in the file
+ j - leave this hunk undecided, see next undecided hunk
+ J - leave this hunk undecided, see next hunk
+ k - leave this hunk undecided, see previous undecided hunk
+ K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
+ e - manually edit the current hunk
? - print help
+
After deciding the fate for all hunks, if there is any hunk
@@ -228,8 +254,14 @@ diff::
This lets you review what will be committed (i.e. between
HEAD and index).
+Bugs
+----
+The interactive mode does not work with files whose names contain
+characters that need C-quoting. `core.quotepath` configuration can be
+used to work this limitation around to some degree, but backslash,
+double-quote and control characters will still have problems.
-See Also
+SEE ALSO
--------
linkgit:git-status[1]
linkgit:git-rm[1]
@@ -248,4 +280,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 2ffba2102..b9c6fac74 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -9,11 +9,11 @@ git-am - Apply a series of patches from a mailbox
SYNOPSIS
--------
[verse]
-'git-am' [--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8]
- [--3way] [--interactive] [--binary]
+'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
+ [--3way] [--interactive]
[--whitespace=<option>] [-C<n>] [-p<n>]
- <mbox>|<Maildir>...
-'git-am' [--skip | --resolved]
+ [<mbox> | <Maildir>...]
+'git am' (--skip | --resolved | --abort)
DESCRIPTION
-----------
@@ -28,19 +28,18 @@ OPTIONS
supply this argument, reads from the standard input. If you supply
directories, they'll be treated as Maildirs.
--s, --signoff::
+-s::
+--signoff::
Add `Signed-off-by:` line to the commit message, using
the committer identity of yourself.
--d=<dir>, --dotest=<dir>::
- Instead of `.dotest` directory, use <dir> as a working
- area to store extracted patches.
+-k::
+--keep::
+ Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
--k, --keep::
- Pass `-k` flag to `git-mailinfo` (see linkgit:git-mailinfo[1]).
-
--u, --utf8::
- Pass `-u` flag to `git-mailinfo` (see linkgit:git-mailinfo[1]).
+-u::
+--utf8::
+ Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
The proposed commit log message taken from the e-mail
is re-coded into UTF-8 encoding (configuration variable
`i18n.commitencoding` can be used to specify project's
@@ -50,37 +49,37 @@ This was optional in prior versions of git, but now it is the
default. You could use `--no-utf8` to override this.
--no-utf8::
- Pass `-n` flag to `git-mailinfo` (see
+ Pass `-n` flag to 'git-mailinfo' (see
linkgit:git-mailinfo[1]).
--3, --3way::
+-3::
+--3way::
When the patch does not apply cleanly, fall back on
3-way merge, if the patch records the identity of blobs
it is supposed to apply to, and we have those blobs
available locally.
--b, --binary::
- Pass `--allow-binary-replacement` flag to `git-apply`
- (see linkgit:git-apply[1]).
-
--whitespace=<option>::
- This flag is passed to the `git-apply` (see linkgit:git-apply[1])
+ This flag is passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
--C<n>, -p<n>::
- These flags are passed to the `git-apply` (see linkgit:git-apply[1])
+-C<n>::
+-p<n>::
+ These flags are passed to the 'git-apply' (see linkgit:git-apply[1])
program that applies
the patch.
--i, --interactive::
+-i::
+--interactive::
Run interactively.
--skip::
Skip the current patch. This is only meaningful when
restarting an aborted patch.
--r, --resolved::
+-r::
+--resolved::
After a patch failure (e.g. attempting to apply
conflicting patch), the user has applied it by hand and
the index file stores the result of the application.
@@ -93,7 +92,10 @@ default. You could use `--no-utf8` to override this.
to the screen before exiting. This overrides the
standard message informing you to use `--resolved`
or `--skip` to handle the failure. This is solely
- for internal use between `git-rebase` and `git-am`.
+ for internal use between 'git-rebase' and 'git-am'.
+
+--abort::
+ Restore the original branch and abort the patching operation.
DISCUSSION
----------
@@ -136,11 +138,17 @@ aborts in the middle,. You can recover from this in one of two ways:
the index file to bring it in a state that the patch should
have produced. Then run the command with '--resolved' option.
-The command refuses to process new mailboxes while `.dotest`
+The command refuses to process new mailboxes while `.git/rebase-apply`
directory exists, so if you decide to start over from scratch,
-run `rm -f .dotest` before running the command with mailbox
+run `rm -f -r .git/rebase-apply` before running the command with mailbox
names.
+Before any patches are applied, ORIG_HEAD is set to the tip of the
+current branch. This is useful if you have problems with multiple
+commits, like running 'git am' on the wrong branch or an error in the
+commits that is more easily fixed by changing the mailbox (e.g.
+errors in the "From:" lines).
+
SEE ALSO
--------
@@ -149,7 +157,7 @@ linkgit:git-apply[1].
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -157,4 +165,4 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.o
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-annotate.txt b/Documentation/git-annotate.txt
index 45a6a7251..8b6b56a54 100644
--- a/Documentation/git-annotate.txt
+++ b/Documentation/git-annotate.txt
@@ -7,7 +7,7 @@ git-annotate - Annotate file lines with commit info
SYNOPSIS
--------
-git-annotate [options] file [revision]
+'git annotate' [options] file [revision]
DESCRIPTION
-----------
@@ -28,4 +28,4 @@ Written by Ryan Anderson <ryan@michonline.com>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 2dec2ec1c..feb51f124 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -9,16 +9,16 @@ git-apply - Apply a patch on a git index file and a working tree
SYNOPSIS
--------
[verse]
-'git-apply' [--stat] [--numstat] [--summary] [--check] [--index]
+'git apply' [--stat] [--numstat] [--summary] [--check] [--index]
[--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
[--allow-binary-replacement | --binary] [--reject] [-z]
- [-pNUM] [-CNUM] [--inaccurate-eof] [--cached]
+ [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
[--whitespace=<nowarn|warn|fix|error|error-all>]
- [--exclude=PATH] [--verbose] [<patch>...]
+ [--exclude=PATH] [--directory=<root>] [--verbose] [<patch>...]
DESCRIPTION
-----------
-Reads supplied diff output and applies it on a git index file
+Reads supplied 'diff' output and applies it on a git index file
and a work tree.
OPTIONS
@@ -64,7 +64,7 @@ OPTIONS
without using the working tree. This implies '--index'.
--build-fake-ancestor <file>::
- Newer git-diff output has embedded 'index information'
+ Newer 'git-diff' output has embedded 'index information'
for each blob to help identify the original version that
the patch applies to. When this flag is given, and if
the original versions of the blobs is available locally,
@@ -73,11 +73,12 @@ OPTIONS
When a pure mode change is encountered (which has no index information),
the information is read from the current index instead.
--R, --reverse::
+-R::
+--reverse::
Apply the patch in reverse.
--reject::
- For atomicity, linkgit:git-apply[1] by default fails the whole patch and
+ For atomicity, 'git-apply' by default fails the whole patch and
does not touch the working tree when some of the hunks
do not apply. This option makes it apply
the parts of the patch that are applicable, and leave the
@@ -101,7 +102,7 @@ the information is read from the current index instead.
ever ignored.
--unidiff-zero::
- By default, linkgit:git-apply[1] expects that the patch being
+ By default, 'git-apply' expects that the patch being
applied is a unified diff with at least one line of context.
This provides good safety measures, but breaks down when
applying a diff generated with --unified=0. To bypass these
@@ -112,7 +113,7 @@ discouraged.
--apply::
If you use any of the options marked "Turns off
- 'apply'" above, linkgit:git-apply[1] reads and outputs the
+ 'apply'" above, 'git-apply' reads and outputs the
information you asked without actually applying the
patch. Give this flag after those flags to also apply
the patch.
@@ -120,11 +121,12 @@ discouraged.
--no-add::
When applying a patch, ignore additions made by the
patch. This can be used to extract the common part between
- two files by first running `diff` on them and applying
+ two files by first running 'diff' on them and applying
the result with this option, which would apply the
deletion part but not addition part.
---allow-binary-replacement, --binary::
+--allow-binary-replacement::
+--binary::
Historically we did not allow binary patch applied
without an explicit permission from the user, and this
flag was the way to do so. Currently we always allow binary
@@ -145,7 +147,7 @@ discouraged.
considered whitespace errors.
+
By default, the command outputs warning messages but applies the patch.
-When linkgit:git-apply[1] is used for statistics and not applying a
+When `git-apply is used for statistics and not applying a
patch, it defaults to `nowarn`.
+
You can use different `<action>` to control this
@@ -163,17 +165,31 @@ behavior:
* `error-all` is similar to `error` but shows all errors.
--inaccurate-eof::
- Under certain circumstances, some versions of diff do not correctly
+ Under certain circumstances, some versions of 'diff' do not correctly
detect a missing new-line at the end of the file. As a result, patches
- created by such diff programs do not record incomplete lines
+ created by such 'diff' programs do not record incomplete lines
correctly. This option adds support for applying such patches by
working around this bug.
--v, --verbose::
+-v::
+--verbose::
Report progress to stderr. By default, only a message about the
current patch being applied will be printed. This option will cause
additional information to be reported.
+--recount::
+ Do not trust the line counts in the hunk headers, but infer them
+ by inspecting the patch (e.g. after editing the patch without
+ adjusting the hunk headers appropriately).
+
+--directory=<root>::
+ Prepend <root> to all filenames. If a "-p" argument was passed, too,
+ it is applied before prepending the new root.
++
+For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh`
+can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by
+running `git apply --directory=modules/git-gui`.
+
Configuration
-------------
@@ -183,7 +199,7 @@ apply.whitespace::
Submodules
----------
-If the patch contains any changes to submodules then linkgit:git-apply[1]
+If the patch contains any changes to submodules then 'git-apply'
treats these changes as follows.
If --index is specified (explicitly or implicitly), then the submodule
@@ -206,4 +222,4 @@ Documentation by Junio C Hamano
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-archimport.txt b/Documentation/git-archimport.txt
index bd20fd820..c7a6e3ec0 100644
--- a/Documentation/git-archimport.txt
+++ b/Documentation/git-archimport.txt
@@ -9,7 +9,7 @@ git-archimport - Import an Arch repository into git
SYNOPSIS
--------
[verse]
-'git-archimport' [-h] [-v] [-o] [-a] [-f] [-T] [-D depth] [-t tempdir]
+'git archimport' [-h] [-v] [-o] [-a] [-f] [-T] [-D depth] [-t tempdir]
<archive/branch>[:<git-branch>] ...
DESCRIPTION
@@ -29,17 +29,17 @@ branches that have different roots, it will refuse to run. In that case,
edit your <archive/branch> parameters to define clearly the scope of the
import.
-`git-archimport` uses `tla` extensively in the background to access the
+'git-archimport' uses `tla` extensively in the background to access the
Arch repository.
Make sure you have a recent version of `tla` available in the path. `tla` must
-know about the repositories you pass to `git-archimport`.
+know about the repositories you pass to 'git-archimport'.
-For the initial import `git-archimport` expects to find itself in an empty
+For the initial import, 'git-archimport' expects to find itself in an empty
directory. To follow the development of a project that uses Arch, rerun
-`git-archimport` with the same parameters as the initial import to perform
+'git-archimport' with the same parameters as the initial import to perform
incremental imports.
-While git-archimport will try to create sensible branch names for the
+While 'git-archimport' will try to create sensible branch names for the
archives that it imports, it is also possible to specify git branch names
manually. To do so, write a git branch name after each <archive/branch>
parameter, separated by a colon. This way, you can shorten the Arch
@@ -84,7 +84,7 @@ OPTIONS
-o::
Use this for compatibility with old-style branch names used by
- earlier versions of git-archimport. Old-style branch names
+ earlier versions of 'git-archimport'. Old-style branch names
were category--branch, whereas new-style branch names are
archive,category--branch--version. In both cases, names given
on the command-line will override the automatically-generated
@@ -117,4 +117,4 @@ Documentation by Junio C Hamano, Martin Langhoff and the git-list <git@vger.kern
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index d3eaa16af..41cbf9c08 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -9,7 +9,7 @@ git-archive - Create an archive of files from a named tree
SYNOPSIS
--------
[verse]
-'git-archive' --format=<fmt> [--list] [--prefix=<prefix>/] [<extra>]
+'git archive' --format=<fmt> [--list] [--prefix=<prefix>/] [<extra>]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[path...]
@@ -36,10 +36,12 @@ OPTIONS
Format of the resulting archive: 'tar' or 'zip'. The default
is 'tar'.
---list, -l::
+-l::
+--list::
Show all available formats.
---verbose, -v::
+-v::
+--verbose::
Report progress to stderr.
--prefix=<prefix>/::
@@ -55,7 +57,7 @@ OPTIONS
--exec=<git-upload-archive>::
Used with --remote to specify the path to the
- git-upload-archive executable on the remote side.
+ 'git-upload-archive' on the remote side.
<tree-ish>::
The tree or commit to produce an archive for.
@@ -118,4 +120,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 96585ae8d..c7981efcd 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -15,6 +15,7 @@ DESCRIPTION
The command takes various subcommands, and different options depending
on the subcommand:
+ git bisect help
git bisect start [<bad> [<good>...]] [--] [<paths>...]
git bisect bad [<rev>]
git bisect good [<rev>...]
@@ -25,10 +26,16 @@ on the subcommand:
git bisect log
git bisect run <cmd>...
-This command uses 'git-rev-list --bisect' option to help drive the
+This command uses 'git-rev-list --bisect' to help drive the
binary search process to find which change introduced a bug, given an
old "good" commit object name and a later "bad" commit object name.
+Getting help
+~~~~~~~~~~~~
+
+Use "git bisect" to get a short usage description, and "git bisect
+help" or "git bisect -h" to get a long usage description.
+
Basic bisect commands: start, bad, good
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -78,10 +85,9 @@ Oh, and then after you want to reset to the original head, do a
$ git bisect reset
------------------------------------------------
-to get back to the master branch, instead of being in one of the
-bisection branches ("git bisect start" will do that for you too,
-actually: it will reset the bisection state, and before it does that
-it checks that you're not using some old bisection branch).
+to get back to the original branch, instead of being on the bisection
+commit ("git bisect start" will do that for you too, actually: it will
+reset the bisection state).
Bisect visualize
~~~~~~~~~~~~~~~~
@@ -92,10 +98,10 @@ During the bisection process, you can say
$ git bisect visualize
------------
-to see the currently remaining suspects in `gitk`. `visualize` is a bit
+to see the currently remaining suspects in 'gitk'. `visualize` is a bit
too long to type and `view` is provided as a synonym.
-If `DISPLAY` environment variable is not set, `git log` is used
+If 'DISPLAY' environment variable is not set, 'git-log' is used
instead. You can even give command line options such as `-p` and
`--stat`.
@@ -209,13 +215,62 @@ tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or
work around other problem this bisection is not interested in")
applied to the revision being tested.
-To cope with such a situation, after the inner git-bisect finds the
+To cope with such a situation, after the inner 'git-bisect' finds the
next revision to test, with the "run" script, you can apply that tweak
before compiling, run the real test, and after the test decides if the
revision (possibly with the needed tweaks) passed the test, rewind the
tree to the pristine state. Finally the "run" script can exit with
-the status of the real test to let "git bisect run" command loop to
-know the outcome.
+the status of the real test to let the "git bisect run" command loop to
+determine the outcome.
+
+EXAMPLES
+--------
+
+* Automatically bisect a broken build between v1.2 and HEAD:
++
+------------
+$ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good
+$ git bisect run make # "make" builds the app
+------------
+
+* Automatically bisect a broken test suite:
++
+------------
+$ cat ~/test.sh
+#!/bin/sh
+make || exit 125 # this "skip"s broken builds
+make test # "make test" runs the test suite
+$ git bisect start v1.3 v1.1 -- # v1.3 is bad, v1.1 is good
+$ git bisect run ~/test.sh
+------------
++
+Here we use a "test.sh" custom script. In this script, if "make"
+fails, we "skip" the current commit.
++
+It's safer to use a custom script outside the repo to prevent
+interactions between the bisect, make and test processes and the
+script.
++
+And "make test" should "exit 0", if the test suite passes, and
+"exit 1" (for example) otherwise.
+
+* Automatically bisect a broken test case:
++
+------------
+$ cat ~/test.sh
+#!/bin/sh
+make || exit 125 # this "skip"s broken builds
+~/check_test_case.sh # does the test case passes ?
+$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
+$ git bisect run ~/test.sh
+------------
++
+Here "check_test_case.sh" should "exit 0", if the test case passes,
+and "exit 1" (for example) otherwise.
++
+It's safer if both "test.sh" and "check_test_case.sh" scripts are
+outside the repo to prevent interactions between the bisect, make and
+test processes and the scripts.
Author
------
@@ -227,4 +282,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index 14163b65f..fba374d65 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -8,7 +8,7 @@ git-blame - Show what revision and author last modified each line of a file
SYNOPSIS
--------
[verse]
-'git-blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
+'git blame' [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [--incremental] [-L n,m]
[-S <revs-file>] [-M] [-C] [-C] [--since=<date>]
[<rev> | --contents <file>] [--] <file>
@@ -21,7 +21,7 @@ last modified the line. Optionally, start annotating from the given revision.
Also it can limit the range of lines annotated.
This report doesn't tell you anything about lines which have been deleted or
-replaced; you need to use a tool such as linkgit:git-diff[1] or the "pickaxe"
+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
@@ -49,15 +49,17 @@ include::blame-options.txt[]
file (see `-M`). The first number listed is the score.
This is the number of alphanumeric characters detected
to be moved between or within files. This must be above
- a certain threshold for git-blame to consider those lines
+ a certain threshold for 'git-blame' to consider those lines
of code to have been moved.
--f, --show-name::
+-f::
+--show-name::
Show filename in the original commit. By default
filename is shown if there is any line that came from a
file with different name, due to rename detection.
--n, --show-number::
+-n::
+--show-number::
Show line number in the original commit (Default: off).
-s::
@@ -98,7 +100,7 @@ header elements later.
SPECIFYING RANGES
-----------------
-Unlike `git-blame` and `git-annotate` in older git, the extent
+Unlike 'git-blame' and 'git-annotate' in older git, the extent
of annotation can be limited to both line ranges and revision
ranges. When you are interested in finding the origin for
ll. 40-60 for file `foo`, you can use `-L` option like these
@@ -116,7 +118,7 @@ would limit the annotation to the body of `hello` subroutine.
When you are not interested in changes older than the version
v2.6.18, or changes older than 3 weeks, you can use revision
-range specifiers similar to `git-rev-list`:
+range specifiers similar to 'git-rev-list':
git blame v2.6.18.. -- foo
git blame --since=3.weeks -- foo
@@ -188,8 +190,8 @@ linkgit:git-annotate[1]
AUTHOR
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index f920c04cc..6103d62fe 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -8,22 +8,27 @@ git-branch - List, create, or delete branches
SYNOPSIS
--------
[verse]
-'git-branch' [--color | --no-color] [-r | -a]
- [-v [--abbrev=<length> | --no-abbrev]]
- [--contains <commit>]
-'git-branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
-'git-branch' (-m | -M) [<oldbranch>] <newbranch>
-'git-branch' (-d | -D) [-r] <branchname>...
+'git branch' [--color | --no-color] [-r | -a]
+ [-v [--abbrev=<length> | --no-abbrev]]
+ [(--merged | --no-merged | --contains) [<commit>]]
+'git branch' [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
+'git branch' (-m | -M) [<oldbranch>] <newbranch>
+'git branch' (-d | -D) [-r] <branchname>...
DESCRIPTION
-----------
-With no arguments given a list of existing branches
-will be shown, the current branch will be highlighted with an asterisk.
-Option `-r` causes the remote-tracking branches to be listed,
-and option `-a` shows both.
-With `--contains <commit>`, shows only the branches that
-contains the named commit (in other words, the branches whose
-tip commits are descendant of the named commit).
+
+With no 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.
+
+With `--contains`, shows only the branches that contains the named commit
+(in other words, the branches whose tip commits are descendant of the
+named commit). With `--merged`, only branches merged into the named
+commit (i.e. the branches whose tip commits are reachable from the named
+commit) will be listed. With `--no-merged` only branches not merged into
+the named commit will be listed. Missing <commit> argument defaults to
+'HEAD' (i.e. the tip of the current branch).
In its second form, a new branch named <branchname> will be created.
It will start out with a head equal to the one given as <start-point>.
@@ -34,12 +39,11 @@ 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 branch, git can setup the
-branch so that linkgit:git-pull[1] will appropriately merge from that
-remote branch. If this behavior is desired, it is possible to make it
-the default using the global `branch.autosetupmerge` configuration
-flag. Otherwise, it can be chosen per-branch using the `--track`
-and `--no-track` options.
+When a local branch is started off a remote branch, git sets up the
+branch so that 'git-pull' will appropriately merge from
+the remote branch. This behavior may be changed via the global
+`branch.autosetupmerge` configuration flag. That setting can be
+overridden by using the `--track` and `--no-track` options.
With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.
If <oldbranch> had a corresponding reflog, it is renamed to match
@@ -53,7 +57,7 @@ has a reflog then the reflog will also be deleted.
Use -r together with -d to delete remote-tracking branches. Note, that it
only makes sense to delete remote-tracking branches if they no longer exist
-in remote repository or if linkgit:git-fetch[1] was configured not to fetch
+in remote repository or if 'git-fetch' was configured not to fetch
them again. See also 'prune' subcommand of linkgit:git-remote[1] for way to
clean up all obsolete remote-tracking branches.
@@ -94,7 +98,8 @@ OPTIONS
-a::
List both remote-tracking branches and local branches.
--v, --verbose::
+-v::
+--verbose::
Show sha1 and commit subject line for each head.
--abbrev=<length>::
@@ -105,19 +110,28 @@ OPTIONS
Display the full sha1s in output listing rather than abbreviating them.
--track::
- Set up configuration so that git-pull will automatically
- retrieve data from the remote branch. Use this if you always
- pull from the same remote branch into the new branch, or if you
- don't want to use "git pull <repository> <refspec>" explicitly. Set the
- branch.autosetupmerge configuration variable to true if you
- want git-checkout and git-branch to always behave as if
- '--track' were given.
+ When creating a new branch, set up configuration so that 'git-pull'
+ will automatically retrieve data from the start point, which must be
+ a branch. Use this if you always pull from the same upstream branch
+ into the new branch, and if you don't want to use "git pull
+ <repository> <refspec>" explicitly. This behavior is the default
+ when the start point is a remote branch. Set the
+ branch.autosetupmerge configuration variable to `false` if you want
+ 'git-checkout' and 'git-branch' to always behave as if '--no-track' were
+ given. Set it to `always` if you want this behavior when the
+ start-point is either a local or remote branch.
--no-track::
- When a branch is created off a remote branch,
- set up configuration so that git-pull will not retrieve data
- from the remote branch, ignoring the branch.autosetupmerge
- configuration variable.
+ Ignore the branch.autosetupmerge configuration variable.
+
+--contains <commit>::
+ Only list branches which contain the specified commit.
+
+--merged::
+ Only list branches which are fully contained by HEAD.
+
+--no-merged::
+ Do not list branches which are fully contained by HEAD.
<branchname>::
The name of the branch to create or delete.
@@ -176,10 +190,22 @@ If you are creating a branch that you want to immediately checkout, it's
easier to use the git checkout command with its `-b` option to create
a branch and check it out with a single command.
+The options `--contains`, `--merged` and `--no-merged` serves three related
+but different purposes:
+
+- `--contains <commit>` is used to find all branches which will need
+ special attention if <commit> were to be rebased or amended, since those
+ branches contain the specified <commit>.
+
+- `--merged` is used to find all branches which can be safely deleted,
+ since those branches are fully contained by HEAD.
+
+- `--no-merged` is used to find branches which are candidates for merging
+ into HEAD, since those branches are not fully contained by HEAD.
Author
------
-Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano <junkio@cox.net>
+Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -187,4 +213,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-bundle.txt b/Documentation/git-bundle.txt
index 72f080a97..1b66ab743 100644
--- a/Documentation/git-bundle.txt
+++ b/Documentation/git-bundle.txt
@@ -9,10 +9,10 @@ git-bundle - Move objects and refs by archive
SYNOPSIS
--------
[verse]
-'git-bundle' create <file> [git-rev-list args]
-'git-bundle' verify <file>
-'git-bundle' list-heads <file> [refname...]
-'git-bundle' unbundle <file> [refname...]
+'git bundle' create <file> <git-rev-list args>
+'git bundle' verify <file>
+'git bundle' list-heads <file> [refname...]
+'git bundle' unbundle <file> [refname...]
DESCRIPTION
-----------
@@ -21,9 +21,9 @@ Some workflows require that one or more branches of development on one
machine be replicated on another machine, but the two machines cannot
be directly connected so the interactive git protocols (git, ssh,
rsync, http) cannot be used. This command provides support for
-git-fetch and git-pull to operate by packaging objects and references
+'git-fetch' and 'git-pull' to operate by packaging objects and references
in an archive at the originating machine, then importing those into
-another repository using linkgit:git-fetch[1] and linkgit:git-pull[1]
+another repository using 'git-fetch' and 'git-pull'
after moving the archive by some means (i.e., by sneakernet). As no
direct connection between repositories exists, the user must specify a
basis for the bundle that is held by the destination repository: the
@@ -35,14 +35,14 @@ OPTIONS
create <file>::
Used to create a bundle named 'file'. This requires the
- git-rev-list arguments to define the bundle contents.
+ 'git-rev-list' arguments to define the bundle contents.
verify <file>::
Used to check that a bundle file is valid and will apply
cleanly to the current repository. This includes checks on the
bundle format itself as well as checking that the prerequisite
commits exist and are fully linked in the current repository.
- git-bundle prints a list of missing commits, if any, and exits
+ 'git-bundle' prints a list of missing commits, if any, and exits
with non-zero status.
list-heads <file>::
@@ -51,16 +51,15 @@ list-heads <file>::
printed out.
unbundle <file>::
- Passes the objects in the bundle to linkgit:git-index-pack[1]
+ Passes the objects in the bundle to 'git-index-pack'
for storage in the repository, then prints the names of all
defined references. If a reflist is given, only references
matching those in the given list are printed. This command is
- really plumbing, intended to be called only by
- linkgit:git-fetch[1].
+ really plumbing, intended to be called only by 'git-fetch'.
[git-rev-list-args...]::
- A list of arguments, acceptable to git-rev-parse and
- git-rev-list, that specify the specific objects and references
+ A list of arguments, acceptable to 'git-rev-parse' and
+ 'git-rev-list', that specify the specific objects and references
to transport. For example, "master~10..master" causes the
current master reference to be packaged along with all objects
added since its 10th ancestor commit. There is no explicit
@@ -70,16 +69,16 @@ unbundle <file>::
[refname...]::
A list of references used to limit the references reported as
- available. This is principally of use to git-fetch, which
+ available. This is principally of use to 'git-fetch', which
expects to receive only those references asked for and not
- necessarily everything in the pack (in this case, git-bundle is
- acting like linkgit:git-fetch-pack[1]).
+ necessarily everything in the pack (in this case, 'git-bundle' is
+ acting like 'git-fetch-pack').
SPECIFYING REFERENCES
---------------------
-git-bundle will only package references that are shown by
-git-show-ref: this includes heads, tags, and remote heads. References
+'git-bundle' will only package references that are shown by
+'git-show-ref': this includes heads, tags, and remote heads. References
such as master~1 cannot be packaged, but are perfectly suitable for
defining the basis. More than one reference may be packaged, and more
than one basis can be specified. The objects packaged are those not
@@ -99,36 +98,62 @@ Assume two repositories exist as R1 on machine A, and R2 on machine B.
For whatever reason, direct connection between A and B is not allowed,
but we can move data from A to B via some mechanism (CD, email, etc).
We want to update R2 with developments made on branch master in R1.
+
+To create the bundle you have to specify the basis. You have some options:
+
+- Without basis.
++
+This is useful when sending the whole history.
+
+------------
+$ git bundle create mybundle master
+------------
+
+- Using temporally tags.
++
We set a tag in R1 (lastR2bundle) after the previous such transport,
and move it afterwards to help build the bundle.
-in R1 on A:
-
------------
-$ git-bundle create mybundle master ^lastR2bundle
+$ git bundle create mybundle master ^lastR2bundle
$ git tag -f lastR2bundle master
------------
-(move mybundle from A to B by some mechanism)
+- Using a tag present in both repositories
+
+------------
+$ git bundle create mybundle master ^v1.0.0
+------------
+
+- A basis based on time.
+
+------------
+$ git bundle create mybundle master --since=10.days.ago
+------------
-in R2 on B:
+- With a limit on the number of commits
------------
-$ git-bundle verify mybundle
-$ git-fetch mybundle refspec
+$ git bundle create mybundle master -n 10
------------
-where refspec is refInBundle:localRef
+Then you move mybundle from A to B, and in R2 on B:
+------------
+$ git bundle verify mybundle
+$ git fetch mybundle master:localRef
+------------
-Also, with something like this in your config:
+With something like this in the config in R2:
+------------------------
[remote "bundle"]
url = /home/me/tmp/file.bdl
fetch = refs/heads/*:refs/remotes/origin/*
+------------------------
You can first sneakernet the bundle file to ~/tmp/file.bdl and
-then these commands:
+then these commands on machine B:
------------
$ git ls-remote bundle
@@ -145,4 +170,4 @@ Written by Mark Levedahl <mdl123@verizon.net>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index df42cb10f..668f697c2 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -8,13 +8,18 @@ git-cat-file - Provide content or type/size information for repository objects
SYNOPSIS
--------
-'git-cat-file' [-t | -s | -e | -p | <type>] <object>
+[verse]
+'git cat-file' [-t | -s | -e | -p | <type>] <object>
+'git cat-file' [--batch | --batch-check] < <list-of-objects>
DESCRIPTION
-----------
-Provides content or type of objects in the repository. The type
-is required unless '-t' or '-p' is used to find the object type,
-or '-s' is used to find the object size.
+In the first form, provides content or type of objects in the repository. The
+type is required unless '-t' or '-p' is used to find the object type, or '-s'
+is used to find the object size.
+
+In the second form, a list of object (separated by LFs) is provided on stdin,
+and the SHA1, type, and size of each object is printed on stdout.
OPTIONS
-------
@@ -46,6 +51,14 @@ OPTIONS
or to ask for a "blob" with <object> being a tag object that
points at it.
+--batch::
+ Print the SHA1, type, size, and contents of each object provided on
+ stdin. May not be combined with any other options or arguments.
+
+--batch-check::
+ Print the SHA1, type, and size of each object provided on stdin. May not be
+ combined with any other options or arguments.
+
OUTPUT
------
If '-t' is specified, one of the <type>.
@@ -56,9 +69,30 @@ If '-e' is specified, no output.
If '-p' is specified, the contents of <object> are pretty-printed.
-Otherwise the raw (though uncompressed) contents of the <object> will
-be returned.
+If <type> is specified, the raw (though uncompressed) contents of the <object>
+will be returned.
+
+If '--batch' is specified, output of the following form is printed for each
+object specified on stdin:
+
+------------
+<sha1> SP <type> SP <size> LF
+<contents> LF
+------------
+
+If '--batch-check' is specified, output of the following form is printed for
+each object specified on stdin:
+
+------------
+<sha1> SP <type> SP <size> LF
+------------
+
+For both '--batch' and '--batch-check', output of the following form is printed
+for each object specified on stdin that does not exist in the repository:
+------------
+<object> SP missing LF
+------------
Author
------
@@ -70,4 +104,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-check-attr.txt b/Documentation/git-check-attr.txt
index 290f10f16..2b821f2a1 100644
--- a/Documentation/git-check-attr.txt
+++ b/Documentation/git-check-attr.txt
@@ -8,7 +8,7 @@ git-check-attr - Display gitattributes information.
SYNOPSIS
--------
-'git-check-attr' attr... [--] pathname...
+'git check-attr' attr... [--] pathname...
DESCRIPTION
-----------
@@ -30,7 +30,7 @@ linkgit:gitattributes[5].
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -38,4 +38,4 @@ Documentation by James Bowes.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-check-ref-format.txt b/Documentation/git-check-ref-format.txt
index a67688042..034223cc5 100644
--- a/Documentation/git-check-ref-format.txt
+++ b/Documentation/git-check-ref-format.txt
@@ -7,7 +7,7 @@ git-check-ref-format - Make sure ref name is well formed
SYNOPSIS
--------
-'git-check-ref-format' <refname>
+'git check-ref-format' <refname>
DESCRIPTION
-----------
@@ -47,9 +47,9 @@ refname expressions (see linkgit:git-rev-parse[1]). Namely:
. colon `:` is used as in `srcref:dstref` to mean "use srcref\'s
value and store it in dstref" in fetch and push operations.
It may also be used to select a specific object such as with
- linkgit:git-cat-file[1] "git-cat-file blob v1.3.3:refs.c".
+ 'git-cat-file': "git cat-file blob v1.3.3:refs.c".
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-checkout-index.txt b/Documentation/git-checkout-index.txt
index cbbb0b509..62d84836b 100644
--- a/Documentation/git-checkout-index.txt
+++ b/Documentation/git-checkout-index.txt
@@ -9,7 +9,7 @@ git-checkout-index - Copy files from the index to the working tree
SYNOPSIS
--------
[verse]
-'git-checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
+'git checkout-index' [-u] [-q] [-a] [-f] [-n] [--prefix=<string>]
[--stage=<number>|all]
[--temp]
[-z] [--stdin]
@@ -22,21 +22,26 @@ Will copy all files listed from the index to the working directory
OPTIONS
-------
--u|--index::
+-u::
+--index::
update stat information for the checked out entries in
the index file.
--q|--quiet::
+-q::
+--quiet::
be quiet if files exist or are not in the index
--f|--force::
+-f::
+--force::
forces overwrite of existing files
--a|--all::
+-a::
+--all::
checks out all files in the index. Cannot be used
together with explicit filenames.
--n|--no-create::
+-n::
+--no-create::
Don't checkout new files, only refresh files already checked
out.
@@ -68,25 +73,25 @@ OPTIONS
The order of the flags used to matter, but not anymore.
-Just doing `git-checkout-index` does nothing. You probably meant
-`git-checkout-index -a`. And if you want to force it, you want
-`git-checkout-index -f -a`.
+Just doing `git checkout-index` does nothing. You probably meant
+`git checkout-index -a`. And if you want to force it, you want
+`git checkout-index -f -a`.
Intuitiveness is not the goal here. Repeatability is. The reason for
the "no arguments means no work" behavior is that from scripts you are
supposed to be able to do:
----------------
-$ find . -name '*.h' -print0 | xargs -0 git-checkout-index -f --
+$ find . -name '*.h' -print0 | xargs -0 git checkout-index -f --
----------------
which will force all existing `*.h` files to be replaced with their
cached copies. If an empty command line implied "all", then this would
force-refresh everything in the index, which was not the point. But
-since git-checkout-index accepts --stdin it would be faster to use:
+since 'git-checkout-index' accepts --stdin it would be faster to use:
----------------
-$ find . -name '*.h' -print0 | git-checkout-index -f -z --stdin
+$ find . -name '*.h' -print0 | git checkout-index -f -z --stdin
----------------
The `--` is just a good idea when you know the rest will be filenames;
@@ -97,7 +102,7 @@ Using `--` is probably a good policy in scripts.
Using --temp or --stage=all
---------------------------
When `--temp` is used (or implied by `--stage=all`)
-`git-checkout-index` will create a temporary file for each index
+'git-checkout-index' will create a temporary file for each index
entry being checked out. The index will not be updated with stat
information. These options can be useful if the caller needs all
stages of all unmerged entries so that the unmerged files can be
@@ -139,19 +144,19 @@ EXAMPLES
To update and refresh only the files already checked out::
+
----------------
-$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
+$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
----------------
-Using `git-checkout-index` to "export an entire tree"::
+Using 'git-checkout-index' to "export an entire tree"::
The prefix ability basically makes it trivial to use
- `git-checkout-index` as an "export as tree" function.
+ 'git-checkout-index' as an "export as tree" function.
Just read the desired tree into the index, and do:
+
----------------
-$ git-checkout-index --prefix=git-export-dir/ -a
+$ git checkout-index --prefix=git-export-dir/ -a
----------------
+
-`git-checkout-index` will "export" the index into the specified
+`git checkout-index` will "export" the index into the specified
directory.
+
The final "/" is important. The exported name is literally just
@@ -161,7 +166,7 @@ following example.
Export files with a prefix::
+
----------------
-$ git-checkout-index --prefix=.merged- Makefile
+$ git checkout-index --prefix=.merged- Makefile
----------------
+
This will check out the currently cached copy of `Makefile`
@@ -181,4 +186,4 @@ Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 584359ff3..5aa69c0e1 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -3,13 +3,13 @@ git-checkout(1)
NAME
----
-git-checkout - Checkout and switch to a branch
+git-checkout - Checkout a branch or paths to the working tree
SYNOPSIS
--------
[verse]
-'git-checkout' [-q] [-f] [[--track | --no-track] -b <new_branch> [-l]] [-m] [<branch>]
-'git-checkout' [<tree-ish>] <paths>...
+'git checkout' [-q] [-f] [[--track | --no-track] -b <new_branch> [-l]] [-m] [<branch>]
+'git checkout' [<tree-ish>] [--] <paths>...
DESCRIPTION
-----------
@@ -23,7 +23,7 @@ options, which will be passed to `git branch`.
When <paths> are given, this command does *not* switch
branches. It updates the named paths in the working tree from
-the index file (i.e. it runs `git-checkout-index -f -u`), or
+the index file (i.e. it runs `git checkout-index -f -u`), or
from a named commit. In
this case, the `-f` and `-b` options are meaningless and giving
either of them results in an error. <tree-ish> argument can be
@@ -47,21 +47,21 @@ OPTIONS
by linkgit:git-check-ref-format[1]. Some of these checks
may restrict the characters allowed in a branch name.
+-t::
--track::
- When -b is given and a branch is created off a remote branch,
- set up configuration so that git-pull will automatically
- retrieve data from the remote branch. Use this if you always
- pull from the same remote branch into the new branch, or if you
- don't want to use "git pull <repository> <refspec>" explicitly. Set the
- branch.autosetupmerge configuration variable to true if you
- want git-checkout and git-branch to always behave as if
- '--track' were given.
+ When creating a new branch, set up configuration so that 'git-pull'
+ will automatically retrieve data from the start point, which must be
+ a branch. Use this if you always pull from the same upstream branch
+ into the new branch, and if you don't want to use "git pull
+ <repository> <refspec>" explicitly. This behavior is the default
+ when the start point is a remote branch. Set the
+ branch.autosetupmerge configuration variable to `false` if you want
+ 'git-checkout' and 'git-branch' to always behave as if '--no-track' were
+ given. Set it to `always` if you want this behavior when the
+ start-point is either a local or remote branch.
--no-track::
- When -b is given and a branch is created off a remote branch,
- set up configuration so that git-pull will not retrieve data
- from the remote branch, ignoring the branch.autosetupmerge
- configuration variable.
+ Ignore the branch.autosetupmerge configuration variable.
-l::
Create the new branch's reflog. This activates recording of
@@ -112,7 +112,7 @@ current branch and directly point at the commit named by the tag
(`v2.6.18` in the above example).
You can use usual git commands while in this state. You can use
-`git-reset --hard $othercommit` to further move around, for
+`git reset --hard $othercommit` to further move around, for
example. You can make changes and create a new commit on top of
a detached HEAD. You can even create a merge by using `git
merge $othercommit`.
@@ -216,4 +216,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 877ab66ef..837fb08b7 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -7,7 +7,7 @@ git-cherry-pick - Apply the change introduced by an existing commit
SYNOPSIS
--------
-'git-cherry-pick' [--edit] [-n] [-m parent-number] [-x] <commit>
+'git cherry-pick' [--edit] [-n] [-m parent-number] [-s] [-x] <commit>
DESCRIPTION
-----------
@@ -19,11 +19,12 @@ OPTIONS
-------
<commit>::
Commit to cherry-pick.
- For a more complete list of ways to spell commits, see
+ For a more complete list of ways to spell commits, see the
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
--e|--edit::
- With this option, `git-cherry-pick` will let you edit the commit
+-e::
+--edit::
+ With this option, 'git-cherry-pick' will let you edit the commit
message prior to committing.
-x::
@@ -44,30 +45,36 @@ OPTIONS
described above, and `-r` was to disable it. Now the
default is not to do `-x` so this option is a no-op.
--m parent-number|--mainline parent-number::
- Usually you cannot revert a merge because you do not know which
+-m parent-number::
+--mainline parent-number::
+ Usually you cannot cherry-pick a merge because you do not know which
side of the merge should be considered the mainline. This
option specifies the parent number (starting from 1) of
the mainline and allows cherry-pick to replay the change
relative to the specified parent.
--n|--no-commit::
+-n::
+--no-commit::
Usually the command automatically creates a commit with
a commit log message stating which commit was
cherry-picked. This flag applies the change necessary
- to cherry-pick the named commit to your working tree,
- but does not make the commit. In addition, when this
- option is used, your working tree does not have to match
+ to cherry-pick the named commit to your working tree
+ and the index, but does not make the commit. In addition,
+ when this option is used, your index does not have to match
the HEAD commit. The cherry-pick is done against the
- beginning state of your working tree.
+ beginning state of your index.
+
This is useful when cherry-picking more than one commits'
-effect to your working tree in a row.
+effect to your index in a row.
+
+-s::
+--signoff::
+ Add Signed-off-by line at the end of the commit message.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -75,4 +82,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cherry.txt b/Documentation/git-cherry.txt
index b0468aa74..74d14c4e7 100644
--- a/Documentation/git-cherry.txt
+++ b/Documentation/git-cherry.txt
@@ -7,12 +7,14 @@ git-cherry - Find commits not merged upstream
SYNOPSIS
--------
-'git-cherry' [-v] <upstream> [<head>] [<limit>]
+'git cherry' [-v] <upstream> [<head>] [<limit>]
DESCRIPTION
-----------
The changeset (or "diff") of each commit between the fork-point and <head>
is compared against each commit between the fork-point and <upstream>.
+The commits are compared with their 'patch id', obtained from
+the 'git-patch-id' program.
Every commit that doesn't exist in the <upstream> branch
has its id (sha1) reported, prefixed by a symbol. The ones that have
@@ -35,8 +37,8 @@ to and including <limit> are not reported:
\__*__*__<limit>__-__+__> <head>
-Because git-cherry compares the changeset rather than the commit id
-(sha1), you can use git-cherry to find out if a commit you made locally
+Because 'git-cherry' compares the changeset rather than the commit id
+(sha1), you can use 'git-cherry' to find out if a commit you made locally
has been applied <upstream> under a different commit id. For example,
this will happen if you're feeding patches <upstream> via email rather
than pushing or pulling commits directly.
@@ -56,9 +58,13 @@ OPTIONS
<limit>::
Do not report commits up to (and including) limit.
+SEE ALSO
+--------
+linkgit:git-patch-id[1]
+
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -66,4 +72,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-citool.txt b/Documentation/git-citool.txt
index aca1d75e5..670cb02b6 100644
--- a/Documentation/git-citool.txt
+++ b/Documentation/git-citool.txt
@@ -14,9 +14,9 @@ DESCRIPTION
A Tcl/Tk based graphical interface to review modified files, stage
them into the index, enter a commit message and record the new
commit onto the current branch. This interface is an alternative
-to the less interactive linkgit:git-commit[1] program.
+to the less interactive 'git-commit' program.
-git-citool is actually a standard alias for 'git gui citool'.
+'git-citool' is actually a standard alias for `git gui citool`.
See linkgit:git-gui[1] for more details.
Author
@@ -29,4 +29,4 @@ Documentation by Shawn O. Pearce <spearce@spearce.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt
index 5e9da036b..8a114509f 100644
--- a/Documentation/git-clean.txt
+++ b/Documentation/git-clean.txt
@@ -8,7 +8,7 @@ git-clean - Remove untracked files from the working tree
SYNOPSIS
--------
[verse]
-'git-clean' [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...
+'git clean' [-d] [-f] [-n] [-q] [-x | -X] [--] <path>...
DESCRIPTION
-----------
@@ -16,8 +16,8 @@ Removes files unknown to git. This allows to clean the working tree
from files that are not under version control. If the '-x' option is
specified, ignored files are also removed, allowing to remove all
build products.
-When optional `<paths>...` arguments are given, the paths
-affected are further limited to those that match them.
+If any optional `<path>...` arguments are given, only those paths
+are affected.
OPTIONS
@@ -27,19 +27,21 @@ OPTIONS
-f::
If the git configuration specifies clean.requireForce as true,
- git-clean will refuse to run unless given -f or -n.
+ 'git-clean' will refuse to run unless given -f or -n.
-n::
+--dry-run::
Don't actually remove anything, just show what would be done.
-q::
+--quiet::
Be quiet, only report errors, but not the files that are
successfully removed.
-x::
Don't use the ignore rules. This allows removing all untracked
files, including build products. This can be used (possibly in
- conjunction with linkgit:git-reset[1]) to create a pristine
+ conjunction with 'git-reset') to create a pristine
working directory to test a clean build.
-X::
@@ -54,4 +56,4 @@ Written by Pavel Roskin <proski@gnu.org>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index fdccbd4cb..0e14e732f 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -9,8 +9,8 @@ git-clone - Clone a repository into a new directory
SYNOPSIS
--------
[verse]
-'git-clone' [--template=<template_directory>]
- [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare]
+'git clone' [--template=<template_directory>]
+ [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
[--depth <depth>] [--] <repository> [<directory>]
@@ -62,6 +62,18 @@ OPTIONS
.git/objects/info/alternates to share the objects
with the source repository. The resulting repository
starts out without any object of its own.
++
+*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
+source repository, some objects may become unreferenced (or dangling).
+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.
+
+
--reference <repository>::
If the reference repository is on the local machine
@@ -70,11 +82,13 @@ OPTIONS
an already existing repository as an alternate will
require fewer objects to be copied from the repository
being cloned, reducing network and local storage costs.
++
+*NOTE*: see NOTE to --shared option.
--quiet::
-q::
- Operate quietly. This flag is passed to "rsync" and
- "git-fetch-pack" commands when given.
+ Operate quietly. This flag is also passed to the `rsync'
+ command when given.
--no-checkout::
-n::
@@ -92,6 +106,9 @@ OPTIONS
used, neither remote-tracking branches nor the related
configuration variables are created.
+--mirror::
+ Set up a mirror of the remote repository. This implies --bare.
+
--origin <name>::
-o <name>::
Instead of using the remote name 'origin' to keep track
@@ -99,9 +116,8 @@ OPTIONS
--upload-pack <upload-pack>::
-u <upload-pack>::
- When given, and the repository to clone from is handled
- by 'git-fetch-pack', '--exec=<upload-pack>' is passed to
- the command to specify non-default path for the command
+ When given, and the repository to clone from is accessed
+ via ssh, this specifies a non-default path for the command
run on the other end.
--template=<template_directory>::
@@ -191,4 +207,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index 170803a6d..92ab3ab4a 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -8,7 +8,7 @@ git-commit-tree - Create a new commit object
SYNOPSIS
--------
-'git-commit-tree' <tree> [-p <parent commit>]\* < changelog
+'git commit-tree' <tree> [-p <parent commit>]\* < changelog
DESCRIPTION
-----------
@@ -16,12 +16,12 @@ This is usually not what an end user wants to run directly. See
linkgit:git-commit[1] instead.
Creates a new commit object based on the provided tree object and
-emits the new commit object id on stdout. If no parent is given then
-it is considered to be an initial tree.
+emits the new commit object id on stdout.
-A commit object usually has 1 parent (a commit after a change) or up
-to 16 parents. More than one parent represents a merge of branches
-that led to them.
+A commit object may have any number of parents. With exactly one
+parent, it is an ordinary commit. Having more than one parent makes
+the commit a merge between several lines of history. Initial (root)
+commits have no parents.
While a tree represents a particular directory state of a working
directory, a commit represents that state in "time", and explains how
@@ -70,7 +70,7 @@ is taken from the configuration items user.name and user.email, or, if not
present, system user name and fully qualified hostname.
A commit comment is read from stdin. If a changelog
-entry is not provided via "<" redirection, "git-commit-tree" will just wait
+entry is not provided via "<" redirection, 'git-commit-tree' will just wait
for one to be entered and terminated with ^D.
@@ -88,7 +88,7 @@ Discussion
include::i18n.txt[]
-See Also
+SEE ALSO
--------
linkgit:git-write-tree[1]
@@ -103,4 +103,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index c3725b2ed..0e25bb862 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -8,23 +8,23 @@ git-commit - Record changes to the repository
SYNOPSIS
--------
[verse]
-'git-commit' [-a | --interactive] [-s] [-v] [-u]
- [(-c | -C) <commit> | -F <file> | -m <msg> | --amend]
- [--allow-empty] [--no-verify] [-e] [--author <author>]
+'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend]
+ [(-c | -C) <commit>] [-F <file> | -m <msg>]
+ [--allow-empty] [--no-verify] [-e] [--author=<author>]
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
DESCRIPTION
-----------
-Use 'git commit' to store the current contents of the index in a new
-commit along with a log message describing the changes you have made.
+Stores the current contents of the index in a new commit along
+with a log message from the user describing the changes.
The content to be added can be specified in several ways:
-1. by using linkgit:git-add[1] to incrementally "add" changes to the
+1. by using 'git-add' to incrementally "add" changes to the
index before using the 'commit' command (Note: even modified
files must be "added");
-2. by using linkgit:git-rm[1] to remove files from the working tree
+2. by using 'git-rm' to remove files from the working tree
and the index, again before using the 'commit' command;
3. by listing files as arguments to the 'commit' command, in which
@@ -39,55 +39,65 @@ The content to be added can be specified in several ways:
5. by using the --interactive switch with the 'commit' command to decide one
by one which files should be part of the commit, before finalizing the
- operation. Currently, this is done by invoking `git-add --interactive`.
+ operation. Currently, this is done by invoking 'git-add --interactive'.
-The linkgit:git-status[1] command can be used to obtain a
+The 'git-status' command can be used to obtain a
summary of what is included by any of the above for the next
commit by giving the same set of parameters you would give to
this command.
-If you make a commit and then found a mistake immediately after
-that, you can recover from it with linkgit:git-reset[1].
+If you make a commit and then find a mistake immediately after
+that, you can recover from it with 'git-reset'.
OPTIONS
-------
--a|--all::
+-a::
+--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.
--c or -C <commit>::
- Take existing commit object, and reuse the log message
+-C <commit>::
+--reuse-message=<commit>::
+ Take an existing commit object, and reuse the log message
and the authorship information (including the timestamp)
- when creating the commit. With '-C', the editor is not
- invoked; with '-c' the user can further edit the commit
- message.
+ when creating the commit.
+
+-c <commit>::
+--reedit-message=<commit>::
+ Like '-C', but with '-c' the editor is invoked, so that
+ the user can further edit the commit message.
-F <file>::
+--file=<file>::
Take the commit message from the given file. Use '-' to
read the message from the standard input.
---author <author>::
+--author=<author>::
Override the author name used in the commit. Use
`A U Thor <author@example.com>` format.
--m <msg>|--message=<msg>::
+-m <msg>::
+--message=<msg>::
Use the given <msg> as the commit message.
--t <file>|--template=<file>::
+-t <file>::
+--template=<file>::
Use the contents of the given file as the initial version
of the commit message. The editor is invoked and you can
make subsequent changes. If a message is specified using
the `-m` or `-F` options, this option has no effect. This
overrides the `commit.template` configuration variable.
--s|--signoff::
+-s::
+--signoff::
Add Signed-off-by line at the end of the commit message.
+-n::
--no-verify::
This option bypasses the pre-commit and commit-msg hooks.
- See also link:hooks.html[hooks].
+ See also linkgit:githooks[5].
--allow-empty::
Usually recording a commit that has the exact same tree as its
@@ -105,14 +115,14 @@ OPTIONS
'whitespace' removes just leading/trailing whitespace lines
and 'strip' removes both whitespace and commentary.
--e|--edit::
+-e::
+--edit::
The message taken from file with `-F`, command line with
`-m`, and from file with `-C` are usually used as the
commit log message unmodified. This option lets you
further edit the message taken from these sources.
--amend::
-
Used to amend the tip of the current branch. Prepare the tree
object you would want to replace the latest commit as usual
(this includes the usual -i/-o and explicit paths), and the
@@ -133,26 +143,51 @@ It is a rough equivalent for:
but can be used to amend a merge commit.
--
--i|--include::
+-i::
+--include::
Before making a commit out of staged contents so far,
stage the contents of paths given on the command line
as well. This is usually not what you want unless you
are concluding a conflicted merge.
--u|--untracked-files::
- Show all untracked files, also those in uninteresting
- directories, in the "Untracked files:" section of commit
- message template. Without this option only its name and
- a trailing slash are displayed for each untracked
- directory.
+-o::
+--only::
+ Make a commit only from the paths specified on the
+ command line, disregarding any contents that have been
+ staged so far. This is the default mode of operation of
+ 'git-commit' if any paths are given on the command line,
+ in which case this option can be omitted.
+ If this option is specified together with '--amend', then
+ no paths need be specified, which can be used to amend
+ the last commit without committing changes that have
+ already been staged.
+
+-u[<mode>]::
+--untracked-files[=<mode>]::
+ Show untracked files (Default: 'all').
++
+The mode parameter is optional, and is used to specify
+the handling of untracked files. The possible options are:
++
+--
+ - 'no' - Show no untracked files
+ - 'normal' - Shows untracked files and directories
+ - 'all' - Also shows individual files in untracked directories.
+--
++
+See linkgit:git-config[1] for configuration variable
+used to change the default for when the option is not
+specified.
--v|--verbose::
+-v::
+--verbose::
Show unified diff between the HEAD commit and what
would be committed at the bottom of the commit message
template. Note that this diff output doesn't have its
lines prefixed with '#'.
--q|--quiet::
+-q::
+--quiet::
Suppress commit summary message.
\--::
@@ -170,10 +205,10 @@ EXAMPLES
--------
When recording your own work, the contents of modified files in
your working tree are temporarily stored to a staging area
-called the "index" with linkgit:git-add[1]. A file can be
+called the "index" with 'git-add'. A file can be
reverted back, only in the index but not in the working tree,
-to that of the last commit with `git-reset HEAD -- <file>`,
-which effectively reverts `git-add` and prevents the changes to
+to that of the last commit with `git reset HEAD -- <file>`,
+which effectively reverts 'git-add' and prevents the changes to
this file from participating in the next commit. After building
the state to be committed incrementally with these commands,
`git commit` (without any pathname parameter) is used to record what
@@ -229,13 +264,13 @@ $ git commit
this second commit would record the changes to `hello.c` and
`hello.h` as expected.
-After a merge (initiated by either linkgit:git-merge[1] or
-linkgit:git-pull[1]) stops because of conflicts, cleanly merged
+After a merge (initiated by 'git-merge' or 'git-pull') stops
+because of conflicts, cleanly merged
paths are already staged to be committed for you, and paths that
conflicted are left in unmerged state. You would have to first
-check which paths are conflicting with linkgit:git-status[1]
+check which paths are conflicting with 'git-status'
and after fixing them manually in your working tree, you would
-stage the result as usual with linkgit:git-add[1]:
+stage the result as usual with 'git-add':
------------
$ git status | grep unmerged
@@ -280,8 +315,8 @@ order).
HOOKS
-----
-This command can run `commit-msg`, `pre-commit`, and
-`post-commit` hooks. See link:hooks.html[hooks] for more
+This command can run `commit-msg`, `prepare-commit-msg`, `pre-commit`,
+and `post-commit` hooks. See linkgit:githooks[5] for more
information.
@@ -296,9 +331,9 @@ linkgit:git-commit-tree[1]
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
+Junio C Hamano <gitster@pobox.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index e4d0e4752..28e186109 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -9,19 +9,19 @@ git-config - Get and set repository or global options
SYNOPSIS
--------
[verse]
-'git-config' [<file-option>] [type] [-z|--null] name [value [value_regex]]
-'git-config' [<file-option>] [type] --add name value
-'git-config' [<file-option>] [type] --replace-all name [value [value_regex]]
-'git-config' [<file-option>] [type] [-z|--null] --get name [value_regex]
-'git-config' [<file-option>] [type] [-z|--null] --get-all name [value_regex]
-'git-config' [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
-'git-config' [<file-option>] --unset name [value_regex]
-'git-config' [<file-option>] --unset-all name [value_regex]
-'git-config' [<file-option>] --rename-section old_name new_name
-'git-config' [<file-option>] --remove-section name
-'git-config' [<file-option>] [-z|--null] -l | --list
-'git-config' [<file-option>] --get-color name [default]
-'git-config' [<file-option>] --get-colorbool name [stdout-is-tty]
+'git config' [<file-option>] [type] [-z|--null] name [value [value_regex]]
+'git config' [<file-option>] [type] --add name value
+'git config' [<file-option>] [type] --replace-all name [value [value_regex]]
+'git config' [<file-option>] [type] [-z|--null] --get name [value_regex]
+'git config' [<file-option>] [type] [-z|--null] --get-all name [value_regex]
+'git config' [<file-option>] [type] [-z|--null] --get-regexp name_regex [value_regex]
+'git config' [<file-option>] --unset name [value_regex]
+'git config' [<file-option>] --unset-all name [value_regex]
+'git config' [<file-option>] --rename-section old_name new_name
+'git config' [<file-option>] --remove-section name
+'git config' [<file-option>] [-z|--null] -l | --list
+'git config' [<file-option>] --get-color name [default]
+'git config' [<file-option>] --get-colorbool name [stdout-is-tty]
DESCRIPTION
-----------
@@ -101,7 +101,8 @@ rather than from all available files.
+
See also <<FILES>>.
--f config-file, --file config-file::
+-f config-file::
+--file config-file::
Use the given config file instead of the one specified by GIT_CONFIG.
--remove-section::
@@ -116,21 +117,23 @@ See also <<FILES>>.
--unset-all::
Remove all lines matching the key from config file.
--l, --list::
+-l::
+--list::
List all variables set in config file.
--bool::
- git-config will ensure that the output is "true" or "false"
+ 'git-config' will ensure that the output is "true" or "false"
--int::
- git-config will ensure that the output is a simple
+ 'git-config' will ensure that the output is a simple
decimal number. An optional value suffix of 'k', 'm', or 'g'
in the config file will cause the value to be multiplied
by 1024, 1048576, or 1073741824 prior to output.
--z, --null::
+-z::
+--null::
For all options that output values and/or keys, always
- end values with with the null character (instead of a
+ end values with the null character (instead of a
newline). Use newline instead as a delimiter between
key and value. This allows for secure parsing of the
output without getting confused e.g. by values that
@@ -144,6 +147,8 @@ See also <<FILES>>.
"auto". If `stdout-is-tty` is missing, then checks the standard
output of the command itself, and exits with status 0 if color
is to be used, or exits with status 1 otherwise.
+ When the color setting for `name` is undefined, the command uses
+ `color.ui` as fallback.
--get-color name default::
@@ -157,7 +162,7 @@ FILES
-----
If not set explicitly with '--file', there are three files where
-git-config will search for configuration options:
+'git-config' will search for configuration options:
$GIT_DIR/config::
Repository specific configuration file. (The filename is
@@ -174,23 +179,18 @@ $(prefix)/etc/gitconfig::
If no further options are given, all reading options will read all of these
files that are available. If the global or the system-wide configuration
file are not available they will be ignored. If the repository configuration
-file is not available or readable, git-config will exit with a non-zero
+file is not available or readable, 'git-config' will exit with a non-zero
error code. However, in neither case will an error message be issued.
All writing options will per default write to the repository specific
configuration file. Note that this also affects options like '--replace-all'
-and '--unset'. *git-config will only ever change one file at a time*.
+and '--unset'. *'git-config' will only ever change one file at a time*.
You can override these rules either by command line options or by environment
variables. The '--global' and the '--system' options will limit the file used
to the global or system-wide file respectively. The GIT_CONFIG environment
variable has a similar effect, but you can specify any filename you want.
-The GIT_CONFIG_LOCAL environment variable on the other hand only changes
-the name used instead of the repository configuration file. The global and
-the system-wide configuration files will still be read. (For writing options
-this will obviously result in the same behavior as using GIT_CONFIG.)
-
ENVIRONMENT
-----------
@@ -200,10 +200,6 @@ GIT_CONFIG::
Using the "--global" option forces this to ~/.gitconfig. Using the
"--system" option forces this to $(prefix)/etc/gitconfig.
-GIT_CONFIG_LOCAL::
- Take the configuration from the given file instead if .git/config.
- Still read the global and the system-wide configuration files, though.
-
See also <<FILES>>.
@@ -226,7 +222,7 @@ Given a .git/config like this:
; Our diff algorithm
[diff]
- external = "/usr/local/bin/gnu-diff -u"
+ external = /usr/local/bin/diff-wrapper
renames = true
; Proxy settings
@@ -332,4 +328,4 @@ Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.ker
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt
index 7fb08e934..75a8da1ca 100644
--- a/Documentation/git-count-objects.txt
+++ b/Documentation/git-count-objects.txt
@@ -7,7 +7,7 @@ git-count-objects - Count unpacked number of objects and their disk consumption
SYNOPSIS
--------
-'git-count-objects' [-v]
+'git count-objects' [-v]
DESCRIPTION
-----------
@@ -18,15 +18,16 @@ them, to help you decide when it is a good time to repack.
OPTIONS
-------
-v::
+--verbose::
In addition to the number of loose objects and disk
space consumed, it reports the number of in-pack
objects, number of packs, and number of objects that can be
- removed by running `git-prune-packed`.
+ removed by running `git prune-packed`.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -34,4 +35,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt
index 9a47b4c39..2da8588f4 100644
--- a/Documentation/git-cvsexportcommit.txt
+++ b/Documentation/git-cvsexportcommit.txt
@@ -8,7 +8,8 @@ git-cvsexportcommit - Export a single commit to a CVS checkout
SYNOPSIS
--------
-'git-cvsexportcommit' [-h] [-u] [-v] [-c] [-P] [-p] [-a] [-d cvsroot] [-w cvsworkdir] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
+'git cvsexportcommit' [-h] [-u] [-v] [-c] [-P] [-p] [-a] [-d cvsroot]
+ [-w cvsworkdir] [-W] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
DESCRIPTION
@@ -26,8 +27,8 @@ by default.
Supports file additions, removals, and commits that affect binary files.
-If the commit is a merge commit, you must tell git-cvsexportcommit what parent
-should the changeset be done against.
+If the commit is a merge commit, you must tell 'git-cvsexportcommit' what
+parent the changeset should be done against.
OPTIONS
-------
@@ -65,11 +66,22 @@ 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.
+ current directory is within a git repository. The default is the
+ value of 'cvsexportcommit.cvsdir'.
+
+-W::
+ Tell cvsexportcommit that the current working directory is not only
+ a Git checkout, but also the CVS checkout. Therefore, Git will
+ reset the working directory to the parent commit before proceeding.
-v::
Verbose.
+CONFIGURATION
+-------------
+cvsexportcommit.cvsdir::
+ The default location of the CVS checkout to use for the export.
+
EXAMPLES
--------
@@ -78,14 +90,14 @@ Merge one patch into CVS::
------------
$ export GIT_DIR=~/project/.git
$ cd ~/project_cvs_checkout
-$ git-cvsexportcommit -v <commit-sha1>
+$ git cvsexportcommit -v <commit-sha1>
$ cvs commit -F .msg <files>
------------
Merge one patch into CVS (-c and -w options). The working directory is within the Git Repo::
+
------------
- $ git-cvsexportcommit -v -c -w ~/project_cvs_checkout <commit-sha1>
+ $ git cvsexportcommit -v -c -w ~/project_cvs_checkout <commit-sha1>
------------
Merge pending patches into CVS automatically -- only if you really know what you are doing::
@@ -93,7 +105,7 @@ Merge pending patches into CVS automatically -- only if you really know what you
------------
$ export GIT_DIR=~/project/.git
$ cd ~/project_cvs_checkout
-$ git-cherry cvshead myhead | sed -n 's/^+ //p' | xargs -l1 git-cvsexportcommit -c -p -v
+$ git cherry cvshead myhead | sed -n 's/^+ //p' | xargs -l1 git cvsexportcommit -c -p -v
------------
Author
@@ -106,4 +118,4 @@ Documentation by Martin Langhoff <martin@catalyst.net.nz> and others.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
index dbce50369..b7a8c10b8 100644
--- a/Documentation/git-cvsimport.txt
+++ b/Documentation/git-cvsimport.txt
@@ -9,7 +9,7 @@ git-cvsimport - Salvage your data out of another SCM people love to hate
SYNOPSIS
--------
[verse]
-'git-cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>]
+'git cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>]
[-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>]
[-C <git_repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>]
[-a] [-m] [-M <regex>] [-S <regex>] [-L <commitlimit>]
@@ -25,12 +25,18 @@ Splitting the CVS log into patch sets is done by 'cvsps'.
At least version 2.1 is required.
You should *never* do any work of your own on the branches that are
-created by git-cvsimport. By default initial import will create and populate a
+created by 'git-cvsimport'. By default initial import will create and populate a
"master" branch from the CVS repository's main branch which you're free
-to work with; after that, you need to 'git merge' incremental imports, or
+to work with; after that, you need to 'git-merge' incremental imports, or
any CVS branches, yourself. It is advisable to specify a named remote via
-r to separate and protect the incoming branches.
+If you intend to set up a shared public repository that all developers can
+read/write, or if you want to use linkgit:git-cvsserver[1], then you
+probably want to make a bare clone of the imported repository,
+and use the clone as the shared repository.
+See linkgit:gitcvs-migration[7].
+
OPTIONS
-------
@@ -40,13 +46,13 @@ OPTIONS
-d <CVSROOT>::
The root of the CVS archive. May be local (a simple path) or remote;
currently, only the :local:, :ext: and :pserver: access methods
- are supported. If not given, git-cvsimport will try to read it
+ are supported. If not given, 'git-cvsimport' will try to read it
from `CVS/Root`. If no such file exists, it checks for the
`CVSROOT` environment variable.
<CVS_module>::
The CVS module you want to import. Relative to <CVSROOT>.
- If not given, git-cvsimport tries to read it from
+ If not given, 'git-cvsimport' tries to read it from
`CVS/Repository`.
-C <target-dir>::
@@ -56,14 +62,14 @@ OPTIONS
-r <remote>::
The git remote to import this CVS repository into.
Moves all CVS branches into remotes/<remote>/<branch>
- akin to the git-clone --use-separate-remote option.
+ akin to the 'git-clone' "--use-separate-remote" option.
-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.
When a remote is specified the 'HEAD' branch is named
- remotes/<remote>/master mirroring git-clone behaviour.
+ remotes/<remote>/master mirroring 'git-clone' behaviour.
Use this option if you want to import into a different
branch.
+
@@ -102,13 +108,17 @@ If you need to pass multiple options, separate them with a comma.
-m::
Attempt to detect merges based on the commit message. This option
- will enable default regexes that try to capture the name source
+ will enable default regexes that try to capture the source
branch name from the commit message.
-M <regex>::
Attempt to detect merges based on the commit message with a custom
- regex. It can be used with '-m' to also see the default regexes.
- You must escape forward slashes.
+ regex. It can be used with '-m' to enable the default regexes
+ as well. You must escape forward slashes.
++
+The regex must capture the source branch name in $1.
++
+This option can be used several times to provide several detection regexes.
-S <regex>::
Skip paths matching the regex.
@@ -132,17 +142,17 @@ If you need to pass multiple options, separate them with a comma.
---------
+
-git-cvsimport will make it appear as those authors had
+'git-cvsimport' will make it appear as those authors had
their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly
all along.
+
For convenience, this data is saved to `$GIT_DIR/cvs-authors`
each time the '-A' option is provided and read from that same
-file each time git-cvsimport is run.
+file each time 'git-cvsimport' is run.
+
It is not recommended to use this feature if you intend to
export changes back to CVS again later with
-linkgit:git-cvsexportcommit[1].
+'git-cvsexportcommit'.
-h::
Print a short usage message and exit.
@@ -166,4 +176,4 @@ Documentation by Matthias Urlichs <smurf@smurf.noris.de>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt
index d75e40134..c2d3c90d2 100644
--- a/Documentation/git-cvsserver.txt
+++ b/Documentation/git-cvsserver.txt
@@ -22,7 +22,7 @@ cvspserver stream tcp nowait nobody /usr/bin/git-cvsserver git-cvsserver pserver
Usage:
[verse]
-'git-cvsserver' [options] [pserver|server] [<directory> ...]
+'git cvsserver' [options] [pserver|server] [<directory> ...]
OPTIONS
-------
@@ -41,10 +41,13 @@ Don't allow recursing into subdirectories
Don't check for `gitcvs.enabled` in config. You also have to specify a list
of allowed directories (see below) if you want to use this option.
---version, -V::
+-V::
+--version::
Print version information and exit
---help, -h, -H::
+-h::
+-H::
+--help::
Print usage information and exit
<directory>::
@@ -74,7 +77,7 @@ over pserver for anonymous CVS access.
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.
@@ -100,7 +103,7 @@ looks like
------
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.
+environment variable, you can rename 'git-cvsserver' to `cvs`.
Note: Newer CVS versions (>= 1.12.11) also support specifying
CVS_SERVER directly in CVSROOT like
@@ -110,7 +113,9 @@ cvs -d ":ext;CVS_SERVER=git-cvsserver:user@server/path/repo.git" co <HEAD_name>
------
This has the advantage that it will be saved in your 'CVS/Root' files and
you don't need to worry about always setting the correct environment
-variable.
+variable. SSH users restricted to 'git-shell' don't need to override the default
+with CVS_SERVER (and shouldn't) as 'git-shell' understands `cvs` to mean
+'git-cvsserver' and pretends that the other end runs the real 'cvs' better.
--
2. For each repo that you want accessible from CVS you need to edit config in
the repo and add the following section.
@@ -123,11 +128,14 @@ variable.
logfile=/path/to/logfile
------
-Note: you need to ensure each user that is going to invoke git-cvsserver has
+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.
+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]]
All configuration variables can also be overridden for a specific method of
access. Valid method names are "ext" (for SSH access) and "pserver". The
@@ -141,25 +149,29 @@ allowing access over SSH.
enabled=1
------
--
-3. On the client machine you need to set the following variables.
- CVSROOT should be set as per normal, but the directory should point at the
- appropriate git repo. For example:
+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
+ _not_ restricted to 'git-shell', CVS_SERVER should be set to 'git-cvsserver'.
+
--
-For SSH access, CVS_SERVER should be set to git-cvsserver
-
-Example:
-
------
export CVSROOT=:ext:user@server:/var/git/project.git
export CVS_SERVER=git-cvsserver
------
--
-4. For SSH clients that will make commits, make sure their .bashrc file
- sets the GIT_AUTHOR and GIT_COMMITTER variables.
+4. For SSH clients that will make commits, make sure their server-side
+ .ssh/environment files (or .bashrc, etc., according to their specific shell)
+ export appropriate values for GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL,
+ GIT_COMMITTER_NAME, and GIT_COMMITTER_EMAIL. For SSH clients whose login
+ 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. Example:
+ 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:
+
------
cvs co -d project-master master
@@ -169,27 +181,27 @@ Example:
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 for faster access. The
database doesn't contain any persistent data and can be completely
regenerated from the git repository at any time. The database
needs to be updated (i.e. written to) after every commit.
-If the commit is done directly by using git (as opposed to
-using git-cvsserver) the update will need to happen on the
-next repository access by git-cvsserver, independent of
+If the commit is done directly by using `git` (as opposed to
+using 'git-cvsserver') the update will need to happen on the
+next repository access by 'git-cvsserver', independent of
access method and requested operation.
That means that even if you offer only read access (e.g. by using
-the pserver method), git-cvsserver should have write access to
+the pserver method), 'git-cvsserver' should have write access to
the database to work reliably (otherwise you need to make sure
-that the database if up-to-date all the time git-cvsserver is run).
+that the database is up-to-date any time 'git-cvsserver' is executed).
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
-git-cvsserver write access to the database file without granting
+'git-cvsserver' write access to the database file without granting
them write access to the directory, too.
You can configure the database backend with the following
@@ -198,13 +210,13 @@ configuration variables:
Configuring database backend
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-git-cvsserver uses the Perl DBI module. Please also read
+'git-cvsserver' uses the Perl DBI module. Please also read
its documentation if changing these variables, especially
about `DBI->connect()`.
gitcvs.dbname::
Database name. The exact meaning depends on the
- used database driver, for SQLite this is a filename.
+ selected database driver, for SQLite this is a filename.
Supports variable substitution (see below). May
not contain semicolons (`;`).
Default: '%Ggitcvs.%m.sqlite'
@@ -215,7 +227,7 @@ gitcvs.dbdriver::
with 'DBD::SQLite', reported to work with
'DBD::Pg', and reported *not* to work with 'DBD::mysql'.
Please regard this as an experimental feature. May not
- contain double colons (`:`).
+ contain colons (`:`).
Default: 'SQLite'
gitcvs.dbuser::
@@ -227,6 +239,11 @@ gitcvs.dbpass::
Database password. Only useful if setting `dbdriver`, since
SQLite has no concept of database passwords.
+gitcvs.dbTableNamePrefix::
+ Database table name prefix. Supports variable substitution
+ (see below). Any non-alphabetic characters will be replaced
+ with underscores.
+
All variables can also be set per access method, see <<configaccessmethod,above>>.
Variable substitution
@@ -245,7 +262,7 @@ In `dbdriver` and `dbuser` you can use the following variables:
%a::
access method (one of "ext" or "pserver")
%u::
- Name of the user running git-cvsserver.
+ Name of the user running 'git-cvsserver'.
If no name can be determined, the
numeric uid is used.
@@ -271,8 +288,8 @@ you will definitely want to have SSH keys setup.
Alternatively, you can just use the non-standard extssh protocol that Eclipse
offer. In that case CVS_SERVER is ignored, and you will have to replace
-the cvs utility on the server with git-cvsserver or manipulate your `.bashrc`
-so that calling 'cvs' effectively calls git-cvsserver.
+the cvs utility on the server with 'git-cvsserver' or manipulate your `.bashrc`
+so that calling 'cvs' effectively calls 'git-cvsserver'.
Clients known to work
---------------------
@@ -290,16 +307,37 @@ checkout, diff, status, update, log, add, remove, commit.
Legacy monitoring operations are not supported (edit, watch and related).
Exports and tagging (tags and branches) are not supported at this stage.
-The server should set the '-k' mode to binary when relevant, however,
-this is not really implemented yet. For now, you can force the server
-to set '-kb' for all files by setting the `gitcvs.allbinary` config
-variable. In proper GIT tradition, the contents of the files are
-always respected. No keyword expansion or newline munging is supported.
+CRLF Line Ending Conversions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+By default the server leaves the '-k' mode blank for all files,
+which causes the cvs client to treat them as a text files, subject
+to crlf conversion on some platforms.
+
+You can make the server use `crlf` attributes to set the '-k' modes
+for files by setting the `gitcvs.usecrlfattr` config variable.
+In this case, if `crlf` is explicitly unset ('-crlf'), then the
+server will set '-kb' mode for binary files. If `crlf` is set,
+then the '-k' mode will explicitly be left blank. See
+also linkgit:gitattributes[5] for more information about the `crlf`
+attribute.
+
+Alternatively, if `gitcvs.usecrlfattr` config is not enabled
+or if the `crlf` attribute is unspecified for a filename, then
+the server uses the `gitcvs.allbinary` config for the default setting.
+If `gitcvs.allbinary` is set, then file not otherwise
+specified will default to '-kb' mode. Otherwise the '-k' mode
+is left blank. But if `gitcvs.allbinary` is set to "guess", then
+the correct '-k' mode will be guessed based on the contents of
+the file.
+
+For best consistency with 'cvs', it is probably best to override the
+defaults by setting `gitcvs.usecrlfattr` to true,
+and `gitcvs.allbinary` to "guess".
Dependencies
------------
-
-git-cvsserver depends on DBD::SQLite.
+'git-cvsserver' depends on DBD::SQLite.
Copyright and Authors
---------------------
@@ -319,4 +357,4 @@ Documentation by Martyn Smith <martyn@catalyst.net.nz>, Martin Langhoff <martin@
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index fd83bc783..4ba4b75c1 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -8,12 +8,12 @@ git-daemon - A really simple server for git repositories
SYNOPSIS
--------
[verse]
-'git-daemon' [--verbose] [--syslog] [--export-all]
- [--timeout=n] [--init-timeout=n] [--strict-paths]
- [--base-path=path] [--user-path | --user-path=path]
- [--interpolated-path=pathtemplate]
- [--reuseaddr] [--detach] [--pid-file=file]
- [--enable=service] [--disable=service]
+'git daemon' [--verbose] [--syslog] [--export-all]
+ [--timeout=n] [--init-timeout=n] [--strict-paths]
+ [--base-path=path] [--user-path | --user-path=path]
+ [--interpolated-path=pathtemplate]
+ [--reuseaddr] [--detach] [--pid-file=file]
+ [--enable=service] [--disable=service]
[--allow-override=service] [--forbid-override=service]
[--inetd | [--listen=host_or_ipaddr] [--port=n] [--user=user [--group=group]]
[directory...]
@@ -31,32 +31,32 @@ pass some directory paths as 'git-daemon' arguments, you can further restrict
the offers to a whitelist comprising of those.
By default, only `upload-pack` service is enabled, which serves
-`git-fetch-pack` and `git-ls-remote` clients, which are invoked
-from `git-fetch`, `git-pull`, and `git-clone`.
+'git-fetch-pack' and 'git-ls-remote' clients, which are invoked
+from 'git-fetch', 'git-pull', and 'git-clone'.
This is ideally suited for read-only updates, i.e., pulling from
git repositories.
-An `upload-archive` also exists to serve `git-archive`.
+An `upload-archive` also exists to serve 'git-archive'.
OPTIONS
-------
--strict-paths::
Match paths exactly (i.e. don't allow "/foo/repo" when the real path is
"/foo/repo.git" or "/foo/repo/.git") and don't do user-relative paths.
- git-daemon will refuse to start when this option is enabled and no
+ 'git-daemon' will refuse to start when this option is enabled and no
whitelist is specified.
--base-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
+ 'git://example.com/hello.git', 'git-daemon' will interpret the path
as '/srv/git/hello.git'.
--base-path-relaxed::
If --base-path is enabled and repo lookup fails, with this option
- `git-daemon` will attempt to lookup without prefixing the base path.
+ 'git-daemon' will attempt to lookup without prefixing the base path.
This is useful for switching to --base-path usage, while still
allowing the old paths.
@@ -103,7 +103,8 @@ OPTIONS
Log to syslog instead of stderr. Note that this option does not imply
--verbose, thus by default only error conditions will be logged.
---user-path, --user-path=path::
+--user-path::
+--user-path=path::
Allow ~user notation to be used in requests. When
specified with no parameter, requests to
git://host/~alice/foo is taken as a request to access
@@ -127,7 +128,8 @@ OPTIONS
Save the process id in 'file'. Ignored when the daemon
is run under `--inetd`.
---user=user, --group=group::
+--user=user::
+--group=group::
Change daemon's uid and gid before entering the service loop.
When only `--user` is given without `--group`, the
primary group ID for the user is used. The values of
@@ -136,16 +138,18 @@ OPTIONS
+
Giving these options is an error when used with `--inetd`; use
the facility of inet daemon to achieve the same before spawning
-`git-daemon` if needed.
+'git-daemon' if needed.
---enable=service, --disable=service::
+--enable=service::
+--disable=service::
Enable/disable the service site-wide per default. Note
that a service disabled site-wide can still be enabled
per repository if it is marked overridable and the
repository enables the service with an configuration
item.
---allow-override=service, --forbid-override=service::
+--allow-override=service::
+--forbid-override=service::
Allow/forbid overriding the site-wide default with per
repository configuration. By default, all the services
are overridable.
@@ -160,24 +164,24 @@ SERVICES
These services can be globally enabled/disabled using the
command line options of this command. If a finer-grained
-control is desired (e.g. to allow `git-archive` to be run
+control is desired (e.g. to allow 'git-archive' to be run
against only in a few selected repositories the daemon serves),
the per-repository configuration file can be used to enable or
disable them.
upload-pack::
- This serves `git-fetch-pack` and `git-ls-remote`
+ This serves 'git-fetch-pack' and 'git-ls-remote'
clients. It is enabled by default, but a repository can
disable it by setting `daemon.uploadpack` configuration
item to `false`.
upload-archive::
- This serves `git-archive --remote`. It is disabled by
+ This serves 'git-archive --remote'. It is disabled by
default, but a repository can enable it by setting
- `daemon.uploadarchive` configuration item to `true`.
+ `daemon.uploadarch` configuration item to `true`.
receive-pack::
- This serves `git-send-pack` clients, allowing anonymous
+ This serves 'git-send-pack' clients, allowing anonymous
push. It is disabled by default, as there is _no_
authentication in the protocol (in other words, anybody
can push anything into the repository, including removal
@@ -195,28 +199,28 @@ $ grep 9418 /etc/services
git 9418/tcp # Git Version Control System
------------
-git-daemon as inetd server::
- To set up `git-daemon` as an inetd service that handles any
+'git-daemon' as inetd server::
+ To set up 'git-daemon' as an inetd service that handles any
repository under the whitelisted set of directories, /pub/foo
and /pub/bar, place an entry like the following into
/etc/inetd all on one line:
+
------------------------------------------------
- git stream tcp nowait nobody /usr/bin/git-daemon
- git-daemon --inetd --verbose --export-all
+ git stream tcp nowait nobody /usr/bin/git
+ git daemon --inetd --verbose --export-all
/pub/foo /pub/bar
------------------------------------------------
-git-daemon as inetd server for virtual hosts::
- To set up `git-daemon` as an inetd service that handles
+'git-daemon' as inetd server for virtual hosts::
+ To set up 'git-daemon' as an inetd service that handles
repositories for different virtual hosts, `www.example.com`
and `www.example.org`, place an entry like the following into
`/etc/inetd` all on one line:
+
------------------------------------------------
- git stream tcp nowait nobody /usr/bin/git-daemon
- git-daemon --inetd --verbose --export-all
+ git stream tcp nowait nobody /usr/bin/git
+ git daemon --inetd --verbose --export-all
--interpolated-path=/pub/%H%D
/pub/www.example.org/software
/pub/www.example.com/software
@@ -231,13 +235,13 @@ clients, a symlink from `/software` into the appropriate
default repository could be made as well.
-git-daemon as regular daemon for virtual hosts::
- To set up `git-daemon` as a regular, non-inetd service that
+'git-daemon' as regular daemon for virtual hosts::
+ To set up 'git-daemon' as a regular, non-inetd service that
handles repositories for multiple virtual hosts based on
their IP addresses, start the daemon like this:
+
------------------------------------------------
- git-daemon --verbose --export-all
+ git daemon --verbose --export-all
--interpolated-path=/pub/%IP/%D
/pub/192.168.1.200/software
/pub/10.10.220.23/software
@@ -249,7 +253,7 @@ Repositories can still be accessed by hostname though, assuming
they correspond to these IP addresses.
selectively enable/disable services per repository::
- To enable `git-archive --remote` and disable `git-fetch` against
+ To enable 'git-archive --remote' and disable 'git-fetch' against
a repository, have the following in the configuration file in the
repository (that is the file 'config' next to 'HEAD', 'refs' and
'objects').
@@ -257,7 +261,7 @@ selectively enable/disable services per repository::
----------------------------------------------------------------
[daemon]
uploadpack = false
- uploadarchive = true
+ uploadarch = true
----------------------------------------------------------------
@@ -272,4 +276,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index 0742152b8..c4dbc2ae3 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -8,20 +8,21 @@ git-describe - Show the most recent tag that is reachable from a commit
SYNOPSIS
--------
-'git-describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
+'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] <committish>...
DESCRIPTION
-----------
The command finds the most recent tag that is reachable from a
-commit, and if the commit itself is pointed at by the tag, shows
-the tag. Otherwise, it suffixes the tag name with the number of
-additional commits and the abbreviated object name of the commit.
+commit. If the tag points to the commit, then only the tag is
+shown. Otherwise, it suffixes the tag name with the number of
+additional commits on top of the tagged object and the
+abbreviated object name of the most recent commit.
OPTIONS
-------
-<committish>::
- The object name of the committish.
+<committish>...::
+ Committish object names to describe.
--all::
Instead of using only the annotated tags, use any ref
@@ -45,18 +46,39 @@ OPTIONS
candidates to describe the input committish consider
up to <n> candidates. Increasing <n> above 10 will take
slightly longer but may produce a more accurate result.
+ An <n> of 0 will cause only exact matches to be output.
+
+--exact-match::
+ Only output exact matches (a tag directly references the
+ supplied commit). This is a synonym for --candidates=0.
--debug::
Verbosely display information about the searching strategy
being employed to standard error. The tag name will still
be printed to standard out.
+--long::
+ Always output the long format (the tag, the number of commits
+ and the abbreviated commit name) even when it matches a tag.
+ This is useful when you want to see parts of the commit object name
+ in "describe" output, even when the commit in question happens to be
+ a tagged version. Instead of just emitting the tag name, it will
+ describe such a commit as v1.2-0-deadbeef (0th commit since tag v1.2
+ that points at object deadbeef....).
+
+--match <pattern>::
+ Only consider tags matching the given pattern (can be used to avoid
+ leaking private tags made from the repository).
+
+--always::
+ Show uniquely abbreviated commit object as fallback.
+
EXAMPLES
--------
With something like git.git current tree, I get:
- [torvalds@g5 git]$ git-describe parent
+ [torvalds@g5 git]$ git describe parent
v1.0.4-14-g2414721
i.e. the current head of my "parent" branch is based on v1.0.4,
@@ -70,9 +92,9 @@ of commits which would be displayed by "git log v1.0.4..parent".
The hash suffix is "-g" + 7-char abbreviation for the tip commit
of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
-Doing a "git-describe" on a tag-name will just show the tag name:
+Doing a 'git-describe' on a tag-name will just show the tag name:
- [torvalds@g5 git]$ git-describe v1.0.4
+ [torvalds@g5 git]$ git describe v1.0.4
v1.0.4
With --all, the command can use branch heads as references, so
@@ -93,13 +115,13 @@ closest tagname without any suffix:
SEARCH STRATEGY
---------------
-For each committish supplied "git describe" will first look for
+For each committish supplied, 'git-describe' will first look for
a tag which tags exactly that commit. Annotated tags will always
be preferred over lightweight tags, and tags with newer dates will
always be preferred over tags with older dates. If an exact match
is found, its name will be output and searching will stop.
-If an exact match was not found "git describe" will walk back
+If an exact match was not found, 'git-describe' will walk back
through the commit history to locate an ancestor commit which
has been tagged. The ancestor's tag will be output along with an
abbreviation of the input committish's SHA1.
@@ -107,14 +129,14 @@ abbreviation of the input committish's SHA1.
If multiple tags were found during the walk then the tag which
has the fewest commits different from the input committish will be
selected and output. Here fewest commits different is defined as
-the number of commits which would be shown by "git log tag..input"
+the number of commits which would be shown by `git log tag..input`
will be the smallest number of commits possible.
Author
------
Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
-butchered by Junio C Hamano <junkio@cox.net>. Later significantly
+butchered by Junio C Hamano <gitster@pobox.com>. Later significantly
updated by Shawn Pearce <spearce@spearce.org>.
Documentation
@@ -123,4 +145,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-diff-files.txt b/Documentation/git-diff-files.txt
index 6d2ea16a2..5c8c1d95a 100644
--- a/Documentation/git-diff-files.txt
+++ b/Documentation/git-diff-files.txt
@@ -8,14 +8,14 @@ git-diff-files - Compares files in the working tree and the index
SYNOPSIS
--------
-'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc|--no-index] [<common diff options>] [<path>...]
+'git diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...]
DESCRIPTION
-----------
Compares the files in the working tree and the index. When paths
are specified, compares only those named paths. Otherwise all
entries in the index are compared. The output format is the
-same as "git-diff-index" and "git-diff-tree".
+same as for 'git-diff-index' and 'git-diff-tree'.
OPTIONS
-------
@@ -30,15 +30,13 @@ The default is to diff against our branch (-2) and the
cleanly resolved paths. The option -0 can be given to
omit diff output for unmerged entries and just show "Unmerged".
--c,--cc::
+-c::
+--cc::
This compares stage 2 (our branch), stage 3 (their
branch) and the working tree file and outputs a combined
diff, similar to the way 'diff-tree' shows a merge
commit with these flags.
---no-index::
- Compare the two given files / directories.
-
-q::
Remain silent even on nonexistent files
@@ -57,4 +55,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-diff-index.txt b/Documentation/git-diff-index.txt
index e86777859..26920d4f6 100644
--- a/Documentation/git-diff-index.txt
+++ b/Documentation/git-diff-index.txt
@@ -8,7 +8,7 @@ git-diff-index - Compares content and mode of blobs between the index and reposi
SYNOPSIS
--------
-'git-diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
+'git diff-index' [-m] [--cached] [<common diff options>] <tree-ish> [<path>...]
DESCRIPTION
-----------
@@ -31,7 +31,7 @@ include::diff-options.txt[]
-m::
By default, files recorded in the index but not checked
out are reported as deleted. This flag makes
- "git-diff-index" say that all non-checked-out files are up
+ 'git-diff-index' say that all non-checked-out files are up
to date.
Output format
@@ -50,31 +50,31 @@ Cached Mode
If '--cached' is specified, it allows you to ask:
show me the differences between HEAD and the current index
- contents (the ones I'd write with a "git-write-tree")
+ contents (the ones I'd write using 'git-write-tree')
For example, let's say that you have worked on your working directory, updated
some files in the index and are ready to commit. You want to see exactly
*what* you are going to commit, without having to write a new tree
object and compare it that way, and to do that, you just do
- git-diff-index --cached HEAD
+ git diff-index --cached HEAD
Example: let's say I had renamed `commit.c` to `git-commit.c`, and I had
-done an "git-update-index" to make that effective in the index file.
-"git-diff-files" wouldn't show anything at all, since the index file
-matches my working directory. But doing a "git-diff-index" does:
+done an `update-index` to make that effective in the index file.
+`git diff-files` wouldn't show anything at all, since the index file
+matches my working directory. But doing a 'git-diff-index' does:
- torvalds@ppc970:~/git> git-diff-index --cached HEAD
+ torvalds@ppc970:~/git> git diff-index --cached HEAD
-100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
+100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c
You can see easily that the above is a rename.
-In fact, "git-diff-index --cached" *should* always be entirely equivalent to
-actually doing a "git-write-tree" and comparing that. Except this one is much
+In fact, `git diff-index --cached` *should* always be entirely equivalent to
+actually doing a 'git-write-tree' and comparing that. Except this one is much
nicer for the case where you just want to check where you are.
-So doing a "git-diff-index --cached" is basically very useful when you are
+So doing a 'git-diff-index --cached' is basically very useful when you are
asking yourself "what have I already marked for being committed, and
what's the difference to a previous tree".
@@ -82,23 +82,23 @@ Non-cached Mode
---------------
The "non-cached" mode takes a different approach, and is potentially
the more useful of the two in that what it does can't be emulated with
-a "git-write-tree" + "git-diff-tree". Thus that's the default mode.
+a 'git-write-tree' + 'git-diff-tree'. Thus that's the default mode.
The non-cached version asks the question:
show me the differences between HEAD and the currently checked out
tree - index contents _and_ files that aren't up-to-date
which is obviously a very useful question too, since that tells you what
-you *could* commit. Again, the output matches the "git-diff-tree -r"
+you *could* commit. Again, the output matches the 'git-diff-tree -r'
output to a tee, but with a twist.
The twist is that if some file doesn't match the index, we don't have
a backing store thing for it, and we use the magic "all-zero" sha1 to
show that. So let's say that you have edited `kernel/sched.c`, but
-have not actually done a "git-update-index" on it yet - there is no
+have not actually done a 'git-update-index' on it yet - there is no
"object" associated with the new state, and you get:
- torvalds@ppc970:~/v2.6/linux> git-diff-index HEAD
+ torvalds@ppc970:~/v2.6/linux> git diff-index HEAD
*100644->100664 blob 7476bb......->000000...... kernel/sched.c
i.e., it shows that the tree has changed, and that `kernel/sched.c` has is
@@ -106,11 +106,11 @@ not up-to-date and may contain new stuff. The all-zero sha1 means that to
get the real diff, you need to look at the object in the working directory
directly rather than do an object-to-object diff.
-NOTE: As with other commands of this type, "git-diff-index" does not
+NOTE: As with other commands of this type, 'git-diff-index' does not
actually look at the contents of the file at all. So maybe
`kernel/sched.c` hasn't actually changed, and it's just that you
touched it. In either case, it's a note that you need to
-"git-update-index" it to make the index be in sync.
+'git-update-index' it to make the index be in sync.
NOTE: You can have a mixture of files show up as "has been updated"
and "is still dirty in the working directory" together. You can always
@@ -129,4 +129,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
index 58d02c6a2..1fdf20dcc 100644
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -9,7 +9,7 @@ git-diff-tree - Compares the content and mode of blobs found via two tree object
SYNOPSIS
--------
[verse]
-'git-diff-tree' [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
+'git diff-tree' [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
[-t] [-r] [-c | --cc] [--root] [<common diff options>]
<tree-ish> [<tree-ish>] [<path>...]
@@ -20,7 +20,7 @@ Compares the content and mode of the blobs found via two tree objects.
If there is only one <tree-ish> given, the commit is compared with its parents
(see --stdin below).
-Note that "git-diff-tree" can use the tree encapsulated in a commit object.
+Note that 'git-diff-tree' can use the tree encapsulated in a commit object.
OPTIONS
-------
@@ -49,34 +49,34 @@ include::diff-options.txt[]
--stdin::
When '--stdin' is specified, the command does not take
<tree-ish> arguments from the command line. Instead, it
- reads either one <commit> or a pair of <tree-ish>
+ reads either one <commit> or a list of <commit>
separated with a single space from its standard input.
+
When a single commit is given on one line of such input, it compares
the commit with its parents. The following flags further affects its
-behavior. This does not apply to the case where two <tree-ish>
-separated with a single space are given.
+behavior. The remaining commits, when given, are used as if they are
+parents of the first commit.
-m::
- By default, "git-diff-tree --stdin" does not show
+ By default, 'git-diff-tree --stdin' does not show
differences for merge commits. With this flag, it shows
differences to that commit from all of its parents. See
also '-c'.
-s::
- By default, "git-diff-tree --stdin" shows differences,
+ By default, 'git-diff-tree --stdin' shows differences,
either in machine-readable form (without '-p') or in patch
form (with '-p'). This output can be suppressed. It is
only useful with '-v' flag.
-v::
- This flag causes "git-diff-tree --stdin" to also show
+ This flag causes 'git-diff-tree --stdin' to also show
the commit message before the differences.
include::pretty-options.txt[]
--no-commit-id::
- git-diff-tree outputs a line with the commit ID when
+ 'git-diff-tree' outputs a line with the commit ID when
applicable. This flag suppressed the commit ID output.
-c::
@@ -93,11 +93,11 @@ include::pretty-options.txt[]
This flag changes the way a merge commit patch is displayed,
in a similar way to the '-c' option. It implies the '-c'
and '-p' options and further compresses the patch output
- by omitting hunks that show differences from only one
- parent, or show the same change from all but one parent
- for an Octopus merge. When this optimization makes all
- hunks disappear, the commit itself and the commit log
- message is not shown, just like in any other "empty diff" case.
+ by omitting uninteresting hunks whose the contents in the parents
+ have only two variants and the merge result picks one of them
+ without modification. When all hunks are uninteresting, the commit
+ itself and the commit log message is not shown, just like in any other
+ "empty diff" case.
--always::
Show the commit itself and the commit log message even
@@ -112,13 +112,13 @@ Limiting Output
If you're only interested in differences in a subset of files, for
example some architecture-specific files, you might do:
- git-diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64
+ git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64
and it will only show you what changed in those two directories.
Or if you are searching for what changed in just `kernel/sched.c`, just do
- git-diff-tree -r <tree-ish> <tree-ish> kernel/sched.c
+ git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c
and it will ignore all differences to other files.
@@ -129,7 +129,7 @@ so it can be used to name subdirectories.
An example of normal usage is:
- torvalds@ppc970:~/git> git-diff-tree 5319e4......
+ torvalds@ppc970:~/git> git diff-tree 5319e4......
*100664->100664 blob ac348b.......->a01513....... git-fsck-objects.c
which tells you that the last commit changed just one file (it's from
@@ -165,4 +165,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 57c28628b..c53eba557 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -8,14 +8,14 @@ git-diff - Show changes between commits, commit and working tree, etc
SYNOPSIS
--------
-'git-diff' [<common diff options>] <commit>{0,2} [--] [<path>...]
+'git diff' [<common diff options>] <commit>{0,2} [--] [<path>...]
DESCRIPTION
-----------
Show changes between two trees, a tree and the working tree, a
tree and the index file, or the index file and the working tree.
-'git-diff' [--options] [--] [<path>...]::
+'git diff' [--options] [--] [<path>...]::
This form is to view the changes you made relative to
the index (staging area for the next commit). In other
@@ -27,14 +27,14 @@ If exactly two paths are given, and at least one is untracked,
compare the two files / directories. This behavior can be
forced by --no-index.
-'git-diff' [--options] --cached [<commit>] [--] [<path>...]::
+'git diff' [--options] --cached [<commit>] [--] [<path>...]::
This form is to view the changes you staged for the next
commit relative to the named <commit>. Typically you
would want comparison with the latest commit, so if you
do not give <commit>, it defaults to HEAD.
-'git-diff' [--options] <commit> [--] [<path>...]::
+'git diff' [--options] <commit> [--] [<path>...]::
This form is to view the changes you have in your
working tree relative to the named <commit>. You can
@@ -42,23 +42,23 @@ forced by --no-index.
branch name to compare with the tip of a different
branch.
-'git-diff' [--options] <commit> <commit> [--] [<path>...]::
+'git diff' [--options] <commit> <commit> [--] [<path>...]::
This is to view the changes between two arbitrary
<commit>.
-'git-diff' [--options] <commit>..<commit> [--] [<path>...]::
+'git diff' [--options] <commit>..<commit> [--] [<path>...]::
This is synonymous to the previous form. If <commit> on
one side is omitted, it will have the same effect as
using HEAD instead.
-'git-diff' [--options] <commit>\...<commit> [--] [<path>...]::
+'git diff' [--options] <commit>\...<commit> [--] [<path>...]::
This form is to view the changes on the branch containing
and up to the second <commit>, starting at a common ancestor
- of both <commit>. "git-diff A\...B" is equivalent to
- "git-diff $(git-merge-base A B) B". You can omit any one
+ of both <commit>. "git diff A\...B" is equivalent to
+ "git diff $(git-merge-base A B) B". You can omit any one
of <commit>, which has the same effect as using HEAD instead.
Just in case if you are doing something exotic, it should be
@@ -168,4 +168,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt
index 6dac475a0..b974e2115 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -8,23 +8,23 @@ git-fast-export - Git data exporter
SYNOPSIS
--------
-'git-fast-export [options]' | 'git-fast-import'
+'git fast-export [options]' | 'git fast-import'
DESCRIPTION
-----------
This program dumps the given revisions in a form suitable to be piped
-into linkgit:git-fast-import[1].
+into 'git-fast-import'.
You can use it as a human readable bundle replacement (see
linkgit:git-bundle[1]), or as a kind of an interactive
-linkgit:git-filter-branch[1].
+'git-filter-branch'.
OPTIONS
-------
--progress=<n>::
Insert 'progress' statements every <n> objects, to be shown by
- linkgit:git-fast-import[1] during import.
+ 'git-fast-import' during import.
--signed-tags=(verbatim|warn|strip|abort)::
Specify how to handle signed tags. Since any transformation
@@ -36,6 +36,35 @@ when encountering a signed tag. With 'strip', the tags will be made
unsigned, with 'verbatim', they will be silently exported
and with 'warn', they will be exported, but you will see a warning.
+-M::
+-C::
+ Perform move and/or copy detection, as described in the
+ linkgit:git-diff[1] manual page, and use it to generate
+ rename and copy commands in the output dump.
++
+Note that earlier versions of this command did not complain and
+produced incorrect results if you gave these options.
+
+--export-marks=<file>::
+ Dumps the internal marks table to <file> when complete.
+ Marks are written one per line as `:markid SHA-1`. Only marks
+ for revisions are dumped; marks for blobs are ignored.
+ Backends can use this file to validate imports after they
+ have been completed, or to save the marks table across
+ incremental runs. As <file> is only opened and truncated
+ at completion, the same path can also be safely given to
+ \--import-marks.
+
+--import-marks=<file>::
+ Before processing any input, load the marks specified in
+ <file>. The input file must exist, must be readable, and
+ must use the same format as produced by \--export-marks.
++
+Any commits that have already been marked will not be exported again.
+If the backend uses a similar \--import-marks file, this allows for
+incremental bidirectional exporting of the repository by keeping the
+marks the same across runs.
+
EXAMPLES
--------
@@ -65,7 +94,7 @@ referenced by that revision range contains the string
Limitations
-----------
-Since linkgit:git-fast-import[1] cannot tag trees, you will not be
+Since 'git-fast-import' cannot tag trees, you will not be
able to export the linux-2.6.git repository completely, as it contains
a tag referencing a tree instead of a commit.
@@ -80,4 +109,4 @@ Documentation by Johannes E. Schindelin <johannes.schindelin@gmx.de>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index bd625abab..c2f483a8d 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -8,14 +8,14 @@ git-fast-import - Backend for fast Git data importers
SYNOPSIS
--------
-frontend | 'git-fast-import' [options]
+frontend | 'git fast-import' [options]
DESCRIPTION
-----------
This program is usually not what the end user wants to run directly.
Most end users want to use one of the existing frontend programs,
which parses a specific type of foreign source and feeds the contents
-stored there to git-fast-import.
+stored there to 'git-fast-import'.
fast-import reads a mixed command/data stream from standard input and
writes one or more packfiles directly into the current repository.
@@ -24,7 +24,7 @@ updated branch and tag refs, fully updating the current repository
with the newly imported data.
The fast-import backend itself can import into an empty repository (one that
-has already been initialized by linkgit:git-init[1]) or incrementally
+has already been initialized by 'git-init') or incrementally
update an existing populated repository. Whether or not incremental
imports are supported from a particular foreign source depends on
the frontend program in use.
@@ -82,11 +82,11 @@ OPTIONS
This information may be useful after importing projects
whose total object set exceeds the 4 GiB packfile limit,
as these commits can be used as edge points during calls
- to linkgit:git-pack-objects[1].
+ to 'git-pack-objects'.
--quiet::
Disable all non-fatal output, making fast-import silent when it
- is successful. This option disables the output shown by
+ is successful. This option disables the output shown by
\--stats.
--stats::
@@ -124,9 +124,9 @@ an ideal situation, given that most conversion tools are throw-away
Parallel Operation
------------------
-Like `git-push` or `git-fetch`, imports handled by fast-import are safe to
+Like 'git-push' or 'git-fetch', imports handled by fast-import are safe to
run alongside parallel `git repack -a -d` or `git gc` invocations,
-or any other Git operation (including `git prune`, as loose objects
+or any other Git operation (including 'git-prune', as loose objects
are never used by fast-import).
fast-import does not lock the branch or tag refs it is actively importing.
@@ -220,7 +220,7 @@ variation in formatting will cause fast-import to reject the value.
+
An example value is ``Tue Feb 6 11:22:18 2007 -0500''. The Git
parser is accurate, but a little on the lenient side. It is the
-same parser used by linkgit:git-am[1] when applying patches
+same parser used by 'git-am' when applying patches
received from email.
+
Some malformed strings may be accepted as valid dates. In some of
@@ -256,7 +256,7 @@ timezone.
This particular format is supplied as its short to implement and
may be useful to a process that wants to create a new commit
right now, without needing to use a working directory or
-linkgit:git-update-index[1].
+'git-update-index'.
+
If separate `author` and `committer` commands are used in a `commit`
the timestamps may not match, as the system clock will be polled
@@ -385,6 +385,9 @@ new commit.
Omitting the `from` command in the first commit of a new branch
will cause fast-import to create that commit with no ancestor. This
tends to be desired only for the initial commit of a project.
+If the frontend creates all files from scratch when making a new
+branch, a `merge` command may be used instead of `from` to start
+the commit with an empty tree.
Omitting the `from` command on existing branches is usually desired,
as the current commit on that branch is automatically assumed to
be the first ancestor of the new commit.
@@ -427,13 +430,15 @@ existing value of the branch.
`merge`
^^^^^^^
-Includes one additional ancestor commit, and makes the current
-commit a merge commit. An unlimited number of `merge` commands per
+Includes one additional ancestor commit. If the `from` command is
+omitted when creating a new branch, the first `merge` commit will be
+the first ancestor of the current commit, and the branch will start
+out with no files. An unlimited number of `merge` commands per
commit are permitted by fast-import, thereby establishing an n-way merge.
However Git's other tools never create commits with more than 15
additional ancestors (forming a 16-way merge). For this reason
it is suggested that frontends do not use more than 15 `merge`
-commands per commit.
+commands per commit; 16, if starting a new, empty branch.
Here `<committish>` is any of the commit specification expressions
also accepted by `from` (see above).
@@ -476,6 +481,9 @@ in octal. Git only supports the following modes:
what you want.
* `100755` or `755`: A normal, but executable, file.
* `120000`: A symlink, the content of the file will be the link target.
+* `160000`: A gitlink, SHA-1 of the object refers to a commit in
+ another repository. Git links can only be specified by SHA or through
+ a commit mark. They are used to implement submodules.
In both formats `<path>` is the complete path of the file to be added
(if not already existing) or modified (if already existing).
@@ -649,7 +657,7 @@ recommended, as the frontend does not (easily) have access to the
complete set of bytes which normally goes into such a signature.
If signing is required, create lightweight tags from within fast-import with
`reset`, then create the annotated versions of those tags offline
-with the standard linkgit:git-tag[1] process.
+with the standard 'git-tag' process.
`reset`
~~~~~~~
@@ -798,13 +806,100 @@ Callers may wish to process the output through a tool such as sed to
remove the leading part of the line, for example:
====
- frontend | git-fast-import | sed 's/^progress //'
+ frontend | git fast-import | sed 's/^progress //'
====
Placing a `progress` command immediately after a `checkpoint` will
inform the reader when the `checkpoint` has been completed and it
can safely access the refs that fast-import updated.
+Crash Reports
+-------------
+If fast-import is supplied invalid input it will terminate with a
+non-zero exit status and create a crash report in the top level of
+the Git repository it was importing into. Crash reports contain
+a snapshot of the internal fast-import state as well as the most
+recent commands that lead up to the crash.
+
+All recent commands (including stream comments, file changes and
+progress commands) are shown in the command history within the crash
+report, but raw file data and commit messages are excluded from the
+crash report. This exclusion saves space within the report file
+and reduces the amount of buffering that fast-import must perform
+during execution.
+
+After writing a crash report fast-import will close the current
+packfile and export the marks table. This allows the frontend
+developer to inspect the repository state and resume the import from
+the point where it crashed. The modified branches and tags are not
+updated during a crash, as the import did not complete successfully.
+Branch and tag information can be found in the crash report and
+must be applied manually if the update is needed.
+
+An example crash:
+
+====
+ $ cat >in <<END_OF_INPUT
+ # my very first test commit
+ commit refs/heads/master
+ committer Shawn O. Pearce <spearce> 19283 -0400
+ # who is that guy anyway?
+ data <<EOF
+ this is my commit
+ EOF
+ M 644 inline .gitignore
+ data <<EOF
+ .gitignore
+ EOF
+ M 777 inline bob
+ END_OF_INPUT
+
+ $ git fast-import <in
+ fatal: Corrupt mode: M 777 inline bob
+ fast-import: dumping crash report to .git/fast_import_crash_8434
+
+ $ cat .git/fast_import_crash_8434
+ fast-import crash report:
+ fast-import process: 8434
+ parent process : 1391
+ at Sat Sep 1 00:58:12 2007
+
+ fatal: Corrupt mode: M 777 inline bob
+
+ Most Recent Commands Before Crash
+ ---------------------------------
+ # my very first test commit
+ commit refs/heads/master
+ committer Shawn O. Pearce <spearce> 19283 -0400
+ # who is that guy anyway?
+ data <<EOF
+ M 644 inline .gitignore
+ data <<EOF
+ * M 777 inline bob
+
+ Active Branch LRU
+ -----------------
+ active_branches = 1 cur, 5 max
+
+ pos clock name
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 1) 0 refs/heads/master
+
+ Inactive Branches
+ -----------------
+ refs/heads/master:
+ status : active loaded dirty
+ tip commit : 0000000000000000000000000000000000000000
+ old tree : 0000000000000000000000000000000000000000
+ cur tree : 0000000000000000000000000000000000000000
+ commit clock: 0
+ last pack :
+
+
+ -------------------
+ END OF CRASH REPORT
+====
+
Tips and Tricks
---------------
The following tips and tricks have been collected from various
@@ -863,7 +958,7 @@ is not `refs/heads/TAG_FIXUP`).
When committing fixups, consider using `merge` to connect the
commit(s) which are supplying file revisions to the fixup branch.
-Doing so will allow tools such as linkgit:git-blame[1] to track
+Doing so will allow tools such as 'git-blame' to track
through the real commit history and properly annotate the source
files.
@@ -892,7 +987,7 @@ Repacking Historical Data
~~~~~~~~~~~~~~~~~~~~~~~~~
If you are repacking very old imported data (e.g. older than the
last year), consider expending some extra CPU time and supplying
-\--window=50 (or higher) when you run linkgit:git-repack[1].
+\--window=50 (or higher) when you run 'git-repack'.
This will take longer, but will also produce a smaller packfile.
You only need to expend the effort once, and everyone using your
project will benefit from the smaller repository.
@@ -1027,4 +1122,4 @@ Documentation by Shawn O. Pearce <spearce@spearce.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt
index 2b8ffe532..47448da22 100644
--- a/Documentation/git-fetch-pack.txt
+++ b/Documentation/git-fetch-pack.txt
@@ -8,14 +8,14 @@ git-fetch-pack - Receive missing objects from another repository
SYNOPSIS
--------
-'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]
+'git fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]
DESCRIPTION
-----------
-Usually you would want to use linkgit:git-fetch[1] which is a
-higher level wrapper of this command instead.
+Usually you would want to use 'git-fetch', which is a
+higher level wrapper of this command, instead.
-Invokes 'git-upload-pack' on a potentially remote repository,
+Invokes 'git-upload-pack' on a possibly remote repository
and asks it to send objects missing from this repository, to
update the named heads. The list of commits available locally
is found out by scanning local $GIT_DIR/refs/ and sent to
@@ -28,24 +28,32 @@ have a common ancestor commit.
OPTIONS
-------
-\--all::
+--all::
Fetch all remote refs.
-\--quiet, \-q::
+-q::
+--quiet::
Pass '-q' flag to 'git-unpack-objects'; this makes the
cloning process less verbose.
-\--keep, \-k::
+-k::
+--keep::
Do not invoke 'git-unpack-objects' on received data, but
create a single packfile out of it instead, and store it
in the object database. If provided twice then the pack is
locked against repacking.
-\--thin::
+--thin::
Spend extra cycles to minimize the number of objects to be sent.
Use it on slower connection.
-\--upload-pack=<git-upload-pack>::
+--include-tag::
+ If the remote side supports it, annotated tags objects will
+ be downloaded on the same connection as the other objects if
+ the object the tag references is downloaded. The caller must
+ otherwise determine the tags this option made available.
+
+--upload-pack=<git-upload-pack>::
Use this to specify the path to 'git-upload-pack' on the
remote side, if is not found on your $PATH.
Installations of sshd ignores the user's environment
@@ -57,16 +65,16 @@ OPTIONS
shells by having a lean .bashrc file (they set most of
the things up in .bash_profile).
-\--exec=<git-upload-pack>::
+--exec=<git-upload-pack>::
Same as \--upload-pack=<git-upload-pack>.
-\--depth=<n>::
+--depth=<n>::
Limit fetching to ancestor-chains not longer than n.
-\--no-progress::
+--no-progress::
Do not show the progress.
-\-v::
+-v::
Run verbosely.
<host>::
@@ -93,4 +101,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
index d982f961f..d3164c5c8 100644
--- a/Documentation/git-fetch.txt
+++ b/Documentation/git-fetch.txt
@@ -8,7 +8,7 @@ git-fetch - Download objects and refs from another repository
SYNOPSIS
--------
-'git-fetch' <options> <repository> <refspec>...
+'git fetch' <options> <repository> <refspec>...
DESCRIPTION
@@ -18,7 +18,7 @@ the objects necessary to complete them.
The ref names and their object names of fetched refs are stored
in `.git/FETCH_HEAD`. This information is left for a later merge
-operation done by "git merge".
+operation done by 'git-merge'.
When <refspec> stores the fetched result in tracking branches,
the tags that point at these branches are automatically
@@ -45,7 +45,7 @@ linkgit:git-pull[1]
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
+Junio C Hamano <gitster@pobox.com>
Documentation
-------------
@@ -53,4 +53,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index e22dfa580..b0e710d5f 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -8,12 +8,12 @@ git-filter-branch - Rewrite branches
SYNOPSIS
--------
[verse]
-'git-filter-branch' [--env-filter <command>] [--tree-filter <command>]
+'git filter-branch' [--env-filter <command>] [--tree-filter <command>]
[--index-filter <command>] [--parent-filter <command>]
[--msg-filter <command>] [--commit-filter <command>]
[--tag-name-filter <command>] [--subdirectory-filter <directory>]
[--original <namespace>] [-d <directory>] [-f | --force]
- [<rev-list options>...]
+ [--] [<rev-list options>...]
DESCRIPTION
-----------
@@ -25,7 +25,7 @@ Otherwise, all information (including original commit times or merge
information) will be preserved.
The command will only rewrite the _positive_ refs mentioned in the
-command line (i.e. if you pass 'a..b', only 'b' will be rewritten).
+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,
@@ -42,7 +42,7 @@ Always verify that the rewritten version is correct: The original refs,
if different from the rewritten ones, will be stored in the namespace
'refs/original/'.
-Note that since this operation is extensively I/O expensive, it might
+Note that since this operation is very I/O expensive, it might
be a good idea to redirect the temporary directory off-disk with the
'-d' option, e.g. on tmpfs. Reportedly the speedup is very noticeable.
@@ -51,12 +51,15 @@ Filters
~~~~~~~
The filters are applied in the order as listed below. The <command>
-argument is always evaluated in shell using the 'eval' command (with the
-notable exception of the commit filter, for technical reasons).
+argument is always evaluated in the shell context using the 'eval' command
+(with the notable exception of the commit filter, for technical reasons).
Prior to that, the $GIT_COMMIT environment variable will be set to contain
the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
-and GIT_COMMITTER_DATE are set according to the current commit.
+and GIT_COMMITTER_DATE are set according to the current commit. The values
+of these variables after the filters have run, are used for the new commit.
+If any evaluation of <command> returns a non-zero exit status, the whole
+operation will be aborted.
A 'map' function is available that takes an "original sha1 id" argument
and outputs a "rewritten sha1 id" if the commit has been already
@@ -69,9 +72,9 @@ OPTIONS
-------
--env-filter <command>::
- This is the filter for modifying the environment in which
- the commit will be performed. Specifically, you might want
- to rewrite the author/committer name/email/time environment
+ This filter may be used if you only need to modify the environment
+ in which the commit will be performed. Specifically, you might
+ want to rewrite the author/committer name/email/time environment
variables (see linkgit:git-commit[1] for details). Do not forget
to re-export the variables.
@@ -92,7 +95,7 @@ OPTIONS
This is the filter for rewriting the commit's parent list.
It will receive the parent string on stdin and shall output
the new parent string on stdout. The parent string is in
- a format accepted by linkgit:git-commit-tree[1]: empty for
+ the format described in linkgit:git-commit-tree[1]: empty for
the initial commit, "-p parent" for a normal commit and
"-p parent1 -p parent2 -p parent3 ..." for a merge commit.
@@ -105,18 +108,18 @@ OPTIONS
--commit-filter <command>::
This is the filter for performing the commit.
If this filter is specified, it will be called instead of the
- linkgit:git-commit-tree[1] command, with arguments of the form
+ 'git-commit-tree' command, with arguments of the form
"<TREE_ID> [-p <PARENT_COMMIT_ID>]..." and the log message on
stdin. The commit id is expected on stdout.
+
As a special extension, the commit filter may emit multiple
-commit ids; in that case, ancestors of the original commit will
+commit ids; in that case, the rewritten children of the original commit will
have all of them as parents.
+
You can use the 'map' convenience function in this filter, and other
convenience functions, too. For example, calling 'skip_commit "$@"'
will leave out the current commit (but not its changes! If you want
-that, use linkgit:git-rebase[1] instead).
+that, use 'git-rebase' instead).
--tag-name-filter <command>::
This is the filter for rewriting tag names. When passed,
@@ -130,10 +133,16 @@ use "--tag-name-filter cat" to simply update the tags. In this
case, be very careful and make sure you have the old tags
backed up in case the conversion has run afoul.
+
-Note that there is currently no support for proper rewriting of
-tag objects; in layman terms, if the tag has a message or signature
-attached, the rewritten tag won't have it. Sorry. (It is by
-definition impossible to preserve signatures at any rate.)
+Nearly proper rewriting of tag objects is supported. If the tag has
+a message attached, a new tag object will be created with the same message,
+author, and timestamp. If the tag has a signature attached, the
+signature will be stripped. It is by definition impossible to preserve
+signatures. The reason this is "nearly" proper, is because ideally if
+the tag did not change (points to the same object, has the same name, etc.)
+it should retain any signature. That is not the case, signatures will always
+be removed, buyer beware. There is also no support for changing the
+author or timestamp (or the tag message for that matter). Tags which point
+to other tags will be rewritten to point to the underlying commit.
--subdirectory-filter <directory>::
Only look at the history which touches the given subdirectory.
@@ -147,21 +156,22 @@ definition impossible to preserve signatures at any rate.)
-d <directory>::
Use this option to set the path to the temporary directory used for
rewriting. When applying a tree filter, the command needs to
- temporary checkout the tree to some directory, which may consume
+ temporarily check out the tree to some directory, which may consume
considerable space in case of large projects. By default it
does this in the '.git-rewrite/' directory but you can override
that choice by this parameter.
--f|--force::
- `git filter-branch` refuses to start with an existing temporary
+-f::
+--force::
+ 'git-filter-branch' refuses to start with an existing temporary
directory or when there are already refs starting with
'refs/original/', unless forced.
-<rev-list-options>::
- When options are given after the new branch name, they will
- be passed to linkgit:git-rev-list[1]. Only commits in the resulting
- output will be filtered, although the filtered commits can still
- reference parents which are outside of that set.
+<rev-list options>...::
+ Arguments for 'git-rev-list'. All positive refs included by
+ these options are rewritten. You may also specify options
+ such as '--all', but you must use '--' to separate them from
+ the 'git-filter-branch' options.
Examples
@@ -174,14 +184,29 @@ or copyright violation) from all commits:
git filter-branch --tree-filter 'rm filename' HEAD
-------------------------------------------------------
+However, if the file is absent from the tree of some commit,
+a simple `rm filename` will fail for that tree and commit.
+Thus you may instead want to use `rm -f filename` as the script.
+
A significantly faster version:
--------------------------------------------------------------------------
-git filter-branch --index-filter 'git update-index --remove filename' HEAD
+git filter-branch --index-filter 'git rm --cached filename' HEAD
--------------------------------------------------------------------------
Now, you will get the rewritten history saved in HEAD.
+To rewrite the repository to look as if `foodir/` had been its project
+root, and discard all other history:
+
+-------------------------------------------------------
+git filter-branch --subdirectory-filter foodir -- --all
+-------------------------------------------------------
+
+Thus you can, e.g., turn a library subdirectory into a repository of
+its own. Note the `\--` that separates 'filter-branch' options from
+revision options, and the `\--all` to rewrite all branches and tags.
+
To set a commit (which typically is at the tip of another
history) to be the parent of the current initial commit, in
order to paste the other history behind the current history:
@@ -197,7 +222,7 @@ happened). If this is not the case, use:
--------------------------------------------------------------------------
git filter-branch --parent-filter \
- 'cat; test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>"' HEAD
+ 'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD
--------------------------------------------------------------------------
or even simpler:
@@ -240,16 +265,25 @@ committed a merge between P1 and P2, it will be propagated properly
and all children of the merge will become merge commits with P1,P2
as their parents instead of the merge commit.
+You can rewrite the commit log messages using `--msg-filter`. For
+example, 'git-svn-id' strings in a repository created by 'git-svn' can
+be removed this way:
+
+-------------------------------------------------------
+git filter-branch --msg-filter '
+ sed -e "/^git-svn-id:/d"
+'
+-------------------------------------------------------
To restrict rewriting to only part of the history, specify a revision
range in addition to the new branch name. The new branch name will
-point to the top-most revision that a 'git rev-list' of this range
+point to the top-most revision that a 'git-rev-list' of this range
will print.
*NOTE* the changes introduced by the commits, and which are not reverted
by subsequent commits, will still be in the rewritten branch. If you want
to throw out _changes_ together with the commits, you should use the
-interactive mode of linkgit:git-rebase[1].
+interactive mode of 'git-rebase'.
Consider this history:
@@ -295,4 +329,4 @@ Documentation by Petr Baudis and the git list.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
index 8615ae353..1c24796d6 100644
--- a/Documentation/git-fmt-merge-msg.txt
+++ b/Documentation/git-fmt-merge-msg.txt
@@ -9,41 +9,51 @@ git-fmt-merge-msg - Produce a merge commit message
SYNOPSIS
--------
[verse]
-git-fmt-merge-msg [--summary | --no-summary] <$GIT_DIR/FETCH_HEAD
-git-fmt-merge-msg [--summary | --no-summary] -F <file>
+'git fmt-merge-msg' [--log | --no-log] <$GIT_DIR/FETCH_HEAD
+'git fmt-merge-msg' [--log | --no-log] -F <file>
DESCRIPTION
-----------
Takes the list of merged objects on stdin and produces a suitable
commit message to be used for the merge commit, usually to be
-passed as the '<merge-message>' argument of `git-merge`.
+passed as the '<merge-message>' argument of 'git-merge'.
This script is intended mostly for internal use by scripts
-automatically invoking `git-merge`.
+automatically invoking 'git-merge'.
OPTIONS
-------
---summary::
+--log::
In addition to branch names, populate the log message with
one-line descriptions from the actual commits that are being
merged.
---no-summary::
+--no-log::
Do not list one-line descriptions from the actual commits being
merged.
---file <file>, -F <file>::
+--summary::
+--no-summary::
+ Synonyms to --log and --no-log; these are deprecated and will be
+ removed in the future.
+
+-F <file>::
+--file <file>::
Take the list of merged objects from <file> instead of
stdin.
CONFIGURATION
-------------
-merge.summary::
+merge.log::
Whether to include summaries of merged commits in newly
merge commit messages. False by default.
+merge.summary::
+ Synonym to `merge.log`; this is deprecated and will be removed in
+ the future.
+
SEE ALSO
--------
linkgit:git-merge[1]
@@ -51,7 +61,7 @@ linkgit:git-merge[1]
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -59,4 +69,4 @@ Documentation by Petr Baudis, Junio C Hamano and the git-list <git@vger.kernel.o
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index f1f90cca6..eae6c0e7b 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -8,9 +8,8 @@ git-for-each-ref - Output information on each ref
SYNOPSIS
--------
[verse]
-'git-for-each-ref' [--count=<count>]\*
- [--shell|--perl|--python|--tcl]
- [--sort=<key>]\* [--format=<format>] [<pattern>]
+'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl]
+ [--sort=<key>]\* [--format=<format>] [<pattern>...]
DESCRIPTION
-----------
@@ -32,8 +31,9 @@ OPTIONS
<key>::
A field name to sort on. Prefix `-` to sort in
descending order of the value. When unspecified,
- `refname` is used. More than one sort keys can be
- given.
+ `refname` is used. You may use the --sort=<key> option
+ multiple times, in which case the last key becomes the primary
+ key.
<format>::
A string that interpolates `%(fieldname)` from the
@@ -47,12 +47,16 @@ OPTIONS
`xx`; for example `%00` interpolates to `\0` (NUL),
`%09` to `\t` (TAB) and `%0a` to `\n` (LF).
-<pattern>::
- If given, the name of the ref is matched against this
- using fnmatch(3). Refs that do not match the pattern
- are not shown.
+<pattern>...::
+ If one or more patterns are given, only refs are shown that
+ match against at least one pattern, either using fnmatch(3) or
+ literally, in the latter case matching completely or from the
+ beginning up to a slash.
---shell, --perl, --python, --tcl::
+--shell::
+--perl::
+--python::
+--tcl::
If given, strings that substitute `%(fieldname)`
placeholders are quoted as string literals suitable for
the specified host language. This is meant to produce
@@ -75,7 +79,7 @@ objecttype::
The type of the object (`blob`, `tree`, `commit`, `tag`).
objectsize::
- The size of the object (the same as `git-cat-file -s` reports).
+ The size of the object (the same as 'git-cat-file -s' reports).
objectname::
The object name (aka SHA-1).
@@ -115,7 +119,7 @@ An example directly producing formatted text. Show the most recent
------------
#!/bin/sh
-git-for-each-ref --count=3 --sort='-*authordate' \
+git for-each-ref --count=3 --sort='-*authordate' \
--format='From: %(*authorname) %(*authoremail)
Subject: %(*subject)
Date: %(*authordate)
@@ -131,7 +135,7 @@ demonstrating the use of --shell. List the prefixes of all heads::
------------
#!/bin/sh
-git-for-each-ref --shell --format="ref=%(refname)" refs/heads | \
+git for-each-ref --shell --format="ref=%(refname)" refs/heads | \
while read entry
do
eval "$entry"
@@ -185,7 +189,7 @@ Its message reads as:
fi
'
-eval=`git-for-each-ref --shell --format="$fmt" \
+eval=`git for-each-ref --shell --format="$fmt" \
--sort='*objecttype' \
--sort=-taggerdate \
refs/tags`
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 651efe6ca..adb4ea7b1 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -9,14 +9,16 @@ git-format-patch - Prepare patches for e-mail submission
SYNOPSIS
--------
[verse]
-'git-format-patch' [-k] [-o <dir> | --stdout] [--thread]
- [--attach[=<boundary>] | --inline[=<boundary>]]
- [-s | --signoff] [<common diff options>]
- [-n | --numbered | -N | --no-numbered]
- [--start-number <n>] [--numbered-files]
- [--in-reply-to=Message-Id] [--suffix=.<sfx>]
- [--ignore-if-in-upstream]
- [--subject-prefix=Subject-Prefix]
+'git format-patch' [-k] [-o <dir> | --stdout] [--thread]
+ [--attach[=<boundary>] | --inline[=<boundary>]]
+ [-s | --signoff] [<common diff options>]
+ [-n | --numbered | -N | --no-numbered]
+ [--start-number <n>] [--numbered-files]
+ [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+ [--ignore-if-in-upstream]
+ [--subject-prefix=Subject-Prefix]
+ [--cc=<email>]
+ [--cover-letter]
[ <since> | <revision range> ]
DESCRIPTION
@@ -25,7 +27,7 @@ DESCRIPTION
Prepare each commit with its patch in
one file per commit, formatted to resemble UNIX mailbox format.
The output of this command is convenient for e-mail submission or
-for use with linkgit:git-am[1].
+for use with 'git-am'.
There are two ways to specify which commits to operate on.
@@ -59,7 +61,7 @@ they are created in the current working directory.
If -n is specified, instead of "[PATCH] Subject", the first line
is formatted as "[PATCH n/m] Subject".
-If given --thread, git-format-patch will generate In-Reply-To and
+If given --thread, 'git-format-patch' will generate In-Reply-To and
References headers to make the second and subsequent patch mails appear
as replies to the first mail; this also generates a Message-Id header to
reference.
@@ -72,14 +74,17 @@ include::diff-options.txt[]
-<n>::
Limits the number of patches to prepare.
--o|--output-directory <dir>::
+-o <dir>::
+--output-directory <dir>::
Use <dir> to store the resulting files, instead of the
current working directory.
--n|--numbered::
+-n::
+--numbered::
Name output in '[PATCH n/m]' format.
--N|--no-numbered::
+-N::
+--no-numbered::
Name output in '[PATCH]' format.
--start-number <n>::
@@ -90,11 +95,13 @@ include::diff-options.txt[]
without the default first line of the commit appended.
Mutually exclusive with the --stdout option.
--k|--keep-subject::
+-k::
+--keep-subject::
Do not strip/add '[PATCH]' from the first line of the
commit log message.
--s|--signoff::
+-s::
+--signoff::
Add `Signed-off-by:` line to the commit message, using
the committer identity of yourself.
@@ -135,6 +142,15 @@ include::diff-options.txt[]
allows for useful naming of a patch series, and can be
combined with the --numbered option.
+--cc=<email>::
+ Add a "Cc:" header to the email headers. This is in addition
+ to any configured headers, and may be used multiple times.
+
+--cover-letter::
+ In addition to the patches, generate a cover letter file
+ containing the shortlog and the overall diffstat. You can
+ fill in a description in the file before sending it out.
+
--suffix=.<sfx>::
Instead of using `.patch` as the suffix for generated
filenames, use specified suffix. A common alternative is
@@ -145,6 +161,12 @@ want a filename like `0001-description-of-my-change.patch`, and
the first letter does not have to be a dot. Leaving it empty would
not add any suffix.
+--no-binary::
+ Don't output contents of changes in binary files, just take note
+ that they differ. Note that this disable the patch to be properly
+ applied. By default the contents of changes in those files are
+ encoded in the patch.
+
CONFIGURATION
-------------
You can specify extra mail header lines to be added to each message
@@ -153,51 +175,67 @@ and file suffix, and number patches when outputting more than one.
------------
[format]
- headers = "Organization: git-foo\n"
- subjectprefix = CHANGE
- suffix = .txt
- numbered = auto
+ headers = "Organization: git-foo\n"
+ subjectprefix = CHANGE
+ suffix = .txt
+ numbered = auto
+ cc = <email>
------------
EXAMPLES
--------
-git-format-patch -k --stdout R1..R2 | git-am -3 -k::
- Extract commits between revisions R1 and R2, and apply
- them on top of the current branch using `git-am` to
- cherry-pick them.
-
-git-format-patch origin::
- Extract all commits which are in the current branch but
- not in the origin branch. For each commit a separate file
- is created in the current directory.
-
-git-format-patch \--root origin::
- Extract all commits that lead to 'origin' since the
- inception of the project.
-
-git-format-patch -M -B origin::
- The same as the previous one. 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 it. Note that the "patch" program does not
- understand renaming patches, so use it only when you know
- the recipient uses git to apply your patch.
-
-git-format-patch -3::
- Extract three topmost commits from the current branch
- and format them as e-mailable patches.
-
-See Also
+* Extract commits between revisions R1 and R2, and apply them on top of
+the current branch using 'git-am' to cherry-pick them:
++
+------------
+$ git format-patch -k --stdout R1..R2 | git am -3 -k
+------------
+
+* Extract all commits which are in the current branch but not in the
+origin branch:
++
+------------
+$ git format-patch origin
+------------
++
+For each commit a separate file is created in the current directory.
+
+* Extract all commits that lead to 'origin' since the inception of the
+project:
++
+------------
+$ git format-patch --root origin
+------------
+
+* The same as the previous one:
++
+------------
+$ 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 it.
+Note that the "patch" program does not 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:
++
+------------
+$ git format-patch -3
+------------
+
+SEE ALSO
--------
linkgit:git-am[1], linkgit:git-send-email[1]
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -205,4 +243,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-fsck-objects.txt b/Documentation/git-fsck-objects.txt
index 6e9f71764..965a8279c 100644
--- a/Documentation/git-fsck-objects.txt
+++ b/Documentation/git-fsck-objects.txt
@@ -8,7 +8,7 @@ git-fsck-objects - Verifies the connectivity and validity of the objects in the
SYNOPSIS
--------
-'git-fsck-objects' ...
+'git fsck-objects' ...
DESCRIPTION
-----------
diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt
index f16cb9861..d5a764721 100644
--- a/Documentation/git-fsck.txt
+++ b/Documentation/git-fsck.txt
@@ -9,7 +9,7 @@ git-fsck - Verifies the connectivity and validity of the objects in the database
SYNOPSIS
--------
[verse]
-'git-fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
+'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]
[--full] [--strict] [--verbose] [--lost-found] [<object>*]
DESCRIPTION
@@ -21,8 +21,9 @@ OPTIONS
<object>::
An object to treat as the head of an unreachability trace.
+
-If no objects are given, git-fsck defaults to using the
-index file and all SHA1 references in .git/refs/* as heads.
+If no objects are given, 'git-fsck' defaults to using the
+index file, all SHA1 references in .git/refs/*, and all reflogs (unless
+--no-reflogs is given) as heads.
--unreachable::
Print out objects that exist but that aren't readable from any
@@ -78,15 +79,15 @@ that aren't readable from any of the specified head nodes.
So for example
- git-fsck --unreachable HEAD $(cat .git/refs/heads/*)
+ git fsck --unreachable HEAD $(cat .git/refs/heads/*)
will do quite a _lot_ of verification on the tree. There are a few
extra validity tests to be added (make sure that tree objects are
-sorted properly etc), but on the whole if "git-fsck" is happy, you
+sorted properly etc), but on the whole if 'git-fsck' is happy, you
do have a valid tree.
Any corrupt objects you will have to find in backups or other archives
-(i.e., you can just remove them and do an "rsync" with some other site in
+(i.e., you can just remove them and do an 'rsync' with some other site in
the hopes that somebody else has the object you have corrupted).
Of course, "valid tree" doesn't mean that it wasn't generated by some
@@ -150,4 +151,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 4b2dfefa6..7086eea74 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -8,44 +8,40 @@ git-gc - Cleanup unnecessary files and optimize the local repository
SYNOPSIS
--------
-'git-gc' [--prune] [--aggressive] [--auto]
+'git gc' [--aggressive] [--auto] [--quiet]
DESCRIPTION
-----------
Runs a number of housekeeping tasks within the current repository,
such as compressing file revisions (to reduce disk space and increase
performance) and removing unreachable objects which may have been
-created from prior invocations of linkgit:git-add[1].
+created from prior invocations of 'git-add'.
Users are encouraged to run this task on a regular basis within
each repository to maintain good disk space utilization and good
-operating performance. Some git commands may automatically run
-`git-gc`; see the `--auto` flag below for details.
+operating performance.
+
+Some git commands may automatically run 'git-gc'; see the `--auto` flag
+below for details. If you know what you're doing and all you want is to
+disable this behavior permanently without further considerations, just do:
+
+----------------------
+$ git config --global gc.auto 0
+----------------------
OPTIONS
-------
---prune::
- Usually `git-gc` packs refs, expires old reflog entries,
- packs loose objects,
- and removes old 'rerere' records. Removal
- of unreferenced loose objects is an unsafe operation
- while other git operations are in progress, so it is not
- done by default. Pass this option if you want it, and only
- when you know nobody else is creating new objects in the
- repository at the same time (e.g. never use this option
- in a cron script).
-
--aggressive::
Usually 'git-gc' runs very quickly while providing good disk
space utilization and performance. This option will cause
- git-gc to more aggressively optimize the repository at the expense
+ 'git-gc' to more aggressively optimize the repository at the expense
of taking much more time. The effects of this optimization are
persistent, so this option only needs to be used occasionally; every
few hundred changesets or so.
--auto::
- With this option, `git gc` checks whether any housekeeping is
+ With this option, 'git-gc' checks whether any housekeeping is
required; if not, it exits without performing any work.
Some git commands run `git gc --auto` after performing
operations that could create many loose objects.
@@ -54,15 +50,18 @@ Housekeeping is required if there are too many loose objects or
too many packs in the repository. If the number of loose objects
exceeds the value of the `gc.auto` configuration variable, then
all loose objects are combined into a single pack using
-`git-repack -d -l`. Setting the value of `gc.auto` to 0
+'git-repack -d -l'. Setting the value of `gc.auto` to 0
disables automatic packing of loose objects.
+
If the number of packs exceeds the value of `gc.autopacklimit`,
then existing packs (except those marked with a `.keep` file)
are consolidated into a single pack by using the `-A` option of
-`git-repack`. Setting `gc.autopacklimit` to 0 disables
+'git-repack'. Setting `gc.autopacklimit` to 0 disables
automatic consolidation of packs.
+--quiet::
+ Suppress all progress reports.
+
Configuration
-------------
@@ -90,7 +89,7 @@ how long records of conflicted merge you have not resolved are
kept. This defaults to 15 days.
The optional configuration variable 'gc.packrefs' determines if
-`git gc` runs `git-pack-refs`. This can be set to "nobare" to enable
+'git-gc' runs 'git-pack-refs'. This can be set to "nobare" to enable
it within all non-bare repos or it can be set to a boolean value.
This defaults to true.
@@ -101,7 +100,26 @@ the value, the more time is spent optimizing the delta compression. See
the documentation for the --window' option in linkgit:git-repack[1] for
more details. This defaults to 10.
-See Also
+The optional configuration variable 'gc.pruneExpire' controls how old
+the unreferenced loose objects have to be before they are pruned. The
+default is "2 weeks ago".
+
+
+Notes
+-----
+
+'git-gc' tries very hard to be safe about the garbage it collects. In
+particular, it will keep not only objects referenced by your current set
+of branches and tags, but also objects referenced by the index, remote
+tracking branches, refs saved by 'git-filter-branch' in
+refs/original/, or reflogs (which may references commits in branches
+that were later amended or rewound).
+
+If you are expecting some objects to be collected and they aren't, check
+all of those locations and decide whether it makes sense in your case to
+remove those references.
+
+SEE ALSO
--------
linkgit:git-prune[1]
linkgit:git-reflog[1]
@@ -114,4 +132,4 @@ Written by Shawn O. Pearce <spearce@spearce.org>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-get-tar-commit-id.txt b/Documentation/git-get-tar-commit-id.txt
index dea41490c..84f23ee52 100644
--- a/Documentation/git-get-tar-commit-id.txt
+++ b/Documentation/git-get-tar-commit-id.txt
@@ -8,18 +8,18 @@ git-get-tar-commit-id - Extract commit ID from an archive created using git-arch
SYNOPSIS
--------
-'git-get-tar-commit-id' < <tarfile>
+'git get-tar-commit-id' < <tarfile>
DESCRIPTION
-----------
Acts as a filter, extracting the commit ID stored in archives created by
-linkgit:git-archive[1]. It reads only the first 1024 bytes of input, thus its
+'git-archive'. It reads only the first 1024 bytes of input, thus its
runtime is not influenced by the size of <tarfile> very much.
-If no commit ID is found, git-get-tar-commit-id quietly exists with a
+If no commit ID is found, 'git-get-tar-commit-id' quietly exists with a
return code of 1. This can happen if <tarfile> had not been created
-using git-archive or if the first parameter of git-archive had been
+using 'git-archive' or if the first parameter of 'git-archive' had been
a tree ID instead of a commit ID or tag.
@@ -33,4 +33,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index f3cb24f25..fa4d133c1 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -9,7 +9,7 @@ git-grep - Print lines matching a pattern
SYNOPSIS
--------
[verse]
-'git-grep' [--cached]
+'git grep' [--cached]
[-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
[-v | --invert-match] [-h|-H] [--full-name]
[-E | --extended-regexp] [-G | --basic-regexp]
@@ -33,25 +33,30 @@ OPTIONS
Instead of searching in the working tree files, check
the blobs registered in the index file.
--a | --text::
+-a::
+--text::
Process binary files as if they were text.
--i | --ignore-case::
+-i::
+--ignore-case::
Ignore case differences between the patterns and the
files.
-I::
Don't match the pattern in binary files.
--w | --word-regexp::
+-w::
+--word-regexp::
Match the pattern only at word boundary (either begin at the
beginning of a line, or preceded by a non-word character; end at
the end of a line or followed by a non-word character).
--v | --invert-match::
+-v::
+--invert-match::
Select non-matching lines.
--h | -H::
+-h::
+-H::
By default, the command shows the filename for each
match. `-h` option is used to suppress this output.
`-H` is there for completeness and does not do anything
@@ -64,22 +69,33 @@ OPTIONS
option forces paths to be output relative to the project
top directory.
--E | --extended-regexp | -G | --basic-regexp::
+-E::
+--extended-regexp::
+-G::
+--basic-regexp::
Use POSIX extended/basic regexp for patterns. Default
is to use basic regexp.
--F | --fixed-strings::
+-F::
+--fixed-strings::
Use fixed strings for patterns (don't interpret pattern
as a regex).
-n::
Prefix the line number to matching lines.
--l | --files-with-matches | -L | --files-without-match::
+-l::
+--files-with-matches::
+--name-only::
+-L::
+--files-without-match::
Instead of showing every matched line, show only the
names of files that contain (or do not contain) matches.
+ For better compatibility with 'git-diff', --name-only is a
+ synonym for --files-with-matches.
--c | --count::
+-c::
+--count::
Instead of showing every matched line, show the number of
lines that match.
@@ -101,7 +117,10 @@ OPTIONS
scripts passing user input to grep. Multiple patterns are
combined by 'or'.
---and | --or | --not | ( | )::
+--and::
+--or::
+--not::
+( ... )::
Specify how multiple patterns are combined using Boolean
expressions. `--or` is the default operator. `--and` has
higher precedence than `--or`. `-e` has to be used for all
@@ -143,4 +162,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-gui.txt b/Documentation/git-gui.txt
index 6d6cd5d87..0e650f497 100644
--- a/Documentation/git-gui.txt
+++ b/Documentation/git-gui.txt
@@ -11,19 +11,19 @@ SYNOPSIS
DESCRIPTION
-----------
-A Tcl/Tk based graphical user interface to Git. git-gui focuses
+A Tcl/Tk based graphical user interface to Git. 'git-gui' focuses
on allowing users to make changes to their repository by making
new commits, amending existing ones, creating branches, performing
local merges, and fetching/pushing to remote repositories.
-Unlike linkgit:gitk[1], git-gui focuses on commit generation
-and single file annotation, and does not show project history.
-It does however supply menu actions to start a gitk session from
-within git-gui.
+Unlike 'gitk', 'git-gui' focuses on commit generation
+and single file annotation and does not show project history.
+It does however supply menu actions to start a 'gitk' session from
+within 'git-gui'.
-git-gui is known to work on all popular UNIX systems, Mac OS X,
+'git-gui' is known to work on all popular UNIX systems, Mac OS X,
and Windows (under both Cygwin and MSYS). To the extent possible
-OS specific user interface guidelines are followed, making git-gui
+OS specific user interface guidelines are followed, making 'git-gui'
a fairly native interface for users.
COMMANDS
@@ -34,17 +34,17 @@ blame::
browser::
Start a tree browser showing all files in the specified
- commit (or 'HEAD' by default). Files selected through the
+ commit (or 'HEAD' by default). Files selected through the
browser are opened in the blame viewer.
citool::
- Start git-gui and arrange to make exactly one commit before
+ Start 'git-gui' and arrange to make exactly one commit before
exiting and returning to the shell. The interface is limited
to only commit actions, slightly reducing the application's
startup time and simplifying the menubar.
version::
- Display the currently running version of git-gui.
+ Display the currently running version of 'git-gui'.
Examples
@@ -61,7 +61,7 @@ git gui blame Makefile::
git gui blame v0.99.8 Makefile::
Show the contents of 'Makefile' in revision 'v0.99.8'
- and provide annotations for each line. Unlike the above
+ and provide annotations for each line. Unlike the above
example the file is read from the object database and not
the working directory.
@@ -71,7 +71,7 @@ git gui citool::
git citool::
- Same as 'git gui citool' (above).
+ Same as `git gui citool` (above).
git gui browser maint::
@@ -79,20 +79,20 @@ git gui browser maint::
selected in the browser can be viewed with the internal
blame viewer.
-See Also
+SEE ALSO
--------
-'gitk(1)'::
+linkgit:gitk[1]::
The git repository browser. Shows branches, commit history
and file differences. gitk is the utility started by
- git-gui's Repository Visualize actions.
+ 'git-gui''s Repository Visualize actions.
Other
-----
-git-gui is actually maintained as an independent project, but stable
+'git-gui' is actually maintained as an independent project, but stable
versions are distributed as part of the Git suite for the convenience
of end users.
-A git-gui development repository can be obtained from:
+A 'git-gui' development repository can be obtained from:
git clone git://repo.or.cz/git-gui.git
@@ -112,4 +112,4 @@ Documentation by Shawn O. Pearce <spearce@spearce.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt
index 33030c022..ac928e198 100644
--- a/Documentation/git-hash-object.txt
+++ b/Documentation/git-hash-object.txt
@@ -8,7 +8,7 @@ git-hash-object - Compute object ID and optionally creates a blob from a file
SYNOPSIS
--------
-'git-hash-object' [-t <type>] [-w] [--stdin] [--] <file>...
+'git hash-object' [-t <type>] [-w] [--stdin | --stdin-paths] [--] <file>...
DESCRIPTION
-----------
@@ -16,7 +16,7 @@ Computes the object ID value for an object with specified type
with the contents of the named file (which can be outside of the
work tree), and optionally writes the resulting object into the
object database. Reports its object ID to its standard output.
-This is used by "git-cvsimport" to update the index
+This is used by 'git-cvsimport' to update the index
without modifying files in the work tree. When <type> is not
specified, it defaults to "blob".
@@ -32,9 +32,12 @@ OPTIONS
--stdin::
Read the object from standard input instead of from a file.
+--stdin-paths::
+ Read file names from stdin instead of from the command-line.
+
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -42,4 +45,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index 09904c75c..f414583fc 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -23,45 +23,48 @@ If a git command is named, a manual page for that command is brought
up. The 'man' program is used by default for this purpose, but this
can be overridden by other options or configuration variables.
-Note that 'git --help ...' is identical as 'git help ...' because the
+Note that `git --help ...` is identical to `git help ...` because the
former is internally converted into the latter.
OPTIONS
-------
--a|--all::
+-a::
+--all::
Prints all the available commands on the standard output. This
option supersedes any other option.
--i|--info::
- Use the 'info' program to display the manual page, instead of
- the 'man' program that is used by default.
+-i::
+--info::
+ Display manual page for the command in the 'info' format. The
+ 'info' program will be used for that purpose.
--m|--man::
- Use the 'man' program to display the manual page. This may be
- used to override a value set in the 'help.format'
- configuration variable.
-
--w|--web::
- Use a web browser to display the HTML manual page, instead of
- the 'man' program that is used by default.
+-m::
+--man::
+ Display manual page for the command in the 'man' format. This
+ option may be used to override a value set in the
+ 'help.format' configuration variable.
++
+By default the 'man' program will be used to display the manual page,
+but the 'man.viewer' configuration variable may be used to choose
+other display programs (see below).
+
+-w::
+--web::
+ Display manual page for the command in the 'web' (HTML)
+ format. A web browser will be used for that purpose.
+
The web browser can be specified using the configuration variable
'help.browser', or 'web.browser' if the former is not set. If none of
-these config variables is set, the 'git-help--browse' helper script
-(called by 'git-help') will pick a suitable default.
-+
-You can explicitly provide a full path to your preferred browser by
-setting the configuration variable 'browser.<tool>.path'. For example,
-you can configure the absolute path to firefox by setting
-'browser.firefox.path'. Otherwise, 'git-help--browse' assumes the tool
-is available in PATH.
-+
-Note that the script tries, as much as possible, to display the HTML
-page in a new tab on an already opened browser.
+these config variables is set, the 'git-web--browse' helper script
+(called by 'git-help') will pick a suitable default. See
+linkgit:git-web--browse[1] for more information about this.
CONFIGURATION VARIABLES
-----------------------
+help.format
+~~~~~~~~~~~
+
If no command line option is passed, the 'help.format' configuration
variable will be checked. The following values are supported for this
variable; they make 'git-help' behave as their corresponding command
@@ -69,15 +72,94 @@ line option:
* "man" corresponds to '-m|--man',
* "info" corresponds to '-i|--info',
-* "web" or "html" correspond to '-w|--web',
+* "web" or "html" correspond to '-w|--web'.
+
+help.browser, web.browser and browser.<tool>.path
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'help.browser', 'web.browser' and 'browser.<tool>.path' will also
be checked if the 'web' format is chosen (either by command line
option or configuration variable). See '-w|--web' in the OPTIONS
-section above.
+section above and linkgit:git-web--browse[1].
+
+man.viewer
+~~~~~~~~~~
+
+The 'man.viewer' config variable will be checked if the 'man' format
+is chosen. The following values are currently supported:
+
+* "man": use the 'man' program as usual,
+* "woman": use 'emacsclient' to launch the "woman" mode in emacs
+(this only works starting with emacsclient versions 22),
+* "konqueror": use 'kfmclient' to open the man page in a new konqueror
+tab (see 'Note about konqueror' below).
+
+Values for other tools can be used if there is a corresponding
+'man.<tool>.cmd' configuration entry (see below).
+
+Multiple values may be given to the 'man.viewer' configuration
+variable. Their corresponding programs will be tried in the order
+listed in the configuration file.
+
+For example, this configuration:
+
+------------------------------------------------
+ [man]
+ viewer = konqueror
+ viewer = woman
+------------------------------------------------
+
+will try to use konqueror first. But this may fail (for example if
+DISPLAY is not set) and in that case emacs' woman mode will be tried.
+
+If everything fails the 'man' program will be tried anyway.
+
+man.<tool>.path
+~~~~~~~~~~~~~~~
+
+You can explicitly provide a full path to your preferred man viewer by
+setting the configuration variable 'man.<tool>.path'. For example, you
+can configure the absolute path to konqueror by setting
+'man.konqueror.path'. Otherwise, 'git-help' assumes the tool is
+available in PATH.
+
+man.<tool>.cmd
+~~~~~~~~~~~~~~
+
+When the man viewer, specified by the 'man.viewer' configuration
+variables, is not among the supported ones, then the corresponding
+'man.<tool>.cmd' configuration variable will be looked up. If this
+variable exists then the specified tool will be treated as a custom
+command and a shell eval will be used to run the command with the man
+page passed as arguments.
+
+Note about konqueror
+~~~~~~~~~~~~~~~~~~~~
+
+When 'konqueror' is specified in the 'man.viewer' configuration
+variable, we launch 'kfmclient' to try to open the man page on an
+already opened konqueror in a new tab if possible.
+
+For consistency, we also try such a trick if 'man.konqueror.path' is
+set to something like 'A_PATH_TO/konqueror'. That means we will try to
+launch 'A_PATH_TO/kfmclient' instead.
+
+If you really want to use 'konqueror', then you can use something like
+the following:
+
+------------------------------------------------
+ [man]
+ viewer = konq
+
+ [man "konq"]
+ cmd = A_PATH_TO/konqueror
+------------------------------------------------
+
+Note about git config --global
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Note that these configuration variables should probably be set using
-the '--global' flag, for example like this:
+Note that all these configuration variables should probably be set
+using the '--global' flag, for example like this:
------------------------------------------------
$ git config --global help.format web
@@ -94,10 +176,10 @@ Written by Junio C Hamano <gitster@pobox.com> and the git-list
Documentation
-------------
-Initial documentation was part of the linkgit:git[7] man page.
+Initial documentation was part of the linkgit:git[1] man page.
Christian Couder <chriscool@tuxfamily.org> extracted and rewrote it a
little. Maintenance is done by the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt
index b784a9d07..e7c796155 100644
--- a/Documentation/git-http-fetch.txt
+++ b/Documentation/git-http-fetch.txt
@@ -8,7 +8,7 @@ git-http-fetch - Download from a remote git repository via HTTP
SYNOPSIS
--------
-'git-http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [--stdin] <commit> <url>
+'git http-fetch' [-c] [-t] [-a] [-d] [-v] [-w filename] [--recover] [--stdin] <commit> <url>
DESCRIPTION
-----------
@@ -53,4 +53,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-http-push.txt b/Documentation/git-http-push.txt
index cca77f10d..aef383e0b 100644
--- a/Documentation/git-http-push.txt
+++ b/Documentation/git-http-push.txt
@@ -8,13 +8,16 @@ git-http-push - Push objects over HTTP/DAV to another repository
SYNOPSIS
--------
-'git-http-push' [--all] [--dry-run] [--force] [--verbose] <url> <ref> [<ref>...]
+'git http-push' [--all] [--dry-run] [--force] [--verbose] <url> <ref> [<ref>...]
DESCRIPTION
-----------
Sends missing objects to remote repository, and updates the
remote branch.
+*NOTE*: This command is temporarily disabled if your libcurl
+is older than 7.16, as the combination has been reported
+not to work and sometimes corrupts repository.
OPTIONS
-------
@@ -37,7 +40,8 @@ OPTIONS
Report the list of objects being walked locally and the
list of objects successfully sent to the remote repository.
--d, -D::
+-d::
+-D::
Remove <ref> from remote repository. The specified branch
cannot be the remote HEAD. If -d is specified the following
other conditions must also be met:
@@ -98,4 +102,4 @@ Documentation by Nick Hengeveld
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-imap-send.txt b/Documentation/git-imap-send.txt
index 522b73c12..b3d8da33e 100644
--- a/Documentation/git-imap-send.txt
+++ b/Documentation/git-imap-send.txt
@@ -8,7 +8,7 @@ git-imap-send - Dump a mailbox from stdin into an imap folder
SYNOPSIS
--------
-'git-imap-send'
+'git imap-send'
DESCRIPTION
@@ -20,13 +20,13 @@ files directly.
Typical usage is something like:
-git-format-patch --signoff --stdout --attach origin | git-imap-send
+git format-patch --signoff --stdout --attach origin | git imap-send
CONFIGURATION
-------------
-git-imap-send requires the following values in the repository
+'git-imap-send' requires the following values in the repository
configuration file (shown with examples):
..........................
@@ -59,4 +59,4 @@ Documentation by Mike McCormack
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-index-pack.txt b/Documentation/git-index-pack.txt
index 72b5d0011..4b5c743c1 100644
--- a/Documentation/git-index-pack.txt
+++ b/Documentation/git-index-pack.txt
@@ -9,8 +9,8 @@ git-index-pack - Build pack index file for an existing packed archive
SYNOPSIS
--------
[verse]
-'git-index-pack' [-v] [-o <index-file>] <pack-file>
-'git-index-pack' --stdin [--fix-thin] [--keep] [-v] [-o <index-file>]
+'git index-pack' [-v] [-o <index-file>] <pack-file>
+'git index-pack' --stdin [--fix-thin] [--keep] [-v] [-o <index-file>]
[<pack-file>]
@@ -43,10 +43,10 @@ OPTIONS
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
- linkgit:git-repack[1].
+ 'git-repack'.
--fix-thin::
- It is possible for linkgit:git-pack-objects[1] to build
+ It is possible for 'git-pack-objects' to build
"thin" pack, which records objects in deltified form based on
objects not included in the pack to reduce network traffic.
Those objects are expected to be present on the receiving end
@@ -59,7 +59,7 @@ OPTIONS
Before moving the index into its final destination
create an empty .keep file for the associated pack file.
This option is usually necessary with --stdin to prevent a
- simultaneous linkgit:git-repack[1] process from deleting
+ simultaneous 'git-repack' process from deleting
the newly constructed pack and index before refs can be
updated to use objects contained in the pack.
@@ -75,6 +75,9 @@ OPTIONS
to force the version for the generated pack index, and to force
64-bit index entries on objects located above the given offset.
+--strict::
+ Die, if the pack contains broken objects or links.
+
Note
----
@@ -83,7 +86,7 @@ Once the index has been created, the list of object names is sorted
and the SHA1 hash of that list is printed to stdout. If --stdin was
also used then this is prefixed by either "pack\t", or "keep\t" if a
new .keep file was successfully created. This is useful to remove a
-.keep file used as a lock to prevent the race with linkgit:git-repack[1]
+.keep file used as a lock to prevent the race with 'git-repack'
mentioned above.
@@ -97,4 +100,4 @@ Documentation by Sergey Vlasov
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt
index 439cabb73..1fd0ff261 100644
--- a/Documentation/git-init-db.txt
+++ b/Documentation/git-init-db.txt
@@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository
SYNOPSIS
--------
-'git-init-db' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
+'git init-db' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
DESCRIPTION
diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
index 62914da97..71749c09d 100644
--- a/Documentation/git-init.txt
+++ b/Documentation/git-init.txt
@@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one
SYNOPSIS
--------
-'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
+'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]]
OPTIONS
@@ -16,10 +16,16 @@ OPTIONS
--
--q, \--quiet::
+-q::
+--quiet::
Only print error and warning messages, all other output will be suppressed.
+--bare::
+
+Create a bare repository. If GIT_DIR environment is not set, it is set to the
+current working directory.
+
--template=<template_directory>::
Provide the directory from which templates will be used. The default template
@@ -31,7 +37,7 @@ structure, some suggested "exclude patterns", and copies of non-executing
"hook" files. The suggested patterns and hook files are all modifiable and
extensible.
---shared[={false|true|umask|group|all|world|everybody}]::
+--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
Specify that the git repository is to be shared amongst several users. This
allows users belonging to the same group to push into that
@@ -52,6 +58,12 @@ is given:
- 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
readable by all users.
+ - '0xxx': '0xxx' is an octal number and each file will have mode '0xxx'
+ Any option except 'umask' can be set using this option. '0xxx' will
+ override users umask(2) value, and thus, users with a safe umask (0077)
+ can use this option. '0640' will create a repository which is group-readable
+ but not writable. '0660' is equivalent to 'group'.
+
By default, the configuration flag receive.denyNonFastForwards is enabled
in shared repositories, so that you cannot force a non fast-forwarding push
into it.
@@ -74,11 +86,11 @@ If the object storage directory is specified via the `$GIT_OBJECT_DIRECTORY`
environment variable then the sha1 directories are created underneath -
otherwise the default `$GIT_DIR/objects` directory is used.
-Running `git-init` in an existing repository is safe. It will not overwrite
-things that are already there. The primary reason for rerunning `git-init`
+Running 'git-init' in an existing repository is safe. It will not overwrite
+things that are already there. The primary reason for rerunning 'git-init'
is to pick up newly added templates.
-Note that `git-init` is the same as `git-init-db`. The command
+Note that 'git-init' is the same as 'git-init-db'. The command
was primarily meant to initialize the object database, but over
time it has become responsible for setting up the other aspects
of the repository, such as installing the default hooks and
@@ -93,8 +105,8 @@ Start a new git repository for an existing code base::
+
----------------
$ cd /path/to/my/codebase
-$ git-init <1>
-$ git-add . <2>
+$ git init <1>
+$ git add . <2>
----------------
+
<1> prepare /path/to/my/codebase/.git directory
@@ -111,4 +123,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index 841e8fac7..22da21a54 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -8,40 +8,46 @@ git-instaweb - Instantly browse your working repository in gitweb
SYNOPSIS
--------
[verse]
-'git-instaweb' [--local] [--httpd=<httpd>] [--port=<port>]
+'git instaweb' [--local] [--httpd=<httpd>] [--port=<port>]
[--browser=<browser>]
-'git-instaweb' [--start] [--stop] [--restart]
+'git instaweb' [--start] [--stop] [--restart]
DESCRIPTION
-----------
-A simple script to setup gitweb and a web server for browsing the local
+A simple script to set up `gitweb` and a web server for browsing the local
repository.
OPTIONS
-------
--l|--local::
+-l::
+--local::
Only bind the web server to the local IP (127.0.0.1).
--d|--httpd::
+-d::
+--httpd::
The HTTP daemon command-line that will be executed.
Command-line options may be specified here, and the
configuration file will be added at the end of the command-line.
Currently lighttpd, apache2 and webrick are supported.
(Default: lighttpd)
--m|--module-path::
+-m::
+--module-path::
The module path (only needed if httpd is Apache).
(Default: /usr/lib/apache2/modules)
--p|--port::
+-p::
+--port::
The port number to bind the httpd to. (Default: 1234)
--b|--browser::
-
- The web browser command-line to execute to view the gitweb page.
- If blank, the URL of the gitweb instance will be printed to
- stdout. (Default: 'firefox')
+-b::
+--browser::
+ The web browser that should be used to view the gitweb
+ page. This will be passed to the 'git-web--browse' helper
+ script along with the URL of the gitweb instance. See
+ linkgit:git-web--browse[1] for more information about this. If
+ the script fails, the URL will be printed to stdout.
--start::
Start the httpd instance and exit. This does not generate
@@ -72,7 +78,8 @@ You may specify configuration in your .git/config
-----------------------------------------------------------------------
If the configuration variable 'instaweb.browser' is not set,
-'web.browser' will be used instead if it is defined.
+'web.browser' will be used instead if it is defined. See
+linkgit:git-web--browse[1] for more information about this.
Author
------
@@ -84,4 +91,4 @@ Documentation by Eric Wong <normalperson@yhbt.net>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index ebaee4b33..0446bad7e 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -8,15 +8,15 @@ git-log - Show commit logs
SYNOPSIS
--------
-'git-log' <option>...
+'git log' <option>...
DESCRIPTION
-----------
Shows the commit logs.
-The command takes options applicable to the linkgit:git-rev-list[1]
+The command takes options applicable to the 'git-rev-list'
command to control what is shown and how, and options applicable to
-the linkgit:git-diff-tree[1] commands to control how the changes
+the 'git-diff-*' commands to control how the changes
each commit introduces are shown.
@@ -41,10 +41,10 @@ include::diff-options.txt[]
Print out the ref names of any commits that are shown.
--full-diff::
- Without this flag, "git log -p <paths>..." shows commits that
+ Without this flag, "git log -p <path>..." shows commits that
touch the specified paths, and diffs about the same specified
paths. With this, the full diff is shown for commits that touch
- the specified paths; this means that "<paths>..." limits only
+ the specified paths; this means that "<path>..." limits only
commits, and doesn't limit diff for those commits.
--follow::
@@ -57,8 +57,8 @@ include::diff-options.txt[]
Note that only message is considered, if also a diff is shown
its size is not included.
-<paths>...::
- Show only commits that affect the specified paths.
+<path>...::
+ Show only commits that affect any of the specified paths.
include::rev-list-options.txt[]
@@ -112,4 +112,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-lost-found.txt b/Documentation/git-lost-found.txt
index b1c797f10..602b8d5d4 100644
--- a/Documentation/git-lost-found.txt
+++ b/Documentation/git-lost-found.txt
@@ -7,7 +7,7 @@ git-lost-found - Recover lost refs that luckily have not yet been pruned
SYNOPSIS
--------
-'git-lost-found'
+'git lost-found'
DESCRIPTION
-----------
@@ -78,4 +78,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index da9ebf405..9f85d60b5 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -9,7 +9,7 @@ git-ls-files - Show information about files in the index and the working tree
SYNOPSIS
--------
[verse]
-'git-ls-files' [-z] [-t] [-v]
+'git ls-files' [-z] [-t] [-v]
(--[cached|deleted|others|ignored|stage|unmerged|killed|modified])\*
(-[c|d|o|i|s|u|k|m])\*
[-x <pattern>|--exclude=<pattern>]
@@ -30,24 +30,30 @@ shown:
OPTIONS
-------
--c|--cached::
+-c::
+--cached::
Show cached files in the output (default)
--d|--deleted::
+-d::
+--deleted::
Show deleted files in the output
--m|--modified::
+-m::
+--modified::
Show modified files in the output
--o|--others::
+-o::
+--others::
Show other files in the output
--i|--ignored::
+-i::
+--ignored::
Show ignored files in the output.
Note that this also reverses any exclude list present.
--s|--stage::
- Show stage files in the output
+-s::
+--stage::
+ Show staged contents' object name, mode bits and stage number in the output.
--directory::
If a whole directory is classified as "other", show just its
@@ -56,10 +62,12 @@ OPTIONS
--no-empty-directory::
Do not list empty directories. Has no effect without --directory.
--u|--unmerged::
+-u::
+--unmerged::
Show unmerged files in the output (forces --stage)
--k|--killed::
+-k::
+--killed::
Show files on the filesystem that need to be removed due
to file/directory conflicts for checkout-index to
succeed.
@@ -67,11 +75,13 @@ OPTIONS
-z::
\0 line termination on output.
--x|--exclude=<pattern>::
+-x <pattern>::
+--exclude=<pattern>::
Skips files matching pattern.
Note that pattern is a shell wildcard pattern.
--X|--exclude-from=<file>::
+-X <file>::
+--exclude-from=<file>::
exclude patterns are read from <file>; 1 per line.
--exclude-per-directory=<file>::
@@ -133,14 +143,14 @@ which case it outputs:
[<tag> ]<mode> <object> <stage> <file>
-"git-ls-files --unmerged" and "git-ls-files --stage" can be used to examine
+'git-ls-files --unmerged' and 'git-ls-files --stage' can be used to examine
detailed information on unmerged paths.
For an unmerged path, instead of recording a single mode/SHA1 pair,
the index records up to three such pairs; one from tree O in stage
1, A in stage 2, and B in stage 3. This information can be used by
the user (or the porcelain) to see what should eventually be recorded at the
-path. (see git-read-tree for more information on state)
+path. (see linkgit:git-read-tree[1] for more information on state)
When `-z` option is not used, TAB, LF, and backslash characters
in pathnames are represented as `\t`, `\n`, and `\\`,
@@ -177,7 +187,7 @@ top of the directory tree. A pattern read from a file specified
by --exclude-per-directory is relative to the directory that the
pattern file appears in.
-See Also
+SEE ALSO
--------
linkgit:git-read-tree[1], linkgit:gitignore[5]
@@ -192,4 +202,4 @@ Documentation by David Greaves, Junio C Hamano, Josh Triplett, and the git-list
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index c5ba0aad1..abe7bf9ff 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -9,7 +9,7 @@ git-ls-remote - List references in a remote repository
SYNOPSIS
--------
[verse]
-'git-ls-remote' [--heads] [--tags] [-u <exec> | --upload-pack <exec>]
+'git ls-remote' [--heads] [--tags] [-u <exec> | --upload-pack <exec>]
<repository> <refs>...
DESCRIPTION
@@ -20,14 +20,18 @@ commit IDs.
OPTIONS
-------
--h|--heads, -t|--tags::
+-h::
+--heads::
+-t::
+--tags::
Limit to only refs/heads and refs/tags, respectively.
These options are _not_ mutually exclusive; when given
both, references stored in refs/heads and refs/tags are
displayed.
--u <exec>, --upload-pack=<exec>::
- Specify the full path of linkgit:git-upload-pack[1] on the remote
+-u <exec>::
+--upload-pack=<exec>::
+ Specify the full path of 'git-upload-pack' on the remote
host. This allows listing references from repositories accessed via
SSH and where the SSH daemon does not use the PATH configured by the
user.
@@ -65,8 +69,8 @@ EXAMPLES
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index 360c0a1b9..4c7262f1c 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -9,17 +9,27 @@ git-ls-tree - List the contents of a tree object
SYNOPSIS
--------
[verse]
-'git-ls-tree' [-d] [-r] [-t] [-l] [-z]
+'git ls-tree' [-d] [-r] [-t] [-l] [-z]
[--name-only] [--name-status] [--full-name] [--abbrev=[<n>]]
<tree-ish> [paths...]
DESCRIPTION
-----------
Lists the contents of a given tree object, like what "/bin/ls -a" does
-in the current working directory. Note that the usage is subtly different,
-though - 'paths' denote just a list of patterns to match, e.g. so specifying
-directory name (without '-r') will behave differently, and order of the
-arguments does not matter.
+in the current working directory. Note that:
+
+ - the behaviour is slightly different from that of "/bin/ls" in that the
+ 'paths' denote just a list of patterns to match, e.g. so specifying
+ directory name (without '-r') will behave differently, and order of the
+ arguments does not matter.
+
+ - the behaviour is similar to that of "/bin/ls" in that the 'paths' is
+ taken as relative to the current working directory. E.g. when you are
+ in a directory 'sub' that has a directory 'dir', you can run 'git
+ ls-tree -r HEAD dir' to list the contents of the tree (that is
+ 'sub/dir' in 'HEAD'). You don't want to give a tree that is not at the
+ root level (e.g. 'git ls-tree -r HEAD:sub dir') in this case, as that
+ would result in asking for 'sub/sub/dir' in the 'HEAD' commit.
OPTIONS
-------
@@ -81,7 +91,7 @@ with minimum width of 7 characters. Object size is given only for blobs
Author
------
Written by Petr Baudis <pasky@suse.cz>
-Completely rewritten from scratch by Junio C Hamano <junkio@cox.net>,
+Completely rewritten from scratch by Junio C Hamano <gitster@pobox.com>,
another major rewrite by Linus Torvalds <torvalds@osdl.org>
Documentation
@@ -91,4 +101,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index 3846f0e6e..31eccea5b 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -8,7 +8,7 @@ git-mailinfo - Extracts patch and authorship from a single e-mail message
SYNOPSIS
--------
-'git-mailinfo' [-k] [-u | --encoding=<encoding>] <msg> <patch>
+'git mailinfo' [-k] [-u | --encoding=<encoding> | -n] <msg> <patch>
DESCRIPTION
@@ -16,7 +16,7 @@ DESCRIPTION
Reading a single e-mail message from the standard input, and
writes the commit log message in <msg> file, and the patches in
<patch> file. The author name, e-mail and e-mail subject are
-written out to the standard output to be used by git-am
+written out to the standard output to be used by 'git-am'
to create a commit. It is usually not necessary to use this
command directly. See linkgit:git-am[1] instead.
@@ -29,8 +29,8 @@ OPTIONS
among which (1) remove 'Re:' or 're:', (2) leading
whitespaces, (3) '[' up to ']', typically '[PATCH]', and
then prepends "[PATCH] ". This flag forbids this
- munging, and is most useful when used to read back 'git
- format-patch -k' output.
+ munging, and is most useful when used to read back
+ 'git-format-patch -k' output.
-u::
The commit log message, author name and author email are
@@ -46,6 +46,9 @@ conversion, even with this flag.
from what is specified by i18n.commitencoding, this flag
can be used to override it.
+-n::
+ Disable all charset re-coding of the metadata.
+
<msg>::
The commit log message extracted from e-mail, usually
except the title line which comes from e-mail Subject.
@@ -57,7 +60,7 @@ conversion, even with this flag.
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
+Junio C Hamano <gitster@pobox.com>
Documentation
@@ -66,4 +69,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt
index 8243f6911..5cc94ec53 100644
--- a/Documentation/git-mailsplit.txt
+++ b/Documentation/git-mailsplit.txt
@@ -7,7 +7,7 @@ git-mailsplit - Simple UNIX mbox splitter program
SYNOPSIS
--------
-'git-mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]
+'git mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>|<Maildir>...]
DESCRIPTION
-----------
@@ -27,7 +27,7 @@ OPTIONS
Root of the Maildir to split. This directory should contain the cur, tmp
and new subdirectories.
-<directory>::
+-o<directory>::
Directory in which to place the individual messages.
-b::
@@ -46,7 +46,7 @@ OPTIONS
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
-and Junio C Hamano <junkio@cox.net>
+and Junio C Hamano <gitster@pobox.com>
Documentation
@@ -55,4 +55,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt
index 07f78b4ae..1a7ecbf8f 100644
--- a/Documentation/git-merge-base.txt
+++ b/Documentation/git-merge-base.txt
@@ -8,20 +8,20 @@ git-merge-base - Find as good common ancestors as possible for a merge
SYNOPSIS
--------
-'git-merge-base' [--all] <commit> <commit>
+'git merge-base' [--all] <commit> <commit>
DESCRIPTION
-----------
-"git-merge-base" finds as good a common ancestor as possible between
-the two commits. That is, given two commits A and B 'git-merge-base A
-B' will output a commit which is reachable from both A and B through
+'git-merge-base' finds as good a common ancestor as possible between
+the two commits. That is, given two commits A and B, `git merge-base A
+B` will output a commit which is reachable from both A and B through
the parent relationship.
Given a selection of equally good common ancestors it should not be
relied on to decide in any particular way.
-The "git-merge-base" algorithm is still in flux - use the source...
+The 'git-merge-base' algorithm is still in flux - use the source...
OPTIONS
-------
@@ -39,4 +39,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
index c513184ba..024ec015a 100644
--- a/Documentation/git-merge-file.txt
+++ b/Documentation/git-merge-file.txt
@@ -9,21 +9,21 @@ git-merge-file - Run a three-way file merge
SYNOPSIS
--------
[verse]
-'git-merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
+'git merge-file' [-L <current-name> [-L <base-name> [-L <other-name>]]]
[-p|--stdout] [-q|--quiet] <current-file> <base-file> <other-file>
DESCRIPTION
-----------
-git-file-merge incorporates all changes that lead from the `<base-file>`
+'git-file-merge' incorporates all changes that lead from the `<base-file>`
to `<other-file>` into `<current-file>`. The result ordinarily goes into
-`<current-file>`. git-merge-file is useful for combining separate changes
+`<current-file>`. 'git-merge-file' is useful for combining separate changes
to an original. Suppose `<base-file>` is the original, and both
`<current-file>` and `<other-file>` are modifications of `<base-file>`.
-Then git-merge-file combines both changes.
+Then 'git-merge-file' combines both changes.
A conflict occurs if both `<current-file>` and `<other-file>` have changes
-in a common segment of lines. If a conflict is found, git-merge-file
+in a common segment of lines. If a conflict is found, 'git-merge-file'
normally outputs a warning and brackets the conflict with <<<<<<< and
>>>>>>> lines. A typical conflict will look like this:
@@ -39,8 +39,8 @@ the alternatives.
The exit value of this program is negative on error, and the number of
conflicts otherwise. If the merge was clean, the exit value is 0.
-git-merge-file is designed to be a minimal clone of RCS merge, that is, it
-implements all of RCS merge's functionality which is needed by
+'git-merge-file' is designed to be a minimal clone of RCS 'merge'; that is, it
+implements all of RCS 'merge''s functionality which is needed by
linkgit:git[1].
@@ -51,7 +51,7 @@ OPTIONS
This option may be given up to three times, and
specifies labels to be used in place of the
corresponding file names in conflict reports. That is,
- `git-merge-file -L x -L y -L z a b c` generates output that
+ `git merge-file -L x -L y -L z a b c` generates output that
looks like it came from files x, y and z instead of
from files a, b and c.
@@ -85,8 +85,8 @@ Written by Johannes Schindelin <johannes.schindelin@gmx.de>
Documentation
--------------
Documentation by Johannes Schindelin and the git-list <git@vger.kernel.org>,
-with parts copied from the original documentation of RCS merge.
+with parts copied from the original documentation of RCS 'merge'.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
index 5d816d0d8..ff088c5c2 100644
--- a/Documentation/git-merge-index.txt
+++ b/Documentation/git-merge-index.txt
@@ -8,7 +8,7 @@ git-merge-index - Run a merge for files needing merging
SYNOPSIS
--------
-'git-merge-index' [-o] [-q] <merge-program> (-a | \-- | <file>\*)
+'git merge-index' [-o] [-q] <merge-program> (-a | [--] <file>\*)
DESCRIPTION
-----------
@@ -36,24 +36,24 @@ OPTIONS
failure usually indicates conflicts during merge). This is for
porcelains which might want to emit custom messages.
-If "git-merge-index" is called with multiple <file>s (or -a) then it
+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
-the merge command from the RCS package.
+the 'merge' command from the RCS package.
-A sample script called "git-merge-one-file" is included in the
+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
-RCS "merge" program merge object order. In the above ordering, 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.
+'merge' is to have the original in the middle. Don't ask me why.
Examples:
- torvalds@ppc970:~/merge-test> git-merge-index cat MM
+ torvalds@ppc970:~/merge-test> git merge-index cat MM
This is MM from the original tree. # original
This is modified MM in the branch A. # merge1
This is modified MM in the branch B. # merge2
@@ -61,17 +61,17 @@ Examples:
or
- torvalds@ppc970:~/merge-test> git-merge-index cat AA MM
+ torvalds@ppc970:~/merge-test> git merge-index cat AA MM
cat: : No such file or directory
This is added AA in the branch A.
This is added AA in the branch B.
This is added AA in the branch B.
fatal: merge program failed
-where the latter example shows how "git-merge-index" will stop trying to
-merge once anything has returned an error (i.e., "cat" returned an error
+where the latter example shows how 'git-merge-index' will stop trying to
+merge once anything has returned an error (i.e., `cat` returned an error
for the AA file, because it didn't exist in the original, and thus
-"git-merge-index" didn't even try to merge the MM thing).
+'git-merge-index' didn't even try to merge the MM thing).
Author
------
@@ -84,4 +84,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge-one-file.txt b/Documentation/git-merge-one-file.txt
index ee95df3bc..dc8a96adb 100644
--- a/Documentation/git-merge-one-file.txt
+++ b/Documentation/git-merge-one-file.txt
@@ -12,13 +12,13 @@ SYNOPSIS
DESCRIPTION
-----------
-This is the standard helper program to use with "git-merge-index"
-to resolve a merge after the trivial merge done with "git-read-tree -m".
+This is the standard helper program to use with 'git-merge-index'
+to resolve a merge after the trivial merge done with 'git-read-tree -m'.
Author
------
Written by Linus Torvalds <torvalds@osdl.org>,
-Junio C Hamano <junkio@cox.net> and Petr Baudis <pasky@suse.cz>.
+Junio C Hamano <gitster@pobox.com> and Petr Baudis <pasky@suse.cz>.
Documentation
--------------
@@ -26,4 +26,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 4cc0964e7..dbb0c1866 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -8,7 +8,7 @@ git-merge-tree - Show three-way merge without touching index
SYNOPSIS
--------
-'git-merge-tree' <base-tree> <branch1> <branch2>
+'git merge-tree' <base-tree> <branch1> <branch2>
DESCRIPTION
-----------
@@ -33,4 +33,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 0c9ad7f2b..17a15acb0 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -9,9 +9,9 @@ git-merge - Join two or more development histories together
SYNOPSIS
--------
[verse]
-'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]...
+'git merge' [-n] [--stat] [--no-commit] [--squash] [-s <strategy>]...
[-m <msg>] <remote> <remote>...
-'git-merge' <msg> HEAD <remote>...
+'git merge' <msg> HEAD <remote>...
DESCRIPTION
-----------
@@ -29,11 +29,11 @@ include::merge-options.txt[]
-m <msg>::
The commit message to be used for the merge commit (in case
- it is created). The `git-fmt-merge-msg` script can be used
- to give a good default for automated `git-merge` invocations.
+ it is created). The 'git-fmt-merge-msg' script can be used
+ to give a good default for automated 'git-merge' invocations.
-<remote>::
- Other branch head merged into our branch. You need at
+<remote>...::
+ Other branch heads to merge into our branch. You need at
least one <remote>. Specifying more than one <remote>
obviously means you are trying an Octopus.
@@ -41,75 +41,47 @@ include::merge-strategies.txt[]
If you tried a merge which resulted in a complex conflicts and
-would want to start over, you can recover with
-linkgit:git-reset[1].
+would want to start over, you can recover with 'git-reset'.
CONFIGURATION
-------------
-
-merge.summary::
- Whether to include summaries of merged commits in newly
- created merge commit. False by default.
-
-merge.verbosity::
- Controls the amount of output shown by the recursive merge
- strategy. Level 0 outputs nothing except a final error
- message if conflicts were detected. Level 1 outputs only
- conflicts, 2 outputs conflicts and file changes. Level 5 and
- above outputs debugging information. The default is level 2.
- Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+include::merge-config.txt[]
branch.<name>.mergeoptions::
Sets default options for merging into branch <name>. The syntax and
- supported options are equal to that of git-merge, but option values
+ supported options are equal to that of 'git-merge', but option values
containing whitespace characters are currently not supported.
HOW MERGE WORKS
---------------
A merge is always between the current `HEAD` and one or more
-remote branch heads, and the index file must exactly match the
-tree of `HEAD` commit (i.e. the contents of the last commit) when
-it happens. In other words, `git-diff --cached HEAD` must
-report no changes.
-
-[NOTE]
-This is a bit of a lie. In certain special cases, your index is
-allowed to be different from the tree of the `HEAD` commit. The most
-notable case is when your `HEAD` commit is already ahead of what
-is being merged, in which case your index can have arbitrary
-differences from your `HEAD` commit. Also, your index entries
-may have differences from your `HEAD` commit that match
-the result of a trivial merge (e.g. you received the same patch
-from an external source to produce the same result as what you are
-merging). For example, if a path did not exist in the common
-ancestor and your head commit but exists in the tree you are
-merging into your repository, and if you already happen to have
-that path exactly in your index, the merge does not have to
-fail.
-
-Otherwise, merge will refuse to do any harm to your repository
-(that is, it may fetch the objects from remote, and it may even
-update the local branch used to keep track of the remote branch
-with `git pull remote rbranch:lbranch`, but your working tree,
-`.git/HEAD` pointer and index file are left intact).
-
-You may have local modifications in the working tree files. In
-other words, `git-diff` is allowed to report changes.
-However, the merge uses your working tree as the working area,
-and in order to prevent the merge operation from losing such
-changes, it makes sure that they do not interfere with the
-merge. Those complex tables in read-tree documentation define
-what it means for a path to "interfere with the merge". And if
-your local modifications interfere with the merge, again, it
-stops before touching anything.
-
-So in the above two "failed merge" case, you do not have to
-worry about loss of data --- you simply were not ready to do
-a merge, so no merge happened at all. You may want to finish
-whatever you were in the middle of doing, and retry the same
-pull after you are done and ready.
-
+commits (usually, branch head or tag), and the index file must
+match the tree of `HEAD` commit (i.e. the contents of the last commit)
+when it starts out. In other words, `git diff --cached HEAD` must
+report no changes. (One exception is when the changed index
+entries are already in the same state that would result from
+the merge anyway.)
+
+Three kinds of merge can happen:
+
+* The merged commit is already contained in `HEAD`. This is the
+ simplest case, called "Already up-to-date."
+
+* `HEAD` is already contained in the merged commit. This is the
+ most common case especially when involved through 'git pull':
+ you are tracking an upstream repository, committed no local
+ changes and now you want to update to a newer upstream revision.
+ Your `HEAD` (and the index) is updated to at point the merged
+ commit, without creating an extra merge commit. This is
+ called "Fast-forward".
+
+* Both the merged commit and `HEAD` are independent and must be
+ tied together by a merge commit that has them both as its parents.
+ The rest of this section describes this "True merge" case.
+
+The chosen merge strategy merges the two commits into a single
+new source tree.
When things cleanly merge, these things happen:
1. The results are updated both in the index file and in your
@@ -138,7 +110,7 @@ When there are conflicts, these things happen:
3. For conflicting paths, the index file records up to three
versions; stage1 stores the version from the common ancestor,
stage2 from `HEAD`, and stage3 from the remote branch (you
- can inspect the stages with `git-ls-files -u`). The working
+ can inspect the stages with `git ls-files -u`). The working
tree files have the result of "merge" program; i.e. 3-way
merge result with familiar conflict markers `<<< === >>>`.
@@ -151,25 +123,29 @@ After seeing a conflict, you can do two things:
* Decide not to merge. The only clean-up you need are to reset
the index file to the `HEAD` commit to reverse 2. and to clean
- up working tree changes made by 2. and 3.; `git-reset` can
+ up working tree changes made by 2. and 3.; 'git-reset --hard' can
be used for this.
- * Resolve the conflicts. `git-diff` would report only the
- conflicting paths because of the above 2. and 3.. Edit the
- working tree files into a desirable shape, `git-add` or `git-rm`
+ * Resolve the conflicts. `git diff` would report only the
+ conflicting paths because of the above 2. and 3.
+ Edit the working tree files into a desirable shape
+ ('git mergetool' can ease this task), 'git-add' or 'git-rm'
them, to make the index file contain what the merge result
- should be, and run `git-commit` to commit the result.
+ should be, and run 'git-commit' to commit the result.
SEE ALSO
--------
linkgit:git-fmt-merge-msg[1], linkgit:git-pull[1],
-linkgit:gitattributes[5]
-
+linkgit:gitattributes[5],
+linkgit:git-reset[1],
+linkgit:git-diff[1], linkgit:git-ls-files[1],
+linkgit:git-add[1], linkgit:git-rm[1],
+linkgit:git-mergetool[1]
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
@@ -178,4 +154,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
index 50f106ec5..e0b2703b3 100644
--- a/Documentation/git-mergetool.txt
+++ b/Documentation/git-mergetool.txt
@@ -7,17 +7,17 @@ git-mergetool - Run merge conflict resolution tools to resolve merge conflicts
SYNOPSIS
--------
-'git-mergetool' [--tool=<tool>] [<file>]...
+'git mergetool' [--tool=<tool>] [<file>]...
DESCRIPTION
-----------
-Use 'git mergetool' to run one of several merge utilities to resolve
-merge conflicts. It is typically run after linkgit:git-merge[1].
+Use `git mergetool` to run one of several merge utilities to resolve
+merge conflicts. It is typically run after 'git-merge'.
If one or more <file> parameters are given, the merge tool program will
be run to resolve differences on each file. If no <file> names are
-specified, 'git mergetool' will run the merge tool program on every file
+specified, 'git-mergetool' will run the merge tool program on every file
with merge conflicts.
OPTIONS
@@ -27,16 +27,38 @@ OPTIONS
Valid merge tools are:
kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff
+
-If a merge resolution program is not specified, 'git mergetool'
-will use the configuration variable merge.tool. If the
-configuration variable merge.tool is not set, 'git mergetool'
+If a merge resolution program is not specified, 'git-mergetool'
+will use the configuration variable `merge.tool`. If the
+configuration variable `merge.tool` is not set, 'git-mergetool'
will pick a suitable default.
+
You can explicitly provide a full path to the tool by setting the
-configuration variable mergetool.<tool>.path. For example, you
+configuration variable `mergetool.<tool>.path`. For example, you
can configure the absolute path to kdiff3 by setting
-mergetool.kdiff3.path. Otherwise, 'git mergetool' assumes the tool
-is available in PATH.
+`mergetool.kdiff3.path`. Otherwise, 'git-mergetool' assumes the
+tool is available in PATH.
++
+Instead of running one of the known merge tool programs
+'git-mergetool' can be customized to run an alternative program
+by specifying the command line to invoke in a configuration
+variable `mergetool.<tool>.cmd`.
++
+When 'git-mergetool' is invoked with this tool (either through the
+`-t` or `--tool` option or the `merge.tool` configuration
+variable) the configured command line will be invoked with `$BASE`
+set to the name of a temporary file containing the common base for
+the merge, if available; `$LOCAL` set to the name of a temporary
+file containing the contents of the file on the current branch;
+`$REMOTE` set to the name of a temporary file containing the
+contents of the file to be merged, and `$MERGED` set to the name
+of the file to which the merge tool should write the result of the
+merge resolution.
++
+If the custom merge tool correctly indicates the success of a
+merge resolution with its exit code then the configuration
+variable `mergetool.<tool>.trustExitCode` can be set to `true`.
+Otherwise, 'git-mergetool' will prompt the user to indicate the
+success of the resolution after the custom tool has exited.
Author
------
@@ -48,4 +70,4 @@ Documentation by Theodore Y Ts'o.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mktag.txt b/Documentation/git-mktag.txt
index 82db9f5d8..8bcc11443 100644
--- a/Documentation/git-mktag.txt
+++ b/Documentation/git-mktag.txt
@@ -8,7 +8,7 @@ git-mktag - Creates a tag object
SYNOPSIS
--------
-'git-mktag' < signature_file
+'git mktag' < signature_file
DESCRIPTION
-----------
@@ -43,4 +43,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mktree.txt b/Documentation/git-mktree.txt
index f312036ab..af19f06ed 100644
--- a/Documentation/git-mktree.txt
+++ b/Documentation/git-mktree.txt
@@ -8,7 +8,7 @@ git-mktree - Build a tree-object from ls-tree formatted text
SYNOPSIS
--------
-'git-mktree' [-z]
+'git mktree' [-z]
DESCRIPTION
-----------
@@ -23,7 +23,7 @@ OPTIONS
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -31,4 +31,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
index bff3fbe74..9c5660275 100644
--- a/Documentation/git-mv.txt
+++ b/Documentation/git-mv.txt
@@ -8,14 +8,14 @@ git-mv - Move or rename a file, a directory, or a symlink
SYNOPSIS
--------
-'git-mv' <options>... <args>...
+'git mv' <options>... <args>...
DESCRIPTION
-----------
This script is used to move or rename a file, directory or symlink.
- git-mv [-f] [-n] <source> <destination>
- git-mv [-f] [-n] [-k] <source> ... <destination directory>
+ git mv [-f] [-n] <source> <destination>
+ git mv [-f] [-n] [-k] <source> ... <destination directory>
In the first form, it renames <source>, which must exist and be either
a file, symlink or directory, to <destination>.
@@ -34,7 +34,8 @@ OPTIONS
condition. An error happens when a source is neither existing nor
controlled by GIT, or when it would overwrite an existing
file unless '-f' is given.
--n, \--dry-run::
+-n::
+--dry-run::
Do nothing; only show what would happen
@@ -50,4 +51,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt
index efcabdc27..abd2237e5 100644
--- a/Documentation/git-name-rev.txt
+++ b/Documentation/git-name-rev.txt
@@ -9,13 +9,13 @@ git-name-rev - Find symbolic names for given revs
SYNOPSIS
--------
[verse]
-'git-name-rev' [--tags] [--refs=<pattern>]
+'git name-rev' [--tags] [--refs=<pattern>]
( --all | --stdin | <committish>... )
DESCRIPTION
-----------
Finds symbolic names suitable for human digestion for revisions given in any
-format parsable by git-rev-parse.
+format parsable by 'git-rev-parse'.
OPTIONS
@@ -38,8 +38,14 @@ OPTIONS
Instead of printing both the SHA-1 and the name, print only
the name. If given with --tags the usual tag prefix of
"tags/" is also omitted from the name, matching the output
- of linkgit:git-describe[1] more closely. This option
- cannot be combined with --stdin.
+ of `git-describe` more closely.
+
+--no-undefined::
+ Die with error code != 0 when a reference is undefined,
+ instead of printing `undefined`.
+
+--always::
+ Show uniquely abbreviated commit object as fallback.
EXAMPLE
-------
@@ -49,7 +55,7 @@ wrote you about that fantastic commit 33db5f4d9027a10e477ccf054b2c1ab94f74c85a.
Of course, you look into the commit, but that only tells you what happened, but
not the context.
-Enter git-name-rev:
+Enter 'git-name-rev':
------------
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a
@@ -75,4 +81,4 @@ Documentation by Johannes Schindelin.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index 74cc7c1cb..8c354bd47 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt
@@ -9,7 +9,7 @@ git-pack-objects - Create a packed archive of objects
SYNOPSIS
--------
[verse]
-'git-pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty]
+'git pack-objects' [-q] [--no-reuse-delta] [--delta-base-offset] [--non-empty]
[--local] [--incremental] [--window=N] [--depth=N] [--all-progress]
[--revs [--unpacked | --all]*] [--stdout | base-name] < object-list
@@ -22,14 +22,15 @@ archive with specified base-name, or to the standard output.
A packed archive is an efficient way to transfer set of objects
between two repositories, and also is an archival format which
is efficient to access. The packed archive format (.pack) is
-designed to be unpackable without having anything else, but for
-random access, accompanied with the pack index file (.idx).
+designed to be self contained so that it can be unpacked without
+any further information, but for fast, random access to the objects
+in the pack, a pack index file (.idx) will be generated.
Placing both in the pack/ subdirectory of $GIT_OBJECT_DIRECTORY (or
any of the directories on $GIT_ALTERNATE_OBJECT_DIRECTORIES)
enables git to read from such an archive.
-'git-unpack-objects' command can read the packed archive and
+The 'git-unpack-objects' command can read the packed archive and
expand the objects contained in the pack into "one-file
one-object" format; this is typically done by the smart-pull
commands when a pack is created on-the-fly for efficient network
@@ -58,7 +59,7 @@ base-name::
--revs::
Read the revision arguments from the standard input, instead of
individual object names. The revision arguments are processed
- the same way as linkgit:git-rev-list[1] with `--objects` flag
+ the same way as 'git-rev-list' with the `--objects` flag
uses its `commit` arguments to build the list of objects it
outputs. The objects on the resulting list are packed.
@@ -73,7 +74,13 @@ base-name::
as if all refs under `$GIT_DIR/refs` are specified to be
included.
---window=[N], --depth=[N]::
+--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.
+
+--window=[N]::
+--depth=[N]::
These two options affect how the objects contained in
the pack are stored using delta compression. The
objects are first internally sorted by type, size and
@@ -99,7 +106,8 @@ base-name::
--max-pack-size=<n>::
Maximum size of each output packfile, expressed in MiB.
If specified, multiple packfiles may be created.
- The default is unlimited.
+ The default is unlimited, unless the config variable
+ `pack.packSizeLimit` is set.
--incremental::
This flag causes an object already in a pack ignored
@@ -155,14 +163,14 @@ base-name::
generated pack. If not specified, pack compression level is
determined first by pack.compression, then by core.compression,
and defaults to -1, the zlib default, if neither is set.
- Add \--no-reuse-object if you want to force a uniform compression
+ Add --no-reuse-object if you want to force a uniform compression
level on all data no matter the source.
--delta-base-offset::
A packed archive can express base object of a delta as
either 20-byte object name or as an offset in the
stream, but older version of git does not understand the
- latter. By default, git-pack-objects only uses 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
compactness. Depending on the average delta chain
@@ -176,6 +184,8 @@ base-name::
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
+ and set the number of threads accordingly.
--index-version=<version>[,<offset>]::
This is intended to be used by the test suite only. It allows
@@ -191,7 +201,7 @@ Documentation
-------------
Documentation by Junio C Hamano
-See Also
+SEE ALSO
--------
linkgit:git-rev-list[1]
linkgit:git-repack[1]
@@ -199,4 +209,4 @@ linkgit:git-prune-packed[1]
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt
index af4aa4a2e..5f9435e59 100644
--- a/Documentation/git-pack-redundant.txt
+++ b/Documentation/git-pack-redundant.txt
@@ -8,21 +8,21 @@ git-pack-redundant - Find redundant pack files
SYNOPSIS
--------
-'git-pack-redundant' [ --verbose ] [ --alt-odb ] < --all | .pack filename ... >
+'git pack-redundant' [ --verbose ] [ --alt-odb ] < --all | .pack filename ... >
DESCRIPTION
-----------
This program computes which packs in your repository
are redundant. The output is suitable for piping to
-'xargs rm' if you are in the root of the repository.
+`xargs rm` if you are in the root of the repository.
-git-pack-redundant accepts a list of objects on standard input. Any objects
+'git-pack-redundant' accepts a list of objects on standard input. Any objects
given will be ignored when checking which packs are required. This makes the
following command useful when wanting to remove packs which contain unreachable
objects.
-git-fsck --full --unreachable | cut -d ' ' -f3 | \
-git-pack-redundant --all | xargs rm
+git fsck --full --unreachable | cut -d ' ' -f3 | \
+git pack-redundant --all | xargs rm
OPTIONS
-------
@@ -46,7 +46,7 @@ Documentation
--------------
Documentation by Lukas Sandström <lukass@etek.chalmers.se>
-See Also
+SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-repack[1]
@@ -54,4 +54,4 @@ linkgit:git-prune-packed[1]
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-pack-refs.txt b/Documentation/git-pack-refs.txt
index e4ff93471..a5244d35f 100644
--- a/Documentation/git-pack-refs.txt
+++ b/Documentation/git-pack-refs.txt
@@ -7,7 +7,7 @@ git-pack-refs - Pack heads and tags for efficient repository access
SYNOPSIS
--------
-'git-pack-refs' [--all] [--no-prune]
+'git pack-refs' [--all] [--no-prune]
DESCRIPTION
-----------
@@ -31,7 +31,7 @@ Subsequent updates to branches always creates new file under
A recommended practice to deal with a repository with too many
refs is to pack its refs with `--all --prune` once, and
-occasionally run `git-pack-refs \--prune`. Tags are by
+occasionally run `git pack-refs \--prune`. Tags are by
definition stationary and are not expected to change. Branch
heads will be packed with the initial `pack-refs --all`, but
only the currently active branch heads will become unpacked,
@@ -42,7 +42,7 @@ unpacked.
OPTIONS
-------
-\--all::
+--all::
The command by default packs all tags and refs that are already
packed, and leaves other refs
@@ -51,7 +51,7 @@ developed and packing their tips does not help performance.
This option causes branch tips to be packed as well. Useful for
a repository with many branches of historical interests.
-\--no-prune::
+--no-prune::
The command usually removes loose refs under `$GIT_DIR/refs`
hierarchy after packing them. This option tells it not to.
@@ -63,4 +63,4 @@ Written by Linus Torvalds <torvalds@osdl.org>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt
index deb8b2f01..cd4306987 100644
--- a/Documentation/git-parse-remote.txt
+++ b/Documentation/git-parse-remote.txt
@@ -8,7 +8,7 @@ git-parse-remote - Routines to help parsing remote repository access parameters
SYNOPSIS
--------
-'. git-parse-remote'
+'. "$(git --exec-path)/git-parse-remote"'
DESCRIPTION
-----------
@@ -32,7 +32,7 @@ get_remote_refs_for_fetch::
get_remote_refs_for_push::
Given the list of user-supplied `<repo> <refspec>...`,
return the list of refs to push in a form suitable to be
- fed to the `git-send-pack` command. When `<refspec>...`
+ fed to the 'git-send-pack' command. When `<refspec>...`
is empty the returned list of refs consists of the
defaults for the given `<repo>`, if specified in
`$GIT_DIR/remotes/`.
@@ -47,4 +47,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt
index 894852a78..477785e13 100644
--- a/Documentation/git-patch-id.txt
+++ b/Documentation/git-patch-id.txt
@@ -7,7 +7,7 @@ git-patch-id - Compute unique ID for a patch
SYNOPSIS
--------
-'git-patch-id' < <patch>
+'git patch-id' < <patch>
DESCRIPTION
-----------
@@ -18,7 +18,7 @@ ID" are almost guaranteed to be the same thing.
IOW, you can use this thing to look for likely duplicate commits.
-When dealing with git-diff-tree output, it takes advantage of
+When dealing with 'git-diff-tree' output, it takes advantage of
the fact that the patch is prefixed with the object name of the
commit, and outputs two 40-byte hexadecimal string. The first
string is the patch ID, and the second string is the commit ID.
@@ -39,4 +39,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-peek-remote.txt b/Documentation/git-peek-remote.txt
index 000171007..8282a5e82 100644
--- a/Documentation/git-peek-remote.txt
+++ b/Documentation/git-peek-remote.txt
@@ -8,15 +8,15 @@ git-peek-remote - List the references in a remote repository
SYNOPSIS
--------
-'git-peek-remote' [--upload-pack=<git-upload-pack>] [<host>:]<directory>
+'git peek-remote' [--upload-pack=<git-upload-pack>] [<host>:]<directory>
DESCRIPTION
-----------
-This command is deprecated; use `git-ls-remote` instead.
+This command is deprecated; use 'git-ls-remote' instead.
OPTIONS
-------
-\--upload-pack=<git-upload-pack>::
+--upload-pack=<git-upload-pack>::
Use this to specify the path to 'git-upload-pack' on the
remote side, if it is not found on your $PATH. Some
installations of sshd ignores the user's environment
@@ -39,7 +39,7 @@ OPTIONS
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -47,4 +47,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt
index 93ee82ae5..b5f26cee1 100644
--- a/Documentation/git-prune-packed.txt
+++ b/Documentation/git-prune-packed.txt
@@ -8,7 +8,7 @@ git-prune-packed - Remove extra objects that are already in pack files
SYNOPSIS
--------
-'git-prune-packed' [-n] [-q]
+'git prune-packed' [-n] [-q]
DESCRIPTION
@@ -42,11 +42,11 @@ Documentation
--------------
Documentation by Ryan Anderson <ryan@michonline.com>
-See Also
+SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-repack[1]
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
index f151cff5d..54f1dab38 100644
--- a/Documentation/git-prune.txt
+++ b/Documentation/git-prune.txt
@@ -13,13 +13,19 @@ SYNOPSIS
DESCRIPTION
-----------
-This runs `git-fsck --unreachable` using all the refs
+NOTE: In most cases, users should run 'git-gc', which calls
+'git-prune'. See the section "NOTES", below.
+
+This runs 'git-fsck --unreachable' using all the refs
available in `$GIT_DIR/refs`, optionally with additional set of
-objects specified on the command line, and prunes all
+objects specified on the command line, and prunes all unpacked
objects unreachable from any of these head objects from the object database.
In addition, it
prunes the unpacked objects that are also found in packs by
-running `git prune-packed`.
+running 'git-prune-packed'.
+
+Note that unreachable, packed objects will remain. If this is
+not desired, see linkgit:git-repack[1].
OPTIONS
-------
@@ -31,7 +37,7 @@ OPTIONS
\--::
Do not interpret any more arguments as options.
-\--expire <time>::
+--expire <time>::
Only expire loose objects older than <time>.
<head>...::
@@ -47,9 +53,26 @@ borrows from your repository via its
`.git/objects/info/alternates`:
------------
-$ git prune $(cd ../another && $(git-rev-parse --all))
+$ git prune $(cd ../another && $(git rev-parse --all))
------------
+Notes
+-----
+
+In most cases, users will not need to call 'git-prune' directly, but
+should instead call 'git-gc', which handles pruning along with
+many other housekeeping tasks.
+
+For a description of which objects are considered for pruning, see
+'git-fsck''s --unreachable option.
+
+SEE ALSO
+--------
+
+linkgit:git-fsck[1],
+linkgit:git-gc[1],
+linkgit:git-reflog[1]
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
@@ -60,4 +83,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 77fdaf146..7578623ed 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -8,23 +8,45 @@ git-pull - Fetch from and merge with another repository or a local branch
SYNOPSIS
--------
-'git-pull' <options> <repository> <refspec>...
+'git pull' <options> <repository> <refspec>...
DESCRIPTION
-----------
-Runs `git-fetch` with the given parameters, and calls `git-merge`
+Runs 'git-fetch' with the given parameters, and calls 'git-merge'
to merge the retrieved head(s) into the current branch.
+With `--rebase`, calls 'git-rebase' instead of 'git-merge'.
Note that you can use `.` (current directory) as the
<repository> to pull from the local repository -- this is useful
when merging local branches into the current branch.
+Also note that options meant for 'git-pull' itself and underlying
+'git-merge' must be given before the options meant for 'git-fetch'.
OPTIONS
-------
include::merge-options.txt[]
+:git-pull: 1
+
+--rebase::
+ Instead of a merge, perform a rebase after fetching. If
+ there is a remote ref for the upstream branch, and this branch
+ was rebased since last fetched, the rebase uses that information
+ to avoid rebasing non-local changes. To make this the default
+ for branch `<name>`, set configuration `branch.<name>.rebase`
+ to `true`.
++
+[NOTE]
+This is a potentially _dangerous_ mode of operation.
+It rewrites history, which does not bode well when you
+published that history already. Do *not* use this option
+unless you have read linkgit:git-rebase[1] carefully.
+
+--no-rebase::
+ Override earlier --rebase.
+
include::fetch-options.txt[]
include::pull-fetch-param.txt[]
@@ -33,16 +55,6 @@ include::urls-remotes.txt[]
include::merge-strategies.txt[]
-\--rebase::
- Instead of a merge, perform a rebase after fetching.
- *NOTE:* This is a potentially _dangerous_ mode of operation.
- It rewrites history, which does not bode well when you
- published that history already. Do *not* use this option
- unless you have read linkgit:git-rebase[1] carefully.
-
-\--no-rebase::
- Override earlier \--rebase.
-
DEFAULT BEHAVIOUR
-----------------
@@ -100,40 +112,58 @@ rules apply:
EXAMPLES
--------
-git pull, git pull origin::
- Update the remote-tracking branches for the repository
- you cloned from, then merge one of them into your
- current branch. Normally the branch merged in is
- the HEAD of the remote repository, but the choice is
- determined by the branch.<name>.remote and
- branch.<name>.merge options; see linkgit:git-config[1]
- for details.
-
-git pull origin next::
- Merge into the current branch the remote branch `next`;
- leaves a copy of `next` temporarily in FETCH_HEAD, but
- does not update any remote-tracking branches.
-
-git pull . fixes enhancements::
- Bundle local branch `fixes` and `enhancements` on top of
- the current branch, making an Octopus merge. This `git pull .`
- syntax is equivalent to `git merge`.
-
-git pull -s ours . obsolete::
- Merge local branch `obsolete` into the current branch,
- using `ours` merge strategy.
-
-git pull --no-commit . maint::
- Merge local branch `maint` into the current branch, but
- do not make a commit automatically. This can be used
- when you want to include further changes to the merge,
- or want to write your own merge commit message.
+* Update the remote-tracking branches for the repository
+ you cloned from, then merge one of them into your
+ current branch:
++
+------------------------------------------------
+$ git pull, git pull origin
+------------------------------------------------
++
+Normally the branch merged in is the HEAD of the remote repository,
+but the choice is determined by the branch.<name>.remote and
+branch.<name>.merge options; see linkgit:git-config[1] for details.
+
+* Merge into the current branch the remote branch `next`:
++
+------------------------------------------------
+$ git pull origin next
+------------------------------------------------
++
+This leaves a copy of `next` temporarily in FETCH_HEAD, but
+does not update any remote-tracking branches.
+
+* Bundle local branch `fixes` and `enhancements` on top of
+ the current branch, making an Octopus merge:
++
+------------------------------------------------
+$ git pull . fixes enhancements
+------------------------------------------------
++
+This `git pull .` syntax is equivalent to `git merge`.
+
+* Merge local branch `obsolete` into the current branch, using `ours`
+ merge strategy:
++
+------------------------------------------------
+$ git pull -s ours . obsolete
+------------------------------------------------
+
+* Merge local branch `maint` into the current branch, but do not make
+ a commit automatically:
++
+------------------------------------------------
+$ git pull --no-commit . maint
+------------------------------------------------
++
+This can be used when you want to include further changes to the
+merge, or want to write your own merge commit message.
+
You should refrain from abusing this option to sneak substantial
changes into a merge commit. Small fixups like bumping
release/version name would be acceptable.
-Command line pull of multiple branches from one repository::
+* Command line pull of multiple branches from one repository:
+
------------------------------------------------
$ git checkout master
@@ -141,19 +171,18 @@ $ git fetch origin +pu:pu maint:tmp
$ git pull . tmp
------------------------------------------------
+
-This updates (or creates, as necessary) branches `pu` and `tmp`
-in the local repository by fetching from the branches
-(respectively) `pu` and `maint` from the remote repository.
+This updates (or creates, as necessary) branches `pu` and `tmp` in
+the local repository by fetching from the branches (respectively)
+`pu` and `maint` from the remote repository.
+
-The `pu` branch will be updated even if it is does not
-fast-forward; the others will not be.
+The `pu` branch will be updated even if it is does not fast-forward;
+the others will not be.
+
The final command then merges the newly fetched `tmp` into master.
If you tried a pull which resulted in a complex conflicts and
-would want to start over, you can recover with
-linkgit:git-reset[1].
+would want to start over, you can recover with 'git-reset'.
SEE ALSO
@@ -164,7 +193,7 @@ linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-config[1]
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
-and Junio C Hamano <junkio@cox.net>
+and Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -174,4 +203,4 @@ Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 5f2494495..45c96435f 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,8 +9,9 @@ git-push - Update remote refs along with associated objects
SYNOPSIS
--------
[verse]
-'git-push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
- [--repo=all] [-f | --force] [-v | --verbose] [<repository> <refspec>...]
+'git push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
+ [--repo=all] [-f | --force] [-v | --verbose]
+ [<repository> <refspec>...]
DESCRIPTION
-----------
@@ -29,28 +30,23 @@ OPTIONS
The "remote" repository that is destination of a push
operation. See the section <<URLS,GIT URLS>> below.
-<refspec>::
+<refspec>...::
The canonical format of a <refspec> parameter is
- `+?<src>:<dst>`; that is, an optional plus `+`, followed
+ `+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
by the source ref, followed by a colon `:`, followed by
the destination ref.
+
-The <src> side can be an
-arbitrary "SHA1 expression" that can be used as an
-argument to `git-cat-file -t`. E.g. `master~4` (push
-four parents before the current master head).
+The <src> side represents the source branch (or arbitrary
+"SHA1 expression", such as `master~4` (four parents before the
+tip of `master` branch); see linkgit:git-rev-parse[1]) that you
+want to push. The <dst> side represents the destination location.
+
The local ref that matches <src> is used
-to fast forward the remote ref that matches <dst>. If
-the optional plus `+` is used, the remote ref is updated
+to fast forward the remote ref that matches <dst> (or, if no <dst> was
+specified, the same ref that <src> referred to locally). If
+the optional leading plus `+` is used, the remote ref is updated
even if it does not result in a fast forward update.
+
-Note: If no explicit refspec is found, (that is neither
-on the command line nor in any Push line of the
-corresponding remotes file---see below), then all the
-heads that exist both on the local side and on the remote
-side are updated.
-+
`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
+
A parameter <ref> without a colon pushes the <ref> from the source
@@ -58,56 +54,118 @@ repository to the destination repository under the same name.
+
Pushing an empty <src> allows you to delete the <dst> ref from
the remote repository.
-
-\--all::
++
+The special refspec `:` (or `+:` to allow non-fast forward updates)
+directs git to push "matching" heads: for every head that exists on
+the local side, the remote side is updated if a head 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
+nor in any Push line of the corresponding remotes file---see below).
+
+--all::
Instead of naming each ref to push, specifies that all
refs under `$GIT_DIR/refs/heads/` be pushed.
-\--mirror::
+--mirror::
Instead of naming each ref to push, specifies that all
- refs under `$GIT_DIR/refs/heads/` and `$GIT_DIR/refs/tags/`
+ refs under `$GIT_DIR/refs/` (which includes but is not
+ limited to `refs/heads/`, `refs/remotes/`, and `refs/tags/`)
be mirrored to the remote repository. Newly created local
refs will be pushed to the remote end, locally updated refs
will be force updated on the remote end, and deleted refs
- will be removed from the remote end.
+ will be removed from the remote end. This is the default
+ if the configuration option `remote.<remote>.mirror` is
+ set.
-\--dry-run::
+--dry-run::
Do everything except actually send the updates.
-\--tags::
+--tags::
All refs under `$GIT_DIR/refs/tags` are pushed, in
addition to refspecs explicitly listed on the command
line.
-\--receive-pack=<git-receive-pack>::
+--receive-pack=<git-receive-pack>::
Path to the 'git-receive-pack' program on the remote
end. Sometimes useful when pushing to a remote
repository over ssh, and you do not have the program in
a directory on the default $PATH.
-\--exec=<git-receive-pack>::
+--exec=<git-receive-pack>::
Same as \--receive-pack=<git-receive-pack>.
--f, \--force::
+-f::
+--force::
Usually, the command refuses to update a remote ref that is
not an ancestor of the local ref used to overwrite it.
This flag disables the check. This can cause the
remote repository to lose commits; use it with care.
-\--repo=<repo>::
+--repo=<repo>::
When no repository is specified the command defaults to
"origin"; this overrides it.
-\--thin, \--no-thin::
- These options are passed to `git-send-pack`. Thin
+--thin::
+--no-thin::
+ These options are passed to 'git-send-pack'. Thin
transfer spends extra cycles to minimize the number of
objects to be sent and meant to be used on slower connection.
--v, \--verbose::
+-v::
+--verbose::
Run verbosely.
include::urls-remotes.txt[]
+OUTPUT
+------
+
+The output of "git push" depends on the transport method used; this
+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
+representing the status of a single ref. Each line is of the form:
+
+-------------------------------
+ <flag> <summary> <from> -> <to> (<reason>)
+-------------------------------
+
+flag::
+ A single character indicating the status of the ref. This is
+ blank for a successfully pushed ref, `!` for a ref that was
+ rejected or failed to push, and '=' for a ref that was up to
+ date and did not need pushing (note that the status of up to
+ date refs is shown only when `git push` is running verbosely).
+
+summary::
+ For a successfully pushed ref, the summary shows the old and new
+ values of the ref in a form suitable for using as an argument to
+ `git log` (this is `<old>..<new>` in most cases, and
+ `<old>...<new>` for forced non-fast forward updates). For a
+ failed update, more details are given for the failure.
+ The string `rejected` indicates that git did not try to send the
+ ref at all (typically because it is not a fast forward). The
+ string `remote rejected` indicates that the remote end refused
+ the update; this rejection is typically caused by a hook on the
+ remote side. The string `remote failure` indicates that the
+ remote end did not report the successful update of the ref
+ (perhaps because of a temporary error on the remote side, a
+ break in the network connection, or other transient error).
+
+from::
+ The name of the local ref being pushed, minus its
+ `refs/<type>/` prefix. In the case of deletion, the
+ name of the local ref is omitted.
+
+to::
+ The name of the remote ref being updated, minus its
+ `refs/<type>/` prefix.
+
+reason::
+ A human-readable explanation. In the case of successfully pushed
+ refs, no explanation is needed. For a failed ref, the reason for
+ failure is described.
Examples
--------
@@ -116,27 +174,29 @@ git push origin master::
Find a ref that matches `master` in the source repository
(most likely, it would find `refs/heads/master`), and update
the same ref (e.g. `refs/heads/master`) in `origin` repository
- with it.
+ with it. If `master` did not exist remotely, it would be
+ created.
git push origin :experimental::
Find a ref that matches `experimental` in the `origin` repository
(e.g. `refs/heads/experimental`), and delete it.
-git push origin master:satellite/master::
- Find a ref that matches `master` in the source repository
- (most likely, it would find `refs/heads/master`), and update
- the ref that matches `satellite/master` (most likely, it would
- be `refs/remotes/satellite/master`) in `origin` repository with it.
+git push origin master:satellite/master dev:satellite/dev::
+ Use the source ref that matches `master` (e.g. `refs/heads/master`)
+ to update the ref that matches `satellite/master` (most probably
+ `refs/remotes/satellite/master`) in the `origin` repository, then
+ do the same for `dev` and `satellite/dev`.
git push origin master:refs/heads/experimental::
Create the branch `experimental` in the `origin` repository
- by copying the current `master` branch. This form is usually
- needed to create a new branch in the remote repository as
- there is no `experimental` branch to match.
+ by copying the current `master` branch. This form is only
+ needed to create a new branch or tag in the remote repository when
+ the local name and the remote name are different; otherwise,
+ the ref name on its own will work.
Author
------
-Written by Junio C Hamano <junkio@cox.net>, later rewritten in C
+Written by Junio C Hamano <gitster@pobox.com>, later rewritten in C
by Linus Torvalds <torvalds@osdl.org>
Documentation
@@ -145,4 +205,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt
index 0fc2b56c1..d4037de51 100644
--- a/Documentation/git-quiltimport.txt
+++ b/Documentation/git-quiltimport.txt
@@ -9,7 +9,7 @@ git-quiltimport - Applies a quilt patchset onto the current branch
SYNOPSIS
--------
[verse]
-'git-quiltimport' [--dry-run] [--author <author>] [--patches <dir>]
+'git quiltimport' [--dry-run] [--author <author>] [--patches <dir>]
DESCRIPTION
@@ -29,6 +29,8 @@ preserved as the 1 line subject in the git description.
OPTIONS
-------
+
+-n::
--dry-run::
Walk through the patches in the series and warn
if we cannot find all of the necessary information to commit
@@ -57,4 +59,4 @@ Documentation by Eric Biederman <ebiederm@lnxi.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt
index 8421d1fd7..6f4b9b017 100644
--- a/Documentation/git-read-tree.txt
+++ b/Documentation/git-read-tree.txt
@@ -8,7 +8,7 @@ git-read-tree - Reads tree information into the index
SYNOPSIS
--------
-'git-read-tree' (<tree-ish> | [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] [--index-output=<file>] <tree-ish1> [<tree-ish2> [<tree-ish3>]])
+'git read-tree' (<tree-ish> | [[-m [--trivial] [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] [--index-output=<file>] <tree-ish1> [<tree-ish2> [<tree-ish3>]])
DESCRIPTION
@@ -22,8 +22,8 @@ fast-forward (i.e. 2-way) merge, or a 3-way merge, with the `-m`
flag. When used with `-m`, the `-u` flag causes it to also update
the files in the work tree with the result of the merge.
-Trivial merges are done by `git-read-tree` itself. Only conflicting paths
-will be in unmerged state when `git-read-tree` returns.
+Trivial merges are done by 'git-read-tree' itself. Only conflicting paths
+will be in unmerged state when 'git-read-tree' returns.
OPTIONS
-------
@@ -50,14 +50,17 @@ OPTIONS
trees that are not directly related to the current
working tree status into a temporary index file.
+-v::
+ Show the progress of checking files out.
+
--trivial::
- Restrict three-way merge by `git-read-tree` to happen
+ Restrict three-way merge by 'git-read-tree' to happen
only if there is no file-level merging required, instead
of resolving merge for trivial cases and leaving
conflicting files unresolved in the index.
--aggressive::
- Usually a three-way merge by `git-read-tree` resolves
+ Usually a three-way merge by 'git-read-tree' resolves
the merge for really trivial cases and leaves other
cases unresolved in the index, so that Porcelains can
implement different merge policies. This flag makes the
@@ -110,7 +113,7 @@ OPTIONS
Merging
-------
-If `-m` is specified, `git-read-tree` can perform 3 kinds of
+If `-m` is specified, 'git-read-tree' can perform 3 kinds of
merge, a single tree merge if only 1 tree is given, a
fast-forward merge with 2 trees, or a 3-way merge if 3 trees are
provided.
@@ -118,29 +121,29 @@ provided.
Single Tree Merge
~~~~~~~~~~~~~~~~~
-If only 1 tree is specified, git-read-tree operates as if the user did not
+If only 1 tree is specified, 'git-read-tree' operates as if the user did not
specify `-m`, except that if the original index has an entry for a
given pathname, and the contents of the path matches with the tree
being read, the stat info from the index is used. (In other words, the
index's stat()s take precedence over the merged tree's).
-That means that if you do a `git-read-tree -m <newtree>` followed by a
-`git-checkout-index -f -u -a`, the `git-checkout-index` only checks out
+That means that if you do a `git read-tree -m <newtree>` followed by a
+`git checkout-index -f -u -a`, the 'git-checkout-index' only checks out
the stuff that really changed.
-This is used to avoid unnecessary false hits when `git-diff-files` is
-run after `git-read-tree`.
+This is used to avoid unnecessary false hits when 'git-diff-files' is
+run after 'git-read-tree'.
Two Tree Merge
~~~~~~~~~~~~~~
-Typically, this is invoked as `git-read-tree -m $H $M`, where $H
+Typically, this is invoked as `git read-tree -m $H $M`, where $H
is the head commit of the current repository, and $M is the head
of a foreign tree, which is simply ahead of $H (i.e. we are in a
fast forward situation).
-When two trees are specified, the user is telling git-read-tree
+When two trees are specified, the user is telling 'git-read-tree'
the following:
1. The current index and work tree is derived from $H, but
@@ -148,7 +151,7 @@ the following:
2. The user wants to fast-forward to $M.
-In this case, the `git-read-tree -m $H $M` command makes sure
+In this case, the `git read-tree -m $H $M` command makes sure
that no local change is lost as the result of this "merge".
Here are the "carry forward" rules:
@@ -190,18 +193,18 @@ Here are the "carry forward" rules:
In all "keep index" cases, the index entry stays as in the
original index file. If the entry were not up to date,
-git-read-tree keeps the copy in the work tree intact when
+'git-read-tree' keeps the copy in the work tree intact when
operating under the -u flag.
-When this form of git-read-tree returns successfully, you can
+When this form of 'git-read-tree' returns successfully, you can
see what "local changes" you made are carried forward by running
-`git-diff-index --cached $M`. Note that this does not
-necessarily match `git-diff-index --cached $H` would have
+`git diff-index --cached $M`. Note that this does not
+necessarily match `git diff-index --cached $H` would have
produced before such a two tree merge. This is because of cases
18 and 19 --- if you already had the changes in $M (e.g. maybe
-you picked it up via e-mail in a patch form), `git-diff-index
+you picked it up via e-mail in a patch form), `git diff-index
--cached $H` would have told you about the change before this
-merge, but it would not show in `git-diff-index --cached $M`
+merge, but it would not show in `git diff-index --cached $M`
output after two-tree merge.
@@ -210,13 +213,13 @@ output after two-tree merge.
Each "index" entry has two bits worth of "stage" state. stage 0 is the
normal one, and is the only one you'd see in any kind of normal use.
-However, when you do `git-read-tree` with three trees, the "stage"
+However, when you do 'git-read-tree' with three trees, the "stage"
starts out at 1.
This means that you can do
----------------
-$ git-read-tree -m <tree1> <tree2> <tree3>
+$ git read-tree -m <tree1> <tree2> <tree3>
----------------
and you will end up with an index with all of the <tree1> entries in
@@ -226,7 +229,7 @@ branch into the current branch, we use the common ancestor tree
as <tree1>, the current branch head as <tree2>, and the other
branch head as <tree3>.
-Furthermore, `git-read-tree` has special-case logic that says: if you see
+Furthermore, 'git-read-tree' has special-case logic that says: if you see
a file that matches in all respects in the following states, it
"collapses" back to "stage0":
@@ -242,7 +245,7 @@ a file that matches in all respects in the following states, it
- stage 1 and stage 3 are the same and stage 2 is different take
stage 2 (we did something while they did nothing)
-The `git-write-tree` command refuses to write a nonsensical tree, and it
+The 'git-write-tree' command refuses to write a nonsensical tree, and it
will complain about unmerged entries if it sees a single entry that is not
stage 0.
@@ -258,7 +261,7 @@ start a 3-way merge with an index file that is already
populated. Here is an outline of how the algorithm works:
- if a file exists in identical format in all three trees, it will
- automatically collapse to "merged" state by git-read-tree.
+ automatically collapse to "merged" state by 'git-read-tree'.
- a file that has _any_ difference what-so-ever in the three trees
will stay as separate entries in the index. It's up to "porcelain
@@ -282,8 +285,8 @@ populated. Here is an outline of how the algorithm works:
matching "stage1" entry if it exists too. .. all the normal
trivial rules ..
-You would normally use `git-merge-index` with supplied
-`git-merge-one-file` to do this last step. The script updates
+You would normally use 'git-merge-index' with supplied
+'git-merge-one-file' to do this last step. The script updates
the files in the working tree as it merges each path and at the
end of a successful merge.
@@ -301,16 +304,16 @@ commit. To illustrate, suppose you start from what has been
committed last to your repository:
----------------
-$ JC=`git-rev-parse --verify "HEAD^0"`
-$ git-checkout-index -f -u -a $JC
+$ JC=`git rev-parse --verify "HEAD^0"`
+$ git checkout-index -f -u -a $JC
----------------
-You do random edits, without running git-update-index. And then
+You do random edits, without running 'git-update-index'. And then
you notice that the tip of your "upstream" tree has advanced
since you pulled from him:
----------------
-$ git-fetch git://.... linus
+$ git fetch git://.... linus
$ LT=`cat .git/FETCH_HEAD`
----------------
@@ -320,10 +323,10 @@ added or modified index entries since $JC, and if you haven't,
then does the right thing. So with the following sequence:
----------------
-$ git-read-tree -m -u `git-merge-base $JC $LT` $JC $LT
-$ git-merge-index git-merge-one-file -a
+$ git read-tree -m -u `git merge-base $JC $LT` $JC $LT
+$ git merge-index git-merge-one-file -a
$ echo "Merge with Linus" | \
- git-commit-tree `git-write-tree` -p $JC -p $LT
+ git commit-tree `git write-tree` -p $JC -p $LT
----------------
what you would commit is a pure merge between $JC and $LT without
@@ -331,21 +334,21 @@ your work-in-progress changes, and your work tree would be
updated to the result of the merge.
However, if you have local changes in the working tree that
-would be overwritten by this merge,`git-read-tree` will refuse
+would be overwritten by this merge, 'git-read-tree' will refuse
to run to prevent your changes from being lost.
In other words, there is no need to worry about what exists only
in the working tree. When you have local changes in a part of
the project that is not involved in the merge, your changes do
not interfere with the merge, and are kept intact. When they
-*do* interfere, the merge does not even start (`git-read-tree`
+*do* interfere, the merge does not even start ('git-read-tree'
complains loudly and fails without modifying anything). In such
a case, you can simply continue doing what you were in the
middle of doing, and when your working tree is ready (i.e. you
have finished your work-in-progress), attempt the merge again.
-See Also
+SEE ALSO
--------
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];
linkgit:gitignore[5]
@@ -361,4 +364,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index c11c6453e..59c1b021a 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -8,14 +8,15 @@ git-rebase - Forward-port local commits to the updated upstream head
SYNOPSIS
--------
[verse]
-'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
+'git rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
+ [-s <strategy> | --strategy=<strategy>]
[-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
[--onto <newbase>] <upstream> [<branch>]
-'git-rebase' --continue | --skip | --abort
+'git rebase' --continue | --skip | --abort
DESCRIPTION
-----------
-If <branch> is specified, git-rebase will perform an automatic
+If <branch> is specified, 'git-rebase' will perform an automatic
`git checkout <branch>` before doing anything else. Otherwise
it remains on the current branch.
@@ -25,7 +26,8 @@ of commits that would be shown by `git log <upstream>..HEAD`.
The current branch is reset to <upstream>, or <newbase> if the
--onto option was supplied. This has the exact same effect as
-`git reset --hard <upstream>` (or <newbase>).
+`git reset --hard <upstream>` (or <newbase>). ORIG_HEAD is set
+to point at the tip of the branch before the reset.
The commits that were previously saved into the temporary area are
then reapplied to the current branch, one by one, in order. Note that
@@ -37,8 +39,8 @@ It is possible that a merge failure will prevent this process from being
completely automatic. You will have to resolve any such merge failure
and run `git rebase --continue`. Another option is to bypass the commit
that caused the merge failure with `git rebase --skip`. To restore the
-original <branch> and remove the .dotest working files, use the command
-`git rebase --abort` instead.
+original <branch> and remove the .git/rebase-apply working files, use the
+command `git rebase --abort` instead.
Assume the following history exists and the current branch is "topic":
@@ -51,8 +53,8 @@ Assume the following history exists and the current branch is "topic":
From this point, the result of either of the following commands:
- git-rebase master
- git-rebase master topic
+ git rebase master
+ git rebase master topic
would be:
@@ -67,7 +69,7 @@ followed by `git rebase master`.
If the upstream branch already contains a change you have made (e.g.,
because you mailed a patch which was applied upstream), then that commit
-will be skipped. For example, running `git-rebase master` on the
+will be skipped. For example, running `git rebase master` on the
following history (in which A' and A introduce the same set of changes,
but have different committer information):
@@ -115,7 +117,7 @@ got merged into more stable 'master' branch, like this:
We can get this using the following command:
- git-rebase --onto master next topic
+ git rebase --onto master next topic
Another example of --onto option is to rebase part of a
@@ -131,7 +133,7 @@ branch. If we have the following situation:
then the command
- git-rebase --onto master topicA topicB
+ git rebase --onto master topicA topicB
would result in:
@@ -154,7 +156,7 @@ the following situation:
then the command
- git-rebase --onto topicA~5 topicA~3 topicA
+ git rebase --onto topicA~5 topicA~3 topicA
would result in the removal of commits F and G:
@@ -166,8 +168,8 @@ This is useful if F and G were flawed in some way, or should not be
part of topicA. Note that the argument to --onto and the <upstream>
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
+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,
typically this would be done with
@@ -183,7 +185,7 @@ desired resolution, you can continue the rebasing process with
git rebase --continue
-Alternatively, you can undo the git-rebase with
+Alternatively, you can undo the 'git-rebase' with
git rebase --abort
@@ -212,19 +214,22 @@ OPTIONS
--skip::
Restart the rebasing process by skipping the current patch.
--m, \--merge::
+-m::
+--merge::
Use merging strategies to rebase. When the recursive (default) merge
strategy is used, this allows rebase to be aware of renames on the
upstream side.
--s <strategy>, \--strategy=<strategy>::
+-s <strategy>::
+--strategy=<strategy>::
Use the given merge strategy; can be supplied more than
once to specify them in the order they should be tried.
If there is no `-s` option, a built-in list of strategies
- is used instead (`git-merge-recursive` when merging a single
- head, `git-merge-octopus` otherwise). This implies --merge.
+ is used instead ('git-merge-recursive' when merging a single
+ head, 'git-merge-octopus' otherwise). This implies --merge.
--v, \--verbose::
+-v::
+--verbose::
Display a diffstat of what changed upstream since the last rebase.
-C<n>::
@@ -234,15 +239,17 @@ OPTIONS
ever ignored.
--whitespace=<nowarn|warn|error|error-all|strip>::
- This flag is passed to the `git-apply` program
+ This flag is passed to the 'git-apply' program
(see linkgit:git-apply[1]) that applies the patch.
--i, \--interactive::
+-i::
+--interactive::
Make a list of the commits which are about to be rebased. Let the
user edit that list before rebasing. This mode can also be used to
split commits (see SPLITTING COMMITS below).
--p, \--preserve-merges::
+-p::
+--preserve-merges::
Instead of ignoring merges, try to recreate them. This option
only works in interactive mode.
@@ -253,16 +260,15 @@ NOTES
When you rebase a branch, you are changing its history in a way that
will cause problems for anyone who already has a copy of the branch
in their repository and tries to pull updates from you. You should
-understand the implications of using 'git rebase' on a repository that
+understand the implications of using 'git-rebase' on a repository that
you share.
-When the git rebase command is run, it will first execute a "pre-rebase"
+When the git-rebase command is run, it will first execute a "pre-rebase"
hook if one exists. You can use this hook to do sanity checks and
reject the rebase if it isn't appropriate. Please see the template
pre-rebase hook script for an example.
-You must be in the top directory of your project to start (or continue)
-a rebase. Upon completion, <branch> will be the current branch.
+Upon completion, <branch> will be the current branch.
INTERACTIVE MODE
----------------
@@ -309,12 +315,12 @@ pick fa1afe1 The oneline of the next commit
...
-------------------------------------------
-The oneline descriptions are purely for your pleasure; `git-rebase` will
+The oneline descriptions are purely for your pleasure; 'git-rebase' will
not look at them but at the commit names ("deadbee" and "fa1afe1" in this
example), so do not delete or edit the names.
By replacing the command "pick" with the command "edit", you can tell
-`git-rebase` to stop after applying that commit, so that you can edit
+'git-rebase' to stop after applying that commit, so that you can edit
the files and/or the commit message, amend the commit, and continue
rebasing.
@@ -329,7 +335,7 @@ the loop with `git rebase --continue`.
For example, if you want to reorder the last 5 commits, such that what
was HEAD~4 becomes the new HEAD. To achieve that, you would call
-`git-rebase` like this:
+'git-rebase' like this:
----------------------
$ git rebase -i HEAD~5
@@ -359,40 +365,40 @@ SPLITTING COMMITS
-----------------
In interactive mode, you can mark commits with the action "edit". However,
-this does not necessarily mean that 'git rebase' expects the result of this
+this does not necessarily mean that 'git-rebase' expects the result of this
edit to be exactly one commit. Indeed, you can undo the commit, or you can
add other commits. This can be used to split a commit into two:
-- Start an interactive rebase with 'git rebase -i <commit>^', where
+- Start an interactive rebase with `git rebase -i <commit>^`, where
<commit> is the commit you want to split. In fact, any commit range
will do, as long as it contains that commit.
- Mark the commit you want to split with the action "edit".
-- When it comes to editing that commit, execute 'git reset HEAD^'. The
+- When it comes to editing that commit, execute `git reset HEAD^`. The
effect is that the HEAD is rewound by one, and the index follows suit.
However, the working tree stays the same.
- Now add the changes to the index that you want to have in the first
- commit. You can use linkgit:git-add[1] (possibly interactively) and/or
- linkgit:git-gui[1] to do that.
+ commit. You can use `git add` (possibly interactively) or
+ 'git-gui' (or both) to do that.
- Commit the now-current index with whatever commit message is appropriate
now.
- Repeat the last two steps until your working tree is clean.
-- Continue the rebase with 'git rebase --continue'.
+- Continue the rebase with `git rebase --continue`.
If you are not absolutely sure that the intermediate revisions are
consistent (they compile, pass the testsuite, etc.) you should use
-linkgit:git-stash[1] to stash away the not-yet-committed changes
+'git-stash' to stash away the not-yet-committed changes
after each commit, test, and amend the commit if fixes are necessary.
Authors
------
-Written by Junio C Hamano <junkio@cox.net> and
+Written by Junio C Hamano <gitster@pobox.com> and
Johannes E. Schindelin <johannes.schindelin@gmx.de>
Documentation
@@ -401,4 +407,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
index 4111434bb..6b2f8c4de 100644
--- a/Documentation/git-receive-pack.txt
+++ b/Documentation/git-receive-pack.txt
@@ -8,7 +8,7 @@ git-receive-pack - Receive what is pushed into the repository
SYNOPSIS
--------
-'git-receive-pack' <directory>
+'git receive-pack' <directory>
DESCRIPTION
-----------
@@ -18,17 +18,17 @@ information fed from the remote end.
This command is usually not invoked directly by the end user.
The UI for the protocol is on the 'git-send-pack' side, and the
program pair is meant to be used to push updates to remote
-repository. For pull operations, see 'git-fetch-pack'.
+repository. For pull operations, see linkgit:git-fetch-pack[1].
The command allows for creation and fast forwarding of sha1 refs
(heads/tags) on the remote end (strictly speaking, it is the
-local end receive-pack runs, but to the user who is sitting at
+local end 'git-receive-pack' runs, but to the user who is sitting at
the send-pack end, it is updating the remote. Confused?)
There are other real-world examples of using update and
post-update hooks found in the Documentation/howto directory.
-git-receive-pack honours the receive.denyNonFastForwards config
+'git-receive-pack' honours the receive.denyNonFastForwards config
option, which tells it if updates to a ref should be denied if they
are not fast-forwards.
@@ -111,10 +111,10 @@ ref listing the commits pushed to the repository:
if expr "$oval" : '0*$' >/dev/null
then
echo "Created a new ref, with the following commits:"
- git-rev-list --pretty "$nval"
+ git rev-list --pretty "$nval"
else
echo "New commits:"
- git-rev-list --pretty "$nval" "^$oval"
+ git rev-list --pretty "$nval" "^$oval"
fi |
mail -s "Changes to ref $ref" commit-list@mydomain
done
@@ -125,7 +125,7 @@ non-zero exit code will generate an error message.
Note that it is possible for refname to not have sha1-new when this
hook runs. This can easily occur if another user modifies the ref
-after it was updated by receive-pack, but before the hook was able
+after it was updated by 'git-receive-pack', but before the hook was able
to evaluate it. It is recommended that hooks rely on sha1-new
rather than the current value of refname.
@@ -137,14 +137,14 @@ post-update will called with the list of refs that have been updated.
This can be used to implement any repository wide cleanup tasks.
The exit code from this hook invocation is ignored; the only thing
-left for git-receive-pack to do at that point is to exit itself
+left for 'git-receive-pack' to do at that point is to exit itself
anyway.
-This hook can be used, for example, to run "git-update-server-info"
+This hook can be used, for example, to run `git update-server-info`
if the repository is packed and is served via a dumb transport.
#!/bin/sh
- exec git-update-server-info
+ exec git update-server-info
SEE ALSO
@@ -162,4 +162,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index f9bba36c2..d99236e14 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -16,10 +16,12 @@ The command takes various subcommands, and different options
depending on the subcommand:
[verse]
-git reflog expire [--dry-run] [--stale-fix] [--verbose]
+'git reflog expire' [--dry-run] [--stale-fix] [--verbose]
[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
-
-git reflog [show] [log-options] [<ref>]
++
+'git reflog delete' ref@\{specifier\}...
++
+'git reflog' ['show'] [log-options] [<ref>]
Reflog is a mechanism to record when the tip of branches are
updated. This command is to manage the information recorded in it.
@@ -34,7 +36,7 @@ The subcommand "show" (which is also the default, in the absence of any
subcommands) will take all the normal log options, and show the log of
the reference provided in the command-line (or `HEAD`, by default).
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';
+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
@@ -43,6 +45,9 @@ two moves ago", `master@\{one.week.ago\}` means "where master used to
point to one week ago", and so on. See linkgit:git-rev-parse[1] for
more details.
+To delete single entries from the reflog, use the subcommand "delete"
+and specify the _exact_ entry (e.g. "`git reflog delete master@\{2\}`").
+
OPTIONS
-------
@@ -55,7 +60,7 @@ OPTIONS
refs.
+
This computation involves traversing all the reachable objects, i.e. it
-has the same cost as 'git prune'. Fortunately, once this is run, we
+has the same cost as 'git-prune'. Fortunately, once this is run, we
should not have to ever worry about missing objects, because the current
prune and pack-objects know about reflogs and protect objects referred by
them.
@@ -75,12 +80,21 @@ them.
--all::
Instead of listing <refs> explicitly, prune all refs.
+--updateref::
+ Update the ref with the sha1 of the top reflog entry (i.e.
+ <ref>@\{0\}) after expiring or deleting.
+
+--rewrite::
+ While expiring or deleting, adjust each reflog entry to ensure
+ that the `old` sha1 field points to the `new` sha1 field of the
+ previous entry.
+
--verbose::
Print extra information on screen.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -88,4 +102,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-relink.txt b/Documentation/git-relink.txt
index 1b024ded3..25ff8f9dc 100644
--- a/Documentation/git-relink.txt
+++ b/Documentation/git-relink.txt
@@ -7,7 +7,7 @@ git-relink - Hardlink common objects in local repositories
SYNOPSIS
--------
-'git-relink' [--safe] <dir> [<dir>]\* <master_dir>
+'git relink' [--safe] <dir> [<dir>]\* <master_dir>
DESCRIPTION
-----------
@@ -34,4 +34,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 10f6fa58b..bb99810ec 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -9,12 +9,12 @@ git-remote - manage set of tracked repositories
SYNOPSIS
--------
[verse]
-'git-remote'
-'git-remote' add [-t <branch>] [-m <branch>] [-f] [--mirror] <name> <url>
-'git-remote' rm <name>
-'git-remote' show <name>
-'git-remote' prune <name>
-'git-remote' update [group]
+'git remote' [-v | --verbose]
+'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>
+'git remote rm' <name>
+'git remote show' [-n] <name>
+'git remote prune' [-n | --dry-run] <name>
+'git remote update' [group]
DESCRIPTION
-----------
@@ -22,6 +22,14 @@ DESCRIPTION
Manage the set of repositories ("remotes") whose branches you track.
+OPTIONS
+-------
+
+-v::
+--verbose::
+ Be a little more verbose and show remote url after name.
+
+
COMMANDS
--------
@@ -47,9 +55,11 @@ With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
up to point at remote's `<master>` branch instead of whatever
branch the `HEAD` at the remote repository actually points at.
+
-In mirror mode, enabled with `--mirror`, the refs will not be stored
+In mirror mode, enabled with `\--mirror`, the refs will not be stored
in the 'refs/remotes/' namespace, but in 'refs/heads/'. This option
-only makes sense in bare repositories.
+only makes sense in bare repositories. If a remote uses mirror
+mode, furthermore, `git push` will always behave as if `\--mirror`
+was passed.
'rm'::
@@ -70,9 +80,8 @@ These stale branches have already been removed from the remote repository
referenced by <name>, but are still locally available in
"remotes/<name>".
+
-With `-n` option, the remote heads are not confirmed first with `git
-ls-remote <name>`; cached information is used instead. Use with
-caution.
+With `--dry-run` option, report what branches will be pruned, but do no
+actually prune them.
'update'::
@@ -115,7 +124,7 @@ $ git checkout -b nfs linux-nfs/master
...
------------
-* Imitate 'git clone' but track only selected branches
+* Imitate 'git-clone' but track only selected branches
+
------------
$ mkdir project.git
@@ -126,7 +135,7 @@ $ git merge origin
------------
-See Also
+SEE ALSO
--------
linkgit:git-fetch[1]
linkgit:git-branch[1]
@@ -144,4 +153,4 @@ Documentation by J. Bruce Fields and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 3d957492f..38ac60947 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -8,7 +8,7 @@ git-repack - Pack unpacked objects in a repository
SYNOPSIS
--------
-'git-repack' [-a] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]
+'git repack' [-a] [-A] [-d] [-f] [-l] [-n] [-q] [--window=N] [--depth=N]
DESCRIPTION
-----------
@@ -37,28 +37,45 @@ OPTIONS
leaves behind, but `git fsck --full` shows as
dangling.
+-A::
+ Same as `-a`, but any unreachable objects in a previous
+ pack become loose, unpacked objects, instead of being
+ left in the old pack. Unreachable objects are never
+ intentionally added to a pack, even when repacking.
+ When used with '-d', this option
+ prevents unreachable objects from being immediately
+ deleted by way of being left in the old pack and then
+ removed. Instead, the loose unreachable objects
+ will be pruned according to normal expiry rules
+ with the next 'git-gc' invocation. See linkgit:git-gc[1].
+
-d::
After packing, if the newly created packs make some
existing packs redundant, remove the redundant packs.
- Also runs linkgit:git-prune-packed[1].
+ Also run 'git-prune-packed' to remove redundant
+ loose object files.
-l::
- Pass the `--local` option to `git pack-objects`, see
+ Pass the `--local` option to 'git-pack-objects'. See
linkgit:git-pack-objects[1].
-f::
- Pass the `--no-reuse-delta` option to `git pack-objects`, see
+ Pass the `--no-reuse-delta` option to 'git-pack-objects'. See
linkgit:git-pack-objects[1].
-q::
- Pass the `-q` option to `git pack-objects`, see
+ Pass the `-q` option to 'git-pack-objects'. See
linkgit:git-pack-objects[1].
-n::
- Do not update the server information with
- `git update-server-info`.
-
---window=[N], --depth=[N]::
+ Do not update the server information with
+ 'git-update-server-info'. This option skips
+ updating local catalog files needed to publish
+ this repository (or a direct copy of it)
+ over HTTP or FTP. See linkgit:git-update-server-info[1].
+
+--window=[N]::
+--depth=[N]::
These two options affect how the objects contained in the pack are
stored using delta compression. The objects are first internally
sorted by type, size and optionally names and compared against the
@@ -90,7 +107,7 @@ Configuration
When configuration variable `repack.UseDeltaBaseOffset` is set
for the repository, the command passes `--delta-base-offset`
-option to `git-pack-objects`; this typically results in slightly
+option to 'git-pack-objects'; this typically results in slightly
smaller packs, but the generated packs are incompatible with
versions of git older than (and including) v1.4.3; do not set
the variable in a repository that older version of git needs to
@@ -107,11 +124,11 @@ Documentation
--------------
Documentation by Ryan Anderson <ryan@michonline.com>
-See Also
+SEE ALSO
--------
linkgit:git-pack-objects[1]
linkgit:git-prune-packed[1]
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index 2ca39946b..e5bdb5533 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -8,7 +8,7 @@ git-repo-config - Get and set repository or global options
SYNOPSIS
--------
-'git-repo-config' ...
+'git repo-config' ...
DESCRIPTION
diff --git a/Documentation/git-request-pull.txt b/Documentation/git-request-pull.txt
index 270df9b18..19335fdda 100644
--- a/Documentation/git-request-pull.txt
+++ b/Documentation/git-request-pull.txt
@@ -7,7 +7,7 @@ git-request-pull - Generates a summary of pending changes
SYNOPSIS
--------
-'git-request-pull' <start> <url> [<end>]
+'git request-pull' <start> <url> [<end>]
DESCRIPTION
-----------
@@ -24,11 +24,11 @@ OPTIONS
URL to include in the summary.
<end>::
- Commit to send at; defaults to HEAD.
+ Commit to end at; defaults to HEAD.
Author
------
-Written by Ryan Anderson <ryan@michonline.com> and Junio C Hamano <junkio@cox.net>
+Written by Ryan Anderson <ryan@michonline.com> and Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -36,4 +36,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt
index a53858e25..64715c17d 100644
--- a/Documentation/git-rerere.txt
+++ b/Documentation/git-rerere.txt
@@ -7,7 +7,7 @@ git-rerere - Reuse recorded resolution of conflicted merges
SYNOPSIS
--------
-'git-rerere' [clear|diff|status|gc]
+'git rerere' ['clear'|'diff'|'status'|'gc']
DESCRIPTION
-----------
@@ -30,26 +30,26 @@ enable this command.
COMMANDS
--------
-Normally, git-rerere is run without arguments or user-intervention.
+Normally, 'git-rerere' is run without arguments or user-intervention.
However, it has several commands that allow it to interact with
its working state.
'clear'::
This resets the metadata used by rerere if a merge resolution is to be
-is aborted. Calling linkgit:git-am[1] --skip or linkgit:git-rebase[1]
-[--skip|--abort] will automatically invoke this command.
+aborted. Calling 'git-am [--skip|--abort]' or 'git-rebase [--skip|--abort]'
+will automatically invoke this command.
'diff'::
This displays diffs for the current state of the resolution. It is
useful for tracking what has changed while the user is resolving
conflicts. Additional arguments are passed directly to the system
-diff(1) command installed in PATH.
+'diff' command installed in PATH.
'status'::
-Like diff, but this only prints the filenames that will be tracked
+Like 'diff', but this only prints the filenames that will be tracked
for resolutions.
'gc'::
@@ -90,15 +90,15 @@ One way to do it is to pull master into the topic branch:
The commits marked with `*` touch the same area in the same
file; you need to resolve the conflicts when creating the commit
-marked with `+`. Then you can test the result to make sure your
+marked with `{plus}`. Then you can test the result to make sure your
work-in-progress still works with what is in the latest master.
After this test merge, there are two ways to continue your work
on the topic. The easiest is to build on top of the test merge
-commit `+`, and when your work in the topic branch is finally
+commit `{plus}`, and when your work in the topic branch is finally
ready, pull the topic branch into master, and/or ask the
upstream to pull from you. By that time, however, the master or
-the upstream might have been advanced since the test merge `+`,
+the upstream might have been advanced since the test merge `{plus}`,
in which case the final commit graph would look like this:
------------
@@ -142,33 +142,33 @@ finally ready and merged into the master branch. This merge
would require you to resolve the conflict, introduced by the
commits marked with `*`. However, often this conflict is the
same conflict you resolved when you created the test merge you
-blew away. `git-rerere` command helps you to resolve this final
+blew away. 'git-rerere' command helps you to resolve this final
conflicted merge using the information from your earlier hand
resolve.
-Running `git-rerere` command immediately after a conflicted
+Running the 'git-rerere' command immediately after a conflicted
automerge records the conflicted working tree files, with the
usual conflict markers `<<<<<<<`, `=======`, and `>>>>>>>` in
them. Later, after you are done resolving the conflicts,
-running `git-rerere` again records the resolved state of these
+running 'git-rerere' again records the resolved state of these
files. Suppose you did this when you created the test merge of
master into the topic branch.
-Next time, running `git-rerere` after seeing a conflicted
+Next time, running 'git-rerere' after seeing a conflicted
automerge, if the conflict is the same as the earlier one
recorded, it is noticed and a three-way merge between the
earlier conflicted automerge, the earlier manual resolution, and
the current conflicted automerge is performed by the command.
If this three-way merge resolves cleanly, the result is written
out to your working tree file, so you would not have to manually
-resolve it. Note that `git-rerere` leaves the index file alone,
+resolve it. Note that 'git-rerere' leaves the index file alone,
so you still need to do the final sanity checks with `git diff`
-(or `git diff -c`) and `git add` when you are satisfied.
+(or `git diff -c`) and 'git-add' when you are satisfied.
-As a convenience measure, `git-merge` automatically invokes
-`git-rerere` when it exits with a failed automerge, which
+As a convenience measure, 'git-merge' automatically invokes
+'git-rerere' when it exits with a failed automerge, which
records it if it is a new conflict, or reuses the earlier hand
-resolve when it is not. `git-commit` also invokes `git-rerere`
+resolve when it is not. 'git-commit' also invokes 'git-rerere'
when recording a merge result. What this means is that you do
not have to do anything special yourself (Note: you still have
to set the config variable rerere.enabled to enable this command).
@@ -178,8 +178,8 @@ resolution is recorded, and it will be reused when you do the
actual merge later with updated master and topic branch, as long
as the earlier resolution is still applicable.
-The information `git-rerere` records is also used when running
-`git-rebase`. After blowing away the test merge and continuing
+The information 'git-rerere' records is also used when running
+'git-rebase'. After blowing away the test merge and continuing
development on the topic branch:
------------
@@ -198,14 +198,14 @@ you could run `git rebase master topic`, to keep yourself
up-to-date even before your topic is ready to be sent upstream.
This would result in falling back to three-way merge, and it
would conflict the same way the test merge you resolved earlier.
-`git-rerere` is run by `git rebase` to help you resolve this
+'git-rerere' is run by 'git-rebase' to help you resolve this
conflict.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index a4e0a779d..6abaeac28 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state
SYNOPSIS
--------
[verse]
-'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]
-'git-reset' [--mixed] [-q] [<commit>] [--] <paths>...
+'git reset' [--mixed | --soft | --hard] [-q] [<commit>]
+'git reset' [-q] [<commit>] [--] <paths>...
DESCRIPTION
-----------
@@ -37,7 +37,7 @@ OPTIONS
--soft::
Does not touch the index file nor the working tree at all, but
requires them to be in a good order. This leaves all your changed
- files "Added but not yet committed", as linkgit:git-status[1] would
+ files "Changes to be committed", as 'git-status' would
put it.
--hard::
@@ -176,9 +176,26 @@ $ git reset <3>
committed as 'snapshot WIP'. This updates the index to show your
WIP files as uncommitted.
+Reset a single file in the index::
++
+Suppose you have added a file to your index, but later decide you do not
+want to add it to your commit. You can remove the file from the index
+while keeping your changes with git reset.
++
+------------
+$ git reset -- frotz.c <1>
+$ git commit -m "Commit files in index" <2>
+$ git add frotz.c <3>
+------------
++
+<1> This removes the file from the index while keeping it in the working
+ directory.
+<2> This commits all other changes in the index.
+<3> Adds the file to the index again.
+
Author
------
-Written by Junio C Hamano <junkio@cox.net> and Linus Torvalds <torvalds@osdl.org>
+Written by Junio C Hamano <gitster@pobox.com> and Linus Torvalds <torvalds@osdl.org>
Documentation
--------------
@@ -186,4 +203,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 5b96eabfc..fd1de92e3 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -20,6 +20,9 @@ SYNOPSIS
[ \--full-history ]
[ \--not ]
[ \--all ]
+ [ \--branches ]
+ [ \--tags ]
+ [ \--remotes ]
[ \--stdin ]
[ \--quiet ]
[ \--topo-order ]
@@ -31,6 +34,7 @@ SYNOPSIS
[ \--(author|committer|grep)=<pattern> ]
[ \--regexp-ignore-case | \-i ]
[ \--extended-regexp | \-E ]
+ [ \--fixed-strings | \-F ]
[ \--date={local|relative|default|iso|rfc|short} ]
[ [\--objects | \--objects-edge] [ \--unpacked ] ]
[ \--pretty | \--header ]
@@ -55,7 +59,7 @@ stop at that point. Their parents are implied. Thus the following
command:
-----------------------------------------------------------------------
- $ git-rev-list foo bar ^baz
+ $ git rev-list foo bar ^baz
-----------------------------------------------------------------------
means "list all the commits which are included in 'foo' and 'bar', but
@@ -66,8 +70,8 @@ short-hand for "{caret}'<commit1>' '<commit2>'". For example, either of
the following may be used interchangeably:
-----------------------------------------------------------------------
- $ git-rev-list origin..HEAD
- $ git-rev-list HEAD ^origin
+ $ git rev-list origin..HEAD
+ $ git rev-list HEAD ^origin
-----------------------------------------------------------------------
Another special notation is "'<commit1>'...'<commit2>'" which is useful
@@ -75,15 +79,15 @@ for merges. The resulting set of commits is the symmetric difference
between the two operands. The following two commands are equivalent:
-----------------------------------------------------------------------
- $ git-rev-list A B --not $(git-merge-base --all A B)
- $ git-rev-list A...B
+ $ git rev-list A B --not $(git merge-base --all A B)
+ $ git rev-list A...B
-----------------------------------------------------------------------
-linkgit:git-rev-list[1] is a very essential git program, since it
+'git-rev-list' is a very essential git program, 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 linkgit:git-bisect[1] and
-linkgit:git-repack[1].
+used by commands as different as 'git-bisect' and
+'git-repack'.
OPTIONS
-------
@@ -105,4 +109,4 @@ and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 5d9c36985..2921da320 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -8,23 +8,23 @@ git-rev-parse - Pick out and massage parameters
SYNOPSIS
--------
-'git-rev-parse' [ --option ] <args>...
+'git rev-parse' [ --option ] <args>...
DESCRIPTION
-----------
Many git porcelainish commands take mixture of flags
(i.e. parameters that begin with a dash '-') and parameters
-meant for underlying `git-rev-list` command they use internally
-and flags and parameters for other commands they use as the
-downstream of `git-rev-list`. This command is used to
+meant for the underlying 'git-rev-list' command they use internally
+and flags and parameters for the other commands they use
+downstream of 'git-rev-list'. This command is used to
distinguish between them.
OPTIONS
-------
--parseopt::
- Use `git-rev-parse` in option parsing mode (see PARSEOPT section below).
+ Use 'git-rev-parse' in option parsing mode (see PARSEOPT section below).
--keep-dash-dash::
Only meaningful in `--parseopt` mode. Tells the option parser to echo
@@ -32,11 +32,11 @@ OPTIONS
--revs-only::
Do not output flags and parameters not meant for
- `git-rev-list` command.
+ 'git-rev-list' command.
--no-revs::
Do not output flags and parameters meant for
- `git-rev-list` command.
+ 'git-rev-list' command.
--flags::
Do not output non-flag parameters.
@@ -52,13 +52,19 @@ OPTIONS
The parameter given must be usable as a single, valid
object name. Otherwise barf and abort.
+-q::
+--quiet::
+ Only meaningful in `--verify` mode. Do not output an error
+ message if the first argument is not a valid object name;
+ instead exit with non-zero status silently.
+
--sq::
Usually the output is made one line per flag and
parameter. This option makes output a single line,
properly quoted for consumption by shell. Useful when
you expect your parameter to contain whitespaces and
newlines (e.g. when using pickaxe `-S` with
- `git-diff-\*`).
+ 'git-diff-\*').
--not::
When showing object names, prefix them with '{caret}' and
@@ -114,18 +120,21 @@ OPTIONS
--is-bare-repository::
When the repository is bare print "true", otherwise "false".
---short, --short=number::
+--short::
+--short=number::
Instead of outputting the full SHA1 values of object names try to
abbreviate them to a shorter unique name. When no length is specified
7 is used. The minimum length is 4.
---since=datestring, --after=datestring::
- Parses the date string, and outputs corresponding
- --max-age= parameter for git-rev-list command.
+--since=datestring::
+--after=datestring::
+ Parse the date string, and output the corresponding
+ --max-age= parameter for 'git-rev-list'.
---until=datestring, --before=datestring::
- Parses the date string, and outputs corresponding
- --min-age= parameter for git-rev-list command.
+--until=datestring::
+--before=datestring::
+ Parse the date string, and output the corresponding
+ --min-age= parameter for 'git-rev-list'.
<args>...::
Flags and parameters to be parsed.
@@ -146,8 +155,9 @@ blobs contained in a commit.
name the same commit object if there are no other object in
your repository whose object name starts with dae86e.
-* An output from `git-describe`; i.e. a closest tag, followed by a
- dash, a `g`, and an abbreviated object name.
+* An output from 'git-describe'; i.e. a closest tag, optionally
+ followed by a dash and a number of commits, followed by a dash, a
+ `g`, and an abbreviated object name.
* A symbolic ref name. E.g. 'master' typically means the commit
object referenced by $GIT_DIR/refs/heads/master. If you
@@ -157,7 +167,7 @@ blobs contained in a commit.
first match in the following rules:
. if `$GIT_DIR/<name>` exists, that is what you mean (this is usually
- useful only for `HEAD`, `FETCH_HEAD` and `MERGE_HEAD`);
+ useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD` and `MERGE_HEAD`);
. otherwise, `$GIT_DIR/refs/<name>` if exists;
@@ -168,6 +178,16 @@ blobs contained in a commit.
. otherwise, `$GIT_DIR/refs/remotes/<name>` if exists;
. otherwise, `$GIT_DIR/refs/remotes/<name>/HEAD` if exists.
++
+HEAD names the commit your changes in the working tree is based on.
+FETCH_HEAD records the branch you fetched from a remote repository
+with your last 'git-fetch' invocation.
+ORIG_HEAD is created by commands that moves your HEAD in a drastic
+way, to record the position of the HEAD before their operation, so that
+you can change the tip of the branch back to the state before you ran
+them easily.
+MERGE_HEAD records the commit(s) you are merging into your branch
+when you run 'git-merge'.
* A ref followed by the suffix '@' with a date specification
enclosed in a brace
@@ -175,7 +195,10 @@ blobs contained in a commit.
second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value
of the ref at a prior point in time. This suffix may only be
used immediately following a ref name and the ref must have an
- existing log ($GIT_DIR/logs/<ref>).
+ existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state
+ of your *local* ref at a given time; e.g., what was in your local
+ `master` branch last week. If you want to look at commits made during
+ certain times, see `--since` and `--until`.
* A ref followed by the suffix '@' with an ordinal specification
enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify
@@ -229,25 +252,27 @@ blobs contained in a commit.
* A colon, optionally followed by a stage number (0 to 3) and a
colon, followed by a path; this names a blob object in the
index at the given path. Missing stage number (and the colon
- that follows it) names an stage 0 entry. During a merge, stage
+ that follows it) names a stage 0 entry. During a merge, stage
1 is the common ancestor, stage 2 is the target branch's version
(typically the current branch), and stage 3 is the version from
the branch being merged.
-Here is an illustration, by Jon Loeliger. Both node B and C are
-a commit parents of commit node A. Parent commits are ordered
+Here is an illustration, by Jon Loeliger. Both commit nodes B
+and C are parents of commit node A. Parent commits are ordered
left-to-right.
- G H I J
- \ / \ /
- D E F
- \ | / \
- \ | / |
- \|/ |
- B C
- \ /
- \ /
- A
+........................................
+G H I J
+ \ / \ /
+ D E F
+ \ | / \
+ \ | / |
+ \|/ |
+ B C
+ \ /
+ \ /
+ A
+........................................
A = = A^0
B = A^ = A^1 = A~1
@@ -264,7 +289,7 @@ left-to-right.
SPECIFYING RANGES
-----------------
-History traversing commands such as `git-log` operate on a set
+History traversing commands such as 'git-log' operate on a set
of commits, not just a single commit. To these commands,
specifying a single revision with the notation described in the
previous section means the set of commits reachable from that
@@ -275,23 +300,23 @@ notation is used. E.g. "`{caret}r1 r2`" means commits reachable
from `r2` but exclude the ones reachable from `r1`.
This set operation appears so often that there is a shorthand
-for it. "`r1..r2`" is equivalent to "`{caret}r1 r2`". It is
-the difference of two sets (subtract the set of commits
-reachable from `r1` from the set of commits reachable from
-`r2`).
+for it. When you have two commits `r1` and `r2` (named according
+to the syntax explained in SPECIFYING REVISIONS above), you can ask
+for commits that are reachable from r2 excluding those that are reachable
+from r1 by "`{caret}r1 r2`" and it can be written as "`r1..r2`".
A similar notation "`r1\...r2`" is called symmetric difference
of `r1` and `r2` and is defined as
-"`r1 r2 --not $(git-merge-base --all r1 r2)`".
+"`r1 r2 --not $(git merge-base --all r1 r2)`".
It is the set of commits that are reachable from either one of
`r1` or `r2` but not from both.
Two other shorthands for naming a set that is formed by a commit
-and its parent commits exists. `r1{caret}@` notation means all
+and its parent commits exist. The `r1{caret}@` notation means all
parents of `r1`. `r1{caret}!` includes commit `r1` but excludes
-its all parents.
+all of its parents.
-Here are a handful examples:
+Here are a handful of examples:
D G H D
D F G H I J D F
@@ -305,7 +330,7 @@ Here are a handful examples:
PARSEOPT
--------
-In `--parseopt` mode, `git-rev-parse` helps massaging options to bring to shell
+In `--parseopt` mode, 'git-rev-parse' helps massaging options to bring to shell
scripts the same facilities C builtins have. It works as an option normalizer
(e.g. splits single switches aggregate values), a bit like `getopt(1)` does.
@@ -317,7 +342,7 @@ usage on the standard error stream, and exits with code 129.
Input Format
~~~~~~~~~~~~
-`git-rev-parse --parseopt` input format is fully text based. It has two parts,
+'git-rev-parse --parseopt' input format is fully text based. It has two parts,
separated by a line that contains only `--`. The lines before the separator
(should be more than one) are used for the usage.
The lines after the separator describe the options.
@@ -325,7 +350,7 @@ The lines after the separator describe the options.
Each line of options has this format:
------------
-<opt_spec><arg_spec>? SP+ help LF
+<opt_spec><flags>* SP+ help LF
------------
`<opt_spec>`::
@@ -334,10 +359,17 @@ Each line of options has this format:
is necessary. `h,help`, `dry-run` and `f` are all three correct
`<opt_spec>`.
-`<arg_spec>`::
- an `<arg_spec>` tells the option parser if the option has an argument
- (`=`), an optional one (`?` though its use is discouraged) or none
- (no `<arg_spec>` in that case).
+`<flags>`::
+ `<flags>` are of `*`, `=`, `?` or `!`.
+ * Use `=` if the option takes an argument.
+
+ * Use `?` to mean that the option is optional (though its use is discouraged).
+
+ * Use `*` to mean that this option should not be listed in the usage
+ generated for the `-h` argument. It's shown for `--help-all` as
+ documented in linkgit:gitcli[7].
+
+ * Use `!` to not make the corresponding negated long option available.
The remainder of the line, after stripping the spaces, is used
as the help associated to the option.
@@ -363,14 +395,39 @@ bar= some cool option --bar with an argument
An option group Header
C? option C with an optional argument"
-eval `echo "$OPTS_SPEC" | git-rev-parse --parseopt -- "$@" || echo exit $?`
+eval `echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?`
+------------
+
+EXAMPLES
+--------
+
+* Print the object name of the current commit:
++
+------------
+$ git rev-parse --verify HEAD
+------------
+
+* Print the commit object name from the revision in the $REV shell variable:
++
+------------
+$ git rev-parse --verify $REV
+------------
++
+This will error out if $REV is empty or not a valid revision.
+
+* Same as above:
++
+------------
+$ git rev-parse --default master --verify $REV
------------
++
+but if $REV is empty, the commit object name from master will be printed.
Author
------
Written by Linus Torvalds <torvalds@osdl.org> .
-Junio C Hamano <junkio@cox.net> and Pierre Habouzit <madcoder@debian.org>
+Junio C Hamano <gitster@pobox.com> and Pierre Habouzit <madcoder@debian.org>
Documentation
--------------
@@ -378,4 +435,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 93e20f775..98cfa3c0d 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -7,7 +7,7 @@ git-revert - Revert an existing commit
SYNOPSIS
--------
-'git-revert' [--edit | --no-edit] [-n] [-m parent-number] <commit>
+'git revert' [--edit | --no-edit] [-n] [-m parent-number] [-s] <commit>
DESCRIPTION
-----------
@@ -22,12 +22,14 @@ OPTIONS
For a more complete list of ways to spell commit names, see
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
--e|--edit::
- With this option, `git-revert` will let you edit the commit
+-e::
+--edit::
+ With this option, 'git-revert' will let you edit the commit
message prior to committing the revert. This is the default if
you run the command from a terminal.
--m parent-number|--mainline parent-number::
+-m parent-number::
+--mainline parent-number::
Usually you cannot revert a merge because you do not know which
side of the merge should be considered the mainline. This
option specifies the parent number (starting from 1) of
@@ -35,26 +37,31 @@ OPTIONS
relative to the specified parent.
--no-edit::
- With this option, `git-revert` will not start the commit
+ With this option, 'git-revert' will not start the commit
message editor.
--n|--no-commit::
+-n::
+--no-commit::
Usually the command automatically creates a commit with
- a commit log message stating which commit was reverted.
- This flag applies the change necessary to revert the
- named commit to your working tree, but does not make the
- commit. In addition, when this option is used, your
- working tree does not have to match the HEAD commit.
- The revert is done against the beginning state of your
- working tree.
+ a commit log message stating which commit was
+ reverted. This flag applies the change necessary
+ to revert the named commit to your working tree
+ and the index, but does not make the commit. In addition,
+ when this option is used, your index does not have to match
+ the HEAD commit. The revert is done against the
+ beginning state of your index.
+
This is useful when reverting more than one commits'
-effect to your working tree in a row.
+effect to your index in a row.
+
+-s::
+--signoff::
+ Add Signed-off-by line at the end of the commit message.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -62,4 +69,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
index dc36c662a..5afb1e742 100644
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
@@ -7,32 +7,43 @@ git-rm - Remove files from the working tree and from the index
SYNOPSIS
--------
-'git-rm' [-f] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>...
+'git rm' [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>...
DESCRIPTION
-----------
-Remove files from the working tree and from the index. The
-files have to be identical to the tip of the branch, and no
-updates to its contents must have been placed in the staging
-area (aka index). When --cached is given, the staged content has to
-match either the tip of the branch *or* the file on disk.
+Remove files from the index, or from the working tree and the index.
+'git-rm' will not remove a file from just your working directory.
+(There is no option to remove a file only from the work tree
+and yet keep it in the index; use `/bin/rm` if you want to do that.)
+The files being removed have to be identical to the tip of the branch,
+and no updates to their contents can be staged in the index,
+though that default behavior can be overridden with the `-f` option.
+When '--cached' is given, the staged content has to
+match either the tip of the branch or the file on disk,
+allowing the file to be removed from just the index.
OPTIONS
-------
<file>...::
Files to remove. Fileglobs (e.g. `*.c`) can be given to
- remove all matching files. Also a leading directory name
- (e.g. `dir` to add `dir/file1` and `dir/file2`) can be
- given to remove all files in the directory, recursively,
- but this requires `-r` option to be given for safety.
+ 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
+ given to remove all files in the directory, and recursively
+ all sub-directories,
+ but this requires the `-r` option to be explicitly given.
-f::
+--force::
Override the up-to-date check.
--n, \--dry-run::
- Don't actually remove the file(s), just show if they exist in
- the index.
+-n::
+--dry-run::
+ Don't actually remove any file(s). Instead, just show
+ if they exist in the index and would otherwise be removed
+ by the command.
-r::
Allow recursive removal when a leading directory name is
@@ -43,45 +54,49 @@ OPTIONS
the list of files, (useful when filenames might be mistaken
for command-line options).
-\--cached::
- This option can be used to tell the command to remove
- the paths only from the index, leaving working tree
- files.
+--cached::
+ Use this option to unstage and remove paths only from the index.
+ Working tree files, whether modified or not, will be
+ left alone.
-\--ignore-unmatch::
+--ignore-unmatch::
Exit with a zero status even if no files matched.
--q, \--quiet::
- git-rm normally outputs one line (in the form of an "rm" command)
+-q::
+--quiet::
+ 'git-rm' normally outputs one line (in the form of an "rm" command)
for each file removed. This option suppresses that output.
DISCUSSION
----------
-The list of <file> given to the command can be exact pathnames,
-file glob patterns, or leading directory name. The command
-removes only the paths that is known to git. Giving the name of
+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.
+File globbing matches across directory boundaries. Thus, given
+two directories `d` and `d2`, there is a difference between
+using `git rm \'d\*\'` and `git rm \'d/\*\'`, as the former will
+also remove all of directory `d2`.
EXAMPLES
--------
-git-rm Documentation/\\*.txt::
+git rm Documentation/\\*.txt::
Removes all `\*.txt` files from the index that are under the
`Documentation` directory and any of its subdirectories.
+
Note that the asterisk `\*` is quoted from the shell in this
-example; this lets the command include the files from
-subdirectories of `Documentation/` directory.
+example; this lets git, and not the shell, expand the pathnames
+of files and subdirectories under the `Documentation/` directory.
-git-rm -f git-*.sh::
- Remove all git-*.sh scripts that are in the index.
+git rm -f git-*.sh::
Because this example lets the shell expand the asterisk
(i.e. you are listing the files explicitly), it
does not remove `subdir/git-foo.sh`.
-See Also
+SEE ALSO
--------
linkgit:git-add[1]
@@ -95,4 +110,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 4b8ec8a20..e2437f30c 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -8,7 +8,7 @@ git-send-email - Send a collection of patches as emails
SYNOPSIS
--------
-'git-send-email' [options] <file|directory> [... file|directory]
+'git send-email' [options] <file|directory> [... file|directory]
@@ -40,7 +40,8 @@ The --cc option must be repeated for each user you want on the cc list.
Output of this command must be single email address per line.
Default is the value of 'sendemail.cccmd' configuration value.
---chain-reply-to, --no-chain-reply-to::
+--chain-reply-to::
+--no-chain-reply-to::
If this is set, each email will be sent as a reply to the previous
email sent. If disabled with "--no-chain-reply-to", all emails after
the first will be sent as replies to the first email sent. When using
@@ -55,7 +56,7 @@ The --cc option must be repeated for each user you want on the cc list.
--from::
Specify the sender of the emails. This will default to
- the value GIT_COMMITTER_IDENT, as returned by "git-var -l".
+ the value GIT_COMMITTER_IDENT, as returned by "git var -l".
The user will still be prompted to confirm this entry.
--in-reply-to::
@@ -65,7 +66,8 @@ The --cc option must be repeated for each user you want on the cc list.
Only necessary if --compose is also set. If --compose
is not set, this will be prompted for.
---signed-off-by-cc, --no-signed-off-by-cc::
+--signed-off-by-cc::
+--no-signed-off-by-cc::
If this is set, add emails found in Signed-off-by: or Cc: lines to the
cc list.
Default is the value of 'sendemail.signedoffcc' configuration value;
@@ -96,28 +98,73 @@ The --cc option must be repeated for each user you want on the cc list.
servers typically listen to smtp port 25 and ssmtp port
465).
---smtp-user, --smtp-pass::
- Username and password for SMTP-AUTH. Defaults are the values of
- the configuration values 'sendemail.smtpuser' and
- 'sendemail.smtppass', but see also 'sendemail.identity'.
- If not set, authentication is not attempted.
+--smtp-user::
+ Username for SMTP-AUTH. In place of this option, the following
+ configuration variables can be specified:
++
+--
+ * sendemail.smtpuser
+ * sendemail.<identity>.smtpuser (see sendemail.identity).
+--
++
+However, --smtp-user always overrides these variables.
++
+If a username is not specified (with --smtp-user or a
+configuration variable), then authentication is not attempted.
+
+--smtp-pass::
+ Password for SMTP-AUTH. The argument is optional: If no
+ argument is specified, then the empty string is used as
+ the password.
++
+In place of this option, the following configuration variables
+can be specified:
++
+--
+ * sendemail.smtppass
+ * sendemail.<identity>.smtppass (see sendemail.identity).
+--
++
+However, --smtp-pass always overrides these variables.
++
+Furthermore, passwords need not be specified in configuration files
+or on the command line. If a username has been specified (with
+--smtp-user or a configuration variable), but no password has been
+specified (with --smtp-pass or a configuration variable), then the
+user is prompted for a password while the input is masked for privacy.
+
+--smtp-encryption::
+ Specify the encryption to use, either 'ssl' or 'tls'. Any other
+ value reverts to plain SMTP. Default is the value of
+ 'sendemail.smtpencryption'.
--smtp-ssl::
- If set, connects to the SMTP server using SSL.
- Default is the value of the 'sendemail.smtpssl' configuration value;
- if that is unspecified, does not use SSL.
+ Legacy alias for '--smtp-encryption=ssl'.
--subject::
Specify the initial subject of the email thread.
Only necessary if --compose is also set. If --compose
is not set, this will be prompted for.
---suppress-from, --no-suppress-from::
+--suppress-from::
+--no-suppress-from::
If this is set, do not add the From: address to the cc: list.
Default is the value of 'sendemail.suppressfrom' configuration value;
if that is unspecified, default to --no-suppress-from.
---thread, --no-thread::
+--suppress-cc::
+ Specify an additional category of recipients to suppress the
+ auto-cc of. 'self' will avoid including the sender, 'author' will
+ avoid including the patch author, 'cc' will avoid including anyone
+ mentioned in Cc lines in the patch, 'sob' will avoid including
+ anyone mentioned in Signed-off-by lines, and 'cccmd' will avoid
+ running the --cc-cmd. 'all' will suppress all auto cc values.
+ Default is the value of 'sendemail.suppresscc' configuration value;
+ if that is unspecified, default to 'self' if --suppress-from is
+ specified, as well as 'sob' if --no-signed-off-cc is specified.
+
+--thread::
+--no-thread::
If this is set, the In-Reply-To header will be set on each email sent.
If disabled with "--no-thread", no emails will have the In-Reply-To
header set.
@@ -137,6 +184,8 @@ The --cc option must be repeated for each user you want on the cc list.
Specify the primary recipient of the emails generated.
Generally, this will be the upstream maintainer of the
project involved.
+ Default is the value of the 'sendemail.to' configuration value;
+ if that is unspecified, this will be prompted for.
+
The --to option must be repeated for each user you want on the to list.
@@ -174,14 +223,22 @@ sendemail.chainreplyto::
sendemail.smtpserver::
Default SMTP server to use.
+sendemail.smtpserverport::
+ Default SMTP server port to use.
+
sendemail.smtpuser::
Default SMTP-AUTH username.
sendemail.smtppass::
Default SMTP-AUTH password.
+sendemail.smtpencryption::
+ Default encryption method. Use 'ssl' for SSL (and specify an
+ appropriate port), or 'tls' for TLS. Takes precedence over
+ 'smtpssl' if both are specified.
+
sendemail.smtpssl::
- Boolean value specifying the default to the '--smtp-ssl' parameter.
+ Legacy boolean that sets 'smtpencryption=ssl' if enabled.
Author
------
@@ -196,4 +253,4 @@ Documentation by Ryan Anderson
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
index 777515b12..399821832 100644
--- a/Documentation/git-send-pack.txt
+++ b/Documentation/git-send-pack.txt
@@ -8,12 +8,12 @@ git-send-pack - Push objects over git protocol to another repository
SYNOPSIS
--------
-'git-send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
+'git send-pack' [--all] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
DESCRIPTION
-----------
-Usually you would want to use linkgit:git-push[1] which is a
-higher level wrapper of this command instead.
+Usually you would want to use 'git-push', which is a
+higher-level wrapper of this command, instead. See linkgit:git-push[1].
Invokes 'git-receive-pack' on a possibly remote repository, and
updates it from the current repository, sending named refs.
@@ -21,33 +21,33 @@ updates it from the current repository, sending named refs.
OPTIONS
-------
-\--receive-pack=<git-receive-pack>::
+--receive-pack=<git-receive-pack>::
Path to the 'git-receive-pack' program on the remote
end. Sometimes useful when pushing to a remote
repository over ssh, and you do not have the program in
a directory on the default $PATH.
-\--exec=<git-receive-pack>::
+--exec=<git-receive-pack>::
Same as \--receive-pack=<git-receive-pack>.
-\--all::
+--all::
Instead of explicitly specifying which refs to update,
update all heads that locally exist.
-\--dry-run::
+--dry-run::
Do everything except actually send the updates.
-\--force::
+--force::
Usually, the command refuses to update a remote ref that
is not an ancestor of the local ref used to overwrite it.
This flag disables the check. What this means is that
the remote repository can lose commits; use it with
care.
-\--verbose::
+--verbose::
Run verbosely.
-\--thin::
+--thin::
Spend extra cycles to minimize the number of objects to be sent.
Use it on slower connection.
@@ -86,8 +86,8 @@ and the destination side (after the colon). The ref to be
pushed is determined by finding a match that matches the source
side, and where it is pushed is determined by using the
destination side. The rules used to match a ref are the same
-rules used by linkgit:git-rev-parse[1] to resolve a symbolic ref
-name.
+rules used by 'git-rev-parse' to resolve a symbolic ref
+name. See linkgit:git-rev-parse[1].
- It is an error if <src> does not match exactly one of the
local refs.
@@ -125,4 +125,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index 16b8b7514..18f14b5be 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -7,7 +7,7 @@ git-sh-setup - Common git shell script setup code
SYNOPSIS
--------
-'git-sh-setup'
+'. "$(git --exec-path)/git-sh-setup"'
DESCRIPTION
-----------
@@ -16,7 +16,7 @@ This is not a command the end user would want to run. Ever.
This documentation is meant for people who are studying the
Porcelain-ish scripts and/or are writing new ones.
-The `git-sh-setup` scriptlet is designed to be sourced (using
+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.
@@ -77,4 +77,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt
index bc031e0cc..ff420f8f8 100644
--- a/Documentation/git-shell.txt
+++ b/Documentation/git-shell.txt
@@ -8,7 +8,7 @@ git-shell - Restricted login shell for GIT-only SSH access
SYNOPSIS
--------
-'git-shell' -c <command> <argument>
+'$(git --exec-path)/git-shell' -c <command> <argument>
DESCRIPTION
-----------
@@ -18,7 +18,7 @@ of server-side GIT commands implementing the pull/push functionality.
The commands can be executed only by the '-c' option; the shell is not
interactive.
-Currently, only the `git-receive-pack` and `git-upload-pack` commands
+Currently, only the 'git-receive-pack' and 'git-upload-pack' commands
are permitted to be called, with a single required argument.
Author
@@ -31,4 +31,4 @@ Documentation by Petr Baudis and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index c7752575d..7ccf31ccc 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -3,17 +3,17 @@ git-shortlog(1)
NAME
----
-git-shortlog - Summarize 'git log' output
+git-shortlog - Summarize 'git-log' output
SYNOPSIS
--------
[verse]
-git-log --pretty=short | 'git-shortlog' [-h] [-n] [-s] [-e]
-git-shortlog [-n|--numbered] [-s|--summary] [-e|--email] [<committish>...]
+git log --pretty=short | 'git shortlog' [-h] [-n] [-s] [-e] [-w]
+git shortlog [-n|--numbered] [-s|--summary] [-e|--email] [-w[<width>[,<indent1>[,<indent2>]]]] [<committish>...]
DESCRIPTION
-----------
-Summarizes 'git log' output in a format suitable for inclusion
+Summarizes 'git-log' output in a format suitable for inclusion
in release announcements. Each commit will be grouped by author and
the first line of the commit message will be shown.
@@ -22,19 +22,29 @@ Additionally, "[PATCH]" will be stripped from the commit description.
OPTIONS
-------
--h, \--help::
+-h::
+--help::
Print a short usage message and exit.
--n, \--numbered::
+-n::
+--numbered::
Sort output according to the number of commits per author instead
of author alphabetic order.
--s, \--summary::
+-s::
+--summary::
Suppress commit description and provide a commit count summary only.
--e, \--email::
+-e::
+--email::
Show the email address of each author.
+-w[<width>[,<indent1>[,<indent2>]]]::
+ Linewrap the output by wrapping each line at `width`. The first
+ line of each entry is indented by `indent1` spaces, and the second
+ and subsequent lines are indented by `indent2` spaces. `width`,
+ `indent1`, and `indent2` default to 76, 6 and 9 respectively.
+
FILES
-----
@@ -59,4 +69,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index 0bb8250b2..d3f258869 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -8,10 +8,10 @@ git-show-branch - Show branches and their commits
SYNOPSIS
--------
[verse]
-'git-show-branch' [--all] [--remotes] [--topo-order] [--current]
+'git show-branch' [--all] [--remotes] [--topo-order] [--current]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
-'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
+'git show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
DESCRIPTION
-----------
@@ -29,7 +29,7 @@ no <rev> nor <glob> is given on the command line.
OPTIONS
-------
<rev>::
- Arbitrary extended SHA1 expression (see `git-rev-parse`)
+ Arbitrary extended SHA1 expression (see linkgit:git-rev-parse[1])
that typically names a branch HEAD or a tag.
<glob>::
@@ -38,10 +38,12 @@ OPTIONS
branches under $GIT_DIR/refs/heads/topic, giving
`topic/*` would show all of them.
--r|--remotes::
+-r::
+--remotes::
Show the remote-tracking branches.
--a|--all::
+-a::
+--all::
Show both remote-tracking branches and local branches.
--current::
@@ -180,7 +182,7 @@ topologically related with each other.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
@@ -190,4 +192,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-show-index.txt b/Documentation/git-show-index.txt
index 535a88464..e3285aacf 100644
--- a/Documentation/git-show-index.txt
+++ b/Documentation/git-show-index.txt
@@ -8,13 +8,13 @@ git-show-index - Show packed archive index
SYNOPSIS
--------
-'git-show-index' < idx-file
+'git show-index' < idx-file
DESCRIPTION
-----------
Reads given idx file for packed git archive created with
-git-pack-objects command, and dumps its contents.
+'git-pack-objects' command, and dumps its contents.
The information it outputs is subset of what you can get from
'git-verify-pack -v'; this command only shows the packfile
@@ -31,4 +31,4 @@ Documentation by Junio C Hamano
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-show-ref.txt b/Documentation/git-show-ref.txt
index ce0e643fb..2f173fff3 100644
--- a/Documentation/git-show-ref.txt
+++ b/Documentation/git-show-ref.txt
@@ -8,9 +8,9 @@ git-show-ref - List references in a local repository
SYNOPSIS
--------
[verse]
-'git-show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
+'git show-ref' [-q|--quiet] [--verify] [-h|--head] [-d|--dereference]
[-s|--hash] [--abbrev] [--tags] [--heads] [--] <pattern>...
-'git-show-ref' --exclude-existing[=pattern]
+'git show-ref' --exclude-existing[=pattern]
DESCRIPTION
-----------
@@ -29,22 +29,26 @@ in the `.git` directory.
OPTIONS
-------
--h, --head::
+-h::
+--head::
Show the HEAD reference.
---tags, --heads::
+--tags::
+--heads::
Limit to only "refs/heads" and "refs/tags", respectively. These
options are not mutually exclusive; when given both, references stored
in "refs/heads" and "refs/tags" are displayed.
--d, --dereference::
+-d::
+--dereference::
Dereference tags into object IDs as well. They will be shown with "^{}"
appended.
--s, --hash::
+-s::
+--hash::
Only show the SHA1 hash, not the reference name. When also using
--dereference the dereferenced tag will still be shown after the SHA1.
@@ -55,19 +59,22 @@ OPTIONS
Aside from returning an error code of 1, it will also print an error
message if '--quiet' was not specified.
---abbrev, --abbrev=len::
+--abbrev::
+--abbrev=len::
Abbreviate the object name. When using `--hash`, you do
not have to say `--hash --abbrev`; `--hash=len` would do.
--q, --quiet::
+-q::
+--quiet::
Do not print any results to stdout. When combined with '--verify' this
can be used to silently check if a reference exists.
---exclude-existing, --exclude-existing=pattern::
+--exclude-existing::
+--exclude-existing=pattern::
- Make git-show-ref act as a filter that reads refs from stdin of the
+ Make 'git-show-ref' act as a filter that reads refs from stdin of the
form "^(?:<anything>\s)?<refname>(?:\^\{\})?$" and performs the
following actions on each:
(1) strip "^{}" at the end of line if any;
@@ -77,7 +84,7 @@ OPTIONS
(5) otherwise output the line.
-<pattern>::
+<pattern>...::
Show references matching one or more patterns.
@@ -130,14 +137,14 @@ When using the '--verify' flag, the command requires an exact path:
will only match the exact branch called "master".
-If nothing matches, linkgit:git-show-ref[1] will return an error code of 1,
+If nothing matches, 'git-show-ref' will return an error code of 1,
and in the case of verification, it will show an error message.
For scripting, you can ask it to be quiet with the "--quiet" flag, which
allows you to do things like
-----------------------------------------------------------------------------
- git-show-ref --quiet --verify -- "refs/heads/$headname" ||
+ git show-ref --quiet --verify -- "refs/heads/$headname" ||
echo "$headname is not a valid branch"
-----------------------------------------------------------------------------
@@ -169,4 +176,4 @@ Man page by Jonas Fonseca <fonseca@diku.dk>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
index dccf0e20e..48b612e2a 100644
--- a/Documentation/git-show.txt
+++ b/Documentation/git-show.txt
@@ -8,7 +8,7 @@ git-show - Show various types of objects
SYNOPSIS
--------
-'git-show' [options] <object>...
+'git show' [options] <object>...
DESCRIPTION
-----------
@@ -20,12 +20,12 @@ presents the merge commit in a special format as produced by
For tags, it shows the tag message and the referenced objects.
-For trees, it shows the names (equivalent to linkgit:git-ls-tree[1]
+For trees, it shows the names (equivalent to 'git-ls-tree'
with \--name-only).
For plain blobs, it shows the plain contents.
-The command takes options applicable to the linkgit:git-diff-tree[1] command to
+The command takes options applicable to the 'git-diff-tree' command to
control how the changes the commit introduces are shown.
This manual page describes only the most frequently used options.
@@ -33,8 +33,8 @@ This manual page describes only the most frequently used options.
OPTIONS
-------
-<object>::
- The name of the object to show.
+<object>...::
+ The names of objects to show.
For a more complete list of ways to spell object names, see
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
@@ -71,7 +71,7 @@ include::i18n.txt[]
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>. Significantly enhanced by
+Junio C Hamano <gitster@pobox.com>. Significantly enhanced by
Johannes Schindelin <Johannes.Schindelin@gmx.de>.
@@ -79,8 +79,6 @@ Documentation
-------------
Documentation by David Greaves, Petr Baudis and the git-list <git@vger.kernel.org>.
-This manual page is a stub. You can help the git documentation by expanding it.
-
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index 9889806a5..49e2296a2 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -8,22 +8,27 @@ git-stash - Stash the changes in a dirty working directory away
SYNOPSIS
--------
[verse]
-'git-stash' (list | show [<stash>] | apply [<stash>] | clear)
-'git-stash' [save] [message...]
+'git stash' list [<options>]
+'git stash' (show | drop | pop ) [<stash>]
+'git stash' apply [--index] [<stash>]
+'git stash' branch <branchname> [<stash>]
+'git stash' [save [--keep-index] [<message>]]
+'git stash' clear
+'git stash' create
DESCRIPTION
-----------
-Use 'git-stash' when you want to record the current state of the
+Use 'git stash' when you want to record the current state of the
working directory and the index, but want to go back to a clean
working directory. The command saves your local modifications away
and reverts the working directory to match the `HEAD` commit.
The modifications stashed away by this command can be listed with
-`git-stash list`, inspected with `git-stash show`, and restored
-(potentially on top of a different commit) with `git-stash apply`.
-Calling git-stash without any arguments is equivalent to `git-stash
-save`. A stash is by default listed as "WIP on 'branchname' ...", but
+`git stash list`, inspected with `git stash show`, and restored
+(potentially on top of a different commit) with `git stash apply`.
+Calling `git stash` without any arguments is equivalent to `git stash save`.
+A stash is by default listed as "WIP on 'branchname' ...", but
you can give a more descriptive message on the command line when
you create one.
@@ -36,13 +41,17 @@ is also possible).
OPTIONS
-------
-save::
+save [--keep-index] [<message>]::
- Save your local modifications to a new 'stash', and run `git-reset
+ Save your local modifications to a new 'stash', and run `git reset
--hard` to revert them. This is the default action when no
- subcommand is given.
+ subcommand is given. The <message> part is optional and gives
+ the description along with the stashed state.
++
+If the `--keep-index` option is used, all changes already added to the
+index are left intact.
-list::
+list [<options>]::
List the stashes that you currently have. Each 'stash' is listed
with its name (e.g. `stash@\{0}` is the latest stash, `stash@\{1}` is
@@ -54,13 +63,16 @@ list::
stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
stash@{1}: On master: 9cc0589... Add git-stash
----------------------------------------------------------------
++
+The command takes options applicable to the 'git-log'
+command to control what is shown and how. See linkgit:git-log[1].
show [<stash>]::
Show the changes recorded in the stash as a diff between the
stashed state and its original parent. When no `<stash>` is given,
shows the latest one. By default, the command shows the diffstat, but
- it will accept any format known to `git-diff` (e.g., `git-stash show
+ it will accept any format known to 'git-diff' (e.g., `git stash show
-p stash@\{1}` to view the second most recent stash in patch form).
apply [--index] [<stash>]::
@@ -77,10 +89,40 @@ tree's changes, but also the index's ones. However, this can fail, when you
have conflicts (which are stored in the index, where you therefore can no
longer apply the changes as they were originally).
+branch <branchname> [<stash>]::
+
+ Creates and checks out a new branch named `<branchname>` starting from
+ the commit at which the `<stash>` was originally created, applies the
+ changes recorded in `<stash>` to the new working tree and index, then
+ drops the `<stash>` if that completes successfully. When no `<stash>`
+ is given, applies the latest one.
++
+This is useful if the branch on which you ran `git stash save` has
+changed enough that `git stash apply` fails due to conflicts. Since
+the stash is applied on top of the commit that was HEAD at the time
+`git stash` was run, it restores the originally stashed state with
+no conflicts.
+
clear::
Remove all the stashed states. Note that those states will then
be subject to pruning, and may be difficult or impossible to recover.
+drop [<stash>]::
+
+ Remove a single stashed state from the stash list. When no `<stash>`
+ is given, it removes the latest one. i.e. `stash@\{0}`
+
+pop [<stash>]::
+
+ Remove a single stashed state from the stash list and apply on top
+ of the current working tree state. When no `<stash>` is given,
+ `stash@\{0}` is assumed. See also `apply`.
+
+create::
+
+ Create a stash (which is a regular commit object) and return its
+ object name, without storing it anywhere in the ref namespace.
+
DISCUSSION
----------
@@ -143,7 +185,7 @@ $ git reset --soft HEAD^
... continue hacking ...
----------------------------------------------------------------
+
-You can use `git-stash` to simplify the above, like this:
+You can use 'git-stash' to simplify the above, like this:
+
----------------------------------------------------------------
... hack hack hack ...
@@ -154,6 +196,24 @@ $ git stash apply
... continue hacking ...
----------------------------------------------------------------
+Testing partial commits::
+
+You can use `git stash save --keep-index` when you want to make two or
+more commits out of the changes in the work tree, and you want to test
+each change before committing:
++
+----------------------------------------------------------------
+... hack hack hack ...
+$ git add --patch foo # add just first part to the index
+$ git stash save --keep-index # save all other changes to the stash
+$ edit/build/test first part
+$ git commit foo -m 'First part' # commit fully tested change
+$ git stash pop # prepare to work on all other changes
+... repeat above five steps until one commit remains ...
+$ edit/build/test remaining parts
+$ git commit foo -m 'Remaining parts'
+----------------------------------------------------------------
+
SEE ALSO
--------
linkgit:git-checkout[1],
@@ -167,4 +227,4 @@ Written by Nanako Shiraishi <nanako3@bluebottle.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index 3ea269aa7..84f60f340 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -8,7 +8,7 @@ git-status - Show the working tree status
SYNOPSIS
--------
-'git-status' <options>...
+'git status' <options>...
DESCRIPTION
-----------
@@ -17,16 +17,16 @@ 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
are what you _would_ commit by running `git commit`; the second and
-third are what you _could_ commit by running `git add` before running
+third are what you _could_ commit by running 'git-add' before running
`git commit`.
-The command takes the same set of options as `git-commit`; it
+The command takes the same set of options as 'git-commit'; it
shows what would be committed if the same options are given to
-`git-commit`.
+'git-commit'.
If there is no path that is different between the index file and
the current HEAD commit (i.e., there is nothing to commit by running
-`git-commit`), the command exits with non-zero status.
+`git commit`), the command exits with non-zero status.
OUTPUT
@@ -52,14 +52,19 @@ If the config variable `status.relativePaths` is set to false, then all
paths shown are relative to the repository root, not to the current
directory.
-See Also
+If `status.submodulesummary` is set to a non zero number or true (identical
+to -1 or an unlimited number), the submodule summary will be enabled and a
+summary of commits for modified submodules will be shown (see --summary-limit
+option of linkgit:git-submodule[1]).
+
+SEE ALSO
--------
linkgit:gitignore[5]
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>.
+Junio C Hamano <gitster@pobox.com>.
Documentation
--------------
@@ -67,4 +72,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-stripspace.txt b/Documentation/git-stripspace.txt
index fc5687502..7508c0e42 100644
--- a/Documentation/git-stripspace.txt
+++ b/Documentation/git-stripspace.txt
@@ -8,7 +8,7 @@ git-stripspace - Filter out empty lines
SYNOPSIS
--------
-'git-stripspace' [-s | --strip-comments] < <stream>
+'git stripspace' [-s | --strip-comments] < <stream>
DESCRIPTION
-----------
@@ -16,7 +16,8 @@ Remove multiple empty lines, and empty lines at beginning and end.
OPTIONS
-------
--s|--strip-comments::
+-s::
+--strip-comments::
In addition to empty lines, also strip lines starting with '#'.
<stream>::
@@ -32,4 +33,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index cffc6d48f..bf33b0cba 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -9,59 +9,147 @@ git-submodule - Initialize, update or inspect submodules
SYNOPSIS
--------
[verse]
-'git-submodule' [--quiet] [-b branch] add <repository> [<path>]
-'git-submodule' [--quiet] [--cached] [status|init|update] [--] [<path>...]
+'git submodule' [--quiet] add [-b branch] [--] <repository> <path>
+'git submodule' [--quiet] status [--cached] [--] [<path>...]
+'git submodule' [--quiet] init [--] [<path>...]
+'git submodule' [--quiet] update [--init] [--] [<path>...]
+'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
+
+
+DESCRIPTION
+-----------
+Submodules allow foreign repositories to be embedded within
+a dedicated subdirectory of the source tree, always pointed
+at a particular commit.
+
+They are not to be confused with remotes, which are meant mainly
+for branches of the same project; submodules are meant for
+different projects you would like to make part of your source tree,
+while the history of the two projects still stays completely
+independent and you cannot modify the contents of the submodule
+from within the main project.
+If you want to merge the project histories and want to treat the
+aggregated whole as a single project from then on, you may want to
+add a remote for the other project and use the 'subtree' merge strategy,
+instead of treating the other project as a submodule. Directories
+that come from both projects can be cloned and checked out as a whole
+if you choose to go that route.
+
+Submodules are composed from a so-called `gitlink` tree entry
+in the main repository that refers to a particular commit object
+within the inner repository that is completely separate.
+A record in the `.gitmodules` file at the root of the source
+tree assigns a logical name to the submodule and describes
+the default URL the submodule shall be cloned from.
+The logical name can be used for overriding this URL within your
+local repository configuration (see 'submodule init').
+
+This command will manage the tree entries and contents of the
+gitmodules file for you, as well as inspect the status of your
+submodules and update them.
+When adding a new submodule to the tree, the 'add' subcommand
+is to be used. However, when pulling a tree containing submodules,
+these will not be checked out by default;
+the 'init' and 'update' subcommands will maintain submodules
+checked out and at appropriate revision in your working tree.
+You can briefly inspect the up-to-date status of your submodules
+using the 'status' subcommand and get a detailed overview of the
+difference between the index and checkouts using the 'summary'
+subcommand.
COMMANDS
--------
add::
Add the given repository as a submodule at the given path
- to the changeset to be committed next. In particular, the
- repository is cloned at the specified path, added to the
- changeset and registered in .gitmodules. If no path is
- specified, the path is deduced from the repository specification.
- If the repository url begins with ./ or ../, it is stored as
- given but resolved as a relative path from the main project's
- url when cloning.
+ to the changeset to be committed next to the current
+ project: the current project is termed the "superproject".
++
+This requires two arguments: <repository> and <path>.
++
+<repository> is the URL of the new submodule's origin repository.
+This may be either an absolute URL, or (if it begins with ./
+or ../), the location relative to the superproject's origin
+repository.
++
+<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
+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.
++
+In either case, the given URL is recorded into .gitmodules for
+use by subsequent users cloning the superproject. If the URL is
+given relative to the superproject's repository, the presumption
+is the superproject and submodule repositories will be kept
+together in the same relative location, and only the
+superproject's URL need be provided: git-submodule will correctly
+locate the submodule using the relative URL in .gitmodules.
status::
Show the status of the submodules. This will print the SHA-1 of the
currently checked out commit for each submodule, along with the
- submodule path and the output of linkgit:git-describe[1] for the
+ submodule path and the output of 'git-describe' for the
SHA-1. Each SHA-1 will be prefixed with `-` if the submodule is not
initialized and `+` if the currently checked out submodule commit
does not match the SHA-1 found in the index of the containing
- repository. This command is the default command for git-submodule.
+ repository. This command is the default command for 'git-submodule'.
init::
- Initialize the submodules, i.e. register in .git/config each submodule
- name and url found in .gitmodules. The key used in .git/config is
- `submodule.$name.url`. This command does not alter existing information
- in .git/config.
+ Initialize the submodules, i.e. register each submodule name
+ and url found in .gitmodules into .git/config.
+ The key used in .git/config is `submodule.$name.url`.
+ This command does not alter existing information in .git/config.
+ You can then customize the submodule clone URLs in .git/config
+ for your local setup and proceed to 'git submodule update';
+ you can also just use 'git submodule update --init' without
+ the explicit 'init' step if you do not intend to customize
+ any submodule locations.
update::
Update the registered submodules, i.e. clone missing submodules and
checkout the commit specified in the index of the containing repository.
This will make the submodules HEAD be detached.
++
+If the submodule is not yet initialized, and you just want to use the
+setting as stored in .gitmodules, you can automatically initialize the
+submodule with the --init option.
+summary::
+ Show commit summary between the given commit (defaults to HEAD) and
+ working tree/index. For a submodule in question, a series of commits
+ in the submodule between the given super project commit and the
+ index or working tree (switched by --cached) are shown.
OPTIONS
-------
--q, --quiet::
+-q::
+--quiet::
Only print error messages.
--b, --branch::
+-b::
+--branch::
Branch of repository to add as submodule.
--cached::
- Display the SHA-1 stored in the index, not the SHA-1 of the currently
- checked out submodule commit. This option is only valid for the
- status command.
-
-<path>::
- Path to submodule(s). When specified this will restrict the command
+ This option is only valid for status and summary commands. These
+ commands typically use the commit found in the submodule HEAD, but
+ with this option, the commit stored in the index is used instead.
+
+-n::
+--summary-limit::
+ This option is only valid for the summary command.
+ Limit the summary size (number of commits shown in total).
+ Giving 0 will disable the summary; a negative number means unlimited
+ (the default). This limit only applies to modified submodules. The
+ size is always limited to 1 for added/deleted/typechanged submodules.
+
+<path>...::
+ Paths to submodule(s). When specified this will restrict the command
to only operate on the submodules found at the specified paths.
+ (This argument is required with add).
FILES
-----
@@ -78,4 +166,4 @@ Written by Lars Hjemli <hjemli@gmail.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index e1a1d46a9..1e644ca6d 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -7,23 +7,23 @@ git-svn - Bidirectional operation between a single Subversion branch and git
SYNOPSIS
--------
-'git-svn' <command> [options] [arguments]
+'git svn' <command> [options] [arguments]
DESCRIPTION
-----------
-git-svn is a simple conduit for changesets between Subversion and git.
-It is not to be confused with linkgit:git-svnimport[1], which is
-read-only.
+'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 was originally designed for an individual developer who wants a
-bidirectional flow of changesets between a single branch in Subversion
-and an arbitrary number of branches in git. Since its inception,
-git-svn has gained the ability to track multiple branches in a manner
-similar to git-svnimport.
+'git-svn' can track a single Subversion branch simply by using a
+URL to the branch, follow branches laid out in the Subversion recommended
+method (trunk, branches, tags directories) with the --stdlayout option, or
+follow branches in any layout with the -T/-t/-b options (see options to
+'init' below, and also the 'clone' command).
-git-svn is especially useful when it comes to tracking repositories
-not organized in the way Subversion developers recommend (trunk,
-branches, tags directories).
+Once tracking a Subversion branch (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.
COMMANDS
--------
@@ -31,7 +31,7 @@ COMMANDS
'init'::
Initializes an empty git repository with additional
- metadata directories for git-svn. The Subversion URL
+ 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
directory to operate on can be specified as a second
@@ -61,6 +61,16 @@ COMMANDS
Set the 'useSvnsyncProps' option in the [svn-remote] config.
--rewrite-root=<URL>;;
Set the 'rewriteRoot' option in the [svn-remote] config.
+--use-log-author;;
+ 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 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
+ will retrieve a valid author string for all commits.
--username=<USER>;;
For transports that SVN handles authentication for (http,
https, and plain svn), specify the username. For other
@@ -97,12 +107,12 @@ COMMANDS
This fetches revisions from the SVN parent of the current HEAD
and rebases the current (uncommitted to SVN) work against it.
-This works similarly to 'svn update' or 'git-pull' except that
+This works similarly to `svn update` or 'git-pull' except that
it preserves linear history with 'git-rebase' instead of
-'git-merge' for ease of dcommiting with git-svn.
+'git-merge' for ease of dcommiting with 'git-svn'.
This accepts all options that 'git-svn fetch' and 'git-rebase'
-accepts. However '--fetch-all' only fetches from the current
+accept. However, '--fetch-all' only fetches from the current
[svn-remote], and not all [svn-remote] definitions.
Like 'git-rebase'; this requires that the working tree be clean
@@ -118,7 +128,7 @@ and have no uncommitted changes.
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.
- It is recommended that you run git-svn fetch and rebase (not
+ It is recommended that you run 'git-svn' fetch and rebase (not
pull or merge) your commits against the latest changes in the
SVN repository.
An optional command-line argument may be specified as an
@@ -128,6 +138,15 @@ and have no uncommitted changes.
+
--no-rebase;;
After committing, do not rebase or reset.
+--commit-url <URL>;;
+ Commit to this SVN URL (the full path). This is intended to
+ allow existing git-svn repositories created with one transport
+ method (e.g. `svn://` or `http://` for anonymous read) to be
+ reused if a user is later given access to an alternate transport
+ method (e.g. `svn+ssh://` or `https://`) for commit.
+
+ Using this option for any other purpose (don't ask)
+ is very strongly discouraged.
--
'log'::
@@ -159,7 +178,25 @@ New features:
our version of --pretty=oneline
--
+
-Any other arguments are passed directly to `git log'
+NOTE: SVN itself only stores times in UTC and nothing else. The regular svn
+client converts the UTC time to the local time (or based on the TZ=
+environment). This command has the same behaviour.
++
+Any other arguments are passed directly to 'git-log'
+
+'blame'::
+ Show what revision and author last modified each line of a file. The
+ output of this mode is format-compatible with the output of
+ `svn blame' by default. Like the SVN blame command,
+ local uncommitted changes in the working copy are ignored;
+ the version of the file in the HEAD revision is annotated. Unknown
+ arguments are passed directly to 'git-blame'.
++
+--git-format;;
+ Produce output in the same format as 'git-blame', but with
+ 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'::
@@ -175,7 +212,13 @@ Any other arguments are passed directly to `git log'
absolutely no attempts to do patching when committing to SVN, it
simply overwrites files with those specified in the tree or
commit. All merging is assumed to have taken place
- independently of git-svn functions.
+ independently of 'git-svn' functions.
+
+'create-ignore'::
+ Recursively finds the svn:ignore property on directories and
+ creates matching .gitignore files. The resulting files are staged to
+ be committed, but are not committed. Use -r/--revision to refer to a
+ specific revision.
'show-ignore'::
Recursively finds and lists the svn:ignore property on
@@ -184,13 +227,12 @@ Any other arguments are passed directly to `git log'
'commit-diff'::
Commits the diff of two tree-ish arguments from the
- command-line. This command is intended for interoperability with
- git-svnimport and does not rely on being inside an git-svn
- init-ed repository. This command takes three arguments, (a) the
+ command-line. This command does not rely on being inside an `git-svn
+ init`-ed repository. This command takes three arguments, (a) the
original tree to diff against, (b) the new tree result, (c) the
URL of the target Subversion repository. The final argument
- (URL) may be omitted if you are working from a git-svn-aware
- repository (that has been init-ed with git-svn).
+ (URL) may be omitted if you are working from a 'git-svn'-aware
+ repository (that has been `init`-ed with 'git-svn').
The -r<revision> option is required for this.
'info'::
@@ -199,6 +241,19 @@ Any other arguments are passed directly to `git log'
argument. Use the --url option to output only the value of the
'URL:' field.
+'proplist'::
+ Lists the properties stored in the Subversion repository about a
+ given file or directory. Use -r/--revision to refer to a specific
+ Subversion revision.
+
+'propget'::
+ Gets the Subversion property given as the first argument, for a
+ file. A specific revision can be specified with -r/--revision.
+
+'show-externals'::
+ Shows the Subversion externals. Use -r/--revision to specify a
+ specific revision.
+
--
OPTIONS
@@ -208,7 +263,7 @@ OPTIONS
--shared[={false|true|umask|group|all|world|everybody}]::
--template=<template_directory>::
Only used with the 'init' command.
- These are passed directly to linkgit:git-init[1].
+ These are passed directly to 'git-init'.
-r <ARG>::
--revision <ARG>::
@@ -230,7 +285,7 @@ Only used with the 'set-tree' command.
Read a list of commits from stdin and commit them in reverse
order. Only the leading sha1 is read from each line, so
-git-rev-list --pretty=oneline output can be used.
+'git-rev-list --pretty=oneline' output can be used.
--rmdir::
@@ -260,7 +315,7 @@ config key: svn.edit
Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
-They are both passed directly to git-diff-tree see
+They are both passed directly to 'git-diff-tree'; see
linkgit:git-diff-tree[1] for more information.
[verse]
@@ -270,24 +325,23 @@ config key: svn.findcopiesharder
-A<filename>::
--authors-file=<filename>::
-Syntax is compatible with the files used by git-svnimport and
-git-cvsimport:
+Syntax is compatible with the file used by 'git-cvsimport':
------------------------------------------------------------------------
loginname = Joe User <user@example.com>
------------------------------------------------------------------------
-If this option is specified and git-svn encounters an SVN
-committer name that does not exist in the authors-file, git-svn
+If this option is specified and 'git-svn' encounters an SVN
+committer name that does not exist in the authors-file, 'git-svn'
will abort operation. The user will then have to add the
-appropriate entry. Re-running the previous git-svn command
+appropriate entry. Re-running the previous 'git-svn' command
after the authors-file is modified should continue operation.
config key: svn.authorsfile
-q::
--quiet::
- Make git-svn less verbose.
+ Make 'git-svn' less verbose.
--repack[=<n>]::
--repack-flags=<flags>::
@@ -299,7 +353,7 @@ with many revisions.
to fetch before repacking. This defaults to repacking every
1000 commits fetched if no argument is specified.
---repack-flags are passed directly to linkgit:git-repack[1].
+--repack-flags are passed directly to 'git-repack'.
[verse]
config key: svn.repack
@@ -312,17 +366,21 @@ config key: svn.repackflags
These are only used with the 'dcommit' and 'rebase' commands.
-Passed directly to git-rebase when using 'dcommit' if a
-'git-reset' cannot be used (see dcommit).
+Passed directly to 'git-rebase' when using 'dcommit' if a
+'git-reset' cannot be used (see 'dcommit').
-n::
--dry-run::
-This is only used with the 'dcommit' command.
+This can be used with the 'dcommit' and 'rebase' commands.
-Print out the series of git arguments that would show
+For 'dcommit', print out the series of git arguments that would show
which diffs would be committed to SVN.
+For 'rebase', display the local branch associated with the upstream svn
+repository associated with the current branch and the URL of svn
+repository that will be fetched from.
+
--
ADVANCED OPTIONS
@@ -360,9 +418,9 @@ CONFIG FILE-ONLY OPTIONS
svn.noMetadata::
svn-remote.<name>.noMetadata::
-This gets rid of the git-svn-id: lines at the end of every commit.
+This gets rid of the 'git-svn-id:' lines at the end of every commit.
-If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
+If you lose your .git/svn/git-svn/.rev_db file, 'git-svn' will not
be able to rebuild it and you won't be able to fetch again,
either. This is fine for one-shot imports.
@@ -373,7 +431,7 @@ option for (hopefully) obvious reasons.
svn.useSvmProps::
svn-remote.<name>.useSvmProps::
-This allows git-svn to re-map repository URLs and UUIDs from
+This allows 'git-svn' to re-map repository URLs and UUIDs from
mirrors created using SVN::Mirror (or svk) for metadata.
If an SVN revision has a property, "svm:headrev", it is likely
@@ -392,20 +450,21 @@ svn-remote.<name>.useSvnsyncprops::
svn-remote.<name>.rewriteRoot::
This allows users to create repositories from alternate
- URLs. For example, an administrator could run git-svn on the
+ URLs. For example, an administrator could run 'git-svn' on the
server locally (accessing via file://) but wish to distribute
the repository with a public http:// or svn:// URL in the
metadata so users of it will see the public URL.
+--
+
Since the noMetadata, rewriteRoot, useSvnsyncProps and useSvmProps
-options all affect the metadata generated and used by git-svn; they
+options all affect the metadata generated and used by 'git-svn'; they
*must* be set in the configuration file before any history is imported
and these settings should never be changed once they are set.
Additionally, only one of these four options can be used per-svn-remote
section because they affect the 'git-svn-id:' metadata line.
---
BASIC EXAMPLES
--------------
@@ -414,7 +473,7 @@ Tracking and contributing to the trunk of a Subversion-managed project:
------------------------------------------------------------------------
# Clone a repo (like git clone):
- git-svn clone http://svn.foo.org/project/trunk
+ git svn clone http://svn.foo.org/project/trunk
# Enter the newly cloned directory:
cd trunk
# You should be on master branch, double-check with git-branch
@@ -423,12 +482,12 @@ Tracking and contributing to the trunk of a Subversion-managed project:
git commit ...
# Something is committed to SVN, rebase your local changes against the
# latest changes in SVN:
- git-svn rebase
+ git svn rebase
# Now commit your changes (that were committed previously using git) to SVN,
# as well as automatically updating your working HEAD:
- git-svn dcommit
+ git svn dcommit
# Append svn:ignore settings to the default git exclude file:
- git-svn show-ignore >> .git/info/exclude
+ git svn show-ignore >> .git/info/exclude
------------------------------------------------------------------------
Tracking and contributing to an entire Subversion-managed project
@@ -436,7 +495,7 @@ Tracking and contributing to an entire Subversion-managed project
------------------------------------------------------------------------
# Clone a repo (like git clone):
- git-svn clone http://svn.foo.org/project -T trunk -b branches -t tags
+ git svn clone http://svn.foo.org/project -T trunk -b branches -t tags
# View all branches and tags you have cloned:
git branch -r
# Reset your master to trunk (or any other branch, replacing 'trunk'
@@ -449,42 +508,45 @@ Tracking and contributing to an entire Subversion-managed project
The initial 'git-svn clone' can be quite time-consuming
(especially for large Subversion repositories). If multiple
people (or one person with multiple machines) want to use
-git-svn to interact with the same Subversion repository, you can
+'git-svn' to interact with the same Subversion repository, you can
do the initial 'git-svn clone' to a repository on a server and
-have each person clone that repository with 'git clone':
+have each person clone that repository with 'git-clone':
------------------------------------------------------------------------
# Do the initial import on a server
- ssh server "cd /pub && git-svn clone http://svn.foo.org/project
-# Clone locally
- git clone server:/pub/project
-# Tell git-svn which branch contains the Subversion commits
- git update-ref refs/remotes/git-svn origin/master
+ ssh server "cd /pub && git svn clone http://svn.foo.org/project
+# Clone locally - make sure the refs/remotes/ space matches the server
+ mkdir project
+ cd project
+ git init
+ git remote add origin server:/pub/project
+ git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
+ git fetch
# Initialize git-svn locally (be sure to use the same URL and -T/-b/-t options as were used on server)
- git-svn init http://svn.foo.org/project
+ git svn init http://svn.foo.org/project
# Pull the latest changes from Subversion
- git-svn rebase
+ git svn rebase
------------------------------------------------------------------------
REBASE VS. PULL/MERGE
---------------------
-Originally, git-svn recommended that the remotes/git-svn branch be
+Originally, 'git-svn' recommended that the 'remotes/git-svn' branch be
pulled or merged from. This is because the author favored
-'git-svn set-tree B' to commit a single head rather than the
-'git-svn set-tree A..B' notation to commit multiple commits.
+`git svn set-tree B` to commit a single head rather than the
+`git svn set-tree A..B` notation to commit multiple commits.
-If you use 'git-svn set-tree A..B' to commit several diffs and you do
+If you use `git svn set-tree A..B` to commit several diffs and you do
not have the latest remotes/git-svn merged into my-branch, you should
-use 'git-svn rebase' to update your work branch instead of 'git pull' or
-'git merge'. 'pull/merge' can cause non-linear history to be flattened
+use `git svn rebase` to update your work branch instead of `git pull` or
+`git merge`. `pull`/`merge' can cause non-linear history to be flattened
when committing into SVN, which can lead to merge commits reversing
previous commits in SVN.
DESIGN PHILOSOPHY
-----------------
Merge tracking in Subversion is lacking and doing branched development
-with Subversion can be cumbersome as a result. While git-svn can track
+with Subversion can be cumbersome as a result. 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
@@ -495,30 +557,30 @@ CAVEATS
-------
For the sake of simplicity and interoperating with a less-capable system
-(SVN), 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
+(SVN), 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
-git-format-patch and git-am, or just dcommiting to the SVN repository.
+'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. Subversion does not represent merges in any
+plan to 'dcommit' from. Subversion does not represent merges in any
reasonable or useful fashion; so users using Subversion cannot see any
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
+that is a mirror of an SVN branch, 'dcommit' may commit to the wrong
branch.
'git-clone' does not clone branches under the refs/remotes/ hierarchy or
-any git-svn metadata, or config. So repositories created and managed with
-using git-svn should use rsync(1) for cloning, if cloning is to be done
+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
-before dcommit on will require forcing an overwrite of the existing ref
+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 git-push(1) documentation for details.
+see the linkgit:git-push[1] documentation for details.
-Do not use the --amend option of git-commit(1) on a change you've
+Do not use the --amend option of linkgit:git-commit[1] on a change you've
already dcommitted. It is considered bad practice to --amend commits
you've already pushed to a remote repository for other users, and
dcommit with SVN is analogous to that.
@@ -539,7 +601,7 @@ for git to detect them.
CONFIGURATION
-------------
-git-svn stores [svn-remote] configuration information in the
+'git-svn' stores [svn-remote] configuration information in the
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'
@@ -560,8 +622,7 @@ Keep in mind that the '*' (asterisk) wildcard of the local ref
however the remote wildcard may be anywhere as long as it's own
independent path component (surrounded by '/' or EOL). This
type of configuration is not automatically created by 'init' and
-should be manually entered with a text-editor or using
-linkgit:git-config[1]
+should be manually entered with a text-editor or using 'git-config'.
SEE ALSO
--------
diff --git a/Documentation/git-symbolic-ref.txt b/Documentation/git-symbolic-ref.txt
index a5b40f3e8..210fde03a 100644
--- a/Documentation/git-symbolic-ref.txt
+++ b/Documentation/git-symbolic-ref.txt
@@ -7,7 +7,7 @@ git-symbolic-ref - Read and modify symbolic refs
SYNOPSIS
--------
-'git-symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
+'git symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
DESCRIPTION
-----------
@@ -26,7 +26,8 @@ a regular file whose contents is `ref: refs/heads/master`.
OPTIONS
-------
--q, --quiet::
+-q::
+--quiet::
Do not issue an error message if the <name> is not a
symbolic ref but a detached HEAD; instead exit with
non-zero status silently.
@@ -48,14 +49,14 @@ cumbersome. On some platforms, `ln -sf` does not even work as
advertised (horrors). Therefore symbolic links are now deprecated
and symbolic refs are used by default.
-git-symbolic-ref will exit with status 0 if the contents of the
+'git-symbolic-ref' will exit with status 0 if the contents of the
symbolic ref were printed correctly, with status 1 if the requested
name is not a symbolic ref, or 128 if another error occurs.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index b62a3d1c5..046ab3542 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -9,10 +9,11 @@ git-tag - Create, list, delete or verify a tag object signed with GPG
SYNOPSIS
--------
[verse]
-'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <name> [<head>]
-'git-tag' -d <name>...
-'git-tag' [-n [<num>]] -l [<pattern>]
-'git-tag' -v <name>...
+'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>]
+ <name> [<commit> | <object>]
+'git tag' -d <name>...
+'git tag' [-n[<num>]] -l [<pattern>]
+'git tag' -v <name>...
DESCRIPTION
-----------
@@ -26,6 +27,9 @@ creates a 'tag' object, and requires the tag message. Unless
`-m <msg>` or `-F <file>` is given, an editor is started for the user to type
in the tag message.
+If `-m <msg>` or `-F <file>` is given and `-a`, `-s`, and `-u <key-id>`
+are absent, `-a` is implied.
+
Otherwise just the SHA1 object name of the commit object is
written (i.e. a lightweight tag).
@@ -54,7 +58,7 @@ OPTIONS
-v::
Verify the gpg signature of the given tag names.
--n <num>::
+-n<num>::
<num> specifies how many lines from the annotation, if any,
are printed when using -l.
The default is not to print any annotation lines.
@@ -68,14 +72,18 @@ OPTIONS
Use the given tag message (instead of prompting).
If multiple `-m` options are given, there values are
concatenated as separate paragraphs.
+ Implies `-a` if none of `-a`, `-s`, or `-u <key-id>`
+ is given.
-F <file>::
Take the tag message from the given file. Use '-' to
read the message from the standard input.
+ Implies `-a` if none of `-a`, `-s`, or `-u <key-id>`
+ is given.
CONFIGURATION
-------------
-By default, git-tag in sign-with-default mode (-s) will use your
+By default, 'git-tag' in sign-with-default mode (-s) will use your
committer identity (of the form "Your Name <your@email.address>") to
find a key. If you want to use a different default key, you can specify
it in the repository configuration as follows:
@@ -111,12 +119,12 @@ and be done with it.
. The insane thing.
You really want to call the new version "X" too, 'even though'
-others have already seen the old one. So just use "git tag -f"
+others have already seen the old one. So just use 'git-tag -f'
again, as if you hadn't already published the old one.
However, Git does *not* (and it should not) change tags behind
-users back. So if somebody already got the old tag, doing a "git
-pull" on your tree shouldn't just make them overwrite the old
+users back. So if somebody already got the old tag, doing a
+'git-pull' on your tree shouldn't just make them overwrite the old
one.
If somebody got a release tag from you, you cannot just change
@@ -170,7 +178,7 @@ private anchor point tags from the other person.
You would notice "please pull" messages on the mailing list says
repo URL and branch name alone. This is designed to be easily
-cut&pasted to "git fetch" command line:
+cut&pasted to a 'git-fetch' command line:
------------
Linus, please pull from
@@ -226,21 +234,21 @@ the tag object affects, for example, the ordering of tags in the
gitweb interface.
To set the date used in future tag objects, set the environment
-variable GIT_AUTHOR_DATE to one or more of the date and time. The
+variable GIT_COMMITTER_DATE to one or more of the date and time. The
date and time can be specified in a number of ways; the most common
is "YYYY-MM-DD HH:MM".
An example follows.
------------
-$ GIT_AUTHOR_DATE="2006-10-02 10:31" git tag -s v1.0.1
+$ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1
------------
Author
------
Written by Linus Torvalds <torvalds@osdl.org>,
-Junio C Hamano <junkio@cox.net> and Chris Wright <chrisw@osdl.org>.
+Junio C Hamano <gitster@pobox.com> and Chris Wright <chrisw@osdl.org>.
Documentation
--------------
@@ -248,4 +256,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-tar-tree.txt b/Documentation/git-tar-tree.txt
index 65c68176e..a5d9558dd 100644
--- a/Documentation/git-tar-tree.txt
+++ b/Documentation/git-tar-tree.txt
@@ -8,23 +8,23 @@ git-tar-tree - Create a tar archive of the files in the named tree object
SYNOPSIS
--------
-'git-tar-tree' [--remote=<repo>] <tree-ish> [ <base> ]
+'git tar-tree' [--remote=<repo>] <tree-ish> [ <base> ]
DESCRIPTION
-----------
-THIS COMMAND IS DEPRECATED. Use `git-archive` with `--format=tar`
+THIS COMMAND IS DEPRECATED. Use 'git-archive' with `--format=tar`
option instead (and move the <base> argument to `--prefix=base/`).
Creates a tar archive containing the tree structure for the named tree.
When <base> is specified it is added as a leading path to the files in the
generated tar archive.
-git-tar-tree behaves differently when given a tree ID versus when given
+'git-tar-tree' behaves differently when given a tree ID versus when given
a commit ID or tag ID. In the first case the current time is used as
modification time of each file in the archive. In the latter case the
commit time as recorded in the referenced commit object is used instead.
Additionally the commit ID is stored in a global extended pax header.
-It can be extracted using git-get-tar-commit-id.
+It can be extracted using 'git-get-tar-commit-id'.
OPTIONS
-------
@@ -86,4 +86,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-unpack-file.txt b/Documentation/git-unpack-file.txt
index 1864d13ed..995db9fea 100644
--- a/Documentation/git-unpack-file.txt
+++ b/Documentation/git-unpack-file.txt
@@ -9,7 +9,7 @@ git-unpack-file - Creates a temporary file with a blob's contents
SYNOPSIS
--------
-'git-unpack-file' <blob>
+'git unpack-file' <blob>
DESCRIPTION
-----------
@@ -32,4 +32,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-unpack-objects.txt b/Documentation/git-unpack-objects.txt
index b79be3fd4..36d103805 100644
--- a/Documentation/git-unpack-objects.txt
+++ b/Documentation/git-unpack-objects.txt
@@ -8,7 +8,7 @@ git-unpack-objects - Unpack objects from a packed archive
SYNOPSIS
--------
-'git-unpack-objects' [-n] [-q] [-r] <pack-file
+'git unpack-objects' [-n] [-q] [-r] [--strict] <pack-file
DESCRIPTION
@@ -21,7 +21,7 @@ Objects that already exist in the repository will *not* be unpacked
from the pack-file. Therefore, nothing will be unpacked if you use
this command on a pack-file that exists within the target repository.
-Please see the `git-repack` documentation for options to generate
+See linkgit:git-repack[1] for options to generate
new packs and replace existing ones.
OPTIONS
@@ -40,6 +40,9 @@ OPTIONS
and make the best effort to recover as many objects as
possible.
+--strict::
+ Don't write objects with broken content or links.
+
Author
------
@@ -51,4 +54,4 @@ Documentation by Junio C Hamano
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 66be18ef3..1d9d81a70 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -9,12 +9,13 @@ git-update-index - Register file contents in the working tree to the index
SYNOPSIS
--------
[verse]
-'git-update-index'
+'git update-index'
[--add] [--remove | --force-remove] [--replace]
[--refresh] [-q] [--unmerged] [--ignore-missing]
[--cacheinfo <mode> <object> <file>]\*
[--chmod=(+|-)x]
[--assume-unchanged | --no-assume-unchanged]
+ [--ignore-submodules]
[--really-refresh] [--unresolve] [--again | -g]
[--info-only] [--index-info]
[-z] [--stdin]
@@ -30,7 +31,7 @@ cleared.
See also linkgit:git-add[1] for a more user-friendly way to do some of
the most common operations on the index.
-The way "git-update-index" handles files it is told about can be modified
+The way 'git-update-index' handles files it is told about can be modified
using the various options:
OPTIONS
@@ -52,11 +53,15 @@ OPTIONS
-q::
Quiet. If --refresh finds that the index needs an update, the
default behavior is to error out. This option makes
- git-update-index continue anyway.
+ 'git-update-index' continue anyway.
+
+--ignore-submodules:
+ Do not try to update submodules. This option is only respected
+ when passed before --refresh.
--unmerged::
If --refresh finds unmerged changes in the index, the default
- behavior is to error out. This option makes git-update-index
+ behavior is to error out. This option makes 'git-update-index'
continue anyway.
--ignore-missing::
@@ -71,7 +76,8 @@ OPTIONS
--chmod=(+|-)x::
Set the execute permissions on the updated files.
---assume-unchanged, --no-assume-unchanged::
+--assume-unchanged::
+--no-assume-unchanged::
When these flags are specified, the object name recorded
for the paths are not updated. Instead, these options
sets and unsets the "assume unchanged" bit for the
@@ -82,9 +88,20 @@ OPTIONS
sometimes helpful when working with a big project on a
filesystem that has very slow lstat(2) system call
(e.g. cifs).
-
---again, -g::
- Runs `git-update-index` itself on the paths whose index
++
+This option can be also used as a coarse file-level mechanism
+to ignore uncommitted changes in tracked files (akin to what
+`.gitignore` does for untracked files).
+You should remember that an explicit 'git add' operation will
+still cause the file to be refreshed from the working tree.
+Git will fail (gracefully) in case it needs to modify this file
+in the index e.g. when merging in a commit;
+thus, in case the assumed-untracked file is changed upstream,
+you will need to handle the situation manually.
+
+-g::
+--again::
+ Runs 'git-update-index' itself on the paths whose index
entries are different from those from the `HEAD` commit.
--unresolve::
@@ -102,7 +119,7 @@ OPTIONS
--replace::
By default, when a file `path` exists in the index,
- git-update-index refuses an attempt to add `path/file`.
+ 'git-update-index' refuses an attempt to add `path/file`.
Similarly if a file `path/file` exists, a file `path`
cannot be added. With --replace flag, existing entries
that conflicts with the entry being added are
@@ -138,7 +155,7 @@ up-to-date for mode/content changes. But what it *does* do is to
can refresh the index for a file that hasn't been changed but where
the stat entry is out of date.
-For example, you'd want to do this after doing a "git-read-tree", to link
+For example, you'd want to do this after doing a 'git-read-tree', to link
up the stat index details with the proper files.
Using --cacheinfo or --info-only
@@ -150,7 +167,7 @@ merging.
To pretend you have a file with mode and sha1 at path, say:
----------------
-$ git-update-index --cacheinfo mode sha1 path
+$ git update-index --cacheinfo mode sha1 path
----------------
'--info-only' is used to register files without placing them in the object
@@ -179,13 +196,13 @@ back on 3-way merge.
. mode SP type SP sha1 TAB path
+
-The second format is to stuff git-ls-tree output
+The second format is to stuff 'git-ls-tree' output
into the index file.
. mode SP sha1 SP stage TAB path
+
This format is to put higher order stages into the
-index file and matches git-ls-files --stage output.
+index file and matches 'git-ls-files --stage' output.
To place a higher stage entry to the index, the path should
first be removed by feeding a mode=0 entry for the path, and
@@ -240,13 +257,13 @@ In order to set "assume unchanged" bit, use `--assume-unchanged`
option. To unset, use `--no-assume-unchanged`.
The command looks at `core.ignorestat` configuration variable. When
-this is true, paths updated with `git-update-index paths...` and
+this is true, paths updated with `git update-index paths...` 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
+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
-`git-update-index --refresh` finds the working tree file matches
-the index (use `git-update-index --really-refresh` if you want
+`git update-index --refresh` finds the working tree file matches
+the index (use `git update-index --really-refresh` if you want
to mark them as "assume unchanged").
@@ -255,7 +272,7 @@ Examples
To update and refresh only the files already checked out:
----------------
-$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
+$ git checkout-index -n -f -a && git update-index --ignore-missing --refresh
----------------
On an inefficient filesystem with `core.ignorestat` set::
@@ -296,7 +313,7 @@ unreliable, this should be set to 'false' (see linkgit:git-config[1]).
This causes the command to ignore differences in file modes recorded
in the index and the file mode on the filesystem if they differ only on
executable bit. On such an unfortunate filesystem, you may
-need to use `git-update-index --chmod=`.
+need to use 'git-update-index --chmod='.
Quite similarly, if `core.symlinks` configuration variable is set
to 'false' (see linkgit:git-config[1]), symbolic links are checked out
@@ -306,8 +323,13 @@ from symbolic link to regular file.
The command looks at `core.ignorestat` configuration variable. See
'Using "assume unchanged" bit' section above.
+The command also looks at `core.trustctime` configuration variable.
+It can be useful when the inode change time is regularly modified by
+something outside Git (file system crawlers and backup systems use
+ctime for marking files processed) (see linkgit:git-config[1]).
+
-See Also
+SEE ALSO
--------
linkgit:git-config[1],
linkgit:git-add[1]
@@ -323,4 +345,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt
index 4dc475992..9639f705a 100644
--- a/Documentation/git-update-ref.txt
+++ b/Documentation/git-update-ref.txt
@@ -7,18 +7,18 @@ git-update-ref - Update the object name stored in a ref safely
SYNOPSIS
--------
-'git-update-ref' [-m <reason>] (-d <ref> <oldvalue> | [--no-deref] <ref> <newvalue> [<oldvalue>])
+'git update-ref' [-m <reason>] (-d <ref> [<oldvalue>] | [--no-deref] <ref> <newvalue> [<oldvalue>])
DESCRIPTION
-----------
Given two arguments, stores the <newvalue> in the <ref>, possibly
-dereferencing the symbolic refs. E.g. `git-update-ref HEAD
+dereferencing the symbolic refs. E.g. `git update-ref HEAD
<newvalue>` updates the current branch head to the new object.
Given three arguments, stores the <newvalue> in the <ref>,
possibly dereferencing the symbolic refs, after verifying that
the current value of the <ref> matches <oldvalue>.
-E.g. `git-update-ref refs/heads/master <newvalue> <oldvalue>`
+E.g. `git update-ref refs/heads/master <newvalue> <oldvalue>`
updates the master branch head to <newvalue> only if its current
value is <oldvalue>. You can specify 40 "0" or an empty string
as <oldvalue> to make sure that the ref you are creating does
@@ -41,7 +41,7 @@ the result of following the symbolic pointers.
In general, using
- git-update-ref HEAD "$head"
+ git update-ref HEAD "$head"
should be a _lot_ safer than doing
@@ -61,7 +61,7 @@ still contains <oldvalue>.
Logging Updates
---------------
If config parameter "core.logAllRefUpdates" is true or the file
-"$GIT_DIR/logs/<ref>" exists then `git-update-ref` will append
+"$GIT_DIR/logs/<ref>" exists then `git update-ref` will append
a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all
symbolic refs before creating the log name) describing the change
in ref value. Log lines are formatted as:
@@ -90,4 +90,4 @@ Written by Linus Torvalds <torvalds@osdl.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-update-server-info.txt b/Documentation/git-update-server-info.txt
index 1cf89fd79..35d27b0c7 100644
--- a/Documentation/git-update-server-info.txt
+++ b/Documentation/git-update-server-info.txt
@@ -8,7 +8,7 @@ git-update-server-info - Update auxiliary info file to help dumb servers
SYNOPSIS
--------
-'git-update-server-info' [--force]
+'git update-server-info' [--force]
DESCRIPTION
-----------
@@ -22,7 +22,8 @@ generates such auxiliary files.
OPTIONS
-------
--f|--force::
+-f::
+--force::
Update the info files from scratch.
@@ -30,8 +31,8 @@ OUTPUT
------
Currently the command updates the following files. Please see
-link:repository-layout.html[repository-layout] for description
-of what they are for:
+linkgit:gitrepository-layout[5] for description of
+what they are for:
* objects/info/packs
@@ -46,7 +47,7 @@ info/refs file unless `--force` flag is given.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -54,4 +55,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-upload-archive.txt b/Documentation/git-upload-archive.txt
index c1ef1440b..bbd761758 100644
--- a/Documentation/git-upload-archive.txt
+++ b/Documentation/git-upload-archive.txt
@@ -8,7 +8,7 @@ git-upload-archive - Send archive back to git-archive
SYNOPSIS
--------
-'git-upload-archive' <directory>
+'git upload-archive' <directory>
DESCRIPTION
-----------
@@ -34,4 +34,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt
index 2330d1381..b8e49dce4 100644
--- a/Documentation/git-upload-pack.txt
+++ b/Documentation/git-upload-pack.txt
@@ -8,7 +8,7 @@ git-upload-pack - Send objects packed back to git-fetch-pack
SYNOPSIS
--------
-'git-upload-pack' [--strict] [--timeout=<n>] <directory>
+'git upload-pack' [--strict] [--timeout=<n>] <directory>
DESCRIPTION
-----------
@@ -24,10 +24,10 @@ repository. For push operations, see 'git-send-pack'.
OPTIONS
-------
-\--strict::
+--strict::
Do not try <directory>/.git/ if <directory> is no git directory.
-\--timeout=<n>::
+--timeout=<n>::
Interrupt transfer after <n> seconds of inactivity.
<directory>::
@@ -43,4 +43,4 @@ Documentation by Junio C Hamano.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index 298028390..3647dd6c8 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -8,7 +8,7 @@ git-var - Show a git logical variable
SYNOPSIS
--------
-'git-var' [ -l | <variable> ]
+'git var' [ -l | <variable> ]
DESCRIPTION
-----------
@@ -20,11 +20,11 @@ OPTIONS
Cause the logical variables to be listed. In addition, all the
variables of the git configuration file .git/config are listed
as well. (However, the configuration variables listing functionality
- is deprecated in favor of `git-config -l`.)
+ is deprecated in favor of 'git-config -l'.)
EXAMPLE
--------
- $ git-var GIT_AUTHOR_IDENT
+ $ git var GIT_AUTHOR_IDENT
Eric W. Biederman <ebiederm@lnxi.com> 1121223278 -0600
@@ -45,7 +45,7 @@ Your parents must have hated you!::
Your sysadmin must hate you!::
The password(5) name field is longer than a giant static buffer.
-See Also
+SEE ALSO
--------
linkgit:git-commit-tree[1]
linkgit:git-tag[1]
@@ -61,4 +61,4 @@ Documentation by Eric Biederman and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-verify-pack.txt b/Documentation/git-verify-pack.txt
index db019a2b8..c8611632d 100644
--- a/Documentation/git-verify-pack.txt
+++ b/Documentation/git-verify-pack.txt
@@ -8,13 +8,13 @@ git-verify-pack - Validate packed git archive files
SYNOPSIS
--------
-'git-verify-pack' [-v] [--] <pack>.idx ...
+'git verify-pack' [-v] [--] <pack>.idx ...
DESCRIPTION
-----------
-Reads given idx file for packed git archive created with
-git-pack-objects command and verifies idx file and 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.
OPTIONS
@@ -32,17 +32,17 @@ OUTPUT FORMAT
-------------
When specifying the -v option the format used is:
- SHA1 type size offset-in-packfile
+ SHA1 type size size-in-pack-file offset-in-packfile
for objects that are not deltified in the pack, and
- SHA1 type size offset-in-packfile depth base-SHA1
+ SHA1 type size size-in-packfile offset-in-packfile depth base-SHA1
for objects that are deltified.
Author
------
-Written by Junio C Hamano <junkio@cox.net>
+Written by Junio C Hamano <gitster@pobox.com>
Documentation
--------------
@@ -50,4 +50,4 @@ Documentation by Junio C Hamano
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-verify-tag.txt b/Documentation/git-verify-tag.txt
index 7e9c1ed15..84e70a023 100644
--- a/Documentation/git-verify-tag.txt
+++ b/Documentation/git-verify-tag.txt
@@ -7,16 +7,16 @@ git-verify-tag - Check the GPG signature of tags
SYNOPSIS
--------
-'git-verify-tag' <tag>...
+'git verify-tag' <tag>...
DESCRIPTION
-----------
-Validates the gpg signature created by git-tag.
+Validates the gpg signature created by 'git-tag'.
OPTIONS
-------
-<tag>::
- SHA1 identifier of a git tag object.
+<tag>...::
+ SHA1 identifiers of git tag objects.
Author
------
@@ -28,4 +28,4 @@ Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-web--browse.txt b/Documentation/git-web--browse.txt
new file mode 100644
index 000000000..36afad8d4
--- /dev/null
+++ b/Documentation/git-web--browse.txt
@@ -0,0 +1,124 @@
+git-web--browse(1)
+==================
+
+NAME
+----
+git-web--browse - git helper script to launch a web browser
+
+SYNOPSIS
+--------
+'git web--browse' [OPTIONS] URL/FILE ...
+
+DESCRIPTION
+-----------
+
+This script tries, as much as possible, to display the URLs and FILEs
+that are passed as arguments, as HTML pages in new tabs on an already
+opened web browser.
+
+The following browsers (or commands) are currently supported:
+
+* firefox (this is the default under X Window when not using KDE)
+* iceweasel
+* konqueror (this is the default under KDE, see 'Note about konqueror' below)
+* w3m (this is the default outside graphical environments)
+* links
+* lynx
+* dillo
+* open (this is the default under Mac OS X GUI)
+
+Custom commands may also be specified.
+
+OPTIONS
+-------
+-b BROWSER::
+--browser=BROWSER::
+ Use the specified BROWSER. It must be in the list of supported
+ browsers.
+
+-t BROWSER::
+--tool=BROWSER::
+ Same as above.
+
+-c CONF.VAR::
+--config=CONF.VAR::
+ CONF.VAR is looked up in the git config files. If it's set,
+ then its value specify the browser that should be used.
+
+CONFIGURATION VARIABLES
+-----------------------
+
+CONF.VAR (from -c option) and web.browser
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The web browser can be specified using a configuration variable passed
+with the -c (or --config) command line option, or the 'web.browser'
+configuration variable if the former is not used.
+
+browser.<tool>.path
+~~~~~~~~~~~~~~~~~~~
+
+You can explicitly provide a full path to your preferred browser by
+setting the configuration variable 'browser.<tool>.path'. For example,
+you can configure the absolute path to firefox by setting
+'browser.firefox.path'. Otherwise, 'git-web--browse' assumes the tool
+is available in PATH.
+
+browser.<tool>.cmd
+~~~~~~~~~~~~~~~~~~
+
+When the browser, specified by options or configuration variables, is
+not among the supported ones, then the corresponding
+'browser.<tool>.cmd' configuration variable will be looked up. If this
+variable exists then 'git-web--browse' will treat the specified tool
+as a custom command and will use a shell eval to run the command with
+the URLs passed as arguments.
+
+Note about konqueror
+--------------------
+
+When 'konqueror' is specified by the a command line option or a
+configuration variable, we launch 'kfmclient' to try to open the HTML
+man page on an already opened konqueror in a new tab if possible.
+
+For consistency, we also try such a trick if 'browser.konqueror.path' is
+set to something like 'A_PATH_TO/konqueror'. That means we will try to
+launch 'A_PATH_TO/kfmclient' instead.
+
+If you really want to use 'konqueror', then you can use something like
+the following:
+
+------------------------------------------------
+ [web]
+ browser = konq
+
+ [browser "konq"]
+ cmd = A_PATH_TO/konqueror
+------------------------------------------------
+
+Note about git-config --global
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Note that these configuration variables should probably be set using
+the '--global' flag, for example like this:
+
+------------------------------------------------
+$ git config --global web.browser firefox
+------------------------------------------------
+
+as they are probably more user specific than repository specific.
+See linkgit:git-config[1] for more information about this.
+
+Author
+------
+Written by Christian Couder <chriscool@tuxfamily.org> and the git-list
+<git@vger.kernel.org>, based on 'git-mergetool' by Theodore Y. Ts'o.
+
+Documentation
+-------------
+Documentation by Christian Couder <chriscool@tuxfamily.org> and the
+git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt
index 54947b676..cadfbd904 100644
--- a/Documentation/git-whatchanged.txt
+++ b/Documentation/git-whatchanged.txt
@@ -8,7 +8,7 @@ git-whatchanged - Show logs with difference each commit introduces
SYNOPSIS
--------
-'git-whatchanged' <option>...
+'git whatchanged' <option>...
DESCRIPTION
-----------
@@ -38,11 +38,6 @@ OPTIONS
Show git internal diff output, but for the whole tree,
not just the top level.
---pretty=<format>::
- Controls the output format for the commit logs.
- <format> can be one of 'raw', 'medium', 'short', 'full',
- and 'oneline'.
-
-m::
By default, differences for merge commits are not shown.
With this flag, show differences to that commit from all
@@ -51,14 +46,18 @@ OPTIONS
However, it is not very useful in general, although it
*is* useful on a file-by-file basis.
+include::pretty-options.txt[]
+
+include::pretty-formats.txt[]
+
Examples
--------
-git-whatchanged -p v2.6.12.. include/scsi drivers/scsi::
+git whatchanged -p v2.6.12.. include/scsi drivers/scsi::
Show as patches the commits since version 'v2.6.12' that changed
any file in the include/scsi or drivers/scsi subdirectories
-git-whatchanged --since="2 weeks ago" \-- gitk::
+git whatchanged --since="2 weeks ago" \-- gitk::
Show the changes during the last two weeks to the file 'gitk'.
The "--" is necessary to avoid confusion with the *branch* named
@@ -68,7 +67,7 @@ git-whatchanged --since="2 weeks ago" \-- gitk::
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
-Junio C Hamano <junkio@cox.net>
+Junio C Hamano <gitster@pobox.com>
Documentation
@@ -77,4 +76,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git-write-tree.txt b/Documentation/git-write-tree.txt
index 461c813f5..26d3850e7 100644
--- a/Documentation/git-write-tree.txt
+++ b/Documentation/git-write-tree.txt
@@ -8,7 +8,7 @@ git-write-tree - Create a tree object from the current index
SYNOPSIS
--------
-'git-write-tree' [--missing-ok] [--prefix=<prefix>/]
+'git write-tree' [--missing-ok] [--prefix=<prefix>/]
DESCRIPTION
-----------
@@ -16,17 +16,17 @@ Creates a tree object using the current index.
The index must be in a fully merged state.
-Conceptually, `git-write-tree` sync()s the current index contents
+Conceptually, 'git-write-tree' sync()s the current index contents
into a set of tree files.
In order to have that match what is actually in your directory right
-now, you need to have done a `git-update-index` phase before you did the
-`git-write-tree`.
+now, you need to have done a 'git-update-index' phase before you did the
+'git-write-tree'.
OPTIONS
-------
--missing-ok::
- Normally `git-write-tree` ensures that the objects referenced by the
+ Normally 'git-write-tree' ensures that the objects referenced by the
directory exist in the object database. This option disables this
check.
@@ -46,4 +46,4 @@ Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 4ece40d1e..1bc295dd5 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1,4 +1,4 @@
-git(7)
+git(1)
======
NAME
@@ -20,11 +20,11 @@ Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.
-See this link:tutorial.html[tutorial] to get started, then see
+See linkgit:gittutorial[7] to get started, then see
link:everyday.html[Everyday Git] for a useful minimum set of commands, and
"man git-commandname" for documentation of each command. CVS users may
-also want to read link:cvs-migration.html[CVS migration]. See
-link:user-manual.html[Git User's Manual] for a more in-depth
+also want to read linkgit:gitcvs-migration[7]. See
+the link:user-manual.html[Git User's Manual] for a more in-depth
introduction.
The COMMAND is either a name of a Git command (see below) or an alias
@@ -43,6 +43,40 @@ unreleased) version of git, that is available from 'master'
branch of the `git.git` repository.
Documentation for older releases are available here:
+* link:v1.6.0/git.html[documentation for release 1.6.0]
+
+* release notes for
+ link:RelNotes-1.6.0.txt[1.6.0].
+
+* link:v1.5.6.5/git.html[documentation for release 1.5.6.5]
+
+* release notes for
+ link:RelNotes-1.5.6.5.txt[1.5.6.5],
+ link:RelNotes-1.5.6.4.txt[1.5.6.4],
+ link:RelNotes-1.5.6.3.txt[1.5.6.3],
+ link:RelNotes-1.5.6.2.txt[1.5.6.2],
+ link:RelNotes-1.5.6.1.txt[1.5.6.1],
+ link:RelNotes-1.5.6.txt[1.5.6].
+
+* link:v1.5.5.4/git.html[documentation for release 1.5.5.4]
+
+* release notes for
+ link:RelNotes-1.5.5.4.txt[1.5.5.4],
+ link:RelNotes-1.5.5.3.txt[1.5.5.3],
+ link:RelNotes-1.5.5.2.txt[1.5.5.2],
+ link:RelNotes-1.5.5.1.txt[1.5.5.1],
+ link:RelNotes-1.5.5.txt[1.5.5].
+
+* link:v1.5.4.5/git.html[documentation for release 1.5.4.5]
+
+* release notes for
+ link:RelNotes-1.5.4.5.txt[1.5.4.5],
+ link:RelNotes-1.5.4.4.txt[1.5.4.4],
+ link:RelNotes-1.5.4.3.txt[1.5.4.3],
+ link:RelNotes-1.5.4.2.txt[1.5.4.2],
+ link:RelNotes-1.5.4.1.txt[1.5.4.1],
+ link:RelNotes-1.5.4.txt[1.5.4].
+
* link:v1.5.3.8/git.html[documentation for release 1.5.3.8]
* release notes for
@@ -56,6 +90,8 @@ Documentation for older releases are available here:
link:RelNotes-1.5.3.1.txt[1.5.3.1],
link:RelNotes-1.5.3.txt[1.5.3].
+* link:v1.5.2.5/git.html[documentation for release 1.5.2.5]
+
* release notes for
link:RelNotes-1.5.2.5.txt[1.5.2.5],
link:RelNotes-1.5.2.4.txt[1.5.2.4],
@@ -108,16 +144,17 @@ OPTIONS
+
Other options are available to control how the manual page is
displayed. See linkgit:git-help[1] for more information,
-because 'git --help ...' is converted internally into 'git
-help ...'.
+because `git --help ...` is converted internally into `git
+help ...`.
--exec-path::
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
+ environment variable. If no path is given, 'git' will print
the current setting and then exit.
--p|--paginate::
+-p::
+--paginate::
Pipe all output into 'less' (or if set, $PAGER).
--no-pager::
@@ -125,7 +162,8 @@ help ...'.
--git-dir=<path>::
Set the path to the repository. This can also be controlled by
- setting the GIT_DIR environment variable.
+ setting the GIT_DIR environment variable. It can be an absolute
+ path or relative path to current working directory.
--work-tree=<path>::
Set the path to the working tree. The value will not be
@@ -133,7 +171,12 @@ help ...'.
a .git directory (i.e. $GIT_DIR is not set).
This can also be controlled by setting the GIT_WORK_TREE
environment variable and the core.worktree configuration
- variable.
+ variable. It can be an absolute path or relative path to
+ the directory specified by --git-dir or GIT_DIR.
+ Note: If --git-dir or GIT_DIR are specified but none of
+ --work-tree, GIT_WORK_TREE and core.worktree is specified,
+ the current working directory is regarded as the top directory
+ of your working tree.
--bare::
Treat the repository as a bare repository. If GIT_DIR
@@ -148,13 +191,14 @@ See the references above to get started using git. The following is
probably more detail than necessary for a first-time user.
The link:user-manual.html#git-concepts[git concepts chapter of the
-user-manual] and the link:core-tutorial.html[Core tutorial] both provide
+user-manual] and linkgit:gitcore-tutorial[7] both provide
introductions to the underlying git architecture.
See also the link:howto-index.html[howto] documents for some useful
examples.
-The internals are documented link:technical/api-index.html[here].
+The internals are documented in the
+link:technical/api-index.html[GIT API documentation].
GIT COMMANDS
------------
@@ -338,9 +382,9 @@ For a more complete list of ways to spell object names, see
File/Directory Structure
------------------------
-Please see the link:repository-layout.html[repository layout] document.
+Please see the linkgit:gitrepository-layout[5] document.
-Read link:hooks.html[hooks] for more details about each hook.
+Read linkgit:githooks[5] for more details about each hook.
Higher level SCMs may provide and manage additional information in the
`$GIT_DIR`.
@@ -348,7 +392,7 @@ Higher level SCMs may provide and manage additional information in the
Terminology
-----------
-Please see the link:glossary.html[glossary] document.
+Please see linkgit:gitglossary[7].
Environment Variables
@@ -375,9 +419,9 @@ git so take care if using Cogito etc.
'GIT_ALTERNATE_OBJECT_DIRECTORIES'::
Due to the immutable nature of git objects, old objects can be
archived into shared, read-only directories. This variable
- specifies a ":" separated list of git object directories which
- can be used to search for git objects. New objects will not be
- written to these directories.
+ specifies a ":" separated (on Windows ";" separated) list
+ of git object directories which can be used to search for git
+ objects. New objects will not be written to these directories.
'GIT_DIR'::
If the 'GIT_DIR' environment variable is set then it
@@ -391,6 +435,14 @@ git so take care if using Cogito etc.
This can also be controlled by the '--work-tree' command line
option and the core.worktree configuration variable.
+'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
+ 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.
+ (Useful for excluding slow-loading network directories.)
+
git Commits
~~~~~~~~~~~
'GIT_AUTHOR_NAME'::
@@ -448,10 +500,10 @@ other
a pager.
'GIT_SSH'::
- If this environment variable is set then linkgit:git-fetch[1]
- and linkgit:git-push[1] will use this command instead
- of `ssh` when they need to connect to a remote system.
- The 'GIT_SSH' command will be given exactly two arguments:
+ If this environment variable is set then 'git-fetch'
+ and 'git-push' will use this command instead
+ of 'ssh' when they need to connect to a remote system.
+ The '$GIT_SSH' command will be given exactly two arguments:
the 'username@host' (or just 'host') from the URL and the
shell command to execute on that remote system.
+
@@ -465,8 +517,8 @@ for further details.
'GIT_FLUSH'::
If this environment variable is set to "1", then commands such
- as git-blame (in incremental mode), git-rev-list, git-log,
- git-whatchanged, etc., will force a flush of the output stream
+ as 'git-blame' (in incremental mode), 'git-rev-list', 'git-log',
+ and 'git-whatchanged' will force a flush of the output stream
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
@@ -492,7 +544,7 @@ Discussion[[Discussion]]
More detail on the following is available from the
link:user-manual.html#git-concepts[git concepts chapter of the
-user-manual] and the link:core-tutorial.html[Core tutorial].
+user-manual] and linkgit:gitcore-tutorial[7].
A git project normally consists of a working directory with a ".git"
subdirectory at the top level. The .git directory contains, among other
@@ -553,6 +605,13 @@ The documentation for git suite was started by David Greaves
<david@dgreaves.com>, and later enhanced greatly by the
contributors on the git-list <git@vger.kernel.org>.
+SEE ALSO
+--------
+linkgit:gittutorial[7], linkgit:gittutorial-2[7],
+link:everyday.html[Everyday Git], linkgit:gitcvs-migration[7],
+linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
+linkgit:gitcli[7], link:user-manual.html[The Git User's Manual]
+
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 35a29fd60..db16b0ca5 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -63,6 +63,13 @@ path in question, and its parent directories (the further the
directory that contains `.gitattributes` is from the path in
question, the lower its precedence).
+If you wish to affect only a single repository (i.e., to assign
+attributes to files that are particular to one user's workflow), then
+attributes should be placed in the `$GIT_DIR/info/attributes` file.
+Attributes which should be version-controlled and distributed to other
+repositories (i.e., attributes of interest to all users) should go into
+`.gitattributes` files.
+
Sometimes you would need to override an setting of an attribute
for a path to `unspecified` state. This can be done by listing
the name of the attribute prefixed with an exclamation point `!`.
@@ -80,9 +87,9 @@ 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
+such as 'git-checkout' and 'git-merge' run. They also affect how
git stores the contents you prepare in the working tree in the
-repository upon `git add` and `git commit`.
+repository upon 'git-add' and 'git-commit'.
`crlf`
^^^^^^
@@ -133,6 +140,26 @@ When `core.autocrlf` is set to "input", line endings are
converted to LF upon checkin, but there is no conversion done
upon checkout.
+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
+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...
+
+- 'git-add' itself does not touch the files in the work tree, the
+ next checkout would, so the safety triggers;
+
+- 'git-apply' to update a text file with a patch does touch the files
+ in the work tree, but the operation is about text files and CRLF
+ conversion is about fixing the line ending inconsistencies, so the
+ safety does not trigger;
+
+- 'git-diff' itself does not touch the files in the work tree, it is
+ often run to inspect the changes you intend to next 'git-add'. To
+ catch potential problems early, safety triggers.
+
`ident`
^^^^^^^
@@ -187,7 +214,7 @@ with `crlf`, and then `ident` and fed to `filter`.
Generating diff text
~~~~~~~~~~~~~~~~~~~~
-The attribute `diff` affects if `git diff` generates textual
+The attribute `diff` affects if 'git-diff' generates textual
patch for the path or just says `Binary files differ`. It also
can affect what line is shown on the hunk header `@@ -k,l +n,m @@`
line.
@@ -238,7 +265,7 @@ 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.
-See linkgit:git[7] for details.
+See linkgit:git[1] for details.
Defining a custom hunk-header
@@ -251,7 +278,7 @@ is prefixed with a line of the form:
The text is called 'hunk header', and by default a line that
begins with an alphabet, an underscore or a dollar sign is used,
-which matches what GNU `diff -p` output uses. This default
+which matches what GNU 'diff -p' output uses. This default
selection however is not suited for some contents, and you can
use customized pattern to make a selection.
@@ -280,9 +307,18 @@ backslash, and zero or more occurrences of `sub` followed by
There are a few built-in patterns to make this easier, and `tex`
is one of them, so you do not have to write the above in your
configuration file (you still need to enable this with the
-attribute mechanism, via `.gitattributes`). Another built-in
-pattern is defined for `java` that defines a pattern suitable
-for program text in Java language.
+attribute mechanism, via `.gitattributes`). The following built in
+patterns are available:
+
+- `bibtex` suitable for files with BibTeX coded references.
+
+- `java` suitable for source code in the Java lanugage.
+
+- `pascal` suitable for source code in the Pascal/Delphi language.
+
+- `ruby` suitable for source code in the Ruby language.
+
+- `tex` suitable for source code for LaTeX documents.
Performing a three-way merge
@@ -295,7 +331,7 @@ and other programs such as `git revert` and `git cherry-pick`.
Set::
Built-in 3-way merge driver is used to merge the
- contents in a way similar to `merge` command of `RCS`
+ contents in a way similar to 'merge' command of `RCS`
suite. This is suitable for ordinary text files.
Unset::
@@ -399,7 +435,7 @@ Checking whitespace errors
^^^^^^^^^^^^
The `core.whitespace` configuration variable allows you to define what
-`diff` and `apply` should consider whitespace errors for all paths in
+'diff' and 'apply' should consider whitespace errors for all paths in
the project (See linkgit:git-config[1]). This attribute gives you finer
control per path.
@@ -423,6 +459,29 @@ String::
variable.
+Creating an archive
+~~~~~~~~~~~~~~~~~~~
+
+`export-ignore`
+^^^^^^^^^^^^^^^
+
+Files and directories with the attribute `export-ignore` won't be added to
+archive files.
+
+`export-subst`
+^^^^^^^^^^^^^^
+
+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
+tag then no replacement will be done. The placeholders are the same
+as those for the option `--pretty=format:` of linkgit:git-log[1],
+except that they need to be wrapped like this: `$Format:PLACEHOLDERS$`
+in the file. E.g. the string `$Format:%H$` will be replaced by the
+commit hash.
+
+
EXAMPLE
-------
@@ -472,23 +531,7 @@ frotz unspecified
----------------------------------------------------------------
-Creating an archive
-~~~~~~~~~~~~~~~~~~~
-
-`export-subst`
-^^^^^^^^^^^^^^
-
-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
-tag then no replacement will be done. The placeholders are the same
-as those for the option `--pretty=format:` of linkgit:git-log[1],
-except that they need to be wrapped like this: `$Format:PLACEHOLDERS$`
-in the file. E.g. the string `$Format:%H$` will be replaced by the
-commit hash.
-
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitcli.txt b/Documentation/gitcli.txt
index 7ee5ce386..29e5929db 100644
--- a/Documentation/gitcli.txt
+++ b/Documentation/gitcli.txt
@@ -1,4 +1,4 @@
-gitcli(5)
+gitcli(7)
=========
NAME
@@ -13,8 +13,37 @@ gitcli
DESCRIPTION
-----------
-This manual describes best practice in how to use git CLI. Here are
-the rules that you should follow when you are scripting git:
+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
+arguments. Here are the rules:
+
+ * Revisions come first and then paths.
+ E.g. in `git diff v1.0 v2.0 arch/x86 include/asm-x86`,
+ `v1.0` and `v2.0` are revisions and `arch/x86` and `include/asm-x86`
+ are paths.
+
+ * When an argument can be misunderstood as either a revision or a path,
+ they can be disambiguated by placing `\--` between them.
+ E.g. `git diff \-- HEAD` is, "I have a file called HEAD in my work
+ tree. Please show changes between the version I staged in the index
+ and what I have in the work tree for that file". not "show difference
+ 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
+ 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
+ disambiguate.
+
+When writing a script that is expected to handle random user-input, it is
+a good practice to make it explicit which arguments are which by placing
+disambiguating `\--` at appropriate places.
+
+Here are the rules regarding the "flags" that you should follow when you are
+scripting git:
* it's preferred to use the non dashed form of git commands, which means that
you should prefer `"git foo"` to `"git-foo"`.
@@ -34,8 +63,8 @@ the rules that you should follow when you are scripting git:
if you happen to have a file called `HEAD` in the work tree.
-ENHANCED CLI
-------------
+ENHANCED OPTION PARSER
+----------------------
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.
@@ -104,10 +133,46 @@ $ git describe --abbrev 10 HEAD # NOT WHAT YOU MEANT
----------------------------
+NOTES ON FREQUENTLY CONFUSED OPTIONS
+------------------------------------
+
+Many commands that can work on files in the working tree
+and/or in the index can take `--cached` and/or `--index`
+options. Sometimes people incorrectly think that, because
+the index was originally called cache, these two are
+synonyms. They are *not* -- these two options mean very
+different things.
+
+ * The `--cached` option is used to ask a command that
+ usually works on files in the working tree to *only* work
+ with the index. For example, `git grep`, when used
+ without a commit to specify from which commit to look for
+ strings in, usually works on files in the working tree,
+ but with the `--cached` option, it looks for strings in
+ the index.
+
+ * The `--index` option is used to ask a command that
+ usually works on files in the working tree to *also*
+ affect the index. For example, `git stash apply` usually
+ merges changes recorded in a stash to the working tree,
+ but with the `--index` option, it also merges changes to
+ the index as well.
+
+`git apply` command can be used with `--cached` and
+`--index` (but not at the same time). Usually the command
+only affects the files in the working tree, but with
+`--index`, it patches both the files and their index
+entries, and with `--cached`, it modifies only the index
+entries.
+
+See also http://marc.info/?l=git&m=116563135620359 and
+http://marc.info/?l=git&m=119150393620273 for further
+information.
+
Documentation
-------------
-Documentation by Pierre Habouzit.
+Documentation by Pierre Habouzit and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/core-tutorial.txt b/Documentation/gitcore-tutorial.txt
index aa40dfd36..a417e592a 100644
--- a/Documentation/core-tutorial.txt
+++ b/Documentation/gitcore-tutorial.txt
@@ -1,15 +1,23 @@
-A git core tutorial for developers
-==================================
+gitcore-tutorial(7)
+===================
-Introduction
-------------
+NAME
+----
+gitcore-tutorial - A git core tutorial for developers
+
+SYNOPSIS
+--------
+git *
+
+DESCRIPTION
+-----------
This tutorial explains how to use the "core" git programs to set up and
work with a git repository.
If you just need to use git as a revision control system you may prefer
-to start with link:tutorial.html[a tutorial introduction to git] or
-link:user-manual.html[the git user manual].
+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.
@@ -34,14 +42,14 @@ one for a totally new project, or an existing working tree that you want
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`.
+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
$ cd git-tutorial
-$ git-init
+$ git init
------------------------------------------------
to which git will reply
@@ -53,7 +61,7 @@ Initialized empty Git repository in .git/
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
+inspect that with 'ls'. For your new empty project, it should show you
three entries, among other things:
- a file called `HEAD`, that has `ref: refs/heads/master` in it.
@@ -100,8 +108,7 @@ references in these `refs` subdirectories when you actually start
populating your tree.
[NOTE]
-An advanced user may want to take a look at the
-link:repository-layout.html[repository layout] document
+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
@@ -132,7 +139,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
-to your working tree, you use the `git-update-index` program. That
+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
(or remove existing ones) unless you explicitly tell it that you're
@@ -142,7 +149,7 @@ adding a new entry with the `\--add` flag (or removing an entry with the
So to populate the index with the two files you just created, you can do
------------------------------------------------
-$ git-update-index --add hello example
+$ git update-index --add hello example
------------------------------------------------
and you have now told git to track those two files.
@@ -166,19 +173,19 @@ and see two files:
which correspond with the objects with names of `557db...` and
`f24c7...` respectively.
-If you want to, you can use `git-cat-file` to look at those objects, but
+If you want to, you can use 'git-cat-file' to look at those objects, but
you'll have to use the object name, not the filename of the object:
----------------
-$ git-cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
+$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
----------------
-where the `-t` tells `git-cat-file` to tell you what the "type" of the
+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
regular file), and you can see the contents with
----------------
-$ git-cat-file "blob" 557db03
+$ git cat-file "blob" 557db03
----------------
which will print out "Hello World". The object `557db03` is nothing
@@ -198,7 +205,7 @@ hexadecimal digits in most places.
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
+was just to show that 'git-update-index' did something magical, and
actually saved away the contents of your files into the git object
database.
@@ -221,22 +228,22 @@ $ 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
-`git-diff-files` command:
+'git-diff-files' command:
------------
-$ git-diff-files
+$ git diff-files
------------
Oops. That wasn't very readable. It just spit out its own internal
-version of a `diff`, but that internal version really just tells you
+version of a 'diff', but that internal version really just tells you
that it has noticed that "hello" has been modified, and that the old object
contents it had have been replaced with something else.
-To make it readable, we can tell git-diff-files to output the
+To make it readable, we can tell 'git-diff-files' to output the
differences as a patch, using the `-p` flag:
------------
-$ git-diff-files -p
+$ git diff-files -p
diff --git a/hello b/hello
index 557db03..263414f 100644
--- a/hello
@@ -248,11 +255,11 @@ index 557db03..263414f 100644
i.e. the diff of the change we caused by adding another line to `hello`.
-In other words, `git-diff-files` always shows us the difference between
+In other words, 'git-diff-files' always shows us the difference between
what is recorded in the index, and what is currently in the working
tree. That's very useful.
-A common shorthand for `git-diff-files -p` is to just write `git
+A common shorthand for `git diff-files -p` is to just write `git
diff`, which will do the same thing.
------------
@@ -276,15 +283,15 @@ 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.
-Creating a tree object is trivial, and is done with `git-write-tree`.
-There are no options or other input: git-write-tree will take the
+Creating a tree object is trivial, and is done with 'git-write-tree'.
+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:
------------------------------------------------
-$ git-write-tree
+$ git write-tree
------------------------------------------------
and this will just output the name of the resulting tree, in this case
@@ -295,34 +302,34 @@ and this will just output the name of the resulting tree, in this case
----------------
which is another incomprehensible object name. Again, if you want to,
-you can use `git-cat-file -t 8988d\...` to see that this time the object
+you can use `git cat-file -t 8988d\...` to see that this time the object
is not a "blob" object, but a "tree" object (you can also use
-`git-cat-file` to actually output the raw object contents, but you'll see
+`git cat-file` to actually output the raw object contents, but you'll see
mainly a binary mess, so that's less interesting).
-However -- normally you'd never use `git-write-tree` on its own, because
+However -- normally you'd never use 'git-write-tree' on its own, because
normally you always commit a tree into a commit object using the
-`git-commit-tree` command. In fact, it's easier to not actually use
-`git-write-tree` on its own at all, but to just pass its result in as an
-argument to `git-commit-tree`.
+'git-commit-tree' command. In fact, it's easier to not actually use
+'git-write-tree' on its own at all, but to just pass its result in as an
+argument to 'git-commit-tree'.
-`git-commit-tree` normally takes several arguments -- it wants to know
+'git-commit-tree' normally takes several arguments -- it wants to know
what the 'parent' of a commit was, but since this is the first commit
ever in this new repository, and it has no parents, we only need to pass in
-the object name of the tree. However, `git-commit-tree` also wants to get a
+the object name of the tree. However, 'git-commit-tree' also wants to get a
commit message on its standard input, and it will write out the resulting
object name for the commit to its standard output.
And this is where we create the `.git/refs/heads/master` file
which is pointed at by `HEAD`. This file is supposed to contain
the reference to the top-of-tree of the master branch, and since
-that's exactly what `git-commit-tree` spits out, we can do this
+that's exactly what 'git-commit-tree' spits out, we can do this
all with a sequence of simple shell commands:
------------------------------------------------
-$ tree=$(git-write-tree)
-$ commit=$(echo 'Initial commit' | git-commit-tree $tree)
-$ git-update-ref HEAD $commit
+$ tree=$(git write-tree)
+$ commit=$(echo 'Initial commit' | git commit-tree $tree)
+$ git update-ref HEAD $commit
------------------------------------------------
In this case this creates a totally new commit that is not related to
@@ -338,37 +345,37 @@ instead, and it would have done the above magic scripting for you.
Making a change
---------------
-Remember how we did the `git-update-index` on file `hello` and then we
+Remember how we did the 'git-update-index' on file `hello` and then we
changed `hello` afterward, and could compare the new state of `hello` with the
state we saved in the index file?
-Further, remember how I said that `git-write-tree` writes the contents
+Further, remember how I said that 'git-write-tree' writes the contents
of the *index* file to the tree, and thus what we just committed was in
fact the *original* contents of the file `hello`, not the new ones. We did
that on purpose, to show the difference between the index state, and the
state in the working tree, and how they don't have to match, even
when we commit things.
-As before, if we do `git-diff-files -p` in our git-tutorial project,
+As before, if we do `git diff-files -p` in our git-tutorial project,
we'll still see the same difference we saw last time: the index file
hasn't changed by the act of committing anything. However, now that we
have committed something, we can also learn to use a new command:
-`git-diff-index`.
+'git-diff-index'.
-Unlike `git-diff-files`, which showed the difference between the index
-file and the working tree, `git-diff-index` shows the differences
+Unlike 'git-diff-files', which showed the difference between the index
+file and the working tree, 'git-diff-index' shows the differences
between a committed *tree* and either the index file or the working
-tree. In other words, `git-diff-index` wants a tree to be diffed
+tree. In other words, 'git-diff-index' wants a tree to be diffed
against, and before we did the commit, we couldn't do that, because we
didn't have anything to diff against.
But now we can do
----------------
-$ git-diff-index -p HEAD
+$ git diff-index -p HEAD
----------------
-(where `-p` has the same meaning as it did in `git-diff-files`), and it
+(where `-p` has the same meaning as it did in 'git-diff-files'), and it
will show us the same difference, but for a totally different reason.
Now we're comparing the working tree not against the index file,
but against the tree we just wrote. It just so happens that those two
@@ -383,16 +390,16 @@ $ git diff HEAD
which ends up doing the above for you.
-In other words, `git-diff-index` normally compares a tree against the
+In other words, 'git-diff-index' normally compares a tree against the
working tree, but when given the `\--cached` flag, it is told to
instead compare against just the index cache contents, and ignore the
current working tree state entirely. Since we just wrote the index
-file to HEAD, doing `git-diff-index \--cached -p HEAD` should thus return
+file to HEAD, doing `git diff-index \--cached -p HEAD` should thus return
an empty set of differences, and that's exactly what it does.
[NOTE]
================
-`git-diff-index` really always uses the index for its
+'git-diff-index' really always uses the index for its
comparisons, and saying that it compares a tree against the working
tree is thus not strictly accurate. In particular, the list of
files to compare (the "meta-data") *always* comes from the index file,
@@ -415,17 +422,17 @@ work through the index file, so the first thing we need to do is to
update the index cache:
------------------------------------------------
-$ git-update-index hello
+$ git update-index hello
------------------------------------------------
(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-\*` versions here. After
-we've updated `hello` in the index, `git-diff-files -p` now shows no
-differences, but `git-diff-index -p HEAD` still *does* show that the
+Note what happens to the different 'git-diff-\*' versions here. After
+we've updated `hello` in the index, `git diff-files -p` now shows no
+differences, but `git diff-index -p HEAD` still *does* show that the
current state is different from the state we committed. In fact, now
-`git-diff-index` shows the same difference whether we use the `--cached`
+'git-diff-index' shows the same difference whether we use the `--cached`
flag or not, since now the index is coherent with the working tree.
Now, since we've updated `hello` in the index, we can commit the new
@@ -453,7 +460,7 @@ 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
-commit itself (`git-commit`).
+commit itself ('git-commit').
Inspecting Changes
@@ -461,16 +468,16 @@ Inspecting Changes
While creating changes is useful, it's even more useful if you can tell
later what changed. The most useful command for this is another of the
-`diff` family, namely `git-diff-tree`.
+'diff' family, namely 'git-diff-tree'.
-`git-diff-tree` can be given two arbitrary trees, and it will tell you the
+'git-diff-tree' can be given two arbitrary trees, and it will tell you the
differences between them. Perhaps even more commonly, though, you can
give it just a single commit object, and it will figure out the parent
of that commit itself, and show the difference directly. Thus, to get
the same diff that we've already seen several times, we can now do
----------------
-$ git-diff-tree -p HEAD
+$ git diff-tree -p HEAD
----------------
(again, `-p` means to show the difference as a human-readable patch),
@@ -511,15 +518,15 @@ various diff-\* commands compare things.
+-----------+
============
-More interestingly, you can also give `git-diff-tree` the `--pretty` flag,
+More interestingly, you can also give 'git-diff-tree' the `--pretty` flag,
which tells it to also show the commit message and author and date of the
commit, and you can tell it to show a whole series of diffs.
Alternatively, you can tell it to be "silent", and not show the diffs at
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
+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
activities.
@@ -535,25 +542,25 @@ with the associated patches use the more complex (and much more
powerful)
----------------
-$ git-whatchanged -p --root
+$ git whatchanged -p
----------------
and you will see exactly what has changed in the repository over its
short history.
[NOTE]
-The `\--root` flag is a flag to `git-diff-tree` to tell it to
-show the initial aka 'root' commit too. Normally you'd probably not
-want to see the initial import diff, but since the tutorial project
-was started from scratch and is so small, we use it to make the result
-a bit more interesting.
+When using the above two commands, the initial commit will be shown.
+If this is a problem because it is huge, you can hide it by setting
+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
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'.
@@ -588,7 +595,7 @@ 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
that tag. You create these annotated tags with either the `-a` or
-`-s` flag to `git tag`:
+`-s` flag to 'git-tag':
----------------
$ git tag -s <tagname>
@@ -635,7 +642,7 @@ 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
- is `git clone` command, but if all you want to do is just to
+ 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`.
@@ -646,31 +653,31 @@ 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
+
----------------
-$ git-update-index --refresh
+$ 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
-`scp`, `rsync` or `wget`.
+'scp', 'rsync' or 'wget'.
When copying a remote repository, you'll want to at a minimum update the
index cache when you do this, and especially with other peoples'
repositories you often want to make sure that the index cache is in some
known state (you don't know *what* they've done and not yet checked in),
-so usually you'll precede the `git-update-index` with a
+so usually you'll precede the 'git-update-index' with a
----------------
-$ git-read-tree --reset HEAD
-$ git-update-index --refresh
+$ git read-tree --reset HEAD
+$ git update-index --refresh
----------------
which will force a total index re-build from the tree pointed to by `HEAD`.
-It resets the index contents to `HEAD`, and then the `git-update-index`
+It resets the index contents to `HEAD`, and then the 'git-update-index'
makes sure to match up all index entries with the checked-out files.
If the original repository had uncommitted changes in its
-working tree, `git-update-index --refresh` notices them and
+working tree, `git update-index --refresh` notices them and
tells you they need to be updated.
The above can also be written as simply
@@ -682,8 +689,8 @@ $ git reset
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 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.
Many (most?) public remote repositories will not contain any of
@@ -706,7 +713,7 @@ $ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git
followed by
----------------
-$ git-read-tree HEAD
+$ git read-tree HEAD
----------------
to populate the index. However, now you have populated the index, and
@@ -715,14 +722,14 @@ actually have any of the working tree files to work on. To get
those, you'd check them out with
----------------
-$ git-checkout-index -u -a
+$ git checkout-index -u -a
----------------
where the `-u` flag means that you want the checkout to keep the index
up-to-date (so that you don't have to refresh it afterward), and the
`-a` flag means "check out all files" (if you have a stale copy or an
older version of a checked out tree you may also need to add the `-f`
-flag first, to tell git-checkout-index to *force* overwriting of any old
+flag first, to tell 'git-checkout-index' to *force* overwriting of any old
files).
Again, this can all be simplified with
@@ -769,7 +776,7 @@ to it.
================================================
If you make the decision to start your new branch at some
other point in the history than the current `HEAD`, you can do so by
-just telling `git checkout` what the base of the checkout would be.
+just telling 'git-checkout' what the base of the checkout would be.
In other words, if you have an earlier tag or branch, you'd just do
------------
@@ -812,7 +819,7 @@ $ git branch <branchname> [startingpoint]
which will simply _create_ the branch, but will not do anything further.
You can then later -- once you decide that you want to actually develop
-on that branch -- switch to that branch with a regular `git checkout`
+on that branch -- switch to that branch with a regular 'git-checkout'
with the branchname as the argument.
@@ -832,7 +839,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
+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
the index file so far when making the commit). The `-m` flag is to give the
@@ -871,10 +878,10 @@ means: normally it will just show you your current `HEAD`) and their
histories. You can also see exactly how they came to be from a common
source.
-Anyway, let's exit `gitk` (`^Q` or the File menu), and decide that we want
+Anyway, let's exit 'gitk' (`^Q` or the File menu), and decide that we want
to merge the work we did on the `mybranch` branch into the `master`
branch (which is currently our `HEAD` too). To do that, there's a nice
-script called `git merge`, which wants to know which branches you want
+script called 'git-merge', which wants to know which branches you want
to resolve and what the merge is all about:
------------
@@ -918,7 +925,7 @@ $ git commit -i hello
which will very loudly warn you that you're now committing a merge
(which is correct, so never mind), and you can write a small merge
-message about your adventures in git-merge-land.
+message about your adventures in 'git-merge'-land.
After you're done, start up `gitk \--all` to see graphically what the
history looks like. Notice that `mybranch` still exists, and you can
@@ -931,7 +938,7 @@ Another useful tool, especially if you do not always work in X-Window
environment, is `git show-branch`.
------------------------------------------------
-$ git-show-branch --topo-order --more=1 master mybranch
+$ git show-branch --topo-order --more=1 master mybranch
* [master] Merge work in mybranch
! [mybranch] Some work.
--
@@ -956,14 +963,14 @@ commits from the master branch. The string inside brackets
before the commit log message is a short name you can use to
name the commit. In the above example, 'master' and 'mybranch'
are branch heads. 'master^' is the first parent of 'master'
-branch head. Please see 'git-rev-parse' documentation if you
+branch head. Please see linkgit:git-rev-parse[1] if you want to
see more complex cases.
[NOTE]
Without the '--more=1' option, 'git-show-branch' would not output the
'[master^]' commit, as '[mybranch]' commit is a common ancestor of
-both 'master' and 'mybranch' tips. Please see 'git-show-branch'
-documentation for details.
+both 'master' and 'mybranch' tips. Please see linkgit:git-show-branch[1]
+for details.
[NOTE]
If there were more commits on the 'master' branch after the merge, the
@@ -974,7 +981,7 @@ merge commit visible in this case.
Now, let's pretend you are the one who did all the work in
`mybranch`, and the fruit of your hard work has finally been merged
to the `master` branch. Let's go back to `mybranch`, and run
-`git merge` to get the "upstream changes" back to your branch.
+'git-merge' to get the "upstream changes" back to your branch.
------------
$ git checkout mybranch
@@ -999,7 +1006,7 @@ the tree of your branch to that of the `master` branch. This is
often called 'fast forward' merge.
You can run `gitk \--all` again to see how the commit ancestry
-looks like, or run `show-branch`, which tells you this.
+looks like, or run 'show-branch', which tells you this.
------------------------------------------------
$ git show-branch master mybranch
@@ -1016,12 +1023,12 @@ 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
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
+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"
-followed by a `git merge`.
+followed by a 'git-merge'.
Fetching from a remote repository is done by, unsurprisingly,
-`git fetch`:
+'git-fetch':
----------------
$ git fetch <remote-repository>
@@ -1059,9 +1066,9 @@ most efficient way to exchange git objects between repositories.
Local directory::
`/path/to/repo.git/`
+
-This transport is the same as SSH transport but uses `sh` to run
+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`.
+the remote machine via 'ssh'.
git Native::
`git://remote.machine/path/to/repo.git/`
@@ -1088,7 +1095,7 @@ 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
that does not even support directory index would suffice. But
-you must prepare your repository with `git-update-server-info`
+you must prepare your repository with 'git-update-server-info'
to help dumb transport downloaders.
Once you fetch from the remote repository, you `merge` that
@@ -1108,7 +1115,7 @@ argument.
[NOTE]
You could do without using any branches at all, by
keeping as many local repositories as you would like to have
-branches, and merging between them with `git pull`, just like
+branches, and merging between them with 'git-pull', just like
you merge between branches. The advantage of this approach is
that it lets you keep a set of files for each `branch` checked
out and you may find it easier to switch back and forth if you
@@ -1125,7 +1132,7 @@ like this:
$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/
------------------------------------------------
-and use the "linus" keyword with `git pull` instead of the full URL.
+and use the "linus" keyword with 'git-pull' instead of the full URL.
Examples.
@@ -1161,7 +1168,7 @@ $ git show-branch --more=2 master mybranch
+* [master^] Some fun.
------------
-Remember, before running `git merge`, our `master` head was at
+Remember, before running 'git-merge', our `master` head was at
"Some fun." commit, while our `mybranch` head was at "Some
work." commit.
@@ -1188,10 +1195,10 @@ Now we are ready to experiment with the merge by hand.
`git merge` command, when merging two branches, uses 3-way merge
algorithm. First, it finds the common ancestor between them.
-The command it uses is `git-merge-base`:
+The command it uses is 'git-merge-base':
------------
-$ mb=$(git-merge-base HEAD mybranch)
+$ mb=$(git merge-base HEAD mybranch)
------------
The command writes the commit object name of the common ancestor
@@ -1201,7 +1208,7 @@ ancestor commit is the "New day." commit in this case. You can
tell it by:
------------
-$ git-name-rev $mb
+$ git name-rev $mb
my-first-tag
------------
@@ -1209,10 +1216,10 @@ After finding out a common ancestor commit, the second step is
this:
------------
-$ git-read-tree -m -u $mb HEAD mybranch
+$ git read-tree -m -u $mb HEAD mybranch
------------
-This is the same `git-read-tree` command we have already seen,
+This is the same 'git-read-tree' command we have already seen,
but it takes three trees, unlike previous examples. This reads
the contents of each tree into different 'stage' in the index
file (the first tree goes to stage 1, the second to stage 2,
@@ -1228,7 +1235,7 @@ trees are left in non-zero stages. At this point, you can
inspect the index file with this command:
------------
-$ git-ls-files --stage
+$ git ls-files --stage
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
@@ -1245,7 +1252,7 @@ stages.
To look at only non-zero stages, use `\--unmerged` flag:
------------
-$ git-ls-files --unmerged
+$ git ls-files --unmerged
100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello
@@ -1253,29 +1260,29 @@ $ git-ls-files --unmerged
The next step of merging is to merge these three versions of the
file, using 3-way merge. This is done by giving
-`git-merge-one-file` command as one of the arguments to
-`git-merge-index` command:
+'git-merge-one-file' command as one of the arguments to
+'git-merge-index' command:
------------
-$ git-merge-index git-merge-one-file hello
+$ git merge-index git-merge-one-file hello
Auto-merging hello.
merge: warning: conflicts during merge
ERROR: Merge conflict in hello.
fatal: merge program failed
------------
-`git-merge-one-file` script is called with parameters to
+'git-merge-one-file' script is called with parameters to
describe those three versions, and is responsible to leave the
merge results in the working tree.
It is a fairly straightforward shell script, and
-eventually calls `merge` program from RCS suite to perform a
-file-level 3-way merge. In this case, `merge` detects
+eventually calls 'merge' program from RCS suite to perform a
+file-level 3-way merge. In this case, 'merge' detects
conflicts, and the merge result with conflict marks is left in
the working tree.. This can be seen if you run `ls-files
--stage` again at this point:
------------
-$ git-ls-files --stage
+$ git ls-files --stage
100644 7f8b141b65fdcee47321e399a2598a235a032422 0 example
100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello
100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello
@@ -1283,9 +1290,9 @@ $ git-ls-files --stage
------------
This is the state of the index file and the working file after
-`git merge` returns control back to you, leaving the conflicting
+'git-merge' returns control back to you, leaving the conflicting
merge for you to resolve. Notice that the path `hello` is still
-unmerged, and what you see with `git diff` at this point is
+unmerged, and what you see with 'git-diff' at this point is
differences since stage 2 (i.e. your version).
@@ -1313,7 +1320,7 @@ 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
the remote machine. You need to have an SSH account there to
-run a single command, `git-receive-pack`.
+run a single command, 'git-receive-pack'.
First, you need to create an empty repository on the remote
machine that will house your public repository. This empty
@@ -1322,8 +1329,8 @@ into it later. Obviously, this repository creation needs to be
done only once.
[NOTE]
-`git push` uses a pair of programs,
-`git-send-pack` on your local machine, and `git-receive-pack`
+'git-push' uses a pair of programs,
+'git-send-pack' on your local machine, and 'git-receive-pack'
on the remote machine. The communication between the two over
the network internally uses an SSH connection.
@@ -1338,30 +1345,31 @@ $ mkdir my-git.git
------------
Then, make that directory into a git repository by running
-`git init`, but this time, since its name is not the usual
+'git-init', but this time, since its name is not the usual
`.git`, we do things slightly differently:
------------
-$ GIT_DIR=my-git.git git-init
+$ GIT_DIR=my-git.git git init
------------
Make sure this directory is available for others you want your
changes to be pulled by via the transport of your choice. Also
-you need to make sure that you have the `git-receive-pack`
+you need to make sure that you have the 'git-receive-pack'
program on the `$PATH`.
[NOTE]
Many installations of sshd do not invoke your shell as the login
shell when you directly run programs; what this means is that if
-your login shell is `bash`, only `.bashrc` is read and not
+your login shell is 'bash', only `.bashrc` is read and not
`.bash_profile`. As a workaround, make sure `.bashrc` sets up
-`$PATH` so that you can run `git-receive-pack` program.
+`$PATH` so that you can run 'git-receive-pack' program.
[NOTE]
If you plan to publish this repository to be accessed over http,
-you should do `chmod +x my-git.git/hooks/post-update` at this
-point. This makes sure that every time you push into this
-repository, `git-update-server-info` is run.
+you should do `mv my-git.git/hooks/post-update.sample
+my-git.git/hooks/post-update` at this point.
+This makes sure that every time you push into this
+repository, `git update-server-info` is run.
Your "public repository" is now ready to accept your changes.
Come back to the machine you have your private repository. From
@@ -1400,7 +1408,7 @@ $ git repack
will do it for you. If you followed the tutorial examples, you
would have accumulated about 17 objects in `.git/objects/??/`
-directories by now. `git repack` tells you how many objects it
+directories by now. 'git-repack' tells you how many objects it
packed, and stores the packed file in `.git/objects/pack`
directory.
@@ -1413,7 +1421,7 @@ them together. The former holds all the data from the objects
in the pack, and the latter holds the index for random
access.
-If you are paranoid, running `git-verify-pack` command would
+If you are paranoid, running 'git-verify-pack' command would
detect if you have a corrupt pack, but do not worry too much.
Our programs are always perfect ;-).
@@ -1479,18 +1487,18 @@ A recommended workflow for a "project lead" goes like this:
If other people are pulling from your repository over dumb
transport protocols (HTTP), you need to keep this repository
'dumb transport friendly'. After `git init`,
-`$GIT_DIR/hooks/post-update` copied from the standard templates
-would contain a call to `git-update-server-info` but the
-`post-update` hook itself is disabled by default -- enable it
-with `chmod +x post-update`. This makes sure `git-update-server-info`
-keeps the necessary files up-to-date.
+`$GIT_DIR/hooks/post-update.sample` copied from the standard templates
+would contain a call to 'git-update-server-info'
+but you need to manually enable the hook with
+`mv post-update.sample post-update`. This makes sure
+'git-update-server-info' keeps the necessary files up-to-date.
3. Push into the public repository from your primary
repository.
-4. `git repack` the public repository. This establishes a big
+4. 'git-repack' the public repository. This establishes a big
pack that contains the initial set of objects as the
- baseline, and possibly `git prune` if the transport
+ baseline, and possibly 'git-prune' if the transport
used for pulling from your repository supports packed
repositories.
@@ -1504,14 +1512,14 @@ You can repack this private repository whenever you feel like.
6. Push your changes to the public repository, and announce it
to the public.
-7. Every once in a while, "git repack" the public repository.
+7. Every once in a while, "git-repack" the public repository.
Go back to step 5. and continue working.
A recommended work cycle for a "subsystem maintainer" who works
on that project and has an own "public repository" goes like this:
-1. Prepare your work repository, by `git clone` the public
+1. Prepare your work repository, by 'git-clone' the public
repository of the "project lead". The URL used for the
initial cloning is stored in the remote.origin.url
configuration variable.
@@ -1526,7 +1534,7 @@ on that project and has an own "public repository" goes like this:
point at the repository you are borrowing from.
4. Push into the public repository from your primary
- repository. Run `git repack`, and possibly `git prune` if the
+ repository. Run 'git-repack', and possibly 'git-prune' if the
transport used for pulling from your repository supports
packed repositories.
@@ -1543,7 +1551,7 @@ like.
"project lead" and possibly your "sub-subsystem
maintainers" to pull from it.
-7. Every once in a while, `git repack` the public repository.
+7. Every once in a while, 'git-repack' the public repository.
Go back to step 5. and continue working.
@@ -1551,7 +1559,7 @@ A recommended work cycle for an "individual developer" who does
not have a "public" repository is somewhat different. It goes
like this:
-1. Prepare your work repository, by `git clone` the public
+1. Prepare your work repository, by 'git-clone' the public
repository of the "project lead" (or a "subsystem
maintainer", if you work on a subsystem). The URL used for
the initial cloning is stored in the remote.origin.url
@@ -1581,7 +1589,7 @@ suggested in the previous section may be new to you. You do not
have to worry. git supports "shared public repository" style of
cooperation you are probably more familiar with as well.
-See link:cvs-migration.html[git for CVS users] for the details.
+See linkgit:gitcvs-migration[7] for the details.
Bundling your work together
---------------------------
@@ -1648,9 +1656,9 @@ branch before these two merges by resetting it to 'master~2':
$ git reset --hard master~2
------------
-You can make sure 'git show-branch' matches the state before
-those two 'git merge' you just did. Then, instead of running
-two 'git merge' commands in a row, you would merge these two
+You can make sure `git show-branch` matches the state before
+those two 'git-merge' you just did. Then, instead of running
+two 'git-merge' commands in a row, you would merge these two
branch heads (this is known as 'making an Octopus'):
------------
@@ -1679,3 +1687,13 @@ merge two at a time, documenting how you resolved the conflicts,
and the reason why you preferred changes made in one side over
the other. Otherwise it would make the project history harder
to follow, not easier.
+
+SEE ALSO
+--------
+linkgit:gittutorial[7], linkgit:gittutorial-2[7],
+linkgit:everyday[7], linkgit:gitcvs-migration[7],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/cvs-migration.txt b/Documentation/gitcvs-migration.txt
index ea9890022..aaa7ef737 100644
--- a/Documentation/cvs-migration.txt
+++ b/Documentation/gitcvs-migration.txt
@@ -1,5 +1,16 @@
-git for CVS users
-=================
+gitcvs-migration(7)
+===================
+
+NAME
+----
+gitcvs-migration - git for CVS users
+
+SYNOPSIS
+--------
+git cvsimport *
+
+DESCRIPTION
+-----------
Git differs from CVS in that every working tree contains a repository with
a full copy of the project history, and no repository is inherently more
@@ -7,8 +18,9 @@ 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. This
-link:tutorial.html[tutorial introduction to git] should be sufficient.
+Some basic familiarity with git is required. Having gone through
+linkgit:gittutorial[7] and
+linkgit:gitglossary[7] should be sufficient.
Developing against a shared repository
--------------------------------------
@@ -22,7 +34,7 @@ $ git clone foo.com:/pub/repo.git/ my-project
$ cd my-project
------------------------------------------------
-and hack away. The equivalent of `cvs update` is
+and hack away. The equivalent of 'cvs update' is
------------------------------------------------
$ git pull origin
@@ -34,28 +46,28 @@ them first before running git pull.
[NOTE]
================================
-The `pull` command knows where to get updates from because of certain
-configuration variables that were set by the first `git clone`
+The 'pull' command knows where to get updates from because of certain
+configuration variables that were set by the first 'git-clone'
command; see `git config -l` and the linkgit:git-config[1] man
page for details.
================================
You can update the shared repository with your changes by first committing
-your changes, and then using the linkgit:git-push[1] command:
+your changes, and then using the 'git-push' command:
------------------------------------------------
$ git push origin master
------------------------------------------------
to "push" those commits to the shared repository. If someone else has
-updated the repository more recently, `git push`, like `cvs commit`, will
+updated the repository more recently, 'git-push', like 'cvs commit', will
complain, in which case you must pull any changes before attempting the
push again.
-In the `git push` command above we specify the name of the remote branch
-to update (`master`). If we leave that out, `git push` tries to update
+In the 'git-push' command above we specify the name of the remote branch
+to update (`master`). If we leave that out, 'git-push' tries to update
any branches in the remote repository that have the same name as a branch
-in the local repository. So the last `push` can be done with either of:
+in the local repository. So the last 'push' can be done with either of:
------------
$ git push origin
@@ -69,8 +81,8 @@ Setting Up a Shared Repository
------------------------------
We assume you have already created a git repository for your project,
-possibly created from scratch or from a tarball (see the
-link:tutorial.html[tutorial]), or imported from an already existing CVS
+possibly created from scratch or from a tarball (see
+linkgit:gittutorial[7]), or imported from an already existing CVS
repository (see the next section).
Assume your existing repo is at /home/alice/myproject. Create a new "bare"
@@ -106,7 +118,7 @@ Importing a CVS archive
First, install version 2.1 or higher of cvsps from
link:http://www.cobite.com/cvsps/[http://www.cobite.com/cvsps/] and make
sure it is in your path. Then cd to a checked out CVS working directory
-of the project you are interested in and run linkgit:git-cvsimport[1]:
+of the project you are interested in and run 'git-cvsimport':
-------------------------------------------
$ git cvsimport -C <destination> <module>
@@ -131,12 +143,17 @@ work, you must not modify the imported branches; instead, create new
branches for your own changes, and merge in the imported branches as
necessary.
+If you want a shared repository, you will need to make a bare clone
+of the imported directory, as described above. Then treat the imported
+directory as another development clone for purposes of merging
+incremental imports.
+
Advanced Shared Repository Management
-------------------------------------
Git allows you to specify scripts called "hooks" to be run at certain
points. You can use these, for example, to send all commits to the shared
-repository to a mailing list. See link:hooks.html[Hooks used by git].
+repository to a mailing list. See linkgit:githooks[5].
You can enforce finer grained permissions using update hooks. See
link:howto/update-hook-example.txt[Controlling access to branches using
@@ -169,3 +186,16 @@ variants of this model.
With a small group, developers may just pull changes from each other's
repositories without the need for a central maintainer.
+
+SEE ALSO
+--------
+linkgit:gittutorial[7],
+linkgit:gittutorial-2[7],
+linkgit:gitcore-tutorial[7],
+linkgit:gitglossary[7],
+link:everyday.html[Everyday Git],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/diffcore.txt b/Documentation/gitdiffcore.txt
index c6a983a5d..2bdbc3d4f 100644
--- a/Documentation/diffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -1,34 +1,40 @@
-Tweaking diff output
-====================
-June 2005
+gitdiffcore(7)
+==============
+NAME
+----
+gitdiffcore - Tweaking diff output (June 2005)
-Introduction
-------------
+SYNOPSIS
+--------
+'git diff' *
-The diff commands git-diff-index, git-diff-files, and git-diff-tree
+DESCRIPTION
+-----------
+
+The diff commands 'git-diff-index', 'git-diff-files', and 'git-diff-tree'
can be told to manipulate differences they find in
-unconventional ways before showing diff(1) output. The manipulation
+unconventional ways before showing 'diff' output. The manipulation
is collectively called "diffcore transformation". This short note
-describes what they are and how to use them to produce diff outputs
-that are easier to understand than the conventional kind.
+describes what they are and how to use them to produce 'diff' output
+that is easier to understand than the conventional kind.
The chain of operation
----------------------
-The git-diff-* family works by first comparing two sets of
+The 'git-diff-{asterisk}' family works by first comparing two sets of
files:
- - git-diff-index compares contents of a "tree" object and the
+ - 'git-diff-index' compares contents of a "tree" object and the
working directory (when '\--cached' flag is not used) or a
"tree" object and the index file (when '\--cached' flag is
used);
- - git-diff-files compares contents of the index file and the
+ - 'git-diff-files' compares contents of the index file and the
working directory;
- - git-diff-tree compares contents of two "tree" objects;
+ - 'git-diff-tree' compares contents of two "tree" objects;
In all of these cases, the commands themselves compare
corresponding paths in the two sets of files. The result of
@@ -55,12 +61,12 @@ into another list. There are currently 6 such transformations:
- diffcore-pickaxe
- diffcore-order
-These are applied in sequence. The set of filepairs git-diff-\*
+These are applied in sequence. The set of filepairs 'git-diff-{asterisk}'
commands find are used as the input to diffcore-pathspec, and
the output from diffcore-pathspec is used as the input to the
next transformation. The final result is then passed to the
output routine and generates either diff-raw format (see Output
-format sections of the manual for git-diff-\* commands) or
+format sections of the manual for 'git-diff-{asterisk}' commands) or
diff-patch format.
@@ -69,7 +75,7 @@ diffcore-pathspec: For Ignoring Files Outside Our Consideration
The first transformation in the chain is diffcore-pathspec, and
is controlled by giving the pathname parameters to the
-git-diff-* commands on the command line. The pathspec is used
+'git-diff-{asterisk}' commands on the command line. The pathspec is used
to limit the world diff operates in. It removes the filepairs
outside the specified set of pathnames. E.g. If the input set
of filepairs included:
@@ -78,11 +84,11 @@ of filepairs included:
:100644 100644 bcd1234... 0123456... M junkfile
------------------------------------------------
-but the command invocation was "git-diff-files myfile", then the
+but the command invocation was `git diff-files myfile`, then the
junkfile entry would be removed from the list because only "myfile"
is under consideration.
-Implementation note. For performance reasons, git-diff-tree
+Implementation note. For performance reasons, 'git-diff-tree'
uses the pathname parameters on the command line to cull set of
filepairs it feeds the diffcore mechanism itself, and does not
use diffcore-pathspec, but the end result is the same.
@@ -92,7 +98,7 @@ diffcore-break: For Splitting Up "Complete Rewrites"
----------------------------------------------------
The second transformation in the chain is diffcore-break, and is
-controlled by the -B option to the git-diff-* commands. This is
+controlled by the -B option to the 'git-diff-{asterisk}' commands. This is
used to detect a filepair that represents "complete rewrite" and
break such filepair into two filepairs that represent delete and
create. E.g. If the input contained this filepair:
@@ -128,7 +134,7 @@ diffcore-rename: For Detection Renames and Copies
This transformation is used to detect renames and copies, and is
controlled by the -M option (to detect renames) and the -C option
-(to detect copies as well) to the git-diff-* commands. If the
+(to detect copies as well) to the 'git-diff-{asterisk}' commands. If the
input contained these filepairs:
------------------------------------------------
@@ -173,11 +179,11 @@ number after the "-M" or "-C" option (e.g. "-M8" to tell it to use
8/10 = 80%).
Note. When the "-C" option is used with `\--find-copies-harder`
-option, git-diff-\* commands feed unmodified filepairs to
+option, 'git-diff-{asterisk}' commands feed unmodified filepairs to
diffcore mechanism as well as modified ones. This lets the copy
detector consider unmodified files as copy source candidates at
the expense of making it slower. Without `\--find-copies-harder`,
-git-diff-\* commands can detect copies only if the file that was
+'git-diff-{asterisk}' commands can detect copies only if the file that was
copied happened to have been modified in the same changeset.
@@ -228,7 +234,7 @@ diffcore-pickaxe: For Detecting Addition/Deletion of Specified String
This transformation is used to find filepairs that represent
changes that touch a specified string, and is controlled by the
--S option and the `\--pickaxe-all` option to the git-diff-*
+-S option and the `\--pickaxe-all` option to the 'git-diff-{asterisk}'
commands.
When diffcore-pickaxe is in use, it checks if there are
@@ -251,7 +257,7 @@ diffcore-order: For Sorting the Output Based on Filenames
This is used to reorder the filepairs according to the user's
(or project's) taste, and is controlled by the -O option to the
-git-diff-* commands.
+'git-diff-{asterisk}' commands.
This takes a text file each of whose lines is a shell glob
pattern. Filepairs that match a glob pattern on an earlier line
@@ -269,3 +275,18 @@ Documentation
*.c
t
------------------------------------------------
+
+SEE ALSO
+--------
+linkgit:git-diff[1],
+linkgit:git-diff-files[1],
+linkgit:git-diff-index[1],
+linkgit:git-diff-tree[1],
+linkgit:git-format-patch[1],
+linkgit:git-log[1],
+linkgit:gitglossary[7],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/gitglossary.txt b/Documentation/gitglossary.txt
new file mode 100644
index 000000000..565719ed5
--- /dev/null
+++ b/Documentation/gitglossary.txt
@@ -0,0 +1,25 @@
+gitglossary(7)
+==============
+
+NAME
+----
+gitglossary - A GIT Glossary
+
+SYNOPSIS
+--------
+*
+
+DESCRIPTION
+-----------
+
+include::glossary-content.txt[]
+
+SEE ALSO
+--------
+linkgit:gittutorial[7], linkgit:gittutorial-2[7],
+linkgit:everyday[7], linkgit:gitcvs-migration[7],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/hooks.txt b/Documentation/githooks.txt
index f110162b0..046a2a7fe 100644
--- a/Documentation/hooks.txt
+++ b/Documentation/githooks.txt
@@ -1,21 +1,34 @@
-Hooks used by git
-=================
+githooks(5)
+===========
+
+NAME
+----
+githooks - Hooks used by git
+
+SYNOPSIS
+--------
+$GIT_DIR/hooks/*
+
+
+DESCRIPTION
+-----------
Hooks are little scripts you can place in `$GIT_DIR/hooks`
directory to trigger action at certain points. When
-`git-init` is run, a handful example hooks are copied in the
+'git-init' is run, a handful example hooks are copied in the
`hooks` directory of the new repository, but by default they are
-all disabled. To enable a hook, make it executable with `chmod +x`.
+all disabled. To enable a hook, rename it by removing its `.sample`
+suffix.
This document describes the currently defined hooks.
applypatch-msg
--------------
-This hook is invoked by `git-am` script. It takes a single
+This hook is invoked by 'git-am' script. It takes a single
parameter, the name of the file that holds the proposed commit
log message. Exiting with non-zero status causes
-`git-am` to abort before applying the patch.
+'git-am' to abort before applying the patch.
The hook is allowed to edit the message file in place, and can
be used to normalize the message into some project standard
@@ -28,10 +41,11 @@ The default 'applypatch-msg' hook, when enabled, runs the
pre-applypatch
--------------
-This hook is invoked by `git-am`. It takes no parameter,
-and is invoked after the patch is applied, but before a commit
-is made. Exiting with non-zero status causes the working tree
-after application of the patch not committed.
+This hook is invoked by 'git-am'. It takes no parameter, and is
+invoked after the patch is applied, but before a commit is made.
+
+If it exits with non-zero status, then the working tree will not be
+committed after applying the patch.
It can be used to inspect the current working tree and refuse to
make a commit if it does not pass certain test.
@@ -42,32 +56,61 @@ The default 'pre-applypatch' hook, when enabled, runs the
post-applypatch
---------------
-This hook is invoked by `git-am`. It takes no parameter,
+This hook is invoked by 'git-am'. It takes no parameter,
and is invoked after the patch is applied and a commit is made.
This hook is meant primarily for notification, and cannot affect
-the outcome of `git-am`.
+the outcome of 'git-am'.
pre-commit
----------
-This hook is invoked by `git-commit`, and can be bypassed
+This hook is invoked by 'git-commit', and can be bypassed
with `\--no-verify` option. It takes no parameter, and is
invoked before obtaining the proposed commit log message and
making a commit. Exiting with non-zero status from this script
-causes the `git-commit` to abort.
+causes the 'git-commit' to abort.
The default 'pre-commit' hook, when enabled, catches introduction
of lines with trailing whitespaces and aborts the commit when
such a line is found.
+All the 'git-commit' hooks are invoked with the environment
+variable `GIT_EDITOR=:` if the command will not bring up an editor
+to modify the commit message.
+
+prepare-commit-msg
+------------------
+
+This hook is invoked by 'git-commit' right after preparing the
+default log message, and before the editor is started.
+
+It takes one to three parameters. The first is the name of the file
+that the commit log message. The second is the source of the commit
+message, and can be: `message` (if a `\-m` or `\-F` option was
+given); `template` (if a `\-t` option was given or the
+configuration option `commit.template` is set); `merge` (if the
+commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
+(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
+a commit SHA1 (if a `\-c`, `\-C` or `\--amend` option was given).
+
+If the exit status is non-zero, 'git-commit' will abort.
+
+The purpose of the hook is to edit the message file in place, and
+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
+out the `Conflicts:` part of a merge's commit message.
+
commit-msg
----------
-This hook is invoked by `git-commit`, and can be bypassed
+This hook is invoked by 'git-commit', and can be bypassed
with `\--no-verify` option. It takes a single parameter, the
name of the file that holds the proposed commit log message.
-Exiting with non-zero status causes the `git-commit` to
+Exiting with non-zero status causes the 'git-commit' to
abort.
The hook is allowed to edit the message file in place, and can
@@ -81,21 +124,21 @@ The default 'commit-msg' hook, when enabled, detects duplicate
post-commit
-----------
-This hook is invoked by `git-commit`. It takes no
+This hook is invoked by 'git-commit'. It takes no
parameter, and is invoked after a commit is made.
This hook is meant primarily for notification, and cannot affect
-the outcome of `git-commit`.
+the outcome of 'git-commit'.
post-checkout
-----------
-This hook is invoked when a `git-checkout` is run after having updated the
+This hook is invoked when a 'git-checkout' is run after having updated the
worktree. The hook is given three parameters: the ref of the previous HEAD,
the ref of the new HEAD (which may or may not have changed), and a flag
indicating whether the checkout was a branch checkout (changing branches,
flag=1) or a file checkout (retrieving a file from the index, flag=0).
-This hook cannot affect the outcome of `git-checkout`.
+This hook cannot affect the outcome of 'git-checkout'.
This hook can be used to perform repository validity checks, auto-display
differences from the previous HEAD if different, or set working dir metadata
@@ -104,10 +147,11 @@ properties.
post-merge
-----------
-This hook is invoked by `git-merge`, which happens when a `git pull`
+This hook is invoked by 'git-merge', which happens when a 'git-pull'
is done on a local repository. The hook takes a single parameter, a status
flag specifying whether or not the merge being done was a squash merge.
-This hook cannot affect the outcome of `git-merge`.
+This hook cannot affect the outcome of 'git-merge' and is not executed,
+if the merge failed due to conflicts.
This hook can be used in conjunction with a corresponding pre-commit hook to
save and restore any form of metadata associated with the working tree
@@ -118,8 +162,8 @@ for an example of how to do this.
pre-receive
-----------
-This hook is invoked by `git-receive-pack` on the remote repository,
-which happens when a `git push` is done on a local repository.
+This hook is invoked by 'git-receive-pack' on the remote repository,
+which happens when a 'git-push' is done on a local repository.
Just before starting to update refs on the remote repository, the
pre-receive hook is invoked. Its exit status determines the success
or failure of the update.
@@ -140,15 +184,15 @@ updated. If the hook exits with zero, updating of individual refs can
still be prevented by the <<update,'update'>> hook.
Both standard output and standard error output are forwarded to
-`git-send-pack` on the other end, so you can simply `echo` messages
+'git-send-pack' on the other end, so you can simply `echo` messages
for the user.
[[update]]
update
------
-This hook is invoked by `git-receive-pack` on the remote repository,
-which happens when a `git push` is done on a local repository.
+This hook is invoked by 'git-receive-pack' on the remote repository,
+which happens when a 'git-push' is done on a local repository.
Just before updating the ref on the remote repository, the update hook
is invoked. Its exit status determines the success or failure of
the ref update.
@@ -161,7 +205,7 @@ three parameters:
- and the new objectname to be stored in the ref.
A zero exit from the update hook allows the ref to be updated.
-Exiting with a non-zero status prevents `git-receive-pack`
+Exiting with a non-zero status prevents 'git-receive-pack'
from updating that ref.
This hook can be used to prevent 'forced' update on certain refs by
@@ -179,7 +223,7 @@ implement access control which is finer grained than the one
based on filesystem group.
Both standard output and standard error output are forwarded to
-`git-send-pack` on the other end, so you can simply `echo` messages
+'git-send-pack' on the other end, so you can simply `echo` messages
for the user.
The default 'update' hook, when enabled--and with
@@ -190,8 +234,8 @@ unannotated tags to be pushed.
post-receive
------------
-This hook is invoked by `git-receive-pack` on the remote repository,
-which happens when a `git push` is done on a local repository.
+This hook is invoked by 'git-receive-pack' on the remote repository,
+which happens when a 'git-push' is done on a local repository.
It executes on the remote repository once after all the refs have
been updated.
@@ -200,7 +244,7 @@ arguments, but gets the same information as the
<<pre-receive,'pre-receive'>>
hook does on its standard input.
-This hook does not affect the outcome of `git-receive-pack`, as it
+This hook does not affect the outcome of 'git-receive-pack', as it
is called after the real work is done.
This supersedes the <<post-update,'post-update'>> hook in that it gets
@@ -208,7 +252,7 @@ both old and new values of all the refs in addition to their
names.
Both standard output and standard error output are forwarded to
-`git-send-pack` on the other end, so you can simply `echo` messages
+'git-send-pack' on the other end, so you can simply `echo` messages
for the user.
The default 'post-receive' hook is empty, but there is
@@ -220,8 +264,8 @@ emails.
post-update
-----------
-This hook is invoked by `git-receive-pack` on the remote repository,
-which happens when a `git push` is done on a local repository.
+This hook is invoked by 'git-receive-pack' on the remote repository,
+which happens when a 'git-push' is done on a local repository.
It executes on the remote repository once after all the refs have
been updated.
@@ -229,7 +273,7 @@ It takes a variable number of parameters, each of which is the
name of ref that was actually updated.
This hook is meant primarily for notification, and cannot affect
-the outcome of `git-receive-pack`.
+the outcome of 'git-receive-pack'.
The 'post-update' hook can tell what are the heads that were pushed,
but it does not know what their original and updated values are,
@@ -239,11 +283,22 @@ updated values of the refs. You might consider it instead if you need
them.
When enabled, the default 'post-update' hook runs
-`git-update-server-info` to keep the information used by dumb
+'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
probably enable this hook.
Both standard output and standard error output are forwarded to
-`git-send-pack` on the other end, so you can simply `echo` messages
+'git-send-pack' on the other end, so you can simply `echo` messages
for the user.
+
+pre-auto-gc
+-----------
+
+This hook is invoked by 'git-gc --auto'. It takes no parameter, and
+exiting with non-zero status from this script causes the 'git-gc --auto'
+to abort.
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 08373f52b..59321a2e8 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -13,9 +13,14 @@ DESCRIPTION
-----------
A `gitignore` file specifies intentionally untracked files that
-git should ignore. Each line in a `gitignore` file specifies a
-pattern.
-
+git should ignore.
+Note that all the `gitignore` files really concern only files
+that are not already tracked by git;
+in order to ignore uncommitted changes in already tracked files,
+please refer to the 'git update-index --assume-unchanged'
+documentation.
+
+Each line in a `gitignore` file specifies a pattern.
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
@@ -38,11 +43,23 @@ precedence, the last matching pattern decides the outcome):
* Patterns read from the file specified by the configuration
variable 'core.excludesfile'.
+Which file to place a pattern in depends on how the pattern is meant to
+be used. Patterns which should be version-controlled and distributed to
+other repositories via clone (i.e., files that all developers will want
+to ignore) should go into a `.gitignore` file. Patterns which are
+specific to a particular repository but which do not need to be shared
+with other related repositories (e.g., auxiliary files that live inside
+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
+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`.
+
The underlying git plumbing tools, such as
-linkgit:git-ls-files[1] and linkgit:git-read-tree[1], read
+'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
-tools, such as linkgit:git-status[1] and linkgit:git-add[1],
+tools, such as 'git-status' and 'git-add',
use patterns from the sources specified above.
Patterns have the following format:
@@ -57,6 +74,13 @@ Patterns have the following format:
included again. If a negated pattern matches, this will
override lower precedence patterns sources.
+ - If the pattern ends with a slash, it is removed for the
+ purpose of the following description, but it would only find
+ 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).
+
- If the pattern does not contain a slash '/', git treats it as
a shell glob pattern and checks for a match against the
pathname without leading directories.
@@ -73,7 +97,7 @@ Patterns have the following format:
An example:
--------------------------------------------------------------
- $ git-status
+ $ git status
[...]
# Untracked files:
[...]
@@ -91,7 +115,7 @@ An example:
*.html
# except foo.html which is maintained by hand
!foo.html
- $ git-status
+ $ git status
[...]
# Untracked files:
[...]
@@ -119,4 +143,4 @@ Frank Lichtenheld, and the git-list <git@vger.kernel.org>.
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 29edafced..6e827cd11 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -22,10 +22,12 @@ git repository.
OPTIONS
-------
To control which revisions to shown, the command takes options applicable to
-the linkgit:git-rev-list[1] command. This manual page describes only the most
+the 'git-rev-list' command (see linkgit:git-rev-list[1]).
+This manual page describes only the most
frequently used options.
--n <number>, --max-count=<number>::
+-n <number>::
+--max-count=<number>::
Limits the number of commits to show.
@@ -41,6 +43,12 @@ frequently used options.
Show all branches.
+--merge::
+
+ After an attempt to merge stops with conflicts, show the commits on
+ the history between two branches (i.e. the HEAD and the MERGE_HEAD)
+ that modify the conflicted files.
+
<revs>::
Limit the revisions to show. This can be either a single revision
@@ -50,7 +58,7 @@ frequently used options.
For a more complete list of ways to spell object names, see
"SPECIFYING REVISIONS" section in linkgit:git-rev-parse[1].
-<path>::
+<path>...::
Limit commits to the ones touching files in the given paths. Note, to
avoid ambiguity wrt. revision names use "--" to separate the paths
@@ -74,7 +82,12 @@ gitk --max-count=100 --all \-- Makefile::
Show at most 100 changes made to the file 'Makefile'. Instead of only
looking for changes in the current branch look in all branches.
-See Also
+Files
+-----
+Gitk creates the .gitk file in your $HOME directory to store preferences
+such as display options, font, and colors.
+
+SEE ALSO
--------
'qgit(1)'::
A repository browser written in C++ using Qt.
@@ -98,4 +111,4 @@ Documentation by Junio C Hamano, Jonas Fonseca, and the git-list
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt
index cc95b69f2..f8d122a8b 100644
--- a/Documentation/gitmodules.txt
+++ b/Documentation/gitmodules.txt
@@ -59,4 +59,4 @@ Documentation by Lars Hjemli <hjemli@gmail.com>
GIT
---
-Part of the linkgit:git[7] suite
+Part of the linkgit:git[1] suite
diff --git a/Documentation/repository-layout.txt b/Documentation/gitrepository-layout.txt
index 693913009..a969b3fbc 100644
--- a/Documentation/repository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -1,9 +1,23 @@
-git repository layout
-=====================
+gitrepository-layout(5)
+=======================
+
+NAME
+----
+gitrepository-layout - Git Repository Layout
+
+SYNOPSIS
+--------
+$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).
+`<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).
objects::
Object store associated with this repository. Usually
@@ -50,7 +64,7 @@ objects/info/packs::
are available in this object store. Whenever a pack is
added or removed, `git update-server-info` should be run
to keep this file up-to-date if the repository is
- published for dumb transports. `git repack` does this
+ published for dumb transports. 'git-repack' does this
by default.
objects/info/alternates::
@@ -71,7 +85,7 @@ objects/info/http-alternates::
refs::
References are stored in subdirectories of this
- directory. The `git prune` command knows to keep
+ directory. The 'git-prune' command knows to keep
objects reachable from refs found in this directory and
its subdirectories.
@@ -111,17 +125,17 @@ details.
branches::
A slightly deprecated way to store shorthands to be used
- to specify URL to `git fetch`, `git pull` and `git push`
- commands is to store a file in `branches/'name'` and
+ to specify URL to 'git-fetch', 'git-pull' and 'git-push'
+ commands is to store a file in `branches/<name>` and
give 'name' to these commands in place of 'repository'
argument.
hooks::
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
+ 'git-init' is run, but all of them are disabled by
default. To enable, they need to be made executable.
- Read link:hooks.html[hooks] for more details about
+ Read linkgit:githooks[5] for more details about
each hook.
index::
@@ -136,10 +150,10 @@ info/refs::
This file helps dumb transports discover what refs are
available in this repository. If the repository is
published for dumb transports, this file should be
- regenerated by `git update-server-info` every time a tag
+ regenerated by 'git-update-server-info' every time a tag
or branch is created or modified. This is normally done
from the `hooks/update` hook, which is run by the
- `git-receive-pack` command when you `git push` into the
+ 'git-receive-pack' command when you 'git-push' into the
repository.
info/grafts::
@@ -153,18 +167,18 @@ info/grafts::
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
+ ignore file. 'git-status', 'git-add', 'git-rm' and
+ 'git-clean' look at it but the core git commands do not look
at it. See also: linkgit:gitignore[5].
remotes::
Stores shorthands to be used to give URL and default
- refnames to interact with remote repository to `git
- fetch`, `git pull` and `git push` commands.
+ refnames to interact with remote repository to
+ 'git-fetch', 'git-pull' and 'git-push' commands.
logs::
Records of changes made to refs are stored in this
- directory. See the documentation on git-update-ref
+ directory. See linkgit:git-update-ref[1]
for more information.
logs/refs/heads/`name`::
@@ -177,3 +191,18 @@ shallow::
This is similar to `info/grafts` but is internally used
and maintained by shallow clone mechanism. See `--depth`
option to linkgit:git-clone[1] and linkgit:git-fetch[1].
+
+SEE ALSO
+--------
+linkgit:git-init[1],
+linkgit:git-clone[1],
+linkgit:git-fetch[1],
+linkgit:git-pack-refs[1],
+linkgit:git-gc[1],
+linkgit:git-checkout[1],
+linkgit:gitglossary[7],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/tutorial-2.txt b/Documentation/gittutorial-2.txt
index 7fac47de8..660904686 100644
--- a/Documentation/tutorial-2.txt
+++ b/Documentation/gittutorial-2.txt
@@ -1,8 +1,18 @@
-A tutorial introduction to git: part two
-========================================
+gittutorial-2(7)
+================
-You should work through link:tutorial.html[A tutorial introduction to
-git] before reading this tutorial.
+NAME
+----
+gittutorial-2 - A tutorial introduction to git: part two
+
+SYNOPSIS
+--------
+git *
+
+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
@@ -44,15 +54,15 @@ 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:
------------------------------------------------
-$ git-cat-file -t 54196cc2
+$ git cat-file -t 54196cc2
commit
-$ git-cat-file commit 54196cc2
+$ git cat-file commit 54196cc2
tree 92b8b694ffb1675e5975148e1121810081dbdffe
author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
@@ -155,7 +165,7 @@ hello world!
and the "parent" object refers to the previous commit:
------------------------------------------------
-$ git-cat-file commit 54196cc2
+$ git cat-file commit 54196cc2
tree 92b8b694ffb1675e5975148e1121810081dbdffe
author J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
committer J. Bruce Fields <bfields@puzzle.fieldses.org> 1143414668 -0500
@@ -202,8 +212,8 @@ designate such an argument.
The index file
--------------
-The primary tool we've been using to create commits is "git commit
--a", which creates a commit including every change you've made to
+The primary tool we've been using to create commits is `git-commit
+-a`, which creates a commit including every change you've made to
your working tree. But what if you want to commit changes only to
certain files? Or only certain changes to certain files?
@@ -235,7 +245,7 @@ The last diff is empty, but no new commits have been made, and the
head still doesn't contain the new line:
------------------------------------------------
-$ git-diff HEAD
+$ git diff HEAD
diff --git a/file.txt b/file.txt
index a042389..513feba 100644
--- a/file.txt
@@ -245,7 +255,7 @@ index a042389..513feba 100644
+hello world, again
------------------------------------------------
-So "git diff" is comparing against something other than the head.
+So 'git-diff' is comparing against something other than the head.
The thing that it's comparing against is actually the index file,
which is stored in .git/index in a binary format, but whose contents
we can examine with ls-files:
@@ -260,9 +270,9 @@ hello world!
hello world, again
------------------------------------------------
-So what our "git add" did was store a new blob and then put
+So what our 'git-add' did was store a new blob and then put
a reference to it in the index file. If we modify the file again,
-we'll see that the new modifications are reflected in the "git-diff"
+we'll see that the new modifications are reflected in the 'git-diff'
output:
------------------------------------------------
@@ -277,7 +287,7 @@ index 513feba..ba3da7b 100644
+again?
------------------------------------------------
-With the right arguments, git diff can also show us the difference
+With the right arguments, 'git-diff' can also show us the difference
between the working directory and the last commit, or between the
index and the last commit:
@@ -301,8 +311,8 @@ index a042389..513feba 100644
+hello world, again
------------------------------------------------
-At any time, we can create a new commit using "git commit" (without
-the -a option), and verify that the state committed only includes the
+At any time, we can create a new commit using 'git-commit' (without
+the "-a" option), and verify that the state committed only includes the
changes stored in the index file, not the additional change that is
still only in our working tree:
@@ -319,11 +329,11 @@ index 513feba..ba3da7b 100644
+again?
------------------------------------------------
-So by default "git commit" uses the index to create the commit, not
-the working tree; the -a option to commit tells it to first update
+So by default 'git-commit' uses the index to create the commit, not
+the working tree; the "-a" option to commit tells it to first update
the index with all changes in the working tree.
-Finally, it's worth looking at the effect of "git add" on the index
+Finally, it's worth looking at the effect of 'git-add' on the index
file:
------------------------------------------------
@@ -331,7 +341,7 @@ $ echo "goodbye, world" >closing.txt
$ git add closing.txt
------------------------------------------------
-The effect of the "git add" was to add one entry to the index file:
+The effect of the 'git-add' was to add one entry to the index file:
------------------------------------------------
$ git ls-files --stage
@@ -372,14 +382,14 @@ it is marked "changed but not updated". At this point, running "git
commit" would create a commit that added closing.txt (with its new
contents), but that didn't modify file.txt.
-Also, note that a bare "git diff" shows the changes to file.txt, but
+Also, note that a bare `git diff` shows the changes to file.txt, but
not the addition of closing.txt, because the version of closing.txt
in the index file is identical to the one in the working directory.
In addition to being the staging area for new commits, the index file
is also populated from the object database when checking out a
branch, and is used to hold the trees involved in a merge operation.
-See the link:core-tutorial.html[core tutorial] and the relevant man
+See linkgit:gitcore-tutorial[7] and the relevant man
pages for details.
What next?
@@ -388,19 +398,31 @@ 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
-should be able to find any unknown jargon in the
-link:glossary.html[Glossary].
+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.
-The link:cvs-migration.html[CVS migration] document explains how to
+linkgit:gitcvs-migration[7] explains how to
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
link:howto-index.html[howtos].
-For git developers, the link:core-tutorial.html[Core tutorial] goes
+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
+--------
+linkgit:gittutorial[7],
+linkgit:gitcvs-migration[7],
+linkgit:gitcore-tutorial[7],
+linkgit:gitglossary[7],
+link:everyday.html[Everyday git],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/tutorial.txt b/Documentation/gittutorial.txt
index e2bbda53f..48d1454a9 100644
--- a/Documentation/tutorial.txt
+++ b/Documentation/gittutorial.txt
@@ -1,5 +1,16 @@
-A tutorial introduction to git (for version 1.5.1 or newer)
-===========================================================
+gittutorial(7)
+==============
+
+NAME
+----
+gittutorial - A tutorial introduction to git (for version 1.5.1 or newer)
+
+SYNOPSIS
+--------
+git *
+
+DESCRIPTION
+-----------
This tutorial explains how to import a new project into git, make
changes to it, and share changes with other developers.
@@ -8,11 +19,11 @@ 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].
-First, note that you can get documentation for a command such as "git
-diff" with:
+First, note that you can get documentation for a command such as
+`git log --graph` with:
------------------------------------------------
-$ man git-diff
+$ man git-log
------------------------------------------------
It is a good idea to introduce yourself to git with your name and
@@ -47,7 +58,7 @@ 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
-current directory (note the '.'), with linkgit:git-add[1]:
+current directory (note the '.'), with 'git-add':
------------------------------------------------
$ git add .
@@ -55,7 +66,7 @@ $ git add .
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 linkgit:git-commit[1]:
+repository with 'git-commit':
------------------------------------------------
$ git commit
@@ -74,15 +85,15 @@ $ git add file1 file2 file3
------------------------------------------------
You are now ready to commit. You can see what is about to be committed
-using linkgit:git-diff[1] with the --cached option:
+using 'git-diff' with the --cached option:
------------------------------------------------
$ git diff --cached
------------------------------------------------
-(Without --cached, linkgit:git-diff[1] will show you any changes that
+(Without --cached, 'git-diff' will show you any changes that
you've made but not yet added to the index.) You can also get a brief
-summary of the situation with linkgit:git-status[1]:
+summary of the situation with 'git-status':
------------------------------------------------
$ git status
@@ -103,10 +114,10 @@ newly modified content to the index. Finally, commit your changes with:
$ git commit
------------------------------------------------
-This will again prompt your for a message describing the change, and then
+This will again prompt you for a message describing the change, and then
record a new version of the project.
-Alternatively, instead of running `git add` beforehand, you can use
+Alternatively, instead of running 'git-add' beforehand, you can use
------------------------------------------------
$ git commit -a
@@ -125,9 +136,9 @@ commit in the body.
Git tracks content not files
----------------------------
-Many revision control systems provide an "add" command that tells the
-system to start tracking changes to a new file. Git's "add" command
-does something simpler and more powerful: `git add` is used both for new
+Many revision control systems provide an `add` command that tells the
+system to start tracking changes to a new file. Git's `add` command
+does something simpler and more powerful: 'git-add' is used both for new
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.
@@ -263,7 +274,7 @@ same machine, wants to contribute.
Bob begins with:
------------------------------------------------
-$ git clone /home/alice/project myrepo
+bob$ git clone /home/alice/project myrepo
------------------------------------------------
This creates a new directory "myrepo" containing a clone of Alice's
@@ -274,7 +285,7 @@ Bob then makes some changes and commits them:
------------------------------------------------
(edit files)
-$ git commit -a
+bob$ git commit -a
(repeat as necessary)
------------------------------------------------
@@ -282,8 +293,8 @@ When he's ready, he tells Alice to pull changes from the repository
at /home/bob/myrepo. She does this with:
------------------------------------------------
-$ cd /home/alice/project
-$ git pull /home/bob/myrepo master
+alice$ cd /home/alice/project
+alice$ git pull /home/bob/myrepo master
------------------------------------------------
This merges the changes from Bob's "master" branch into Alice's
@@ -295,30 +306,56 @@ is the default.)
The "pull" command thus performs two operations: it fetches changes
from a remote branch, then merges them into the current branch.
+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
+refuse to merge --- Alice will have to get rid of her local changes in
+some way and pull again when this happens).
+
+Alice can peek at what Bob did without merging first, using the "fetch"
+command; this allows Alice to inspect what Bob did, using a special
+symbol "FETCH_HEAD", in order to determine if he has anything worth
+pulling, like this:
+
+------------------------------------------------
+alice$ git fetch /home/bob/myrepo master
+alice$ git log -p ..FETCH_HEAD
+------------------------------------------------
+
+This operation is safe even if Alice has uncommitted local changes.
+
+After inspecting what Bob did, if there is nothing urgent, Alice may
+decide to continue working without pulling from Bob. If Bob's history
+does have something Alice would immediately need, Alice may choose to
+stash her work-in-progress first, do a "pull", and then finally unstash
+her work-in-progress on top of the resulting history.
+
When you are working in a small closely knit group, it is not
unusual to interact with the same repository over and over
again. By defining 'remote' repository shorthand, you can make
it easier:
------------------------------------------------
-$ git remote add bob /home/bob/myrepo
+alice$ git remote add bob /home/bob/myrepo
------------------------------------------------
-With this, Alice can perform the first operation alone using the
-"git fetch" command without merging them with her own branch,
+With this, Alice can perform the first part of the "pull" operation alone using the
+'git-fetch' command without merging them with her own branch,
using:
-------------------------------------
-$ git fetch bob
+alice$ git fetch bob
-------------------------------------
Unlike the longhand form, when Alice fetches from Bob using a
-remote repository shorthand set up with `git remote`, what was
+remote repository shorthand set up with 'git-remote', what was
fetched is stored in a remote tracking branch, in this case
`bob/master`. So after this:
-------------------------------------
-$ git log -p master..bob/master
+alice$ git log -p master..bob/master
-------------------------------------
shows a list of all the changes that Bob made since he branched from
@@ -328,14 +365,14 @@ After examining those changes, Alice
could merge the changes into her master branch:
-------------------------------------
-$ git merge bob/master
+alice$ git merge bob/master
-------------------------------------
This `merge` can also be done by 'pulling from her own remote
tracking branch', like this:
-------------------------------------
-$ git pull . remotes/bob/master
+alice$ git pull . remotes/bob/master
-------------------------------------
Note that git pull always merges into the current branch,
@@ -344,7 +381,7 @@ regardless of what else is given on the command line.
Later, Bob can update his repo with Alice's latest changes using
-------------------------------------
-$ git pull
+bob$ git pull
-------------------------------------
Note that he doesn't need to give the path to Alice's repository;
@@ -353,19 +390,19 @@ repository in the repository configuration, and that location is
used for pulls:
-------------------------------------
-$ git config --get remote.origin.url
+bob$ git config --get remote.origin.url
/home/alice/project
-------------------------------------
-(The complete configuration created by git-clone is visible using
-"git config -l", and the linkgit:git-config[1] man page
+(The complete configuration created by 'git-clone' is visible using
+`git config -l`, and the linkgit:git-config[1] man page
explains the meaning of each option.)
Git also keeps a pristine copy of Alice's master branch under the
name "origin/master":
-------------------------------------
-$ git branch -r
+bob$ git branch -r
origin/master
-------------------------------------
@@ -373,7 +410,7 @@ If Bob later decides to work from a different host, he can still
perform clones and pulls using the ssh protocol:
-------------------------------------
-$ git clone alice.org:/home/alice/project myrepo
+bob$ git clone alice.org:/home/alice/project myrepo
-------------------------------------
Alternatively, git has a native protocol, or can use rsync or http;
@@ -381,13 +418,13 @@ see linkgit:git-pull[1] for details.
Git can also be used in a CVS-like mode, with a central repository
that various users push changes to; see linkgit:git-push[1] and
-link:cvs-migration.html[git for CVS users].
+linkgit:gitcvs-migration[7].
Exploring history
-----------------
Git history is represented as a series of interrelated commits. We
-have already seen that the git log command can list those commits.
+have already seen that the 'git-log' command can list those commits.
Note that first line of each git log entry also gives a name for the
commit:
@@ -400,7 +437,7 @@ Date: Tue May 16 17:18:22 2006 -0700
merge-base: Clarify the comments on post processing.
-------------------------------------
-We can give this name to git show to see the details about this
+We can give this name to 'git-show' to see the details about this
commit.
-------------------------------------
@@ -436,7 +473,7 @@ $ git show HEAD^2 # show the second parent of HEAD
You can also give commits names of your own; after running
-------------------------------------
-$ git-tag v2.5 1b2e1d63ff
+$ git tag v2.5 1b2e1d63ff
-------------------------------------
you can refer to 1b2e1d63ff by the name "v2.5". If you intend to
@@ -458,13 +495,13 @@ $ git reset --hard HEAD^ # reset your current branch and working
Be careful with that last command: in addition to losing any changes
in the working directory, it will also remove all later commits from
this branch. If this branch is the only branch containing those
-commits, they will be lost. Also, don't use "git reset" on a
+commits, they will be lost. Also, don't use 'git-reset' on a
publicly-visible branch that other developers pull from, as it will
force needless merges on other developers to clean up the history.
-If you need to undo changes that you have pushed, use linkgit:git-revert[1]
+If you need to undo changes that you have pushed, use 'git-revert'
instead.
-The git grep command can search for strings in any version of your
+The 'git-grep' command can search for strings in any version of your
project, so
-------------------------------------
@@ -473,7 +510,7 @@ $ git grep "hello" v2.5
searches for all occurrences of "hello" in v2.5.
-If you leave out the commit name, git grep will search any of the
+If you leave out the commit name, 'git-grep' will search any of the
files it manages in your current directory. So
-------------------------------------
@@ -483,7 +520,7 @@ $ git grep "hello"
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
-in a number of ways. Here are some examples with git log:
+in a number of ways. Here are some examples with 'git-log':
-------------------------------------
$ git log v2.5..v2.6 # commits between v2.5 and v2.6
@@ -493,7 +530,7 @@ $ git log v2.5.. Makefile # commits since v2.5 which modify
# Makefile
-------------------------------------
-You can also give git log a "range" of commits where the first is not
+You can also give 'git-log' a "range" of commits where the first is not
necessarily an ancestor of the second; for example, if the tips of
the branches "stable-release" and "master" diverged from a common
commit some time ago, then
@@ -512,13 +549,13 @@ $ git log experimental..stable
will show the list of commits made on the stable branch but not
the experimental branch.
-The "git log" command has a weakness: it must present commits in a
+The 'git-log' command has a weakness: it must present commits in a
list. When the history has lines of development that diverged and
-then merged back together, the order in which "git log" presents
+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,
-------------------------------------
@@ -538,7 +575,7 @@ of the file:
$ git diff v2.5:Makefile HEAD:Makefile.in
-------------------------------------
-You can also use "git show" to see any such file:
+You can also use 'git-show' to see any such file:
-------------------------------------
$ git show v2.5:Makefile
@@ -560,9 +597,9 @@ is based:
used to create commits, check out working directories, and
hold the various trees involved in a merge.
-link:tutorial-2.html[Part two of this tutorial] explains the object
+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.
+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:
@@ -581,4 +618,17 @@ digressions that may be interesting at this point are:
* link:everyday.html[Everyday GIT with 20 Commands Or So]
- * link:cvs-migration.html[git for CVS users].
+ * linkgit:gitcvs-migration[7]: Git for CVS users.
+
+SEE ALSO
+--------
+linkgit:gittutorial-2[7],
+linkgit:gitcvs-migration[7],
+linkgit:gitcore-tutorial[7],
+linkgit:gitglossary[7],
+link:everyday.html[Everyday git],
+link:user-manual.html[The Git User's Manual]
+
+GIT
+---
+Part of the linkgit:git[1] suite.
diff --git a/Documentation/glossary.txt b/Documentation/glossary-content.txt
index ab4caf4e2..9b4a4f45e 100644
--- a/Documentation/glossary.txt
+++ b/Documentation/glossary-content.txt
@@ -1,6 +1,3 @@
-GIT Glossary
-============
-
[[def_alternate_object_database]]alternate object database::
Via the alternates mechanism, a <<def_repository,repository>>
can inherit part of its <<def_object_database,object database>>
@@ -45,9 +42,12 @@ GIT Glossary
"changesets" with git.
[[def_checkout]]checkout::
- The action of updating the <<def_working_tree,working tree>> to a
- <<def_revision,revision>> which was stored in the
- <<def_object_database,object database>>.
+ The action of updating all or part of the
+ <<def_working_tree,working tree>> with a <<def_tree_object,tree object>>
+ or <<def_blob_object,blob>> from the
+ <<def_object_database,object database>>, and updating the
+ <<def_index,index>> and <<def_HEAD,HEAD>> if the whole working tree has
+ been pointed at a new <<def_branch,branch>>.
[[def_cherry-picking]]cherry-picking::
In <<def_SCM,SCM>> jargon, "cherry pick" means to choose a subset of
@@ -87,11 +87,10 @@ to point at the new commit.
source code management tools.
[[def_DAG]]DAG::
- Directed acyclic graph. The <<def_commit,commit>> objects form a
+ Directed acyclic graph. The <<def_commit_object,commit objects>> form a
directed acyclic graph, because they have parents (directed), and the
- graph of commit objects is acyclic (there is no
- <<def_chain,chain>> which begins and ends with the same
- <<def_object,object>>).
+ graph of commit objects is acyclic (there is no <<def_chain,chain>>
+ which begins and ends with the same <<def_object,object>>).
[[def_dangling_object]]dangling object::
An <<def_unreachable_object,unreachable object>> which is not
@@ -247,9 +246,10 @@ This commit is referred to as a "merge commit", or sometimes just a
the <<def_hash,hash>> of the object.
[[def_object_type]]object type::
- One of the identifiers
- "<<def_commit,commit>>","<<def_tree,tree>>","<<def_tag,tag>>" or "<<def_blob_object,blob>>"
- describing the type of an <<def_object,object>>.
+ One of the identifiers "<<def_commit_object,commit>>",
+ "<<def_tree_object,tree>>", "<<def_tag_object,tag>>" or
+ "<<def_blob_object,blob>>" describing the type of an
+ <<def_object,object>>.
[[def_octopus]]octopus::
To <<def_merge,merge>> more than two <<def_branch,branches>>. Also denotes an
diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt
index 7a76045eb..d214d4bf9 100644
--- a/Documentation/howto/rebase-from-internal-branch.txt
+++ b/Documentation/howto/rebase-from-internal-branch.txt
@@ -1,4 +1,4 @@
-From: Junio C Hamano <junkio@cox.net>
+From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Petr Baudis <pasky@suse.cz>, Linus Torvalds <torvalds@osdl.org>
Subject: Re: sending changesets from the middle of a git tree
diff --git a/Documentation/howto/rebuild-from-update-hook.txt b/Documentation/howto/rebuild-from-update-hook.txt
index 8d55dfbfa..48c67568d 100644
--- a/Documentation/howto/rebuild-from-update-hook.txt
+++ b/Documentation/howto/rebuild-from-update-hook.txt
@@ -1,6 +1,6 @@
Subject: [HOWTO] Using post-update hook
Message-ID: <7vy86o6usx.fsf@assigned-by-dhcp.cox.net>
-From: Junio C Hamano <junkio@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
diff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt
index 865a66632..e70d8a31e 100644
--- a/Documentation/howto/revert-branch-rebase.txt
+++ b/Documentation/howto/revert-branch-rebase.txt
@@ -1,4 +1,4 @@
-From: Junio C Hamano <junkio@cox.net>
+From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [HOWTO] Reverting an existing commit
Abstract: In this article, JC gives a small real-life example of using
diff --git a/Documentation/howto/separating-topic-branches.txt b/Documentation/howto/separating-topic-branches.txt
index 0d73b3122..6d3eb8ed0 100644
--- a/Documentation/howto/separating-topic-branches.txt
+++ b/Documentation/howto/separating-topic-branches.txt
@@ -1,4 +1,4 @@
-From: Junio C Hamano <junkio@cox.net>
+From: Junio C Hamano <gitster@pobox.com>
Subject: Separating topic branches
Abstract: In this article, JC describes how to separate topic branches.
diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt
index 8eadc2049..403274860 100644
--- a/Documentation/howto/setup-git-server-over-http.txt
+++ b/Documentation/howto/setup-git-server-over-http.txt
@@ -1,5 +1,5 @@
From: Rutger Nijlunsing <rutger@nospam.com>
-Subject: Setting up a git repository which can be pushed into and pulled from over HTTP.
+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
Since Apache is one of those packages people like to compile
@@ -40,9 +40,13 @@ What's needed:
- have permissions to chown a directory
-- have git installed at the server _and_ client
+- have git installed on the client, and
-In effect, this probably means you're going to be root.
+- 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
@@ -50,9 +54,9 @@ 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
-option would be to generate an empty repository at the client and copy
-it to the server with WebDAV. But then you're probably the first to
-try that out :)
+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).
Create the directory under the DocumentRoot of the directories served
by Apache. As an example we take /usr/local/apache2, but try "grep
@@ -169,7 +173,9 @@ On Debian:
Most tests should pass.
-A command line tool to test WebDAV is cadaver.
+A command line tool to test WebDAV is cadaver. If you prefer GUIs, for
+example, konqueror can open WebDAV URLs as "webdav://..." or
+"webdavs://...".
If you're into Windows, from XP onwards Internet Explorer supports
WebDAV. For this, do Internet Explorer -> Open Location ->
@@ -179,8 +185,9 @@ 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 curl.
-The easiest way to check is to look for the executable 'git-http-push'.
+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.
Then, add the following to your $HOME/.netrc (you can do without, but will be
asked to input your password a _lot_ of times):
@@ -197,10 +204,10 @@ instead of the server name.
To check whether all is OK, do:
- curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/
-
-...this should give a directory listing in HTML of /var/www/my-new-repo.git .
+ curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/HEAD
+...this should give something like 'ref: refs/heads/master', which is
+the content of the file HEAD on the server.
Now, add the remote in your existing repository which contains the project
you want to export:
@@ -225,6 +232,15 @@ want to export) to repository called 'upload', which we previously
defined with git-config.
+Using a proxy:
+--------------
+
+If you have to access the WebDAV server from behind an HTTP(S) proxy,
+set the variable 'all_proxy' to 'http://proxy-host.com:port', or
+'http://login-on-proxy:passwd-on-proxy@proxy-host.com:port'. See 'man
+curl' for details.
+
+
Troubleshooting:
----------------
@@ -248,9 +264,14 @@ 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
+certificate (this is return code 60). Setting http.sslVerify=false can
+help diagnosing the problem, but removes security checks.
+
Debian References: http://www.debian-administration.org/articles/285
Authors
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Rutger Nijlunsing <git@wingding.demon.nl>
+ Matthieu Moy <Matthieu.Moy@imag.fr>
diff --git a/Documentation/howto/update-hook-example.txt b/Documentation/howto/update-hook-example.txt
index 88765b557..697d91888 100644
--- a/Documentation/howto/update-hook-example.txt
+++ b/Documentation/howto/update-hook-example.txt
@@ -1,4 +1,4 @@
-From: Junio C Hamano <junkio@cox.net> and Carl Baldwin <cnb@fc.hp.com>
+From: Junio C Hamano <gitster@pobox.com> and Carl Baldwin <cnb@fc.hp.com>
Subject: control access to branches.
Date: Thu, 17 Nov 2005 23:55:32 -0800
Message-ID: <7vfypumlu3.fsf@assigned-by-dhcp.cox.net>
@@ -65,10 +65,10 @@ function info {
# Implement generic branch and tag policies.
# - Tags should not be updated once created.
-# - Branches should only be fast-forwarded.
+# - Branches should only be fast-forwarded unless their pattern starts with '+'
case "$1" in
refs/tags/*)
- [ -f "$GIT_DIR/$1" ] &&
+ git rev-parse --verify -q "$1" &&
deny >/dev/null "You can't overwrite an existing tag"
;;
refs/heads/*)
@@ -80,7 +80,7 @@ case "$1" in
mb=$(git-merge-base "$2" "$3")
case "$mb,$2" in
"$2,$mb") info "Update is fast-forward" ;;
- *) deny >/dev/null "This is not a fast-forward update." ;;
+ *) noff=y; info "This is not a fast-forward update.";;
esac
fi
;;
@@ -95,21 +95,30 @@ allowed_users_file=$GIT_DIR/info/allowed-users
username=$(id -u -n)
info "The user is: '$username'"
-if [ -f "$allowed_users_file" ]; then
+if test -f "$allowed_users_file"
+then
rc=$(cat $allowed_users_file | grep -v '^#' | grep -v '^$' |
- while read head_pattern user_patterns; do
- matchlen=$(expr "$1" : "$head_pattern")
- if [ "$matchlen" == "${#1}" ]; then
- info "Found matching head pattern: '$head_pattern'"
- for user_pattern in $user_patterns; do
- info "Checking user: '$username' against pattern: '$user_pattern'"
- matchlen=$(expr "$username" : "$user_pattern")
- if [ "$matchlen" == "${#username}" ]; then
- grant "Allowing user: '$username' with pattern: '$user_pattern'"
- fi
- done
- deny "The user is not in the access list for this branch"
- fi
+ while read heads user_patterns
+ do
+ # does this rule apply to us?
+ head_pattern=${heads#+}
+ matchlen=$(expr "$1" : "${head_pattern#+}")
+ test "$matchlen" = ${#1} || continue
+
+ # if non-ff, $heads must be with the '+' prefix
+ test -n "$noff" &&
+ test "$head_pattern" = "$heads" && continue
+
+ info "Found matching head pattern: '$head_pattern'"
+ for user_pattern in $user_patterns; do
+ info "Checking user: '$username' against pattern: '$user_pattern'"
+ matchlen=$(expr "$username" : "$user_pattern")
+ if test "$matchlen" = "${#username}"
+ then
+ grant "Allowing user: '$username' with pattern: '$user_pattern'"
+ fi
+ done
+ deny "The user is not in the access list for this branch"
done
)
case "$rc" in
@@ -124,23 +133,32 @@ groups=$(id -G -n)
info "The user belongs to the following groups:"
info "'$groups'"
-if [ -f "$allowed_groups_file" ]; then
+if test -f "$allowed_groups_file"
+then
rc=$(cat $allowed_groups_file | grep -v '^#' | grep -v '^$' |
- while read head_pattern group_patterns; do
- matchlen=$(expr "$1" : "$head_pattern")
- if [ "$matchlen" == "${#1}" ]; then
- info "Found matching head pattern: '$head_pattern'"
- for group_pattern in $group_patterns; do
- for groupname in $groups; do
- info "Checking group: '$groupname' against pattern: '$group_pattern'"
- matchlen=$(expr "$groupname" : "$group_pattern")
- if [ "$matchlen" == "${#groupname}" ]; then
- grant "Allowing group: '$groupname' with pattern: '$group_pattern'"
- fi
- done
+ while read heads group_patterns
+ do
+ # does this rule apply to us?
+ head_pattern=${heads#+}
+ matchlen=$(expr "$1" : "${head_pattern#+}")
+ test "$matchlen" = ${#1} || continue
+
+ # if non-ff, $heads must be with the '+' prefix
+ test -n "$noff" &&
+ test "$head_pattern" = "$heads" && continue
+
+ info "Found matching head pattern: '$head_pattern'"
+ for group_pattern in $group_patterns; do
+ for groupname in $groups; do
+ info "Checking group: '$groupname' against pattern: '$group_pattern'"
+ matchlen=$(expr "$groupname" : "$group_pattern")
+ if test "$matchlen" = "${#groupname}"
+ then
+ grant "Allowing group: '$groupname' with pattern: '$group_pattern'"
+ fi
done
- deny "None of the user's groups are in the access list for this branch"
- fi
+ done
+ deny "None of the user's groups are in the access list for this branch"
done
)
case "$rc" in
@@ -159,6 +177,7 @@ allowed-groups, to describe which heads can be pushed into by
whom. The format of each file would look like this:
refs/heads/master junio
+ +refs/heads/pu junio
refs/heads/cogito$ pasky
refs/heads/bw/.* linus
refs/heads/tmp/.* .*
@@ -166,7 +185,8 @@ whom. The format of each file would look like this:
With this, Linus can push or create "bw/penguin" or "bw/zebra"
or "bw/panda" branches, Pasky can do only "cogito", and JC can
-do master branch and make versioned tags. And anybody can do
-tmp/blah branches.
+do master and pu branches and make versioned tags. And anybody
+can do tmp/blah branches. The '+' sign at the pu record means
+that JC can make non-fast-forward pushes on it.
------------
diff --git a/Documentation/i18n.txt b/Documentation/i18n.txt
index 1e188e6e7..fb0d7da56 100644
--- a/Documentation/i18n.txt
+++ b/Documentation/i18n.txt
@@ -21,7 +21,7 @@ project find it more convenient to use legacy encodings, git
does not forbid it. However, there are a few things to keep in
mind.
-. `git-commit-tree` (hence, `git-commit` which uses it) issues
+. 'git-commit-tree' (hence, 'git-commit' which uses it) issues
a warning if the commit log message given to it does not look
like a valid UTF-8 string, unless you explicitly say your
project uses a legacy encoding. The way to say this is to
@@ -37,7 +37,7 @@ of `i18n.commitencoding` in its `encoding` header. This is to
help other people who look at them later. Lack of this header
implies that the commit log message is encoded in UTF-8.
-. `git-log`, `git-show` and friends looks at the `encoding`
+. 'git-log', 'git-show' and friends looks at the `encoding`
header of a commit object, and tries to re-code the log
message into UTF-8 unless otherwise specified. You can
specify the desired output encoding with
diff --git a/Documentation/install-doc-quick.sh b/Documentation/install-doc-quick.sh
index 5433cf8ce..35f440876 100755
--- a/Documentation/install-doc-quick.sh
+++ b/Documentation/install-doc-quick.sh
@@ -6,7 +6,7 @@ head="$1"
mandir="$2"
SUBDIRECTORY_OK=t
USAGE='<refname> <target directory>'
-. git-sh-setup
+. "$(git --exec-path)"/git-sh-setup
cd_to_toplevel
test -z "$mandir" && usage
diff --git a/Documentation/manpage-1.72.xsl b/Documentation/manpage-1.72.xsl
new file mode 100644
index 000000000..4065a3a27
--- /dev/null
+++ b/Documentation/manpage-1.72.xsl
@@ -0,0 +1,21 @@
+<!-- Based on callouts.xsl. Fixes man page callouts for DocBook 1.72 XSL -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:param name="man.output.quietly" select="1"/>
+<xsl:param name="refentry.meta.get.quietly" select="1"/>
+
+<xsl:template match="co">
+ <xsl:value-of select="concat('&#x2593;fB(',substring-after(@id,'-'),')&#x2593;fR')"/>
+</xsl:template>
+<xsl:template match="calloutlist">
+ <xsl:text>&#x2302;sp&#10;</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>&#10;</xsl:text>
+</xsl:template>
+<xsl:template match="callout">
+ <xsl:value-of select="concat('&#x2593;fB',substring-after(@arearefs,'-'),'. &#x2593;fR')"/>
+ <xsl:apply-templates/>
+ <xsl:text>&#x2302;br&#10;</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/Documentation/merge-config.txt b/Documentation/merge-config.txt
new file mode 100644
index 000000000..00277e061
--- /dev/null
+++ b/Documentation/merge-config.txt
@@ -0,0 +1,40 @@
+merge.stat::
+ Whether to print the diffstat between ORIG_HEAD and merge result
+ at the end of the merge. True by default.
+
+merge.log::
+ Whether to include summaries of merged commits in newly created
+ merge commit messages. False by default.
+
+merge.renameLimit::
+ The number of files to consider when performing rename detection
+ during a merge; if not specified, defaults to the value of
+ diff.renameLimit.
+
+merge.tool::
+ Controls which merge resolution program is used by
+ linkgit:git-mergetool[1]. Valid built-in values are: "kdiff3",
+ "tkdiff", "meld", "xxdiff", "emerge", "vimdiff", "gvimdiff", and
+ "opendiff". Any other value is treated is custom merge tool
+ and there must be a corresponding mergetool.<tool>.cmd option.
+
+merge.verbosity::
+ Controls the amount of output shown by the recursive merge
+ strategy. Level 0 outputs nothing except a final error
+ message if conflicts were detected. Level 1 outputs only
+ conflicts, 2 outputs conflicts and file changes. Level 5 and
+ above outputs debugging information. The default is level 2.
+ Can be overridden by 'GIT_MERGE_VERBOSITY' environment variable.
+
+merge.<driver>.name::
+ Defines a human readable name for a custom low-level
+ merge driver. See linkgit:gitattributes[5] for details.
+
+merge.<driver>.driver::
+ Defines the command that implements a custom low-level
+ merge driver. See linkgit:gitattributes[5] for details.
+
+merge.<driver>.recursive::
+ Names a low-level merge driver to be used when
+ performing an internal merge between common ancestors.
+ See linkgit:gitattributes[5] for details.
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 9f1fc8255..007909a82 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt
@@ -1,10 +1,25 @@
---summary::
+--stat::
Show a diffstat at the end of the merge. The diffstat is also
- controlled by the configuration option merge.diffstat.
+ controlled by the configuration option merge.stat.
--n, \--no-summary::
+-n::
+--no-stat::
Do not show diffstat at the end of the merge.
+--summary::
+--no-summary::
+ Synonyms to --stat and --no-stat; these are deprecated and will be
+ removed in the future.
+
+--log::
+ In addition to branch names, populate the log message with
+ one-line descriptions from the actual commits that are being
+ merged.
+
+--no-log::
+ Do not list one-line descriptions from the actual commits being
+ merged.
+
--no-commit::
Perform the merge but pretend the merge failed and do
not autocommit, to give the user a chance to inspect and
@@ -36,9 +51,10 @@
a fast-forward, only update the branch pointer. This is
the default behavior of git-merge.
--s <strategy>, \--strategy=<strategy>::
+-s <strategy>::
+--strategy=<strategy>::
Use the given merge strategy; can be supplied more than
once to specify them in the order they should be tried.
If there is no `-s` option, a built-in list of strategies
- is used instead (`git-merge-recursive` when merging a single
- head, `git-merge-octopus` otherwise).
+ is used instead ('git-merge-recursive' when merging a single
+ head, 'git-merge-octopus' otherwise).
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 7df0266ba..1276f858a 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -33,3 +33,10 @@ ours::
merge is always the current branch head. It is meant to
be used to supersede old development history of side
branches.
+
+subtree::
+ This is a modified recursive strategy. When merging trees A and
+ B, if B corresponds to a subtree of A, B is first adjusted to
+ match the tree structure of A, instead of reading the trees at
+ the same level. This adjustment is also done to the common
+ ancestor tree.
diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 0193c3ce5..c11d49577 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -30,7 +30,7 @@ This is designed to be as compact as possible.
commit <sha1>
Author: <author>
- Date: <date>
+ Date: <author date>
<title line>
@@ -50,9 +50,9 @@ This is designed to be as compact as possible.
commit <sha1>
Author: <author>
- AuthorDate: <date & time>
+ AuthorDate: <author date>
Commit: <committer>
- CommitDate: <date & time>
+ CommitDate: <committer date>
<title line>
@@ -62,7 +62,7 @@ This is designed to be as compact as possible.
From <sha1> <date>
From: <author>
- Date: <date & time>
+ Date: <author date>
Subject: [PATCH] <title line>
<full commit message>
@@ -101,6 +101,7 @@ The placeholders are:
- '%P': parent hashes
- '%p': abbreviated parent hashes
- '%an': author name
+- '%aN': author name (respecting .mailmap)
- '%ae': author email
- '%ad': author date
- '%aD': author date, RFC2822 style
@@ -108,6 +109,7 @@ The placeholders are:
- '%at': author date, UNIX timestamp
- '%ai': author date, ISO 8601 format
- '%cn': committer name
+- '%cN': committer name (respecting .mailmap)
- '%ce': committer email
- '%cd': committer date
- '%cD': committer date, RFC2822 style
@@ -123,3 +125,26 @@ The placeholders are:
- '%Creset': reset color
- '%m': left, right or boundary mark
- '%n': newline
+- '%x00': print a byte from a hex code
+
+* 'tformat:'
++
+The 'tformat:' format works exactly like 'format:', except that it
+provides "terminator" semantics instead of "separator" semantics. In
+other words, each commit has the message terminator character (usually a
+newline) appended, rather than a separator placed between entries.
+This means that the final entry of a single-line format will be properly
+terminated with a new line, just as the "oneline" format does.
+For example:
++
+---------------------
+$ git log -2 --pretty=format:%h 4da45bef \
+ | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
+4da45be
+7134973 -- NO NEWLINE
+
+$ git log -2 --pretty=tformat:%h 4da45bef \
+ | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
+4da45be
+7134973
+---------------------
diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt
index 973d8dd73..6d66c74cc 100644
--- a/Documentation/pretty-options.txt
+++ b/Documentation/pretty-options.txt
@@ -4,6 +4,9 @@
where '<format>' can be one of 'oneline', 'short', 'medium',
'full', 'fuller', 'email', 'raw' and 'format:<string>'.
When omitted, the format defaults to 'medium'.
++
+Note: you can specify the default pretty format in the repository
+configuration (see linkgit:git-config[1]).
--abbrev-commit::
Instead of showing the full 40-byte hexadecimal commit object
diff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt
index b6eb7fc61..ebdd948cd 100644
--- a/Documentation/pull-fetch-param.txt
+++ b/Documentation/pull-fetch-param.txt
@@ -1,10 +1,12 @@
<repository>::
The "remote" repository that is the source of a fetch
- or pull operation. See the section <<URLS,GIT URLS>> below.
+ or pull operation. This parameter can be either a URL
+ (see the section <<URLS,GIT URLS>> below) or the name
+ of a remote (see the section <<REMOTES,REMOTES>> below).
<refspec>::
The canonical format of a <refspec> parameter is
- `+?<src>:<dst>`; that is, an optional plus `+`, followed
+ `+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
by the source ref, followed by a colon `:`, followed by
the destination ref.
+
@@ -30,7 +32,7 @@ must know this is the expected usage pattern for a branch.
[NOTE]
You never do your own development on branches that appear
on the right hand side of a <refspec> colon on `Pull:` lines;
-they are to be updated by `git-fetch`. If you intend to do
+they are to be updated by 'git-fetch'. If you intend to do
development derived from a remote branch `B`, have a `Pull:`
line to track it (i.e. `Pull: B:remote-B`), and have a separate
branch `my-B` to do your development on top of it. The latter
@@ -42,13 +44,13 @@ on the remote branch, merge it into your development branch with
+
[NOTE]
There is a difference between listing multiple <refspec>
-directly on `git-pull` command line and having multiple
+directly on 'git-pull' command line and having multiple
`Pull:` <refspec> lines for a <repository> and running
-`git-pull` command without any explicit <refspec> parameters.
+'git-pull' command without any explicit <refspec> parameters.
<refspec> listed explicitly on the command line are always
merged into the current branch after fetching. In other words,
if you list more than one remote refs, you would be making
-an Octopus. While `git-pull` run without any explicit <refspec>
+an Octopus. While 'git-pull' run without any explicit <refspec>
parameter takes default <refspec>s from `Pull:` lines, it
merges only the first <refspec> found into the current branch,
after fetching all the remote refs. This is because making an
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index a8138e27a..735cf07b2 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -13,10 +13,11 @@ include::pretty-options.txt[]
Synonym for `--date=relative`.
---date={relative,local,default,iso,rfc}::
+--date={relative,local,default,iso,rfc,short}::
Only takes effect for dates shown in human-readable format, such
- as when using "--pretty".
+ as when using "--pretty". `log.date` config variable sets a default
+ value for log command's --date option.
+
`--date=relative` shows dates relative to the current time,
e.g. "2 hours ago".
@@ -33,17 +34,27 @@ format, often found in E-mail messages.
`--date=default` shows timestamps in the original timezone
(either committer's or author's).
+ifdef::git-rev-list[]
--header::
Print the contents of the commit in raw-format; each record is
separated with a NUL character.
+endif::git-rev-list[]
--parents::
- Print the parents of the commit.
+ Print the parents of the commit. Also enables parent
+ rewriting, see 'History Simplification' below.
+
+--children::
+
+ Print the children of the commit. Also enables parent
+ rewriting, see 'History Simplification' below.
+ifdef::git-rev-list[]
--timestamp::
Print the raw commit timestamp.
+endif::git-rev-list[]
--left-right::
@@ -62,7 +73,7 @@ For example, if you have this topology:
o---x---a---a branch A
-----------------------------------------------------------------------
+
-you would get an output line this:
+you would get an output like this:
+
-----------------------------------------------------------------------
$ git rev-list --left-right --boundary --pretty=oneline A...B
@@ -75,6 +86,17 @@ you would get an output line this:
-xxxxxxx... 1st on a
-----------------------------------------------------------------------
+--graph::
+
+ Draw a text-based graphical representation of the commit history
+ on the left hand side of the output. This may cause extra lines
+ to be printed in between commits, in order for the graph history
+ to be drawn properly.
++
+This implies the '--topo-order' option by default, but the
+'--date-order' option may also be specified.
+
+ifndef::git-rev-list[]
Diff Formatting
~~~~~~~~~~~~~~~
@@ -93,9 +115,9 @@ options may be given. See linkgit:git-diff-files[1] for more options.
--cc::
This flag implies the '-c' options and further compresses the
- patch output by omitting hunks that show differences from only
- one parent, or show the same change from all but one parent for
- an Octopus merge.
+ patch output by omitting uninteresting hunks whose contents in
+ the parents have only two variants and the merge result picks
+ one of them without modification.
-r::
@@ -104,6 +126,7 @@ options may be given. See linkgit:git-diff-files[1] for more options.
-t::
Show the tree objects in the diff output. This implies '-r'.
+endif::git-rev-list[]
Commit Limiting
~~~~~~~~~~~~~~~
@@ -114,7 +137,8 @@ limiting may be applied.
--
--n 'number', --max-count='number'::
+-n 'number'::
+--max-count='number'::
Limit the number of commits output.
@@ -122,19 +146,25 @@ limiting may be applied.
Skip 'number' commits before starting to show the commit output.
---since='date', --after='date'::
+--since='date'::
+--after='date'::
Show commits more recent than a specific date.
---until='date', --before='date'::
+--until='date'::
+--before='date'::
Show commits older than a specific date.
---max-age='timestamp', --min-age='timestamp'::
+ifdef::git-rev-list[]
+--max-age='timestamp'::
+--min-age='timestamp'::
Limit the commits output to specified time range.
+endif::git-rev-list[]
---author='pattern', --committer='pattern'::
+--author='pattern'::
+--committer='pattern'::
Limit the commits output to ones with author/committer
header lines that match the specified pattern (regular expression).
@@ -144,26 +174,26 @@ limiting may be applied.
Limit the commits output to ones with log message that
matches the specified pattern (regular expression).
--i, --regexp-ignore-case::
+-i::
+--regexp-ignore-case::
Match the regexp limiting patterns without regard to letters case.
--E, --extended-regexp::
+-E::
+--extended-regexp::
Consider the limiting patterns to be extended regular expressions
instead of the default basic regular expressions.
---remove-empty::
+-F::
+--fixed-strings::
- Stop when a given path disappears from the tree.
+ Consider the limiting patterns to be fixed strings (don't interpret
+ pattern as a regular expression).
---full-history::
+--remove-empty::
- Show also parts of history irrelevant to current state of a given
- path. This turns off history simplification, which removed merges
- which didn't change anything at all at some child. It will still actually
- simplify away merges that didn't change anything at all into either
- child.
+ Stop when a given path disappears from the tree.
--no-merges::
@@ -188,6 +218,7 @@ limiting may be applied.
Pretend as if all the refs in `$GIT_DIR/refs/` are listed on the
command line as '<commit>'.
+ifdef::git-rev-list[]
--stdin::
In addition to the '<commit>' listed on the command
@@ -200,6 +231,7 @@ limiting may be applied.
test the exit status to see if a range of objects is fully
connected (or not). It is faster than redirecting stdout
to /dev/null as the output does not have to be formatted.
+endif::git-rev-list[]
--cherry-pick::
@@ -215,7 +247,8 @@ from the other branch (for example, "3rd on b" may be cherry-picked
from branch A). With this option, such pairs of commits are
excluded from the output.
--g, --walk-reflogs::
+-g::
+--walk-reflogs::
Instead of walking the commit ancestry chain, walk
reflog entries from the most recent one to older ones.
@@ -227,11 +260,10 @@ With '\--pretty' format other than oneline (for obvious reasons),
this causes the output to have two extra lines of information
taken from the reflog. By default, 'commit@\{Nth}' notation is
used in the output. When the starting commit is specified as
-'commit@{now}', output also uses 'commit@\{timestamp}' notation
+'commit@\{now}', output also uses 'commit@\{timestamp}' notation
instead. Under '\--pretty=oneline', the commit message is
prefixed with this information on the same line.
-
-Cannot be combined with '\--reverse'.
+This option cannot be combined with '\--reverse'.
See also linkgit:git-reflog[1].
--merge::
@@ -244,17 +276,144 @@ See also linkgit:git-reflog[1].
Output uninteresting commits at the boundary, which are usually
not shown.
---dense, --sparse::
+--
+
+History Simplification
+~~~~~~~~~~~~~~~~~~~~~~
+
+When optional paths are given, 'git-rev-list' simplifies commits with
+various strategies, according to the options you have selected.
+
+Suppose you specified `foo` as the <paths>. We shall call commits
+that modify `foo` !TREESAME, and the rest TREESAME. (In a diff
+filtered for `foo`, they look different and equal, respectively.)
+
+In the following, we will always refer to the same example history to
+illustrate the differences between simplification settings. We assume
+that you are filtering for a file `foo` in this commit graph:
+-----------------------------------------------------------------------
+ .-A---M---N---O---P
+ / / / / /
+ I B C D E
+ \ / / / /
+ `-------------'
+-----------------------------------------------------------------------
+The horizontal line of history A--P is taken to be the first parent of
+each merge. The commits are:
+
+* `I` is the initial commit, in which `foo` exists with contents
+ "asdf", and a file `quux` exists with contents "quux". Initial
+ commits are compared to an empty tree, so `I` is !TREESAME.
+
+* In `A`, `foo` contains just "foo".
+
+* `B` contains the same change as `A`. Its merge `M` is trivial and
+ hence TREESAME to all parents.
+
+* `C` does not change `foo`, but its merge `N` changes it to "foobar",
+ so it is not TREESAME to any parent.
+
+* `D` sets `foo` to "baz". Its merge `O` combines the strings from
+ `N` and `D` to "foobarbaz"; i.e., it is not TREESAME to any parent.
+
+* `E` changes `quux` to "xyzzy", and its merge `P` combines the
+ strings to "quux xyzzy". Despite appearing interesting, `P` is
+ TREESAME to all parents.
-When optional paths are given, the default behaviour ('--dense') is to
-only output commits that changes at least one of them, and also ignore
-merges that do not touch the given paths.
+'rev-list' walks backwards through history, including or excluding
+commits based on whether '\--full-history' and/or parent rewriting
+(via '\--parents' or '\--children') are used. The following settings
+are available.
+
+Default mode::
+
+ Commits are included if they are not TREESAME to any parent
+ (though this can be changed, see '\--sparse' below). If the
+ commit was a merge, and it was TREESAME to one parent, follow
+ only that parent. (Even if there are several TREESAME
+ parents, follow only one of them.) Otherwise, follow all
+ parents.
++
+This results in:
++
+-----------------------------------------------------------------------
+ .-A---N---O
+ / /
+ I---------D
+-----------------------------------------------------------------------
++
+Note how the rule to only follow the TREESAME parent, if one is
+available, removed `B` from consideration entirely. `C` was
+considered via `N`, but is TREESAME. Root commits are compared to an
+empty tree, so `I` is !TREESAME.
++
+Parent/child relations are only visible with --parents, but that does
+not affect the commits selected in default mode, so we have shown the
+parent lines.
+
+--full-history without parent rewriting::
+
+ This mode differs from the default in one point: always follow
+ all parents of a merge, even if it is TREESAME to one of them.
+ Even if more than one side of the merge has commits that are
+ included, this does not imply that the merge itself is! In
+ the example, we get
++
+-----------------------------------------------------------------------
+ I A B N D O
+-----------------------------------------------------------------------
++
+`P` and `M` were excluded because they are TREESAME to a parent. `E`,
+`C` and `B` were all walked, but only `B` was !TREESAME, so the others
+do not appear.
++
+Note that without parent rewriting, it is not really possible to talk
+about the parent/child relationships between the commits, so we show
+them disconnected.
+
+--full-history with parent rewriting::
+
+ Ordinary commits are only included if they are !TREESAME
+ (though this can be changed, see '\--sparse' below).
++
+Merges are always included. However, their parent list is rewritten:
+Along each parent, prune away commits that are not included
+themselves. This results in
++
+-----------------------------------------------------------------------
+ .-A---M---N---O---P
+ / / / / /
+ I B / D /
+ \ / / / /
+ `-------------'
+-----------------------------------------------------------------------
++
+Compare to '\--full-history' without rewriting above. Note that `E`
+was pruned away because it is TREESAME, but the parent list of P was
+rewritten to contain `E`'s parent `I`. The same happened for `C` and
+`N`. Note also that `P` was included despite being TREESAME.
+
+In addition to the above settings, you can change whether TREESAME
+affects inclusion:
+
+--dense::
+
+ Commits that are walked are included if they are not TREESAME
+ to any parent.
+
+--sparse::
+
+ All commits that are walked are included.
++
+Note that without '\--full-history', this still simplifies merges: if
+one of the parents is TREESAME, we follow only that one, so the other
+sides of the merge are never walked.
-Use the '--sparse' flag to makes the command output all eligible commits
-(still subject to count and age limitation), but apply merge
-simplification nevertheless.
ifdef::git-rev-list[]
+Bisection Helpers
+~~~~~~~~~~~~~~~~~
+
--bisect::
Limit output to the one commit object which is roughly halfway between
@@ -304,7 +463,6 @@ after all the sorted commit objects, there will be the same text as if
`--bisect-vars` had been used alone.
endif::git-rev-list[]
---
Commit Ordering
~~~~~~~~~~~~~~~
diff --git a/Documentation/technical/api-builtin.txt b/Documentation/technical/api-builtin.txt
index 52cdb4c52..7ede1e64e 100644
--- a/Documentation/technical/api-builtin.txt
+++ b/Documentation/technical/api-builtin.txt
@@ -4,7 +4,7 @@ builtin API
Adding a new built-in
---------------------
-There are 4 things to do to add a bulit-in command implementation to
+There are 4 things to do to add a built-in command implementation to
git:
. Define the implementation of the built-in command `foo` with
@@ -18,8 +18,8 @@ git:
defined in `git.c`. The entry should look like:
{ "foo", cmd_foo, <options> },
-
- where options is the bitwise-or of:
++
+where options is the bitwise-or of:
`RUN_SETUP`::
@@ -33,6 +33,12 @@ git:
If the standard output is connected to a tty, spawn a pager and
feed our output to it.
+`NEED_WORK_TREE`::
+
+ Make sure there is a work tree, i.e. the command cannot act
+ on bare repositories.
+ This makes only sense when `RUN_SETUP` is also set.
+
. Add `builtin-foo.o` to `BUILTIN_OBJS` in `Makefile`.
Additionally, if `foo` is a new command, there are 3 more things to do:
@@ -41,8 +47,7 @@ Additionally, if `foo` is a new command, there are 3 more things to do:
. Write documentation in `Documentation/git-foo.txt`.
-. Add an entry for `git-foo` to the list at the end of
- `Documentation/cmd-list.perl`.
+. Add an entry for `git-foo` to `command-list.txt`.
How a built-in is called
diff --git a/Documentation/technical/api-diff.txt b/Documentation/technical/api-diff.txt
index 83b007e70..20b0241d3 100644
--- a/Documentation/technical/api-diff.txt
+++ b/Documentation/technical/api-diff.txt
@@ -39,7 +39,7 @@ Calling sequence
* Once you finish feeding the pairs of files, call `diffcore_std()`.
This will tell the diffcore library to go ahead and do its work.
-* Calling `diffcore_flush()` will produce the output.
+* Calling `diff_flush()` will produce the output.
Data structures
diff --git a/Documentation/technical/api-history-graph.txt b/Documentation/technical/api-history-graph.txt
new file mode 100644
index 000000000..e9559790a
--- /dev/null
+++ b/Documentation/technical/api-history-graph.txt
@@ -0,0 +1,179 @@
+history graph API
+=================
+
+The graph API is used to draw a text-based representation of the commit
+history. The API generates the graph in a line-by-line fashion.
+
+Functions
+---------
+
+Core functions:
+
+* `graph_init()` creates a new `struct git_graph`
+
+* `graph_release()` destroys a `struct git_graph`, and frees the memory
+ associated with it.
+
+* `graph_update()` moves the graph to a new commit.
+
+* `graph_next_line()` outputs the next line of the graph into a strbuf. It
+ does not add a terminating newline.
+
+* `graph_padding_line()` outputs a line of vertical padding in the graph. It
+ is similar to `graph_next_line()`, but is guaranteed to never print the line
+ containing the current commit. Where `graph_next_line()` would print the
+ commit line next, `graph_padding_line()` prints a line that simply extends
+ all branch lines downwards one row, leaving their positions unchanged.
+
+* `graph_is_commit_finished()` determines if the graph has output all lines
+ necessary for the current commit. If `graph_update()` is called before all
+ lines for the current commit have been printed, the next call to
+ `graph_next_line()` will output an ellipsis, to indicate that a portion of
+ the graph was omitted.
+
+The following utility functions are wrappers around `graph_next_line()` and
+`graph_is_commit_finished()`. They always print the output to stdout.
+They can all be called with a NULL graph argument, in which case no graph
+output will be printed.
+
+* `graph_show_commit()` calls `graph_next_line()` until it returns non-zero.
+ This prints all graph lines up to, and including, the line containing this
+ commit. Output is printed to stdout. The last line printed does not contain
+ a terminating newline. This should not be called if the commit line has
+ already been printed, or it will loop forever.
+
+* `graph_show_oneline()` calls `graph_next_line()` and prints the result to
+ stdout. The line printed does not contain a terminating newline.
+
+* `graph_show_padding()` calls `graph_padding_line()` and prints the result to
+ stdout. The line printed does not contain a terminating newline.
+
+* `graph_show_remainder()` calls `graph_next_line()` until
+ `graph_is_commit_finished()` returns non-zero. Output is printed to stdout.
+ The last line printed does not contain a terminating newline. Returns 1 if
+ output was printed, and 0 if no output was necessary.
+
+* `graph_show_strbuf()` prints the specified strbuf to stdout, prefixing all
+ lines but the first with a graph line. The caller is responsible for
+ ensuring graph output for the first line has already been printed to stdout.
+ (This can be done with `graph_show_commit()` or `graph_show_oneline()`.) If
+ a NULL graph is supplied, the strbuf is printed as-is.
+
+* `graph_show_commit_msg()` is similar to `graph_show_strbuf()`, but it also
+ prints the remainder of the graph, if more lines are needed after the strbuf
+ ends. It is better than directly calling `graph_show_strbuf()` followed by
+ `graph_show_remainder()` since it properly handles buffers that do not end in
+ a terminating newline. The output printed by `graph_show_commit_msg()` will
+ end in a newline if and only if the strbuf ends in a newline.
+
+Data structure
+--------------
+`struct git_graph` is an opaque data type used to store the current graph
+state.
+
+Calling sequence
+----------------
+
+* Create a `struct git_graph` by calling `graph_init()`. When using the
+ revision walking API, this is done automatically by `setup_revisions()` if
+ the '--graph' option is supplied.
+
+* Use the revision walking API to walk through a group of contiguous commits.
+ The `get_revision()` function automatically calls `graph_update()` each time
+ it is invoked.
+
+* For each commit, call `graph_next_line()` repeatedly, until
+ `graph_is_commit_finished()` returns non-zero. Each call go
+ `graph_next_line()` will output a single line of the graph. The resulting
+ lines will not contain any newlines. `graph_next_line()` returns 1 if the
+ resulting line contains the current commit, or 0 if this is merely a line
+ needed to adjust the graph before or after the current commit. This return
+ value can be used to determine where to print the commit summary information
+ alongside the graph output.
+
+Limitations
+-----------
+
+* `graph_update()` must be called with commits in topological order. It should
+ not be called on a commit if it has already been invoked with an ancestor of
+ that commit, or the graph output will be incorrect.
+
+* `graph_update()` must be called on a contiguous group of commits. If
+ `graph_update()` is called on a particular commit, it should later be called
+ on all parents of that commit. Parents must not be skipped, or the graph
+ output will appear incorrect.
++
+`graph_update()` may be used on a pruned set of commits only if the parent list
+has been rewritten so as to include only ancestors from the pruned set.
+
+* The graph API does not currently support reverse commit ordering. In
+ order to implement reverse ordering, the graphing API needs an
+ (efficient) mechanism to find the children of a commit.
+
+Sample usage
+------------
+
+------------
+struct commit *commit;
+struct git_graph *graph = graph_init(opts);
+
+while ((commit = get_revision(opts)) != NULL) {
+ graph_update(graph, commit);
+ while (!graph_is_commit_finished(graph))
+ {
+ struct strbuf sb;
+ int is_commit_line;
+
+ strbuf_init(&sb, 0);
+ is_commit_line = graph_next_line(graph, &sb);
+ fputs(sb.buf, stdout);
+
+ if (is_commit_line)
+ log_tree_commit(opts, commit);
+ else
+ putchar(opts->diffopt.line_termination);
+ }
+}
+
+graph_release(graph);
+------------
+
+Sample output
+-------------
+
+The following is an example of the output from the graph API. This output does
+not include any commit summary information--callers are responsible for
+outputting that information, if desired.
+
+------------
+*
+*
+M
+|\
+* |
+| | *
+| \ \
+| \ \
+M-. \ \
+|\ \ \ \
+| | * | |
+| | | | | *
+| | | | | *
+| | | | | M
+| | | | | |\
+| | | | | | *
+| * | | | | |
+| | | | | M \
+| | | | | |\ |
+| | | | * | | |
+| | | | * | | |
+* | | | | | | |
+| |/ / / / / /
+|/| / / / / /
+* | | | | | |
+|/ / / / / /
+* | | | | |
+| | | | | *
+| | | | |/
+| | | | *
+------------
diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt
index b7cda94f5..539863b1f 100644
--- a/Documentation/technical/api-parse-options.txt
+++ b/Documentation/technical/api-parse-options.txt
@@ -1,6 +1,206 @@
parse-options API
=================
-Talk about <parse-options.h>
+The parse-options API is used to parse and massage options in git
+and to provide a usage help with consistent look.
-(Pierre)
+Basics
+------
+
+The argument vector `argv[]` may usually contain mandatory or optional
+'non-option arguments', e.g. a filename or a branch, and 'options'.
+Options are optional arguments that start with a dash and
+that allow to change the behavior of a command.
+
+* There are basically three types of options:
+ 'boolean' options,
+ options with (mandatory) 'arguments' and
+ options with 'optional arguments'
+ (i.e. a boolean option that can be adjusted).
+
+* There are basically two forms of options:
+ 'Short options' consist of one dash (`-`) and one alphanumeric
+ character.
+ 'Long options' begin with two dashes (`\--`) and some
+ alphanumeric characters.
+
+* Options are case-sensitive.
+ Please define 'lower-case long options' only.
+
+The parse-options API allows:
+
+* 'sticked' and 'separate form' of options with arguments.
+ `-oArg` is sticked, `-o Arg` is separate form.
+ `\--option=Arg` is sticked, `\--option Arg` is separate form.
+
+* Long options may be 'abbreviated', as long as the abbreviation
+ is unambiguous.
+
+* Short options may be bundled, e.g. `-a -b` can be specified as `-ab`.
+
+* Boolean long options can be 'negated' (or 'unset') by prepending
+ `no-`, e.g. `\--no-abbrev` instead of `\--abbrev`.
+
+* Options and non-option arguments can clearly be separated using the `\--`
+ option, e.g. `-a -b \--option \-- \--this-is-a-file` indicates that
+ `\--this-is-a-file` must not be processed as an option.
+
+Steps to parse options
+----------------------
+
+. `#include "parse-options.h"`
+
+. define a NULL-terminated
+ `static const char * const builtin_foo_usage[]` array
+ containing alternative usage strings
+
+. define `builtin_foo_options` array as described below
+ in section 'Data Structure'.
+
+. in `cmd_foo(int argc, const char **argv, const char *prefix)`
+ call
+
+ argc = parse_options(argc, argv, builtin_foo_options, builtin_foo_usage, flags);
++
+`parse_options()` will filter out the processed options of `argv[]` and leave the
+non-option arguments in `argv[]`.
+`argc` is updated appropriately because of the assignment.
++
+Flags are the bitwise-or of:
+
+`PARSE_OPT_KEEP_DASHDASH`::
+ Keep the `\--` that usually separates options from
+ non-option arguments.
+
+`PARSE_OPT_STOP_AT_NON_OPTION`::
+ Usually the whole argument vector is massaged and reordered.
+ Using this flag, processing is stopped at the first non-option
+ argument.
+
+Data Structure
+--------------
+
+The main data structure is an array of the `option` struct,
+say `static struct option builtin_add_options[]`.
+There are some macros to easily define options:
+
+`OPT__ABBREV(&int_var)`::
+ Add `\--abbrev[=<n>]`.
+
+`OPT__DRY_RUN(&int_var)`::
+ Add `-n, \--dry-run`.
+
+`OPT__QUIET(&int_var)`::
+ Add `-q, \--quiet`.
+
+`OPT__VERBOSE(&int_var)`::
+ Add `-v, \--verbose`.
+
+`OPT_GROUP(description)`::
+ Start an option group. `description` is a short string that
+ describes the group or an empty string.
+ Start the description with an upper-case letter.
+
+`OPT_BOOLEAN(short, long, &int_var, description)`::
+ Introduce a boolean option.
+ `int_var` is incremented on each use.
+
+`OPT_BIT(short, long, &int_var, description, mask)`::
+ Introduce a boolean option.
+ If used, `int_var` is bitwise-ored with `mask`.
+
+`OPT_SET_INT(short, long, &int_var, description, integer)`::
+ Introduce a boolean option.
+ If used, set `int_var` to `integer`.
+
+`OPT_SET_PTR(short, long, &ptr_var, description, ptr)`::
+ Introduce a boolean option.
+ If used, set `ptr_var` to `ptr`.
+
+`OPT_STRING(short, long, &str_var, arg_str, description)`::
+ Introduce an option with string argument.
+ The string argument is put into `str_var`.
+
+`OPT_INTEGER(short, long, &int_var, description)`::
+ Introduce an option with integer argument.
+ The integer is put into `int_var`.
+
+`OPT_DATE(short, long, &int_var, description)`::
+ Introduce an option with date argument, see `approxidate()`.
+ The timestamp is put into `int_var`.
+
+`OPT_CALLBACK(short, long, &var, arg_str, description, func_ptr)`::
+ Introduce an option with argument.
+ The argument will be fed into the function given by `func_ptr`
+ and the result will be put into `var`.
+ See 'Option Callbacks' below for a more elaborate description.
+
+`OPT_ARGUMENT(long, description)`::
+ Introduce a long-option argument that will be kept in `argv[]`.
+
+
+The last element of the array must be `OPT_END()`.
+
+If not stated otherwise, interpret the arguments as follows:
+
+* `short` is a character for the short option
+ (e.g. `\'e\'` for `-e`, use `0` to omit),
+
+* `long` is a string for the long option
+ (e.g. `"example"` for `\--example`, use `NULL` to omit),
+
+* `int_var` is an integer variable,
+
+* `str_var` is a string variable (`char *`),
+
+* `arg_str` is the string that is shown as argument
+ (e.g. `"branch"` will result in `<branch>`).
+ If set to `NULL`, three dots (`...`) will be displayed.
+
+* `description` is a short string to describe the effect of the option.
+ It shall begin with a lower-case letter and a full stop (`.`) shall be
+ omitted at the end.
+
+Option Callbacks
+----------------
+
+The function must be defined in this form:
+
+ int func(const struct option *opt, const char *arg, int unset)
+
+The callback mechanism is as follows:
+
+* Inside `funct`, the only interesting member of the structure
+ given by `opt` is the void pointer `opt->value`.
+ `\*opt->value` will be the value that is saved into `var`, if you
+ use `OPT_CALLBACK()`.
+ For example, do `*(unsigned long *)opt->value = 42;` to get 42
+ into an `unsigned long` variable.
+
+* Return value `0` indicates success and non-zero return
+ value will invoke `usage_with_options()` and, thus, die.
+
+* If the user negates the option, `arg` is `NULL` and `unset` is 1.
+
+Sophisticated option parsing
+----------------------------
+
+If you need, for example, option callbacks with optional arguments
+or without arguments at all, or if you need other special cases,
+that are not handled by the macros above, you need to specify the
+members of the `option` structure manually.
+
+This is not covered in this document, but well documented
+in `parse-options.h` itself.
+
+Examples
+--------
+
+See `test-parse-options.c` and
+`builtin-add.c`,
+`builtin-clone.c`,
+`builtin-commit.c`,
+`builtin-fetch.c`,
+`builtin-fsck.c`,
+`builtin-rm.c`
+for real-world examples.
diff --git a/Documentation/technical/api-path-list.txt b/Documentation/technical/api-path-list.txt
deleted file mode 100644
index d07768317..000000000
--- a/Documentation/technical/api-path-list.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-path-list API
-=============
-
-Talk about <path-list.h>, things like
-
-* it is not just paths but strings in general;
-* the calling sequence.
-
-(Dscho)
diff --git a/Documentation/technical/api-remote.txt b/Documentation/technical/api-remote.txt
new file mode 100644
index 000000000..073b22bd8
--- /dev/null
+++ b/Documentation/technical/api-remote.txt
@@ -0,0 +1,123 @@
+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
+fashion. Note that the code also handles plain URLs without any
+configuration, giving them just the default information.
+
+struct remote
+-------------
+
+`name`::
+
+ The user's nickname for the remote
+
+`url`::
+
+ An array of all of the url_nr URLs configured for the remote
+
+`push`::
+
+ An array of refspecs configured for pushing, with
+ push_refspec being the literal strings, and push_refspec_nr
+ being the quantity.
+
+`fetch`::
+
+ An array of refspecs configured for fetching, with
+ fetch_refspec being the literal strings, and fetch_refspec_nr
+ being the quantity.
+
+`fetch_tags`::
+
+ The setting for whether to fetch tags (as a separate rule from
+ the configured refspecs); -1 means never to fetch tags, 0
+ means to auto-follow tags based on the default heuristic, 1
+ means to always auto-follow tags, and 2 means to fetch all
+ tags.
+
+`receivepack`, `uploadpack`::
+
+ The configured helper programs to run on the remote side, for
+ git-native protocols.
+
+`http_proxy`::
+
+ The proxy to use for curl (http, https, ftp, etc.) URLs.
+
+struct remotes can be found by name with remote_get(), and iterated
+through with for_each_remote(). remote_get(NULL) will return the
+default remote, given the current branch and configuration.
+
+struct refspec
+--------------
+
+A struct refspec holds the parsed interpretation of a refspec. If it
+will force updates (starts with a '+'), force is true. If it is a
+pattern (sides end with '*') pattern is true. src and dest are the two
+sides (if a pattern, only the part outside of the wildcards); if there
+is only one side, it is src, and dst is NULL; if sides exist but are
+empty (i.e., the refspec either starts or ends with ':'), the
+corresponding side is "".
+
+This parsing can be done to an array of strings to give an array of
+struct refpsecs with parse_ref_spec().
+
+remote_find_tracking(), given a remote and a struct refspec with
+either src or dst filled out, will fill out the other such that the
+result is in the "fetch" specification for the remote (note that this
+evaluates patterns and returns a single result).
+
+struct branch
+-------------
+
+Note that this may end up moving to branch.h
+
+struct branch holds the configuration for a branch. It can be looked
+up with branch_get(name) for "refs/heads/{name}", or with
+branch_get(NULL) for HEAD.
+
+It contains:
+
+`name`::
+
+ The short name of the branch.
+
+`refname`::
+
+ The full path for the branch ref.
+
+`remote_name`::
+
+ The name of the remote listed in the configuration.
+
+`remote`::
+
+ The struct remote for that remote.
+
+`merge_name`::
+
+ An array of the "merge" lines in the configuration.
+
+`merge`::
+
+ An array of the struct refspecs used for the merge lines. That
+ is, merge[i]->dst is a local tracking ref which should be
+ merged into this branch by default.
+
+`merge_nr`::
+
+ The number of merge configurations
+
+branch_has_merge_config() returns true if the given branch has merge
+configuration given.
+
+Other stuff
+-----------
+
+There is other stuff in remote.h that is related, in general, to the
+process of interacting with remotes.
+
+(Daniel Barkalow)
diff --git a/Documentation/technical/api-revision-walking.txt b/Documentation/technical/api-revision-walking.txt
index 01a24551a..996da0503 100644
--- a/Documentation/technical/api-revision-walking.txt
+++ b/Documentation/technical/api-revision-walking.txt
@@ -1,9 +1,67 @@
revision walking API
====================
+The revision walking API offers functions to build a list of revisions
+and then iterate over that list.
+
+Calling sequence
+----------------
+
+The walking API has a given calling sequence: first you need to
+initialize a rev_info structure, then add revisions to control what kind
+of revision list do you want to get, finally you can iterate over the
+revision list.
+
+Functions
+---------
+
+`init_revisions`::
+
+ Initialize a rev_info structure with default values. The second
+ parameter may be NULL or can be prefix path, and then the `.prefix`
+ variable will be set to it. This is typically the first function you
+ want to call when you want to deal with a revision list. After calling
+ this function, you are free to customize options, like set
+ `.ignore_merges` to 0 if you don't want to ignore merges, and so on. See
+ `revision.h` for a complete list of available options.
+
+`add_pending_object`::
+
+ This function can be used if you want to add commit objects as revision
+ information. You can use the `UNINTERESTING` object flag to indicate if
+ you want to include or exclude the given commit (and commits reachable
+ from the given commit) from the revision list.
++
+NOTE: If you have the commits as a string list then you probably want to
+use setup_revisions(), instead of parsing each string and using this
+function.
+
+`setup_revisions`::
+
+ Parse revision information, filling in the `rev_info` structure, and
+ removing the used arguments from the argument list. Returns the number
+ of arguments left that weren't recognized, which are also moved to the
+ head of the argument list. The last parameter is used in case no
+ parameter given by the first two arguments.
+
+`prepare_revision_walk`::
+
+ Prepares the rev_info structure for a walk. You should check if it
+ returns any error (non-zero return code) and if it does not, you can
+ start using get_revision() to do the iteration.
+
+`get_revision`::
+
+ Takes a pointer to a `rev_info` structure and iterates over it,
+ returning a `struct commit *` each time you call it. The end of the
+ revision list is indicated by returning a NULL pointer.
+
+Data structures
+---------------
+
Talk about <revision.h>, things like:
* two diff_options, one for path limiting, another for output;
-* calling sequence: init_revisions(), setup_revsions(), get_revision();
+* remaining functions;
(Linus, JC, Dscho)
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index 19d2f64f7..75aa5d492 100644
--- a/Documentation/technical/api-run-command.txt
+++ b/Documentation/technical/api-run-command.txt
@@ -1,10 +1,172 @@
run-command API
===============
-Talk about <run-command.h>, and things like:
+The run-command API offers a versatile tool to run sub-processes with
+redirected input and output as well as with a modified environment
+and an alternate current directory.
-* Environment the command runs with (e.g. GIT_DIR);
-* File descriptors and pipes;
-* Exit status;
+A similar API offers the capability to run a function asynchronously,
+which is primarily used to capture the output that the function
+produces in the caller in order to process it.
-(Hannes, Dscho, Shawn)
+
+Functions
+---------
+
+`start_command`::
+
+ Start a sub-process. Takes a pointer to a `struct child_process`
+ that specifies the details and returns pipe FDs (if requested).
+ See below for details.
+
+`finish_command`::
+
+ Wait for the completion of a sub-process that was started with
+ start_command().
+
+`run_command`::
+
+ A convenience function that encapsulates a sequence of
+ start_command() followed by finish_command(). Takes a pointer
+ to a `struct child_process` that specifies the details.
+
+`run_command_v_opt`, `run_command_v_opt_cd`, `run_command_v_opt_cd_env`::
+
+ Convenience functions that encapsulate a sequence of
+ start_command() followed by finish_command(). The argument argv
+ specifies the program and its arguments. The argument opt is zero
+ or more of the flags `RUN_COMMAND_NO_STDIN`, `RUN_GIT_CMD`, or
+ `RUN_COMMAND_STDOUT_TO_STDERR` that correspond to the members
+ .no_stdin, .git_cmd, .stdout_to_stderr of `struct child_process`.
+ The argument dir corresponds the member .dir. The argument env
+ corresponds to the member .env.
+
+`start_async`::
+
+ Run a function asynchronously. Takes a pointer to a `struct
+ async` that specifies the details and returns a pipe FD
+ from which the caller reads. See below for details.
+
+`finish_async`::
+
+ Wait for the completion of an asynchronous function that was
+ started with start_async().
+
+
+Data structures
+---------------
+
+* `struct child_process`
+
+This describes the arguments, redirections, and environment of a
+command to run in a sub-process.
+
+The caller:
+
+1. allocates and clears (memset(&chld, 0, sizeof(chld));) a
+ struct child_process variable;
+2. initializes the members;
+3. calls start_command();
+4. processes the data;
+5. closes file descriptors (if necessary; see below);
+6. calls finish_command().
+
+The .argv member is set up as an array of string pointers (NULL
+terminated), of which .argv[0] is the program name to run (usually
+without a path). If the command to run is a git command, set argv[0] to
+the command name without the 'git-' prefix and set .git_cmd = 1.
+
+The members .in, .out, .err are used to redirect stdin, stdout,
+stderr as follows:
+
+. Specify 0 to request no special redirection. No new file descriptor
+ is allocated. The child process simply inherits the channel from the
+ parent.
+
+. Specify -1 to have a pipe allocated; start_command() replaces -1
+ by the pipe FD in the following way:
+
+ .in: Returns the writable pipe end into which the caller writes;
+ the readable end of the pipe becomes the child's stdin.
+
+ .out, .err: Returns the readable pipe end from which the caller
+ reads; the writable end of the pipe end becomes child's
+ stdout/stderr.
+
+ The caller of start_command() must close the so returned FDs
+ after it has completed reading from/writing to it!
+
+. Specify a file descriptor > 0 to be used by the child:
+
+ .in: The FD must be readable; it becomes child's stdin.
+ .out: The FD must be writable; it becomes child's stdout.
+ .err > 0 is not supported.
+
+ The specified FD is closed by start_command(), even if it fails to
+ run the sub-process!
+
+. Special forms of redirection are available by setting these members
+ to 1:
+
+ .no_stdin, .no_stdout, .no_stderr: The respective channel is
+ redirected to /dev/null.
+
+ .stdout_to_stderr: stdout of the child is redirected to its
+ stderr. This happens after stderr is itself redirected.
+ So stdout will follow stderr to wherever it is
+ redirected.
+
+To modify the environment of the sub-process, specify an array of
+string pointers (NULL terminated) in .env:
+
+. If the string is of the form "VAR=value", i.e. it contains '='
+ the variable is added to the child process's environment.
+
+. If the string does not contain '=', it names an environment
+ variable that will be removed from the child process's environment.
+
+To specify a new initial working directory for the sub-process,
+specify it in the .dir member.
+
+
+* `struct async`
+
+This describes a function to run asynchronously, whose purpose is
+to produce output that the caller reads.
+
+The caller:
+
+1. allocates and clears (memset(&asy, 0, sizeof(asy));) a
+ struct async variable;
+2. initializes .proc and .data;
+3. calls start_async();
+4. processes the data by reading from the fd in .out;
+5. closes .out;
+6. calls finish_async().
+
+The function pointer in .proc has the following signature:
+
+ int proc(int fd, void *data);
+
+. fd specifies a writable file descriptor to which the function must
+ write the data that it produces. The function *must* close this
+ descriptor before it returns.
+
+. data is the value that the caller has specified in the .data member
+ of struct async.
+
+. The return value of the function is 0 on success and non-zero
+ on failure. If the function indicates failure, finish_async() will
+ report failure as well.
+
+
+There are serious restrictions on what the asynchronous function can do
+because this facility is implemented by a pipe to a forked process on
+UNIX, but by a thread in the same address space on Windows:
+
+. It cannot change the program's state (global variables, environment,
+ etc.) in a way that the caller notices; in other words, .out is the
+ only communication channel to the caller.
+
+. It must not change the program's state that the caller of the
+ facility also uses.
diff --git a/Documentation/technical/api-strbuf.txt b/Documentation/technical/api-strbuf.txt
index a52e4f36d..a9668e5f2 100644
--- a/Documentation/technical/api-strbuf.txt
+++ b/Documentation/technical/api-strbuf.txt
@@ -1,6 +1,241 @@
strbuf API
==========
-Talk about <strbuf.h>
+strbuf's are meant to be used with all the usual C string and memory
+APIs. Given that the length of the buffer is known, it's often better to
+use the mem* functions than a str* one (memchr vs. strchr e.g.).
+Though, one has to be careful about the fact that str* functions often
+stop on NULs and that strbufs may have embedded NULs.
-(Pierre, JC)
+An strbuf is NUL terminated for convenience, but no function in the
+strbuf API actually relies on the string being free of NULs.
+
+strbufs has some invariants that are very important to keep in mind:
+
+. The `buf` member is never NULL, so you it can be used in any usual C
+string operations safely. strbuf's _have_ to be initialized either by
+`strbuf_init()` or by `= STRBUF_INIT` before the invariants, though.
++
+Do *not* assume anything on what `buf` really is (e.g. if it is
+allocated memory or not), use `strbuf_detach()` to unwrap a memory
+buffer from its strbuf shell in a safe way. That is the sole supported
+way. This will give you a malloced buffer that you can later `free()`.
++
+However, it it totally safe to modify anything in the string pointed by
+the `buf` member, between the indices `0` and `len-1` (inclusive).
+
+. The `buf` member is a byte array that has at least `len + 1` bytes
+ allocated. The extra byte is used to store a `'\0'`, allowing the
+ `buf` member to be a valid C-string. Every strbuf function ensure this
+ invariant is preserved.
++
+NOTE: It is OK to "play" with the buffer directly if you work it this
+ way:
++
+----
+strbuf_grow(sb, SOME_SIZE); <1>
+strbuf_setlen(sb, sb->len + SOME_OTHER_SIZE);
+----
+<1> Here, the memory array starting at `sb->buf`, and of length
+`strbuf_avail(sb)` is all yours, and you can be sure that
+`strbuf_avail(sb)` is at least `SOME_SIZE`.
++
+NOTE: `SOME_OTHER_SIZE` must be smaller or equal to `strbuf_avail(sb)`.
++
+Doing so is safe, though if it has to be done in many places, adding the
+missing API to the strbuf module is the way to go.
++
+WARNING: Do _not_ assume that the area that is yours is of size `alloc
+- 1` even if it's true in the current implementation. Alloc is somehow a
+"private" member that should not be messed with. Use `strbuf_avail()`
+instead.
+
+Data structures
+---------------
+
+* `struct strbuf`
+
+This is string buffer structure. The `len` member can be used to
+determine the current length of the string, and `buf` member provides access to
+the string itself.
+
+Functions
+---------
+
+* Life cycle
+
+`strbuf_init`::
+
+ Initialize the structure. The second parameter can be zero or a bigger
+ number to allocate memory, in case you want to prevent further reallocs.
+
+`strbuf_release`::
+
+ Release a string buffer and the memory it used. You should not use the
+ string buffer after using this function, unless you initialize it again.
+
+`strbuf_detach`::
+
+ Detach the string from the strbuf and returns it; you now own the
+ storage the string occupies and it is your responsibility from then on
+ to release it with `free(3)` when you are done with it.
+
+`strbuf_attach`::
+
+ Attach a string to a buffer. You should specify the string to attach,
+ the current length of the string and the amount of allocated memory.
+ The amount must be larger than the string length, because the string you
+ pass is supposed to be a NUL-terminated string. This string _must_ be
+ malloc()ed, and after attaching, the pointer cannot be relied upon
+ anymore, and neither be free()d directly.
+
+`strbuf_swap`::
+
+ Swap the contents of two string buffers.
+
+* Related to the size of the buffer
+
+`strbuf_avail`::
+
+ Determine the amount of allocated but unused memory.
+
+`strbuf_grow`::
+
+ Ensure that at least this amount of unused memory is available after
+ `len`. This is used when you know a typical size for what you will add
+ and want to avoid repetitive automatic resizing of the underlying buffer.
+ This is never a needed operation, but can be critical for performance in
+ some cases.
+
+`strbuf_setlen`::
+
+ Set the length of the buffer to a given value. This function does *not*
+ allocate new memory, so you should not perform a `strbuf_setlen()` to a
+ length that is larger than `len + strbuf_avail()`. `strbuf_setlen()` is
+ just meant as a 'please fix invariants from this strbuf I just messed
+ with'.
+
+`strbuf_reset`::
+
+ Empty the buffer by setting the size of it to zero.
+
+* Related to the contents of the buffer
+
+`strbuf_rtrim`::
+
+ Strip whitespace from the end of a string.
+
+`strbuf_cmp`::
+
+ Compare two buffers. Returns an integer less than, equal to, or greater
+ than zero if the first buffer is found, respectively, to be less than,
+ to match, or be greater than the second buffer.
+
+* Adding data to the buffer
+
+NOTE: All of these functions in this section will grow the buffer as
+ necessary.
+
+`strbuf_addch`::
+
+ Add a single character to the buffer.
+
+`strbuf_insert`::
+
+ Insert data to the given position of the buffer. The remaining contents
+ will be shifted, not overwritten.
+
+`strbuf_remove`::
+
+ Remove given amount of data from a given position of the buffer.
+
+`strbuf_splice`::
+
+ Remove the bytes between `pos..pos+len` and replace it with the given
+ data.
+
+`strbuf_add`::
+
+ Add data of given length to the buffer.
+
+`strbuf_addstr`::
+
+Add a NUL-terminated string to the buffer.
++
+NOTE: This function will *always* be implemented as an inline or a macro
+that expands to:
++
+----
+strbuf_add(..., s, strlen(s));
+----
++
+Meaning that this is efficient to write things like:
++
+----
+strbuf_addstr(sb, "immediate string");
+----
+
+`strbuf_addbuf`::
+
+ Copy the contents of an other buffer at the end of the current one.
+
+`strbuf_adddup`::
+
+ Copy part of the buffer from a given position till a given length to the
+ end of the buffer.
+
+`strbuf_expand`::
+
+ This function can be used to expand a format string containing
+ placeholders. To that end, it parses the string and calls the specified
+ function for every percent sign found.
++
+The callback function is given a pointer to the character after the `%`
+and a pointer to the struct strbuf. It is expected to add the expanded
+version of the placeholder to the strbuf, e.g. to add a newline
+character if the letter `n` appears after a `%`. The function returns
+the length of the placeholder recognized and `strbuf_expand()` skips
+over it.
++
+All other characters (non-percent and not skipped ones) are copied
+verbatim to the strbuf. If the callback returned zero, meaning that the
+placeholder is unknown, then the percent sign is copied, too.
++
+In order to facilitate caching and to make it possible to give
+parameters to the callback, `strbuf_expand()` passes a context pointer,
+which can be used by the programmer of the callback as she sees fit.
+
+`strbuf_addf`::
+
+ Add a formatted string to the buffer.
+
+`strbuf_fread`::
+
+ Read a given size of data from a FILE* pointer to the buffer.
++
+NOTE: The buffer is rewinded if the read fails. If -1 is returned,
+`errno` must be consulted, like you would do for `read(3)`.
+`strbuf_read()`, `strbuf_read_file()` and `strbuf_getline()` has the
+same behaviour as well.
+
+`strbuf_read`::
+
+ Read the contents of a given file descriptor. The third argument can be
+ used to give a hint about the file size, to avoid reallocs.
+
+`strbuf_read_file`::
+
+ Read the contents of a file, specified by its path. The third argument
+ can be used to give a hint about the file size, to avoid reallocs.
+
+`strbuf_getline`::
+
+ Read a line from a FILE* pointer. The second argument specifies the line
+ terminator character, typically `'\n'`.
+
+`stripspace`::
+
+ Strip whitespace from a buffer. The second parameter controls if
+ comments are considered contents to be removed or not.
+
+`launch_editor`::
diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
new file mode 100644
index 000000000..293bb15d2
--- /dev/null
+++ b/Documentation/technical/api-string-list.txt
@@ -0,0 +1,128 @@
+string-list API
+===============
+
+The string_list API offers a data structure and functions to handle sorted
+and unsorted string lists.
+
+The 'string_list' struct used to be called 'path_list', but was renamed
+because it is not specific to paths.
+
+The caller:
+
+. Allocates and clears a `struct string_list` variable.
+
+. Initializes the members. You might want to set the flag `strdup_strings`
+ if the strings should be strdup()ed. For example, this is necessary
+ when you add something like git_path("..."), since that function returns
+ a static buffer that will change with the next call to git_path().
++
+If you need something advanced, you can manually malloc() the `items`
+member (you need this if you add things later) and you should set the
+`nr` and `alloc` members in that case, too.
+
+. Adds new items to the list, using `string_list_append` or
+ `string_list_insert`.
+
+. Can check if a string is in the list using `string_list_has_string` or
+ `unsorted_string_list_has_string` and get it from the list using
+ `string_list_lookup` for sorted lists.
+
+. Can sort an unsorted list using `sort_string_list`.
+
+. Finally it should free the list using `string_list_clear`.
+
+Example:
+
+----
+struct string_list list;
+int i;
+
+memset(&list, 0, sizeof(struct string_list));
+string_list_append("foo", &list);
+string_list_append("bar", &list);
+for (i = 0; i < list.nr; i++)
+ printf("%s\n", list.items[i].string)
+----
+
+NOTE: It is more efficient to build an unsorted list and sort it
+afterwards, instead of building a sorted list (`O(n log n)` instead of
+`O(n^2)`).
++
+However, if you use the list to check if a certain string was added
+already, you should not do that (using unsorted_string_list_has_string()),
+because the complexity would be quadratic again (but with a worse factor).
+
+Functions
+---------
+
+* General ones (works with sorted and unsorted lists as well)
+
+`print_string_list`::
+
+ Dump a string_list to stdout, useful mainly for debugging purposes. It
+ can take an optional header argument and it writes out the
+ string-pointer pairs of the string_list, each one in its own line.
+
+`string_list_clear`::
+
+ Free a string_list. The `string` pointer of the items will be freed in
+ case the `strdup_strings` member of the string_list is set. The second
+ parameter controls if the `util` pointer of the items should be freed
+ or not.
+
+* Functions for sorted lists only
+
+`string_list_has_string`::
+
+ Determine if the string_list has a given string or not.
+
+`string_list_insert`::
+
+ Insert a new element to the string_list. The returned pointer can be
+ handy if you want to write something to the `util` pointer of the
+ string_list_item containing the just added string.
++
+Since this function uses xrealloc() (which die()s if it fails) if the
+list needs to grow, it is safe not to check the pointer. I.e. you may
+write `string_list_insert(...)->util = ...;`.
+
+`string_list_lookup`::
+
+ Look up a given string in the string_list, returning the containing
+ string_list_item. If the string is not found, NULL is returned.
+
+* Functions for unsorted lists only
+
+`string_list_append`::
+
+ Append a new string to the end of the string_list.
+
+`sort_string_list`::
+
+ Make an unsorted list sorted.
+
+`unsorted_string_list_has_string`::
+
+ It's like `string_list_has_string()` but for unsorted lists.
++
+This function needs to look through all items, as opposed to its
+counterpart for sorted lists, which performs a binary search.
+
+Data structures
+---------------
+
+* `struct string_list_item`
+
+Represents an item of the list. The `string` member is a pointer to the
+string, and you may use the `util` member for any purpose, if you want.
+
+* `struct string_list`
+
+Represents the list itself.
+
+. The array of items are available via the `items` member.
+. The `nr` member contains the number of items stored in the list.
+. The `alloc` member is used to avoid reallocating at every insertion.
+ You should not tamper with it.
+. Setting the `strdup_strings` member to 1 will strdup() the strings
+ before adding them, see above.
diff --git a/Documentation/technical/pack-format.txt b/Documentation/technical/pack-format.txt
index aa87756a5..1803e64e4 100644
--- a/Documentation/technical/pack-format.txt
+++ b/Documentation/technical/pack-format.txt
@@ -103,10 +103,24 @@ Pack file entry: <+
packed object data:
If it is not DELTA, then deflated bytes (the size above
is the size before compression).
- If it is DELTA, then
+ If it is REF_DELTA, then
20-byte base object name SHA1 (the size above is the
size of the delta data that follows).
delta data, deflated.
+ If it is OFS_DELTA, then
+ n-byte offset (see below) interpreted as a negative
+ offset from the type-byte of the header of the
+ ofs-delta entry (the size above is the size of
+ the delta data that follows).
+ delta data, deflated.
+
+ offset encoding:
+ n bytes with MSB set in all but the last one.
+ The offset is then the number constructed by
+ concatenating the lower 7 bit of each byte, and
+ for n >= 2 adding 2^7 + 2^14 + ... + 2^(7*(n-1))
+ to the result.
+
= Version 2 pack-*.idx files support packs larger than 4 GiB, and
diff --git a/Documentation/technical/racy-git.txt b/Documentation/technical/racy-git.txt
index 5030d9f2f..6bdf034b3 100644
--- a/Documentation/technical/racy-git.txt
+++ b/Documentation/technical/racy-git.txt
@@ -184,7 +184,7 @@ In a large project where raciness avoidance cost really matters,
however, the initial computation of all object names in the
index takes more than one second, and the index file is written
out after all that happens. Therefore the timestamp of the
-index file will be more than one seconds later than the the
+index file will be more than one seconds later than the
youngest file in the working tree. This means that in these
cases there actually will not be any racily clean entry in
the resulting index.
diff --git a/Documentation/urls-remotes.txt b/Documentation/urls-remotes.txt
index 5dd1f836c..504ae8a53 100644
--- a/Documentation/urls-remotes.txt
+++ b/Documentation/urls-remotes.txt
@@ -1,55 +1,82 @@
include::urls.txt[]
-REMOTES
--------
+REMOTES[[REMOTES]]
+------------------
-In addition to the above, as a short-hand, the name of a
-file in `$GIT_DIR/remotes` directory can be given; the
-named file should be in the following format:
+The name of one of the following can be used instead
+of a URL as `<repository>` argument:
-------------
- URL: one of the above URL format
- Push: <refspec>
- Pull: <refspec>
+* a remote in the git configuration file: `$GIT_DIR/config`,
+* a file in the `$GIT_DIR/remotes` directory, or
+* a file in the `$GIT_DIR/branches` directory.
-------------
+All of these also allow you to omit the refspec from the command line
+because they each contain a refspec which git will use by default.
-Then such a short-hand is specified in place of
-<repository> without <refspec> parameters on the command
-line, <refspec> specified on `Push:` lines or `Pull:`
-lines are used for `git-push` and `git-fetch`/`git-pull`,
-respectively. Multiple `Push:` and `Pull:` lines may
-be specified for additional branch mappings.
+Named remote in configuration file
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Or, equivalently, in the `$GIT_DIR/config` (note the use
-of `fetch` instead of `Pull:`):
+You can choose to provide the name of a remote which you had previously
+configured using linkgit:git-remote[1], linkgit:git-config[1]
+or even by a manual edit to the `$GIT_DIR/config` file. The URL of
+this remote will be used to access the repository. The refspec
+of this remote will be used by default when you do
+not provide a refspec on the command line. The entry in the
+config file would appear like this:
------------
- [remote "<remote>"]
+ [remote "<name>"]
url = <url>
push = <refspec>
fetch = <refspec>
-
------------
-The name of a file in `$GIT_DIR/branches` directory can be
-specified as an older notation short-hand; the named
-file should contain a single line, a URL in one of the
-above formats, optionally followed by a hash `#` and the
-name of remote head (URL fragment notation).
-`$GIT_DIR/branches/<remote>` file that stores a <url>
-without the fragment is equivalent to have this in the
-corresponding file in the `$GIT_DIR/remotes/` directory.
+
+Named file in `$GIT_DIR/remotes`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can choose to provide the name of a
+file in `$GIT_DIR/remotes`. The URL
+in this file will be used to access the repository. The refspec
+in this file will be used as default when you do not
+provide a refspec on the command line. This file should have the
+following format:
+
+------------
+ URL: one of the above URL format
+ Push: <refspec>
+ Pull: <refspec>
------------
- URL: <url>
- Pull: refs/heads/master:<remote>
+`Push:` lines are used by 'git-push' and
+`Pull:` lines are used by 'git-pull' and 'git-fetch'.
+Multiple `Push:` and `Pull:` lines may
+be specified for additional branch mappings.
+
+Named file in `$GIT_DIR/branches`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can choose to provide the name of a
+file in `$GIT_DIR/branches`.
+The URL in this file will be used to access the repository.
+This file should have the following format:
+
+
+------------
+ <url>#<head>
------------
-while having `<url>#<head>` is equivalent to
+`<url>` is required; `#<head>` is optional.
+When you do not provide a refspec on the command line,
+git will use the following refspec, where `<head>` defaults to `master`,
+and `<repository>` is the name of this file
+you provided in the command line.
------------
- URL: <url>
- Pull: refs/heads/<head>:<remote>
+ refs/heads/<head>:<repository>
------------
+
+
+
+
diff --git a/Documentation/urls.txt b/Documentation/urls.txt
index 81ac17f32..fa34c6747 100644
--- a/Documentation/urls.txt
+++ b/Documentation/urls.txt
@@ -44,3 +44,26 @@ endif::git-clone[]
ifdef::git-clone[]
They are equivalent, except the former implies --local option.
endif::git-clone[]
+
+
+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
+use will be rewritten into URLs that work), you can create a
+configuration section of the form:
+
+------------
+ [url "<actual url base>"]
+ insteadOf = <other url base>
+------------
+
+For example, with this:
+
+------------
+ [url "git://git.host.xz/"]
+ insteadOf = host.xz:/path/to/
+ insteadOf = work:
+------------
+
+a URL like "work:repo.git" or like "host.xz:/path/to/repo.git" will be
+rewritten in any context that takes a URL to be "git://git.host.xz/repo.git".
+
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index 40b0de087..08d1310bf 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -18,7 +18,7 @@ People needing to do actual development will also want to read
Further chapters cover more specialized topics.
Comprehensive reference documentation is available through the man
-pages. For a command such as "git clone", just use
+pages. For a command such as "git clone <repo>", just use
------------------------------------------------
$ man git-clone
@@ -178,7 +178,7 @@ As you can see, a commit shows who made the latest change, what they
did, and why.
Every commit has a 40-hexdigit id, sometimes called the "object name" or the
-"SHA1 id", shown on the first line of the "git show" output. You can usually
+"SHA1 id", shown on the first line of the "git-show" output. You can usually
refer to a commit by a shorter name, such as a tag or a branch name, but this
longer name can also be useful. Most importantly, it is a globally unique
name for this commit: so if you tell somebody else the object name (for
@@ -390,7 +390,7 @@ references with the same shorthand name, see the "SPECIFYING
REVISIONS" section of linkgit:git-rev-parse[1].
[[Updating-a-repository-with-git-fetch]]
-Updating a repository with git fetch
+Updating a repository with git-fetch
------------------------------------
Eventually the developer cloned from will do additional work in her
@@ -417,7 +417,7 @@ $ git fetch linux-nfs
-------------------------------------------------
New remote-tracking branches will be stored under the shorthand name
-that you gave "git remote add", in this case linux-nfs:
+that you gave "git-remote add", in this case linux-nfs:
-------------------------------------------------
$ git branch -r
@@ -479,10 +479,10 @@ Bisecting: 3537 revisions left to test after this
-------------------------------------------------
If you run "git branch" at this point, you'll see that git has
-temporarily moved you to a new branch named "bisect". This branch
-points to a commit (with commit id 65934...) that is reachable from
-"master" but not from v2.6.18. Compile and test it, and see whether
-it crashes. Assume it does crash. Then:
+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,
+and see whether it crashes. Assume it does crash. Then:
-------------------------------------------------
$ git bisect bad
@@ -504,8 +504,7 @@ report with the commit id. Finally, run
$ git bisect reset
-------------------------------------------------
-to return you to the branch you were on before and delete the
-temporary "bisect" branch.
+to return you to the branch you were on before.
Note that the version which git-bisect checks out for you at each
point is just a suggestion, and you're free to try a different
@@ -518,7 +517,7 @@ $ git bisect visualize
-------------------------------------------------
which will run gitk and label the commit it chose with a marker that
-says "bisect". Chose a safe-looking commit nearby, note its commit
+says "bisect". Choose a safe-looking commit nearby, note its commit
id, and check it out with:
-------------------------------------------------
@@ -528,6 +527,22 @@ $ git reset --hard fb47ddb2db...
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
+the current commit:
+
+-------------------------------------------------
+$ git bisect skip
+-------------------------------------------------
+
+In this case, though, git may not eventually be able to tell the first
+bad one between some first skipped commits and a latter bad commit.
+
+There are also ways to automate the bisecting process if you have a
+test script that can tell a good from a bad commit. See
+linkgit:git-bisect[1] for more information about this and other "git
+bisect" features.
+
[[naming-commits]]
Naming commits
--------------
@@ -1048,7 +1063,7 @@ $ git diff
shows the difference between the working tree and the index file.
-Note that "git add" always adds just the current contents of a file
+Note that "git-add" always adds just the current contents of a file
to the index; further changes to the same file will be ignored unless
you run git-add on the file again.
@@ -1111,10 +1126,10 @@ Ignoring files
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
-is just a matter of 'not' calling "`git add`" on them. But it quickly becomes
+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 .`" and "`git commit -a`" practically useless, and they keep
-showing up in the output of "`git status`".
+"`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
in the top level of your working directory, with contents such as:
@@ -1254,16 +1269,15 @@ these three "file stages" represents a different version of the file:
-------------------------------------------------
$ git show :1:file.txt # the file in a common ancestor of both branches
-$ git show :2:file.txt # the version from HEAD, but including any
- # nonconflicting changes from MERGE_HEAD
-$ git show :3:file.txt # the version from MERGE_HEAD, but including any
- # nonconflicting changes from HEAD.
+$ git show :2:file.txt # the version from HEAD.
+$ git show :3:file.txt # the version from MERGE_HEAD.
-------------------------------------------------
-Since the stage 2 and stage 3 versions have already been updated with
-nonconflicting changes, the only remaining differences between them are
-the important ones; thus linkgit:git-diff[1] can use the information in
-the index to show only those conflicts.
+When you ask linkgit:git-diff[1] to show the conflicts, it runs a
+three-way diff between the conflicted merge results in the work tree with
+stages 2 and 3 to show only hunks whose contents come from both sides,
+mixed (in other words, when a hunk's merge results come only from stage 2,
+that part is not conflicting and is not shown. Same for stage 3).
The diff above shows the differences between the working-tree version of
file.txt and the stage 2 and stage 3 versions. So instead of preceding
@@ -1304,7 +1318,7 @@ $ git diff -3 file.txt # diff against stage 3
$ git diff --theirs file.txt # same as the above.
-------------------------------------------------
-The linkgit:git-log[1] and gitk[1] commands also provide special help
+The linkgit:git-log[1] and linkgit:gitk[1] commands also provide special help
for merges:
-------------------------------------------------
@@ -1450,7 +1464,7 @@ Checking out an old version of a file
In the process of undoing a previous bad change, you may find it
useful to check out an older version of a particular file using
-linkgit:git-checkout[1]. We've used git checkout before to switch
+linkgit:git-checkout[1]. We've used git-checkout before to switch
branches, but it has quite different behavior if it is given a path
name: the command
@@ -1548,22 +1562,7 @@ dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
Dangling objects are not a problem. At worst they may take up a little
extra disk space. They can sometimes provide a last-resort method for
-recovering lost work--see <<dangling-objects>> for details. However, if
-you wish, you can remove them with linkgit:git-prune[1] or the `--prune`
-option to linkgit:git-gc[1]:
-
--------------------------------------------------
-$ git gc --prune
--------------------------------------------------
-
-This may be time-consuming. Unlike most other git operations (including
-git-gc when run without any options), it is not safe to prune while
-other git operations are in progress in the same repository.
-
-If linkgit:git-fsck[1] complains about sha1 mismatches or missing
-objects, you may have a much more serious problem; your best option is
-probably restoring from backups. See
-<<recovering-from-repository-corruption>> for a detailed discussion.
+recovering lost work--see <<dangling-objects>> for details.
[[recovering-lost-changes]]
Recovering lost changes
@@ -1667,7 +1666,7 @@ Sharing development with others
===============================
[[getting-updates-with-git-pull]]
-Getting updates with git pull
+Getting updates with git-pull
-----------------------------
After you clone a repository and make a few changes of your own, you
@@ -1786,7 +1785,7 @@ Public git repositories
Another way to submit changes to a project is to tell the maintainer
of that project to pull the changes from your repository using
linkgit:git-pull[1]. In the section "<<getting-updates-with-git-pull,
-Getting updates with git pull>>" we described this as a way to get
+Getting updates with git-pull>>" we described this as a way to get
updates from the "main" repository, but it works just as well in the
other direction.
@@ -1891,12 +1890,11 @@ adjustments to give web clients some extra information they need:
$ mv proj.git /home/you/public_html/proj.git
$ cd proj.git
$ git --bare update-server-info
-$ chmod a+x hooks/post-update
+$ mv hooks/post-update.sample hooks/post-update
-------------------------------------------------
(For an explanation of the last two lines, see
-linkgit:git-update-server-info[1], and the documentation
-link:hooks.html[Hooks used by git].)
+linkgit:git-update-server-info[1] and linkgit:githooks[5].)
Advertise the URL of proj.git. Anybody else should then be able to
clone or pull from that URL, for example with a command line like:
@@ -1980,10 +1978,10 @@ error: failed to push to 'ssh://yourserver.com/~you/proj.git'
This can happen, for example, if you:
- - use `git reset --hard` to remove already-published commits, or
- - use `git commit --amend` to replace already-published commits
+ - use `git-reset --hard` to remove already-published commits, or
+ - use `git-commit --amend` to replace already-published commits
(as in <<fixing-a-mistake-by-rewriting-history>>), or
- - use `git rebase` to rebase any already-published commits (as
+ - use `git-rebase` to rebase any already-published commits (as
in <<using-git-rebase>>).
You may force git-push to perform the update anyway by preceding the
@@ -2005,10 +2003,10 @@ intend to manage the branch.
It's also possible for a push to fail in this way when other people have
the right to push to the same repository. In that case, the correct
-solution is to retry the push after first updating your work by either a
-pull or a fetch followed by a rebase; see the
+solution is to retry the push after first updating your work: either by a
+pull, or by a fetch followed by a rebase; see the
<<setting-up-a-shared-repository,next section>> and
-link:cvs-migration.html[git for CVS users] for more.
+linkgit:gitcvs-migration[7] for more.
[[setting-up-a-shared-repository]]
Setting up a shared repository
@@ -2017,7 +2015,7 @@ Setting up a shared repository
Another way to collaborate is by using a model similar to that
commonly used in CVS, where several developers with special rights
all push to and pull from a single shared repository. See
-link:cvs-migration.html[git for CVS users] for instructions on how to
+linkgit:gitcvs-migration[7] for instructions on how to
set this up.
However, while there is nothing wrong with git's support for shared
@@ -2187,7 +2185,7 @@ they are for, or what status they are in. To get a reminder of what
changes are in a specific branch, use:
-------------------------------------------------
-$ git log linux..branchname | git-shortlog
+$ git log linux..branchname | git shortlog
-------------------------------------------------
To see whether it has already been merged into the test or release branches,
@@ -2448,7 +2446,7 @@ $ git rebase origin
-------------------------------------------------
This will remove each of your commits from mywork, temporarily saving
-them as patches (in a directory named ".dotest"), update mywork to
+them as patches (in a directory named ".git/rebase-apply"), update mywork to
point at the latest version of origin, then apply each of the saved
patches to the new mywork. The result will look like:
@@ -2460,8 +2458,8 @@ patches to the new mywork. The result will look like:
................................................
In the process, it may discover conflicts. In that case it will stop
-and allow you to fix the conflicts; after fixing conflicts, use "git
-add" to update the index with those contents, and then, instead of
+and allow you to fix the conflicts; after fixing conflicts, use "git-add"
+to update the index with those contents, and then, instead of
running git-commit, just run
-------------------------------------------------
@@ -2717,8 +2715,8 @@ master branch. In more detail:
git fetch and fast-forwards
---------------------------
-In the previous example, when updating an existing branch, "git
-fetch" checks to make sure that the most recent commit on the remote
+In the previous example, when updating an existing branch, "git-fetch"
+checks to make sure that the most recent commit on the remote
branch is a descendant of the most recent commit on your copy of the
branch before updating your copy of the branch to point at the new
commit. Git calls this process a <<fast-forwards,fast forward>>.
@@ -2743,7 +2741,7 @@ resulting in a situation like:
o--o--o <-- new head of the branch
................................................
-In this case, "git fetch" will fail, and print out a warning.
+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
described in the following section. However, note that in the
@@ -2752,7 +2750,7 @@ unless you've already created a reference of your own pointing to
them.
[[forcing-fetch]]
-Forcing git fetch to do non-fast-forward updates
+Forcing git-fetch to do non-fast-forward updates
------------------------------------------------
If git fetch fails because the new head of a branch is not a
@@ -2828,7 +2826,7 @@ $ git config remote.example.fetch +master:ref/remotes/example/master
-------------------------------------------------
Don't do this unless you're sure you won't mind "git fetch" possibly
-throwing away commits on mybranch.
+throwing away commits on 'example/master'.
Also note that all of the above configuration can be performed by
directly editing the file .git/config instead of using
@@ -2878,7 +2876,7 @@ There are four different types of objects: "blob", "tree", "commit", and
"tag".
- A <<def_blob_object,"blob" object>> is used to store file data.
-- A <<def_tree_object,"tree" object>> is an object that ties one or more
+- A <<def_tree_object,"tree" object>> ties one or more
"blob" objects into a directory structure. In addition, a tree object
can refer to other tree objects, thus creating a directory hierarchy.
- A <<def_commit_object,"commit" object>> ties such directory hierarchies
@@ -3053,7 +3051,7 @@ Tag Object
A tag object contains an object, object type, tag name, the name of the
person ("tagger") who created the tag, and a message, which may contain
-a signature, as can be seen using the linkgit:git-cat-file[1]:
+a signature, as can be seen using linkgit:git-cat-file[1]:
------------------------------------------------
$ git cat-file tag v1.5.0
@@ -3123,7 +3121,7 @@ $ git prune
to remove any of the "loose" objects that are now contained in the
pack. This will also remove any unreferenced objects (which may be
-created when, for example, you use "git reset" to remove a commit).
+created when, for example, you use "git-reset" to remove a commit).
You can verify that the loose objects are gone by looking at the
.git/objects directory or by running
@@ -3152,7 +3150,7 @@ branch still exists, as does everything it pointed to. The branch
pointer itself just doesn't, since you replaced it with another one.
There are also other situations that cause dangling objects. For
-example, a "dangling blob" may arise because you did a "git add" of a
+example, a "dangling blob" may arise because you did a "git-add" of a
file, but then, before you actually committed it and made it part of the
bigger picture, you changed something else in that file and committed
that *updated* thing--the old state that you added originally ends up
@@ -3202,7 +3200,7 @@ Usually, dangling blobs and trees aren't very interesting. They're
almost always the result of either being a half-way mergebase (the blob
will often even have the conflict markers from a merge in it, if you
have had conflicting merges that you fixed up by hand), or simply
-because you interrupted a "git fetch" with ^C or something like that,
+because you interrupted a "git-fetch" with ^C or something like that,
leaving _some_ of the new objects in the object database, but just
dangling and useless.
@@ -3251,7 +3249,7 @@ it is with linkgit:git-fsck[1]; this may be time-consuming.
Assume the output looks like this:
------------------------------------------------
-$ git-fsck --full
+$ git fsck --full
broken link from tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8
to blob 4b9458b3786228369c63936db65827de3cc06200
missing blob 4b9458b3786228369c63936db65827de3cc06200
@@ -3475,23 +3473,23 @@ $ cd super
$ git init
$ for i in a b c d
do
- git submodule add ~/git/$i
+ git submodule add ~/git/$i $i
done
-------------------------------------------------
NOTE: Do not use local URLs here if you plan to publish your superproject!
-See what files `git submodule` created:
+See what files `git-submodule` created:
-------------------------------------------------
$ ls -a
. .. .git .gitmodules a b c d
-------------------------------------------------
-The `git submodule add` command does a couple of things:
+The `git-submodule add <repo> <path>` command does a couple of things:
-- It clones the submodule under the current directory and by default checks out
- the master branch.
+- It clones the submodule from <repo> to the given <path> under the
+ current directory and by default checks out the master branch.
- It adds the submodule's clone path to the linkgit:gitmodules[5] file and
adds this file to the index, ready to be committed.
- It adds the submodule's current commit ID to the index, ready to be
@@ -3534,7 +3532,7 @@ init` to add the submodule repository URLs to `.git/config`:
$ git submodule init
-------------------------------------------------
-Now use `git submodule update` to clone the repositories and check out the
+Now use `git-submodule update` to clone the repositories and check out the
commits specified in the superproject:
-------------------------------------------------
@@ -3544,8 +3542,8 @@ $ ls -a
. .. .git a.txt
-------------------------------------------------
-One major difference between `git submodule update` and `git submodule add` is
-that `git submodule update` checks out a specific commit, rather than the tip
+One major difference between `git-submodule update` and `git-submodule add` is
+that `git-submodule update` checks out a specific commit, rather than the tip
of a branch. It's like checking out a tag: the head is detached, so you're not
working on a branch.
@@ -3711,7 +3709,7 @@ removed. The only thing `--remove` means is that update-index will be
considering a removed file to be a valid thing, and if the file really
does not exist any more, it will update the index accordingly.
-As a special case, you can also do `git-update-index --refresh`, which
+As a special case, you can also do `git update-index --refresh`, which
will refresh the "stat" information of each index to match the current
stat information. It will 'not' update the object status itself, and
it will only update the fields that are used to quickly test whether
@@ -3746,7 +3744,7 @@ unsaved state that you might want to restore later!) your current
index. Normal operation is just
-------------------------------------------------
-$ git-read-tree <sha1 of tree>
+$ git read-tree <sha1 of tree>
-------------------------------------------------
and your index file will now be equivalent to the tree that you saved
@@ -3769,7 +3767,7 @@ index file with read-tree, and then you need to check out the result
with
-------------------------------------------------
-$ git-checkout-index filename
+$ git checkout-index filename
-------------------------------------------------
or, if you want to check out all of the index, use `-a`.
@@ -3787,7 +3785,7 @@ from one representation to the other:
Tying it all together
~~~~~~~~~~~~~~~~~~~~~
-To commit a tree you have instantiated with "git-write-tree", you'd
+To commit a tree you have instantiated with "git write-tree", you'd
create a "commit" object that refers to that tree and the history
behind it--most notably the "parent" commits that preceded it in
history.
@@ -3806,7 +3804,7 @@ You create a commit object by giving it the tree that describes the
state at the time of the commit, and a list of parents:
-------------------------------------------------
-$ git-commit-tree <tree> -p <parent> [-p <parent2> ..]
+$ git commit-tree <tree> -p <parent> [-p <parent2> ..]
-------------------------------------------------
and then giving the reason for the commit on stdin (either through
@@ -3869,14 +3867,14 @@ linkgit:git-cat-file[1] to examine details about the
object:
-------------------------------------------------
-$ git-cat-file -t <objectname>
+$ git cat-file -t <objectname>
-------------------------------------------------
shows the type of the object, and once you have the type (which is
usually implicit in where you find the object), you can use
-------------------------------------------------
-$ git-cat-file blob|tree|commit|tag <objectname>
+$ git cat-file blob|tree|commit|tag <objectname>
-------------------------------------------------
to show its contents. NOTE! Trees have binary content, and as a result
@@ -3890,7 +3888,7 @@ follow the convention of having the top commit name in `.git/HEAD`,
you can do
-------------------------------------------------
-$ git-cat-file commit HEAD
+$ git cat-file commit HEAD
-------------------------------------------------
to see what the top commit was.
@@ -3914,7 +3912,7 @@ To get the "base" for the merge, you first look up the common parent
of two commits with
-------------------------------------------------
-$ git-merge-base <commit1> <commit2>
+$ git merge-base <commit1> <commit2>
-------------------------------------------------
which will return you the commit they are both based on. You should
@@ -3922,7 +3920,7 @@ now look up the "tree" objects of those commits, which you can easily
do with (for example)
-------------------------------------------------
-$ git-cat-file commit <commitname> | head -1
+$ git cat-file commit <commitname> | head -1
-------------------------------------------------
since the tree object information is always the first line in a commit
@@ -3939,12 +3937,12 @@ you have in your current index anyway).
To do the merge, do
-------------------------------------------------
-$ git-read-tree -m -u <origtree> <yourtree> <targettree>
+$ git read-tree -m -u <origtree> <yourtree> <targettree>
-------------------------------------------------
which will do all trivial merge operations for you directly in the
index file, and you can just write the result out with
-`git-write-tree`.
+`git write-tree`.
[[merging-multiple-trees-2]]
@@ -3958,18 +3956,18 @@ entries" in it. Such an index tree can 'NOT' be written out to a tree
object, and you will have to resolve any such merge clashes using
other tools before you can write out the result.
-You can examine such index state with `git-ls-files --unmerged`
+You can examine such index state with `git ls-files --unmerged`
command. An example:
------------------------------------------------
-$ git-read-tree -m $orig HEAD $target
-$ git-ls-files --unmerged
+$ git read-tree -m $orig HEAD $target
+$ git ls-files --unmerged
100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c
------------------------------------------------
-Each line of the `git-ls-files --unmerged` output begins with
+Each line of the `git ls-files --unmerged` output begins with
the blob mode bits, blob SHA1, 'stage number', and the
filename. The 'stage number' is git's way to say which tree it
came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD`
@@ -3987,9 +3985,9 @@ program, e.g. `diff3`, `merge`, or git's own merge-file, on
the blob objects from these three stages yourself, like this:
------------------------------------------------
-$ git-cat-file blob 263414f... >hello.c~1
-$ git-cat-file blob 06fa6a2... >hello.c~2
-$ git-cat-file blob cc44c73... >hello.c~3
+$ git cat-file blob 263414f... >hello.c~1
+$ git cat-file blob 06fa6a2... >hello.c~2
+$ git cat-file blob cc44c73... >hello.c~3
$ git merge-file hello.c~2 hello.c~1 hello.c~3
------------------------------------------------
@@ -4000,23 +3998,23 @@ merge result for this file is by:
-------------------------------------------------
$ mv -f hello.c~2 hello.c
-$ git-update-index hello.c
+$ git update-index hello.c
-------------------------------------------------
-When a path is in unmerged state, running `git-update-index` for
+When a path is in the "unmerged" state, running `git-update-index` for
that path tells git to mark the path resolved.
The above is the description of a git merge at the lowest level,
to help you understand what conceptually happens under the hood.
-In practice, nobody, not even git itself, uses three `git-cat-file`
-for this. There is `git-merge-index` program that extracts the
+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:
-------------------------------------------------
-$ git-merge-index git-merge-one-file hello.c
+$ git merge-index git-merge-one-file hello.c
-------------------------------------------------
-and that is what higher level `git merge -s resolve` is implemented with.
+and that is what higher level `git-merge -s resolve` is implemented with.
[[hacking-git]]
Hacking git
@@ -4078,7 +4076,7 @@ Note that terminology has changed since that revision. For example, the
README in that revision uses the word "changeset" to describe what we
now call a <<def_commit_object,commit>>.
-Also, we do not call it "cache" any more, but "index", however, the
+Also, we do not call it "cache" any more, but rather "index"; however, the
file is still called `cache.h`. Remark: Not much reason to change it now,
especially since there is no good single name for it anyway, because it is
basically _the_ header file which is included by _all_ of Git's C sources.
@@ -4112,7 +4110,7 @@ functions like `get_sha1_basic()` or the likes.
This is just to get you into the groove for the most libified part of Git:
the revision walker.
-Basically, the initial version of `git log` was a shell script:
+Basically, the initial version of `git-log` was a shell script:
----------------------------------------------------------------
$ git-rev-list --pretty $(git-rev-parse --default HEAD "$@") | \
@@ -4144,10 +4142,10 @@ commits one by one with the function `get_revision()`.
If you are interested in more details of the revision walking process,
just have a look at the first implementation of `cmd_log()`; call
-`git-show v1.3.0~155^2~4` and scroll down to that function (note that you
+`git show v1.3.0{tilde}155^2{tilde}4` and scroll down to that function (note that you
no longer need to call `setup_pager()` directly).
-Nowadays, `git log` is a builtin, which means that it is _contained_ in the
+Nowadays, `git-log` is a builtin, which means that it is _contained_ in the
command `git`. The source side of a builtin is
- a function called `cmd_<bla>`, typically defined in `builtin-<bla>.c`,
@@ -4163,7 +4161,7 @@ since they share quite a bit of code. In that case, the commands which are
_not_ named like the `.c` file in which they live have to be listed in
`BUILT_INS` in the `Makefile`.
-`git log` looks more complicated in C than it does in the original script,
+`git-log` looks more complicated in C than it does in the original script,
but that allows for a much greater flexibility and performance.
Here again it is a good point to take a pause.
@@ -4174,9 +4172,9 @@ the organization of Git (after you know the basic concepts).
So, think about something which you are interested in, say, "how can I
access a blob just knowing the object name of it?". The first step is to
find a Git command with which you can do it. In this example, it is either
-`git show` or `git cat-file`.
+`git-show` or `git-cat-file`.
-For the sake of clarity, let's stay with `git cat-file`, because it
+For the sake of clarity, let's stay with `git-cat-file`, because it
- is plumbing, and
@@ -4235,10 +4233,10 @@ To find out how the result can be used, just read on in `cmd_cat_file()`:
-----------------------------------
Sometimes, you do not know where to look for a feature. In many such cases,
-it helps to search through the output of `git log`, and then `git show` the
+it helps to search through the output of `git log`, and then `git-show` the
corresponding commit.
-Example: If you know that there was some test case for `git bundle`, but
+Example: If you know that there was some test case for `git-bundle`, but
do not remember where it was (yes, you _could_ `git grep bundle t/`, but that
does not illustrate the point!):
@@ -4267,7 +4265,10 @@ You see, Git is actually the best tool to find out about the source of Git
itself!
[[glossary]]
-include::glossary.txt[]
+GIT Glossary
+============
+
+include::glossary-content.txt[]
[[git-quick-start]]
Appendix A: Git Quick Reference
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 2ba142a11..156dc1373 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v1.5.4-rc3.GIT
+DEF_VER=v1.6.0.GIT
LF='
'
@@ -11,11 +11,14 @@ LF='
if test -f version
then
VN=$(cat version) || VN="$DEF_VER"
-elif test -d .git &&
+elif test -d .git -o -f .git &&
VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
- v[0-9]*) : happy ;;
+ v[0-9]*)
+ git update-index -q --refresh
+ test -z "$(git diff-index --name-only HEAD --)" ||
+ VN="$VN-dirty" ;;
esac
then
VN=$(echo "$VN" | sed -e 's/-/./g');
@@ -25,14 +28,6 @@ fi
VN=$(expr "$VN" : v*'\(.*\)')
-dirty=$(sh -c 'git diff-index --name-only HEAD' 2>/dev/null) || dirty=
-case "$dirty" in
-'')
- ;;
-*)
- VN="$VN-dirty" ;;
-esac
-
if test -r $GVF
then
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
diff --git a/INSTALL b/INSTALL
index f1eb4049b..2bae53fcb 100644
--- a/INSTALL
+++ b/INSTALL
@@ -24,19 +24,15 @@ set up install paths (via config.mak.autogen), so you can write instead
Issues of note:
- - git normally installs a helper script wrapper called "git", which
- conflicts with a similarly named "GNU interactive tools" program.
+ - Ancient versions of GNU Interactive Tools (pre-4.9.2) installed a
+ program "git", whose name conflicts with this program. But with
+ version 4.9.2, after long hiatus without active maintenance (since
+ around 1997), it changed its name to gnuit and the name conflict is no
+ longer a problem.
- Tough. Either don't use the wrapper script, or delete the old GNU
- interactive tools. None of the core git stuff needs the wrapper,
- it's just a convenient shorthand and while it is documented in some
- places, you can always replace "git commit" with "git-commit"
- instead.
-
- But let's face it, most of us don't have GNU interactive tools, and
- even if we had it, we wouldn't know what it does. I don't think it
- has been actively developed since 1997, and people have moved over to
- graphical file managers.
+ NOTE: When compiled with backward compatibility option, the GNU
+ Interactive Tools package still can install "git", but you can build it
+ with --disable-transition option to avoid this.
- You can use git after building but without installing if you
wanted to. Various git commands need to find other git
@@ -63,10 +59,10 @@ Issues of note:
that come with git (git includes the one from Mozilla, and has
its own PowerPC and ARM optimized ones too - see the Makefile).
- - "libcurl" and "curl" executable. git-http-fetch and
- git-fetch use them. If you do not use http
- transfer, you are probably OK if you do not have
- them.
+ - libcurl library; git-http-fetch and git-fetch use them. You
+ might also want the "curl" executable for debugging purposes.
+ If you do not use http transfer, you are probably OK if you
+ do not have them.
- expat library; git-http-push uses it for remote lock
management over DAV. Similar to "curl" above, this is optional.
@@ -77,10 +73,7 @@ Issues of note:
- "ssh" is used to push and pull over the net
- "perl" and POSIX-compliant shells are needed to use most of
- the barebone Porcelainish scripts.
-
- - "cpio" is used by git-merge for saving and restoring the index,
- and by git-clone when doing a local (possibly hardlinked) clone.
+ the bare-bones Porcelainish scripts.
- Some platform specific issues are dealt with Makefile rules,
but depending on your specific installation, you may not
diff --git a/Makefile b/Makefile
index 90c0dd8c4..53ab4b553 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,17 @@ all::
# Define V=1 to have a more verbose compile.
#
+# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
+# or vsnprintf() return -1 instead of number of characters which would
+# have been written to the final string if enough space had been available.
+#
+# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
+# when attempting to read from an fopen'ed directory.
+#
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
# This also implies MOZILLA_SHA1.
#
-# Define NO_CURL if you do not have curl installed. git-http-pull and
+# Define NO_CURL if you do not have libcurl installed. git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
#
@@ -42,6 +49,8 @@ all::
#
# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
#
+# Define NO_SYS_SELECT_H if you don't have sys/select.h.
+#
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
# Enable it on Windows. By default, symrefs are still used.
#
@@ -135,6 +144,13 @@ all::
# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit
# parallel delta searching when packing objects.
#
+# Define INTERNAL_QSORT to use Git's implementation of qsort(), which
+# is a simplified version of the merge sort used in glibc. This is
+# recommended if Git triggers O(n^2) behavior in your platform's qsort().
+#
+# Define NO_EXTERNAL_GREP if you don't want "git grep" to ever call
+# your external grep (e.g., if your system lacks grep, if its grep is
+# broken, or spawning external process is slower than built-in grep git has).
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -154,11 +170,21 @@ ALL_CFLAGS = $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
STRIP ?= strip
+# Among the variables below, these:
+# gitexecdir
+# template_dir
+# htmldir
+# ETC_GITCONFIG (but not sysconfdir)
+# can be specified as a relative path ../some/where/else (which must begin
+# with ../); this is interpreted as relative to $(bindir) and "git" at
+# runtime figures out where they are based on the path to the executable.
+# This can help installing the suite in a relocatable way.
+
prefix = $(HOME)
bindir = $(prefix)/bin
mandir = $(prefix)/share/man
infodir = $(prefix)/share/info
-gitexecdir = $(bindir)
+gitexecdir = $(prefix)/libexec/git-core
sharedir = $(prefix)/share
template_dir = $(sharedir)/git-core/templates
htmldir=$(sharedir)/doc/git-doc
@@ -173,6 +199,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig
# default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl
+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
GITWEB_HOME_LINK_STR = projects
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
@@ -188,7 +215,7 @@ GITWEB_FAVICON = git-favicon.png
GITWEB_SITE_HEADER =
GITWEB_SITE_FOOTER =
-export prefix bindir gitexecdir sharedir template_dir htmldir sysconfdir
+export prefix bindir sharedir htmldir sysconfdir
CC = gcc
AR = ar
@@ -216,62 +243,82 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
BASIC_CFLAGS =
BASIC_LDFLAGS =
-SCRIPT_SH = \
- git-bisect.sh \
- git-clone.sh \
- git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \
- git-pull.sh git-rebase.sh git-rebase--interactive.sh \
- git-repack.sh git-request-pull.sh \
- git-sh-setup.sh \
- git-am.sh \
- git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
- git-merge-resolve.sh \
- git-lost-found.sh git-quiltimport.sh git-submodule.sh \
- git-filter-branch.sh \
- git-stash.sh \
- git-help--browse.sh
-
-SCRIPT_PERL = \
- git-add--interactive.perl \
- git-archimport.perl git-cvsimport.perl git-relink.perl \
- git-cvsserver.perl git-remote.perl git-cvsexportcommit.perl \
- git-send-email.perl git-svn.perl
+SCRIPT_SH += git-am.sh
+SCRIPT_SH += git-bisect.sh
+SCRIPT_SH += git-filter-branch.sh
+SCRIPT_SH += git-lost-found.sh
+SCRIPT_SH += git-merge-octopus.sh
+SCRIPT_SH += git-merge-one-file.sh
+SCRIPT_SH += git-merge-resolve.sh
+SCRIPT_SH += git-mergetool.sh
+SCRIPT_SH += git-parse-remote.sh
+SCRIPT_SH += git-pull.sh
+SCRIPT_SH += git-quiltimport.sh
+SCRIPT_SH += git-rebase--interactive.sh
+SCRIPT_SH += git-rebase.sh
+SCRIPT_SH += git-repack.sh
+SCRIPT_SH += git-request-pull.sh
+SCRIPT_SH += git-sh-setup.sh
+SCRIPT_SH += git-stash.sh
+SCRIPT_SH += git-submodule.sh
+SCRIPT_SH += git-web--browse.sh
+
+SCRIPT_PERL += git-add--interactive.perl
+SCRIPT_PERL += git-archimport.perl
+SCRIPT_PERL += git-cvsexportcommit.perl
+SCRIPT_PERL += git-cvsimport.perl
+SCRIPT_PERL += git-cvsserver.perl
+SCRIPT_PERL += git-relink.perl
+SCRIPT_PERL += git-send-email.perl
+SCRIPT_PERL += git-svn.perl
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
git-instaweb
-# ... and all the rest that could be moved out of bindir to gitexecdir
-PROGRAMS = \
- git-fetch-pack$X \
- git-hash-object$X git-index-pack$X \
- git-fast-import$X \
- git-daemon$X \
- git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
- git-receive-pack$X \
- git-send-pack$X git-shell$X \
- git-show-index$X \
- git-unpack-file$X \
- git-update-server-info$X \
- git-upload-pack$X \
- git-pack-redundant$X git-var$X \
- git-merge-tree$X git-imap-send$X \
- $(EXTRA_PROGRAMS)
-
# Empty...
EXTRA_PROGRAMS =
-BUILT_INS = \
- git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
- git-get-tar-commit-id$X git-init$X git-repo-config$X \
- git-fsck-objects$X git-cherry-pick$X git-peek-remote$X git-status$X \
- $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
+# ... and all the rest that could be moved out of bindir to gitexecdir
+PROGRAMS += $(EXTRA_PROGRAMS)
+PROGRAMS += git-fast-import$X
+PROGRAMS += git-fetch-pack$X
+PROGRAMS += git-hash-object$X
+PROGRAMS += git-index-pack$X
+PROGRAMS += git-merge-index$X
+PROGRAMS += git-merge-tree$X
+PROGRAMS += git-mktag$X
+PROGRAMS += git-mktree$X
+PROGRAMS += git-pack-redundant$X
+PROGRAMS += git-patch-id$X
+PROGRAMS += git-receive-pack$X
+PROGRAMS += git-send-pack$X
+PROGRAMS += git-show-index$X
+PROGRAMS += git-unpack-file$X
+PROGRAMS += git-update-server-info$X
+PROGRAMS += git-upload-pack$X
+PROGRAMS += git-var$X
+
+# List built-in command $C whose implementation cmd_$C() is not in
+# builtin-$C.o but is linked in as part of some other command.
+BUILT_INS += $(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
+
+BUILT_INS += git-cherry-pick$X
+BUILT_INS += git-cherry$X
+BUILT_INS += git-format-patch$X
+BUILT_INS += git-fsck-objects$X
+BUILT_INS += git-get-tar-commit-id$X
+BUILT_INS += git-init$X
+BUILT_INS += git-merge-subtree$X
+BUILT_INS += git-peek-remote$X
+BUILT_INS += git-repo-config$X
+BUILT_INS += git-show$X
+BUILT_INS += git-status$X
+BUILT_INS += git-whatchanged$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
-ALL_PROGRAMS += git-merge-subtree$X
-
# what 'all' will build but not install in gitexecdir
OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
@@ -286,112 +333,234 @@ endif
export PERL_PATH
LIB_FILE=libgit.a
+COMPAT_LIB = compat/lib.a
XDIFF_LIB=xdiff/lib.a
-LIB_H = \
- archive.h blob.h cache.h cache-tree.h commit.h csum-file.h delta.h grep.h \
- diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
- run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
- tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
- utf8.h reflog-walk.h patch-ids.h attr.h decorate.h progress.h \
- mailmap.h remote.h parse-options.h transport.h diffcore.h hash.h
-
-DIFF_OBJS = \
- diff.o diff-lib.o diffcore-break.o diffcore-order.o \
- diffcore-pickaxe.o diffcore-rename.o tree-diff.o combine-diff.o \
- diffcore-delta.o log-tree.o
-
-LIB_OBJS = \
- blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \
- date.o diff-delta.o entry.o exec_cmd.o ident.o \
- pretty.o interpolate.o hash.o \
- lockfile.o \
- patch-ids.o \
- object.o pack-check.o pack-write.o patch-delta.o path.o pkt-line.o \
- sideband.o reachable.o reflog-walk.o \
- quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
- server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
- tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
- revision.o pager.o tree-walk.o xdiff-interface.o \
- write_or_die.o trace.o list-objects.o grep.o match-trees.o \
- alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
- color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
- convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
- transport.o bundle.o walker.o parse-options.o ws.o archive.o branch.o
-
-BUILTIN_OBJS = \
- builtin-add.o \
- builtin-annotate.o \
- builtin-apply.o \
- builtin-archive.o \
- builtin-blame.o \
- builtin-branch.o \
- builtin-bundle.o \
- builtin-cat-file.o \
- builtin-check-attr.o \
- builtin-checkout.o \
- builtin-checkout-index.o \
- builtin-check-ref-format.o \
- builtin-clean.o \
- builtin-commit.o \
- builtin-commit-tree.o \
- builtin-count-objects.o \
- builtin-describe.o \
- builtin-diff.o \
- builtin-diff-files.o \
- builtin-diff-index.o \
- builtin-diff-tree.o \
- builtin-fast-export.o \
- builtin-fetch.o \
- builtin-fetch-pack.o \
- builtin-fetch--tool.o \
- builtin-fmt-merge-msg.o \
- builtin-for-each-ref.o \
- builtin-fsck.o \
- builtin-gc.o \
- builtin-grep.o \
- builtin-init-db.o \
- builtin-log.o \
- builtin-ls-files.o \
- builtin-ls-tree.o \
- builtin-ls-remote.o \
- builtin-mailinfo.o \
- builtin-mailsplit.o \
- builtin-merge-base.o \
- builtin-merge-file.o \
- builtin-merge-ours.o \
- builtin-merge-recursive.o \
- builtin-mv.o \
- builtin-name-rev.o \
- builtin-pack-objects.o \
- builtin-prune.o \
- builtin-prune-packed.o \
- builtin-push.o \
- builtin-read-tree.o \
- builtin-reflog.o \
- builtin-send-pack.o \
- builtin-config.o \
- builtin-rerere.o \
- builtin-reset.o \
- builtin-rev-list.o \
- builtin-rev-parse.o \
- builtin-revert.o \
- builtin-rm.o \
- builtin-shortlog.o \
- builtin-show-branch.o \
- builtin-stripspace.o \
- builtin-symbolic-ref.o \
- builtin-tag.o \
- builtin-tar-tree.o \
- builtin-unpack-objects.o \
- builtin-update-index.o \
- builtin-update-ref.o \
- builtin-upload-archive.o \
- builtin-verify-pack.o \
- builtin-verify-tag.o \
- builtin-write-tree.o \
- builtin-show-ref.o \
- builtin-pack-refs.o
+LIB_H += archive.h
+LIB_H += attr.h
+LIB_H += blob.h
+LIB_H += builtin.h
+LIB_H += cache.h
+LIB_H += cache-tree.h
+LIB_H += commit.h
+LIB_H += compat/mingw.h
+LIB_H += csum-file.h
+LIB_H += decorate.h
+LIB_H += delta.h
+LIB_H += diffcore.h
+LIB_H += diff.h
+LIB_H += dir.h
+LIB_H += fsck.h
+LIB_H += git-compat-util.h
+LIB_H += graph.h
+LIB_H += grep.h
+LIB_H += hash.h
+LIB_H += list-objects.h
+LIB_H += ll-merge.h
+LIB_H += log-tree.h
+LIB_H += mailmap.h
+LIB_H += object.h
+LIB_H += pack.h
+LIB_H += pack-refs.h
+LIB_H += pack-revindex.h
+LIB_H += parse-options.h
+LIB_H += patch-ids.h
+LIB_H += string-list.h
+LIB_H += pkt-line.h
+LIB_H += progress.h
+LIB_H += quote.h
+LIB_H += reflog-walk.h
+LIB_H += refs.h
+LIB_H += remote.h
+LIB_H += rerere.h
+LIB_H += revision.h
+LIB_H += run-command.h
+LIB_H += sha1-lookup.h
+LIB_H += sideband.h
+LIB_H += strbuf.h
+LIB_H += tag.h
+LIB_H += transport.h
+LIB_H += tree.h
+LIB_H += tree-walk.h
+LIB_H += unpack-trees.h
+LIB_H += utf8.h
+LIB_H += wt-status.h
+
+LIB_OBJS += abspath.o
+LIB_OBJS += alias.o
+LIB_OBJS += alloc.o
+LIB_OBJS += archive.o
+LIB_OBJS += archive-tar.o
+LIB_OBJS += archive-zip.o
+LIB_OBJS += attr.o
+LIB_OBJS += base85.o
+LIB_OBJS += blob.o
+LIB_OBJS += branch.o
+LIB_OBJS += bundle.o
+LIB_OBJS += cache-tree.o
+LIB_OBJS += color.o
+LIB_OBJS += combine-diff.o
+LIB_OBJS += commit.o
+LIB_OBJS += config.o
+LIB_OBJS += connect.o
+LIB_OBJS += convert.o
+LIB_OBJS += copy.o
+LIB_OBJS += csum-file.o
+LIB_OBJS += ctype.o
+LIB_OBJS += date.o
+LIB_OBJS += decorate.o
+LIB_OBJS += diffcore-break.o
+LIB_OBJS += diffcore-delta.o
+LIB_OBJS += diffcore-order.o
+LIB_OBJS += diffcore-pickaxe.o
+LIB_OBJS += diffcore-rename.o
+LIB_OBJS += diff-delta.o
+LIB_OBJS += diff-no-index.o
+LIB_OBJS += diff-lib.o
+LIB_OBJS += diff.o
+LIB_OBJS += dir.o
+LIB_OBJS += editor.o
+LIB_OBJS += entry.o
+LIB_OBJS += environment.o
+LIB_OBJS += exec_cmd.o
+LIB_OBJS += fsck.o
+LIB_OBJS += graph.o
+LIB_OBJS += grep.o
+LIB_OBJS += hash.o
+LIB_OBJS += help.o
+LIB_OBJS += ident.o
+LIB_OBJS += interpolate.o
+LIB_OBJS += list-objects.o
+LIB_OBJS += ll-merge.o
+LIB_OBJS += lockfile.o
+LIB_OBJS += log-tree.o
+LIB_OBJS += mailmap.o
+LIB_OBJS += match-trees.o
+LIB_OBJS += merge-file.o
+LIB_OBJS += name-hash.o
+LIB_OBJS += object.o
+LIB_OBJS += pack-check.o
+LIB_OBJS += pack-refs.o
+LIB_OBJS += pack-revindex.o
+LIB_OBJS += pack-write.o
+LIB_OBJS += pager.o
+LIB_OBJS += parse-options.o
+LIB_OBJS += patch-delta.o
+LIB_OBJS += patch-ids.o
+LIB_OBJS += string-list.o
+LIB_OBJS += path.o
+LIB_OBJS += pkt-line.o
+LIB_OBJS += pretty.o
+LIB_OBJS += progress.o
+LIB_OBJS += quote.o
+LIB_OBJS += reachable.o
+LIB_OBJS += read-cache.o
+LIB_OBJS += reflog-walk.o
+LIB_OBJS += refs.o
+LIB_OBJS += remote.o
+LIB_OBJS += rerere.o
+LIB_OBJS += revision.o
+LIB_OBJS += run-command.o
+LIB_OBJS += server-info.o
+LIB_OBJS += setup.o
+LIB_OBJS += sha1_file.o
+LIB_OBJS += sha1-lookup.o
+LIB_OBJS += sha1_name.o
+LIB_OBJS += shallow.o
+LIB_OBJS += sideband.o
+LIB_OBJS += strbuf.o
+LIB_OBJS += symlinks.o
+LIB_OBJS += tag.o
+LIB_OBJS += trace.o
+LIB_OBJS += transport.o
+LIB_OBJS += tree-diff.o
+LIB_OBJS += tree.o
+LIB_OBJS += tree-walk.o
+LIB_OBJS += unpack-trees.o
+LIB_OBJS += usage.o
+LIB_OBJS += utf8.o
+LIB_OBJS += walker.o
+LIB_OBJS += wrapper.o
+LIB_OBJS += write_or_die.o
+LIB_OBJS += ws.o
+LIB_OBJS += wt-status.o
+LIB_OBJS += xdiff-interface.o
+
+BUILTIN_OBJS += builtin-add.o
+BUILTIN_OBJS += builtin-annotate.o
+BUILTIN_OBJS += builtin-apply.o
+BUILTIN_OBJS += builtin-archive.o
+BUILTIN_OBJS += builtin-blame.o
+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-ref-format.o
+BUILTIN_OBJS += builtin-checkout-index.o
+BUILTIN_OBJS += builtin-checkout.o
+BUILTIN_OBJS += builtin-clean.o
+BUILTIN_OBJS += builtin-clone.o
+BUILTIN_OBJS += builtin-commit-tree.o
+BUILTIN_OBJS += builtin-commit.o
+BUILTIN_OBJS += builtin-config.o
+BUILTIN_OBJS += builtin-count-objects.o
+BUILTIN_OBJS += builtin-describe.o
+BUILTIN_OBJS += builtin-diff-files.o
+BUILTIN_OBJS += builtin-diff-index.o
+BUILTIN_OBJS += builtin-diff-tree.o
+BUILTIN_OBJS += builtin-diff.o
+BUILTIN_OBJS += builtin-fast-export.o
+BUILTIN_OBJS += builtin-fetch--tool.o
+BUILTIN_OBJS += builtin-fetch-pack.o
+BUILTIN_OBJS += builtin-fetch.o
+BUILTIN_OBJS += builtin-fmt-merge-msg.o
+BUILTIN_OBJS += builtin-for-each-ref.o
+BUILTIN_OBJS += builtin-fsck.o
+BUILTIN_OBJS += builtin-gc.o
+BUILTIN_OBJS += builtin-grep.o
+BUILTIN_OBJS += builtin-init-db.o
+BUILTIN_OBJS += builtin-log.o
+BUILTIN_OBJS += builtin-ls-files.o
+BUILTIN_OBJS += builtin-ls-remote.o
+BUILTIN_OBJS += builtin-ls-tree.o
+BUILTIN_OBJS += builtin-mailinfo.o
+BUILTIN_OBJS += builtin-mailsplit.o
+BUILTIN_OBJS += builtin-merge.o
+BUILTIN_OBJS += builtin-merge-base.o
+BUILTIN_OBJS += builtin-merge-file.o
+BUILTIN_OBJS += builtin-merge-ours.o
+BUILTIN_OBJS += builtin-merge-recursive.o
+BUILTIN_OBJS += builtin-mv.o
+BUILTIN_OBJS += builtin-name-rev.o
+BUILTIN_OBJS += builtin-pack-objects.o
+BUILTIN_OBJS += builtin-pack-refs.o
+BUILTIN_OBJS += builtin-prune-packed.o
+BUILTIN_OBJS += builtin-prune.o
+BUILTIN_OBJS += builtin-push.o
+BUILTIN_OBJS += builtin-read-tree.o
+BUILTIN_OBJS += builtin-reflog.o
+BUILTIN_OBJS += builtin-remote.o
+BUILTIN_OBJS += builtin-rerere.o
+BUILTIN_OBJS += builtin-reset.o
+BUILTIN_OBJS += builtin-rev-list.o
+BUILTIN_OBJS += builtin-rev-parse.o
+BUILTIN_OBJS += builtin-revert.o
+BUILTIN_OBJS += builtin-rm.o
+BUILTIN_OBJS += builtin-send-pack.o
+BUILTIN_OBJS += builtin-shortlog.o
+BUILTIN_OBJS += builtin-show-branch.o
+BUILTIN_OBJS += builtin-show-ref.o
+BUILTIN_OBJS += builtin-stripspace.o
+BUILTIN_OBJS += builtin-symbolic-ref.o
+BUILTIN_OBJS += builtin-tag.o
+BUILTIN_OBJS += builtin-tar-tree.o
+BUILTIN_OBJS += builtin-unpack-objects.o
+BUILTIN_OBJS += builtin-update-index.o
+BUILTIN_OBJS += builtin-update-ref.o
+BUILTIN_OBJS += builtin-upload-archive.o
+BUILTIN_OBJS += builtin-verify-pack.o
+BUILTIN_OBJS += builtin-verify-tag.o
+BUILTIN_OBJS += builtin-write-tree.o
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
EXTLIBS =
@@ -410,6 +579,45 @@ endif
ifeq ($(uname_S),GNU/kFreeBSD)
NO_STRLCPY = YesPlease
endif
+ifeq ($(uname_S),UnixWare)
+ CC = cc
+ NEEDS_SOCKET = YesPlease
+ NEEDS_NSL = YesPlease
+ NEEDS_SSL_WITH_CRYPTO = YesPlease
+ NEEDS_LIBICONV = YesPlease
+ SHELL_PATH = /usr/local/bin/bash
+ NO_IPV6 = YesPlease
+ NO_HSTRERROR = YesPlease
+ BASIC_CFLAGS += -Kthread
+ BASIC_CFLAGS += -I/usr/local/include
+ BASIC_LDFLAGS += -L/usr/local/lib
+ INSTALL = ginstall
+ TAR = gtar
+ NO_STRCASESTR = YesPlease
+ NO_MEMMEM = YesPlease
+endif
+ifeq ($(uname_S),SCO_SV)
+ ifeq ($(uname_R),3.2)
+ CFLAGS = -O2
+ endif
+ ifeq ($(uname_R),5)
+ CC = cc
+ BASIC_CFLAGS += -Kthread
+ endif
+ NEEDS_SOCKET = YesPlease
+ NEEDS_NSL = YesPlease
+ NEEDS_SSL_WITH_CRYPTO = YesPlease
+ NEEDS_LIBICONV = YesPlease
+ SHELL_PATH = /usr/bin/bash
+ NO_IPV6 = YesPlease
+ NO_HSTRERROR = YesPlease
+ BASIC_CFLAGS += -I/usr/local/include
+ BASIC_LDFLAGS += -L/usr/local/lib
+ NO_STRCASESTR = YesPlease
+ NO_MEMMEM = YesPlease
+ INSTALL = ginstall
+ TAR = gtar
+endif
ifeq ($(uname_S),Darwin)
NEEDS_SSL_WITH_CRYPTO = YesPlease
NEEDS_LIBICONV = YesPlease
@@ -466,6 +674,7 @@ ifeq ($(uname_S),FreeBSD)
NO_MEMMEM = YesPlease
BASIC_CFLAGS += -I/usr/local/include
BASIC_LDFLAGS += -L/usr/local/lib
+ DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
endif
ifeq ($(uname_S),OpenBSD)
NO_STRCASESTR = YesPlease
@@ -485,8 +694,12 @@ endif
ifeq ($(uname_S),AIX)
NO_STRCASESTR=YesPlease
NO_MEMMEM = YesPlease
+ NO_MKDTEMP = YesPlease
NO_STRLCPY = YesPlease
+ FREAD_READS_DIRECTORIES = UnfortunatelyYes
+ INTERNAL_QSORT = UnfortunatelyYes
NEEDS_LIBICONV=YesPlease
+ BASIC_CFLAGS += -D_LARGE_FILES
endif
ifeq ($(uname_S),GNU)
# GNU/Hurd
@@ -504,6 +717,48 @@ ifeq ($(uname_S),IRIX64)
# for now, build 32-bit version
BASIC_LDFLAGS += -L/usr/lib32
endif
+ifeq ($(uname_S),HP-UX)
+ NO_IPV6=YesPlease
+ NO_SETENV=YesPlease
+ NO_STRCASESTR=YesPlease
+ NO_MEMMEM = YesPlease
+ NO_STRLCPY = YesPlease
+ NO_MKDTEMP = YesPlease
+ NO_UNSETENV = YesPlease
+ NO_HSTRERROR = YesPlease
+ NO_SYS_SELECT_H = YesPlease
+endif
+ifneq (,$(findstring MINGW,$(uname_S)))
+ NO_MMAP = YesPlease
+ NO_PREAD = YesPlease
+ NO_OPENSSL = YesPlease
+ NO_CURL = YesPlease
+ NO_SYMLINK_HEAD = YesPlease
+ NO_IPV6 = YesPlease
+ NO_SETENV = YesPlease
+ NO_UNSETENV = YesPlease
+ NO_STRCASESTR = YesPlease
+ NO_STRLCPY = YesPlease
+ NO_MEMMEM = YesPlease
+ NEEDS_LIBICONV = YesPlease
+ OLD_ICONV = YesPlease
+ NO_C99_FORMAT = YesPlease
+ NO_STRTOUMAX = YesPlease
+ NO_MKDTEMP = YesPlease
+ SNPRINTF_RETURNS_BOGUS = YesPlease
+ NO_SVN_TESTS = YesPlease
+ NO_PERL_MAKEMAKER = YesPlease
+ NO_POSIX_ONLY_PROGRAMS = YesPlease
+ COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat
+ COMPAT_CFLAGS += -DSNPRINTF_SIZE_CORR=1
+ COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
+ COMPAT_OBJS += compat/mingw.o compat/fnmatch.o compat/regex.o compat/winansi.o
+ EXTLIBS += -lws2_32
+ X = .exe
+ gitexecdir = ../libexec/git-core
+ template_dir = ../share/git-core/templates/
+ ETC_GITCONFIG = ../etc/gitconfig
+endif
ifneq (,$(findstring arm,$(uname_M)))
ARM_SHA1 = YesPlease
endif
@@ -564,6 +819,11 @@ ifdef ZLIB_PATH
endif
EXTLIBS += -lz
+ifndef NO_POSIX_ONLY_PROGRAMS
+ PROGRAMS += git-daemon$X
+ PROGRAMS += git-imap-send$X
+ PROGRAMS += git-shell$X
+endif
ifndef NO_OPENSSL
OPENSSL_LIBSSL = -lssl
ifdef OPENSSLDIR
@@ -606,6 +866,14 @@ endif
ifdef NO_C99_FORMAT
BASIC_CFLAGS += -DNO_C99_FORMAT
endif
+ifdef SNPRINTF_RETURNS_BOGUS
+ COMPAT_CFLAGS += -DSNPRINTF_RETURNS_BOGUS
+ COMPAT_OBJS += compat/snprintf.o
+endif
+ifdef FREAD_READS_DIRECTORIES
+ COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
+ COMPAT_OBJS += compat/fopen.o
+endif
ifdef NO_SYMLINK_HEAD
BASIC_CFLAGS += -DNO_SYMLINK_HEAD
endif
@@ -636,6 +904,9 @@ ifdef NO_UNSETENV
COMPAT_CFLAGS += -DNO_UNSETENV
COMPAT_OBJS += compat/unsetenv.o
endif
+ifdef NO_SYS_SELECT_H
+ BASIC_CFLAGS += -DNO_SYS_SELECT_H
+endif
ifdef NO_MMAP
COMPAT_CFLAGS += -DNO_MMAP
COMPAT_OBJS += compat/mmap.o
@@ -707,10 +978,21 @@ ifdef NO_MEMMEM
COMPAT_CFLAGS += -DNO_MEMMEM
COMPAT_OBJS += compat/memmem.o
endif
+ifdef INTERNAL_QSORT
+ COMPAT_CFLAGS += -DINTERNAL_QSORT
+ COMPAT_OBJS += compat/qsort.o
+endif
ifdef THREADED_DELTA_SEARCH
BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
EXTLIBS += -lpthread
+ LIB_OBJS += thread-utils.o
+endif
+ifdef DIR_HAS_BSD_GROUP_SEMANTICS
+ COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
+endif
+ifdef NO_EXTERNAL_GREP
+ BASIC_CFLAGS += -DNO_EXTERNAL_GREP
endif
ifeq ($(TCLTK_PATH),)
@@ -778,19 +1060,26 @@ export TAR INSTALL DESTDIR SHELL_PATH
### Build rules
-all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
+SHELL = $(SHELL_PATH)
+
+all:: shell_compatibility_test $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
ifneq (,$X)
- $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
+ $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test '$p' -ef '$p$X' || $(RM) '$p';)
endif
all::
ifndef NO_TCLTK
- $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
+ $(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) gitexecdir='$(gitexec_instdir_SQ)' all
$(QUIET_SUBDIR0)gitk-git $(QUIET_SUBDIR1) all
endif
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
+please_set_SHELL_PATH_to_a_more_modern_shell:
+ @$$(:)
+
+shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
+
strip: $(PROGRAMS) git$X
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
@@ -804,12 +1093,10 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
help.o: help.c common-cmds.h GIT-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
+ '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
-git-merge-subtree$X: git-merge-recursive$X
- $(QUIET_BUILT_IN)$(RM) $@ && ln git-merge-recursive$X $@
-
$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
@@ -821,10 +1108,10 @@ common-cmds.h: $(wildcard Documentation/git-*.txt)
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
- -e 's|@@HTMLDIR@@|$(htmldir_SQ)|g' \
$@.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@
@@ -856,6 +1143,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-e 's|++GIT_BINDIR++|$(bindir)|g' \
-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+ -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
@@ -929,12 +1217,18 @@ git-%$X: %.o $(GITLIBS)
git-imap-send$X: imap-send.o $(LIB_FILE)
-http.o http-walker.o http-push.o: http.h
+http.o http-walker.o http-push.o transport.o: http.h
git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
+$(COMPAT_LIB): $(COMPAT_OBJS)
+ $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(COMPAT_OBJS)
+
+git-shell$X: abspath.o ctype.o exec_cmd.o quote.o strbuf.o usage.o wrapper.o shell.o $(COMPAT_LIB)
+ $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(COMPAT_LIB)
+
$(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H)
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
builtin-revert.o wt-status.o: wt-status.h
@@ -980,6 +1274,13 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
echo "$$FLAGS" >GIT-CFLAGS; \
fi
+# We need to apply sq twice, once to protect from the shell
+# that runs GIT-BUILD-OPTIONS, and then again to protect it
+# and the first level quoting from the shell that runs "echo".
+GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
+ @echo SHELL_PATH=\''$(subst ','\'',$(SHELL_PATH_SQ))'\' >$@
+ @echo TAR=\''$(subst ','\'',$(subst ','\'',$(TAR)))'\' >>$@
+
### Detect Tck/Tk interpreter path changes
ifndef NO_TCLTK
TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
@@ -996,7 +1297,7 @@ endif
### Testing rules
-TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-absolute-path$X test-parse-options$X
+TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X
all:: $(TEST_PROGRAMS)
@@ -1027,36 +1328,59 @@ check: common-cmds.h
for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
remove-dashes:
- ./fixup-builtins $(BUILT_INS)
+ ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
### Installation rules
+ifeq ($(firstword $(subst /, ,$(template_dir))),..)
+template_instdir = $(bindir)/$(template_dir)
+else
+template_instdir = $(template_dir)
+endif
+export template_instdir
+
+ifeq ($(firstword $(subst /, ,$(gitexecdir))),..)
+gitexec_instdir = $(bindir)/$(gitexecdir)
+else
+gitexec_instdir = $(gitexecdir)
+endif
+gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
+export gitexec_instdir
+
install: all
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
- $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
- $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+ $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+ $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X '$(DESTDIR_SQ)$(bindir_SQ)'
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
ifndef NO_TCLTK
$(MAKE) -C gitk-git install
- $(MAKE) -C git-gui install
+ $(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
endif
- if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
- then \
- ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
- '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' || \
- cp '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
- '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
- fi
- $(foreach p,$(BUILT_INS), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
ifneq (,$X)
- $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
+ $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';)
endif
+ bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
+ execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
+ if test "z$$bindir" != "z$$execdir"; \
+ then \
+ ln -f "$$bindir/git$X" "$$execdir/git$X" || \
+ cp "$$bindir/git$X" "$$execdir/git$X"; \
+ fi && \
+ { $(foreach p,$(BUILT_INS), $(RM) "$$execdir/$p" && ln "$$execdir/git$X" "$$execdir/$p" ;) } && \
+ if test "z$$bindir" != "z$$execdir"; \
+ then \
+ $(RM) "$$execdir/git$X"; \
+ fi && \
+ ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
install-doc:
$(MAKE) -C Documentation install
+install-html:
+ $(MAKE) -C Documentation install-html
+
install-info:
$(MAKE) -C Documentation install-info
@@ -1072,7 +1396,7 @@ git.spec: git.spec.in
mv $@+ $@
GIT_TARNAME=git-$(GIT_VERSION)
-dist: git.spec git-archive configure
+dist: git.spec git-archive$(X) configure
./git-archive --format=tar \
--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
@mkdir -p $(GIT_TARNAME)
@@ -1117,7 +1441,7 @@ distclean: clean
clean:
$(RM) *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o xdiff/*.o \
- $(LIB_FILE) $(XDIFF_LIB)
+ $(LIB_FILE) $(XDIFF_LIB) $(COMPAT_LIB)
$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
$(RM) $(TEST_PROGRAMS)
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
@@ -1135,10 +1459,12 @@ ifndef NO_TCLTK
$(MAKE) -C gitk-git clean
$(MAKE) -C git-gui clean
endif
- $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS
+ $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
.PHONY: all install clean strip
+.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
+.PHONY: .FORCE-GIT-BUILD-OPTIONS
### Check documentation
#
@@ -1147,7 +1473,7 @@ check-docs::
do \
case "$$v" in \
git-merge-octopus | git-merge-ours | git-merge-recursive | \
- git-merge-resolve | git-merge-stupid | git-merge-subtree | \
+ git-merge-resolve | git-merge-subtree | \
git-fsck-objects | git-init-db | \
git-?*--?* ) continue ;; \
esac ; \
@@ -1178,6 +1504,14 @@ check-docs::
documented,gitmodules | \
documented,gitcli | \
documented,git-tools | \
+ documented,gitcore-tutorial | \
+ documented,gitcvs-migration | \
+ documented,gitdiffcore | \
+ documented,gitglossary | \
+ documented,githooks | \
+ documented,gitrepository-layout | \
+ documented,gittutorial | \
+ documented,gittutorial-2 | \
sentinel,not,matching,is,ok ) continue ;; \
esac; \
case " $(ALL_PROGRAMS) $(BUILT_INS) git gitk " in \
diff --git a/RelNotes b/RelNotes
index 46308cee0..b9a53c341 120000
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.5.4.txt \ No newline at end of file
+Documentation/RelNotes-1.6.0.txt \ No newline at end of file
diff --git a/abspath.c b/abspath.c
new file mode 100644
index 000000000..0d561246e
--- /dev/null
+++ b/abspath.c
@@ -0,0 +1,104 @@
+#include "cache.h"
+
+/* We allow "recursive" symbolic links. Only within reason, though. */
+#define MAXDEPTH 5
+
+const char *make_absolute_path(const char *path)
+{
+ static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
+ char cwd[1024] = "";
+ int buf_index = 1, len;
+
+ int depth = MAXDEPTH;
+ char *last_elem = NULL;
+ struct stat st;
+
+ if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
+ die ("Too long path: %.*s", 60, path);
+
+ while (depth--) {
+ if (stat(buf, &st) || !S_ISDIR(st.st_mode)) {
+ char *last_slash = strrchr(buf, '/');
+ if (last_slash) {
+ *last_slash = '\0';
+ last_elem = xstrdup(last_slash + 1);
+ } else {
+ last_elem = xstrdup(buf);
+ *buf = '\0';
+ }
+ }
+
+ if (*buf) {
+ if (!*cwd && !getcwd(cwd, sizeof(cwd)))
+ die ("Could not get current working directory");
+
+ if (chdir(buf))
+ die ("Could not switch to '%s'", buf);
+ }
+ if (!getcwd(buf, PATH_MAX))
+ die ("Could not get current working directory");
+
+ if (last_elem) {
+ int len = strlen(buf);
+ if (len + strlen(last_elem) + 2 > PATH_MAX)
+ die ("Too long path name: '%s/%s'",
+ buf, last_elem);
+ buf[len] = '/';
+ strcpy(buf + len + 1, last_elem);
+ free(last_elem);
+ last_elem = NULL;
+ }
+
+ if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
+ len = readlink(buf, next_buf, PATH_MAX);
+ if (len < 0)
+ die ("Invalid symlink: %s", buf);
+ next_buf[len] = '\0';
+ buf = next_buf;
+ buf_index = 1 - buf_index;
+ next_buf = bufs[buf_index];
+ } else
+ break;
+ }
+
+ if (*cwd && chdir(cwd))
+ die ("Could not change back to '%s'", cwd);
+
+ return buf;
+}
+
+static const char *get_pwd_cwd(void)
+{
+ static char cwd[PATH_MAX + 1];
+ char *pwd;
+ struct stat cwd_stat, pwd_stat;
+ if (getcwd(cwd, PATH_MAX) == NULL)
+ return NULL;
+ pwd = getenv("PWD");
+ if (pwd && strcmp(pwd, cwd)) {
+ stat(cwd, &cwd_stat);
+ if (!stat(pwd, &pwd_stat) &&
+ pwd_stat.st_dev == cwd_stat.st_dev &&
+ pwd_stat.st_ino == cwd_stat.st_ino) {
+ strlcpy(cwd, pwd, PATH_MAX);
+ }
+ }
+ return cwd;
+}
+
+const char *make_nonrelative_path(const char *path)
+{
+ static char buf[PATH_MAX + 1];
+
+ if (is_absolute_path(path)) {
+ if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
+ die("Too long path: %.*s", 60, path);
+ } else {
+ const char *cwd = get_pwd_cwd();
+ if (!cwd)
+ die("Cannot determine the current working directory");
+ if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX)
+ die("Too long path: %.*s", 60, path);
+ }
+ return buf;
+}
diff --git a/alias.c b/alias.c
new file mode 100644
index 000000000..ccb1108c9
--- /dev/null
+++ b/alias.c
@@ -0,0 +1,77 @@
+#include "cache.h"
+
+static const char *alias_key;
+static char *alias_val;
+
+static int alias_lookup_cb(const char *k, const char *v, void *cb)
+{
+ if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
+ if (!v)
+ return config_error_nonbool(k);
+ alias_val = xstrdup(v);
+ return 0;
+ }
+ return 0;
+}
+
+char *alias_lookup(const char *alias)
+{
+ alias_key = alias;
+ alias_val = NULL;
+ git_config(alias_lookup_cb, NULL);
+ return alias_val;
+}
+
+int split_cmdline(char *cmdline, const char ***argv)
+{
+ int src, dst, count = 0, size = 16;
+ char quoted = 0;
+
+ *argv = xmalloc(sizeof(char*) * size);
+
+ /* split alias_string */
+ (*argv)[count++] = cmdline;
+ for (src = dst = 0; cmdline[src];) {
+ char c = cmdline[src];
+ if (!quoted && isspace(c)) {
+ cmdline[dst++] = 0;
+ while (cmdline[++src]
+ && isspace(cmdline[src]))
+ ; /* skip */
+ if (count >= size) {
+ size += 16;
+ *argv = xrealloc(*argv, sizeof(char*) * size);
+ }
+ (*argv)[count++] = cmdline + dst;
+ } else if (!quoted && (c == '\'' || c == '"')) {
+ quoted = c;
+ src++;
+ } else if (c == quoted) {
+ quoted = 0;
+ src++;
+ } else {
+ if (c == '\\' && quoted != '\'') {
+ src++;
+ c = cmdline[src];
+ if (!c) {
+ free(*argv);
+ *argv = NULL;
+ return error("cmdline ends with \\");
+ }
+ }
+ cmdline[dst++] = c;
+ src++;
+ }
+ }
+
+ cmdline[dst] = 0;
+
+ if (quoted) {
+ free(*argv);
+ *argv = NULL;
+ return error("unclosed quote");
+ }
+
+ return count;
+}
+
diff --git a/archive-tar.c b/archive-tar.c
index e1bced560..13029619e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -2,9 +2,7 @@
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include "cache.h"
-#include "commit.h"
#include "tar.h"
-#include "builtin.h"
#include "archive.h"
#define RECORDSIZE (512)
@@ -13,10 +11,7 @@
static char block[BLOCKSIZE];
static unsigned long offset;
-static time_t archive_time;
static int tar_umask = 002;
-static int verbose;
-static const struct commit *commit;
/* writes out the whole block, but only if it is full */
static void write_if_needed(void)
@@ -113,22 +108,24 @@ static unsigned int ustar_header_chksum(const struct ustar_header *header)
return chksum;
}
-static int get_path_prefix(const struct strbuf *path, int maxlen)
+static size_t get_path_prefix(const char *path, size_t pathlen, size_t maxlen)
{
- int i = path->len;
+ size_t i = pathlen;
if (i > maxlen)
i = maxlen;
do {
i--;
- } while (i > 0 && path->buf[i] != '/');
+ } while (i > 0 && path[i] != '/');
return i;
}
-static void write_entry(const unsigned char *sha1, struct strbuf *path,
- unsigned int mode, void *buffer, unsigned long size)
+static int write_tar_entry(struct archiver_args *args,
+ const unsigned char *sha1, const char *path, size_t pathlen,
+ unsigned int mode, void *buffer, unsigned long size)
{
struct ustar_header header;
struct strbuf ext_header;
+ int err = 0;
memset(&header, 0, sizeof(header));
strbuf_init(&ext_header, 0);
@@ -142,8 +139,6 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
mode = 0100666;
sprintf(header.name, "%s.paxheader", sha1_to_hex(sha1));
} else {
- if (verbose)
- fprintf(stderr, "%.*s\n", (int)path->len, path->buf);
if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
*header.typeflag = TYPEFLAG_DIR;
mode = (mode | 0777) & ~tar_umask;
@@ -154,24 +149,24 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
*header.typeflag = TYPEFLAG_REG;
mode = (mode | ((mode & 0100) ? 0777 : 0666)) & ~tar_umask;
} else {
- error("unsupported file mode: 0%o (SHA1: %s)",
- mode, sha1_to_hex(sha1));
- return;
+ return error("unsupported file mode: 0%o (SHA1: %s)",
+ mode, sha1_to_hex(sha1));
}
- if (path->len > sizeof(header.name)) {
- int plen = get_path_prefix(path, sizeof(header.prefix));
- int rest = path->len - plen - 1;
+ if (pathlen > sizeof(header.name)) {
+ size_t plen = get_path_prefix(path, pathlen,
+ sizeof(header.prefix));
+ size_t rest = pathlen - plen - 1;
if (plen > 0 && rest <= sizeof(header.name)) {
- memcpy(header.prefix, path->buf, plen);
- memcpy(header.name, path->buf + plen + 1, rest);
+ memcpy(header.prefix, path, plen);
+ memcpy(header.name, path + plen + 1, rest);
} else {
sprintf(header.name, "%s.data",
sha1_to_hex(sha1));
strbuf_append_ext_header(&ext_header, "path",
- path->buf, path->len);
+ path, pathlen);
}
} else
- memcpy(header.name, path->buf, path->len);
+ memcpy(header.name, path, pathlen);
}
if (S_ISLNK(mode) && buffer) {
@@ -186,7 +181,7 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
sprintf(header.mode, "%07o", mode & 07777);
sprintf(header.size, "%011lo", S_ISREG(mode) ? size : 0);
- sprintf(header.mtime, "%011lo", archive_time);
+ sprintf(header.mtime, "%011lo", args->time);
sprintf(header.uid, "%07o", 0);
sprintf(header.gid, "%07o", 0);
@@ -201,28 +196,36 @@ static void write_entry(const unsigned char *sha1, struct strbuf *path,
sprintf(header.chksum, "%07o", ustar_header_chksum(&header));
if (ext_header.len > 0) {
- write_entry(sha1, NULL, 0, ext_header.buf, ext_header.len);
+ err = write_tar_entry(args, sha1, NULL, 0, 0, ext_header.buf,
+ ext_header.len);
+ if (err)
+ return err;
}
strbuf_release(&ext_header);
write_blocked(&header, sizeof(header));
if (S_ISREG(mode) && buffer && size > 0)
write_blocked(buffer, size);
+ return err;
}
-static void write_global_extended_header(const unsigned char *sha1)
+static int write_global_extended_header(struct archiver_args *args)
{
+ const unsigned char *sha1 = args->commit_sha1;
struct strbuf ext_header;
+ int err;
strbuf_init(&ext_header, 0);
strbuf_append_ext_header(&ext_header, "comment", sha1_to_hex(sha1), 40);
- write_entry(NULL, NULL, 0, ext_header.buf, ext_header.len);
+ err = write_tar_entry(args, NULL, NULL, 0, 0, ext_header.buf,
+ ext_header.len);
strbuf_release(&ext_header);
+ return err;
}
-static int git_tar_config(const char *var, const char *value)
+static int git_tar_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "tar.umask")) {
- if (!strcmp(value, "user")) {
+ if (value && !strcmp(value, "user")) {
tar_umask = umask(0);
umask(tar_umask);
} else {
@@ -230,64 +233,20 @@ static int git_tar_config(const char *var, const char *value)
}
return 0;
}
- return git_default_config(var, value);
-}
-
-static int write_tar_entry(const unsigned char *sha1,
- const char *base, int baselen,
- const char *filename, unsigned mode, int stage)
-{
- static struct strbuf path = STRBUF_INIT;
- void *buffer;
- enum object_type type;
- unsigned long size;
-
- strbuf_reset(&path);
- strbuf_grow(&path, PATH_MAX);
- strbuf_add(&path, base, baselen);
- strbuf_addstr(&path, filename);
- if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
- strbuf_addch(&path, '/');
- buffer = NULL;
- size = 0;
- } else {
- buffer = sha1_file_to_archive(path.buf, sha1, mode, &type,
- &size, commit);
- if (!buffer)
- die("cannot read %s", sha1_to_hex(sha1));
- }
-
- write_entry(sha1, &path, mode, buffer, size);
- free(buffer);
-
- return READ_TREE_RECURSIVE;
+ return git_default_config(var, value, cb);
}
int write_tar_archive(struct archiver_args *args)
{
- int plen = args->base ? strlen(args->base) : 0;
-
- git_config(git_tar_config);
+ int err = 0;
- archive_time = args->time;
- verbose = args->verbose;
- commit = args->commit;
+ git_config(git_tar_config, NULL);
if (args->commit_sha1)
- write_global_extended_header(args->commit_sha1);
-
- if (args->base && plen > 0 && args->base[plen - 1] == '/') {
- char *base = xstrdup(args->base);
- int baselen = strlen(base);
-
- while (baselen > 0 && base[baselen - 1] == '/')
- base[--baselen] = '\0';
- write_tar_entry(args->tree->object.sha1, "", 0, base, 040777, 0);
- free(base);
- }
- read_tree_recursive(args->tree, args->base, plen, 0,
- args->pathspec, write_tar_entry);
- write_trailer();
-
- return 0;
+ err = write_global_extended_header(args);
+ if (!err)
+ err = write_archive_entries(args, write_tar_entry);
+ if (!err)
+ write_trailer();
+ return err;
}
diff --git a/archive-zip.c b/archive-zip.c
index 74e30f620..cf285044e 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -2,17 +2,10 @@
* Copyright (c) 2006 Rene Scharfe
*/
#include "cache.h"
-#include "commit.h"
-#include "blob.h"
-#include "tree.h"
-#include "quote.h"
-#include "builtin.h"
#include "archive.h"
-static int verbose;
static int zip_date;
static int zip_time;
-static const struct commit *commit;
static unsigned char *zip_dir;
static unsigned int zip_dir_size;
@@ -95,7 +88,7 @@ static void copy_le32(unsigned char *dest, unsigned int n)
}
static void *zlib_deflate(void *data, unsigned long size,
- unsigned long *compressed_size)
+ int compression_level, unsigned long *compressed_size)
{
z_stream stream;
unsigned long maxsize;
@@ -103,7 +96,7 @@ static void *zlib_deflate(void *data, unsigned long size,
int result;
memset(&stream, 0, sizeof(stream));
- deflateInit(&stream, zlib_compression_level);
+ deflateInit(&stream, compression_level);
maxsize = deflateBound(&stream, size);
buffer = xmalloc(maxsize);
@@ -127,33 +120,9 @@ static void *zlib_deflate(void *data, unsigned long size,
return buffer;
}
-static char *construct_path(const char *base, int baselen,
- const char *filename, int isdir, int *pathlen)
-{
- int filenamelen = strlen(filename);
- int len = baselen + filenamelen;
- char *path, *p;
-
- if (isdir)
- len++;
- p = path = xmalloc(len + 1);
-
- memcpy(p, base, baselen);
- p += baselen;
- memcpy(p, filename, filenamelen);
- p += filenamelen;
- if (isdir)
- *p++ = '/';
- *p = '\0';
-
- *pathlen = len;
-
- return path;
-}
-
-static int write_zip_entry(const unsigned char *sha1,
- const char *base, int baselen,
- const char *filename, unsigned mode, int stage)
+static int write_zip_entry(struct archiver_args *args,
+ const unsigned char *sha1, const char *path, size_t pathlen,
+ unsigned int mode, void *buffer, unsigned long size)
{
struct zip_local_header header;
struct zip_dir_header dirent;
@@ -162,31 +131,20 @@ static int write_zip_entry(const unsigned char *sha1,
unsigned long uncompressed_size;
unsigned long crc;
unsigned long direntsize;
- unsigned long size;
int method;
- int result = -1;
- int pathlen;
unsigned char *out;
- char *path;
- enum object_type type;
- void *buffer = NULL;
void *deflated = NULL;
crc = crc32(0, NULL, 0);
- path = construct_path(base, baselen, filename, S_ISDIR(mode), &pathlen);
- if (verbose)
- fprintf(stderr, "%s\n", path);
if (pathlen > 0xffff) {
- error("path too long (%d chars, SHA1: %s): %s", pathlen,
- sha1_to_hex(sha1), path);
- goto out;
+ return error("path too long (%d chars, SHA1: %s): %s",
+ (int)pathlen, sha1_to_hex(sha1), path);
}
if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
method = 0;
attr2 = 16;
- result = (S_ISDIR(mode) ? READ_TREE_RECURSIVE : 0);
out = NULL;
uncompressed_size = 0;
compressed_size = 0;
@@ -194,25 +152,20 @@ static int write_zip_entry(const unsigned char *sha1,
method = 0;
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :
(mode & 0111) ? ((mode) << 16) : 0;
- if (S_ISREG(mode) && zlib_compression_level != 0)
+ if (S_ISREG(mode) && args->compression_level != 0)
method = 8;
- result = 0;
- buffer = sha1_file_to_archive(path, sha1, mode, &type, &size,
- commit);
- if (!buffer)
- die("cannot read %s", sha1_to_hex(sha1));
crc = crc32(crc, buffer, size);
out = buffer;
uncompressed_size = size;
compressed_size = size;
} else {
- error("unsupported file mode: 0%o (SHA1: %s)", mode,
- sha1_to_hex(sha1));
- goto out;
+ return error("unsupported file mode: 0%o (SHA1: %s)", mode,
+ sha1_to_hex(sha1));
}
if (method == 8) {
- deflated = zlib_deflate(buffer, size, &compressed_size);
+ deflated = zlib_deflate(buffer, size, args->compression_level,
+ &compressed_size);
if (deflated && compressed_size - 6 < size) {
/* ZLIB --> raw compressed data (see RFC 1950) */
/* CMF and FLG ... */
@@ -275,12 +228,9 @@ static int write_zip_entry(const unsigned char *sha1,
zip_offset += compressed_size;
}
-out:
- free(buffer);
free(deflated);
- free(path);
- return result;
+ return 0;
}
static void write_zip_trailer(const unsigned char *sha1)
@@ -313,42 +263,18 @@ static void dos_time(time_t *time, int *dos_date, int *dos_time)
int write_zip_archive(struct archiver_args *args)
{
- int plen = strlen(args->base);
+ int err;
dos_time(&args->time, &zip_date, &zip_time);
zip_dir = xmalloc(ZIP_DIRECTORY_MIN_SIZE);
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
- verbose = args->verbose;
- commit = args->commit;
- if (args->base && plen > 0 && args->base[plen - 1] == '/') {
- char *base = xstrdup(args->base);
- int baselen = strlen(base);
-
- while (baselen > 0 && base[baselen - 1] == '/')
- base[--baselen] = '\0';
- write_zip_entry(args->tree->object.sha1, "", 0, base, 040777, 0);
- free(base);
- }
- read_tree_recursive(args->tree, args->base, plen, 0,
- args->pathspec, write_zip_entry);
- write_zip_trailer(args->commit_sha1);
+ err = write_archive_entries(args, write_zip_entry);
+ if (!err)
+ write_zip_trailer(args->commit_sha1);
free(zip_dir);
- return 0;
-}
-
-void *parse_extra_zip_args(int argc, const char **argv)
-{
- for (; argc > 0; argc--, argv++) {
- const char *arg = argv[0];
-
- if (arg[0] == '-' && isdigit(arg[1]) && arg[2] == '\0')
- zlib_compression_level = arg[1] - '0';
- else
- die("Unknown argument for zip format: %s", arg);
- }
- return NULL;
+ return err;
}
diff --git a/archive.c b/archive.c
index fb159fe59..5b40e261f 100644
--- a/archive.c
+++ b/archive.c
@@ -1,6 +1,28 @@
#include "cache.h"
#include "commit.h"
+#include "tree-walk.h"
#include "attr.h"
+#include "archive.h"
+#include "parse-options.h"
+
+static char const * const archive_usage[] = {
+ "git archive [options] <tree-ish> [path...]",
+ "git archive --list",
+ "git archive --remote <repo> [--exec <cmd>] [options] <tree-ish> [path...]",
+ "git archive --remote <repo> [--exec <cmd>] --list",
+ NULL
+};
+
+#define USES_ZLIB_COMPRESSION 1
+
+const struct archiver {
+ const char *name;
+ write_archive_fn_t write_archive;
+ unsigned int flags;
+} archivers[] = {
+ { "tar", write_tar_archive },
+ { "zip", write_zip_archive, USES_ZLIB_COMPRESSION },
+};
static void format_subst(const struct commit *commit,
const char *src, size_t len,
@@ -16,9 +38,9 @@ static void format_subst(const struct commit *commit,
const char *b, *c;
b = memmem(src, len, "$Format:", 8);
- if (!b || src + len < b + 9)
+ if (!b)
break;
- c = memchr(b + 8, '$', len - 8);
+ c = memchr(b + 8, '$', (src + len) - b - 8);
if (!c)
break;
@@ -35,34 +57,9 @@ static void format_subst(const struct commit *commit,
free(to_free);
}
-static int convert_to_archive(const char *path,
- const void *src, size_t len,
- struct strbuf *buf,
- const struct commit *commit)
-{
- static struct git_attr *attr_export_subst;
- struct git_attr_check check[1];
-
- if (!commit)
- return 0;
-
- if (!attr_export_subst)
- attr_export_subst = git_attr("export-subst", 12);
-
- check[0].attr = attr_export_subst;
- if (git_checkattr(path, ARRAY_SIZE(check), check))
- return 0;
- if (!ATTR_TRUE(check[0].value))
- return 0;
-
- format_subst(commit, src, len, buf);
- return 1;
-}
-
-void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
- unsigned int mode, enum object_type *type,
- unsigned long *sizep,
- const struct commit *commit)
+static void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
+ unsigned int mode, enum object_type *type,
+ unsigned long *sizep, const struct commit *commit)
{
void *buffer;
@@ -74,7 +71,8 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
strbuf_init(&buf, 0);
strbuf_attach(&buf, buffer, *sizep, *sizep + 1);
convert_to_working_tree(path, buf.buf, buf.len, &buf);
- convert_to_archive(path, buf.buf, buf.len, &buf, commit);
+ if (commit)
+ format_subst(commit, buf.buf, buf.len, &buf);
buffer = strbuf_detach(&buf, &size);
*sizep = size;
}
@@ -82,3 +80,263 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
return buffer;
}
+static void setup_archive_check(struct git_attr_check *check)
+{
+ static struct git_attr *attr_export_ignore;
+ static struct git_attr *attr_export_subst;
+
+ if (!attr_export_ignore) {
+ attr_export_ignore = git_attr("export-ignore", 13);
+ attr_export_subst = git_attr("export-subst", 12);
+ }
+ check[0].attr = attr_export_ignore;
+ check[1].attr = attr_export_subst;
+}
+
+struct archiver_context {
+ struct archiver_args *args;
+ write_archive_entry_fn_t write_entry;
+};
+
+static int write_archive_entry(const unsigned char *sha1, const char *base,
+ int baselen, const char *filename, unsigned mode, int stage,
+ void *context)
+{
+ static struct strbuf path = STRBUF_INIT;
+ struct archiver_context *c = context;
+ struct archiver_args *args = c->args;
+ write_archive_entry_fn_t write_entry = c->write_entry;
+ struct git_attr_check check[2];
+ const char *path_without_prefix;
+ int convert = 0;
+ int err;
+ enum object_type type;
+ unsigned long size;
+ void *buffer;
+
+ strbuf_reset(&path);
+ strbuf_grow(&path, PATH_MAX);
+ strbuf_add(&path, base, baselen);
+ strbuf_addstr(&path, filename);
+ path_without_prefix = path.buf + args->baselen;
+
+ setup_archive_check(check);
+ if (!git_checkattr(path_without_prefix, ARRAY_SIZE(check), check)) {
+ if (ATTR_TRUE(check[0].value))
+ return 0;
+ convert = ATTR_TRUE(check[1].value);
+ }
+
+ if (S_ISDIR(mode) || S_ISGITLINK(mode)) {
+ strbuf_addch(&path, '/');
+ if (args->verbose)
+ fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
+ err = write_entry(args, sha1, path.buf, path.len, mode, NULL, 0);
+ if (err)
+ return err;
+ return READ_TREE_RECURSIVE;
+ }
+
+ buffer = sha1_file_to_archive(path_without_prefix, sha1, mode,
+ &type, &size, convert ? args->commit : NULL);
+ if (!buffer)
+ return error("cannot read %s", sha1_to_hex(sha1));
+ if (args->verbose)
+ fprintf(stderr, "%.*s\n", (int)path.len, path.buf);
+ err = write_entry(args, sha1, path.buf, path.len, mode, buffer, size);
+ free(buffer);
+ return err;
+}
+
+int write_archive_entries(struct archiver_args *args,
+ write_archive_entry_fn_t write_entry)
+{
+ struct archiver_context context;
+ int err;
+
+ if (args->baselen > 0 && args->base[args->baselen - 1] == '/') {
+ size_t len = args->baselen;
+
+ while (len > 1 && args->base[len - 2] == '/')
+ len--;
+ if (args->verbose)
+ fprintf(stderr, "%.*s\n", (int)len, args->base);
+ err = write_entry(args, args->tree->object.sha1, args->base,
+ len, 040777, NULL, 0);
+ if (err)
+ return err;
+ }
+
+ context.args = args;
+ context.write_entry = write_entry;
+
+ err = read_tree_recursive(args->tree, args->base, args->baselen, 0,
+ args->pathspec, write_archive_entry, &context);
+ if (err == READ_TREE_RECURSIVE)
+ err = 0;
+ return err;
+}
+
+static const struct archiver *lookup_archiver(const char *name)
+{
+ int i;
+
+ if (!name)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(archivers); i++) {
+ if (!strcmp(name, archivers[i].name))
+ return &archivers[i];
+ }
+ return NULL;
+}
+
+static void parse_pathspec_arg(const char **pathspec,
+ struct archiver_args *ar_args)
+{
+ ar_args->pathspec = get_pathspec(ar_args->base, pathspec);
+}
+
+static void parse_treeish_arg(const char **argv,
+ struct archiver_args *ar_args, const char *prefix)
+{
+ const char *name = argv[0];
+ const unsigned char *commit_sha1;
+ time_t archive_time;
+ struct tree *tree;
+ const struct commit *commit;
+ unsigned char sha1[20];
+
+ if (get_sha1(name, sha1))
+ die("Not a valid object name");
+
+ commit = lookup_commit_reference_gently(sha1, 1);
+ if (commit) {
+ commit_sha1 = commit->object.sha1;
+ archive_time = commit->date;
+ } else {
+ commit_sha1 = NULL;
+ archive_time = time(NULL);
+ }
+
+ tree = parse_tree_indirect(sha1);
+ if (tree == NULL)
+ die("not a tree object");
+
+ if (prefix) {
+ unsigned char tree_sha1[20];
+ unsigned int mode;
+ int err;
+
+ err = get_tree_entry(tree->object.sha1, prefix,
+ tree_sha1, &mode);
+ if (err || !S_ISDIR(mode))
+ die("current working directory is untracked");
+
+ tree = parse_tree_indirect(tree_sha1);
+ }
+ ar_args->tree = tree;
+ ar_args->commit_sha1 = commit_sha1;
+ ar_args->commit = commit;
+ ar_args->time = archive_time;
+}
+
+#define OPT__COMPR(s, v, h, p) \
+ { OPTION_SET_INT, (s), NULL, (v), NULL, (h), \
+ PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, (p) }
+#define OPT__COMPR_HIDDEN(s, v, p) \
+ { OPTION_SET_INT, (s), NULL, (v), NULL, "", \
+ PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_HIDDEN, NULL, (p) }
+
+static int parse_archive_args(int argc, const char **argv,
+ const struct archiver **ar, struct archiver_args *args)
+{
+ const char *format = "tar";
+ const char *base = NULL;
+ const char *remote = NULL;
+ const char *exec = NULL;
+ int compression_level = -1;
+ int verbose = 0;
+ int i;
+ int list = 0;
+ struct option opts[] = {
+ OPT_GROUP(""),
+ OPT_STRING(0, "format", &format, "fmt", "archive format"),
+ OPT_STRING(0, "prefix", &base, "prefix",
+ "prepend prefix to each pathname in the archive"),
+ OPT__VERBOSE(&verbose),
+ OPT__COMPR('0', &compression_level, "store only", 0),
+ OPT__COMPR('1', &compression_level, "compress faster", 1),
+ OPT__COMPR_HIDDEN('2', &compression_level, 2),
+ OPT__COMPR_HIDDEN('3', &compression_level, 3),
+ OPT__COMPR_HIDDEN('4', &compression_level, 4),
+ OPT__COMPR_HIDDEN('5', &compression_level, 5),
+ OPT__COMPR_HIDDEN('6', &compression_level, 6),
+ OPT__COMPR_HIDDEN('7', &compression_level, 7),
+ OPT__COMPR_HIDDEN('8', &compression_level, 8),
+ OPT__COMPR('9', &compression_level, "compress better", 9),
+ OPT_GROUP(""),
+ OPT_BOOLEAN('l', "list", &list,
+ "list supported archive formats"),
+ OPT_GROUP(""),
+ OPT_STRING(0, "remote", &remote, "repo",
+ "retrieve the archive from remote repository <repo>"),
+ OPT_STRING(0, "exec", &exec, "cmd",
+ "path to the remote git-upload-archive command"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, opts, archive_usage, 0);
+
+ if (remote)
+ die("Unexpected option --remote");
+ if (exec)
+ die("Option --exec can only be used together with --remote");
+
+ if (!base)
+ base = "";
+
+ if (list) {
+ for (i = 0; i < ARRAY_SIZE(archivers); i++)
+ printf("%s\n", archivers[i].name);
+ exit(0);
+ }
+
+ /* We need at least one parameter -- tree-ish */
+ if (argc < 1)
+ usage_with_options(archive_usage, opts);
+ *ar = lookup_archiver(format);
+ if (!*ar)
+ die("Unknown archive format '%s'", format);
+
+ args->compression_level = Z_DEFAULT_COMPRESSION;
+ if (compression_level != -1) {
+ if ((*ar)->flags & USES_ZLIB_COMPRESSION)
+ args->compression_level = compression_level;
+ else {
+ die("Argument not supported for format '%s': -%d",
+ format, compression_level);
+ }
+ }
+ args->verbose = verbose;
+ args->base = base;
+ args->baselen = strlen(base);
+
+ return argc;
+}
+
+int write_archive(int argc, const char **argv, const char *prefix,
+ int setup_prefix)
+{
+ const struct archiver *ar = NULL;
+ struct archiver_args args;
+
+ argc = parse_archive_args(argc, argv, &ar, &args);
+ if (setup_prefix && prefix == NULL)
+ prefix = setup_git_directory();
+
+ parse_treeish_arg(argv, &args, prefix);
+ parse_pathspec_arg(argv + 1, &args);
+
+ return ar->write_archive(&args);
+}
diff --git a/archive.h b/archive.h
index 5791e657e..0b15b3514 100644
--- a/archive.h
+++ b/archive.h
@@ -1,48 +1,29 @@
#ifndef ARCHIVE_H
#define ARCHIVE_H
-#define MAX_EXTRA_ARGS 32
-#define MAX_ARGS (MAX_EXTRA_ARGS + 32)
-
struct archiver_args {
const char *base;
+ size_t baselen;
struct tree *tree;
const unsigned char *commit_sha1;
const struct commit *commit;
time_t time;
const char **pathspec;
unsigned int verbose : 1;
- void *extra;
+ int compression_level;
};
typedef int (*write_archive_fn_t)(struct archiver_args *);
-typedef void *(*parse_extra_args_fn_t)(int argc, const char **argv);
-
-struct archiver {
- const char *name;
- struct archiver_args args;
- write_archive_fn_t write_archive;
- parse_extra_args_fn_t parse_extra;
-};
-
-extern int parse_archive_args(int argc,
- const char **argv,
- struct archiver *ar);
-
-extern void parse_treeish_arg(const char **treeish,
- struct archiver_args *ar_args,
- const char *prefix);
+typedef int (*write_archive_entry_fn_t)(struct archiver_args *args, const unsigned char *sha1, const char *path, size_t pathlen, unsigned int mode, void *buffer, unsigned long size);
-extern void parse_pathspec_arg(const char **pathspec,
- struct archiver_args *args);
/*
* Archive-format specific backends.
*/
extern int write_tar_archive(struct archiver_args *);
extern int write_zip_archive(struct archiver_args *);
-extern void *parse_extra_zip_args(int argc, const char **argv);
-extern void *sha1_file_to_archive(const char *path, const unsigned char *sha1, unsigned int mode, enum object_type *type, unsigned long *size, const struct commit *commit);
+extern int write_archive_entries(struct archiver_args *args, write_archive_entry_fn_t write_entry);
+extern int write_archive(int argc, const char **argv, const char *prefix, int setup_prefix);
#endif /* ARCHIVE_H */
diff --git a/attr.c b/attr.c
index 741db3b46..17f6a4dca 100644
--- a/attr.c
+++ b/attr.c
@@ -406,7 +406,7 @@ static void debug_info(const char *what, struct attr_stack *elem)
{
fprintf(stderr, "%s: %s\n", what, elem->origin ? elem->origin : "()");
}
-static void debug_set(const char *what, const char *match, struct git_attr *attr, void *v)
+static void debug_set(const char *what, const char *match, struct git_attr *attr, const void *v)
{
const char *value = v;
@@ -438,11 +438,13 @@ static void bootstrap_attr_stack(void)
elem->prev = attr_stack;
attr_stack = elem;
- elem = read_attr(GITATTRIBUTES_FILE, 1);
- elem->origin = strdup("");
- elem->prev = attr_stack;
- attr_stack = elem;
- debug_push(elem);
+ if (!is_bare_repository()) {
+ elem = read_attr(GITATTRIBUTES_FILE, 1);
+ elem->origin = strdup("");
+ elem->prev = attr_stack;
+ attr_stack = elem;
+ debug_push(elem);
+ }
elem = read_attr_from_file(git_path(INFOATTRIBUTES_FILE), 1);
if (!elem)
@@ -457,7 +459,9 @@ static void prepare_attr_stack(const char *path, int dirlen)
{
struct attr_stack *elem, *info;
int len;
- char pathbuf[PATH_MAX];
+ struct strbuf pathbuf;
+
+ strbuf_init(&pathbuf, dirlen+2+strlen(GITATTRIBUTES_FILE));
/*
* At the bottom of the attribute stack is the built-in
@@ -501,22 +505,25 @@ static void prepare_attr_stack(const char *path, int dirlen)
/*
* Read from parent directories and push them down
*/
- while (1) {
- char *cp;
-
- len = strlen(attr_stack->origin);
- if (dirlen <= len)
- break;
- memcpy(pathbuf, path, dirlen);
- memcpy(pathbuf + dirlen, "/", 2);
- cp = strchr(pathbuf + len + 1, '/');
- strcpy(cp + 1, GITATTRIBUTES_FILE);
- elem = read_attr(pathbuf, 0);
- *cp = '\0';
- elem->origin = strdup(pathbuf);
- elem->prev = attr_stack;
- attr_stack = elem;
- debug_push(elem);
+ if (!is_bare_repository()) {
+ while (1) {
+ char *cp;
+
+ len = strlen(attr_stack->origin);
+ if (dirlen <= len)
+ break;
+ strbuf_reset(&pathbuf);
+ strbuf_add(&pathbuf, path, dirlen);
+ strbuf_addch(&pathbuf, '/');
+ cp = strchr(pathbuf.buf + len + 1, '/');
+ strcpy(cp + 1, GITATTRIBUTES_FILE);
+ elem = read_attr(pathbuf.buf, 0);
+ *cp = '\0';
+ elem->origin = strdup(pathbuf.buf);
+ elem->prev = attr_stack;
+ attr_stack = elem;
+ debug_push(elem);
+ }
}
/*
@@ -543,9 +550,11 @@ static int path_matches(const char *pathname, int pathlen,
if (*pattern == '/')
pattern++;
if (pathlen < baselen ||
- (baselen && pathname[baselen - 1] != '/') ||
+ (baselen && pathname[baselen] != '/') ||
strncmp(pathname, base, baselen))
return 0;
+ if (baselen != 0)
+ baselen++;
return fnmatch(pattern, pathname + baselen, FNM_PATHNAME) == 0;
}
diff --git a/branch.c b/branch.c
index 1fc878889..b1e59f219 100644
--- a/branch.c
+++ b/branch.c
@@ -32,12 +32,28 @@ static int find_tracked_branch(struct remote *remote, void *priv)
return 0;
}
+static int should_setup_rebase(const struct tracking *tracking)
+{
+ switch (autorebase) {
+ case AUTOREBASE_NEVER:
+ return 0;
+ case AUTOREBASE_LOCAL:
+ return tracking->remote == NULL;
+ case AUTOREBASE_REMOTE:
+ return tracking->remote != NULL;
+ case AUTOREBASE_ALWAYS:
+ return 1;
+ }
+ return 0;
+}
+
/*
* This is called when new_ref is branched off of orig_ref, and tries
* to infer the settings for branch.<new_ref>.{remote,merge} from the
* config.
*/
-static int setup_tracking(const char *new_ref, const char *orig_ref)
+static int setup_tracking(const char *new_ref, const char *orig_ref,
+ enum branch_track track)
{
char key[1024];
struct tracking tracking;
@@ -48,30 +64,41 @@ static int setup_tracking(const char *new_ref, const char *orig_ref)
memset(&tracking, 0, sizeof(tracking));
tracking.spec.dst = (char *)orig_ref;
- if (for_each_remote(find_tracked_branch, &tracking) ||
- !tracking.matches)
+ if (for_each_remote(find_tracked_branch, &tracking))
return 1;
+ if (!tracking.matches)
+ switch (track) {
+ case BRANCH_TRACK_ALWAYS:
+ case BRANCH_TRACK_EXPLICIT:
+ break;
+ default:
+ return 1;
+ }
+
if (tracking.matches > 1)
return error("Not tracking: ambiguous information for ref %s",
orig_ref);
- if (tracking.matches == 1) {
- sprintf(key, "branch.%s.remote", new_ref);
- git_config_set(key, tracking.remote ? tracking.remote : ".");
- sprintf(key, "branch.%s.merge", new_ref);
- git_config_set(key, tracking.src);
- free(tracking.src);
- printf("Branch %s set up to track remote branch %s.\n",
- new_ref, orig_ref);
+ sprintf(key, "branch.%s.remote", new_ref);
+ git_config_set(key, tracking.remote ? tracking.remote : ".");
+ sprintf(key, "branch.%s.merge", new_ref);
+ git_config_set(key, tracking.src ? tracking.src : orig_ref);
+ printf("Branch %s set up to track %s branch %s.\n", new_ref,
+ tracking.remote ? "remote" : "local", orig_ref);
+ if (should_setup_rebase(&tracking)) {
+ sprintf(key, "branch.%s.rebase", new_ref);
+ git_config_set(key, "true");
+ printf("This branch will rebase on pull.\n");
}
+ free(tracking.src);
return 0;
}
void create_branch(const char *head,
const char *name, const char *start_name,
- int force, int reflog, int track)
+ int force, int reflog, enum branch_track track)
{
struct ref_lock *lock;
struct commit *commit;
@@ -98,7 +125,8 @@ void create_branch(const char *head,
switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) {
case 0:
/* Not branching from any existing branch */
- real_ref = NULL;
+ if (track == BRANCH_TRACK_EXPLICIT)
+ die("Cannot setup tracking information; starting point is not a branch.");
break;
case 1:
/* Unique completion -- good */
@@ -126,23 +154,19 @@ void create_branch(const char *head,
snprintf(msg, sizeof msg, "branch: Created from %s",
start_name);
- /* When branching off a remote branch, set up so that git-pull
- automatically merges from there. So far, this is only done for
- remotes registered via .git/config. */
if (real_ref && track)
- setup_tracking(name, real_ref);
+ setup_tracking(name, real_ref, track);
if (write_ref_sha1(lock, sha1, msg) < 0)
die("Failed to write ref: %s.", strerror(errno));
- if (real_ref)
- free(real_ref);
+ free(real_ref);
}
void remove_branch_state(void)
{
unlink(git_path("MERGE_HEAD"));
- unlink(git_path("rr-cache/MERGE_RR"));
+ unlink(git_path("MERGE_RR"));
unlink(git_path("MERGE_MSG"));
unlink(git_path("SQUASH_MSG"));
}
diff --git a/branch.h b/branch.h
index d30abe036..9f0c2a2c1 100644
--- a/branch.h
+++ b/branch.h
@@ -13,7 +13,7 @@
* branch for (if any).
*/
void create_branch(const char *head, const char *name, const char *start_name,
- int force, int reflog, int track);
+ int force, int reflog, enum branch_track track);
/*
* Remove information about the state of working on the current
diff --git a/builtin-add.c b/builtin-add.c
index 4a91e3eb1..fc3f96eae 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -16,7 +16,7 @@
#include "parse-options.h"
static const char * const builtin_add_usage[] = {
- "git-add [options] [--] <filepattern>...",
+ "git add [options] [--] <filepattern>...",
NULL
};
static int patch_interactive = 0, add_interactive = 0;
@@ -79,12 +79,18 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec,
prune_directory(dir, pathspec, baselen);
}
+struct update_callback_data
+{
+ int flags;
+ int add_errors;
+};
+
static void update_callback(struct diff_queue_struct *q,
struct diff_options *opt, void *cbdata)
{
- int i, verbose;
+ int i;
+ struct update_callback_data *data = cbdata;
- verbose = *((int *)cbdata);
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
const char *path = p->one->path;
@@ -94,27 +100,36 @@ static void update_callback(struct diff_queue_struct *q,
case DIFF_STATUS_UNMERGED:
case DIFF_STATUS_MODIFIED:
case DIFF_STATUS_TYPE_CHANGED:
- add_file_to_cache(path, verbose);
+ if (add_file_to_cache(path, data->flags)) {
+ if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
+ die("updating files failed");
+ data->add_errors++;
+ }
break;
case DIFF_STATUS_DELETED:
- remove_file_from_cache(path);
- if (verbose)
+ if (!(data->flags & ADD_CACHE_PRETEND))
+ remove_file_from_cache(path);
+ if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
printf("remove '%s'\n", path);
break;
}
}
}
-void add_files_to_cache(int verbose, const char *prefix, const char **pathspec)
+int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
{
+ struct update_callback_data data;
struct rev_info rev;
init_revisions(&rev, prefix);
setup_revisions(0, NULL, &rev, NULL);
rev.prune_data = pathspec;
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = update_callback;
- rev.diffopt.format_callback_data = &verbose;
+ data.flags = flags;
+ data.add_errors = 0;
+ rev.diffopt.format_callback_data = &data;
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
+ return !!data.add_errors;
}
static void refresh(int verbose, const char **pathspec)
@@ -125,9 +140,8 @@ static void refresh(int verbose, const char **pathspec)
for (specs = 0; pathspec[specs]; specs++)
/* nothing */;
seen = xcalloc(specs, 1);
- if (read_cache() < 0)
- die("index file corrupt");
- refresh_index(&the_index, verbose ? 0 : REFRESH_QUIET, pathspec, seen);
+ refresh_index(&the_index, verbose ? REFRESH_SAY_CHANGED : REFRESH_QUIET,
+ pathspec, seen);
for (i = 0; i < specs; i++) {
if (!seen[i])
die("pathspec '%s' did not match any files", pathspec[i]);
@@ -177,6 +191,7 @@ static const char ignore_error[] =
"The following paths are ignored by one of your .gitignore files:\n";
static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
+static int ignore_add_errors, addremove;
static struct option builtin_add_options[] = {
OPT__DRY_RUN(&show_only),
@@ -184,17 +199,53 @@ static struct option builtin_add_options[] = {
OPT_GROUP(""),
OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
OPT_BOOLEAN('p', "patch", &patch_interactive, "interactive patching"),
- OPT_BOOLEAN('f', NULL, &ignored_too, "allow adding otherwise ignored files"),
- OPT_BOOLEAN('u', NULL, &take_worktree_changes, "update tracked files"),
+ OPT_BOOLEAN('f', "force", &ignored_too, "allow adding otherwise ignored files"),
+ OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
+ OPT_BOOLEAN('A', "all", &addremove, "add all, noticing removal of tracked files"),
OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
+ OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
OPT_END(),
};
+static int add_config(const char *var, const char *value, void *cb)
+{
+ if (!strcasecmp(var, "add.ignore-errors")) {
+ ignore_add_errors = git_config_bool(var, value);
+ return 0;
+ }
+ return git_default_config(var, value, cb);
+}
+
+static int add_files(struct dir_struct *dir, int flags)
+{
+ int i, exit_status = 0;
+
+ if (dir->ignored_nr) {
+ fprintf(stderr, ignore_error);
+ for (i = 0; i < dir->ignored_nr; i++)
+ fprintf(stderr, "%s\n", dir->ignored[i]->name);
+ fprintf(stderr, "Use -f if you really want to add them.\n");
+ die("no files added");
+ }
+
+ for (i = 0; i < dir->nr; i++)
+ if (add_file_to_cache(dir->entries[i]->name, flags)) {
+ if (!ignore_add_errors)
+ die("adding files failed");
+ exit_status = 1;
+ }
+ return exit_status;
+}
+
int cmd_add(int argc, const char **argv, const char *prefix)
{
- int i, newfd;
+ int exit_status = 0;
+ int newfd;
const char **pathspec;
struct dir_struct dir;
+ int flags;
+ int add_new_files;
+ int require_pathspec;
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
@@ -203,58 +254,53 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (add_interactive)
exit(interactive_add(argc, argv, prefix));
- git_config(git_default_config);
+ git_config(add_config, NULL);
+
+ if (addremove && take_worktree_changes)
+ die("-A and -u are mutually incompatible");
+ if (addremove && !argc) {
+ static const char *here[2] = { ".", NULL };
+ argc = 1;
+ argv = here;
+ }
+
+ add_new_files = !take_worktree_changes && !refresh_only;
+ require_pathspec = !take_worktree_changes;
newfd = hold_locked_index(&lock_file, 1);
- if (take_worktree_changes) {
- const char **pathspec;
- if (read_cache() < 0)
- die("index file corrupt");
- pathspec = get_pathspec(prefix, argv);
- add_files_to_cache(verbose, prefix, pathspec);
- goto finish;
- }
+ flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
+ (show_only ? ADD_CACHE_PRETEND : 0) |
+ (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0));
- if (argc == 0) {
+ if (require_pathspec && argc == 0) {
fprintf(stderr, "Nothing specified, nothing added.\n");
fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
return 0;
}
pathspec = get_pathspec(prefix, argv);
- if (refresh_only) {
- refresh(verbose, pathspec);
- goto finish;
- }
-
- fill_directory(&dir, pathspec, ignored_too);
-
- if (show_only) {
- const char *sep = "", *eof = "";
- for (i = 0; i < dir.nr; i++) {
- printf("%s%s", sep, dir.entries[i]->name);
- sep = " ";
- eof = "\n";
- }
- fputs(eof, stdout);
- return 0;
- }
+ /*
+ * If we are adding new files, we need to scan the working
+ * tree to find the ones that match pathspecs; this needs
+ * to be done before we read the index.
+ */
+ if (add_new_files)
+ fill_directory(&dir, pathspec, ignored_too);
if (read_cache() < 0)
die("index file corrupt");
- if (dir.ignored_nr) {
- fprintf(stderr, ignore_error);
- for (i = 0; i < dir.ignored_nr; i++) {
- fprintf(stderr, "%s\n", dir.ignored[i]->name);
- }
- fprintf(stderr, "Use -f if you really want to add them.\n");
- die("no files added");
+ if (refresh_only) {
+ refresh(verbose, pathspec);
+ goto finish;
}
- for (i = 0; i < dir.nr; i++)
- add_file_to_cache(dir.entries[i]->name, verbose);
+ if (take_worktree_changes || addremove)
+ exit_status |= add_files_to_cache(prefix, pathspec, flags);
+
+ if (add_new_files)
+ exit_status |= add_files(&dir, flags);
finish:
if (active_cache_changed) {
@@ -263,5 +309,5 @@ int cmd_add(int argc, const char **argv, const char *prefix)
die("Unable to write new index file");
}
- return 0;
+ return exit_status;
}
diff --git a/builtin-apply.c b/builtin-apply.c
index 30d86f219..2216a0bf7 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -12,6 +12,7 @@
#include "blob.h"
#include "delta.h"
#include "builtin.h"
+#include "string-list.h"
/*
* --check turns on checking that the working tree matches the
@@ -45,7 +46,7 @@ static const char *fake_ancestor;
static int line_termination = '\n';
static unsigned long p_context = ULONG_MAX;
static const char apply_usage[] =
-"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...";
+"git apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [--reject] [--verbose] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|fix|error|error-all>] <patch>...";
static enum ws_error_action {
nowarn_ws_error,
@@ -57,6 +58,8 @@ static int whitespace_error;
static int squelch_whitespace_errors = 5;
static int applied_after_fixing_ws;
static const char *patch_input_file;
+static const char *root;
+static int root_len;
static void parse_whitespace_option(const char *option)
{
@@ -153,6 +156,7 @@ struct patch {
unsigned int is_binary:1;
unsigned int is_copy:1;
unsigned int is_rename:1;
+ unsigned int recount:1;
struct fragment *fragments;
char *result;
size_t resultsize;
@@ -161,6 +165,91 @@ struct patch {
struct patch *next;
};
+/*
+ * A line in a file, len-bytes long (includes the terminating LF,
+ * except for an incomplete line at the end if the file ends with
+ * one), and its contents hashes to 'hash'.
+ */
+struct line {
+ size_t len;
+ unsigned hash : 24;
+ unsigned flag : 8;
+#define LINE_COMMON 1
+};
+
+/*
+ * This represents a "file", which is an array of "lines".
+ */
+struct image {
+ char *buf;
+ size_t len;
+ size_t nr;
+ size_t alloc;
+ struct line *line_allocated;
+ struct line *line;
+};
+
+/*
+ * Records filenames that have been touched, in order to handle
+ * the case where more than one patches touch the same file.
+ */
+
+static struct string_list fn_table;
+
+static uint32_t hash_line(const char *cp, size_t len)
+{
+ size_t i;
+ uint32_t h;
+ for (i = 0, h = 0; i < len; i++) {
+ if (!isspace(cp[i])) {
+ h = h * 3 + (cp[i] & 0xff);
+ }
+ }
+ return h;
+}
+
+static void add_line_info(struct image *img, const char *bol, size_t len, unsigned flag)
+{
+ ALLOC_GROW(img->line_allocated, img->nr + 1, img->alloc);
+ img->line_allocated[img->nr].len = len;
+ img->line_allocated[img->nr].hash = hash_line(bol, len);
+ img->line_allocated[img->nr].flag = flag;
+ img->nr++;
+}
+
+static void prepare_image(struct image *image, char *buf, size_t len,
+ int prepare_linetable)
+{
+ const char *cp, *ep;
+
+ memset(image, 0, sizeof(*image));
+ image->buf = buf;
+ image->len = len;
+
+ if (!prepare_linetable)
+ return;
+
+ ep = image->buf + image->len;
+ cp = image->buf;
+ while (cp < ep) {
+ const char *next;
+ for (next = cp; next < ep && *next != '\n'; next++)
+ ;
+ if (next < ep)
+ next++;
+ add_line_info(image, cp, next - cp, 0);
+ cp = next;
+ }
+ image->line = image->line_allocated;
+}
+
+static void clear_image(struct image *image)
+{
+ free(image->buf);
+ image->buf = NULL;
+ image->len = 0;
+}
+
static void say_patch_name(FILE *output, const char *pre,
struct patch *patch, const char *post)
{
@@ -253,6 +342,8 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
*/
strbuf_remove(&name, 0, cp - name.buf);
free(def);
+ if (root)
+ strbuf_insert(&name, 0, root, root_len);
return strbuf_detach(&name, NULL);
}
}
@@ -291,6 +382,14 @@ static char *find_name(const char *line, char *def, int p_value, int terminate)
free(def);
}
+ if (root) {
+ char *ret = xmalloc(root_len + len + 1);
+ strcpy(ret, root);
+ memcpy(ret + root_len, start, len);
+ ret[root_len + len] = '\0';
+ return ret;
+ }
+
return xmemdupz(start, len);
}
@@ -340,7 +439,7 @@ static int guess_p_value(const char *nameline)
}
/*
- * Get the name etc info from the --/+++ lines of a traditional patch header
+ * Get the name etc info from the ---/+++ lines of a traditional patch header
*
* FIXME! The end-of-filename heuristics are kind of screwy. For existing
* files, we can happily check the index for a match, but for creating a
@@ -804,6 +903,56 @@ static int parse_range(const char *line, int len, int offset, const char *expect
return offset + ex;
}
+static void recount_diff(char *line, int size, struct fragment *fragment)
+{
+ int oldlines = 0, newlines = 0, ret = 0;
+
+ if (size < 1) {
+ warning("recount: ignore empty hunk");
+ return;
+ }
+
+ for (;;) {
+ int len = linelen(line, size);
+ size -= len;
+ line += len;
+
+ if (size < 1)
+ break;
+
+ switch (*line) {
+ case ' ': case '\n':
+ newlines++;
+ /* fall through */
+ case '-':
+ oldlines++;
+ continue;
+ case '+':
+ newlines++;
+ continue;
+ case '\\':
+ continue;
+ case '@':
+ ret = size < 3 || prefixcmp(line, "@@ ");
+ break;
+ case 'd':
+ ret = size < 5 || prefixcmp(line, "diff ");
+ break;
+ default:
+ ret = -1;
+ break;
+ }
+ if (ret) {
+ warning("recount: unexpected line: %.*s",
+ (int)linelen(line, size), line);
+ return;
+ }
+ break;
+ }
+ fragment->oldlines = oldlines;
+ fragment->newlines = newlines;
+}
+
/*
* Parse a unified diff fragment header of the
* form "@@ -a,b +c,d @@"
@@ -901,8 +1050,7 @@ static int find_header(char *line, unsigned long size, int *hdrsize, struct patc
static void check_whitespace(const char *line, int len, unsigned ws_rule)
{
char *err;
- unsigned result = check_and_emit_line(line + 1, len - 1, ws_rule,
- NULL, NULL, NULL, NULL);
+ unsigned result = ws_check(line + 1, len - 1, ws_rule);
if (!result)
return;
@@ -913,7 +1061,7 @@ static void check_whitespace(const char *line, int len, unsigned ws_rule)
else {
err = whitespace_error_string(result);
fprintf(stderr, "%s:%d: %s.\n%.*s\n",
- patch_input_file, linenr, err, len - 2, line + 1);
+ patch_input_file, linenr, err, len - 2, line + 1);
free(err);
}
}
@@ -935,6 +1083,8 @@ static int parse_fragment(char *line, unsigned long size,
offset = parse_fragment_header(line, len, fragment);
if (offset < 0)
return -1;
+ if (offset > 0 && patch->recount)
+ recount_diff(line + offset, size - offset, fragment);
oldlines = fragment->oldlines;
newlines = fragment->newlines;
leading = 0;
@@ -1065,21 +1215,6 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
if (patch->is_delete < 0 &&
(newlines || (patch->fragments && patch->fragments->next)))
patch->is_delete = 0;
- if (!unidiff_zero || context) {
- /* If the user says the patch is not generated with
- * --unified=0, or if we have seen context lines,
- * then not having oldlines means the patch is creation,
- * and not having newlines means the patch is deletion.
- */
- if (patch->is_new < 0 && !oldlines) {
- patch->is_new = 1;
- patch->old_name = NULL;
- }
- if (patch->is_delete < 0 && !newlines) {
- patch->is_delete = 1;
- patch->new_name = NULL;
- }
- }
if (0 < patch->is_new && oldlines)
die("new file %s depends on old contents", patch->new_name);
@@ -1430,234 +1565,345 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
case S_IFREG:
if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
return error("unable to open or read %s", path);
- convert_to_git(path, buf->buf, buf->len, buf);
+ convert_to_git(path, buf->buf, buf->len, buf, 0);
return 0;
default:
return -1;
}
}
-static int find_offset(const char *buf, unsigned long size,
- const char *fragment, unsigned long fragsize,
- int line, int *lines)
+static void update_pre_post_images(struct image *preimage,
+ struct image *postimage,
+ char *buf,
+ size_t len)
{
- int i;
- unsigned long start, backwards, forwards;
+ int i, ctx;
+ char *new, *old, *fixed;
+ struct image fixed_preimage;
- if (fragsize > size)
- return -1;
+ /*
+ * Update the preimage with whitespace fixes. Note that we
+ * are not losing preimage->buf -- apply_one_fragment() will
+ * free "oldlines".
+ */
+ prepare_image(&fixed_preimage, buf, len, 1);
+ assert(fixed_preimage.nr == preimage->nr);
+ for (i = 0; i < preimage->nr; i++)
+ fixed_preimage.line[i].flag = preimage->line[i].flag;
+ free(preimage->line_allocated);
+ *preimage = fixed_preimage;
- start = 0;
- if (line > 1) {
- unsigned long offset = 0;
- i = line-1;
- while (offset + fragsize <= size) {
- if (buf[offset++] == '\n') {
- start = offset;
- if (!--i)
- break;
- }
+ /*
+ * Adjust the common context lines in postimage, in place.
+ * This is possible because whitespace fixing does not make
+ * the string grow.
+ */
+ new = old = postimage->buf;
+ fixed = preimage->buf;
+ for (i = ctx = 0; i < postimage->nr; i++) {
+ size_t len = postimage->line[i].len;
+ if (!(postimage->line[i].flag & LINE_COMMON)) {
+ /* an added line -- no counterparts in preimage */
+ memmove(new, old, len);
+ old += len;
+ new += len;
+ continue;
}
+
+ /* a common context -- skip it in the original postimage */
+ old += len;
+
+ /* and find the corresponding one in the fixed preimage */
+ while (ctx < preimage->nr &&
+ !(preimage->line[ctx].flag & LINE_COMMON)) {
+ fixed += preimage->line[ctx].len;
+ ctx++;
+ }
+ if (preimage->nr <= ctx)
+ die("oops");
+
+ /* and copy it in, while fixing the line length */
+ len = preimage->line[ctx].len;
+ memcpy(new, fixed, len);
+ new += len;
+ fixed += len;
+ postimage->line[i].len = len;
+ ctx++;
+ }
+
+ /* Fix the length of the whole thing */
+ postimage->len = new - postimage->buf;
+}
+
+static int match_fragment(struct image *img,
+ struct image *preimage,
+ struct image *postimage,
+ unsigned long try,
+ int try_lno,
+ unsigned ws_rule,
+ int match_beginning, int match_end)
+{
+ int i;
+ char *fixed_buf, *buf, *orig, *target;
+
+ if (preimage->nr + try_lno > img->nr)
+ return 0;
+
+ if (match_beginning && try_lno)
+ return 0;
+
+ if (match_end && preimage->nr + try_lno != img->nr)
+ return 0;
+
+ /* Quick hash check */
+ for (i = 0; i < preimage->nr; i++)
+ if (preimage->line[i].hash != img->line[try_lno + i].hash)
+ return 0;
+
+ /*
+ * Do we have an exact match? If we were told to match
+ * at the end, size must be exactly at try+fragsize,
+ * otherwise try+fragsize must be still within the preimage,
+ * and either case, the old piece should match the preimage
+ * exactly.
+ */
+ if ((match_end
+ ? (try + preimage->len == img->len)
+ : (try + preimage->len <= img->len)) &&
+ !memcmp(img->buf + try, preimage->buf, preimage->len))
+ return 1;
+
+ if (ws_error_action != correct_ws_error)
+ return 0;
+
+ /*
+ * The hunk does not apply byte-by-byte, but the hash says
+ * it might with whitespace fuzz.
+ */
+ fixed_buf = xmalloc(preimage->len + 1);
+ buf = fixed_buf;
+ orig = preimage->buf;
+ target = img->buf + try;
+ for (i = 0; i < preimage->nr; i++) {
+ size_t fixlen; /* length after fixing the preimage */
+ size_t oldlen = preimage->line[i].len;
+ size_t tgtlen = img->line[try_lno + i].len;
+ size_t tgtfixlen; /* length after fixing the target line */
+ char tgtfixbuf[1024], *tgtfix;
+ int match;
+
+ /* Try fixing the line in the preimage */
+ fixlen = ws_fix_copy(buf, orig, oldlen, ws_rule, NULL);
+
+ /* Try fixing the line in the target */
+ if (sizeof(tgtfixbuf) < tgtlen)
+ tgtfix = tgtfixbuf;
+ else
+ tgtfix = xmalloc(tgtlen);
+ tgtfixlen = ws_fix_copy(tgtfix, target, tgtlen, ws_rule, NULL);
+
+ /*
+ * If they match, either the preimage was based on
+ * a version before our tree fixed whitespace breakage,
+ * or we are lacking a whitespace-fix patch the tree
+ * the preimage was based on already had (i.e. target
+ * has whitespace breakage, the preimage doesn't).
+ * In either case, we are fixing the whitespace breakages
+ * so we might as well take the fix together with their
+ * real change.
+ */
+ match = (tgtfixlen == fixlen && !memcmp(tgtfix, buf, fixlen));
+
+ if (tgtfix != tgtfixbuf)
+ free(tgtfix);
+ if (!match)
+ goto unmatch_exit;
+
+ orig += oldlen;
+ buf += fixlen;
+ target += tgtlen;
}
- /* Exact line number? */
- if ((start + fragsize <= size) &&
- !memcmp(buf + start, fragment, fragsize))
- return start;
+ /*
+ * Yes, the preimage is based on an older version that still
+ * has whitespace breakages unfixed, and fixing them makes the
+ * hunk match. Update the context lines in the postimage.
+ */
+ update_pre_post_images(preimage, postimage,
+ fixed_buf, buf - fixed_buf);
+ return 1;
+
+ unmatch_exit:
+ free(fixed_buf);
+ return 0;
+}
+
+static int find_pos(struct image *img,
+ struct image *preimage,
+ struct image *postimage,
+ int line,
+ unsigned ws_rule,
+ int match_beginning, int match_end)
+{
+ int i;
+ unsigned long backwards, forwards, try;
+ int backwards_lno, forwards_lno, try_lno;
+
+ if (preimage->nr > img->nr)
+ return -1;
+
+ /*
+ * If match_begining or match_end is specified, there is no
+ * point starting from a wrong line that will never match and
+ * wander around and wait for a match at the specified end.
+ */
+ if (match_beginning)
+ line = 0;
+ else if (match_end)
+ line = img->nr - preimage->nr;
+
+ if (line > img->nr)
+ line = img->nr;
+
+ try = 0;
+ for (i = 0; i < line; i++)
+ try += img->line[i].len;
/*
* There's probably some smart way to do this, but I'll leave
* that to the smart and beautiful people. I'm simple and stupid.
*/
- backwards = start;
- forwards = start;
+ backwards = try;
+ backwards_lno = line;
+ forwards = try;
+ forwards_lno = line;
+ try_lno = line;
+
for (i = 0; ; i++) {
- unsigned long try;
- int n;
+ if (match_fragment(img, preimage, postimage,
+ try, try_lno, ws_rule,
+ match_beginning, match_end))
+ return try_lno;
+
+ again:
+ if (backwards_lno == 0 && forwards_lno == img->nr)
+ break;
- /* "backward" */
if (i & 1) {
- if (!backwards) {
- if (forwards + fragsize > size)
- break;
- continue;
+ if (backwards_lno == 0) {
+ i++;
+ goto again;
}
- do {
- --backwards;
- } while (backwards && buf[backwards-1] != '\n');
+ backwards_lno--;
+ backwards -= img->line[backwards_lno].len;
try = backwards;
+ try_lno = backwards_lno;
} else {
- while (forwards + fragsize <= size) {
- if (buf[forwards++] == '\n')
- break;
+ if (forwards_lno == img->nr) {
+ i++;
+ goto again;
}
+ forwards += img->line[forwards_lno].len;
+ forwards_lno++;
try = forwards;
+ try_lno = forwards_lno;
}
- if (try + fragsize > size)
- continue;
- if (memcmp(buf + try, fragment, fragsize))
- continue;
- n = (i >> 1)+1;
- if (i & 1)
- n = -n;
- *lines = n;
- return try;
}
-
- /*
- * We should start searching forward and backward.
- */
return -1;
}
-static void remove_first_line(const char **rbuf, int *rsize)
+static void remove_first_line(struct image *img)
{
- const char *buf = *rbuf;
- int size = *rsize;
- unsigned long offset;
- offset = 0;
- while (offset <= size) {
- if (buf[offset++] == '\n')
- break;
- }
- *rsize = size - offset;
- *rbuf = buf + offset;
+ img->buf += img->line[0].len;
+ img->len -= img->line[0].len;
+ img->line++;
+ img->nr--;
}
-static void remove_last_line(const char **rbuf, int *rsize)
+static void remove_last_line(struct image *img)
{
- const char *buf = *rbuf;
- int size = *rsize;
- unsigned long offset;
- offset = size - 1;
- while (offset > 0) {
- if (buf[--offset] == '\n')
- break;
- }
- *rsize = offset + 1;
+ img->len -= img->line[--img->nr].len;
}
-static int apply_line(char *output, const char *patch, int plen,
- unsigned ws_rule)
+static void update_image(struct image *img,
+ int applied_pos,
+ struct image *preimage,
+ struct image *postimage)
{
/*
- * plen is number of bytes to be copied from patch,
- * starting at patch+1 (patch[0] is '+'). Typically
- * patch[plen] is '\n', unless this is the incomplete
- * last line.
- */
- int i;
- int add_nl_to_tail = 0;
- int fixed = 0;
- int last_tab_in_indent = 0;
- int last_space_in_indent = 0;
- int need_fix_leading_space = 0;
- char *buf;
-
- if ((ws_error_action != correct_ws_error) || !whitespace_error ||
- *patch != '+') {
- memcpy(output, patch + 1, plen);
- return plen;
- }
-
- /*
- * Strip trailing whitespace
- */
- if ((ws_rule & WS_TRAILING_SPACE) &&
- (1 < plen && isspace(patch[plen-1]))) {
- if (patch[plen] == '\n')
- add_nl_to_tail = 1;
- plen--;
- while (0 < plen && isspace(patch[plen]))
- plen--;
- fixed = 1;
- }
-
- /*
- * Check leading whitespaces (indent)
+ * remove the copy of preimage at offset in img
+ * and replace it with postimage
*/
- for (i = 1; i < plen; i++) {
- char ch = patch[i];
- if (ch == '\t') {
- last_tab_in_indent = i;
- if ((ws_rule & WS_SPACE_BEFORE_TAB) &&
- 0 < last_space_in_indent)
- need_fix_leading_space = 1;
- } else if (ch == ' ') {
- last_space_in_indent = i;
- if ((ws_rule & WS_INDENT_WITH_NON_TAB) &&
- 8 <= i - last_tab_in_indent)
- need_fix_leading_space = 1;
- }
- else
- break;
- }
-
- buf = output;
- if (need_fix_leading_space) {
- int consecutive_spaces = 0;
- int last = last_tab_in_indent + 1;
-
- if (ws_rule & WS_INDENT_WITH_NON_TAB) {
- /* have "last" point at one past the indent */
- if (last_tab_in_indent < last_space_in_indent)
- last = last_space_in_indent + 1;
- else
- last = last_tab_in_indent + 1;
- }
+ int i, nr;
+ size_t remove_count, insert_count, applied_at = 0;
+ char *result;
+ for (i = 0; i < applied_pos; i++)
+ applied_at += img->line[i].len;
+
+ remove_count = 0;
+ for (i = 0; i < preimage->nr; i++)
+ remove_count += img->line[applied_pos + i].len;
+ insert_count = postimage->len;
+
+ /* Adjust the contents */
+ result = xmalloc(img->len + insert_count - remove_count + 1);
+ memcpy(result, img->buf, applied_at);
+ memcpy(result + applied_at, postimage->buf, postimage->len);
+ memcpy(result + applied_at + postimage->len,
+ img->buf + (applied_at + remove_count),
+ img->len - (applied_at + remove_count));
+ free(img->buf);
+ img->buf = result;
+ img->len += insert_count - remove_count;
+ result[img->len] = '\0';
+
+ /* Adjust the line table */
+ nr = img->nr + postimage->nr - preimage->nr;
+ if (preimage->nr < postimage->nr) {
/*
- * between patch[1..last], strip the funny spaces,
- * updating them to tab as needed.
+ * NOTE: this knows that we never call remove_first_line()
+ * on anything other than pre/post image.
*/
- for (i = 1; i < last; i++, plen--) {
- char ch = patch[i];
- if (ch != ' ') {
- consecutive_spaces = 0;
- *output++ = ch;
- } else {
- consecutive_spaces++;
- if (consecutive_spaces == 8) {
- *output++ = '\t';
- consecutive_spaces = 0;
- }
- }
- }
- while (0 < consecutive_spaces--)
- *output++ = ' ';
- fixed = 1;
- i = last;
+ img->line = xrealloc(img->line, nr * sizeof(*img->line));
+ img->line_allocated = img->line;
}
- else
- i = 1;
-
- memcpy(output, patch + i, plen);
- if (add_nl_to_tail)
- output[plen++] = '\n';
- if (fixed)
- applied_after_fixing_ws++;
- return output + plen - buf;
+ if (preimage->nr != postimage->nr)
+ memmove(img->line + applied_pos + postimage->nr,
+ img->line + applied_pos + preimage->nr,
+ (img->nr - (applied_pos + preimage->nr)) *
+ sizeof(*img->line));
+ memcpy(img->line + applied_pos,
+ postimage->line,
+ postimage->nr * sizeof(*img->line));
+ img->nr = nr;
}
-static int apply_one_fragment(struct strbuf *buf, struct fragment *frag,
+static int apply_one_fragment(struct image *img, struct fragment *frag,
int inaccurate_eof, unsigned ws_rule)
{
int match_beginning, match_end;
const char *patch = frag->patch;
- int offset, size = frag->size;
- char *old = xmalloc(size);
- char *new = xmalloc(size);
- const char *oldlines, *newlines;
- int oldsize = 0, newsize = 0;
+ int size = frag->size;
+ char *old, *new, *oldlines, *newlines;
int new_blank_lines_at_end = 0;
unsigned long leading, trailing;
- int pos, lines;
+ int pos, applied_pos;
+ struct image preimage;
+ struct image postimage;
+
+ memset(&preimage, 0, sizeof(preimage));
+ memset(&postimage, 0, sizeof(postimage));
+ oldlines = xmalloc(size);
+ newlines = xmalloc(size);
+ old = oldlines;
+ new = newlines;
while (size > 0) {
char first;
int len = linelen(patch, size);
- int plen;
+ int plen, added;
int added_blank_line = 0;
if (!len)
@@ -1670,7 +1916,7 @@ static int apply_one_fragment(struct strbuf *buf, struct fragment *frag,
* followed by "\ No newline", then we also remove the
* last one (which is the newline, of course).
*/
- plen = len-1;
+ plen = len - 1;
if (len < size && patch[len] == '\\')
plen--;
first = *patch;
@@ -1687,25 +1933,40 @@ static int apply_one_fragment(struct strbuf *buf, struct fragment *frag,
if (plen < 0)
/* ... followed by '\No newline'; nothing */
break;
- old[oldsize++] = '\n';
- new[newsize++] = '\n';
+ *old++ = '\n';
+ *new++ = '\n';
+ add_line_info(&preimage, "\n", 1, LINE_COMMON);
+ add_line_info(&postimage, "\n", 1, LINE_COMMON);
break;
case ' ':
case '-':
- memcpy(old + oldsize, patch + 1, plen);
- oldsize += plen;
+ memcpy(old, patch + 1, plen);
+ add_line_info(&preimage, old, plen,
+ (first == ' ' ? LINE_COMMON : 0));
+ old += plen;
if (first == '-')
break;
/* Fall-through for ' ' */
case '+':
- if (first != '+' || !no_add) {
- int added = apply_line(new + newsize, patch,
- plen, ws_rule);
- newsize += added;
- if (first == '+' &&
- added == 1 && new[newsize-1] == '\n')
- added_blank_line = 1;
+ /* --no-add does not add new lines */
+ if (first == '+' && no_add)
+ break;
+
+ if (first != '+' ||
+ !whitespace_error ||
+ ws_error_action != correct_ws_error) {
+ memcpy(new, patch + 1, plen);
+ added = plen;
}
+ else {
+ added = ws_fix_copy(new, patch + 1, plen, ws_rule, &applied_after_fixing_ws);
+ }
+ add_line_info(&postimage, new, added,
+ (first == '+' ? 0 : LINE_COMMON));
+ new += added;
+ if (first == '+' &&
+ added == 1 && new[-1] == '\n')
+ added_blank_line = 1;
break;
case '@': case '\\':
/* Ignore it, we already handled it */
@@ -1722,63 +1983,51 @@ static int apply_one_fragment(struct strbuf *buf, struct fragment *frag,
patch += len;
size -= len;
}
-
if (inaccurate_eof &&
- oldsize > 0 && old[oldsize - 1] == '\n' &&
- newsize > 0 && new[newsize - 1] == '\n') {
- oldsize--;
- newsize--;
+ old > oldlines && old[-1] == '\n' &&
+ new > newlines && new[-1] == '\n') {
+ old--;
+ new--;
}
- oldlines = old;
- newlines = new;
leading = frag->leading;
trailing = frag->trailing;
/*
- * If we don't have any leading/trailing data in the patch,
- * we want it to match at the beginning/end of the file.
+ * A hunk to change lines at the beginning would begin with
+ * @@ -1,L +N,M @@
*
- * But that would break if the patch is generated with
- * --unified=0; sane people wouldn't do that to cause us
- * trouble, but we try to please not so sane ones as well.
+ * And a hunk to add to an empty file would begin with
+ * @@ -0,0 +N,M @@
+ *
+ * In other words, a hunk that is (frag->oldpos <= 1) with or
+ * without leading context must match at the beginning.
*/
- if (unidiff_zero) {
- match_beginning = (!leading && !frag->oldpos);
- match_end = 0;
- }
- else {
- match_beginning = !leading && (frag->oldpos == 1);
- match_end = !trailing;
- }
+ match_beginning = frag->oldpos <= 1;
+
+ /*
+ * A hunk without trailing lines must match at the end.
+ * However, we simply cannot tell if a hunk must match end
+ * from the lack of trailing lines if the patch was generated
+ * with unidiff without any context.
+ */
+ match_end = !unidiff_zero && !trailing;
+
+ pos = frag->newpos ? (frag->newpos - 1) : 0;
+ preimage.buf = oldlines;
+ preimage.len = old - oldlines;
+ postimage.buf = newlines;
+ postimage.len = new - newlines;
+ preimage.line = preimage.line_allocated;
+ postimage.line = postimage.line_allocated;
- lines = 0;
- pos = frag->newpos;
for (;;) {
- offset = find_offset(buf->buf, buf->len,
- oldlines, oldsize, pos, &lines);
- if (match_end && offset + oldsize != buf->len)
- offset = -1;
- if (match_beginning && offset)
- offset = -1;
- if (offset >= 0) {
- if (ws_error_action == correct_ws_error &&
- (buf->len - oldsize - offset == 0)) /* end of file? */
- newsize -= new_blank_lines_at_end;
-
- /* Warn if it was necessary to reduce the number
- * of context lines.
- */
- if ((leading != frag->leading) ||
- (trailing != frag->trailing))
- fprintf(stderr, "Context reduced to (%ld/%ld)"
- " to apply fragment at %d\n",
- leading, trailing, pos + lines);
-
- strbuf_splice(buf, offset, oldsize, newlines, newsize);
- offset = 0;
+
+ applied_pos = find_pos(img, &preimage, &postimage, pos,
+ ws_rule, match_beginning, match_end);
+
+ if (applied_pos >= 0)
break;
- }
/* Am I at my context limits? */
if ((leading <= p_context) && (trailing <= p_context))
@@ -1787,33 +2036,64 @@ static int apply_one_fragment(struct strbuf *buf, struct fragment *frag,
match_beginning = match_end = 0;
continue;
}
+
/*
* Reduce the number of context lines; reduce both
* leading and trailing if they are equal otherwise
* just reduce the larger context.
*/
if (leading >= trailing) {
- remove_first_line(&oldlines, &oldsize);
- remove_first_line(&newlines, &newsize);
+ remove_first_line(&preimage);
+ remove_first_line(&postimage);
pos--;
leading--;
}
if (trailing > leading) {
- remove_last_line(&oldlines, &oldsize);
- remove_last_line(&newlines, &newsize);
+ remove_last_line(&preimage);
+ remove_last_line(&postimage);
trailing--;
}
}
- if (offset && apply_verbosely)
- error("while searching for:\n%.*s", oldsize, oldlines);
+ if (applied_pos >= 0) {
+ if (ws_error_action == correct_ws_error &&
+ new_blank_lines_at_end &&
+ postimage.nr + applied_pos == img->nr) {
+ /*
+ * If the patch application adds blank lines
+ * at the end, and if the patch applies at the
+ * end of the image, remove those added blank
+ * lines.
+ */
+ while (new_blank_lines_at_end--)
+ remove_last_line(&postimage);
+ }
- free(old);
- free(new);
- return offset;
+ /*
+ * Warn if it was necessary to reduce the number
+ * of context lines.
+ */
+ if ((leading != frag->leading) ||
+ (trailing != frag->trailing))
+ fprintf(stderr, "Context reduced to (%ld/%ld)"
+ " to apply fragment at %d\n",
+ leading, trailing, applied_pos+1);
+ update_image(img, applied_pos, &preimage, &postimage);
+ } else {
+ if (apply_verbosely)
+ error("while searching for:\n%.*s",
+ (int)(old - oldlines), oldlines);
+ }
+
+ free(oldlines);
+ free(newlines);
+ free(preimage.line_allocated);
+ free(postimage.line_allocated);
+
+ return (applied_pos < 0);
}
-static int apply_binary_fragment(struct strbuf *buf, struct patch *patch)
+static int apply_binary_fragment(struct image *img, struct patch *patch)
{
struct fragment *fragment = patch->fragments;
unsigned long len;
@@ -1830,22 +2110,26 @@ static int apply_binary_fragment(struct strbuf *buf, struct patch *patch)
}
switch (fragment->binary_patch_method) {
case BINARY_DELTA_DEFLATED:
- dst = patch_delta(buf->buf, buf->len, fragment->patch,
+ dst = patch_delta(img->buf, img->len, fragment->patch,
fragment->size, &len);
if (!dst)
return -1;
- /* XXX patch_delta NUL-terminates */
- strbuf_attach(buf, dst, len, len + 1);
+ clear_image(img);
+ img->buf = dst;
+ img->len = len;
return 0;
case BINARY_LITERAL_DEFLATED:
- strbuf_reset(buf);
- strbuf_add(buf, fragment->patch, fragment->size);
+ clear_image(img);
+ img->len = fragment->size;
+ img->buf = xmalloc(img->len+1);
+ memcpy(img->buf, fragment->patch, img->len);
+ img->buf[img->len] = '\0';
return 0;
}
return -1;
}
-static int apply_binary(struct strbuf *buf, struct patch *patch)
+static int apply_binary(struct image *img, struct patch *patch)
{
const char *name = patch->old_name ? patch->old_name : patch->new_name;
unsigned char sha1[20];
@@ -1866,7 +2150,7 @@ static int apply_binary(struct strbuf *buf, struct patch *patch)
* See if the old one matches what the patch
* applies to.
*/
- hash_sha1_file(buf->buf, buf->len, blob_type, sha1);
+ hash_sha1_file(img->buf, img->len, blob_type, sha1);
if (strcmp(sha1_to_hex(sha1), patch->old_sha1_prefix))
return error("the patch applies to '%s' (%s), "
"which does not match the "
@@ -1875,14 +2159,14 @@ static int apply_binary(struct strbuf *buf, struct patch *patch)
}
else {
/* Otherwise, the old one must be empty. */
- if (buf->len)
+ if (img->len)
return error("the patch applies to an empty "
"'%s' but it is not empty", name);
}
get_sha1_hex(patch->new_sha1_prefix, sha1);
if (is_null_sha1(sha1)) {
- strbuf_release(buf);
+ clear_image(img);
return 0; /* deletion patch */
}
@@ -1897,20 +2181,21 @@ static int apply_binary(struct strbuf *buf, struct patch *patch)
return error("the necessary postimage %s for "
"'%s' cannot be read",
patch->new_sha1_prefix, name);
- /* XXX read_sha1_file NUL-terminates */
- strbuf_attach(buf, result, size, size + 1);
+ clear_image(img);
+ img->buf = result;
+ img->len = size;
} else {
/*
* We have verified buf matches the preimage;
* apply the patch data to it, which is stored
* in the patch->fragments->{patch,size}.
*/
- if (apply_binary_fragment(buf, patch))
+ if (apply_binary_fragment(img, patch))
return error("binary patch does not apply to '%s'",
name);
/* verify that the result matches */
- hash_sha1_file(buf->buf, buf->len, blob_type, sha1);
+ hash_sha1_file(img->buf, img->len, blob_type, sha1);
if (strcmp(sha1_to_hex(sha1), patch->new_sha1_prefix))
return error("binary patch to '%s' creates incorrect result (expecting %s, got %s)",
name, patch->new_sha1_prefix, sha1_to_hex(sha1));
@@ -1919,7 +2204,7 @@ static int apply_binary(struct strbuf *buf, struct patch *patch)
return 0;
}
-static int apply_fragments(struct strbuf *buf, struct patch *patch)
+static int apply_fragments(struct image *img, struct patch *patch)
{
struct fragment *frag = patch->fragments;
const char *name = patch->old_name ? patch->old_name : patch->new_name;
@@ -1927,10 +2212,10 @@ static int apply_fragments(struct strbuf *buf, struct patch *patch)
unsigned inaccurate_eof = patch->inaccurate_eof;
if (patch->is_binary)
- return apply_binary(buf, patch);
+ return apply_binary(img, patch);
while (frag) {
- if (apply_one_fragment(buf, frag, inaccurate_eof, ws_rule)) {
+ if (apply_one_fragment(img, frag, inaccurate_eof, ws_rule)) {
error("patch failed: %s:%ld", name, frag->oldpos);
if (!apply_with_reject)
return -1;
@@ -1963,12 +2248,63 @@ static int read_file_or_gitlink(struct cache_entry *ce, struct strbuf *buf)
return 0;
}
+static struct patch *in_fn_table(const char *name)
+{
+ struct string_list_item *item;
+
+ if (name == NULL)
+ return NULL;
+
+ item = string_list_lookup(name, &fn_table);
+ if (item != NULL)
+ return (struct patch *)item->util;
+
+ return NULL;
+}
+
+static void add_to_fn_table(struct patch *patch)
+{
+ struct string_list_item *item;
+
+ /*
+ * Always add new_name unless patch is a deletion
+ * This should cover the cases for normal diffs,
+ * file creations and copies
+ */
+ if (patch->new_name != NULL) {
+ item = string_list_insert(patch->new_name, &fn_table);
+ item->util = patch;
+ }
+
+ /*
+ * store a failure on rename/deletion cases because
+ * later chunks shouldn't patch old names
+ */
+ if ((patch->new_name == NULL) || (patch->is_rename)) {
+ item = string_list_insert(patch->old_name, &fn_table);
+ item->util = (struct patch *) -1;
+ }
+}
+
static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
{
struct strbuf buf;
+ struct image image;
+ size_t len;
+ char *img;
+ struct patch *tpatch;
strbuf_init(&buf, 0);
- if (cached) {
+
+ if (!(patch->is_copy || patch->is_rename) &&
+ ((tpatch = in_fn_table(patch->old_name)) != NULL)) {
+ if (tpatch == (struct patch *) -1) {
+ return error("patch %s has been renamed/deleted",
+ patch->old_name);
+ }
+ /* We have a patched copy in memory use that */
+ strbuf_add(&buf, tpatch->result, tpatch->resultsize);
+ } else if (cached) {
if (read_file_or_gitlink(ce, &buf))
return error("read of %s failed", patch->old_name);
} else if (patch->old_name) {
@@ -1988,9 +2324,15 @@ static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
}
}
- if (apply_fragments(&buf, patch) < 0)
+ img = strbuf_detach(&buf, &len);
+ prepare_image(&image, img, len, !patch->is_binary);
+
+ if (apply_fragments(&image, patch) < 0)
return -1; /* note with --reject this succeeds. */
- patch->result = strbuf_detach(&buf, &patch->resultsize);
+ patch->result = image.buf;
+ patch->resultsize = image.len;
+ add_to_fn_table(patch);
+ free(image.line_allocated);
if (0 < patch->is_delete && patch->resultsize)
return error("removal patch leaves file contents");
@@ -2011,7 +2353,7 @@ static int check_to_create_blob(const char *new_name, int ok_if_exists)
* In such a case, path "new_name" does not exist as
* far as git is concerned.
*/
- if (has_symlink_leading_path(new_name, NULL))
+ if (has_symlink_leading_path(strlen(new_name), new_name))
return 0;
return error("%s: already exists in working directory", new_name);
@@ -2031,16 +2373,12 @@ static int verify_index_match(struct cache_entry *ce, struct stat *st)
return ce_match_stat(ce, st, CE_MATCH_IGNORE_VALID);
}
-static int check_patch(struct patch *patch, struct patch *prev_patch)
+static int check_preimage(struct patch *patch, struct cache_entry **ce, struct stat *st)
{
- struct stat st;
const char *old_name = patch->old_name;
- const char *new_name = patch->new_name;
- const char *name = old_name ? old_name : new_name;
- struct cache_entry *ce = NULL;
- int ok_if_exists;
-
- patch->rejected = 1; /* we will drop this after we succeed */
+ struct patch *tpatch = NULL;
+ int stat_ret = 0;
+ unsigned st_mode = 0;
/*
* Make sure that we do not have local modifications from the
@@ -2048,60 +2386,93 @@ static int check_patch(struct patch *patch, struct patch *prev_patch)
* we have the preimage file to be patched in the work tree,
* unless --cached, which tells git to apply only in the index.
*/
- if (old_name) {
- int stat_ret = 0;
- unsigned st_mode = 0;
-
- if (!cached)
- stat_ret = lstat(old_name, &st);
- if (check_index) {
- int pos = cache_name_pos(old_name, strlen(old_name));
- if (pos < 0)
- return error("%s: does not exist in index",
- old_name);
- ce = active_cache[pos];
- if (stat_ret < 0) {
- struct checkout costate;
- if (errno != ENOENT)
- return error("%s: %s", old_name,
- strerror(errno));
- /* checkout */
- costate.base_dir = "";
- costate.base_dir_len = 0;
- costate.force = 0;
- costate.quiet = 0;
- costate.not_new = 0;
- costate.refresh_cache = 1;
- if (checkout_entry(ce,
- &costate,
- NULL) ||
- lstat(old_name, &st))
- return -1;
- }
- if (!cached && verify_index_match(ce, &st))
- return error("%s: does not match index",
- old_name);
- if (cached)
- st_mode = ce->ce_mode;
- } else if (stat_ret < 0)
- return error("%s: %s", old_name, strerror(errno));
+ if (!old_name)
+ return 0;
+
+ assert(patch->is_new <= 0);
- if (!cached)
- st_mode = ce_mode_from_stat(ce, st.st_mode);
+ if (!(patch->is_copy || patch->is_rename) &&
+ (tpatch = in_fn_table(old_name)) != NULL) {
+ if (tpatch == (struct patch *) -1) {
+ return error("%s: has been deleted/renamed", old_name);
+ }
+ st_mode = tpatch->new_mode;
+ } else if (!cached) {
+ stat_ret = lstat(old_name, st);
+ if (stat_ret && errno != ENOENT)
+ return error("%s: %s", old_name, strerror(errno));
+ }
+ if (check_index && !tpatch) {
+ int pos = cache_name_pos(old_name, strlen(old_name));
+ if (pos < 0) {
+ if (patch->is_new < 0)
+ goto is_new;
+ return error("%s: does not exist in index", old_name);
+ }
+ *ce = active_cache[pos];
+ if (stat_ret < 0) {
+ struct checkout costate;
+ /* checkout */
+ costate.base_dir = "";
+ costate.base_dir_len = 0;
+ costate.force = 0;
+ costate.quiet = 0;
+ costate.not_new = 0;
+ costate.refresh_cache = 1;
+ if (checkout_entry(*ce, &costate, NULL) ||
+ lstat(old_name, st))
+ return -1;
+ }
+ if (!cached && verify_index_match(*ce, st))
+ return error("%s: does not match index", old_name);
+ if (cached)
+ st_mode = (*ce)->ce_mode;
+ } else if (stat_ret < 0) {
if (patch->is_new < 0)
- patch->is_new = 0;
- if (!patch->old_mode)
- patch->old_mode = st_mode;
- if ((st_mode ^ patch->old_mode) & S_IFMT)
- return error("%s: wrong type", old_name);
- if (st_mode != patch->old_mode)
- fprintf(stderr, "warning: %s has type %o, expected %o\n",
- old_name, st_mode, patch->old_mode);
- }
-
- if (new_name && prev_patch && 0 < prev_patch->is_delete &&
- !strcmp(prev_patch->old_name, new_name))
+ goto is_new;
+ return error("%s: %s", old_name, strerror(errno));
+ }
+
+ if (!cached)
+ st_mode = ce_mode_from_stat(*ce, st->st_mode);
+
+ if (patch->is_new < 0)
+ patch->is_new = 0;
+ if (!patch->old_mode)
+ patch->old_mode = st_mode;
+ if ((st_mode ^ patch->old_mode) & S_IFMT)
+ return error("%s: wrong type", old_name);
+ if (st_mode != patch->old_mode)
+ fprintf(stderr, "warning: %s has type %o, expected %o\n",
+ old_name, st_mode, patch->old_mode);
+ return 0;
+
+ is_new:
+ patch->is_new = 1;
+ patch->is_delete = 0;
+ patch->old_name = NULL;
+ return 0;
+}
+
+static int check_patch(struct patch *patch)
+{
+ struct stat st;
+ const char *old_name = patch->old_name;
+ const char *new_name = patch->new_name;
+ const char *name = old_name ? old_name : new_name;
+ struct cache_entry *ce = NULL;
+ int ok_if_exists;
+ int status;
+
+ patch->rejected = 1; /* we will drop this after we succeed */
+
+ status = check_preimage(patch, &ce, &st);
+ if (status)
+ return status;
+ old_name = patch->old_name;
+
+ if (in_fn_table(new_name) == (struct patch *) -1)
/*
* A type-change diff is always split into a patch to
* delete old, immediately followed by a patch to
@@ -2151,15 +2522,14 @@ static int check_patch(struct patch *patch, struct patch *prev_patch)
static int check_patch_list(struct patch *patch)
{
- struct patch *prev_patch = NULL;
int err = 0;
- for (prev_patch = NULL; patch ; patch = patch->next) {
+ while (patch) {
if (apply_verbosely)
say_patch_name(stderr,
"Checking patch ", patch, "...\n");
- err |= check_patch(patch, prev_patch);
- prev_patch = patch;
+ err |= check_patch(patch);
+ patch = patch->next;
}
return err;
}
@@ -2670,13 +3040,18 @@ static void prefix_patches(struct patch *p)
}
}
-static int apply_patch(int fd, const char *filename, int inaccurate_eof)
+#define INACCURATE_EOF (1<<0)
+#define RECOUNT (1<<1)
+
+static int apply_patch(int fd, const char *filename, int options)
{
size_t offset;
struct strbuf buf;
struct patch *list = NULL, **listp = &list;
int skipped_patch = 0;
+ /* FIXME - memory leak when using multiple patch files as inputs */
+ memset(&fn_table, 0, sizeof(struct string_list));
strbuf_init(&buf, 0);
patch_input_file = filename;
read_patch_file(&buf, fd);
@@ -2686,7 +3061,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
int nr;
patch = xcalloc(1, sizeof(*patch));
- patch->inaccurate_eof = inaccurate_eof;
+ patch->inaccurate_eof = !!(options & INACCURATE_EOF);
+ patch->recount = !!(options & RECOUNT);
nr = parse_chunk(buf.buf + offset, buf.len - offset, patch);
if (nr < 0)
break;
@@ -2743,13 +3119,11 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
return 0;
}
-static int git_apply_config(const char *var, const char *value)
+static int git_apply_config(const char *var, const char *value, void *cb)
{
- if (!strcmp(var, "apply.whitespace")) {
- apply_default_whitespace = xstrdup(value);
- return 0;
- }
- return git_default_config(var, value);
+ if (!strcmp(var, "apply.whitespace"))
+ return git_config_string(&apply_default_whitespace, var, value);
+ return git_default_config(var, value, cb);
}
@@ -2757,15 +3131,15 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
{
int i;
int read_stdin = 1;
- int inaccurate_eof = 0;
+ int options = 0;
int errs = 0;
- int is_not_gitdir = 0;
+ int is_not_gitdir;
const char *whitespace_option = NULL;
prefix = setup_git_directory_gently(&is_not_gitdir);
prefix_length = prefix ? strlen(prefix) : 0;
- git_config(git_apply_config);
+ git_config(git_apply_config, NULL);
if (apply_default_whitespace)
parse_whitespace_option(apply_default_whitespace);
@@ -2775,7 +3149,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
int fd;
if (!strcmp(arg, "-")) {
- errs |= apply_patch(0, "<stdin>", inaccurate_eof);
+ errs |= apply_patch(0, "<stdin>", options);
read_stdin = 0;
continue;
}
@@ -2875,7 +3249,23 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
continue;
}
if (!strcmp(arg, "--inaccurate-eof")) {
- inaccurate_eof = 1;
+ options |= INACCURATE_EOF;
+ continue;
+ }
+ if (!strcmp(arg, "--recount")) {
+ options |= RECOUNT;
+ continue;
+ }
+ if (!prefixcmp(arg, "--directory=")) {
+ arg += strlen("--directory=");
+ root_len = strlen(arg);
+ if (root_len && arg[root_len - 1] != '/') {
+ char *new_root;
+ root = new_root = xmalloc(root_len + 2);
+ strcpy(new_root, arg);
+ strcpy(new_root + root_len++, "/");
+ } else
+ root = arg;
continue;
}
if (0 < prefix_length)
@@ -2883,15 +3273,15 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
fd = open(arg, O_RDONLY);
if (fd < 0)
- usage(apply_usage);
+ die("can't open patch '%s': %s", arg, strerror(errno));
read_stdin = 0;
set_default_whitespace_mode(whitespace_option);
- errs |= apply_patch(fd, arg, inaccurate_eof);
+ errs |= apply_patch(fd, arg, options);
close(fd);
}
set_default_whitespace_mode(whitespace_option);
if (read_stdin)
- errs |= apply_patch(0, "<stdin>", inaccurate_eof);
+ errs |= apply_patch(0, "<stdin>", options);
if (whitespace_error) {
if (squelch_whitespace_errors &&
squelch_whitespace_errors < whitespace_error) {
diff --git a/builtin-archive.c b/builtin-archive.c
index c2e0c1ea5..22445acbf 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -5,25 +5,8 @@
#include "cache.h"
#include "builtin.h"
#include "archive.h"
-#include "commit.h"
-#include "tree-walk.h"
-#include "exec_cmd.h"
#include "pkt-line.h"
#include "sideband.h"
-#include "attr.h"
-
-static const char archive_usage[] = \
-"git-archive --format=<fmt> [--prefix=<prefix>/] [--verbose] [<extra>] <tree-ish> [path...]";
-
-static struct archiver_desc
-{
- const char *name;
- write_archive_fn_t write_archive;
- parse_extra_args_fn_t parse_extra;
-} archivers[] = {
- { "tar", write_tar_archive, NULL },
- { "zip", write_zip_archive, parse_extra_zip_args },
-};
static int run_remote_archiver(const char *remote, int argc,
const char **argv)
@@ -32,7 +15,7 @@ static int run_remote_archiver(const char *remote, int argc,
int fd[2], i, len, rv;
struct child_process *conn;
const char *exec = "git-upload-archive";
- int exec_at = 0;
+ int exec_at = 0, exec_value_at = 0;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -41,7 +24,14 @@ static int run_remote_archiver(const char *remote, int argc,
die("multiple --exec specified");
exec = arg + 7;
exec_at = i;
- break;
+ } else if (!strcmp(arg, "--exec")) {
+ if (exec_at)
+ die("multiple --exec specified");
+ if (i + 1 >= argc)
+ die("option --exec requires a value");
+ exec = argv[i + 1];
+ exec_at = i;
+ exec_value_at = ++i;
}
}
@@ -49,7 +39,7 @@ static int run_remote_archiver(const char *remote, int argc,
conn = git_connect(fd, url, exec, 0);
for (i = 1; i < argc; i++) {
- if (i == exec_at)
+ if (i == exec_at || i == exec_value_at)
continue;
packet_write(fd[1], "argument %s\n", argv[i]);
}
@@ -79,132 +69,6 @@ static int run_remote_archiver(const char *remote, int argc,
return !!rv;
}
-static int init_archiver(const char *name, struct archiver *ar)
-{
- int rv = -1, i;
-
- for (i = 0; i < ARRAY_SIZE(archivers); i++) {
- if (!strcmp(name, archivers[i].name)) {
- memset(ar, 0, sizeof(*ar));
- ar->name = archivers[i].name;
- ar->write_archive = archivers[i].write_archive;
- ar->parse_extra = archivers[i].parse_extra;
- rv = 0;
- break;
- }
- }
- return rv;
-}
-
-void parse_pathspec_arg(const char **pathspec, struct archiver_args *ar_args)
-{
- ar_args->pathspec = get_pathspec(ar_args->base, pathspec);
-}
-
-void parse_treeish_arg(const char **argv, struct archiver_args *ar_args,
- const char *prefix)
-{
- const char *name = argv[0];
- const unsigned char *commit_sha1;
- time_t archive_time;
- struct tree *tree;
- const struct commit *commit;
- unsigned char sha1[20];
-
- if (get_sha1(name, sha1))
- die("Not a valid object name");
-
- commit = lookup_commit_reference_gently(sha1, 1);
- if (commit) {
- commit_sha1 = commit->object.sha1;
- archive_time = commit->date;
- } else {
- commit_sha1 = NULL;
- archive_time = time(NULL);
- }
-
- tree = parse_tree_indirect(sha1);
- if (tree == NULL)
- die("not a tree object");
-
- if (prefix) {
- unsigned char tree_sha1[20];
- unsigned int mode;
- int err;
-
- err = get_tree_entry(tree->object.sha1, prefix,
- tree_sha1, &mode);
- if (err || !S_ISDIR(mode))
- die("current working directory is untracked");
-
- tree = parse_tree_indirect(tree_sha1);
- }
- ar_args->tree = tree;
- ar_args->commit_sha1 = commit_sha1;
- ar_args->commit = commit;
- ar_args->time = archive_time;
-}
-
-int parse_archive_args(int argc, const char **argv, struct archiver *ar)
-{
- const char *extra_argv[MAX_EXTRA_ARGS];
- int extra_argc = 0;
- const char *format = "tar";
- const char *base = "";
- int verbose = 0;
- int i;
-
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
-
- if (!strcmp(arg, "--list") || !strcmp(arg, "-l")) {
- for (i = 0; i < ARRAY_SIZE(archivers); i++)
- printf("%s\n", archivers[i].name);
- exit(0);
- }
- if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
- verbose = 1;
- continue;
- }
- if (!prefixcmp(arg, "--format=")) {
- format = arg + 9;
- continue;
- }
- if (!prefixcmp(arg, "--prefix=")) {
- base = arg + 9;
- continue;
- }
- if (!strcmp(arg, "--")) {
- i++;
- break;
- }
- if (arg[0] == '-') {
- if (extra_argc > MAX_EXTRA_ARGS - 1)
- die("Too many extra options");
- extra_argv[extra_argc++] = arg;
- continue;
- }
- break;
- }
-
- /* We need at least one parameter -- tree-ish */
- if (argc - 1 < i)
- usage(archive_usage);
- if (init_archiver(format, ar) < 0)
- die("Unknown archive format '%s'", format);
-
- if (extra_argc) {
- if (!ar->parse_extra)
- die("'%s' format does not handle %s",
- ar->name, extra_argv[0]);
- ar->args.extra = ar->parse_extra(extra_argc, extra_argv);
- }
- ar->args.verbose = verbose;
- ar->args.base = base;
-
- return i;
-}
-
static const char *extract_remote_arg(int *ac, const char **av)
{
int ix, iy, cnt = *ac;
@@ -221,6 +85,13 @@ static const char *extract_remote_arg(int *ac, const char **av)
die("Multiple --remote specified");
remote = arg + 9;
continue;
+ } else if (!strcmp(arg, "--remote")) {
+ if (remote)
+ die("Multiple --remote specified");
+ if (++ix >= cnt)
+ die("option --remote requires a value");
+ remote = av[ix];
+ continue;
}
if (arg[0] != '-')
no_more_options = 1;
@@ -238,8 +109,6 @@ static const char *extract_remote_arg(int *ac, const char **av)
int cmd_archive(int argc, const char **argv, const char *prefix)
{
- struct archiver ar;
- int tree_idx;
const char *remote = NULL;
remote = extract_remote_arg(&argc, argv);
@@ -248,14 +117,5 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
- memset(&ar, 0, sizeof(ar));
- tree_idx = parse_archive_args(argc, argv, &ar);
- if (prefix == NULL)
- prefix = setup_git_directory();
-
- argv += tree_idx;
- parse_treeish_arg(argv, &ar.args, prefix);
- parse_pathspec_arg(argv + 1, &ar.args);
-
- return ar.write_archive(&ar.args);
+ return write_archive(argc, argv, prefix, 1);
}
diff --git a/builtin-blame.c b/builtin-blame.c
index c7e68874e..4ea343189 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -16,26 +16,18 @@
#include "quote.h"
#include "xdiff-interface.h"
#include "cache-tree.h"
-#include "path-list.h"
+#include "string-list.h"
#include "mailmap.h"
+#include "parse-options.h"
-static char blame_usage[] =
-"git-blame [-c] [-b] [-l] [--root] [-t] [-f] [-n] [-s] [-p] [-w] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
-" -c Use the same output mode as git-annotate (Default: off)\n"
-" -b Show blank SHA-1 for boundary commits (Default: off)\n"
-" -l Show long commit SHA1 (Default: off)\n"
-" --root Do not treat root commits as boundaries (Default: off)\n"
-" -t Show raw timestamp (Default: off)\n"
-" -f, --show-name Show original filename (Default: auto)\n"
-" -n, --show-number Show original linenumber (Default: off)\n"
-" -s Suppress author name and timestamp (Default: off)\n"
-" -p, --porcelain Show in a format designed for machine consumption\n"
-" -w Ignore whitespace differences\n"
-" -L n,m Process only line range n,m, counting from 1\n"
-" -M, -C Find line movements within and across files\n"
-" --incremental Show blame entries as we find them, incrementally\n"
-" --contents file Use <file>'s contents as the final image\n"
-" -S revs-file Use revisions from revs-file instead of calling git-rev-list\n";
+static char blame_usage[] = "git blame [options] [rev-opts] [rev] [--] file";
+
+static const char *blame_opt_usage[] = {
+ blame_usage,
+ "",
+ "[rev-opts] are documented in git-rev-list(1)",
+ NULL
+};
static int longest_file;
static int longest_author;
@@ -43,11 +35,12 @@ static int max_orig_digits;
static int max_digits;
static int max_score_digits;
static int show_root;
+static int reverse;
static int blank_boundary;
static int incremental;
static int cmd_is_annotate;
static int xdl_opts = XDF_NEED_MINIMAL;
-static struct path_list mailmap;
+static struct string_list mailmap;
#ifndef DEBUG
#define DEBUG 0
@@ -91,7 +84,7 @@ struct origin {
* Given an origin, prepare mmfile_t structure to be used by the
* diff machinery
*/
-static char *fill_origin_blob(struct origin *o, mmfile_t *file)
+static void fill_origin_blob(struct origin *o, mmfile_t *file)
{
if (!o->file.ptr) {
enum object_type type;
@@ -106,7 +99,6 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
}
else
*file = o->file;
- return file->ptr;
}
/*
@@ -123,8 +115,7 @@ static inline struct origin *origin_incref(struct origin *o)
static void origin_decref(struct origin *o)
{
if (o && --o->refcnt <= 0) {
- if (o->file.ptr)
- free(o->file.ptr);
+ free(o->file.ptr);
free(o);
}
}
@@ -162,6 +153,10 @@ struct blame_entry {
*/
char guilty;
+ /* true if the entry has been scanned for copies in the current parent
+ */
+ char scanned;
+
/* the line number of the first line of this group in the
* suspect's file; internally all line numbers are 0 based.
*/
@@ -179,7 +174,7 @@ struct blame_entry {
struct scoreboard {
/* the final commit (i.e. where we started digging from) */
struct commit *final;
-
+ struct rev_info *revs;
const char *path;
/*
@@ -1017,7 +1012,8 @@ static int find_move_in_parent(struct scoreboard *sb,
while (made_progress) {
made_progress = 0;
for (e = sb->ent; e; e = e->next) {
- if (e->guilty || !same_suspect(e->suspect, target))
+ if (e->guilty || !same_suspect(e->suspect, target) ||
+ ent_score(sb, e) < blame_move_score)
continue;
find_copy_in_blob(sb, e, parent, split, &file_p);
if (split[1].suspect &&
@@ -1042,6 +1038,7 @@ struct blame_list {
*/
static struct blame_list *setup_blame_list(struct scoreboard *sb,
struct origin *target,
+ int min_score,
int *num_ents_p)
{
struct blame_entry *e;
@@ -1049,12 +1046,16 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
struct blame_list *blame_list = NULL;
for (e = sb->ent, num_ents = 0; e; e = e->next)
- if (!e->guilty && same_suspect(e->suspect, target))
+ if (!e->scanned && !e->guilty &&
+ same_suspect(e->suspect, target) &&
+ min_score < ent_score(sb, e))
num_ents++;
if (num_ents) {
blame_list = xcalloc(num_ents, sizeof(struct blame_list));
for (e = sb->ent, i = 0; e; e = e->next)
- if (!e->guilty && same_suspect(e->suspect, target))
+ if (!e->scanned && !e->guilty &&
+ same_suspect(e->suspect, target) &&
+ min_score < ent_score(sb, e))
blame_list[i++].ent = e;
}
*num_ents_p = num_ents;
@@ -1062,6 +1063,16 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
}
/*
+ * Reset the scanned status on all entries.
+ */
+static void reset_scanned_flag(struct scoreboard *sb)
+{
+ struct blame_entry *e;
+ for (e = sb->ent; e; e = e->next)
+ e->scanned = 0;
+}
+
+/*
* For lines target is suspected for, see if we can find code movement
* across file boundary from the parent commit. porigin is the path
* in the parent we already tried.
@@ -1079,7 +1090,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
struct blame_list *blame_list;
int num_ents;
- blame_list = setup_blame_list(sb, target, &num_ents);
+ blame_list = setup_blame_list(sb, target, blame_copy_score, &num_ents);
if (!blame_list)
return 1; /* nothing remains for this target */
@@ -1153,18 +1164,21 @@ static int find_copy_in_parent(struct scoreboard *sb,
split_blame(sb, split, blame_list[j].ent);
made_progress = 1;
}
+ else
+ blame_list[j].ent->scanned = 1;
decref_split(split);
}
free(blame_list);
if (!made_progress)
break;
- blame_list = setup_blame_list(sb, target, &num_ents);
+ blame_list = setup_blame_list(sb, target, blame_copy_score, &num_ents);
if (!blame_list) {
retval = 1;
break;
}
}
+ reset_scanned_flag(sb);
diff_flush(&diff_opts);
diff_tree_release_paths(&diff_opts);
return retval;
@@ -1193,18 +1207,48 @@ static void pass_whole_blame(struct scoreboard *sb,
}
}
-#define MAXPARENT 16
+/*
+ * We pass blame from the current commit to its parents. We keep saying
+ * "parent" (and "porigin"), but what we mean is to find scapegoat to
+ * exonerate ourselves.
+ */
+static struct commit_list *first_scapegoat(struct rev_info *revs, struct commit *commit)
+{
+ if (!reverse)
+ return commit->parents;
+ return lookup_decoration(&revs->children, &commit->object);
+}
+
+static int num_scapegoats(struct rev_info *revs, struct commit *commit)
+{
+ int cnt;
+ struct commit_list *l = first_scapegoat(revs, commit);
+ for (cnt = 0; l; l = l->next)
+ cnt++;
+ return cnt;
+}
+
+#define MAXSG 16
static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
{
- int i, pass;
+ struct rev_info *revs = sb->revs;
+ int i, pass, num_sg;
struct commit *commit = origin->commit;
- struct commit_list *parent;
- struct origin *parent_origin[MAXPARENT], *porigin;
-
- memset(parent_origin, 0, sizeof(parent_origin));
+ struct commit_list *sg;
+ struct origin *sg_buf[MAXSG];
+ struct origin *porigin, **sg_origin = sg_buf;
+
+ num_sg = num_scapegoats(revs, commit);
+ if (!num_sg)
+ goto finish;
+ else if (num_sg < ARRAY_SIZE(sg_buf))
+ memset(sg_buf, 0, sizeof(sg_buf));
+ else
+ sg_origin = xcalloc(num_sg, sizeof(*sg_origin));
- /* The first pass looks for unrenamed path to optimize for
+ /*
+ * The first pass looks for unrenamed path to optimize for
* common cases, then we look for renames in the second pass.
*/
for (pass = 0; pass < 2; pass++) {
@@ -1212,13 +1256,13 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
struct commit *, struct origin *);
find = pass ? find_rename : find_origin;
- for (i = 0, parent = commit->parents;
- i < MAXPARENT && parent;
- parent = parent->next, i++) {
- struct commit *p = parent->item;
+ for (i = 0, sg = first_scapegoat(revs, commit);
+ i < num_sg && sg;
+ sg = sg->next, i++) {
+ struct commit *p = sg->item;
int j, same;
- if (parent_origin[i])
+ if (sg_origin[i])
continue;
if (parse_commit(p))
continue;
@@ -1231,24 +1275,24 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
goto finish;
}
for (j = same = 0; j < i; j++)
- if (parent_origin[j] &&
- !hashcmp(parent_origin[j]->blob_sha1,
+ if (sg_origin[j] &&
+ !hashcmp(sg_origin[j]->blob_sha1,
porigin->blob_sha1)) {
same = 1;
break;
}
if (!same)
- parent_origin[i] = porigin;
+ sg_origin[i] = porigin;
else
origin_decref(porigin);
}
}
num_commits++;
- for (i = 0, parent = commit->parents;
- i < MAXPARENT && parent;
- parent = parent->next, i++) {
- struct origin *porigin = parent_origin[i];
+ for (i = 0, sg = first_scapegoat(revs, commit);
+ i < num_sg && sg;
+ sg = sg->next, i++) {
+ struct origin *porigin = sg_origin[i];
if (!porigin)
continue;
if (pass_blame_to_parent(sb, origin, porigin))
@@ -1259,10 +1303,10 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
* Optionally find moves in parents' files.
*/
if (opt & PICKAXE_BLAME_MOVE)
- for (i = 0, parent = commit->parents;
- i < MAXPARENT && parent;
- parent = parent->next, i++) {
- struct origin *porigin = parent_origin[i];
+ for (i = 0, sg = first_scapegoat(revs, commit);
+ i < num_sg && sg;
+ sg = sg->next, i++) {
+ struct origin *porigin = sg_origin[i];
if (!porigin)
continue;
if (find_move_in_parent(sb, origin, porigin))
@@ -1273,23 +1317,25 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
* Optionally find copies from parents' files.
*/
if (opt & PICKAXE_BLAME_COPY)
- for (i = 0, parent = commit->parents;
- i < MAXPARENT && parent;
- parent = parent->next, i++) {
- struct origin *porigin = parent_origin[i];
- if (find_copy_in_parent(sb, origin, parent->item,
+ for (i = 0, sg = first_scapegoat(revs, commit);
+ i < num_sg && sg;
+ sg = sg->next, i++) {
+ struct origin *porigin = sg_origin[i];
+ if (find_copy_in_parent(sb, origin, sg->item,
porigin, opt))
goto finish;
}
finish:
- for (i = 0; i < MAXPARENT; i++) {
- if (parent_origin[i]) {
- drop_origin_blob(parent_origin[i]);
- origin_decref(parent_origin[i]);
+ for (i = 0; i < num_sg; i++) {
+ if (sg_origin[i]) {
+ drop_origin_blob(sg_origin[i]);
+ origin_decref(sg_origin[i]);
}
}
drop_origin_blob(origin);
+ if (sg_buf != sg_origin)
+ free(sg_origin);
}
/*
@@ -1488,8 +1534,10 @@ static void found_guilty_entry(struct blame_entry *ent)
* is still unknown, pick one blame_entry, and allow its current
* suspect to pass blames to its parents.
*/
-static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
+static void assign_blame(struct scoreboard *sb, int opt)
{
+ struct rev_info *revs = sb->revs;
+
while (1) {
struct blame_entry *ent;
struct commit *commit;
@@ -1510,8 +1558,9 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
commit = suspect->commit;
if (!commit->object.parsed)
parse_commit(commit);
- if (!(commit->object.flags & UNINTERESTING) &&
- !(revs->max_age != -1 && commit->date < revs->max_age))
+ if (reverse ||
+ (!(commit->object.flags & UNINTERESTING) &&
+ !(revs->max_age != -1 && commit->date < revs->max_age)))
pass_blame(sb, suspect, opt);
else {
commit->object.flags |= UNINTERESTING;
@@ -1877,7 +1926,7 @@ static void sanity_check_refcnt(struct scoreboard *sb)
* Used for the command line parsing; check if the path exists
* in the working tree.
*/
-static int has_path_in_work_tree(const char *path)
+static int has_string_in_work_tree(const char *path)
{
struct stat st;
return !lstat(path, &st);
@@ -1894,9 +1943,7 @@ static unsigned parse_score(const char *arg)
static const char *add_prefix(const char *prefix, const char *path)
{
- if (!prefix || !prefix[0])
- return path;
- return prefix_path(prefix, strlen(prefix), path);
+ return prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
}
/*
@@ -1996,7 +2043,7 @@ static void prepare_blame_range(struct scoreboard *sb,
usage(blame_usage);
}
-static int git_blame_config(const char *var, const char *value)
+static int git_blame_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "blame.showroot")) {
show_root = git_config_bool(var, value);
@@ -2006,9 +2053,13 @@ static int git_blame_config(const char *var, const char *value)
blank_boundary = git_config_bool(var, value);
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
+/*
+ * Prepare a dummy commit that represents the work tree (or staged) item.
+ * Note that annotating work tree item never works in the reverse.
+ */
static struct commit *fake_working_tree_commit(const char *path, const char *contents_from)
{
struct commit *commit;
@@ -2073,7 +2124,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
if (strbuf_read(&buf, 0, 0) < 0)
die("read error %s from stdin", strerror(errno));
}
- convert_to_git(path, buf.buf, buf.len, &buf);
+ convert_to_git(path, buf.buf, buf.len, &buf, 0);
origin->file.ptr = buf.buf;
origin->file.size = buf.len;
pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1);
@@ -2125,6 +2176,108 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
return commit;
}
+static const char *prepare_final(struct scoreboard *sb)
+{
+ int i;
+ const char *final_commit_name = NULL;
+ struct rev_info *revs = sb->revs;
+
+ /*
+ * There must be one and only one positive commit in the
+ * revs->pending array.
+ */
+ for (i = 0; i < revs->pending.nr; i++) {
+ struct object *obj = revs->pending.objects[i].item;
+ if (obj->flags & UNINTERESTING)
+ continue;
+ while (obj->type == OBJ_TAG)
+ obj = deref_tag(obj, NULL, 0);
+ if (obj->type != OBJ_COMMIT)
+ die("Non commit %s?", revs->pending.objects[i].name);
+ if (sb->final)
+ die("More than one commit to dig from %s and %s?",
+ revs->pending.objects[i].name,
+ final_commit_name);
+ sb->final = (struct commit *) obj;
+ final_commit_name = revs->pending.objects[i].name;
+ }
+ return final_commit_name;
+}
+
+static const char *prepare_initial(struct scoreboard *sb)
+{
+ int i;
+ const char *final_commit_name = NULL;
+ struct rev_info *revs = sb->revs;
+
+ /*
+ * There must be one and only one negative commit, and it must be
+ * the boundary.
+ */
+ for (i = 0; i < revs->pending.nr; i++) {
+ struct object *obj = revs->pending.objects[i].item;
+ if (!(obj->flags & UNINTERESTING))
+ continue;
+ while (obj->type == OBJ_TAG)
+ obj = deref_tag(obj, NULL, 0);
+ if (obj->type != OBJ_COMMIT)
+ die("Non commit %s?", revs->pending.objects[i].name);
+ if (sb->final)
+ die("More than one commit to dig down to %s and %s?",
+ revs->pending.objects[i].name,
+ final_commit_name);
+ sb->final = (struct commit *) obj;
+ final_commit_name = revs->pending.objects[i].name;
+ }
+ if (!final_commit_name)
+ die("No commit to dig down to?");
+ return final_commit_name;
+}
+
+static int blame_copy_callback(const struct option *option, const char *arg, int unset)
+{
+ int *opt = option->value;
+
+ /*
+ * -C enables copy from removed files;
+ * -C -C enables copy from existing files, but only
+ * when blaming a new file;
+ * -C -C -C enables copy from existing files for
+ * everybody
+ */
+ if (*opt & PICKAXE_BLAME_COPY_HARDER)
+ *opt |= PICKAXE_BLAME_COPY_HARDEST;
+ if (*opt & PICKAXE_BLAME_COPY)
+ *opt |= PICKAXE_BLAME_COPY_HARDER;
+ *opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;
+
+ if (arg)
+ blame_copy_score = parse_score(arg);
+ return 0;
+}
+
+static int blame_move_callback(const struct option *option, const char *arg, int unset)
+{
+ int *opt = option->value;
+
+ *opt |= PICKAXE_BLAME_MOVE;
+
+ if (arg)
+ blame_move_score = parse_score(arg);
+ return 0;
+}
+
+static int blame_bottomtop_callback(const struct option *option, const char *arg, int unset)
+{
+ const char **bottomtop = option->value;
+ if (!arg)
+ return -1;
+ if (*bottomtop)
+ die("More than one '-L n,m' option given");
+ *bottomtop = arg;
+ return 0;
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -2132,102 +2285,70 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
struct scoreboard sb;
struct origin *o;
struct blame_entry *ent;
- int i, seen_dashdash, unk, opt;
- long bottom, top, lno;
- int output_option = 0;
- int show_stats = 0;
- const char *revs_file = NULL;
+ long dashdash_pos, bottom, top, lno;
const char *final_commit_name = NULL;
enum object_type type;
- const char *bottomtop = NULL;
- const char *contents_from = NULL;
+
+ static const char *bottomtop = NULL;
+ static int output_option = 0, opt = 0;
+ static int show_stats = 0;
+ static const char *revs_file = NULL;
+ static const char *contents_from = NULL;
+ static const struct option options[] = {
+ OPT_BOOLEAN(0, "incremental", &incremental, "Show blame entries as we find them, incrementally"),
+ OPT_BOOLEAN('b', NULL, &blank_boundary, "Show blank SHA-1 for boundary commits (Default: off)"),
+ OPT_BOOLEAN(0, "root", &show_root, "Do not treat root commits as boundaries (Default: off)"),
+ OPT_BOOLEAN(0, "show-stats", &show_stats, "Show work cost statistics"),
+ OPT_BIT(0, "score-debug", &output_option, "Show output score for blame entries", OUTPUT_SHOW_SCORE),
+ OPT_BIT('f', "show-name", &output_option, "Show original filename (Default: auto)", OUTPUT_SHOW_NAME),
+ OPT_BIT('n', "show-number", &output_option, "Show original linenumber (Default: off)", OUTPUT_SHOW_NUMBER),
+ OPT_BIT('p', "porcelain", &output_option, "Show in a format designed for machine consumption", OUTPUT_PORCELAIN),
+ OPT_BIT('c', NULL, &output_option, "Use the same output mode as git-annotate (Default: off)", OUTPUT_ANNOTATE_COMPAT),
+ OPT_BIT('t', NULL, &output_option, "Show raw timestamp (Default: off)", OUTPUT_RAW_TIMESTAMP),
+ OPT_BIT('l', NULL, &output_option, "Show long commit SHA1 (Default: off)", OUTPUT_LONG_OBJECT_NAME),
+ OPT_BIT('s', NULL, &output_option, "Suppress author name and timestamp (Default: off)", OUTPUT_NO_AUTHOR),
+ OPT_BIT('w', NULL, &xdl_opts, "Ignore whitespace differences", XDF_IGNORE_WHITESPACE),
+ OPT_STRING('S', NULL, &revs_file, "file", "Use revisions from <file> instead of calling git-rev-list"),
+ OPT_STRING(0, "contents", &contents_from, "file", "Use <file>'s contents as the final image"),
+ { OPTION_CALLBACK, 'C', NULL, &opt, "score", "Find line copies within and across files", PARSE_OPT_OPTARG, blame_copy_callback },
+ { OPTION_CALLBACK, 'M', NULL, &opt, "score", "Find line movements within and across files", PARSE_OPT_OPTARG, blame_move_callback },
+ OPT_CALLBACK('L', NULL, &bottomtop, "n,m", "Process only line range n,m, counting from 1", blame_bottomtop_callback),
+ OPT_END()
+ };
+
+ struct parse_opt_ctx_t ctx;
cmd_is_annotate = !strcmp(argv[0], "annotate");
- git_config(git_blame_config);
+ git_config(git_blame_config, NULL);
+ init_revisions(&revs, NULL);
save_commit_buffer = 0;
-
- opt = 0;
- seen_dashdash = 0;
- for (unk = i = 1; i < argc; i++) {
- const char *arg = argv[i];
- if (*arg != '-')
- break;
- else if (!strcmp("-b", arg))
- blank_boundary = 1;
- else if (!strcmp("--root", arg))
- show_root = 1;
- else if (!strcmp(arg, "--show-stats"))
- show_stats = 1;
- else if (!strcmp("-c", arg))
- output_option |= OUTPUT_ANNOTATE_COMPAT;
- else if (!strcmp("-t", arg))
- output_option |= OUTPUT_RAW_TIMESTAMP;
- else if (!strcmp("-l", arg))
- output_option |= OUTPUT_LONG_OBJECT_NAME;
- else if (!strcmp("-s", arg))
- output_option |= OUTPUT_NO_AUTHOR;
- else if (!strcmp("-w", arg))
- xdl_opts |= XDF_IGNORE_WHITESPACE;
- else if (!strcmp("-S", arg) && ++i < argc)
- revs_file = argv[i];
- else if (!prefixcmp(arg, "-M")) {
- opt |= PICKAXE_BLAME_MOVE;
- blame_move_score = parse_score(arg+2);
+ dashdash_pos = 0;
+
+ parse_options_start(&ctx, argc, argv, PARSE_OPT_KEEP_DASHDASH |
+ PARSE_OPT_KEEP_ARGV0);
+ for (;;) {
+ switch (parse_options_step(&ctx, options, blame_opt_usage)) {
+ case PARSE_OPT_HELP:
+ exit(129);
+ case PARSE_OPT_DONE:
+ if (ctx.argv[0])
+ dashdash_pos = ctx.cpidx;
+ goto parse_done;
}
- else if (!prefixcmp(arg, "-C")) {
- /*
- * -C enables copy from removed files;
- * -C -C enables copy from existing files, but only
- * when blaming a new file;
- * -C -C -C enables copy from existing files for
- * everybody
- */
- if (opt & PICKAXE_BLAME_COPY_HARDER)
- opt |= PICKAXE_BLAME_COPY_HARDEST;
- if (opt & PICKAXE_BLAME_COPY)
- opt |= PICKAXE_BLAME_COPY_HARDER;
- opt |= PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE;
- blame_copy_score = parse_score(arg+2);
- }
- else if (!prefixcmp(arg, "-L")) {
- if (!arg[2]) {
- if (++i >= argc)
- usage(blame_usage);
- arg = argv[i];
- }
- else
- arg += 2;
- if (bottomtop)
- die("More than one '-L n,m' option given");
- bottomtop = arg;
- }
- else if (!strcmp("--contents", arg)) {
- if (++i >= argc)
- usage(blame_usage);
- contents_from = argv[i];
- }
- else if (!strcmp("--incremental", arg))
- incremental = 1;
- else if (!strcmp("--score-debug", arg))
- output_option |= OUTPUT_SHOW_SCORE;
- else if (!strcmp("-f", arg) ||
- !strcmp("--show-name", arg))
- output_option |= OUTPUT_SHOW_NAME;
- else if (!strcmp("-n", arg) ||
- !strcmp("--show-number", arg))
- output_option |= OUTPUT_SHOW_NUMBER;
- else if (!strcmp("-p", arg) ||
- !strcmp("--porcelain", arg))
- output_option |= OUTPUT_PORCELAIN;
- else if (!strcmp("--", arg)) {
- seen_dashdash = 1;
- i++;
- break;
+
+ if (!strcmp(ctx.argv[0], "--reverse")) {
+ ctx.argv[0] = "--children";
+ reverse = 1;
}
- else
- argv[unk++] = arg;
+ parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
}
+parse_done:
+ argc = parse_options_end(&ctx);
+
+ if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
+ opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
+ PICKAXE_BLAME_COPY_HARDER);
if (!blame_move_score)
blame_move_score = BLAME_DEFAULT_MOVE_SCORE;
@@ -2241,115 +2362,59 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
*
* The remaining are:
*
- * (1) if seen_dashdash, its either
- * "-options -- <path>" or
- * "-options -- <path> <rev>".
- * but the latter is allowed only if there is no
- * options that we passed to revision machinery.
+ * (1) if dashdash_pos != 0, its either
+ * "blame [revisions] -- <path>" or
+ * "blame -- <path> <rev>"
*
- * (2) otherwise, we may have "--" somewhere later and
- * might be looking at the first one of multiple 'rev'
- * parameters (e.g. " master ^next ^maint -- path").
- * See if there is a dashdash first, and give the
- * arguments before that to revision machinery.
- * After that there must be one 'path'.
+ * (2) otherwise, its one of the two:
+ * "blame [revisions] <path>"
+ * "blame <path> <rev>"
*
- * (3) otherwise, its one of the three:
- * "-options <path> <rev>"
- * "-options <rev> <path>"
- * "-options <path>"
- * but again the first one is allowed only if
- * there is no options that we passed to revision
- * machinery.
+ * Note that we must strip out <path> from the arguments: we do not
+ * want the path pruning but we may want "bottom" processing.
*/
-
- if (seen_dashdash) {
- /* (1) */
- if (argc <= i)
- usage(blame_usage);
- path = add_prefix(prefix, argv[i]);
- if (i + 1 == argc - 1) {
- if (unk != 1)
- usage(blame_usage);
- argv[unk++] = argv[i + 1];
+ if (dashdash_pos) {
+ switch (argc - dashdash_pos - 1) {
+ case 2: /* (1b) */
+ if (argc != 4)
+ usage_with_options(blame_opt_usage, options);
+ /* reorder for the new way: <rev> -- <path> */
+ argv[1] = argv[3];
+ argv[3] = argv[2];
+ argv[2] = "--";
+ /* FALLTHROUGH */
+ case 1: /* (1a) */
+ path = add_prefix(prefix, argv[--argc]);
+ argv[argc] = NULL;
+ break;
+ default:
+ usage_with_options(blame_opt_usage, options);
}
- else if (i + 1 != argc)
- /* garbage at end */
- usage(blame_usage);
- }
- else {
- int j;
- for (j = i; !seen_dashdash && j < argc; j++)
- if (!strcmp(argv[j], "--"))
- seen_dashdash = j;
- if (seen_dashdash) {
- /* (2) */
- if (seen_dashdash + 1 != argc - 1)
- usage(blame_usage);
- path = add_prefix(prefix, argv[seen_dashdash + 1]);
- for (j = i; j < seen_dashdash; j++)
- argv[unk++] = argv[j];
+ } else {
+ if (argc < 2)
+ usage_with_options(blame_opt_usage, options);
+ path = add_prefix(prefix, argv[argc - 1]);
+ if (argc == 3 && !has_string_in_work_tree(path)) { /* (2b) */
+ path = add_prefix(prefix, argv[1]);
+ argv[1] = argv[2];
}
- else {
- /* (3) */
- if (argc <= i)
- usage(blame_usage);
- path = add_prefix(prefix, argv[i]);
- if (i + 1 == argc - 1) {
- final_commit_name = argv[i + 1];
-
- /* if (unk == 1) we could be getting
- * old-style
- */
- if (unk == 1 && !has_path_in_work_tree(path)) {
- path = add_prefix(prefix, argv[i + 1]);
- final_commit_name = argv[i];
- }
- }
- else if (i != argc - 1)
- usage(blame_usage); /* garbage at end */
+ argv[argc - 1] = "--";
- setup_work_tree();
- if (!has_path_in_work_tree(path))
- die("cannot stat path %s: %s",
- path, strerror(errno));
- }
+ setup_work_tree();
+ if (!has_string_in_work_tree(path))
+ die("cannot stat path %s: %s", path, strerror(errno));
}
- if (final_commit_name)
- argv[unk++] = final_commit_name;
-
- /*
- * Now we got rev and path. We do not want the path pruning
- * but we may want "bottom" processing.
- */
- argv[unk++] = "--"; /* terminate the rev name */
- argv[unk] = NULL;
-
- init_revisions(&revs, NULL);
- setup_revisions(unk, argv, &revs, NULL);
+ setup_revisions(argc, argv, &revs, NULL);
memset(&sb, 0, sizeof(sb));
- /*
- * There must be one and only one positive commit in the
- * revs->pending array.
- */
- for (i = 0; i < revs.pending.nr; i++) {
- struct object *obj = revs.pending.objects[i].item;
- if (obj->flags & UNINTERESTING)
- continue;
- while (obj->type == OBJ_TAG)
- obj = deref_tag(obj, NULL, 0);
- if (obj->type != OBJ_COMMIT)
- die("Non commit %s?",
- revs.pending.objects[i].name);
- if (sb.final)
- die("More than one commit to dig from %s and %s?",
- revs.pending.objects[i].name,
- final_commit_name);
- sb.final = (struct commit *) obj;
- final_commit_name = revs.pending.objects[i].name;
- }
+ sb.revs = &revs;
+ if (!reverse)
+ final_commit_name = prepare_final(&sb);
+ else if (contents_from)
+ die("--contents and --children do not blend well.");
+ else
+ final_commit_name = prepare_initial(&sb);
if (!sb.final) {
/*
@@ -2369,7 +2434,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
* bottom commits we would reach while traversing as
* uninteresting.
*/
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
if (is_null_sha1(sb.final->object.sha1)) {
char *buf;
@@ -2427,7 +2493,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
if (!incremental)
setup_pager();
- assign_blame(&sb, &revs, opt);
+ assign_blame(&sb, opt);
if (incremental)
return 0;
diff --git a/builtin-branch.c b/builtin-branch.c
index 1e0c9dea3..b1a2ad7a6 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -13,26 +13,24 @@
#include "remote.h"
#include "parse-options.h"
#include "branch.h"
+#include "diff.h"
+#include "revision.h"
static const char * const builtin_branch_usage[] = {
- "git-branch [options] [-r | -a]",
- "git-branch [options] [-l] [-f] <branchname> [<start-point>]",
- "git-branch [options] [-r] (-d | -D) <branchname>",
- "git-branch [options] (-m | -M) [<oldbranch>] <newbranch>",
+ "git branch [options] [-r | -a] [--merged | --no-merged]",
+ "git branch [options] [-l] [-f] <branchname> [<start-point>]",
+ "git branch [options] [-r] (-d | -D) <branchname>",
+ "git branch [options] (-m | -M) [<oldbranch>] <newbranch>",
NULL
};
-#define REF_UNKNOWN_TYPE 0x00
#define REF_LOCAL_BRANCH 0x01
#define REF_REMOTE_BRANCH 0x02
-#define REF_TAG 0x04
static const char *head;
static unsigned char head_sha1[20];
-static int branch_track = 1;
-
-static int branch_use_color;
+static int branch_use_color = -1;
static char branch_colors[][COLOR_MAXLEN] = {
"\033[m", /* reset */
"", /* PLAIN (normal) */
@@ -48,6 +46,13 @@ enum color_branch {
COLOR_BRANCH_CURRENT = 4,
};
+static enum merge_filter {
+ NO_FILTER = 0,
+ SHOW_NOT_MERGED,
+ SHOW_MERGED,
+} merge_filter;
+static unsigned char merge_filter_ref[20];
+
static int parse_branch_color_slot(const char *var, int ofs)
{
if (!strcasecmp(var+ofs, "plain"))
@@ -63,7 +68,7 @@ static int parse_branch_color_slot(const char *var, int ofs)
die("bad config variable '%s'", var);
}
-static int git_branch_config(const char *var, const char *value)
+static int git_branch_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "color.branch")) {
branch_use_color = git_config_colorbool(var, value, -1);
@@ -71,18 +76,17 @@ static int git_branch_config(const char *var, const char *value)
}
if (!prefixcmp(var, "color.branch.")) {
int slot = parse_branch_color_slot(var, 13);
+ if (!value)
+ return config_error_nonbool(var);
color_parse(value, var, branch_colors[slot]);
return 0;
}
- if (!strcmp(var, "branch.autosetupmerge"))
- branch_track = git_config_bool(var, value);
-
- return git_default_config(var, value);
+ return git_color_default_config(var, value, cb);
}
static const char *branch_get_color(enum color_branch ix)
{
- if (branch_use_color)
+ if (branch_use_color > 0)
return branch_colors[ix];
return "";
}
@@ -124,8 +128,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
continue;
}
- if (name)
- free(name);
+ free(name);
name = xstrdup(mkpath(fmt, argv[i]));
if (!resolve_ref(name, sha1, 1, NULL)) {
@@ -170,8 +173,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
}
}
- if (name)
- free(name);
+ free(name);
return(ret);
}
@@ -179,25 +181,21 @@ static int delete_branches(int argc, const char **argv, int force, int kinds)
struct ref_item {
char *name;
unsigned int kind;
- unsigned char sha1[20];
+ struct commit *commit;
};
struct ref_list {
+ struct rev_info revs;
int index, alloc, maxwidth;
struct ref_item *list;
struct commit_list *with_commit;
int kinds;
};
-static int has_commit(const unsigned char *sha1, struct commit_list *with_commit)
+static int has_commit(struct commit *commit, struct commit_list *with_commit)
{
- struct commit *commit;
-
if (!with_commit)
return 1;
- commit = lookup_commit_reference_gently(sha1, 1);
- if (!commit)
- return 0;
while (with_commit) {
struct commit *other;
@@ -213,7 +211,8 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
{
struct ref_list *ref_list = (struct ref_list*)(cb_data);
struct ref_item *newitem;
- int kind = REF_UNKNOWN_TYPE;
+ struct commit *commit;
+ int kind;
int len;
/* Detect kind */
@@ -223,19 +222,25 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
} else if (!prefixcmp(refname, "refs/remotes/")) {
kind = REF_REMOTE_BRANCH;
refname += 13;
- } else if (!prefixcmp(refname, "refs/tags/")) {
- kind = REF_TAG;
- refname += 10;
- }
+ } else
+ return 0;
+
+ commit = lookup_commit_reference_gently(sha1, 1);
+ if (!commit)
+ return error("branch '%s' does not point at a commit", refname);
/* Filter with with_commit if specified */
- if (!has_commit(sha1, ref_list->with_commit))
+ if (!has_commit(commit, ref_list->with_commit))
return 0;
/* Don't add types the caller doesn't want */
if ((kind & ref_list->kinds) == 0)
return 0;
+ if (merge_filter != NO_FILTER)
+ add_pending_object(&ref_list->revs,
+ (struct object *)commit, refname);
+
/* Resize buffer */
if (ref_list->index >= ref_list->alloc) {
ref_list->alloc = alloc_nr(ref_list->alloc);
@@ -247,7 +252,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
newitem = &(ref_list->list[ref_list->index++]);
newitem->name = xstrdup(refname);
newitem->kind = kind;
- hashcpy(newitem->sha1, sha1);
+ newitem->commit = commit;
len = strlen(newitem->name);
if (len > ref_list->maxwidth)
ref_list->maxwidth = len;
@@ -274,12 +279,41 @@ static int ref_cmp(const void *r1, const void *r2)
return strcmp(c1->name, c2->name);
}
+static void fill_tracking_info(char *stat, const char *branch_name)
+{
+ int ours, theirs;
+ struct branch *branch = branch_get(branch_name);
+
+ if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs))
+ return;
+ if (!ours)
+ sprintf(stat, "[behind %d] ", theirs);
+ else if (!theirs)
+ sprintf(stat, "[ahead %d] ", ours);
+ else
+ sprintf(stat, "[ahead %d, behind %d] ", ours, theirs);
+}
+
+static int matches_merge_filter(struct commit *commit)
+{
+ int is_merged;
+
+ if (merge_filter == NO_FILTER)
+ return 1;
+
+ is_merged = !!(commit->object.flags & UNINTERESTING);
+ return (is_merged == (merge_filter == SHOW_MERGED));
+}
+
static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
int abbrev, int current)
{
char c;
int color;
- struct commit *commit;
+ struct commit *commit = item->commit;
+
+ if (!matches_merge_filter(commit))
+ return;
switch (item->kind) {
case REF_LOCAL_BRANCH:
@@ -302,19 +336,26 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
if (verbose) {
struct strbuf subject;
const char *sub = " **** invalid ref ****";
+ char stat[128];
strbuf_init(&subject, 0);
+ stat[0] = '\0';
- commit = lookup_commit(item->sha1);
+ commit = item->commit;
if (commit && !parse_commit(commit)) {
pretty_print_commit(CMIT_FMT_ONELINE, commit,
&subject, 0, NULL, NULL, 0, 0);
sub = subject.buf;
}
- printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
+
+ if (item->kind == REF_LOCAL_BRANCH)
+ fill_tracking_info(stat, item->name);
+
+ printf("%c %s%-*s%s %s %s%s\n", c, branch_get_color(color),
maxwidth, item->name,
branch_get_color(COLOR_BRANCH_RESET),
- find_unique_abbrev(item->sha1, abbrev), sub);
+ find_unique_abbrev(item->commit->object.sha1, abbrev),
+ stat, sub);
strbuf_release(&subject);
} else {
printf("%c %s%s%s\n", c, branch_get_color(color), item->name,
@@ -322,26 +363,53 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
}
}
+static int calc_maxwidth(struct ref_list *refs)
+{
+ int i, l, w = 0;
+ for (i = 0; i < refs->index; i++) {
+ if (!matches_merge_filter(refs->list[i].commit))
+ continue;
+ l = strlen(refs->list[i].name);
+ if (l > w)
+ w = l;
+ }
+ return w;
+}
+
static void print_ref_list(int kinds, int detached, int verbose, int abbrev, struct commit_list *with_commit)
{
int i;
struct ref_list ref_list;
+ struct commit *head_commit = lookup_commit_reference_gently(head_sha1, 1);
memset(&ref_list, 0, sizeof(ref_list));
ref_list.kinds = kinds;
ref_list.with_commit = with_commit;
+ if (merge_filter != NO_FILTER)
+ init_revisions(&ref_list.revs, NULL);
for_each_ref(append_ref, &ref_list);
+ if (merge_filter != NO_FILTER) {
+ struct commit *filter;
+ filter = lookup_commit_reference_gently(merge_filter_ref, 0);
+ filter->object.flags |= UNINTERESTING;
+ add_pending_object(&ref_list.revs,
+ (struct object *) filter, "");
+ ref_list.revs.limited = 1;
+ prepare_revision_walk(&ref_list.revs);
+ if (verbose)
+ ref_list.maxwidth = calc_maxwidth(&ref_list);
+ }
qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);
detached = (detached && (kinds & REF_LOCAL_BRANCH));
- if (detached && has_commit(head_sha1, with_commit)) {
+ if (detached && head_commit && has_commit(head_commit, with_commit)) {
struct ref_item item;
item.name = xstrdup("(no branch)");
item.kind = REF_LOCAL_BRANCH;
- hashcpy(item.sha1, head_sha1);
+ item.commit = head_commit;
if (strlen(item.name) > ref_list.maxwidth)
- ref_list.maxwidth = strlen(item.name);
+ ref_list.maxwidth = strlen(item.name);
print_ref_item(&item, ref_list.maxwidth, verbose, abbrev, 1);
free(item.name);
}
@@ -413,28 +481,48 @@ static int opt_parse_with_commit(const struct option *opt, const char *arg, int
return 0;
}
+static int opt_parse_merge_filter(const struct option *opt, const char *arg, int unset)
+{
+ merge_filter = ((opt->long_name[0] == 'n')
+ ? SHOW_NOT_MERGED
+ : SHOW_MERGED);
+ if (unset)
+ merge_filter = SHOW_NOT_MERGED; /* b/c for --no-merged */
+ if (!arg)
+ arg = "HEAD";
+ if (get_sha1(arg, merge_filter_ref))
+ die("malformed object name %s", arg);
+ return 0;
+}
+
int cmd_branch(int argc, const char **argv, const char *prefix)
{
int delete = 0, rename = 0, force_create = 0;
int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
- int reflog = 0, track;
+ int reflog = 0;
+ enum branch_track track;
int kinds = REF_LOCAL_BRANCH;
struct commit_list *with_commit = NULL;
struct option options[] = {
OPT_GROUP("Generic options"),
OPT__VERBOSE(&verbose),
- OPT_BOOLEAN( 0 , "track", &track, "set up tracking mode (see git-pull(1))"),
+ OPT_SET_INT( 0 , "track", &track, "set up tracking mode (see git-pull(1))",
+ BRANCH_TRACK_EXPLICIT),
OPT_BOOLEAN( 0 , "color", &branch_use_color, "use colored output"),
OPT_SET_INT('r', NULL, &kinds, "act on remote-tracking branches",
REF_REMOTE_BRANCH),
- OPT_CALLBACK(0, "contains", &with_commit, "commit",
- "print only branches that contain the commit",
- opt_parse_with_commit),
+ {
+ OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
+ "print only branches that contain the commit",
+ PARSE_OPT_LASTARG_DEFAULT,
+ opt_parse_with_commit, (intptr_t)"HEAD",
+ },
{
OPTION_CALLBACK, 0, "with", &with_commit, "commit",
"print only branches that contain the commit",
- PARSE_OPT_HIDDEN, opt_parse_with_commit,
+ PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
+ opt_parse_with_commit, (intptr_t) "HEAD",
},
OPT__ABBREV(&abbrev),
@@ -447,14 +535,27 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
OPT_BOOLEAN('l', NULL, &reflog, "create the branch's reflog"),
OPT_BOOLEAN('f', NULL, &force_create, "force creation (when already exists)"),
+ {
+ OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
+ "commit", "print only not merged branches",
+ PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG,
+ opt_parse_merge_filter, (intptr_t) "HEAD",
+ },
+ {
+ OPTION_CALLBACK, 0, "merged", &merge_filter_ref,
+ "commit", "print only merged branches",
+ PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG,
+ opt_parse_merge_filter, (intptr_t) "HEAD",
+ },
OPT_END(),
};
- git_config(git_branch_config);
- track = branch_track;
- argc = parse_options(argc, argv, options, builtin_branch_usage, 0);
- if (!!delete + !!rename + !!force_create > 1)
- usage_with_options(builtin_branch_usage, options);
+ git_config(git_branch_config, NULL);
+
+ if (branch_use_color == -1)
+ branch_use_color = git_use_color_default;
+
+ track = git_branch_track;
head = resolve_ref("HEAD", head_sha1, 0, NULL);
if (!head)
@@ -467,6 +568,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
die("HEAD not found below refs/heads!");
head += 11;
}
+ hashcpy(merge_filter_ref, head_sha1);
+
+ argc = parse_options(argc, argv, options, builtin_branch_usage, 0);
+ if (!!delete + !!rename + !!force_create > 1)
+ usage_with_options(builtin_branch_usage, options);
if (delete)
return delete_branches(argc, argv, delete > 1, kinds);
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 9f38e2176..ac476e7a4 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -14,7 +14,7 @@ static const char *bundle_usage="git-bundle (create <bundle> <git-rev-list args>
int cmd_bundle(int argc, const char **argv, const char *prefix)
{
struct bundle_header header;
- int nongit = 0;
+ int nongit;
const char *cmd, *bundle_file;
int bundle_fd = -1;
char buffer[PATH_MAX];
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index f132d583d..7441a56ac 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -8,6 +8,10 @@
#include "tag.h"
#include "tree.h"
#include "builtin.h"
+#include "parse-options.h"
+
+#define BATCH 1
+#define BATCH_CHECK 2
static void pprint_tag(const unsigned char *sha1, const char *buf, unsigned long size)
{
@@ -76,31 +80,16 @@ static void pprint_tag(const unsigned char *sha1, const char *buf, unsigned long
write_or_die(1, cp, endp - cp);
}
-int cmd_cat_file(int argc, const char **argv, const char *prefix)
+static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
{
unsigned char sha1[20];
enum object_type type;
void *buf;
unsigned long size;
- int opt;
- const char *exp_type, *obj_name;
-
- git_config(git_default_config);
- if (argc != 3)
- usage("git-cat-file [-t|-s|-e|-p|<type>] <sha1>");
- exp_type = argv[1];
- obj_name = argv[2];
if (get_sha1(obj_name, sha1))
die("Not a valid object name %s", obj_name);
- opt = 0;
- if ( exp_type[0] == '-' ) {
- opt = exp_type[1];
- if ( !opt || exp_type[2] )
- opt = -1; /* Not a single character option */
- }
-
buf = NULL;
switch (opt) {
case 't':
@@ -157,3 +146,113 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
write_or_die(1, buf, size);
return 0;
}
+
+static int batch_one_object(const char *obj_name, int print_contents)
+{
+ unsigned char sha1[20];
+ enum object_type type = 0;
+ unsigned long size;
+ void *contents = contents;
+
+ if (!obj_name)
+ return 1;
+
+ if (get_sha1(obj_name, sha1)) {
+ printf("%s missing\n", obj_name);
+ fflush(stdout);
+ return 0;
+ }
+
+ if (print_contents == BATCH)
+ contents = read_sha1_file(sha1, &type, &size);
+ else
+ type = sha1_object_info(sha1, &size);
+
+ if (type <= 0) {
+ printf("%s missing\n", obj_name);
+ fflush(stdout);
+ return 0;
+ }
+
+ printf("%s %s %lu\n", sha1_to_hex(sha1), typename(type), size);
+ fflush(stdout);
+
+ if (print_contents == BATCH) {
+ write_or_die(1, contents, size);
+ printf("\n");
+ fflush(stdout);
+ free(contents);
+ }
+
+ return 0;
+}
+
+static int batch_objects(int print_contents)
+{
+ struct strbuf buf;
+
+ strbuf_init(&buf, 0);
+ while (strbuf_getline(&buf, stdin, '\n') != EOF) {
+ int error = batch_one_object(buf.buf, print_contents);
+ if (error)
+ return error;
+ }
+
+ return 0;
+}
+
+static const char * const cat_file_usage[] = {
+ "git cat-file [-t|-s|-e|-p|<type>] <sha1>",
+ "git cat-file [--batch|--batch-check] < <list_of_sha1s>",
+ NULL
+};
+
+int cmd_cat_file(int argc, const char **argv, const char *prefix)
+{
+ int opt = 0, batch = 0;
+ const char *exp_type = NULL, *obj_name = NULL;
+
+ const struct option options[] = {
+ OPT_GROUP("<type> can be one of: blob, tree, commit, tag"),
+ OPT_SET_INT('t', NULL, &opt, "show object type", 't'),
+ OPT_SET_INT('s', NULL, &opt, "show object size", 's'),
+ OPT_SET_INT('e', NULL, &opt,
+ "exit with zero when there's no error", 'e'),
+ OPT_SET_INT('p', NULL, &opt, "pretty-print object's content", 'p'),
+ OPT_SET_INT(0, "batch", &batch,
+ "show info and content of objects feeded on stdin", BATCH),
+ OPT_SET_INT(0, "batch-check", &batch,
+ "show info about objects feeded on stdin",
+ BATCH_CHECK),
+ OPT_END()
+ };
+
+ git_config(git_default_config, NULL);
+
+ if (argc != 3 && argc != 2)
+ usage_with_options(cat_file_usage, options);
+
+ argc = parse_options(argc, argv, options, cat_file_usage, 0);
+
+ if (opt) {
+ if (argc == 1)
+ obj_name = argv[0];
+ else
+ usage_with_options(cat_file_usage, options);
+ }
+ if (!opt && !batch) {
+ if (argc == 2) {
+ exp_type = argv[0];
+ obj_name = argv[1];
+ } else
+ usage_with_options(cat_file_usage, options);
+ }
+ if (batch && (opt || argc)) {
+ usage_with_options(cat_file_usage, options);
+ }
+
+ if (batch)
+ return batch_objects(batch);
+
+ return cat_one_file(opt, exp_type, obj_name);
+}
diff --git a/builtin-check-attr.c b/builtin-check-attr.c
index 6afdfa10a..cb783fc77 100644
--- a/builtin-check-attr.c
+++ b/builtin-check-attr.c
@@ -4,7 +4,7 @@
#include "quote.h"
static const char check_attr_usage[] =
-"git-check-attr attr... [--] pathname...";
+"git check-attr attr... [--] pathname...";
int cmd_check_attr(int argc, const char **argv, const char *prefix)
{
diff --git a/builtin-checkout-index.c b/builtin-checkout-index.c
index 7e42024c6..71ebabf99 100644
--- a/builtin-checkout-index.c
+++ b/builtin-checkout-index.c
@@ -154,7 +154,7 @@ static void checkout_all(const char *prefix, int prefix_length)
}
static const char checkout_cache_usage[] =
-"git-checkout-index [-u] [-q] [-a] [-f] [-n] [--stage=[123]|all] [--prefix=<string>] [--temp] [--] <file>...";
+"git checkout-index [-u] [-q] [-a] [-f] [-n] [--stage=[123]|all] [--prefix=<string>] [--temp] [--] <file>...";
static struct lock_file lock_file;
@@ -166,7 +166,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
int read_from_stdin = 0;
int prefix_length;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
state.base_dir = "";
prefix_length = prefix ? strlen(prefix) : 0;
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 141a9e187..cff017915 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -12,6 +12,7 @@
#include "branch.h"
#include "diff.h"
#include "revision.h"
+#include "remote.h"
static const char * const checkout_usage[] = {
"git checkout [options] <branch>",
@@ -42,7 +43,7 @@ static int post_checkout_hook(struct commit *old, struct commit *new,
}
static int update_some(const unsigned char *sha1, const char *base, int baselen,
- const char *pathname, unsigned mode, int stage)
+ const char *pathname, unsigned mode, int stage, void *context)
{
int len;
struct cache_entry *ce;
@@ -66,16 +67,7 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
static int read_tree_some(struct tree *tree, const char **pathspec)
{
- int newfd;
- struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
- newfd = hold_locked_index(lock_file, 1);
- read_cache();
-
- read_tree_recursive(tree, "", 0, 0, pathspec, update_some);
-
- if (write_cache(newfd, active_cache, active_nr) ||
- commit_locked_index(lock_file))
- die("unable to write new index file");
+ read_tree_recursive(tree, "", 0, 0, pathspec, update_some, NULL);
/* update the index with the given tree's info
* for all args, expanding wildcards, and exit
@@ -84,7 +76,7 @@ static int read_tree_some(struct tree *tree, const char **pathspec)
return 0;
}
-static int checkout_paths(const char **pathspec)
+static int checkout_paths(struct tree *source_tree, const char **pathspec)
{
int pos;
struct checkout state;
@@ -92,6 +84,16 @@ static int checkout_paths(const char **pathspec)
unsigned char rev[20];
int flag;
struct commit *head;
+ int errs = 0;
+
+ int newfd;
+ struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+ newfd = hold_locked_index(lock_file, 1);
+ read_cache();
+
+ if (source_tree)
+ read_tree_some(source_tree, pathspec);
for (pos = 0; pathspec[pos]; pos++)
;
@@ -105,20 +107,26 @@ static int checkout_paths(const char **pathspec)
if (report_path_error(ps_matched, pathspec, 0))
return 1;
+ /* Now we are committed to check them out */
memset(&state, 0, sizeof(state));
state.force = 1;
state.refresh_cache = 1;
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
if (pathspec_match(pathspec, NULL, ce->name, 0)) {
- checkout_entry(ce, &state, NULL);
+ errs |= checkout_entry(ce, &state, NULL);
}
}
+ if (write_cache(newfd, active_cache, active_nr) ||
+ commit_locked_index(lock_file))
+ die("unable to write new index file");
+
resolve_ref("HEAD", rev, 0, &flag);
head = lookup_commit_reference_gently(rev, 1);
- return post_checkout_hook(head, head, 0);
+ errs |= post_checkout_hook(head, head, 0);
+ return errs;
}
static void show_local_changes(struct object *head)
@@ -137,57 +145,56 @@ static void describe_detached_head(char *msg, struct commit *commit)
struct strbuf sb;
strbuf_init(&sb, 0);
parse_commit(commit);
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, "", "", 0, 0);
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
}
-static int reset_to_new(struct tree *tree, int quiet)
-{
- struct unpack_trees_options opts;
- struct tree_desc tree_desc;
- memset(&opts, 0, sizeof(opts));
- opts.head_idx = -1;
- opts.update = 1;
- opts.reset = 1;
- opts.merge = 1;
- opts.fn = oneway_merge;
- opts.verbose_update = !quiet;
- parse_tree(tree);
- init_tree_desc(&tree_desc, tree->buffer, tree->size);
- if (unpack_trees(1, &tree_desc, &opts))
- return 128;
- return 0;
-}
+struct checkout_opts {
+ int quiet;
+ int merge;
+ int force;
+ int writeout_error;
+
+ char *new_branch;
+ int new_branch_log;
+ enum branch_track track;
+};
-static void reset_clean_to_new(struct tree *tree, int quiet)
+static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
{
struct unpack_trees_options opts;
struct tree_desc tree_desc;
+
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
- opts.skip_unmerged = 1;
+ opts.update = worktree;
+ opts.skip_unmerged = !worktree;
opts.reset = 1;
opts.merge = 1;
opts.fn = oneway_merge;
- opts.verbose_update = !quiet;
+ opts.verbose_update = !o->quiet;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
parse_tree(tree);
init_tree_desc(&tree_desc, tree->buffer, tree->size);
- if (unpack_trees(1, &tree_desc, &opts))
- exit(128);
+ switch (unpack_trees(1, &tree_desc, &opts)) {
+ case -2:
+ o->writeout_error = 1;
+ /*
+ * We return 0 nevertheless, as the index is all right
+ * and more importantly we have made best efforts to
+ * update paths in the work tree, and we cannot revert
+ * them.
+ */
+ case 0:
+ return 0;
+ default:
+ return 128;
+ }
}
-struct checkout_opts {
- int quiet;
- int merge;
- int force;
-
- char *new_branch;
- int new_branch_log;
- int track;
-};
-
struct branch_info {
const char *name; /* The short name used */
const char *path; /* The full name of a real branch */
@@ -204,8 +211,7 @@ static void setup_branch_path(struct branch_info *branch)
}
static int merge_working_tree(struct checkout_opts *opts,
- struct branch_info *old, struct branch_info *new,
- const char *prefix)
+ struct branch_info *old, struct branch_info *new)
{
int ret;
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
@@ -213,37 +219,44 @@ static int merge_working_tree(struct checkout_opts *opts,
read_cache();
if (opts->force) {
- ret = reset_to_new(new->commit->tree, opts->quiet);
+ ret = reset_tree(new->commit->tree, opts, 1);
if (ret)
return ret;
} else {
struct tree_desc trees[2];
struct tree *tree;
struct unpack_trees_options topts;
+
memset(&topts, 0, sizeof(topts));
topts.head_idx = -1;
+ topts.src_index = &the_index;
+ topts.dst_index = &the_index;
+
+ topts.msgs.not_uptodate_file = "You have local changes to '%s'; cannot switch branches.";
refresh_cache(REFRESH_QUIET);
if (unmerged_cache()) {
- ret = opts->merge ? -1 :
- error("you need to resolve your current index first");
- } else {
- topts.update = 1;
- topts.merge = 1;
- topts.gently = opts->merge;
- topts.fn = twoway_merge;
- topts.dir = xcalloc(1, sizeof(*topts.dir));
- topts.dir->show_ignored = 1;
- topts.dir->exclude_per_dir = ".gitignore";
- topts.prefix = prefix;
- tree = parse_tree_indirect(old->commit->object.sha1);
- init_tree_desc(&trees[0], tree->buffer, tree->size);
- tree = parse_tree_indirect(new->commit->object.sha1);
- init_tree_desc(&trees[1], tree->buffer, tree->size);
- ret = unpack_trees(2, trees, &topts);
+ error("you need to resolve your current index first");
+ return 1;
}
- if (ret) {
+
+ /* 2-way merge to the new branch */
+ topts.update = 1;
+ topts.merge = 1;
+ topts.gently = opts->merge;
+ topts.verbose_update = !opts->quiet;
+ topts.fn = twoway_merge;
+ topts.dir = xcalloc(1, sizeof(*topts.dir));
+ topts.dir->show_ignored = 1;
+ topts.dir->exclude_per_dir = ".gitignore";
+ tree = parse_tree_indirect(old->commit->object.sha1);
+ init_tree_desc(&trees[0], tree->buffer, tree->size);
+ tree = parse_tree_indirect(new->commit->object.sha1);
+ init_tree_desc(&trees[1], tree->buffer, tree->size);
+
+ ret = unpack_trees(2, trees, &topts);
+ if (ret == -1) {
/*
* Unpack couldn't do a trivial merge; either
* give up or do a real merge, depending on
@@ -268,15 +281,17 @@ static int merge_working_tree(struct checkout_opts *opts,
* entries in the index.
*/
- add_files_to_cache(0, NULL, NULL);
+ add_files_to_cache(NULL, NULL, 0);
work = write_tree_from_memory();
- ret = reset_to_new(new->commit->tree, opts->quiet);
+ ret = reset_tree(new->commit->tree, opts, 1);
if (ret)
return ret;
merge_trees(new->commit->tree, work, old->commit->tree,
new->name, "local", &result);
- reset_clean_to_new(new->commit->tree, opts->quiet);
+ ret = reset_tree(new->commit->tree, opts, 0);
+ if (ret)
+ return ret;
}
}
@@ -290,6 +305,17 @@ static int merge_working_tree(struct checkout_opts *opts,
return 0;
}
+static void report_tracking(struct branch_info *new)
+{
+ struct strbuf sb = STRBUF_INIT;
+ struct branch *branch = branch_get(new->name);
+
+ if (!format_tracking_info(branch, &sb))
+ return;
+ fputs(sb.buf, stdout);
+ strbuf_release(&sb);
+}
+
static void update_refs_for_switch(struct checkout_opts *opts,
struct branch_info *old,
struct branch_info *new)
@@ -332,10 +358,11 @@ static void update_refs_for_switch(struct checkout_opts *opts,
}
remove_branch_state();
strbuf_release(&msg);
+ if (!opts->quiet && (new->path || !strcmp(new->name, "HEAD")))
+ report_tracking(new);
}
-static int switch_branches(struct checkout_opts *opts,
- struct branch_info *new, const char *prefix)
+static int switch_branches(struct checkout_opts *opts, struct branch_info *new)
{
int ret = 0;
struct branch_info old;
@@ -378,23 +405,15 @@ static int switch_branches(struct checkout_opts *opts,
opts->force = 1;
}
- ret = merge_working_tree(opts, &old, new, prefix);
+ ret = merge_working_tree(opts, &old, new);
if (ret)
return ret;
update_refs_for_switch(opts, &old, new);
- free((char *)old.path);
- return post_checkout_hook(old.commit, new->commit, 1);
-}
-static int branch_track = 0;
-
-static int git_checkout_config(const char *var, const char *value)
-{
- if (!strcmp(var, "branch.autosetupmerge"))
- branch_track = git_config_bool(var, value);
-
- return git_default_config(var, value);
+ ret = post_checkout_hook(old.commit, new->commit, 1);
+ free((char *)old.path);
+ return ret || opts->writeout_error;
}
int cmd_checkout(int argc, const char **argv, const char *prefix)
@@ -408,24 +427,72 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
OPT__QUIET(&opts.quiet),
OPT_STRING('b', NULL, &opts.new_branch, "new branch", "branch"),
OPT_BOOLEAN('l', NULL, &opts.new_branch_log, "log for new branch"),
- OPT_BOOLEAN( 0 , "track", &opts.track, "track"),
+ OPT_SET_INT('t', "track", &opts.track, "track",
+ BRANCH_TRACK_EXPLICIT),
OPT_BOOLEAN('f', NULL, &opts.force, "force"),
OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
+ OPT_END(),
};
+ int has_dash_dash;
memset(&opts, 0, sizeof(opts));
memset(&new, 0, sizeof(new));
- git_config(git_checkout_config);
+ git_config(git_default_config, NULL);
- opts.track = branch_track;
+ opts.track = git_branch_track;
+
+ argc = parse_options(argc, argv, options, checkout_usage,
+ PARSE_OPT_KEEP_DASHDASH);
+
+ if (!opts.new_branch && (opts.track != git_branch_track))
+ die("git checkout: --track and --no-track require -b");
- argc = parse_options(argc, argv, options, checkout_usage, 0);
+ if (opts.force && opts.merge)
+ die("git checkout: -f and -m are incompatible");
+
+ /*
+ * case 1: git checkout <ref> -- [<paths>]
+ *
+ * <ref> must be a valid tree, everything after the '--' must be
+ * a path.
+ *
+ * case 2: git checkout -- [<paths>]
+ *
+ * everything after the '--' must be paths.
+ *
+ * case 3: git checkout <something> [<paths>]
+ *
+ * With no paths, if <something> is a commit, that is to
+ * switch to the branch or detach HEAD at it.
+ *
+ * Otherwise <something> shall not be ambiguous.
+ * - If it's *only* a reference, treat it like case (1).
+ * - If it's only a path, treat it like case (2).
+ * - else: fail.
+ *
+ */
if (argc) {
+ if (!strcmp(argv[0], "--")) { /* case (2) */
+ argv++;
+ argc--;
+ goto no_reference;
+ }
+
arg = argv[0];
- if (get_sha1(arg, rev))
- ;
- else if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
+ has_dash_dash = (argc > 1) && !strcmp(argv[1], "--");
+
+ if (get_sha1(arg, rev)) {
+ if (has_dash_dash) /* case (1) */
+ die("invalid reference: %s", arg);
+ goto no_reference; /* case (3 -> 2) */
+ }
+
+ /* we can't end up being in (2) anymore, eat the argument */
+ argv++;
+ argc--;
+
+ if ((new.commit = lookup_commit_reference_gently(rev, 1))) {
new.name = arg;
setup_branch_path(&new);
if (resolve_ref(new.path, rev, 1, NULL))
@@ -434,27 +501,34 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
new.path = NULL;
parse_commit(new.commit);
source_tree = new.commit->tree;
- argv++;
- argc--;
- } else if ((source_tree = parse_tree_indirect(rev))) {
+ } else
+ source_tree = parse_tree_indirect(rev);
+
+ if (!source_tree) /* case (1): want a tree */
+ die("reference is not a tree: %s", arg);
+ if (!has_dash_dash) {/* case (3 -> 1) */
+ /*
+ * Do not complain the most common case
+ * git checkout branch
+ * even if there happen to be a file called 'branch';
+ * it would be extremely annoying.
+ */
+ if (argc)
+ verify_non_filename(NULL, arg);
+ }
+ else {
argv++;
argc--;
}
}
- if (argc && !strcmp(argv[0], "--")) {
- argv++;
- argc--;
- }
-
- if (!opts.new_branch && (opts.track != branch_track))
- die("git checkout: --track and --no-track require -b");
-
- if (opts.force && opts.merge)
- die("git checkout: -f and -m are incompatible");
-
+no_reference:
if (argc) {
const char **pathspec = get_pathspec(prefix, argv);
+
+ if (!pathspec)
+ die("invalid path specification");
+
/* Checkout paths */
if (opts.new_branch || opts.force || opts.merge) {
if (argc == 1) {
@@ -464,16 +538,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
}
}
- if (source_tree)
- read_tree_some(source_tree, pathspec);
- else
- read_cache();
- return checkout_paths(pathspec);
+ return checkout_paths(source_tree, pathspec);
}
if (new.name && !new.commit) {
die("Cannot switch branch to a non-commit.");
}
- return switch_branches(&opts, &new, prefix);
+ return switch_branches(&opts, &new);
}
diff --git a/builtin-clean.c b/builtin-clean.c
index eb853a37c..48bf29f40 100644
--- a/builtin-clean.c
+++ b/builtin-clean.c
@@ -10,31 +10,33 @@
#include "cache.h"
#include "dir.h"
#include "parse-options.h"
+#include "quote.h"
static int force = -1; /* unset */
static const char *const builtin_clean_usage[] = {
- "git-clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...",
+ "git clean [-d] [-f] [-n] [-q] [-x | -X] [--] <paths>...",
NULL
};
-static int git_clean_config(const char *var, const char *value)
+static int git_clean_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "clean.requireforce"))
force = !git_config_bool(var, value);
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
int cmd_clean(int argc, const char **argv, const char *prefix)
{
int i;
int show_only = 0, remove_directories = 0, quiet = 0, ignored = 0;
- int ignored_only = 0, baselen = 0, config_set = 0;
+ int ignored_only = 0, baselen = 0, config_set = 0, errors = 0;
struct strbuf directory;
struct dir_struct dir;
const char *path, *base;
static const char **pathspec;
- int prefix_offset = 0;
+ struct strbuf buf;
+ const char *qname;
char *seen = NULL;
struct option options[] = {
OPT__QUIET(&quiet),
@@ -48,7 +50,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
OPT_END()
};
- git_config(git_clean_config);
+ git_config(git_clean_config, NULL);
if (force < 0)
force = 0;
else
@@ -56,6 +58,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, options, builtin_clean_usage, 0);
+ strbuf_init(&buf, 0);
memset(&dir, 0, sizeof(dir));
if (ignored_only)
dir.show_ignored = 1;
@@ -72,8 +75,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
if (!ignored)
setup_standard_excludes(&dir);
- if (prefix)
- prefix_offset = strlen(prefix);
pathspec = get_pathspec(prefix, argv);
read_cache();
@@ -94,7 +95,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
- int len, pos, matches;
+ int len, pos;
+ int matches = 0;
struct cache_entry *ce;
struct stat st;
@@ -126,47 +128,48 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
if (pathspec) {
memset(seen, 0, argc > 0 ? argc : 1);
- matches = match_pathspec(pathspec, ent->name, ent->len,
+ matches = match_pathspec(pathspec, ent->name, len,
baselen, seen);
- } else {
- matches = 0;
}
if (S_ISDIR(st.st_mode)) {
strbuf_addstr(&directory, ent->name);
- if (show_only && (remove_directories || matches)) {
- printf("Would remove %s\n",
- directory.buf + prefix_offset);
- } else if (quiet && (remove_directories || matches)) {
- remove_dir_recursively(&directory, 0);
- } else if (remove_directories || matches) {
- printf("Removing %s\n",
- directory.buf + prefix_offset);
- remove_dir_recursively(&directory, 0);
+ qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
+ if (show_only && (remove_directories ||
+ (matches == MATCHED_EXACTLY))) {
+ printf("Would remove %s\n", qname);
+ } else if (remove_directories ||
+ (matches == MATCHED_EXACTLY)) {
+ if (!quiet)
+ printf("Removing %s\n", qname);
+ if (remove_dir_recursively(&directory, 0) != 0) {
+ warning("failed to remove '%s'", qname);
+ errors++;
+ }
} else if (show_only) {
- printf("Would not remove %s\n",
- directory.buf + prefix_offset);
+ printf("Would not remove %s\n", qname);
} else {
- printf("Not removing %s\n",
- directory.buf + prefix_offset);
+ printf("Not removing %s\n", qname);
}
strbuf_reset(&directory);
} else {
if (pathspec && !matches)
continue;
+ qname = quote_path_relative(ent->name, -1, &buf, prefix);
if (show_only) {
- printf("Would remove %s\n",
- ent->name + prefix_offset);
+ printf("Would remove %s\n", qname);
continue;
} else if (!quiet) {
- printf("Removing %s\n",
- ent->name + prefix_offset);
+ printf("Removing %s\n", qname);
+ }
+ if (unlink(ent->name) != 0) {
+ warning("failed to remove '%s'", qname);
+ errors++;
}
- unlink(ent->name);
}
}
free(seen);
strbuf_release(&directory);
- return 0;
+ return (errors != 0);
}
diff --git a/builtin-clone.c b/builtin-clone.c
new file mode 100644
index 000000000..c0e308643
--- /dev/null
+++ b/builtin-clone.c
@@ -0,0 +1,602 @@
+/*
+ * Builtin "git clone"
+ *
+ * Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>,
+ * 2008 Daniel Barkalow <barkalow@iabervon.org>
+ * Based on git-commit.sh by Junio C Hamano and Linus Torvalds
+ *
+ * Clone a repository into a different directory that does not yet exist.
+ */
+
+#include "cache.h"
+#include "parse-options.h"
+#include "fetch-pack.h"
+#include "refs.h"
+#include "tree.h"
+#include "tree-walk.h"
+#include "unpack-trees.h"
+#include "transport.h"
+#include "strbuf.h"
+#include "dir.h"
+#include "pack-refs.h"
+
+/*
+ * Overall FIXMEs:
+ * - respect DB_ENVIRONMENT for .git/objects.
+ *
+ * Implementation notes:
+ * - dropping use-separate-remote and no-separate-remote compatibility
+ *
+ */
+static const char * const builtin_clone_usage[] = {
+ "git clone [options] [--] <repo> [<dir>]",
+ NULL
+};
+
+static int option_quiet, option_no_checkout, option_bare, option_mirror;
+static int option_local, option_no_hardlinks, option_shared;
+static char *option_template, *option_reference, *option_depth;
+static char *option_origin = NULL;
+static char *option_upload_pack = "git-upload-pack";
+
+static struct option builtin_clone_options[] = {
+ OPT__QUIET(&option_quiet),
+ OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
+ "don't create a checkout"),
+ OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
+ OPT_BOOLEAN(0, "naked", &option_bare, "create a bare repository"),
+ OPT_BOOLEAN(0, "mirror", &option_mirror,
+ "create a mirror repository (implies bare)"),
+ OPT_BOOLEAN('l', "local", &option_local,
+ "to clone from a local repository"),
+ OPT_BOOLEAN(0, "no-hardlinks", &option_no_hardlinks,
+ "don't use local hardlinks, always copy"),
+ OPT_BOOLEAN('s', "shared", &option_shared,
+ "setup as shared repository"),
+ OPT_STRING(0, "template", &option_template, "path",
+ "path the template repository"),
+ OPT_STRING(0, "reference", &option_reference, "repo",
+ "reference repository"),
+ OPT_STRING('o', "origin", &option_origin, "branch",
+ "use <branch> instead or 'origin' to track upstream"),
+ OPT_STRING('u', "upload-pack", &option_upload_pack, "path",
+ "path to git-upload-pack on the remote"),
+ OPT_STRING(0, "depth", &option_depth, "depth",
+ "create a shallow clone of that depth"),
+
+ OPT_END()
+};
+
+static char *get_repo_path(const char *repo, int *is_bundle)
+{
+ static char *suffix[] = { "/.git", ".git", "" };
+ static char *bundle_suffix[] = { ".bundle", "" };
+ struct stat st;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(suffix); i++) {
+ const char *path;
+ path = mkpath("%s%s", repo, suffix[i]);
+ if (!stat(path, &st) && S_ISDIR(st.st_mode)) {
+ *is_bundle = 0;
+ return xstrdup(make_nonrelative_path(path));
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(bundle_suffix); i++) {
+ const char *path;
+ path = mkpath("%s%s", repo, bundle_suffix[i]);
+ if (!stat(path, &st) && S_ISREG(st.st_mode)) {
+ *is_bundle = 1;
+ return xstrdup(make_nonrelative_path(path));
+ }
+ }
+
+ return NULL;
+}
+
+static char *guess_dir_name(const char *repo, int is_bundle, int is_bare)
+{
+ const char *end = repo + strlen(repo), *start;
+
+ /*
+ * Strip trailing slashes and /.git
+ */
+ while (repo < end && is_dir_sep(end[-1]))
+ end--;
+ if (end - repo > 5 && is_dir_sep(end[-5]) &&
+ !strncmp(end - 4, ".git", 4)) {
+ end -= 5;
+ while (repo < end && is_dir_sep(end[-1]))
+ end--;
+ }
+
+ /*
+ * Find last component, but be prepared that repo could have
+ * the form "remote.example.com:foo.git", i.e. no slash
+ * in the directory part.
+ */
+ start = end;
+ while (repo < start && !is_dir_sep(start[-1]) && start[-1] != ':')
+ start--;
+
+ /*
+ * Strip .{bundle,git}.
+ */
+ if (is_bundle) {
+ if (end - start > 7 && !strncmp(end - 7, ".bundle", 7))
+ end -= 7;
+ } else {
+ if (end - start > 4 && !strncmp(end - 4, ".git", 4))
+ end -= 4;
+ }
+
+ if (is_bare) {
+ char *result = xmalloc(end - start + 5);
+ sprintf(result, "%.*s.git", (int)(end - start), start);
+ return result;
+ }
+
+ return xstrndup(start, end - start);
+}
+
+static int is_directory(const char *path)
+{
+ struct stat buf;
+
+ return !stat(path, &buf) && S_ISDIR(buf.st_mode);
+}
+
+static void setup_reference(const char *repo)
+{
+ const char *ref_git;
+ char *ref_git_copy;
+
+ struct remote *remote;
+ struct transport *transport;
+ const struct ref *extra;
+
+ ref_git = make_absolute_path(option_reference);
+
+ if (is_directory(mkpath("%s/.git/objects", ref_git)))
+ ref_git = mkpath("%s/.git", ref_git);
+ else if (!is_directory(mkpath("%s/objects", ref_git)))
+ die("reference repository '%s' is not a local directory.",
+ option_reference);
+
+ ref_git_copy = xstrdup(ref_git);
+
+ add_to_alternates_file(ref_git_copy);
+
+ remote = remote_get(ref_git_copy);
+ transport = transport_get(remote, ref_git_copy);
+ for (extra = transport_get_remote_refs(transport); extra;
+ extra = extra->next)
+ add_extra_ref(extra->name, extra->old_sha1, 0);
+
+ transport_disconnect(transport);
+
+ free(ref_git_copy);
+}
+
+static void copy_or_link_directory(char *src, char *dest)
+{
+ struct dirent *de;
+ struct stat buf;
+ int src_len, dest_len;
+ DIR *dir;
+
+ dir = opendir(src);
+ if (!dir)
+ die("failed to open %s\n", src);
+
+ if (mkdir(dest, 0777)) {
+ if (errno != EEXIST)
+ die("failed to create directory %s\n", dest);
+ else if (stat(dest, &buf))
+ die("failed to stat %s\n", dest);
+ else if (!S_ISDIR(buf.st_mode))
+ die("%s exists and is not a directory\n", dest);
+ }
+
+ src_len = strlen(src);
+ src[src_len] = '/';
+ dest_len = strlen(dest);
+ dest[dest_len] = '/';
+
+ while ((de = readdir(dir)) != NULL) {
+ strcpy(src + src_len + 1, de->d_name);
+ strcpy(dest + dest_len + 1, de->d_name);
+ if (stat(src, &buf)) {
+ warning ("failed to stat %s\n", src);
+ continue;
+ }
+ if (S_ISDIR(buf.st_mode)) {
+ if (de->d_name[0] != '.')
+ copy_or_link_directory(src, dest);
+ continue;
+ }
+
+ if (unlink(dest) && errno != ENOENT)
+ die("failed to unlink %s\n", dest);
+ if (!option_no_hardlinks) {
+ if (!link(src, dest))
+ continue;
+ if (option_local)
+ die("failed to create link %s\n", dest);
+ option_no_hardlinks = 1;
+ }
+ if (copy_file(dest, src, 0666))
+ die("failed to copy file to %s\n", dest);
+ }
+ closedir(dir);
+}
+
+static const struct ref *clone_local(const char *src_repo,
+ const char *dest_repo)
+{
+ const struct ref *ret;
+ char src[PATH_MAX];
+ char dest[PATH_MAX];
+ struct remote *remote;
+ struct transport *transport;
+
+ if (option_shared)
+ add_to_alternates_file(src_repo);
+ else {
+ snprintf(src, PATH_MAX, "%s/objects", src_repo);
+ snprintf(dest, PATH_MAX, "%s/objects", dest_repo);
+ copy_or_link_directory(src, dest);
+ }
+
+ remote = remote_get(src_repo);
+ transport = transport_get(remote, src_repo);
+ ret = transport_get_remote_refs(transport);
+ transport_disconnect(transport);
+ return ret;
+}
+
+static const char *junk_work_tree;
+static const char *junk_git_dir;
+pid_t junk_pid;
+
+static void remove_junk(void)
+{
+ struct strbuf sb;
+ if (getpid() != junk_pid)
+ return;
+ strbuf_init(&sb, 0);
+ if (junk_git_dir) {
+ strbuf_addstr(&sb, junk_git_dir);
+ remove_dir_recursively(&sb, 0);
+ strbuf_reset(&sb);
+ }
+ if (junk_work_tree) {
+ strbuf_addstr(&sb, junk_work_tree);
+ remove_dir_recursively(&sb, 0);
+ strbuf_reset(&sb);
+ }
+}
+
+static void remove_junk_on_signal(int signo)
+{
+ remove_junk();
+ signal(SIGINT, SIG_DFL);
+ raise(signo);
+}
+
+static const struct ref *locate_head(const struct ref *refs,
+ const struct ref *mapped_refs,
+ const struct ref **remote_head_p)
+{
+ const struct ref *remote_head = NULL;
+ const struct ref *remote_master = NULL;
+ const struct ref *r;
+ for (r = refs; r; r = r->next)
+ if (!strcmp(r->name, "HEAD"))
+ remote_head = r;
+
+ for (r = mapped_refs; r; r = r->next)
+ if (!strcmp(r->name, "refs/heads/master"))
+ remote_master = r;
+
+ if (remote_head_p)
+ *remote_head_p = remote_head;
+
+ /* If there's no HEAD value at all, never mind. */
+ if (!remote_head)
+ return NULL;
+
+ /* If refs/heads/master could be right, it is. */
+ if (remote_master && !hashcmp(remote_master->old_sha1,
+ remote_head->old_sha1))
+ return remote_master;
+
+ /* Look for another ref that points there */
+ for (r = mapped_refs; r; r = r->next)
+ if (r != remote_head &&
+ !hashcmp(r->old_sha1, remote_head->old_sha1))
+ return r;
+
+ /* Nothing is the same */
+ return NULL;
+}
+
+static struct ref *write_remote_refs(const struct ref *refs,
+ struct refspec *refspec, const char *reflog)
+{
+ struct ref *local_refs = NULL;
+ struct ref **tail = &local_refs;
+ struct ref *r;
+
+ get_fetch_map(refs, refspec, &tail, 0);
+ if (!option_mirror)
+ get_fetch_map(refs, tag_refspec, &tail, 0);
+
+ for (r = local_refs; r; r = r->next)
+ add_extra_ref(r->peer_ref->name, r->old_sha1, 0);
+
+ pack_refs(PACK_REFS_ALL);
+ clear_extra_refs();
+
+ return local_refs;
+}
+
+int cmd_clone(int argc, const char **argv, const char *prefix)
+{
+ int use_local_hardlinks = 1;
+ int use_separate_remote = 1;
+ int is_bundle = 0;
+ struct stat buf;
+ const char *repo_name, *repo, *work_tree, *git_dir;
+ char *path, *dir;
+ const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
+ char branch_top[256], key[256], value[256];
+ struct strbuf reflog_msg;
+ struct transport *transport = NULL;
+ char *src_ref_prefix = "refs/heads/";
+
+ struct refspec refspec;
+
+ junk_pid = getpid();
+
+ argc = parse_options(argc, argv, builtin_clone_options,
+ builtin_clone_usage, 0);
+
+ if (argc == 0)
+ die("You must specify a repository to clone.");
+
+ if (option_no_hardlinks)
+ use_local_hardlinks = 0;
+
+ if (option_mirror)
+ option_bare = 1;
+
+ if (option_bare) {
+ if (option_origin)
+ die("--bare and --origin %s options are incompatible.",
+ option_origin);
+ option_no_checkout = 1;
+ use_separate_remote = 0;
+ }
+
+ if (!option_origin)
+ option_origin = "origin";
+
+ repo_name = argv[0];
+
+ path = get_repo_path(repo_name, &is_bundle);
+ if (path)
+ repo = path;
+ else if (!strchr(repo_name, ':'))
+ repo = xstrdup(make_absolute_path(repo_name));
+ else
+ repo = repo_name;
+
+ if (argc == 2)
+ dir = xstrdup(argv[1]);
+ else
+ dir = guess_dir_name(repo_name, is_bundle, option_bare);
+
+ if (!stat(dir, &buf))
+ die("destination directory '%s' already exists.", dir);
+
+ strbuf_init(&reflog_msg, 0);
+ strbuf_addf(&reflog_msg, "clone: from %s", repo);
+
+ if (option_bare)
+ work_tree = NULL;
+ else {
+ work_tree = getenv("GIT_WORK_TREE");
+ if (work_tree && !stat(work_tree, &buf))
+ die("working tree '%s' already exists.", work_tree);
+ }
+
+ if (option_bare || work_tree)
+ git_dir = xstrdup(dir);
+ else {
+ work_tree = dir;
+ git_dir = xstrdup(mkpath("%s/.git", dir));
+ }
+
+ if (!option_bare) {
+ junk_work_tree = work_tree;
+ if (safe_create_leading_directories_const(work_tree) < 0)
+ die("could not create leading directories of '%s'",
+ work_tree);
+ if (mkdir(work_tree, 0755))
+ die("could not create work tree dir '%s'.", work_tree);
+ set_git_work_tree(work_tree);
+ }
+ junk_git_dir = git_dir;
+ atexit(remove_junk);
+ signal(SIGINT, remove_junk_on_signal);
+
+ setenv(CONFIG_ENVIRONMENT, xstrdup(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);
+ set_git_dir(make_absolute_path(git_dir));
+
+ init_db(option_template, option_quiet ? INIT_DB_QUIET : 0);
+
+ /*
+ * 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);
+
+ if (option_reference)
+ setup_reference(git_dir);
+
+ git_config(git_default_config, NULL);
+
+ if (option_bare) {
+ if (option_mirror)
+ src_ref_prefix = "refs/";
+ strcpy(branch_top, src_ref_prefix);
+
+ git_config_set("core.bare", "true");
+ } else {
+ snprintf(branch_top, sizeof(branch_top),
+ "refs/remotes/%s/", option_origin);
+ }
+
+ if (option_mirror || !option_bare) {
+ /* Configure the remote */
+ if (option_mirror) {
+ snprintf(key, sizeof(key),
+ "remote.%s.mirror", option_origin);
+ git_config_set(key, "true");
+ }
+
+ snprintf(key, sizeof(key), "remote.%s.url", option_origin);
+ git_config_set(key, repo);
+
+ snprintf(key, sizeof(key), "remote.%s.fetch", option_origin);
+ snprintf(value, sizeof(value),
+ "+%s*:%s*", src_ref_prefix, branch_top);
+ git_config_set_multivar(key, value, "^$", 0);
+ }
+
+ refspec.force = 0;
+ refspec.pattern = 1;
+ refspec.src = src_ref_prefix;
+ refspec.dst = branch_top;
+
+ if (path && !is_bundle)
+ refs = clone_local(path, git_dir);
+ else {
+ struct remote *remote = remote_get(argv[0]);
+ transport = transport_get(remote, remote->url[0]);
+
+ if (!transport->get_refs_list || !transport->fetch)
+ die("Don't know how to clone %s", transport->url);
+
+ transport_set_option(transport, TRANS_OPT_KEEP, "yes");
+
+ if (option_depth)
+ transport_set_option(transport, TRANS_OPT_DEPTH,
+ option_depth);
+
+ if (option_quiet)
+ transport->verbose = -1;
+
+ if (option_upload_pack)
+ transport_set_option(transport, TRANS_OPT_UPLOADPACK,
+ option_upload_pack);
+
+ refs = transport_get_remote_refs(transport);
+ transport_fetch_refs(transport, refs);
+ }
+
+ clear_extra_refs();
+
+ mapped_refs = write_remote_refs(refs, &refspec, reflog_msg.buf);
+
+ head_points_at = locate_head(refs, mapped_refs, &remote_head);
+
+ if (head_points_at) {
+ /* Local default branch link */
+ create_symref("HEAD", head_points_at->name, NULL);
+
+ if (!option_bare) {
+ struct strbuf head_ref;
+ const char *head = head_points_at->name;
+
+ if (!prefixcmp(head, "refs/heads/"))
+ head += 11;
+
+ /* Set up the initial local branch */
+
+ /* Local branch initial value */
+ update_ref(reflog_msg.buf, "HEAD",
+ head_points_at->old_sha1,
+ NULL, 0, DIE_ON_ERR);
+
+ strbuf_init(&head_ref, 0);
+ strbuf_addstr(&head_ref, branch_top);
+ strbuf_addstr(&head_ref, "HEAD");
+
+ /* Remote branch link */
+ create_symref(head_ref.buf,
+ head_points_at->peer_ref->name,
+ reflog_msg.buf);
+
+ snprintf(key, sizeof(key), "branch.%s.remote", head);
+ git_config_set(key, option_origin);
+ snprintf(key, sizeof(key), "branch.%s.merge", head);
+ git_config_set(key, head_points_at->name);
+ }
+ } else if (remote_head) {
+ /* Source had detached HEAD pointing somewhere. */
+ if (!option_bare)
+ update_ref(reflog_msg.buf, "HEAD",
+ remote_head->old_sha1,
+ NULL, REF_NODEREF, DIE_ON_ERR);
+ } else {
+ /* Nothing to checkout out */
+ if (!option_no_checkout)
+ warning("remote HEAD refers to nonexistent ref, "
+ "unable to checkout.\n");
+ option_no_checkout = 1;
+ }
+
+ if (transport)
+ transport_unlock_pack(transport);
+
+ if (!option_no_checkout) {
+ struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+ struct unpack_trees_options opts;
+ struct tree *tree;
+ struct tree_desc t;
+ int fd;
+
+ /* We need to be in the new work tree for the checkout */
+ setup_work_tree();
+
+ fd = hold_locked_index(lock_file, 1);
+
+ memset(&opts, 0, sizeof opts);
+ opts.update = 1;
+ opts.merge = 1;
+ opts.fn = oneway_merge;
+ opts.verbose_update = !option_quiet;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
+
+ tree = parse_tree_indirect(remote_head->old_sha1);
+ parse_tree(tree);
+ init_tree_desc(&t, tree->buffer, tree->size);
+ unpack_trees(1, &t, &opts);
+
+ if (write_cache(fd, active_cache, active_nr) ||
+ commit_locked_index(lock_file))
+ die("unable to write new index file");
+ }
+
+ strbuf_release(&reflog_msg);
+ junk_pid = 0;
+ return 0;
+}
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 6610d1835..7a9a309be 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -24,26 +24,20 @@ static void check_valid(unsigned char *sha1, enum object_type expect)
typename(expect));
}
-/*
- * Having more than two parents is not strange at all, and this is
- * how multi-way merges are represented.
- */
-#define MAXPARENT (16)
-static unsigned char parent_sha1[MAXPARENT][20];
-
static const char commit_tree_usage[] = "git-commit-tree <sha1> [-p <sha1>]* < changelog";
-static int new_parent(int idx)
+static void new_parent(struct commit *parent, struct commit_list **parents_p)
{
- int i;
- unsigned char *sha1 = parent_sha1[idx];
- for (i = 0; i < idx; i++) {
- if (!hashcmp(parent_sha1[i], sha1)) {
+ unsigned char *sha1 = parent->object.sha1;
+ struct commit_list *parents;
+ for (parents = *parents_p; parents; parents = parents->next) {
+ if (parents->item == parent) {
error("duplicate parent %s ignored", sha1_to_hex(sha1));
- return 0;
+ return;
}
+ parents_p = &parents->next;
}
- return 1;
+ commit_list_insert(parent, parents_p);
}
static const char commit_utf8_warn[] =
@@ -51,51 +45,32 @@ static const char commit_utf8_warn[] =
"You may want to amend it after fixing the message, or set the config\n"
"variable i18n.commitencoding to the encoding your project uses.\n";
-int cmd_commit_tree(int argc, const char **argv, const char *prefix)
+int commit_tree(const char *msg, unsigned char *tree,
+ struct commit_list *parents, unsigned char *ret)
{
- int i;
- int parents = 0;
- unsigned char tree_sha1[20];
- unsigned char commit_sha1[20];
- struct strbuf buffer;
int encoding_is_utf8;
+ struct strbuf buffer;
- git_config(git_default_config);
-
- if (argc < 2)
- usage(commit_tree_usage);
- if (get_sha1(argv[1], tree_sha1))
- die("Not a valid object name %s", argv[1]);
-
- check_valid(tree_sha1, OBJ_TREE);
- for (i = 2; i < argc; i += 2) {
- const char *a, *b;
- a = argv[i]; b = argv[i+1];
- if (!b || strcmp(a, "-p"))
- usage(commit_tree_usage);
-
- if (parents >= MAXPARENT)
- die("Too many parents (%d max)", MAXPARENT);
- if (get_sha1(b, parent_sha1[parents]))
- die("Not a valid object name %s", b);
- check_valid(parent_sha1[parents], OBJ_COMMIT);
- if (new_parent(parents))
- parents++;
- }
+ check_valid(tree, OBJ_TREE);
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
strbuf_init(&buffer, 8192); /* should avoid reallocs for the headers */
- strbuf_addf(&buffer, "tree %s\n", sha1_to_hex(tree_sha1));
+ strbuf_addf(&buffer, "tree %s\n", sha1_to_hex(tree));
/*
* NOTE! This ordering means that the same exact tree merged with a
* different order of parents will be a _different_ changeset even
* if everything else stays the same.
*/
- for (i = 0; i < parents; i++)
- strbuf_addf(&buffer, "parent %s\n", sha1_to_hex(parent_sha1[i]));
+ while (parents) {
+ struct commit_list *next = parents->next;
+ strbuf_addf(&buffer, "parent %s\n",
+ sha1_to_hex(parents->item->object.sha1));
+ free(parents);
+ parents = next;
+ }
/* Person/date information */
strbuf_addf(&buffer, "author %s\n", git_author_info(IDENT_ERROR_ON_NO_NAME));
@@ -105,14 +80,47 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
strbuf_addch(&buffer, '\n');
/* And add the comment */
- if (strbuf_read(&buffer, 0, 0) < 0)
- die("git-commit-tree: read returned %s", strerror(errno));
+ strbuf_addstr(&buffer, msg);
/* And check the encoding */
if (encoding_is_utf8 && !is_utf8(buffer.buf))
fprintf(stderr, commit_utf8_warn);
- if (!write_sha1_file(buffer.buf, buffer.len, commit_type, commit_sha1)) {
+ return write_sha1_file(buffer.buf, buffer.len, commit_type, ret);
+}
+
+int cmd_commit_tree(int argc, const char **argv, const char *prefix)
+{
+ int i;
+ struct commit_list *parents = NULL;
+ unsigned char tree_sha1[20];
+ unsigned char commit_sha1[20];
+ struct strbuf buffer = STRBUF_INIT;
+
+ git_config(git_default_config, NULL);
+
+ if (argc < 2)
+ usage(commit_tree_usage);
+ if (get_sha1(argv[1], tree_sha1))
+ die("Not a valid object name %s", argv[1]);
+
+ for (i = 2; i < argc; i += 2) {
+ unsigned char sha1[20];
+ const char *a, *b;
+ a = argv[i]; b = argv[i+1];
+ if (!b || strcmp(a, "-p"))
+ usage(commit_tree_usage);
+
+ if (get_sha1(b, sha1))
+ die("Not a valid object name %s", b);
+ check_valid(sha1, OBJ_COMMIT);
+ new_parent(lookup_commit(sha1), &parents);
+ }
+
+ if (strbuf_read(&buffer, 0, 0) < 0)
+ die("git-commit-tree: read returned %s", strerror(errno));
+
+ if (!commit_tree(buffer.buf, tree_sha1, parents, commit_sha1)) {
printf("%s\n", sha1_to_hex(commit_sha1));
return 0;
}
diff --git a/builtin-commit.c b/builtin-commit.c
index 5b5b7c0f4..649c8beb3 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -7,6 +7,7 @@
#include "cache.h"
#include "cache-tree.h"
+#include "color.h"
#include "dir.h"
#include "builtin.h"
#include "diff.h"
@@ -20,16 +21,17 @@
#include "strbuf.h"
#include "utf8.h"
#include "parse-options.h"
-#include "path-list.h"
+#include "string-list.h"
+#include "rerere.h"
#include "unpack-trees.h"
static const char * const builtin_commit_usage[] = {
- "git-commit [options] [--] <filepattern>...",
+ "git commit [options] [--] <filepattern>...",
NULL
};
static const char * const builtin_status_usage[] = {
- "git-status [options] [--] <filepattern>...",
+ "git status [options] [--] <filepattern>...",
NULL
};
@@ -44,10 +46,13 @@ static enum {
COMMIT_PARTIAL,
} commit_style;
-static char *logfile, *force_author, *template_file;
+static const char *logfile, *force_author;
+static const char *template_file;
static char *edit_message, *use_message;
+static char *author_name, *author_email, *author_date;
static int all, edit_flag, also, interactive, only, amend, signoff;
-static int quiet, verbose, untracked_files, no_verify, allow_empty;
+static int quiet, verbose, no_verify, allow_empty;
+static char *untracked_files_arg;
/*
* The default commit message cleanup mode will remove the lines
* beginning with # (shell comments) and leading and trailing
@@ -63,8 +68,8 @@ static enum {
static char *cleanup_arg;
static int use_editor = 1, initial_commit, in_merge;
-const char *only_include_assumed;
-struct strbuf message;
+static const char *only_include_assumed;
+static struct strbuf message;
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
{
@@ -73,8 +78,7 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
strbuf_setlen(buf, 0);
else {
strbuf_addstr(buf, arg);
- strbuf_addch(buf, '\n');
- strbuf_addch(buf, '\n');
+ strbuf_addstr(buf, "\n\n");
}
return 0;
}
@@ -89,7 +93,7 @@ static struct option builtin_commit_options[] = {
OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m),
OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit "),
OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"),
- OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by: header"),
+ OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_STRING('t', "template", &template_file, "FILE", "use specified template file"),
OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
@@ -97,10 +101,10 @@ static struct option builtin_commit_options[] = {
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"),
OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
- OPT_BOOLEAN('o', "only", &only, ""),
+ OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
- OPT_BOOLEAN(0, "untracked-files", &untracked_files, "show all untracked files"),
+ { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
@@ -122,26 +126,30 @@ static void rollback_index_files(void)
}
}
-static void commit_index_files(void)
+static int commit_index_files(void)
{
+ int err = 0;
+
switch (commit_style) {
case COMMIT_AS_IS:
break; /* nothing to do */
case COMMIT_NORMAL:
- commit_lock_file(&index_lock);
+ err = commit_lock_file(&index_lock);
break;
case COMMIT_PARTIAL:
- commit_lock_file(&index_lock);
+ err = commit_lock_file(&index_lock);
rollback_lock_file(&false_lock);
break;
}
+
+ return err;
}
/*
* Take a union of paths in the index and the named tree (typically, "HEAD"),
* and return the paths that match the given pattern in list.
*/
-static int list_paths(struct path_list *list, const char *with_tree,
+static int list_paths(struct string_list *list, const char *with_tree,
const char *prefix, const char **pattern)
{
int i;
@@ -160,21 +168,24 @@ static int list_paths(struct path_list *list, const char *with_tree,
continue;
if (!pathspec_match(pattern, m, ce->name, 0))
continue;
- path_list_insert(ce->name, list);
+ string_list_insert(ce->name, list);
}
return report_path_error(m, pattern, prefix ? strlen(prefix) : 0);
}
-static void add_remove_files(struct path_list *list)
+static void add_remove_files(struct string_list *list)
{
int i;
for (i = 0; i < list->nr; i++) {
- struct path_list_item *p = &(list->items[i]);
- if (file_exists(p->path))
- add_file_to_cache(p->path, 0);
- else
- remove_file_from_cache(p->path);
+ struct stat st;
+ struct string_list_item *p = &(list->items[i]);
+
+ if (!lstat(p->string, &st)) {
+ if (add_to_cache(p->string, &st, 0))
+ die("updating files failed");
+ } else
+ remove_file_from_cache(p->string);
}
}
@@ -193,6 +204,8 @@ static void create_base_index(void)
opts.head_idx = 1;
opts.index_only = 1;
opts.merge = 1;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
opts.fn = oneway_merge;
tree = parse_tree_indirect(head_sha1);
@@ -207,11 +220,13 @@ static void create_base_index(void)
static char *prepare_index(int argc, const char **argv, const char *prefix)
{
int fd;
- struct path_list partial;
+ struct string_list partial;
const char **pathspec = NULL;
if (interactive) {
interactive_add(argc, argv, prefix);
+ if (read_cache() < 0)
+ die("index file corrupt");
commit_style = COMMIT_AS_IS;
return get_index_file();
}
@@ -236,7 +251,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
*/
if (all || (also && pathspec && *pathspec)) {
int fd = hold_locked_index(&index_lock, 1);
- add_files_to_cache(0, also ? prefix : NULL, pathspec);
+ add_files_to_cache(also ? prefix : NULL, pathspec, 0);
refresh_cache(REFRESH_QUIET);
if (write_cache(fd, active_cache, active_nr) ||
close_lock_file(&index_lock))
@@ -289,7 +304,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
die("cannot do a partial commit during a merge.");
memset(&partial, 0, sizeof(partial));
- partial.strdup_paths = 1;
+ partial.strdup_strings = 1;
if (list_paths(&partial, initial_commit ? NULL : "HEAD", prefix, pathspec))
exit(1);
@@ -314,6 +329,10 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
if (write_cache(fd, active_cache, active_nr) ||
close_lock_file(&false_lock))
die("unable to write temporary index file");
+
+ discard_cache();
+ read_cache_from(false_lock.filename);
+
return false_lock.filename;
}
@@ -330,7 +349,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
s.reference = "HEAD^1";
}
s.verbose = verbose;
- s.untracked = untracked_files;
+ s.untracked = (show_untracked_files == SHOW_ALL_UNTRACKED_FILES);
s.index_file = index_file;
s.fp = fp;
s.nowarn = nowarn;
@@ -340,48 +359,153 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
return s.commitable;
}
+static int run_hook(const char *index_file, const char *name, ...)
+{
+ struct child_process hook;
+ const char *argv[10], *env[2];
+ char index[PATH_MAX];
+ va_list args;
+ int i;
+
+ va_start(args, name);
+ argv[0] = git_path("hooks/%s", name);
+ i = 0;
+ do {
+ if (++i >= ARRAY_SIZE(argv))
+ die ("run_hook(): too many arguments");
+ argv[i] = va_arg(args, const char *);
+ } while (argv[i]);
+ va_end(args);
+
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
+ env[0] = index;
+ env[1] = NULL;
+
+ if (access(argv[0], X_OK) < 0)
+ return 0;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+ hook.env = env;
+
+ return run_command(&hook);
+}
+
+static int is_a_merge(const unsigned char *sha1)
+{
+ struct commit *commit = lookup_commit(sha1);
+ if (!commit || parse_commit(commit))
+ die("could not parse HEAD commit");
+ return !!(commit->parents && commit->parents->next);
+}
+
static const char sign_off_header[] = "Signed-off-by: ";
-static int prepare_log_message(const char *index_file, const char *prefix)
+static void determine_author_info(void)
+{
+ char *name, *email, *date;
+
+ name = getenv("GIT_AUTHOR_NAME");
+ email = getenv("GIT_AUTHOR_EMAIL");
+ date = getenv("GIT_AUTHOR_DATE");
+
+ if (use_message) {
+ const char *a, *lb, *rb, *eol;
+
+ a = strstr(use_message_buffer, "\nauthor ");
+ if (!a)
+ die("invalid commit: %s", use_message);
+
+ lb = strstr(a + 8, " <");
+ rb = strstr(a + 8, "> ");
+ eol = strchr(a + 8, '\n');
+ if (!lb || !rb || !eol)
+ die("invalid commit: %s", use_message);
+
+ name = xstrndup(a + 8, lb - (a + 8));
+ email = xstrndup(lb + 2, rb - (lb + 2));
+ date = xstrndup(rb + 2, eol - (rb + 2));
+ }
+
+ if (force_author) {
+ const char *lb = strstr(force_author, " <");
+ const char *rb = strchr(force_author, '>');
+
+ if (!lb || !rb)
+ die("malformed --author parameter");
+ name = xstrndup(force_author, lb - force_author);
+ email = xstrndup(lb + 2, rb - (lb + 2));
+ }
+
+ author_name = name;
+ author_email = email;
+ author_date = date;
+}
+
+static int prepare_to_commit(const char *index_file, const char *prefix)
{
struct stat statbuf;
int commitable, saved_color_setting;
struct strbuf sb;
char *buffer;
FILE *fp;
+ const char *hook_arg1 = NULL;
+ const char *hook_arg2 = NULL;
+ int ident_shown = 0;
+
+ if (!no_verify && run_hook(index_file, "pre-commit", NULL))
+ return 0;
strbuf_init(&sb, 0);
if (message.len) {
strbuf_addbuf(&sb, &message);
+ hook_arg1 = "message";
} else if (logfile && !strcmp(logfile, "-")) {
if (isatty(0))
fprintf(stderr, "(reading log message from standard input)\n");
if (strbuf_read(&sb, 0, 0) < 0)
die("could not read log from standard input");
+ hook_arg1 = "message";
} else if (logfile) {
if (strbuf_read_file(&sb, logfile, 0) < 0)
die("could not read log file '%s': %s",
logfile, strerror(errno));
+ hook_arg1 = "message";
} else if (use_message) {
buffer = strstr(use_message_buffer, "\n\n");
if (!buffer || buffer[2] == '\0')
die("commit has empty message");
strbuf_add(&sb, buffer + 2, strlen(buffer + 2));
+ hook_arg1 = "commit";
+ hook_arg2 = use_message;
} else if (!stat(git_path("MERGE_MSG"), &statbuf)) {
if (strbuf_read_file(&sb, git_path("MERGE_MSG"), 0) < 0)
die("could not read MERGE_MSG: %s", strerror(errno));
+ hook_arg1 = "merge";
} else if (!stat(git_path("SQUASH_MSG"), &statbuf)) {
if (strbuf_read_file(&sb, git_path("SQUASH_MSG"), 0) < 0)
die("could not read SQUASH_MSG: %s", strerror(errno));
+ hook_arg1 = "squash";
} else if (template_file && !stat(template_file, &statbuf)) {
if (strbuf_read_file(&sb, template_file, 0) < 0)
die("could not read %s: %s",
template_file, strerror(errno));
+ hook_arg1 = "template";
}
+ /*
+ * This final case does not modify the template message,
+ * it just sets the argument to the prepare-commit-msg hook.
+ */
+ else if (in_merge)
+ hook_arg1 = "merge";
+
fp = fopen(git_path(commit_editmsg), "w");
if (fp == NULL)
- die("could not open %s", git_path(commit_editmsg));
+ die("could not open %s: %s",
+ git_path(commit_editmsg), strerror(errno));
if (cleanup_mode != CLEANUP_NONE)
stripspace(&sb, 0);
@@ -410,13 +534,71 @@ static int prepare_log_message(const char *index_file, const char *prefix)
strbuf_release(&sb);
- if (!use_editor) {
+ determine_author_info();
+
+ /* This checks if committer ident is explicitly given */
+ git_committer_info(0);
+ if (use_editor) {
+ char *author_ident;
+ const char *committer_ident;
+
+ if (in_merge)
+ fprintf(fp,
+ "#\n"
+ "# It looks like you may be committing a MERGE.\n"
+ "# If this is not correct, please remove the file\n"
+ "# %s\n"
+ "# and try again.\n"
+ "#\n",
+ git_path("MERGE_HEAD"));
+
+ fprintf(fp,
+ "\n"
+ "# Please enter the commit message for your changes.");
+ if (cleanup_mode == CLEANUP_ALL)
+ fprintf(fp,
+ " Lines starting\n"
+ "# with '#' will be ignored, and an empty"
+ " message aborts the commit.\n");
+ else /* CLEANUP_SPACE, that is. */
+ fprintf(fp,
+ " Lines starting\n"
+ "# with '#' will be kept; you may remove them"
+ " yourself if you want to.\n"
+ "# An empty message aborts the commit.\n");
+ if (only_include_assumed)
+ fprintf(fp, "# %s\n", only_include_assumed);
+
+ author_ident = xstrdup(fmt_name(author_name, author_email));
+ committer_ident = fmt_name(getenv("GIT_COMMITTER_NAME"),
+ getenv("GIT_COMMITTER_EMAIL"));
+ if (strcmp(author_ident, committer_ident))
+ fprintf(fp,
+ "%s"
+ "# Author: %s\n",
+ ident_shown++ ? "" : "#\n",
+ author_ident);
+ free(author_ident);
+
+ if (!user_ident_explicitly_given)
+ fprintf(fp,
+ "%s"
+ "# Committer: %s\n",
+ ident_shown++ ? "" : "#\n",
+ committer_ident);
+
+ if (ident_shown)
+ fprintf(fp, "#\n");
+
+ saved_color_setting = wt_status_use_color;
+ wt_status_use_color = 0;
+ commitable = run_status(fp, index_file, prefix, 1);
+ wt_status_use_color = saved_color_setting;
+ } else {
struct rev_info rev;
unsigned char sha1[20];
const char *parent = "HEAD";
- fclose(fp);
-
if (!active_nr && read_cache() < 0)
die("Cannot read index");
@@ -424,48 +606,64 @@ static int prepare_log_message(const char *index_file, const char *prefix)
parent = "HEAD^1";
if (get_sha1(parent, sha1))
- return !!active_nr;
+ commitable = !!active_nr;
+ else {
+ init_revisions(&rev, "");
+ rev.abbrev = 0;
+ setup_revisions(0, NULL, &rev, parent);
+ DIFF_OPT_SET(&rev.diffopt, QUIET);
+ DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
+ run_diff_index(&rev, 1 /* cached */);
+
+ commitable = !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
+ }
+ }
- init_revisions(&rev, "");
- rev.abbrev = 0;
- setup_revisions(0, NULL, &rev, parent);
- DIFF_OPT_SET(&rev.diffopt, QUIET);
- DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
- run_diff_index(&rev, 1 /* cached */);
+ fclose(fp);
- return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
+ if (!commitable && !in_merge && !allow_empty &&
+ !(amend && is_a_merge(head_sha1))) {
+ run_status(stdout, index_file, prefix, 0);
+ unlink(commit_editmsg);
+ return 0;
}
- if (in_merge)
- fprintf(fp,
- "#\n"
- "# It looks like you may be committing a MERGE.\n"
- "# If this is not correct, please remove the file\n"
- "# %s\n"
- "# and try again.\n"
- "#\n",
- git_path("MERGE_HEAD"));
-
- fprintf(fp,
- "\n"
- "# Please enter the commit message for your changes.\n"
- "# (Comment lines starting with '#' will ");
- if (cleanup_mode == CLEANUP_ALL)
- fprintf(fp, "not be included)\n");
- else /* CLEANUP_SPACE, that is. */
- fprintf(fp, "be kept.\n"
- "# You can remove them yourself if you want to)\n");
- if (only_include_assumed)
- fprintf(fp, "# %s\n", only_include_assumed);
-
- saved_color_setting = wt_status_use_color;
- wt_status_use_color = 0;
- commitable = run_status(fp, index_file, prefix, 1);
- wt_status_use_color = saved_color_setting;
+ /*
+ * Re-read the index as pre-commit hook could have updated it,
+ * and write it out as a tree. We must do this before we invoke
+ * the editor and after we invoke run_status above.
+ */
+ discard_cache();
+ read_cache_from(index_file);
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+ if (cache_tree_update(active_cache_tree,
+ active_cache, active_nr, 0, 0) < 0) {
+ error("Error building trees");
+ return 0;
+ }
- fclose(fp);
+ if (run_hook(index_file, "prepare-commit-msg",
+ git_path(commit_editmsg), hook_arg1, hook_arg2, NULL))
+ return 0;
+
+ if (use_editor) {
+ char index[PATH_MAX];
+ const char *env[2] = { index, NULL };
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
+ if (launch_editor(git_path(commit_editmsg), NULL, env)) {
+ fprintf(stderr,
+ "Please supply the message using either -m or -F option.\n");
+ exit(1);
+ }
+ }
- return commitable;
+ if (!no_verify &&
+ run_hook(index_file, "commit-msg", git_path(commit_editmsg), NULL)) {
+ return 0;
+ }
+
+ return 1;
}
/*
@@ -512,56 +710,22 @@ static int message_is_empty(struct strbuf *sb, int start)
return 1;
}
-static void determine_author_info(struct strbuf *sb)
-{
- char *name, *email, *date;
-
- name = getenv("GIT_AUTHOR_NAME");
- email = getenv("GIT_AUTHOR_EMAIL");
- date = getenv("GIT_AUTHOR_DATE");
-
- if (use_message) {
- const char *a, *lb, *rb, *eol;
-
- a = strstr(use_message_buffer, "\nauthor ");
- if (!a)
- die("invalid commit: %s", use_message);
-
- lb = strstr(a + 8, " <");
- rb = strstr(a + 8, "> ");
- eol = strchr(a + 8, '\n');
- if (!lb || !rb || !eol)
- die("invalid commit: %s", use_message);
-
- name = xstrndup(a + 8, lb - (a + 8));
- email = xstrndup(lb + 2, rb - (lb + 2));
- date = xstrndup(rb + 2, eol - (rb + 2));
- }
-
- if (force_author) {
- const char *lb = strstr(force_author, " <");
- const char *rb = strchr(force_author, '>');
-
- if (!lb || !rb)
- die("malformed --author parameter");
- name = xstrndup(force_author, lb - force_author);
- email = xstrndup(lb + 2, rb - (lb + 2));
- }
-
- strbuf_addf(sb, "author %s\n", fmt_ident(name, email, date, IDENT_ERROR_ON_NO_NAME));
-}
-
static int parse_and_validate_options(int argc, const char *argv[],
- const char * const usage[])
+ const char * const usage[],
+ const char *prefix)
{
int f = 0;
argc = parse_options(argc, argv, builtin_commit_options, usage, 0);
+ logfile = parse_options_fix_filename(prefix, logfile);
+ template_file = parse_options_fix_filename(prefix, template_file);
if (logfile || message.len || use_message)
use_editor = 0;
if (edit_flag)
use_editor = 1;
+ if (!use_editor)
+ setenv("GIT_EDITOR", ":", 1);
if (get_sha1("HEAD", head_sha1))
initial_commit = 1;
@@ -598,7 +762,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (get_sha1(use_message, sha1))
die("could not lookup commit %s", use_message);
- commit = lookup_commit(sha1);
+ commit = lookup_commit_reference(sha1);
if (!commit || parse_commit(commit))
die("could not parse commit %s", use_message);
@@ -633,10 +797,8 @@ static int parse_and_validate_options(int argc, const char *argv[],
die("No paths with --include/--only does not make sense.");
if (argc == 0 && only && amend)
only_include_assumed = "Clever... amending the last one with dirty index.";
- if (argc > 0 && !also && !only) {
+ if (argc > 0 && !also && !only)
only_include_assumed = "Explicit paths specified without -i nor -o; assuming --only paths...";
- also = 0;
- }
if (!cleanup_arg || !strcmp(cleanup_arg, "default"))
cleanup_mode = use_editor ? CLEANUP_ALL : CLEANUP_SPACE;
else if (!strcmp(cleanup_arg, "verbatim"))
@@ -648,6 +810,17 @@ static int parse_and_validate_options(int argc, const char *argv[],
else
die("Invalid cleanup mode %s", cleanup_arg);
+ if (!untracked_files_arg)
+ ; /* default already initialized */
+ else if (!strcmp(untracked_files_arg, "no"))
+ show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ else if (!strcmp(untracked_files_arg, "normal"))
+ show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ else if (!strcmp(untracked_files_arg, "all"))
+ show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ else
+ die("Invalid untracked files mode '%s'", untracked_files_arg);
+
if (all && argc > 0)
die("Paths with -a does not make sense.");
else if (interactive && argc > 0)
@@ -661,9 +834,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
const char *index_file;
int commitable;
- git_config(git_status_config);
+ git_config(git_status_config, NULL);
+
+ if (wt_status_use_color == -1)
+ wt_status_use_color = git_use_color_default;
- argc = parse_and_validate_options(argc, argv, builtin_status_usage);
+ argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
index_file = prepare_index(argc, argv, prefix);
@@ -674,31 +850,6 @@ int cmd_status(int argc, const char **argv, const char *prefix)
return commitable ? 0 : 1;
}
-static int run_hook(const char *index_file, const char *name, const char *arg)
-{
- struct child_process hook;
- const char *argv[3], *env[2];
- char index[PATH_MAX];
-
- argv[0] = git_path("hooks/%s", name);
- argv[1] = arg;
- argv[2] = NULL;
- snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
- env[0] = index;
- env[1] = NULL;
-
- if (access(argv[0], X_OK) < 0)
- return 0;
-
- memset(&hook, 0, sizeof(hook));
- hook.argv = argv;
- hook.no_stdin = 1;
- hook.stdout_to_stderr = 1;
- hook.env = env;
-
- return run_command(&hook);
-}
-
static void print_summary(const char *prefix, const unsigned char *sha1)
{
struct rev_info rev;
@@ -720,7 +871,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
rev.verbose_header = 1;
rev.show_root_diff = 1;
- rev.commit_format = get_commit_format("format:%h: %s");
+ get_commit_format("format:%h: %s", &rev);
rev.always_show_header = 0;
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 100;
@@ -737,22 +888,12 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
}
}
-int git_commit_config(const char *k, const char *v)
+static int git_commit_config(const char *k, const char *v, void *cb)
{
- if (!strcmp(k, "commit.template")) {
- template_file = xstrdup(v);
- return 0;
- }
-
- return git_status_config(k, v);
-}
+ if (!strcmp(k, "commit.template"))
+ return git_config_string(&template_file, k, v);
-static int is_a_merge(const unsigned char *sha1)
-{
- struct commit *commit = lookup_commit(sha1);
- if (!commit || parse_commit(commit))
- die("could not parse HEAD commit");
- return !!(commit->parents && commit->parents->next);
+ return git_status_config(k, v, cb);
}
static const char commit_utf8_warn[] =
@@ -764,10 +905,19 @@ static void add_parent(struct strbuf *sb, const unsigned char *sha1)
{
struct object *obj = parse_object(sha1);
const char *parent = sha1_to_hex(sha1);
+ const char *cp;
+
if (!obj)
die("Unable to find commit parent %s", parent);
if (obj->type != OBJ_COMMIT)
die("Parent %s isn't a proper commit", parent);
+
+ for (cp = sb->buf; cp && (cp = strstr(cp, "\nparent ")); cp += 8) {
+ if (!memcmp(cp + 8, parent, 40) && cp[48] == '\n') {
+ error("duplicate parent %s ignored", parent);
+ return;
+ }
+ }
strbuf_addf(sb, "parent %s\n", parent);
}
@@ -780,39 +930,19 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
- git_config(git_commit_config);
+ git_config(git_commit_config, NULL);
- argc = parse_and_validate_options(argc, argv, builtin_commit_usage);
+ argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
index_file = prepare_index(argc, argv, prefix);
- if (!no_verify && run_hook(index_file, "pre-commit", NULL)) {
+ /* Set up everything for writing the commit object. This includes
+ running hooks, writing the trees, and interacting with the user. */
+ if (!prepare_to_commit(index_file, prefix)) {
rollback_index_files();
return 1;
}
- if (!prepare_log_message(index_file, prefix) && !in_merge &&
- !allow_empty && !(amend && is_a_merge(head_sha1))) {
- run_status(stdout, index_file, prefix, 0);
- rollback_index_files();
- unlink(commit_editmsg);
- return 1;
- }
-
- /*
- * Re-read the index as pre-commit hook could have updated it,
- * and write it out as a tree.
- */
- discard_cache();
- read_cache_from(index_file);
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
- if (cache_tree_update(active_cache_tree,
- active_cache, active_nr, 0, 0) < 0) {
- rollback_index_files();
- die("Error building trees");
- }
-
/*
* The commit object
*/
@@ -858,25 +988,15 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
strbuf_addf(&sb, "parent %s\n", sha1_to_hex(head_sha1));
}
- determine_author_info(&sb);
+ strbuf_addf(&sb, "author %s\n",
+ fmt_ident(author_name, author_email, author_date, IDENT_ERROR_ON_NO_NAME));
strbuf_addf(&sb, "committer %s\n", git_committer_info(IDENT_ERROR_ON_NO_NAME));
if (!is_encoding_utf8(git_commit_encoding))
strbuf_addf(&sb, "encoding %s\n", git_commit_encoding);
strbuf_addch(&sb, '\n');
- /* Get the commit message and validate it */
+ /* Finally, get the commit message */
header_len = sb.len;
- if (use_editor) {
- char index[PATH_MAX];
- const char *env[2] = { index, NULL };
- snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
- launch_editor(git_path(commit_editmsg), NULL, env);
- }
- if (!no_verify &&
- run_hook(index_file, "commit-msg", git_path(commit_editmsg))) {
- rollback_index_files();
- exit(1);
- }
if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
rollback_index_files();
die("could not read commit message");
@@ -891,7 +1011,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
stripspace(&sb, cleanup_mode == CLEANUP_ALL);
if (sb.len < header_len || message_is_empty(&sb, header_len)) {
rollback_index_files();
- die("no commit message? aborting commit.");
+ fprintf(stderr, "Aborting commit due to empty commit message.\n");
+ exit(1);
}
strbuf_addch(&sb, '\0');
if (is_encoding_utf8(git_commit_encoding) && !is_utf8(sb.buf))
@@ -926,8 +1047,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
+ unlink(git_path("SQUASH_MSG"));
- commit_index_files();
+ if (commit_index_files())
+ die ("Repository has been updated, but unable to write\n"
+ "new_index file. Check that disk is not full or quota is\n"
+ "not exceeded, and then \"git reset HEAD\" to recover.");
rerere();
run_hook(get_index_file(), "post-commit", NULL);
diff --git a/builtin-config.c b/builtin-config.c
index e4a12e316..91fdc4985 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -3,7 +3,7 @@
#include "color.h"
static const char git_config_set_usage[] =
-"git-config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
+"git config [ --global | --system | [ -f | --file ] config-file ] [ --bool | --int | --bool-or-int ] [ -z | --null ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --remove-section name | --list | --get-color var [default] | --get-colorbool name [stdout-is-tty]";
static char *key;
static regex_t *key_regexp;
@@ -16,9 +16,9 @@ static int seen;
static char delim = '=';
static char key_delim = ' ';
static char term = '\n';
-static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
+static enum { T_RAW, T_INT, T_BOOL, T_BOOL_OR_INT } type = T_RAW;
-static int show_all_config(const char *key_, const char *value_)
+static int show_all_config(const char *key_, const char *value_, void *cb)
{
if (value_)
printf("%s%c%s%c", key_, delim, value_, term);
@@ -27,7 +27,7 @@ static int show_all_config(const char *key_, const char *value_)
return 0;
}
-static int show_config(const char* key_, const char* value_)
+static int show_config(const char* key_, const char* value_, void *cb)
{
char value[256];
const char *vptr = value;
@@ -53,6 +53,14 @@ static int show_config(const char* key_, const char* value_)
sprintf(value, "%d", git_config_int(key_, value_?value_:""));
else if (type == T_BOOL)
vptr = git_config_bool(key_, value_) ? "true" : "false";
+ else if (type == T_BOOL_OR_INT) {
+ int is_bool, v;
+ v = git_config_bool_or_int(key_, value_, &is_bool);
+ if (is_bool)
+ vptr = v ? "true" : "false";
+ else
+ sprintf(value, "%d", v);
+ }
else
vptr = value_?value_:"";
seen++;
@@ -73,15 +81,14 @@ static int get_value(const char* key_, const char* regex_)
char *global = NULL, *repo_config = NULL;
const char *system_wide = NULL, *local;
- local = getenv(CONFIG_ENVIRONMENT);
+ local = config_exclusive_filename;
if (!local) {
const char *home = getenv("HOME");
- local = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!local)
- local = repo_config = xstrdup(git_path("config"));
- if (home)
+ local = repo_config = xstrdup(git_path("config"));
+ if (git_config_global() && home)
global = xstrdup(mkpath("%s/.gitconfig", home));
- system_wide = git_etc_gitconfig();
+ if (git_config_system())
+ system_wide = git_etc_gitconfig();
}
key = xstrdup(key_);
@@ -112,14 +119,14 @@ static int get_value(const char* key_, const char* regex_)
}
if (do_all && system_wide)
- git_config_from_file(show_config, system_wide);
+ git_config_from_file(show_config, system_wide, NULL);
if (do_all && global)
- git_config_from_file(show_config, global);
- git_config_from_file(show_config, local);
+ git_config_from_file(show_config, global, NULL);
+ git_config_from_file(show_config, local, NULL);
if (!do_all && !seen && global)
- git_config_from_file(show_config, global);
+ git_config_from_file(show_config, global, NULL);
if (!do_all && !seen && system_wide)
- git_config_from_file(show_config, system_wide);
+ git_config_from_file(show_config, system_wide, NULL);
free(key);
if (regexp) {
@@ -138,7 +145,7 @@ free_strings:
return ret;
}
-char *normalize_value(const char *key, const char *value)
+static char *normalize_value(const char *key, const char *value)
{
char *normalized;
@@ -156,6 +163,14 @@ char *normalize_value(const char *key, const char *value)
else if (type == T_BOOL)
sprintf(normalized, "%s",
git_config_bool(key, value) ? "true" : "false");
+ else if (type == T_BOOL_OR_INT) {
+ int is_bool, v;
+ v = git_config_bool_or_int(key, value, &is_bool);
+ if (!is_bool)
+ sprintf(normalized, "%d", v);
+ else
+ sprintf(normalized, "%s", v ? "true" : "false");
+ }
}
return normalized;
@@ -165,9 +180,11 @@ static int get_color_found;
static const char *get_color_slot;
static char parsed_color[COLOR_MAXLEN];
-static int git_get_color_config(const char *var, const char *value)
+static int git_get_color_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, get_color_slot)) {
+ if (!value)
+ config_error_nonbool(var);
color_parse(value, var, parsed_color);
get_color_found = 1;
}
@@ -199,7 +216,7 @@ static int get_color(int argc, const char **argv)
get_color_found = 0;
parsed_color[0] = '\0';
- git_config(git_get_color_config);
+ git_config(git_get_color_config, NULL);
if (!get_color_found && def_color)
color_parse(def_color, "command line", parsed_color);
@@ -211,7 +228,8 @@ static int get_color(int argc, const char **argv)
static int stdout_is_tty;
static int get_colorbool_found;
static int get_diff_color_found;
-static int git_get_colorbool_config(const char *var, const char *value)
+static int git_get_colorbool_config(const char *var, const char *value,
+ void *cb)
{
if (!strcmp(var, get_color_slot)) {
get_colorbool_found =
@@ -221,6 +239,10 @@ static int git_get_colorbool_config(const char *var, const char *value)
get_diff_color_found =
git_config_colorbool(var, value, stdout_is_tty);
}
+ if (!strcmp(var, "color.ui")) {
+ git_use_color_default = git_config_colorbool(var, value, stdout_is_tty);
+ return 0;
+ }
return 0;
}
@@ -242,13 +264,13 @@ static int get_colorbool(int argc, const char **argv)
get_colorbool_found = -1;
get_diff_color_found = -1;
get_color_slot = argv[0];
- git_config(git_get_colorbool_config);
+ git_config(git_get_colorbool_config, NULL);
if (get_colorbool_found < 0) {
if (!strcmp(get_color_slot, "color.diff"))
get_colorbool_found = get_diff_color_found;
if (get_colorbool_found < 0)
- get_colorbool_found = 0;
+ get_colorbool_found = git_use_color_default;
}
if (argc == 1) {
@@ -261,19 +283,24 @@ static int get_colorbool(int argc, const char **argv)
int cmd_config(int argc, const char **argv, const char *prefix)
{
- int nongit = 0;
+ int nongit;
char* value;
const char *file = setup_git_directory_gently(&nongit);
+ config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
+
while (1 < argc) {
if (!strcmp(argv[1], "--int"))
type = T_INT;
else if (!strcmp(argv[1], "--bool"))
type = T_BOOL;
+ else if (!strcmp(argv[1], "--bool-or-int"))
+ type = T_BOOL_OR_INT;
else if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l")) {
if (argc != 2)
usage(git_config_set_usage);
- if (git_config(show_all_config) < 0 && file && errno)
+ if (git_config(show_all_config, NULL) < 0 &&
+ file && errno)
die("unable to read config file %s: %s", file,
strerror(errno));
return 0;
@@ -282,14 +309,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
char *home = getenv("HOME");
if (home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
- setenv(CONFIG_ENVIRONMENT, user_config, 1);
- free(user_config);
+ config_exclusive_filename = user_config;
} else {
die("$HOME not set");
}
}
else if (!strcmp(argv[1], "--system"))
- setenv(CONFIG_ENVIRONMENT, git_etc_gitconfig(), 1);
+ config_exclusive_filename = git_etc_gitconfig();
else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
if (argc < 3)
usage(git_config_set_usage);
@@ -298,7 +324,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
argv[2]);
else
file = argv[2];
- setenv(CONFIG_ENVIRONMENT, file, 1);
+ config_exclusive_filename = file;
argc--;
argv++;
}
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index f00306fb6..91b548747 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -67,7 +67,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
}
static char const * const count_objects_usage[] = {
- "git-count-objects [-v]",
+ "git count-objects [-v]",
NULL
};
diff --git a/builtin-describe.c b/builtin-describe.c
index 7a148a2c2..ec404c839 100644
--- a/builtin-describe.c
+++ b/builtin-describe.c
@@ -10,18 +10,23 @@
#define MAX_TAGS (FLAG_BITS - 1)
static const char * const describe_usage[] = {
- "git-describe [options] <committish>*",
+ "git describe [options] <committish>*",
NULL
};
static int debug; /* Display lots of verbose info */
static int all; /* Default to annotated tags only */
static int tags; /* But allow any tags if --tags is specified */
+static int longformat;
static int abbrev = DEFAULT_ABBREV;
static int max_candidates = 10;
+static const char *pattern;
+static int always;
struct commit_name {
+ struct tag *tag;
int prio; /* annotated tag = 2, tag = 1, head = 0 */
+ unsigned char sha1[20];
char path[FLEX_ARRAY]; /* more */
};
static const char *prio_names[] = {
@@ -30,14 +35,17 @@ static const char *prio_names[] = {
static void add_to_known_names(const char *path,
struct commit *commit,
- int prio)
+ int prio,
+ const unsigned char *sha1)
{
struct commit_name *e = commit->util;
if (!e || e->prio < prio) {
size_t len = strlen(path)+1;
free(e);
e = xmalloc(sizeof(struct commit_name) + len);
+ e->tag = NULL;
e->prio = prio;
+ hashcpy(e->sha1, sha1);
memcpy(e->path, path, len);
commit->util = e;
}
@@ -45,22 +53,40 @@ static void add_to_known_names(const char *path,
static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
- struct commit *commit = lookup_commit_reference_gently(sha1, 1);
+ int might_be_tag = !prefixcmp(path, "refs/tags/");
+ struct commit *commit;
struct object *object;
- int prio;
+ unsigned char peeled[20];
+ int is_tag, prio;
- if (!commit)
+ if (!all && !might_be_tag)
return 0;
- object = parse_object(sha1);
+
+ if (!peel_ref(path, peeled) && !is_null_sha1(peeled)) {
+ commit = lookup_commit_reference_gently(peeled, 1);
+ if (!commit)
+ return 0;
+ is_tag = !!hashcmp(sha1, commit->object.sha1);
+ } else {
+ commit = lookup_commit_reference_gently(sha1, 1);
+ object = parse_object(sha1);
+ if (!commit || !object)
+ return 0;
+ is_tag = object->type == OBJ_TAG;
+ }
+
/* If --all, then any refs are used.
* If --tags, then any tags are used.
* Otherwise only annotated tags are used.
*/
- if (!prefixcmp(path, "refs/tags/")) {
- if (object->type == OBJ_TAG)
+ if (might_be_tag) {
+ if (is_tag)
prio = 2;
else
prio = 1;
+
+ if (pattern && fnmatch(pattern, path + 10, 0))
+ prio = 0;
}
else
prio = 0;
@@ -71,7 +97,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
if (!tags && prio < 2)
return 0;
}
- add_to_known_names(all ? path + 5 : path + 10, commit, prio);
+ add_to_known_names(all ? path + 5 : path + 10, commit, prio, sha1);
return 0;
}
@@ -128,6 +154,27 @@ static unsigned long finish_depth_computation(
return seen_commits;
}
+static void display_name(struct commit_name *n)
+{
+ if (n->prio == 2 && !n->tag) {
+ n->tag = lookup_tag(n->sha1);
+ if (!n->tag || parse_tag(n->tag) || !n->tag->tag)
+ die("annotated tag %s not available", n->path);
+ if (strcmp(n->tag->tag, n->path))
+ warning("tag '%s' is really '%s' here", n->tag->tag, n->path);
+ }
+
+ if (n->tag)
+ printf("%s", n->tag->tag);
+ else
+ printf("%s", n->path);
+}
+
+static void show_suffix(int depth, const unsigned char *sha1)
+{
+ printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev));
+}
+
static void describe(const char *arg, int last_one)
{
unsigned char sha1[20];
@@ -152,10 +199,18 @@ static void describe(const char *arg, int last_one)
n = cmit->util;
if (n) {
- printf("%s\n", n->path);
+ /*
+ * Exact match to an existing ref.
+ */
+ display_name(n);
+ if (longformat)
+ show_suffix(0, n->tag ? n->tag->tagged->sha1 : sha1);
+ printf("\n");
return;
}
+ if (!max_candidates)
+ die("no tag exactly matches '%s'", sha1_to_hex(cmit->object.sha1));
if (debug)
fprintf(stderr, "searching to describe %s\n", arg);
@@ -204,8 +259,14 @@ static void describe(const char *arg, int last_one)
}
}
- if (!match_cnt)
- die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
+ if (!match_cnt) {
+ const unsigned char *sha1 = cmit->object.sha1;
+ if (always) {
+ printf("%s\n", find_unique_abbrev(sha1, abbrev));
+ return;
+ }
+ die("cannot describe '%s'", sha1_to_hex(sha1));
+ }
qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);
@@ -232,12 +293,11 @@ static void describe(const char *arg, int last_one)
sha1_to_hex(gave_up_on->object.sha1));
}
}
- if (abbrev == 0)
- printf("%s\n", all_matches[0].name->path );
- else
- printf("%s-%d-g%s\n", all_matches[0].name->path,
- all_matches[0].depth,
- find_unique_abbrev(cmit->object.sha1, abbrev));
+
+ display_name(all_matches[0].name);
+ if (abbrev)
+ show_suffix(all_matches[0].depth, cmit->object.sha1);
+ printf("\n");
if (!last_one)
clear_commit_marks(cmit, -1);
@@ -251,27 +311,46 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN(0, "debug", &debug, "debug search strategy on stderr"),
OPT_BOOLEAN(0, "all", &all, "use any ref in .git/refs"),
OPT_BOOLEAN(0, "tags", &tags, "use any tag in .git/refs/tags"),
+ OPT_BOOLEAN(0, "long", &longformat, "always use long format"),
OPT__ABBREV(&abbrev),
+ OPT_SET_INT(0, "exact-match", &max_candidates,
+ "only output exact matches", 0),
OPT_INTEGER(0, "candidates", &max_candidates,
- "consider <n> most recent tags (default: 10)"),
+ "consider <n> most recent tags (default: 10)"),
+ OPT_STRING(0, "match", &pattern, "pattern",
+ "only consider tags matching <pattern>"),
+ OPT_BOOLEAN(0, "always", &always,
+ "show abbreviated commit object as fallback"),
OPT_END(),
};
argc = parse_options(argc, argv, options, describe_usage, 0);
- if (max_candidates < 1)
- max_candidates = 1;
+ if (max_candidates < 0)
+ max_candidates = 0;
else if (max_candidates > MAX_TAGS)
max_candidates = MAX_TAGS;
save_commit_buffer = 0;
+ if (longformat && abbrev == 0)
+ die("--long is incompatible with --abbrev=0");
+
if (contains) {
- const char **args = xmalloc((4 + argc) * sizeof(char*));
+ const char **args = xmalloc((7 + argc) * sizeof(char*));
int i = 0;
args[i++] = "name-rev";
args[i++] = "--name-only";
- if (!all)
+ args[i++] = "--no-undefined";
+ if (always)
+ args[i++] = "--always";
+ if (!all) {
args[i++] = "--tags";
+ if (pattern) {
+ char *s = xmalloc(strlen("--refs=refs/tags/") + strlen(pattern) + 1);
+ sprintf(s, "--refs=refs/tags/%s", pattern);
+ args[i++] = s;
+ }
+ }
memcpy(args + i, argv, argc * sizeof(char*));
args[i + argc] = NULL;
return cmd_name_rev(i + argc, args, prefix);
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 4abe3c28f..9bf10bb37 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -10,26 +10,54 @@
#include "builtin.h"
static const char diff_files_usage[] =
-"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|--no-index] [<common diff options>] [<path>...]"
+"git diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
int cmd_diff_files(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- int nongit = 0;
int result;
+ unsigned options = 0;
- prefix = setup_git_directory_gently(&nongit);
init_revisions(&rev, prefix);
- git_config(git_diff_basic_config); /* no "diff" UI options */
+ git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
- if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
- argc = 0;
- else
- argc = setup_revisions(argc, argv, &rev, NULL);
+ argc = setup_revisions(argc, argv, &rev, NULL);
+ while (1 < argc && argv[1][0] == '-') {
+ if (!strcmp(argv[1], "--base"))
+ rev.max_count = 1;
+ else if (!strcmp(argv[1], "--ours"))
+ rev.max_count = 2;
+ else if (!strcmp(argv[1], "--theirs"))
+ rev.max_count = 3;
+ else if (!strcmp(argv[1], "-q"))
+ options |= DIFF_SILENT_ON_REMOVED;
+ else
+ usage(diff_files_usage);
+ argv++; argc--;
+ }
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
- result = run_diff_files_cmd(&rev, argc, argv);
+
+ /*
+ * Make sure there are NO revision (i.e. pending object) parameter,
+ * rev.max_count is reasonable (0 <= n <= 3), and
+ * there is no other revision filtering parameters.
+ */
+ if (rev.pending.nr ||
+ rev.min_age != -1 || rev.max_age != -1 ||
+ 3 < rev.max_count)
+ usage(diff_files_usage);
+
+ if (rev.max_count == -1 &&
+ (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
+ rev.combine_merges = rev.dense_combined_merges = 1;
+
+ if (read_cache() < 0) {
+ perror("read_cache");
+ return -1;
+ }
+ result = run_diff_files(&rev, options);
return diff_result_code(&rev.diffopt, result);
}
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 2b955deb9..17d851b29 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -5,7 +5,7 @@
#include "builtin.h"
static const char diff_cache_usage[] =
-"git-diff-index [-m] [--cached] "
+"git diff-index [-m] [--cached] "
"[<common diff options>] <tree-ish> [<path>...]"
COMMON_DIFF_OPTIONS_HELP;
@@ -17,7 +17,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
int result;
init_revisions(&rev, prefix);
- git_config(git_diff_basic_config); /* no "diff" UI options */
+ git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
rev.abbrev = 0;
argc = setup_revisions(argc, argv, &rev, NULL);
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 832797ff3..415cb1612 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -53,7 +53,7 @@ static int diff_tree_stdin(char *line)
}
static const char diff_tree_usage[] =
-"git-diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
+"git diff-tree [--stdin] [-m] [-c] [--cc] [-s] [-v] [--pretty] [-t] [-r] [--root] "
"[<common diff options>] <tree-ish> [<tree-ish>] [<path>...]\n"
" -r diff recursively\n"
" --root include the initial commit as diff against /dev/null\n"
@@ -68,7 +68,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
int read_stdin = 0;
init_revisions(opt, prefix);
- git_config(git_diff_basic_config); /* no "diff" UI options */
+ git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
nr_sha1 = 0;
opt->abbrev = 0;
opt->diff = 1;
diff --git a/builtin-diff.c b/builtin-diff.c
index 8d7a5697f..7ffea9750 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -4,6 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
+#include "color.h"
#include "commit.h"
#include "blob.h"
#include "tag.h"
@@ -20,7 +21,7 @@ struct blobinfo {
};
static const char builtin_diff_usage[] =
-"git-diff <options> <rev>{0,2} -- <path>*";
+"git diff <options> <rev>{0,2} -- <path>*";
static void stuff_change(struct diff_options *opt,
unsigned old_mode, unsigned new_mode,
@@ -43,12 +44,17 @@ static void stuff_change(struct diff_options *opt,
tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;
tmp_c = old_name; old_name = new_name; new_name = tmp_c;
}
+
+ if (opt->prefix &&
+ (strncmp(old_name, opt->prefix, opt->prefix_length) ||
+ strncmp(new_name, opt->prefix, opt->prefix_length)))
+ return;
+
one = alloc_filespec(old_name);
two = alloc_filespec(new_name);
fill_filespec(one, old_sha1, old_mode);
fill_filespec(two, new_sha1, new_mode);
- /* NEEDSWORK: shouldn't this part of diffopt??? */
diff_queue(&diff_queued_diff, one, two);
}
@@ -196,6 +202,37 @@ static void refresh_index_quietly(void)
rollback_lock_file(lock_file);
}
+static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv)
+{
+ int result;
+ unsigned int options = 0;
+
+ while (1 < argc && argv[1][0] == '-') {
+ if (!strcmp(argv[1], "--base"))
+ revs->max_count = 1;
+ else if (!strcmp(argv[1], "--ours"))
+ revs->max_count = 2;
+ else if (!strcmp(argv[1], "--theirs"))
+ revs->max_count = 3;
+ else if (!strcmp(argv[1], "-q"))
+ options |= DIFF_SILENT_ON_REMOVED;
+ else
+ return error("invalid option: %s", argv[1]);
+ argv++; argc--;
+ }
+
+ if (revs->max_count == -1 &&
+ (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
+ revs->combine_merges = revs->dense_combined_merges = 1;
+
+ if (read_cache() < 0) {
+ perror("read_cache");
+ return -1;
+ }
+ result = run_diff_files(revs, options);
+ return diff_result_code(&revs->diffopt, result);
+}
+
int cmd_diff(int argc, const char **argv, const char *prefix)
{
int i;
@@ -204,7 +241,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
int ents = 0, blobs = 0, paths = 0;
const char *path = NULL;
struct blobinfo blob[2];
- int nongit = 0;
+ int nongit;
int result = 0;
/*
@@ -224,18 +261,29 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
* N=2, M=0:
* tree vs tree (diff-tree)
*
+ * N=0, M=0, P=2:
+ * compare two filesystem entities (aka --no-index).
+ *
* Other cases are errors.
*/
prefix = setup_git_directory_gently(&nongit);
- git_config(git_diff_ui_config);
+ git_config(git_diff_ui_config, NULL);
+
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
init_revisions(&rev, prefix);
+
+ /* If this is a no-index diff, just run it and exit there. */
+ diff_no_index(&rev, argc, argv, nongit, prefix);
+
+ /* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
- if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
- argc = 0;
- else
- argc = setup_revisions(argc, argv, &rev, NULL);
+ if (nongit)
+ die("Not a git repository");
+ argc = setup_revisions(argc, argv, &rev, NULL);
if (!rev.diffopt.output_format) {
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
if (diff_setup_done(&rev.diffopt) < 0)
@@ -248,10 +296,12 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
* If the user asked for our exit code then don't start a
* pager or we would end up reporting its exit code instead.
*/
- if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
+ if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS) &&
+ check_pager_config("diff") != 0)
setup_pager();
- /* Do we have --cached and not have a pending object, then
+ /*
+ * Do we have --cached and not have a pending object, then
* default to HEAD by hand. Eek.
*/
if (!rev.pending.nr) {
@@ -319,7 +369,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (!ents) {
switch (blobs) {
case 0:
- result = run_diff_files_cmd(&rev, argc, argv);
+ result = builtin_diff_files(&rev, argc, argv);
break;
case 1:
if (paths != 1)
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index ef27eee71..070971616 100755..100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -13,12 +13,12 @@
#include "log-tree.h"
#include "revision.h"
#include "decorate.h"
-#include "path-list.h"
+#include "string-list.h"
#include "utf8.h"
#include "parse-options.h"
static const char *fast_export_usage[] = {
- "git-fast-export [rev-list-opts]",
+ "git fast-export [rev-list-opts]",
NULL
};
@@ -56,10 +56,24 @@ static int has_unshown_parent(struct commit *commit)
}
/* Since intptr_t is C99, we do not use it here */
-static void mark_object(struct object *object)
+static inline uint32_t *mark_to_ptr(uint32_t mark)
{
- last_idnum++;
- add_decoration(&idnums, object, ((uint32_t *)NULL) + last_idnum);
+ return ((uint32_t *)NULL) + mark;
+}
+
+static inline uint32_t ptr_to_mark(void * mark)
+{
+ return (uint32_t *)mark - (uint32_t *)NULL;
+}
+
+static inline void mark_object(struct object *object, uint32_t mark)
+{
+ add_decoration(&idnums, object, mark_to_ptr(mark));
+}
+
+static inline void mark_next_object(struct object *object)
+{
+ mark_object(object, ++last_idnum);
}
static int get_object_mark(struct object *object)
@@ -67,7 +81,7 @@ static int get_object_mark(struct object *object)
void *decoration = lookup_decoration(&idnums, object);
if (!decoration)
return 0;
- return (uint32_t *)decoration - (uint32_t *)NULL;
+ return ptr_to_mark(decoration);
}
static void show_progress(void)
@@ -100,9 +114,9 @@ static void handle_object(const unsigned char *sha1)
if (!buf)
die ("Could not read blob %s", sha1_to_hex(sha1));
- mark_object(object);
+ mark_next_object(object);
- printf("blob\nmark :%d\ndata %lu\n", last_idnum, size);
+ printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
if (size && fwrite(buf, size, 1, stdout) != 1)
die ("Could not write blob %s", sha1_to_hex(sha1));
printf("\n");
@@ -118,13 +132,46 @@ static void show_filemodify(struct diff_queue_struct *q,
{
int i;
for (i = 0; i < q->nr; i++) {
+ struct diff_filespec *ospec = q->queue[i]->one;
struct diff_filespec *spec = q->queue[i]->two;
- if (is_null_sha1(spec->sha1))
+
+ switch (q->queue[i]->status) {
+ case DIFF_STATUS_DELETED:
printf("D %s\n", spec->path);
- else {
- struct object *object = lookup_object(spec->sha1);
- printf("M 0%06o :%d %s\n", spec->mode,
- get_object_mark(object), spec->path);
+ break;
+
+ case DIFF_STATUS_COPIED:
+ case DIFF_STATUS_RENAMED:
+ printf("%c \"%s\" \"%s\"\n", q->queue[i]->status,
+ ospec->path, spec->path);
+
+ if (!hashcmp(ospec->sha1, spec->sha1) &&
+ ospec->mode == spec->mode)
+ break;
+ /* fallthrough */
+
+ case DIFF_STATUS_TYPE_CHANGED:
+ case DIFF_STATUS_MODIFIED:
+ case DIFF_STATUS_ADDED:
+ /*
+ * Links refer to objects in another repositories;
+ * output the SHA-1 verbatim.
+ */
+ if (S_ISGITLINK(spec->mode))
+ printf("M %06o %s %s\n", spec->mode,
+ sha1_to_hex(spec->sha1), spec->path);
+ else {
+ struct object *object = lookup_object(spec->sha1);
+ printf("M %06o :%d %s\n", spec->mode,
+ get_object_mark(object), spec->path);
+ }
+ break;
+
+ default:
+ die("Unexpected comparison status '%c' for %s, %s",
+ q->queue[i]->status,
+ ospec->path ? ospec->path : "none",
+ spec->path ? spec->path : "none");
}
}
}
@@ -182,13 +229,17 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
diff_root_tree_sha1(commit->tree->object.sha1,
"", &rev->diffopt);
+ /* Export the referenced blobs, and remember the marks. */
for (i = 0; i < diff_queued_diff.nr; i++)
- handle_object(diff_queued_diff.queue[i]->two->sha1);
+ if (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))
+ handle_object(diff_queued_diff.queue[i]->two->sha1);
- mark_object(&commit->object);
+ mark_next_object(&commit->object);
if (!is_encoding_utf8(encoding))
reencoded = reencode_string(message, "UTF-8", encoding);
- printf("commit %s\nmark :%d\n%.*s\n%.*s\ndata %u\n%s",
+ if (!commit->parents)
+ printf("reset %s\n", (const char*)commit->util);
+ printf("commit %s\nmark :%"PRIu32"\n%.*s\n%.*s\ndata %u\n%s",
(const char *)commit->util, last_idnum,
(int)(author_end - author), author,
(int)(committer_end - committer), committer,
@@ -196,8 +247,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
? strlen(reencoded) : message
? strlen(message) : 0),
reencoded ? reencoded : message ? message : "");
- if (reencoded)
- free(reencoded);
+ free(reencoded);
for (i = 0, p = commit->parents; p; p = p->next) {
int mark = get_object_mark(&p->item->object);
@@ -205,14 +255,10 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
continue;
if (i == 0)
printf("from :%d\n", mark);
- else if (i == 1)
- printf("merge :%d", mark);
else
- printf(" :%d", mark);
+ printf("merge :%d\n", mark);
i++;
}
- if (i > 1)
- printf("\n");
log_tree_diff_flush(rev);
rev->diffopt.output_format = saved_output_format;
@@ -287,7 +333,7 @@ static void handle_tag(const char *name, struct tag *tag)
}
static void get_tags_and_duplicates(struct object_array *pending,
- struct path_list *extra_refs)
+ struct string_list *extra_refs)
{
struct tag *tag;
int i;
@@ -308,7 +354,7 @@ static void get_tags_and_duplicates(struct object_array *pending,
case OBJ_TAG:
tag = (struct tag *)e->item;
while (tag && tag->object.type == OBJ_TAG) {
- path_list_insert(full_name, extra_refs)->util = tag;
+ string_list_insert(full_name, extra_refs)->util = tag;
tag = (struct tag *)tag->tagged;
}
if (!tag)
@@ -328,19 +374,19 @@ static void get_tags_and_duplicates(struct object_array *pending,
}
if (commit->util)
/* more than one name for the same object */
- path_list_insert(full_name, extra_refs)->util = commit;
+ string_list_insert(full_name, extra_refs)->util = commit;
else
commit->util = full_name;
}
}
-static void handle_tags_and_duplicates(struct path_list *extra_refs)
+static void handle_tags_and_duplicates(struct string_list *extra_refs)
{
struct commit *commit;
int i;
for (i = extra_refs->nr - 1; i >= 0; i--) {
- const char *name = extra_refs->items[i].path;
+ const char *name = extra_refs->items[i].string;
struct object *object = extra_refs->items[i].util;
switch (object->type) {
case OBJ_TAG:
@@ -357,23 +403,90 @@ static void handle_tags_and_duplicates(struct path_list *extra_refs)
}
}
+static void export_marks(char *file)
+{
+ unsigned int i;
+ uint32_t mark;
+ struct object_decoration *deco = idnums.hash;
+ FILE *f;
+
+ f = fopen(file, "w");
+ if (!f)
+ error("Unable to open marks file %s for writing", file);
+
+ for (i = 0; i < idnums.size; i++) {
+ if (deco->base && deco->base->type == 1) {
+ mark = ptr_to_mark(deco->decoration);
+ fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1));
+ }
+ deco++;
+ }
+
+ if (ferror(f) || fclose(f))
+ error("Unable to write marks file %s.", file);
+}
+
+static void import_marks(char *input_file)
+{
+ char line[512];
+ FILE *f = fopen(input_file, "r");
+ if (!f)
+ die("cannot read %s: %s", input_file, strerror(errno));
+
+ while (fgets(line, sizeof(line), f)) {
+ uint32_t mark;
+ char *line_end, *mark_end;
+ unsigned char sha1[20];
+ struct object *object;
+
+ line_end = strchr(line, '\n');
+ if (line[0] != ':' || !line_end)
+ die("corrupt mark line: %s", line);
+ *line_end = '\0';
+
+ mark = strtoumax(line + 1, &mark_end, 10);
+ if (!mark || mark_end == line + 1
+ || *mark_end != ' ' || get_sha1(mark_end + 1, sha1))
+ die("corrupt mark line: %s", line);
+
+ object = parse_object(sha1);
+ if (!object)
+ die ("Could not read blob %s", sha1_to_hex(sha1));
+
+ if (object->flags & SHOWN)
+ error("Object %s already has a mark", sha1);
+
+ mark_object(object, mark);
+ if (last_idnum < mark)
+ last_idnum = mark;
+
+ object->flags |= SHOWN;
+ }
+ fclose(f);
+}
+
int cmd_fast_export(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
struct object_array commits = { 0, 0, NULL };
- struct path_list extra_refs = { NULL, 0, 0, 0 };
+ struct string_list extra_refs = { NULL, 0, 0, 0 };
struct commit *commit;
+ char *export_filename = NULL, *import_filename = NULL;
struct option options[] = {
OPT_INTEGER(0, "progress", &progress,
"show progress after <n> objects"),
OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, "mode",
"select handling of signed tags",
parse_opt_signed_tag_mode),
+ OPT_STRING(0, "export-marks", &export_filename, "FILE",
+ "Dump marks to this file"),
+ OPT_STRING(0, "import-marks", &import_filename, "FILE",
+ "Import marks from this file"),
OPT_END()
};
/* we handle encodings */
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
init_revisions(&revs, prefix);
argc = setup_revisions(argc, argv, &revs, NULL);
@@ -381,9 +494,13 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (argc > 1)
usage_with_options (fast_export_usage, options);
+ if (import_filename)
+ import_marks(import_filename);
+
get_tags_and_duplicates(&revs.pending, &extra_refs);
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
revs.diffopt.format_callback = show_filemodify;
DIFF_OPT_SET(&revs.diffopt, RECURSIVE);
while ((commit = get_revision(&revs))) {
@@ -402,5 +519,8 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
handle_tags_and_duplicates(&extra_refs);
+ if (export_filename)
+ export_marks(export_filename);
+
return 0;
}
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index e68e01592..273239af3 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -7,6 +7,7 @@
#include "pack.h"
#include "sideband.h"
#include "fetch-pack.h"
+#include "remote.h"
#include "run-command.h"
static int transfer_unpack_limit = -1;
@@ -17,7 +18,7 @@ static struct fetch_pack_args args = {
};
static const char fetch_pack_usage[] =
-"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
+"git fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--include-tag] [--upload-pack=<git-upload-pack>] [--depth=<n>] [--no-progress] [-v] [<host>:]<directory> [<refs>...]";
#define COMPLETE (1U << 0)
#define COMMON (1U << 1)
@@ -25,6 +26,8 @@ static const char fetch_pack_usage[] =
#define SEEN (1U << 3)
#define POPPED (1U << 4)
+static int marked;
+
/*
* After sending this many "have"s if we do not get any new ACK , we
* give up traversing our history.
@@ -40,7 +43,8 @@ static void rev_list_push(struct commit *commit, int mark)
commit->object.flags |= mark;
if (!(commit->object.parsed))
- parse_commit(commit);
+ if (parse_commit(commit))
+ return;
insert_by_date(commit, &rev_list);
@@ -59,6 +63,16 @@ static int rev_list_insert_ref(const char *path, const unsigned char *sha1, int
return 0;
}
+static int clear_marks(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+{
+ struct object *o = deref_tag(parse_object(sha1), path, 0);
+
+ if (o && o->type == OBJ_COMMIT)
+ clear_commit_marks((struct commit *)o,
+ COMMON | COMMON_REF | SEEN | POPPED);
+ return 0;
+}
+
/*
This function marks a rev and its ancestors as common.
In some cases, it is desirable to mark only the ancestors (for example
@@ -82,7 +96,8 @@ static void mark_common(struct commit *commit,
if (!ancestors_only && !(o->flags & POPPED))
non_common_revs--;
if (!o->parsed && !dont_parse)
- parse_commit(commit);
+ if (parse_commit(commit))
+ return;
for (parents = commit->parents;
parents;
@@ -102,20 +117,20 @@ static const unsigned char* get_rev(void)
while (commit == NULL) {
unsigned int mark;
- struct commit_list* parents;
+ struct commit_list *parents;
if (rev_list == NULL || non_common_revs == 0)
return NULL;
commit = rev_list->item;
- if (!(commit->object.parsed))
+ if (!commit->object.parsed)
parse_commit(commit);
+ parents = commit->parents;
+
commit->object.flags |= POPPED;
if (!(commit->object.flags & COMMON))
non_common_revs--;
- parents = commit->parents;
-
if (commit->object.flags & COMMON) {
/* do not send "have", and ignore ancestors */
commit = NULL;
@@ -150,6 +165,10 @@ static int find_common(int fd[2], unsigned char *result_sha1,
unsigned in_vain = 0;
int got_continue = 0;
+ if (marked)
+ for_each_ref(clear_marks, NULL);
+ marked = 1;
+
for_each_ref(rev_list_insert_ref, NULL);
fetching = 0;
@@ -173,13 +192,14 @@ static int find_common(int fd[2], unsigned char *result_sha1,
}
if (!fetching)
- packet_write(fd[1], "want %s%s%s%s%s%s%s\n",
+ packet_write(fd[1], "want %s%s%s%s%s%s%s%s\n",
sha1_to_hex(remote),
(multi_ack ? " multi_ack" : ""),
(use_sideband == 2 ? " side-band-64k" : ""),
(use_sideband == 1 ? " side-band" : ""),
(args.use_thin_pack ? " thin-pack" : ""),
(args.no_progress ? " no-progress" : ""),
+ (args.include_tag ? " include-tag" : ""),
" ofs-delta");
else
packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
@@ -211,7 +231,8 @@ static int find_common(int fd[2], unsigned char *result_sha1,
if (!lookup_object(sha1))
die("object not found: %s", line);
/* make sure that it is parsed as shallow */
- parse_object(sha1);
+ if (!parse_object(sha1))
+ die("error in object: %s", line);
if (unregister_shallow(sha1))
die("no shallow found: %s", line);
continue;
@@ -288,7 +309,8 @@ done:
}
flushes--;
}
- return retval;
+ /* it is no error to fetch into a completely empty repo */
+ return count ? retval : 0;
}
static struct commit_list *complete;
@@ -385,7 +407,6 @@ static int everything_local(struct ref **refs, int nr_match, char **match)
int retval;
unsigned long cutoff = 0;
- track_object_refs = 0;
save_commit_buffer = 0;
for (ref = *refs; ref; ref = ref->next) {
@@ -499,7 +520,8 @@ static int get_pack(int xd[2], char **pack_lockfile)
if (read_pack_header(demux.out, &header))
die("protocol error: bad pack header");
- snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
+ snprintf(hdr_arg, sizeof(hdr_arg),
+ "--pack_header=%"PRIu32",%"PRIu32,
ntohl(header.hdr_version), ntohl(header.hdr_entries));
if (ntohl(header.hdr_entries) < unpack_limit)
do_keep = 0;
@@ -537,8 +559,10 @@ static int get_pack(int xd[2], char **pack_lockfile)
cmd.git_cmd = 1;
if (start_command(&cmd))
die("fetch-pack: unable to fork off %s", argv[0]);
- if (do_keep && pack_lockfile)
+ if (do_keep && pack_lockfile) {
*pack_lockfile = index_pack_lockfile(cmd.out);
+ close(cmd.out);
+ }
if (finish_command(&cmd))
die("%s failed", argv[0]);
@@ -548,14 +572,14 @@ static int get_pack(int xd[2], char **pack_lockfile)
}
static struct ref *do_fetch_pack(int fd[2],
+ const struct ref *orig_ref,
int nr_match,
char **match,
char **pack_lockfile)
{
- struct ref *ref;
+ struct ref *ref = copy_ref_list(orig_ref);
unsigned char sha1[20];
- get_remote_heads(fd[0], &ref, 0, NULL, 0);
if (is_repository_shallow() && !server_supports("shallow"))
die("Server does not support shallow clients");
if (server_supports("multi_ack")) {
@@ -573,10 +597,6 @@ static struct ref *do_fetch_pack(int fd[2],
fprintf(stderr, "Server supports side-band\n");
use_sideband = 1;
}
- if (!ref) {
- packet_flush(fd[1]);
- die("no matching remote head");
- }
if (everything_local(&ref, nr_match, match)) {
packet_flush(fd[1]);
goto all_done;
@@ -617,7 +637,7 @@ static int remove_duplicates(int nr_heads, char **heads)
return dst;
}
-static int fetch_pack_config(const char *var, const char *value)
+static int fetch_pack_config(const char *var, const char *value, void *cb)
{
if (strcmp(var, "fetch.unpacklimit") == 0) {
fetch_unpack_limit = git_config_int(var, value);
@@ -629,7 +649,7 @@ static int fetch_pack_config(const char *var, const char *value)
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
static struct lock_file lock;
@@ -639,7 +659,7 @@ static void fetch_pack_setup(void)
static int did_setup;
if (did_setup)
return;
- git_config(fetch_pack_config);
+ git_config(fetch_pack_config, NULL);
if (0 <= transfer_unpack_limit)
unpack_limit = transfer_unpack_limit;
else if (0 <= fetch_unpack_limit)
@@ -650,8 +670,10 @@ static void fetch_pack_setup(void)
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
{
int i, ret, nr_heads;
- struct ref *ref;
+ struct ref *ref = NULL;
char *dest = NULL, **heads;
+ int fd[2];
+ struct child_process *conn;
nr_heads = 0;
heads = NULL;
@@ -680,6 +702,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
args.use_thin_pack = 1;
continue;
}
+ if (!strcmp("--include-tag", arg)) {
+ args.include_tag = 1;
+ continue;
+ }
if (!strcmp("--all", arg)) {
args.fetch_all = 1;
continue;
@@ -706,9 +732,33 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
if (!dest)
usage(fetch_pack_usage);
- ref = fetch_pack(&args, dest, nr_heads, heads, NULL);
+ conn = git_connect(fd, (char *)dest, args.uploadpack,
+ args.verbose ? CONNECT_VERBOSE : 0);
+ if (conn) {
+ get_remote_heads(fd[0], &ref, 0, NULL, 0);
+
+ ref = fetch_pack(&args, fd, conn, ref, dest, nr_heads, heads, NULL);
+ close(fd[0]);
+ close(fd[1]);
+ if (finish_connect(conn))
+ ref = NULL;
+ } else {
+ ref = NULL;
+ }
ret = !ref;
+ if (!ret && nr_heads) {
+ /* If the heads to pull were given, we should have
+ * consumed all of them by matching the remote.
+ * Otherwise, 'git-fetch remote no-such-ref' would
+ * silently succeed without issuing an error.
+ */
+ for (i = 0; i < nr_heads; i++)
+ if (heads[i] && heads[i][0]) {
+ error("no such remote ref %s", heads[i]);
+ ret = 1;
+ }
+ }
while (ref) {
printf("%s %s\n",
sha1_to_hex(ref->old_sha1), ref->name);
@@ -719,16 +769,15 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
}
struct ref *fetch_pack(struct fetch_pack_args *my_args,
+ int fd[], struct child_process *conn,
+ const struct ref *ref,
const char *dest,
int nr_heads,
char **heads,
char **pack_lockfile)
{
- int i, ret;
- int fd[2];
- struct child_process *conn;
- struct ref *ref;
struct stat st;
+ struct ref *ref_cpy;
fetch_pack_setup();
memcpy(&args, my_args, sizeof(args));
@@ -737,29 +786,15 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
st.st_mtime = 0;
}
- conn = git_connect(fd, (char *)dest, args.uploadpack,
- args.verbose ? CONNECT_VERBOSE : 0);
if (heads && nr_heads)
nr_heads = remove_duplicates(nr_heads, heads);
- ref = do_fetch_pack(fd, nr_heads, heads, pack_lockfile);
- close(fd[0]);
- close(fd[1]);
- ret = finish_connect(conn);
-
- if (!ret && nr_heads) {
- /* If the heads to pull were given, we should have
- * consumed all of them by matching the remote.
- * Otherwise, 'git-fetch remote no-such-ref' would
- * silently succeed without issuing an error.
- */
- for (i = 0; i < nr_heads; i++)
- if (heads[i] && heads[i][0]) {
- error("no such remote ref %s", heads[i]);
- ret = 1;
- }
+ if (!ref) {
+ packet_flush(fd[1]);
+ die("no matching remote head");
}
+ ref_cpy = do_fetch_pack(fd, ref, nr_heads, heads, pack_lockfile);
- if (!ret && args.depth > 0) {
+ if (args.depth > 0) {
struct cache_time mtime;
char *shallow = git_path("shallow");
int fd;
@@ -787,8 +822,6 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
}
}
- if (ret)
- ref = NULL;
-
- return ref;
+ reprepare_packed_git();
+ return ref_cpy;
}
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 320e23568..7eec4a0e4 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -5,14 +5,14 @@
#include "refs.h"
#include "commit.h"
#include "builtin.h"
-#include "path-list.h"
+#include "string-list.h"
#include "remote.h"
#include "transport.h"
#include "run-command.h"
#include "parse-options.h"
static const char * const builtin_fetch_usage[] = {
- "git-fetch [options] [<repository> <refspec>...]",
+ "git fetch [options] [<repository> <refspec>...]",
NULL
};
@@ -40,6 +40,8 @@ static struct option builtin_fetch_options[] = {
"force overwrite of local branch"),
OPT_SET_INT('t', "tags", &tags,
"fetch all tags and associated objects", TAGS_SET),
+ OPT_SET_INT('n', NULL, &tags,
+ "do not fetch all tags (--no-tags)", TAGS_UNSET),
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
"allow updating of HEAD ref"),
@@ -101,6 +103,10 @@ static void add_merge_config(struct ref **head,
}
}
+static void find_non_local_tags(struct transport *transport,
+ struct ref **head,
+ struct ref ***tail);
+
static struct ref *get_ref_map(struct transport *transport,
struct refspec *refs, int ref_count, int tags,
int *autotags)
@@ -121,14 +127,8 @@ static struct ref *get_ref_map(struct transport *transport,
/* Merge everything on the command line, but not --tags */
for (rm = ref_map; rm; rm = rm->next)
rm->merge = 1;
- if (tags == TAGS_SET) {
- struct refspec refspec;
- refspec.src = "refs/tags/";
- refspec.dst = "refs/tags/";
- refspec.pattern = 1;
- refspec.force = 0;
- get_fetch_map(remote_refs, &refspec, &tail, 0);
- }
+ if (tags == TAGS_SET)
+ get_fetch_map(remote_refs, tag_refspec, &tail, 0);
} else {
/* Use the defaults */
struct remote *remote = transport->remote;
@@ -157,8 +157,11 @@ static struct ref *get_ref_map(struct transport *transport,
if (!ref_map)
die("Couldn't find remote ref HEAD");
ref_map->merge = 1;
+ tail = &ref_map->next;
}
}
+ if (tags == TAGS_DEFAULT && *autotags)
+ find_non_local_tags(transport, &ref_map, &tail);
ref_remove_duplicates(ref_map);
return ref_map;
@@ -178,9 +181,9 @@ static int s_update_ref(const char *action,
lock = lock_any_ref_for_update(ref->name,
check_old ? ref->old_sha1 : NULL, 0);
if (!lock)
- return 1;
+ return 2;
if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
- return 1;
+ return 2;
return 0;
}
@@ -206,13 +209,6 @@ static int update_local_ref(struct ref *ref,
if (type < 0)
die("object %s not found", sha1_to_hex(ref->new_sha1));
- if (!*ref->name) {
- /* Not storing */
- if (verbose)
- sprintf(display, "* branch %s -> FETCH_HEAD", remote);
- return 0;
- }
-
if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
if (verbose)
sprintf(display, "= %-*s %-*s -> %s", SUMMARY_WIDTH,
@@ -237,10 +233,12 @@ static int update_local_ref(struct ref *ref,
if (!is_null_sha1(ref->old_sha1) &&
!prefixcmp(ref->name, "refs/tags/")) {
- sprintf(display, "- %-*s %-*s -> %s",
+ int r;
+ r = s_update_ref("updating tag", ref, 0);
+ sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
SUMMARY_WIDTH, "[tag update]", REFCOL_WIDTH, remote,
- pretty_ref);
- return s_update_ref("updating tag", ref, 0);
+ pretty_ref, r ? " (unable to update local ref)" : "");
+ return r;
}
current = lookup_commit_reference_gently(ref->old_sha1, 1);
@@ -248,6 +246,7 @@ static int update_local_ref(struct ref *ref,
if (!current || !updated) {
const char *msg;
const char *what;
+ int r;
if (!strncmp(ref->name, "refs/tags/", 10)) {
msg = "storing tag";
what = "[new tag]";
@@ -257,27 +256,36 @@ static int update_local_ref(struct ref *ref,
what = "[new branch]";
}
- sprintf(display, "* %-*s %-*s -> %s", SUMMARY_WIDTH, what,
- REFCOL_WIDTH, remote, pretty_ref);
- return s_update_ref(msg, ref, 0);
+ r = s_update_ref(msg, ref, 0);
+ sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '*',
+ SUMMARY_WIDTH, what, REFCOL_WIDTH, remote, pretty_ref,
+ r ? " (unable to update local ref)" : "");
+ return r;
}
if (in_merge_bases(current, &updated, 1)) {
char quickref[83];
+ int r;
strcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));
strcat(quickref, "..");
strcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));
- sprintf(display, " %-*s %-*s -> %s", SUMMARY_WIDTH, quickref,
- REFCOL_WIDTH, remote, pretty_ref);
- return s_update_ref("fast forward", ref, 1);
+ r = s_update_ref("fast forward", ref, 1);
+ sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : ' ',
+ SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
+ pretty_ref, r ? " (unable to update local ref)" : "");
+ return r;
} else if (force || ref->force) {
char quickref[84];
+ int r;
strcpy(quickref, find_unique_abbrev(current->object.sha1, DEFAULT_ABBREV));
strcat(quickref, "...");
strcat(quickref, find_unique_abbrev(ref->new_sha1, DEFAULT_ABBREV));
- sprintf(display, "+ %-*s %-*s -> %s (forced update)",
- SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote, pretty_ref);
- return s_update_ref("forced-update", ref, 1);
+ r = s_update_ref("forced-update", ref, 1);
+ sprintf(display, "%c %-*s %-*s -> %s (%s)", r ? '!' : '+',
+ SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
+ pretty_ref,
+ r ? "unable to update local ref" : "forced update");
+ return r;
} else {
sprintf(display, "! %-*s %-*s -> %s (non fast forward)",
SUMMARY_WIDTH, "[rejected]", REFCOL_WIDTH, remote,
@@ -286,11 +294,12 @@ static int update_local_ref(struct ref *ref,
}
}
-static int store_updated_refs(const char *url, struct ref *ref_map)
+static int store_updated_refs(const char *url, const char *remote_name,
+ struct ref *ref_map)
{
FILE *fp;
struct commit *commit;
- int url_len, i, note_len, shown_url = 0;
+ int url_len, i, note_len, shown_url = 0, rc = 0;
char note[1024];
const char *what, *kind;
struct ref *rm;
@@ -356,20 +365,27 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
rm->merge ? "" : "not-for-merge",
note);
- if (ref) {
- update_local_ref(ref, what, verbose, note);
- if (*note) {
- if (!shown_url) {
- fprintf(stderr, "From %.*s\n",
- url_len, url);
- shown_url = 1;
- }
- fprintf(stderr, " %s\n", note);
+ if (ref)
+ rc |= update_local_ref(ref, what, verbose, note);
+ else
+ sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
+ SUMMARY_WIDTH, *kind ? kind : "branch",
+ REFCOL_WIDTH, *what ? what : "HEAD");
+ if (*note) {
+ if (!shown_url) {
+ fprintf(stderr, "From %.*s\n",
+ url_len, url);
+ shown_url = 1;
}
+ fprintf(stderr, " %s\n", note);
}
}
fclose(fp);
- return 0;
+ if (rc & 2)
+ error("some local refs could not be updated; try running\n"
+ " 'git remote prune %s' to remove any old, conflicting "
+ "branches", remote_name);
+ return rc;
}
/*
@@ -439,7 +455,9 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
if (ret)
ret = transport_fetch_refs(transport, ref_map);
if (!ret)
- ret |= store_updated_refs(transport->url, ref_map);
+ ret |= store_updated_refs(transport->url,
+ transport->remote->name,
+ ref_map);
transport_unlock_pack(transport);
return ret;
}
@@ -447,23 +465,33 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
static int add_existing(const char *refname, const unsigned char *sha1,
int flag, void *cbdata)
{
- struct path_list *list = (struct path_list *)cbdata;
- path_list_insert(refname, list);
+ struct string_list *list = (struct string_list *)cbdata;
+ string_list_insert(refname, list);
return 0;
}
-static struct ref *find_non_local_tags(struct transport *transport,
- struct ref *fetch_map)
+static int will_fetch(struct ref **head, const unsigned char *sha1)
{
- static struct path_list existing_refs = { NULL, 0, 0, 0 };
- struct path_list new_refs = { NULL, 0, 0, 1 };
+ struct ref *rm = *head;
+ while (rm) {
+ if (!hashcmp(rm->old_sha1, sha1))
+ return 1;
+ rm = rm->next;
+ }
+ return 0;
+}
+
+static void find_non_local_tags(struct transport *transport,
+ struct ref **head,
+ struct ref ***tail)
+{
+ struct string_list existing_refs = { NULL, 0, 0, 0 };
+ struct string_list new_refs = { NULL, 0, 0, 1 };
char *ref_name;
int ref_name_len;
const unsigned char *ref_sha1;
const struct ref *tag_ref;
struct ref *rm = NULL;
- struct ref *ref_map = NULL;
- struct ref **tail = &ref_map;
const struct ref *ref;
for_each_ref(add_existing, &existing_refs);
@@ -487,30 +515,29 @@ static struct ref *find_non_local_tags(struct transport *transport,
}
}
- if (!path_list_has_path(&existing_refs, ref_name) &&
- !path_list_has_path(&new_refs, ref_name) &&
- has_sha1_file(ref->old_sha1)) {
- path_list_insert(ref_name, &new_refs);
+ if (!string_list_has_string(&existing_refs, ref_name) &&
+ !string_list_has_string(&new_refs, ref_name) &&
+ (has_sha1_file(ref->old_sha1) ||
+ will_fetch(head, ref->old_sha1))) {
+ string_list_insert(ref_name, &new_refs);
- rm = alloc_ref(strlen(ref_name) + 1);
- strcpy(rm->name, ref_name);
- rm->peer_ref = alloc_ref(strlen(ref_name) + 1);
- strcpy(rm->peer_ref->name, ref_name);
+ rm = alloc_ref_from_str(ref_name);
+ rm->peer_ref = alloc_ref_from_str(ref_name);
hashcpy(rm->old_sha1, ref_sha1);
- *tail = rm;
- tail = &rm->next;
+ **tail = rm;
+ *tail = &rm->next;
}
free(ref_name);
}
-
- return ref_map;
+ string_list_clear(&existing_refs, 0);
+ string_list_clear(&new_refs, 0);
}
static int do_fetch(struct transport *transport,
struct refspec *refs, int ref_count)
{
- struct ref *ref_map, *fetch_map;
+ struct ref *ref_map;
struct ref *rm;
int autotags = (transport->remote->fetch_tags == 1);
if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET)
@@ -537,26 +564,28 @@ static int do_fetch(struct transport *transport,
read_ref(rm->peer_ref->name, rm->peer_ref->old_sha1);
}
+ if (tags == TAGS_DEFAULT && autotags)
+ transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
if (fetch_refs(transport, ref_map)) {
free_refs(ref_map);
return 1;
}
-
- fetch_map = ref_map;
+ free_refs(ref_map);
/* if neither --no-tags nor --tags was specified, do automated tag
* following ... */
if (tags == TAGS_DEFAULT && autotags) {
- ref_map = find_non_local_tags(transport, fetch_map);
+ struct ref **tail = &ref_map;
+ ref_map = NULL;
+ find_non_local_tags(transport, &ref_map, &tail);
if (ref_map) {
+ transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
fetch_refs(transport, ref_map);
}
free_refs(ref_map);
}
- free_refs(fetch_map);
-
return 0;
}
@@ -577,6 +606,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
int i;
static const char **refs = NULL;
int ref_nr = 0;
+ int exit_code;
/* Record the command line for the reflog */
strbuf_addstr(&default_rla, "fetch");
@@ -613,6 +643,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (!strcmp(argv[i], "tag")) {
char *ref;
i++;
+ if (i >= argc)
+ die("You need to specify a tag name.");
ref = xmalloc(strlen(argv[i]) * 2 + 22);
strcpy(ref, "refs/tags/");
strcat(ref, argv[i]);
@@ -628,5 +660,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
signal(SIGINT, unlock_pack_on_signal);
atexit(unlock_pack);
- return do_fetch(transport, parse_ref_spec(ref_nr, refs), ref_nr);
+ exit_code = do_fetch(transport,
+ parse_fetch_refspec(ref_nr, refs), ref_nr);
+ transport_disconnect(transport);
+ transport = NULL;
+ return exit_code;
}
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index 6163bd497..df02ba7af 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -6,13 +6,18 @@
#include "tag.h"
static const char *fmt_merge_msg_usage =
- "git-fmt-merge-msg [--summary] [--no-summary] [--file <file>]";
+ "git fmt-merge-msg [--log] [--no-log] [--file <file>]";
static int merge_summary;
-static int fmt_merge_msg_config(const char *key, const char *value)
+static int fmt_merge_msg_config(const char *key, const char *value, void *cb)
{
- if (!strcmp("merge.summary", key))
+ static int found_merge_log = 0;
+ if (!strcmp("merge.log", key)) {
+ found_merge_log = 1;
+ merge_summary = git_config_bool(key, value);
+ }
+ if (!found_merge_log && !strcmp("merge.summary", key))
merge_summary = git_config_bool(key, value);
return 0;
}
@@ -154,23 +159,24 @@ static int handle_line(char *line)
}
static void print_joined(const char *singular, const char *plural,
- struct list *list)
+ struct list *list, struct strbuf *out)
{
if (list->nr == 0)
return;
if (list->nr == 1) {
- printf("%s%s", singular, list->list[0]);
+ strbuf_addf(out, "%s%s", singular, list->list[0]);
} else {
int i;
- printf("%s", plural);
+ strbuf_addstr(out, plural);
for (i = 0; i < list->nr - 1; i++)
- printf("%s%s", i > 0 ? ", " : "", list->list[i]);
- printf(" and %s", list->list[list->nr - 1]);
+ strbuf_addf(out, "%s%s", i > 0 ? ", " : "", list->list[i]);
+ strbuf_addf(out, " and %s", list->list[list->nr - 1]);
}
}
static void shortlog(const char *name, unsigned char *sha1,
- struct commit *head, struct rev_info *rev, int limit)
+ struct commit *head, struct rev_info *rev, int limit,
+ struct strbuf *out)
{
int i, count = 0;
struct commit *commit;
@@ -187,7 +193,8 @@ static void shortlog(const char *name, unsigned char *sha1,
add_pending_object(rev, branch, name);
add_pending_object(rev, &head->object, "^HEAD");
head->object.flags |= UNINTERESTING;
- prepare_revision_walk(rev);
+ if (prepare_revision_walk(rev))
+ die("revision walk setup failed");
while ((commit = get_revision(rev)) != NULL) {
char *oneline, *bol, *eol;
@@ -200,6 +207,15 @@ static void shortlog(const char *name, unsigned char *sha1,
continue;
bol = strstr(commit->buffer, "\n\n");
+ if (bol) {
+ unsigned char c;
+ do {
+ c = *++bol;
+ } while (isspace(c));
+ if (!c)
+ bol = NULL;
+ }
+
if (!bol) {
append_to_list(&subjects, xstrdup(sha1_to_hex(
commit->object.sha1)),
@@ -207,7 +223,6 @@ static void shortlog(const char *name, unsigned char *sha1,
continue;
}
- bol += 2;
eol = strchr(bol, '\n');
if (eol) {
oneline = xmemdupz(bol, eol - bol);
@@ -218,15 +233,15 @@ static void shortlog(const char *name, unsigned char *sha1,
}
if (count > limit)
- printf("\n* %s: (%d commits)\n", name, count);
+ strbuf_addf(out, "\n* %s: (%d commits)\n", name, count);
else
- printf("\n* %s:\n", name);
+ strbuf_addf(out, "\n* %s:\n", name);
for (i = 0; i < subjects.nr; i++)
if (i >= limit)
- printf(" ...\n");
+ strbuf_addf(out, " ...\n");
else
- printf(" %s\n", subjects.list[i]);
+ strbuf_addf(out, " %s\n", subjects.list[i]);
clear_commit_marks((struct commit *)branch, flags);
clear_commit_marks(head, flags);
@@ -237,42 +252,13 @@ static void shortlog(const char *name, unsigned char *sha1,
free_list(&subjects);
}
-int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
-{
- int limit = 20, i = 0;
+int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
+ int limit = 20, i = 0, pos = 0;
char line[1024];
- FILE *in = stdin;
- const char *sep = "";
+ char *p = line, *sep = "";
unsigned char head_sha1[20];
const char *current_branch;
- git_config(fmt_merge_msg_config);
-
- while (argc > 1) {
- if (!strcmp(argv[1], "--summary"))
- merge_summary = 1;
- else if (!strcmp(argv[1], "--no-summary"))
- merge_summary = 0;
- else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
- if (argc < 3)
- die ("Which file?");
- if (!strcmp(argv[2], "-"))
- in = stdin;
- else {
- fclose(in);
- in = fopen(argv[2], "r");
- if (!in)
- die("cannot open %s", argv[2]);
- }
- argc--; argv++;
- } else
- break;
- argc--; argv++;
- }
-
- if (argc > 1)
- usage(fmt_merge_msg_usage);
-
/* get current branch */
current_branch = resolve_ref("HEAD", head_sha1, 1, NULL);
if (!current_branch)
@@ -280,75 +266,127 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
if (!prefixcmp(current_branch, "refs/heads/"))
current_branch += 11;
- while (fgets(line, sizeof(line), in)) {
+ /* get a line */
+ while (pos < in->len) {
+ int len;
+ char *newline;
+
+ p = in->buf + pos;
+ newline = strchr(p, '\n');
+ len = newline ? newline - p : strlen(p);
+ pos += len + !!newline;
i++;
- if (line[0] == 0)
- continue;
- if (handle_line(line))
- die ("Error in line %d: %s", i, line);
+ p[len] = 0;
+ if (handle_line(p))
+ die ("Error in line %d: %.*s", i, len, p);
}
- printf("Merge ");
+ strbuf_addstr(out, "Merge ");
for (i = 0; i < srcs.nr; i++) {
struct src_data *src_data = srcs.payload[i];
const char *subsep = "";
- printf(sep);
+ strbuf_addstr(out, sep);
sep = "; ";
if (src_data->head_status == 1) {
- printf(srcs.list[i]);
+ strbuf_addstr(out, srcs.list[i]);
continue;
}
if (src_data->head_status == 3) {
subsep = ", ";
- printf("HEAD");
+ strbuf_addstr(out, "HEAD");
}
if (src_data->branch.nr) {
- printf(subsep);
+ strbuf_addstr(out, subsep);
subsep = ", ";
- print_joined("branch ", "branches ", &src_data->branch);
+ print_joined("branch ", "branches ", &src_data->branch,
+ out);
}
if (src_data->r_branch.nr) {
- printf(subsep);
+ strbuf_addstr(out, subsep);
subsep = ", ";
print_joined("remote branch ", "remote branches ",
- &src_data->r_branch);
+ &src_data->r_branch, out);
}
if (src_data->tag.nr) {
- printf(subsep);
+ strbuf_addstr(out, subsep);
subsep = ", ";
- print_joined("tag ", "tags ", &src_data->tag);
+ print_joined("tag ", "tags ", &src_data->tag, out);
}
if (src_data->generic.nr) {
- printf(subsep);
- print_joined("commit ", "commits ", &src_data->generic);
+ strbuf_addstr(out, subsep);
+ print_joined("commit ", "commits ", &src_data->generic,
+ out);
}
if (strcmp(".", srcs.list[i]))
- printf(" of %s", srcs.list[i]);
+ strbuf_addf(out, " of %s", srcs.list[i]);
}
if (!strcmp("master", current_branch))
- putchar('\n');
+ strbuf_addch(out, '\n');
else
- printf(" into %s\n", current_branch);
+ strbuf_addf(out, " into %s\n", current_branch);
if (merge_summary) {
struct commit *head;
struct rev_info rev;
head = lookup_commit(head_sha1);
- init_revisions(&rev, prefix);
+ init_revisions(&rev, NULL);
rev.commit_format = CMIT_FMT_ONELINE;
rev.ignore_merges = 1;
rev.limited = 1;
for (i = 0; i < origins.nr; i++)
shortlog(origins.list[i], origins.payload[i],
- head, &rev, limit);
+ head, &rev, limit, out);
}
+ return 0;
+}
+
+int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
+{
+ FILE *in = stdin;
+ struct strbuf input, output;
+ int ret;
+
+ git_config(fmt_merge_msg_config, NULL);
+
+ while (argc > 1) {
+ if (!strcmp(argv[1], "--log") || !strcmp(argv[1], "--summary"))
+ merge_summary = 1;
+ else if (!strcmp(argv[1], "--no-log")
+ || !strcmp(argv[1], "--no-summary"))
+ merge_summary = 0;
+ else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
+ if (argc < 3)
+ die ("Which file?");
+ if (!strcmp(argv[2], "-"))
+ in = stdin;
+ else {
+ fclose(in);
+ in = fopen(argv[2], "r");
+ if (!in)
+ die("cannot open %s", argv[2]);
+ }
+ argc--; argv++;
+ } else
+ break;
+ argc--; argv++;
+ }
+
+ if (argc > 1)
+ usage(fmt_merge_msg_usage);
- /* No cleanup yet; is standalone anyway */
+ strbuf_init(&input, 0);
+ if (strbuf_read(&input, fileno(in), 0) < 0)
+ die("could not read input file %s", strerror(errno));
+ strbuf_init(&output, 0);
+ ret = fmt_merge_msg(merge_summary, &input, &output);
+ if (ret)
+ return ret;
+ printf("%s", output.buf);
return 0;
}
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index f36a43c26..445039e19 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -165,7 +165,7 @@ static int verify_format(const char *format)
for (cp = format; *cp && (sp = find_next(cp)); ) {
const char *ep = strchr(sp, ')');
if (!ep)
- return error("malformatted format string %s", sp);
+ return error("malformed format string %s", sp);
/* sp points at "%(" and ep points at the closing ")" */
parse_atom(sp + 2, ep);
cp = ep + 1;
@@ -234,6 +234,13 @@ static void grab_tag_values(struct atom_value *val, int deref, struct object *ob
name++;
if (!strcmp(name, "tag"))
v->s = tag->tag;
+ else if (!strcmp(name, "type") && tag->tagged)
+ v->s = typename(tag->tagged->type);
+ else if (!strcmp(name, "object") && tag->tagged) {
+ char *s = xmalloc(41);
+ strcpy(s, sha1_to_hex(tag->tagged->sha1));
+ v->s = s;
+ }
}
}
@@ -802,7 +809,7 @@ static struct ref_sort *default_sort(void)
return sort;
}
-int opt_parse_sort(const struct option *opt, const char *arg, int unset)
+static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
{
struct ref_sort **sort_tail = opt->value;
struct ref_sort *s;
@@ -824,7 +831,7 @@ int opt_parse_sort(const struct option *opt, const char *arg, int unset)
}
static char const * const for_each_ref_usage[] = {
- "git-for-each-ref [options] [<pattern>]",
+ "git for-each-ref [options] [<pattern>]",
NULL
};
diff --git a/builtin-fsck.c b/builtin-fsck.c
index 6fc9525e0..d3f3de944 100644
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
@@ -8,6 +8,7 @@
#include "pack.h"
#include "cache-tree.h"
#include "tree-walk.h"
+#include "fsck.h"
#include "parse-options.h"
#define REACHABLE 0x0001
@@ -54,13 +55,75 @@ static int objerror(struct object *obj, const char *err, ...)
return -1;
}
-static int objwarning(struct object *obj, const char *err, ...)
+static int fsck_error_func(struct object *obj, int type, const char *err, ...)
{
va_list params;
va_start(params, err);
- objreport(obj, "warning", err, params);
+ objreport(obj, (type == FSCK_WARN) ? "warning" : "error", err, params);
va_end(params);
- return -1;
+ return (type == FSCK_WARN) ? 0 : 1;
+}
+
+static int mark_object(struct object *obj, int type, void *data)
+{
+ struct tree *tree = NULL;
+ struct object *parent = data;
+ int result;
+
+ if (!obj) {
+ printf("broken link from %7s %s\n",
+ typename(parent->type), sha1_to_hex(parent->sha1));
+ printf("broken link from %7s %s\n",
+ (type == OBJ_ANY ? "unknown" : typename(type)), "unknown");
+ errors_found |= ERROR_REACHABLE;
+ return 1;
+ }
+
+ if (type != OBJ_ANY && obj->type != type)
+ objerror(parent, "wrong object type in link");
+
+ if (obj->flags & REACHABLE)
+ return 0;
+ obj->flags |= REACHABLE;
+ if (!obj->parsed) {
+ if (parent && !has_sha1_file(obj->sha1)) {
+ printf("broken link from %7s %s\n",
+ typename(parent->type), sha1_to_hex(parent->sha1));
+ printf(" to %7s %s\n",
+ typename(obj->type), sha1_to_hex(obj->sha1));
+ errors_found |= ERROR_REACHABLE;
+ }
+ return 1;
+ }
+
+ if (obj->type == OBJ_TREE) {
+ obj->parsed = 0;
+ tree = (struct tree *)obj;
+ if (parse_tree(tree) < 0)
+ return 1; /* error already displayed */
+ }
+ result = fsck_walk(obj, mark_object, obj);
+ if (tree) {
+ free(tree->buffer);
+ tree->buffer = NULL;
+ }
+ if (result < 0)
+ result = 1;
+
+ return result;
+}
+
+static void mark_object_reachable(struct object *obj)
+{
+ mark_object(obj, OBJ_ANY, 0);
+}
+
+static int mark_used(struct object *obj, int type, void *data)
+{
+ if (!obj)
+ return 1;
+ obj->used = 1;
+ return 0;
}
/*
@@ -68,8 +131,6 @@ static int objwarning(struct object *obj, const char *err, ...)
*/
static void check_reachable_object(struct object *obj)
{
- const struct object_refs *refs;
-
/*
* We obviously want the object to be parsed,
* except if it was in a pack-file and we didn't
@@ -82,25 +143,6 @@ static void check_reachable_object(struct object *obj)
errors_found |= ERROR_REACHABLE;
return;
}
-
- /*
- * Check that everything that we try to reference is also good.
- */
- refs = lookup_object_refs(obj);
- if (refs) {
- unsigned j;
- for (j = 0; j < refs->count; j++) {
- struct object *ref = refs->ref[j];
- if (ref->parsed ||
- (has_sha1_file(ref->sha1)))
- continue;
- printf("broken link from %7s %s\n",
- typename(obj->type), sha1_to_hex(obj->sha1));
- printf(" to %7s %s\n",
- typename(ref->type), sha1_to_hex(ref->sha1));
- errors_found |= ERROR_REACHABLE;
- }
- }
}
/*
@@ -204,230 +246,56 @@ static void check_connectivity(void)
}
}
-/*
- * The entries in a tree are ordered in the _path_ order,
- * which means that a directory entry is ordered by adding
- * a slash to the end of it.
- *
- * So a directory called "a" is ordered _after_ a file
- * called "a.c", because "a/" sorts after "a.c".
- */
-#define TREE_UNORDERED (-1)
-#define TREE_HAS_DUPS (-2)
-
-static int verify_ordered(unsigned mode1, const char *name1, unsigned mode2, const char *name2)
+static int fsck_sha1(const unsigned char *sha1)
{
- int len1 = strlen(name1);
- int len2 = strlen(name2);
- int len = len1 < len2 ? len1 : len2;
- unsigned char c1, c2;
- int cmp;
-
- cmp = memcmp(name1, name2, len);
- if (cmp < 0)
+ struct object *obj = parse_object(sha1);
+ if (!obj) {
+ errors_found |= ERROR_OBJECT;
+ return error("%s: object corrupt or missing",
+ sha1_to_hex(sha1));
+ }
+ if (obj->flags & SEEN)
return 0;
- if (cmp > 0)
- return TREE_UNORDERED;
-
- /*
- * Ok, the first <len> characters are the same.
- * Now we need to order the next one, but turn
- * a '\0' into a '/' for a directory entry.
- */
- c1 = name1[len];
- c2 = name2[len];
- if (!c1 && !c2)
- /*
- * git-write-tree used to write out a nonsense tree that has
- * entries with the same name, one blob and one tree. Make
- * sure we do not have duplicate entries.
- */
- return TREE_HAS_DUPS;
- if (!c1 && S_ISDIR(mode1))
- c1 = '/';
- if (!c2 && S_ISDIR(mode2))
- c2 = '/';
- return c1 < c2 ? 0 : TREE_UNORDERED;
-}
-
-static int fsck_tree(struct tree *item)
-{
- int retval;
- int has_full_path = 0;
- int has_empty_name = 0;
- int has_zero_pad = 0;
- int has_bad_modes = 0;
- int has_dup_entries = 0;
- int not_properly_sorted = 0;
- struct tree_desc desc;
- unsigned o_mode;
- const char *o_name;
- const unsigned char *o_sha1;
+ obj->flags |= SEEN;
if (verbose)
- fprintf(stderr, "Checking tree %s\n",
- sha1_to_hex(item->object.sha1));
-
- init_tree_desc(&desc, item->buffer, item->size);
-
- o_mode = 0;
- o_name = NULL;
- o_sha1 = NULL;
- while (desc.size) {
- unsigned mode;
- const char *name;
- const unsigned char *sha1;
-
- sha1 = tree_entry_extract(&desc, &name, &mode);
-
- if (strchr(name, '/'))
- has_full_path = 1;
- if (!*name)
- has_empty_name = 1;
- has_zero_pad |= *(char *)desc.buffer == '0';
- update_tree_entry(&desc);
-
- switch (mode) {
- /*
- * Standard modes..
- */
- case S_IFREG | 0755:
- case S_IFREG | 0644:
- case S_IFLNK:
- case S_IFDIR:
- case S_IFGITLINK:
- break;
- /*
- * This is nonstandard, but we had a few of these
- * early on when we honored the full set of mode
- * bits..
- */
- case S_IFREG | 0664:
- if (!check_strict)
- break;
- default:
- has_bad_modes = 1;
- }
+ fprintf(stderr, "Checking %s %s\n",
+ typename(obj->type), sha1_to_hex(obj->sha1));
- if (o_name) {
- switch (verify_ordered(o_mode, o_name, mode, name)) {
- case TREE_UNORDERED:
- not_properly_sorted = 1;
- break;
- case TREE_HAS_DUPS:
- has_dup_entries = 1;
- break;
- default:
- break;
- }
- }
+ if (fsck_walk(obj, mark_used, 0))
+ objerror(obj, "broken links");
+ if (fsck_object(obj, check_strict, fsck_error_func))
+ return -1;
- o_mode = mode;
- o_name = name;
- o_sha1 = sha1;
- }
- free(item->buffer);
- item->buffer = NULL;
+ if (obj->type == OBJ_TREE) {
+ struct tree *item = (struct tree *) obj;
- retval = 0;
- if (has_full_path) {
- objwarning(&item->object, "contains full pathnames");
- }
- if (has_empty_name) {
- objwarning(&item->object, "contains empty pathname");
+ free(item->buffer);
+ item->buffer = NULL;
}
- if (has_zero_pad) {
- objwarning(&item->object, "contains zero-padded file modes");
- }
- if (has_bad_modes) {
- objwarning(&item->object, "contains bad file modes");
- }
- if (has_dup_entries) {
- retval = objerror(&item->object, "contains duplicate file entries");
- }
- if (not_properly_sorted) {
- retval = objerror(&item->object, "not properly sorted");
- }
- return retval;
-}
-static int fsck_commit(struct commit *commit)
-{
- char *buffer = commit->buffer;
- unsigned char tree_sha1[20], sha1[20];
+ if (obj->type == OBJ_COMMIT) {
+ struct commit *commit = (struct commit *) obj;
- if (verbose)
- fprintf(stderr, "Checking commit %s\n",
- sha1_to_hex(commit->object.sha1));
-
- if (memcmp(buffer, "tree ", 5))
- return objerror(&commit->object, "invalid format - expected 'tree' line");
- if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
- return objerror(&commit->object, "invalid 'tree' line format - bad sha1");
- buffer += 46;
- while (!memcmp(buffer, "parent ", 7)) {
- if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
- return objerror(&commit->object, "invalid 'parent' line format - bad sha1");
- buffer += 48;
- }
- if (memcmp(buffer, "author ", 7))
- return objerror(&commit->object, "invalid format - expected 'author' line");
- free(commit->buffer);
- commit->buffer = NULL;
- if (!commit->tree)
- return objerror(&commit->object, "could not load commit's tree %s", tree_sha1);
- if (!commit->parents && show_root)
- printf("root %s\n", sha1_to_hex(commit->object.sha1));
- if (!commit->date)
- printf("bad commit date in %s\n",
- sha1_to_hex(commit->object.sha1));
- return 0;
-}
+ free(commit->buffer);
+ commit->buffer = NULL;
-static int fsck_tag(struct tag *tag)
-{
- struct object *tagged = tag->tagged;
+ if (!commit->parents && show_root)
+ printf("root %s\n", sha1_to_hex(commit->object.sha1));
+ }
- if (verbose)
- fprintf(stderr, "Checking tag %s\n",
- sha1_to_hex(tag->object.sha1));
+ if (obj->type == OBJ_TAG) {
+ struct tag *tag = (struct tag *) obj;
- if (!tagged) {
- return objerror(&tag->object, "could not load tagged object");
+ if (show_tags && tag->tagged) {
+ printf("tagged %s %s", typename(tag->tagged->type), sha1_to_hex(tag->tagged->sha1));
+ printf(" (%s) in %s\n", tag->tag, sha1_to_hex(tag->object.sha1));
+ }
}
- if (!show_tags)
- return 0;
- printf("tagged %s %s", typename(tagged->type), sha1_to_hex(tagged->sha1));
- printf(" (%s) in %s\n", tag->tag, sha1_to_hex(tag->object.sha1));
return 0;
}
-static int fsck_sha1(const unsigned char *sha1)
-{
- struct object *obj = parse_object(sha1);
- if (!obj) {
- errors_found |= ERROR_OBJECT;
- return error("%s: object corrupt or missing",
- sha1_to_hex(sha1));
- }
- if (obj->flags & SEEN)
- return 0;
- obj->flags |= SEEN;
- if (obj->type == OBJ_BLOB)
- return 0;
- if (obj->type == OBJ_TREE)
- return fsck_tree((struct tree *) obj);
- if (obj->type == OBJ_COMMIT)
- return fsck_commit((struct commit *) obj);
- if (obj->type == OBJ_TAG)
- return fsck_tag((struct tag *) obj);
-
- /* By now, parse_object() would've returned NULL instead. */
- return objerror(obj, "unknown type '%d' (internal fsck error)",
- obj->type);
-}
-
/*
* This is the sorting chunk size: make it reasonably
* big so that we can sort well..
@@ -517,6 +385,8 @@ static void fsck_dir(int i, char *path)
add_sha1_list(sha1, DIRENT_SORT_HINT(de));
continue;
}
+ if (!prefixcmp(de->d_name, "tmp_obj_"))
+ continue;
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
}
closedir(dir);
@@ -538,13 +408,13 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
obj = lookup_object(osha1);
if (obj) {
obj->used = 1;
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
}
}
obj = lookup_object(nsha1);
if (obj) {
obj->used = 1;
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
}
return 0;
}
@@ -574,7 +444,7 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f
error("%s: not a commit", refname);
default_refs++;
obj->used = 1;
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
return 0;
}
@@ -660,7 +530,7 @@ static int fsck_cache_tree(struct cache_tree *it)
sha1_to_hex(it->sha1));
return 1;
}
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
obj->used = 1;
if (obj->type != OBJ_TREE)
err |= objerror(obj, "non-tree in cache-tree");
@@ -671,7 +541,7 @@ static int fsck_cache_tree(struct cache_tree *it)
}
static char const * const fsck_usage[] = {
- "git-fsck [options] [<object>...]",
+ "git fsck [options] [<object>...]",
NULL
};
@@ -693,7 +563,6 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
{
int i, heads;
- track_object_refs = 1;
errors_found = 0;
argc = parse_options(argc, argv, fsck_opts, fsck_usage, 0);
@@ -718,7 +587,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
prepare_packed_git();
for (p = packed_git; p; p = p->next)
/* verify gives error messages itself */
- verify_pack(p, 0);
+ verify_pack(p);
for (p = packed_git; p; p = p->next) {
uint32_t j, num;
@@ -741,7 +610,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
continue;
obj->used = 1;
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
heads++;
continue;
}
@@ -773,7 +642,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
continue;
obj = &blob->object;
obj->used = 1;
- mark_reachable(obj, REACHABLE);
+ mark_object_reachable(obj);
}
if (active_cache_tree)
fsck_cache_tree(active_cache_tree);
diff --git a/builtin-gc.c b/builtin-gc.c
index ac34788c8..fac200e0b 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -18,26 +18,27 @@
#define FAILED_RUN "failed to run %s"
static const char * const builtin_gc_usage[] = {
- "git-gc [options]",
+ "git gc [options]",
NULL
};
static int pack_refs = 1;
static int aggressive_window = -1;
static int gc_auto_threshold = 6700;
-static int gc_auto_pack_limit = 20;
+static int gc_auto_pack_limit = 50;
+static char *prune_expire = "2.weeks.ago";
#define MAX_ADD 10
static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
-static const char *argv_prune[] = {"prune", NULL};
+static const char *argv_prune[] = {"prune", "--expire", NULL, NULL};
static const char *argv_rerere[] = {"rerere", "gc", NULL};
-static int gc_config(const char *var, const char *value)
+static int gc_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "gc.packrefs")) {
- if (!strcmp(value, "notbare"))
+ if (value && !strcmp(value, "notbare"))
pack_refs = -1;
else
pack_refs = git_config_bool(var, value);
@@ -55,7 +56,18 @@ static int gc_config(const char *var, const char *value)
gc_auto_pack_limit = git_config_int(var, value);
return 0;
}
- return git_default_config(var, value);
+ if (!strcmp(var, "gc.pruneexpire")) {
+ if (!value)
+ return config_error_nonbool(var);
+ if (strcmp(value, "now")) {
+ unsigned long now = approxidate("now");
+ if (approxidate(value) >= now)
+ return error("Invalid %s: '%s'", var, value);
+ }
+ prune_expire = xstrdup(value);
+ return 0;
+ }
+ return git_default_config(var, value, cb);
}
static void append_option(const char **cmd, const char *opt, int max_length)
@@ -145,13 +157,41 @@ static int too_many_packs(void)
return gc_auto_pack_limit <= cnt;
}
+static int run_hook(void)
+{
+ const char *argv[2];
+ struct child_process hook;
+ int ret;
+
+ argv[0] = git_path("hooks/pre-auto-gc");
+ argv[1] = NULL;
+
+ if (access(argv[0], X_OK) < 0)
+ return 0;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+
+ ret = start_command(&hook);
+ if (ret) {
+ warning("Could not spawn %s", argv[0]);
+ return ret;
+ }
+ ret = finish_command(&hook);
+ if (ret == -ERR_RUN_COMMAND_WAITPID_SIGNAL)
+ warning("%s exited due to uncaught signal", argv[0]);
+ return ret;
+}
+
static int need_to_gc(void)
{
/*
- * Setting gc.auto and gc.autopacklimit to 0 or negative can
- * disable the automatic gc.
+ * Setting gc.auto to 0 or negative can disable the
+ * automatic gc.
*/
- if (gc_auto_threshold <= 0 && gc_auto_pack_limit <= 0)
+ if (gc_auto_threshold <= 0)
return 0;
/*
@@ -164,6 +204,9 @@ static int need_to_gc(void)
append_option(argv_repack, "-A", MAX_ADD);
else if (!too_many_loose_objects())
return 0;
+
+ if (run_hook())
+ return 0;
return 1;
}
@@ -172,16 +215,18 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
int prune = 0;
int aggressive = 0;
int auto_gc = 0;
+ int quiet = 0;
char buf[80];
struct option builtin_gc_options[] = {
- OPT_BOOLEAN(0, "prune", &prune, "prune unreferenced objects"),
+ OPT_BOOLEAN(0, "prune", &prune, "prune unreferenced objects (deprecated)"),
OPT_BOOLEAN(0, "aggressive", &aggressive, "be more thorough (increased runtime)"),
OPT_BOOLEAN(0, "auto", &auto_gc, "enable auto-gc mode"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "suppress progress reports"),
OPT_END()
};
- git_config(gc_config);
+ git_config(gc_config, NULL);
if (pack_refs < 0)
pack_refs = !is_bare_repository();
@@ -197,29 +242,21 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
append_option(argv_repack, buf, MAX_ADD);
}
}
+ if (quiet)
+ append_option(argv_repack, "-q", MAX_ADD);
if (auto_gc) {
/*
* Auto-gc should be least intrusive as possible.
*/
- prune = 0;
if (!need_to_gc())
return 0;
fprintf(stderr, "Auto packing your repository for optimum "
"performance. You may also\n"
"run \"git gc\" manually. See "
"\"git help gc\" for more information.\n");
- } else {
- /*
- * Use safer (for shared repos) "-A" option to
- * repack when not pruning. Auto-gc makes its
- * own decision.
- */
- if (prune)
- append_option(argv_repack, "-a", MAX_ADD);
- else
- append_option(argv_repack, "-A", MAX_ADD);
- }
+ } else
+ append_option(argv_repack, "-A", MAX_ADD);
if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD))
return error(FAILED_RUN, argv_pack_refs[0]);
@@ -230,7 +267,8 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
if (run_command_v_opt(argv_repack, RUN_GIT_CMD))
return error(FAILED_RUN, argv_repack[0]);
- if (prune && run_command_v_opt(argv_prune, RUN_GIT_CMD))
+ argv_prune[2] = prune_expire;
+ if (run_command_v_opt(argv_prune, RUN_GIT_CMD))
return error(FAILED_RUN, argv_prune[0]);
if (run_command_v_opt(argv_rerere, RUN_GIT_CMD))
diff --git a/builtin-grep.c b/builtin-grep.c
index 9180b39e3..631129ddf 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -12,6 +12,14 @@
#include "builtin.h"
#include "grep.h"
+#ifndef NO_EXTERNAL_GREP
+#ifdef __unix__
+#define NO_EXTERNAL_GREP 0
+#else
+#define NO_EXTERNAL_GREP 1
+#endif
+#endif
+
/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;
* pathname wildcards are allowed.
@@ -153,7 +161,7 @@ static int grep_file(struct grep_opt *opt, const char *filename)
return i;
}
-#ifdef __unix__
+#if !NO_EXTERNAL_GREP
static int exec_grep(int argc, const char **argv)
{
pid_t pid;
@@ -372,7 +380,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
int nr;
read_cache();
-#ifdef __unix__
+#if !NO_EXTERNAL_GREP
/*
* Use the external "grep" command for the case where
* we grep through the checked-out files. It tends to
@@ -419,33 +427,35 @@ static int grep_tree(struct grep_opt *opt, const char **paths,
struct name_entry entry;
char *down;
int tn_len = strlen(tree_name);
- char *path_buf = xmalloc(PATH_MAX + tn_len + 100);
+ struct strbuf pathbuf;
+
+ strbuf_init(&pathbuf, PATH_MAX + tn_len);
if (tn_len) {
- tn_len = sprintf(path_buf, "%s:", tree_name);
- down = path_buf + tn_len;
- strcat(down, base);
- }
- else {
- down = path_buf;
- strcpy(down, base);
+ strbuf_add(&pathbuf, tree_name, tn_len);
+ strbuf_addch(&pathbuf, ':');
+ tn_len = pathbuf.len;
}
- len = strlen(path_buf);
+ strbuf_addstr(&pathbuf, base);
+ len = pathbuf.len;
while (tree_entry(tree, &entry)) {
- strcpy(path_buf + len, entry.path);
+ int te_len = tree_entry_len(entry.path, entry.sha1);
+ pathbuf.len = len;
+ strbuf_add(&pathbuf, entry.path, te_len);
if (S_ISDIR(entry.mode))
/* Match "abc/" against pathspec to
* decide if we want to descend into "abc"
* directory.
*/
- strcpy(path_buf + len + tree_entry_len(entry.path, entry.sha1), "/");
+ strbuf_addch(&pathbuf, '/');
+ down = pathbuf.buf + tn_len;
if (!pathspec_matches(paths, down))
;
else if (S_ISREG(entry.mode))
- hit |= grep_sha1(opt, entry.sha1, path_buf, tn_len);
+ hit |= grep_sha1(opt, entry.sha1, pathbuf.buf, tn_len);
else if (S_ISDIR(entry.mode)) {
enum object_type type;
struct tree_desc sub;
@@ -461,6 +471,7 @@ static int grep_tree(struct grep_opt *opt, const char **paths,
free(data);
}
}
+ strbuf_release(&pathbuf);
return hit;
}
@@ -487,7 +498,7 @@ static int grep_object(struct grep_opt *opt, const char **paths,
}
static const char builtin_grep_usage[] =
-"git-grep <option>* <rev>* [-e] <pattern> [<path>...]";
+"git grep <option>* [-e] <pattern> <rev>* [[--] <path>...]";
static const char emsg_invalid_context_len[] =
"%s: invalid context length argument";
@@ -578,6 +589,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp("-l", arg) ||
+ !strcmp("--name-only", arg) ||
!strcmp("--files-with-matches", arg)) {
opt.name_only = 1;
continue;
diff --git a/builtin-http-fetch.c b/builtin-http-fetch.c
index 7f450c61d..3a062487a 100644
--- a/builtin-http-fetch.c
+++ b/builtin-http-fetch.c
@@ -18,7 +18,7 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
int get_verbosely = 0;
int get_recover = 0;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
@@ -59,7 +59,7 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
url = rewritten_url;
}
- walker = get_http_walker(url);
+ walker = get_http_walker(url, NULL);
walker->get_tree = get_tree;
walker->get_history = get_history;
walker->get_all = get_all;
@@ -80,8 +80,7 @@ int cmd_http_fetch(int argc, const char **argv, const char *prefix)
walker_free(walker);
- if (rewritten_url)
- free(rewritten_url);
+ free(rewritten_url);
return rc;
}
diff --git a/builtin-init-db.c b/builtin-init-db.c
index e1393b8d1..baf0d09ac 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -29,27 +29,6 @@ static void safe_create_dir(const char *dir, int share)
die("Could not make %s writable by group\n", dir);
}
-static int copy_file(const char *dst, const char *src, int mode)
-{
- int fdi, fdo, status;
-
- mode = (mode & 0111) ? 0777 : 0666;
- if ((fdi = open(src, O_RDONLY)) < 0)
- return fdi;
- if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
- close(fdi);
- return fdo;
- }
- status = copy_fd(fdi, fdo);
- if (close(fdo) != 0)
- return error("%s: write error: %s", dst, strerror(errno));
-
- if (!status && adjust_shared_perm(dst))
- return -1;
-
- return status;
-}
-
static void copy_templates_1(char *path, int baselen,
char *template, int template_baselen,
DIR *dir)
@@ -125,27 +104,21 @@ static void copy_templates_1(char *path, int baselen,
}
}
-static void copy_templates(const char *git_dir, int len, const char *template_dir)
+static void copy_templates(const char *template_dir)
{
char path[PATH_MAX];
char template_path[PATH_MAX];
int template_len;
DIR *dir;
+ const char *git_dir = get_git_dir();
+ int len = strlen(git_dir);
if (!template_dir)
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
- if (!template_dir) {
- /*
- * if the hard-coded template is relative, it is
- * interpreted relative to the exec_dir
- */
- template_dir = DEFAULT_GIT_TEMPLATE_DIR;
- if (!is_absolute_path(template_dir)) {
- const char *exec_path = git_exec_path();
- template_dir = prefix_path(exec_path, strlen(exec_path),
- template_dir);
- }
- }
+ if (!template_dir)
+ template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
+ if (!template_dir[0])
+ return;
strcpy(template_path, template_dir);
template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {
@@ -163,7 +136,7 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
strcpy(template_path + template_len, "config");
repository_format_version = 0;
git_config_from_file(check_repository_format_version,
- template_path);
+ template_path, NULL);
template_path[template_len] = 0;
if (repository_format_version &&
@@ -177,6 +150,8 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
}
memcpy(path, git_dir, len);
+ if (len && path[len - 1] != '/')
+ path[len++] = '/';
path[len] = 0;
copy_templates_1(path, len,
template_path, template_len,
@@ -184,13 +159,14 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
closedir(dir);
}
-static int create_default_files(const char *git_dir, const char *template_path)
+static int create_default_files(const char *template_path)
{
+ const char *git_dir = get_git_dir();
unsigned len = strlen(git_dir);
static char path[PATH_MAX];
- unsigned char sha1[20];
struct stat st1;
char repo_version_string[10];
+ char junk[2];
int reinit;
int filemode;
@@ -204,35 +180,27 @@ static int create_default_files(const char *git_dir, const char *template_path)
/*
* Create .git/refs/{heads,tags}
*/
- strcpy(path + len, "refs");
- safe_create_dir(path, 1);
- strcpy(path + len, "refs/heads");
- safe_create_dir(path, 1);
- strcpy(path + len, "refs/tags");
- safe_create_dir(path, 1);
+ safe_create_dir(git_path("refs"), 1);
+ safe_create_dir(git_path("refs/heads"), 1);
+ safe_create_dir(git_path("refs/tags"), 1);
/* First copy the templates -- we might have the default
* config file there, in which case we would want to read
* from it after installing.
*/
- path[len] = 0;
- copy_templates(path, len, template_path);
+ copy_templates(template_path);
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
/*
* We would have created the above under user's umask -- under
* shared-repository settings, we would need to fix them up.
*/
if (shared_repository) {
- path[len] = 0;
- adjust_shared_perm(path);
- strcpy(path + len, "refs");
- adjust_shared_perm(path);
- strcpy(path + len, "refs/heads");
- adjust_shared_perm(path);
- strcpy(path + len, "refs/tags");
- adjust_shared_perm(path);
+ adjust_shared_perm(get_git_dir());
+ adjust_shared_perm(git_path("refs"));
+ adjust_shared_perm(git_path("refs/heads"));
+ adjust_shared_perm(git_path("refs/tags"));
}
/*
@@ -240,7 +208,8 @@ static int create_default_files(const char *git_dir, const char *template_path)
* branch, if it does not exist yet.
*/
strcpy(path + len, "HEAD");
- reinit = !read_ref("HEAD", sha1);
+ reinit = (!access(path, R_OK)
+ || readlink(path, junk, sizeof(junk)-1) != -1);
if (!reinit) {
if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
exit(1);
@@ -271,12 +240,14 @@ static int create_default_files(const char *git_dir, const char *template_path)
/* allow template config file to override the default */
if (log_all_ref_updates == -1)
git_config_set("core.logallrefupdates", "true");
- if (work_tree != git_work_tree_cfg)
+ if (prefixcmp(git_dir, work_tree) ||
+ strcmp(git_dir + strlen(work_tree), "/.git")) {
git_config_set("core.worktree", work_tree);
+ }
}
- /* Check if symlink is supported in the work tree */
if (!reinit) {
+ /* Check if symlink is supported in the work tree */
path[len] = 0;
strcpy(path + len, "tXXXXXX");
if (!close(xmkstemp(path)) &&
@@ -287,51 +258,105 @@ static int create_default_files(const char *git_dir, const char *template_path)
unlink(path); /* good */
else
git_config_set("core.symlinks", "false");
+
+ /* Check if the filesystem is case-insensitive */
+ path[len] = 0;
+ strcpy(path + len, "CoNfIg");
+ if (!access(path, F_OK))
+ git_config_set("core.ignorecase", "true");
}
return reinit;
}
-static void guess_repository_type(const char *git_dir)
+int init_db(const char *template_dir, unsigned int flags)
+{
+ const char *sha1_dir;
+ char *path;
+ int len, reinit;
+
+ safe_create_dir(get_git_dir(), 0);
+
+ /* Check to see if the repository version is right.
+ * Note that a newly created repository does not have
+ * config file, so this will not fail. What we are catching
+ * is an attempt to reinitialize new repository with an old tool.
+ */
+ check_repository_format();
+
+ reinit = create_default_files(template_dir);
+
+ sha1_dir = get_object_directory();
+ len = strlen(sha1_dir);
+ path = xmalloc(len + 40);
+ memcpy(path, sha1_dir, len);
+
+ safe_create_dir(sha1_dir, 1);
+ strcpy(path+len, "/pack");
+ safe_create_dir(path, 1);
+ strcpy(path+len, "/info");
+ safe_create_dir(path, 1);
+
+ if (shared_repository) {
+ char buf[10];
+ /* We do not spell "group" and such, so that
+ * the configuration can be read by older version
+ * of git. Note, we use octal numbers for new share modes,
+ * and compatibility values for PERM_GROUP and
+ * PERM_EVERYBODY.
+ */
+ if (shared_repository == PERM_GROUP)
+ sprintf(buf, "%d", OLD_PERM_GROUP);
+ else if (shared_repository == PERM_EVERYBODY)
+ sprintf(buf, "%d", OLD_PERM_EVERYBODY);
+ else
+ sprintf(buf, "0%o", shared_repository);
+ git_config_set("core.sharedrepository", buf);
+ git_config_set("receive.denyNonFastforwards", "true");
+ }
+
+ if (!(flags & INIT_DB_QUIET))
+ printf("%s%s Git repository in %s/\n",
+ reinit ? "Reinitialized existing" : "Initialized empty",
+ shared_repository ? " shared" : "",
+ get_git_dir());
+
+ return 0;
+}
+
+static int guess_repository_type(const char *git_dir)
{
char cwd[PATH_MAX];
const char *slash;
- if (0 <= is_bare_repository_cfg)
- return;
- if (!git_dir)
- return;
-
/*
* "GIT_DIR=. git init" is always bare.
* "GIT_DIR=`pwd` git init" too.
*/
if (!strcmp(".", git_dir))
- goto force_bare;
+ return 1;
if (!getcwd(cwd, sizeof(cwd)))
die("cannot tell cwd");
if (!strcmp(git_dir, cwd))
- goto force_bare;
+ return 1;
/*
* "GIT_DIR=.git or GIT_DIR=something/.git is usually not.
*/
if (!strcmp(git_dir, ".git"))
- return;
+ return 0;
slash = strrchr(git_dir, '/');
if (slash && !strcmp(slash, "/.git"))
- return;
+ return 0;
/*
* Otherwise it is often bare. At this point
* we are just guessing.
*/
- force_bare:
- is_bare_repository_cfg = 1;
- return;
+ return 1;
}
static const char init_db_usage[] =
-"git-init [-q | --quiet] [--template=<template-directory>] [--shared]";
+"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]";
/*
* If you want to, you can share the DB area with any number of branches.
@@ -342,22 +367,25 @@ static const char init_db_usage[] =
int cmd_init_db(int argc, const char **argv, const char *prefix)
{
const char *git_dir;
- const char *sha1_dir;
const char *template_dir = NULL;
- char *path;
- int len, i, reinit;
- int quiet = 0;
+ unsigned int flags = 0;
+ int i;
for (i = 1; i < argc; i++, argv++) {
const char *arg = argv[1];
if (!prefixcmp(arg, "--template="))
template_dir = arg+11;
- else if (!strcmp(arg, "--shared"))
+ else if (!strcmp(arg, "--bare")) {
+ static char git_dir[PATH_MAX+1];
+ is_bare_repository_cfg = 1;
+ setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,
+ sizeof(git_dir)), 0);
+ } else if (!strcmp(arg, "--shared"))
shared_repository = PERM_GROUP;
else if (!prefixcmp(arg, "--shared="))
shared_repository = git_config_perm("arg", arg+9);
else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet"))
- quiet = 1;
+ flags |= INIT_DB_QUIET;
else
usage(init_db_usage);
}
@@ -374,64 +402,35 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
GIT_WORK_TREE_ENVIRONMENT,
GIT_DIR_ENVIRONMENT);
- guess_repository_type(git_dir);
-
- if (is_bare_repository_cfg <= 0) {
- git_work_tree_cfg = xcalloc(PATH_MAX, 1);
- if (!getcwd(git_work_tree_cfg, PATH_MAX))
- die ("Cannot access current working directory.");
- if (access(get_git_work_tree(), X_OK))
- die ("Cannot access work tree '%s'",
- get_git_work_tree());
- }
-
/*
* Set up the default .git directory contents
*/
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
- safe_create_dir(git_dir, 0);
-
- /* Check to see if the repository version is right.
- * Note that a newly created repository does not have
- * config file, so this will not fail. What we are catching
- * is an attempt to reinitialize new repository with an old tool.
- */
- check_repository_format();
-
- reinit = create_default_files(git_dir, template_dir);
-
- /*
- * And set up the object store.
- */
- sha1_dir = get_object_directory();
- len = strlen(sha1_dir);
- path = xmalloc(len + 40);
- memcpy(path, sha1_dir, len);
-
- safe_create_dir(sha1_dir, 1);
- strcpy(path+len, "/pack");
- safe_create_dir(path, 1);
- strcpy(path+len, "/info");
- safe_create_dir(path, 1);
- if (shared_repository) {
- char buf[10];
- /* We do not spell "group" and such, so that
- * the configuration can be read by older version
- * of git.
- */
- sprintf(buf, "%d", shared_repository);
- git_config_set("core.sharedrepository", buf);
- git_config_set("receive.denyNonFastforwards", "true");
+ if (is_bare_repository_cfg < 0)
+ is_bare_repository_cfg = guess_repository_type(git_dir);
+
+ if (!is_bare_repository_cfg) {
+ if (git_dir) {
+ const char *git_dir_parent = strrchr(git_dir, '/');
+ if (git_dir_parent) {
+ char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
+ git_work_tree_cfg = xstrdup(make_absolute_path(rel));
+ free(rel);
+ }
+ }
+ if (!git_work_tree_cfg) {
+ git_work_tree_cfg = xcalloc(PATH_MAX, 1);
+ if (!getcwd(git_work_tree_cfg, PATH_MAX))
+ die ("Cannot access current working directory.");
+ }
+ if (access(get_git_work_tree(), X_OK))
+ die ("Cannot access work tree '%s'",
+ get_git_work_tree());
}
- if (!quiet)
- printf("%s%s Git repository in %s/\n",
- reinit ? "Reinitialized existing" : "Initialized empty",
- shared_repository ? " shared" : "",
- git_dir);
+ set_git_dir(make_absolute_path(git_dir));
- return 0;
+ return init_db(template_dir, flags);
}
diff --git a/builtin-log.c b/builtin-log.c
index dcc9f8179..f4975cf35 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -5,6 +5,7 @@
* 2006 Junio Hamano
*/
#include "cache.h"
+#include "color.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
@@ -14,9 +15,15 @@
#include "reflog-walk.h"
#include "patch-ids.h"
#include "refs.h"
+#include "run-command.h"
+#include "shortlog.h"
+
+/* Set a default date-time format for git log ("log.date" config variable) */
+static const char *default_date_mode = NULL;
static int default_show_root = 1;
static const char *fmt_patch_subject_prefix = "PATCH";
+static const char *fmt_pretty;
static void add_name_decoration(const char *prefix, const char *name, struct object *obj)
{
@@ -51,11 +58,18 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT;
+ if (fmt_pretty)
+ get_commit_format(fmt_pretty, rev);
rev->verbose_header = 1;
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
rev->show_root_diff = default_show_root;
rev->subject_prefix = fmt_patch_subject_prefix;
+
+ if (default_date_mode)
+ rev->date_mode = parse_date_format(default_date_mode);
+
argc = setup_revisions(argc, argv, rev, "HEAD");
+
if (rev->diffopt.pickaxe || rev->diffopt.filter)
rev->always_show_header = 0;
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
@@ -197,7 +211,8 @@ static int cmd_log_walk(struct rev_info *rev)
if (rev->early_output)
setup_early_output(rev);
- prepare_revision_walk(rev);
+ if (prepare_revision_walk(rev))
+ die("revision walk setup failed");
if (rev->early_output)
finish_early_output(rev);
@@ -215,26 +230,30 @@ static int cmd_log_walk(struct rev_info *rev)
return 0;
}
-static int git_log_config(const char *var, const char *value)
+static int git_log_config(const char *var, const char *value, void *cb)
{
- if (!strcmp(var, "format.subjectprefix")) {
- if (!value)
- die("format.subjectprefix without value");
- fmt_patch_subject_prefix = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "format.pretty"))
+ return git_config_string(&fmt_pretty, var, value);
+ if (!strcmp(var, "format.subjectprefix"))
+ return git_config_string(&fmt_patch_subject_prefix, var, value);
+ if (!strcmp(var, "log.date"))
+ return git_config_string(&default_date_mode, var, value);
if (!strcmp(var, "log.showroot")) {
default_show_root = git_config_bool(var, value);
return 0;
}
- return git_diff_ui_config(var, value);
+ return git_diff_ui_config(var, value, cb);
}
int cmd_whatchanged(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- git_config(git_log_config);
+ git_config(git_log_config, NULL);
+
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
init_revisions(&rev, prefix);
rev.diff = 1;
rev.simplify_history = 0;
@@ -294,7 +313,7 @@ static int show_object(const unsigned char *sha1, int show_tag_object,
static int show_tree_object(const unsigned char *sha1,
const char *base, int baselen,
- const char *pathname, unsigned mode, int stage)
+ const char *pathname, unsigned mode, int stage, void *context)
{
printf("%s%s\n", pathname, S_ISDIR(mode) ? "/" : "");
return 0;
@@ -306,7 +325,11 @@ int cmd_show(int argc, const char **argv, const char *prefix)
struct object_array_entry *objects;
int i, count, ret = 0;
- git_config(git_log_config);
+ git_config(git_log_config, NULL);
+
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
init_revisions(&rev, prefix);
rev.diff = 1;
rev.combine_merges = 1;
@@ -333,7 +356,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
ret = show_object(o->sha1, 1, &rev);
- objects[i].item = (struct object *)t->tagged;
+ objects[i].item = parse_object(t->tagged->sha1);
i--;
break;
}
@@ -343,7 +366,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
name,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
read_tree_recursive((struct tree *)o, "", 0, 0, NULL,
- show_tree_object);
+ show_tree_object, NULL);
break;
case OBJ_COMMIT:
rev.pending.nr = rev.pending.alloc = 0;
@@ -366,7 +389,11 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- git_config(git_log_config);
+ git_config(git_log_config, NULL);
+
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
init_revisions(&rev, prefix);
init_reflog_walk(&rev.reflog_info);
rev.abbrev_commit = 1;
@@ -379,6 +406,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
* allow us to set a different default.
*/
rev.commit_format = CMIT_FMT_ONELINE;
+ rev.use_terminator = 1;
rev.always_show_header = 1;
/*
@@ -394,7 +422,11 @@ int cmd_log(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
- git_config(git_log_config);
+ git_config(git_log_config, NULL);
+
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
init_revisions(&rev, prefix);
rev.always_show_header = 1;
cmd_log_init(argc, argv, prefix, &rev);
@@ -410,117 +442,149 @@ static int istitlechar(char c)
(c >= '0' && c <= '9') || c == '.' || c == '_';
}
-static char *extra_headers = NULL;
-static int extra_headers_size = 0;
static const char *fmt_patch_suffix = ".patch";
static int numbered = 0;
static int auto_number = 0;
-static int git_format_config(const char *var, const char *value)
+static char **extra_hdr;
+static int extra_hdr_nr;
+static int extra_hdr_alloc;
+
+static char **extra_to;
+static int extra_to_nr;
+static int extra_to_alloc;
+
+static char **extra_cc;
+static int extra_cc_nr;
+static int extra_cc_alloc;
+
+static void add_header(const char *value)
{
- if (!strcmp(var, "format.headers")) {
- int len;
+ int len = strlen(value);
+ while (value[len - 1] == '\n')
+ len--;
+ if (!strncasecmp(value, "to: ", 4)) {
+ ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
+ extra_to[extra_to_nr++] = xstrndup(value + 4, len - 4);
+ return;
+ }
+ if (!strncasecmp(value, "cc: ", 4)) {
+ ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
+ extra_cc[extra_cc_nr++] = xstrndup(value + 4, len - 4);
+ return;
+ }
+ ALLOC_GROW(extra_hdr, extra_hdr_nr + 1, extra_hdr_alloc);
+ extra_hdr[extra_hdr_nr++] = xstrndup(value, len);
+}
+static int git_format_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "format.headers")) {
if (!value)
die("format.headers without value");
- len = strlen(value);
- extra_headers_size += len + 1;
- extra_headers = xrealloc(extra_headers, extra_headers_size);
- extra_headers[extra_headers_size - len - 1] = 0;
- strcat(extra_headers, value);
+ add_header(value);
return 0;
}
- if (!strcmp(var, "format.suffix")) {
+ if (!strcmp(var, "format.suffix"))
+ return git_config_string(&fmt_patch_suffix, var, value);
+ if (!strcmp(var, "format.cc")) {
if (!value)
- die("format.suffix without value");
- fmt_patch_suffix = xstrdup(value);
+ return config_error_nonbool(var);
+ ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
+ extra_cc[extra_cc_nr++] = xstrdup(value);
return 0;
}
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
return 0;
}
if (!strcmp(var, "format.numbered")) {
- if (!strcasecmp(value, "auto")) {
+ if (value && !strcasecmp(value, "auto")) {
auto_number = 1;
return 0;
}
-
numbered = git_config_bool(var, value);
return 0;
}
- return git_log_config(var, value);
+ return git_log_config(var, value, cb);
}
+static const char *get_oneline_for_filename(struct commit *commit,
+ int keep_subject)
+{
+ static char filename[PATH_MAX];
+ char *sol;
+ int len = 0;
+ int suffix_len = strlen(fmt_patch_suffix) + 1;
+
+ sol = strstr(commit->buffer, "\n\n");
+ if (!sol)
+ filename[0] = '\0';
+ else {
+ int j, space = 0;
+
+ sol += 2;
+ /* strip [PATCH] or [PATCH blabla] */
+ if (!keep_subject && !prefixcmp(sol, "[PATCH")) {
+ char *eos = strchr(sol + 6, ']');
+ if (eos) {
+ while (isspace(*eos))
+ eos++;
+ sol = eos;
+ }
+ }
+
+ for (j = 0;
+ j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 &&
+ len < sizeof(filename) - suffix_len &&
+ sol[j] && sol[j] != '\n';
+ j++) {
+ if (istitlechar(sol[j])) {
+ if (space) {
+ filename[len++] = '-';
+ space = 0;
+ }
+ filename[len++] = sol[j];
+ if (sol[j] == '.')
+ while (sol[j + 1] == '.')
+ j++;
+ } else
+ space = 1;
+ }
+ while (filename[len - 1] == '.'
+ || filename[len - 1] == '-')
+ len--;
+ filename[len] = '\0';
+ }
+ return filename;
+}
+
static FILE *realstdout = NULL;
static const char *output_directory = NULL;
-static int reopen_stdout(struct commit *commit, int nr, int keep_subject,
- int numbered_files)
+static int reopen_stdout(const char *oneline, int nr, int total)
{
char filename[PATH_MAX];
- char *sol;
int len = 0;
int suffix_len = strlen(fmt_patch_suffix) + 1;
if (output_directory) {
- if (strlen(output_directory) >=
+ len = snprintf(filename, sizeof(filename), "%s",
+ output_directory);
+ if (len >=
sizeof(filename) - FORMAT_PATCH_NAME_MAX - suffix_len)
return error("name of output directory is too long");
- strlcpy(filename, output_directory, sizeof(filename) - suffix_len);
- len = strlen(filename);
if (filename[len - 1] != '/')
filename[len++] = '/';
}
- if (numbered_files) {
- sprintf(filename + len, "%d", nr);
- len = strlen(filename);
-
- } else {
- sprintf(filename + len, "%04d", nr);
- len = strlen(filename);
-
- sol = strstr(commit->buffer, "\n\n");
- if (sol) {
- int j, space = 1;
-
- sol += 2;
- /* strip [PATCH] or [PATCH blabla] */
- if (!keep_subject && !prefixcmp(sol, "[PATCH")) {
- char *eos = strchr(sol + 6, ']');
- if (eos) {
- while (isspace(*eos))
- eos++;
- sol = eos;
- }
- }
-
- for (j = 0;
- j < FORMAT_PATCH_NAME_MAX - suffix_len - 5 &&
- len < sizeof(filename) - suffix_len &&
- sol[j] && sol[j] != '\n';
- j++) {
- if (istitlechar(sol[j])) {
- if (space) {
- filename[len++] = '-';
- space = 0;
- }
- filename[len++] = sol[j];
- if (sol[j] == '.')
- while (sol[j + 1] == '.')
- j++;
- } else
- space = 1;
- }
- while (filename[len - 1] == '.'
- || filename[len - 1] == '-')
- len--;
- filename[len] = 0;
- }
- if (len + suffix_len >= sizeof(filename))
- return error("Patch pathname too long");
+ if (!oneline)
+ len += sprintf(filename + len, "%d", nr);
+ else {
+ len += sprintf(filename + len, "%04d-", nr);
+ len += snprintf(filename + len, sizeof(filename) - len - 1
+ - suffix_len, "%s", oneline);
strcpy(filename + len, fmt_patch_suffix);
}
@@ -557,7 +621,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
o2->flags ^= UNINTERESTING;
add_pending_object(&check_rev, o1, "o1");
add_pending_object(&check_rev, o2, "o2");
- prepare_revision_walk(&check_rev);
+ if (prepare_revision_walk(&check_rev))
+ die("revision walk setup failed");
while ((commit = get_revision(&check_rev)) != NULL) {
/* ignore merges */
@@ -576,16 +641,92 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
o2->flags = flags2;
}
-static void gen_message_id(char *dest, unsigned int length, char *base)
+static void gen_message_id(struct rev_info *info, char *base)
{
const char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME);
const char *email_start = strrchr(committer, '<');
const char *email_end = strrchr(committer, '>');
- if(!email_start || !email_end || email_start > email_end - 1)
+ struct strbuf buf;
+ if (!email_start || !email_end || email_start > email_end - 1)
die("Could not extract email from committer identity.");
- snprintf(dest, length, "%s.%lu.git.%.*s", base,
- (unsigned long) time(NULL),
- (int)(email_end - email_start - 1), email_start + 1);
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
+ (unsigned long) time(NULL),
+ (int)(email_end - email_start - 1), email_start + 1);
+ info->message_id = strbuf_detach(&buf, NULL);
+}
+
+static void make_cover_letter(struct rev_info *rev, int use_stdout,
+ int numbered, int numbered_files,
+ struct commit *origin,
+ int nr, struct commit **list, struct commit *head)
+{
+ const char *committer;
+ char *head_sha1;
+ const char *subject_start = NULL;
+ const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
+ const char *msg;
+ const char *extra_headers = rev->extra_headers;
+ struct shortlog log;
+ struct strbuf sb;
+ int i;
+ const char *encoding = "utf-8";
+ struct diff_options opts;
+ int need_8bit_cte = 0;
+
+ if (rev->commit_format != CMIT_FMT_EMAIL)
+ die("Cover letter needs email format");
+
+ if (!use_stdout && reopen_stdout(numbered_files ?
+ NULL : "cover-letter", 0, rev->total))
+ return;
+
+ head_sha1 = sha1_to_hex(head->object.sha1);
+
+ log_write_email_headers(rev, head_sha1, &subject_start, &extra_headers,
+ &need_8bit_cte);
+
+ committer = git_committer_info(0);
+
+ msg = body;
+ strbuf_init(&sb, 0);
+ pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822,
+ encoding);
+ pp_title_line(CMIT_FMT_EMAIL, &msg, &sb, subject_start, extra_headers,
+ encoding, need_8bit_cte);
+ pp_remainder(CMIT_FMT_EMAIL, &msg, &sb, 0);
+ printf("%s\n", sb.buf);
+
+ strbuf_release(&sb);
+
+ shortlog_init(&log);
+ log.wrap_lines = 1;
+ log.wrap = 72;
+ log.in1 = 2;
+ log.in2 = 4;
+ for (i = 0; i < nr; i++)
+ shortlog_add_commit(&log, list[i]);
+
+ shortlog_output(&log);
+
+ /*
+ * We can only do diffstat with a unique reference point
+ */
+ if (!origin)
+ return;
+
+ memcpy(&opts, &rev->diffopt, sizeof(opts));
+ opts.output_format = DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+
+ diff_setup_done(&opts);
+
+ diff_tree_sha1(origin->tree->object.sha1,
+ head->tree->object.sha1,
+ "", &opts);
+ diffcore_std(&opts);
+ diff_flush(&opts);
+
+ printf("\n");
}
static const char *clean_message_id(const char *msg_id)
@@ -623,24 +764,25 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
int subject_prefix = 0;
int ignore_if_in_upstream = 0;
int thread = 0;
+ int cover_letter = 0;
+ int boundary_count = 0;
+ int no_binary_diff = 0;
+ struct commit *origin = NULL, *head = NULL;
const char *in_reply_to = NULL;
struct patch_ids ids;
char *add_signoff = NULL;
- char message_id[1024];
- char ref_message_id[1024];
+ struct strbuf buf;
- git_config(git_format_config);
+ git_config(git_format_config, NULL);
init_revisions(&rev, prefix);
rev.commit_format = CMIT_FMT_EMAIL;
rev.verbose_header = 1;
rev.diff = 1;
rev.combine_merges = 0;
rev.ignore_merges = 1;
- rev.diffopt.msg_sep = "";
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
rev.subject_prefix = fmt_patch_subject_prefix;
- rev.extra_headers = extra_headers;
/*
* Parse the arguments before setup_revisions(), or something
@@ -668,6 +810,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
die("Need a number for --start-number");
start_number = strtol(argv[i], NULL, 10);
}
+ else if (!prefixcmp(argv[i], "--cc=")) {
+ ALLOC_GROW(extra_cc, extra_cc_nr + 1, extra_cc_alloc);
+ extra_cc[extra_cc_nr++] = xstrdup(argv[i] + 5);
+ }
else if (!strcmp(argv[i], "-k") ||
!strcmp(argv[i], "--keep-subject")) {
keep_subject = 1;
@@ -724,11 +870,46 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.subject_prefix = argv[i] + 17;
} else if (!prefixcmp(argv[i], "--suffix="))
fmt_patch_suffix = argv[i] + 9;
+ else if (!strcmp(argv[i], "--cover-letter"))
+ cover_letter = 1;
+ else if (!strcmp(argv[i], "--no-binary"))
+ no_binary_diff = 1;
else
argv[j++] = argv[i];
}
argc = j;
+ strbuf_init(&buf, 0);
+
+ for (i = 0; i < extra_hdr_nr; i++) {
+ strbuf_addstr(&buf, extra_hdr[i]);
+ strbuf_addch(&buf, '\n');
+ }
+
+ if (extra_to_nr)
+ strbuf_addstr(&buf, "To: ");
+ for (i = 0; i < extra_to_nr; i++) {
+ if (i)
+ strbuf_addstr(&buf, " ");
+ strbuf_addstr(&buf, extra_to[i]);
+ if (i + 1 < extra_to_nr)
+ strbuf_addch(&buf, ',');
+ strbuf_addch(&buf, '\n');
+ }
+
+ if (extra_cc_nr)
+ strbuf_addstr(&buf, "Cc: ");
+ for (i = 0; i < extra_cc_nr; i++) {
+ if (i)
+ strbuf_addstr(&buf, " ");
+ strbuf_addstr(&buf, extra_cc[i]);
+ if (i + 1 < extra_cc_nr)
+ strbuf_addch(&buf, ',');
+ strbuf_addch(&buf, '\n');
+ }
+
+ rev.extra_headers = strbuf_detach(&buf, 0);
+
if (start_number < 0)
start_number = 1;
if (numbered && keep_subject)
@@ -745,7 +926,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
- if (!DIFF_OPT_TST(&rev.diffopt, TEXT))
+ if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
DIFF_OPT_SET(&rev.diffopt, BINARY);
if (!output_directory && !use_stdout)
@@ -775,6 +956,18 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
* get_revision() to do the usual traversal.
*/
}
+ if (cover_letter) {
+ /* remember the range */
+ int i;
+ for (i = 0; i < rev.pending.nr; i++) {
+ struct object *o = rev.pending.objects[i].item;
+ if (!(o->flags & UNINTERESTING))
+ head = (struct commit *)o;
+ }
+ /* We can't generate a cover letter without any patches */
+ if (!head)
+ return 0;
+ }
if (ignore_if_in_upstream)
get_patch_ids(&rev, &ids, prefix);
@@ -782,8 +975,16 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!use_stdout)
realstdout = xfdopen(xdup(1), "w");
- prepare_revision_walk(&rev);
+ if (prepare_revision_walk(&rev))
+ die("revision walk setup failed");
+ rev.boundary = 1;
while ((commit = get_revision(&rev)) != NULL) {
+ if (commit->object.flags & BOUNDARY) {
+ boundary_count++;
+ origin = (boundary_count == 1) ? commit : NULL;
+ continue;
+ }
+
/* ignore merges */
if (commit->parents && commit->parents->next)
continue;
@@ -801,29 +1002,42 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
numbered = 1;
if (numbered)
rev.total = total + start_number - 1;
- rev.add_signoff = add_signoff;
if (in_reply_to)
rev.ref_message_id = clean_message_id(in_reply_to);
+ if (cover_letter) {
+ if (thread)
+ gen_message_id(&rev, "cover");
+ make_cover_letter(&rev, use_stdout, numbered, numbered_files,
+ origin, nr, list, head);
+ total++;
+ start_number--;
+ }
+ rev.add_signoff = add_signoff;
while (0 <= --nr) {
int shown;
commit = list[nr];
rev.nr = total - nr + (start_number - 1);
/* Make the second and subsequent mails replies to the first */
if (thread) {
- if (nr == (total - 2)) {
- strncpy(ref_message_id, message_id,
- sizeof(ref_message_id));
- ref_message_id[sizeof(ref_message_id)-1]='\0';
- rev.ref_message_id = ref_message_id;
+ /* Have we already had a message ID? */
+ if (rev.message_id) {
+ /*
+ * If we've got the ID to be a reply
+ * to, discard the current ID;
+ * otherwise, make everything a reply
+ * to that.
+ */
+ if (rev.ref_message_id)
+ free(rev.message_id);
+ else
+ rev.ref_message_id = rev.message_id;
}
- gen_message_id(message_id, sizeof(message_id),
- sha1_to_hex(commit->object.sha1));
- rev.message_id = message_id;
+ gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
}
- if (!use_stdout)
- if (reopen_stdout(commit, rev.nr, keep_subject,
- numbered_files))
- die("Failed to create output files");
+ if (!use_stdout && reopen_stdout(numbered_files ? NULL :
+ get_oneline_for_filename(commit, keep_subject),
+ rev.nr, rev.total))
+ die("Failed to create output files");
shown = log_tree_commit(&rev, commit);
free(commit->buffer);
commit->buffer = NULL;
@@ -868,7 +1082,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
}
static const char cherry_usage[] =
-"git-cherry [-v] <upstream> [<head>] [<limit>]";
+"git cherry [-v] <upstream> [<head>] [<limit>]";
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -924,7 +1138,8 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
die("Unknown commit %s", limit);
/* reverse the list of commits */
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
while ((commit = get_revision(&revs)) != NULL) {
/* ignore merges */
if (commit->parents && commit->parents->next)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index d56e33e25..e8d568eed 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -238,7 +238,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
if (show_cached | show_stage) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
- if (excluded(dir, ce->name) != dir->show_ignored)
+ int dtype = ce_to_dtype(ce);
+ if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
continue;
if (show_unmerged && !ce_stage(ce))
continue;
@@ -252,7 +253,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
struct cache_entry *ce = active_cache[i];
struct stat st;
int err;
- if (excluded(dir, ce->name) != dir->show_ignored)
+ int dtype = ce_to_dtype(ce);
+ if (excluded(dir, ce->name, &dtype) != dir->show_ignored)
continue;
err = lstat(ce->name, &st);
if (show_deleted && err)
@@ -421,7 +423,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_
}
static const char ls_files_usage[] =
- "git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
+ "git ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
"[ --exclude-per-directory=<filename> ] [--exclude-standard] "
"[--full-name] [--abbrev] [--] [<file>]*";
@@ -435,7 +437,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
memset(&dir, 0, sizeof(dir));
if (prefix)
prefix_offset = strlen(prefix);
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
diff --git a/builtin-ls-remote.c b/builtin-ls-remote.c
index 6dd31d1dd..c21b841e7 100644
--- a/builtin-ls-remote.c
+++ b/builtin-ls-remote.c
@@ -4,7 +4,7 @@
#include "remote.h"
static const char ls_remote_usage[] =
-"git-ls-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
+"git ls-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
/*
* Is there one among the list of patterns that match the tail part
@@ -31,7 +31,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
{
int i;
const char *dest = NULL;
- int nongit = 0;
+ int nongit;
unsigned flags = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
@@ -94,10 +94,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
ref = transport_get_remote_refs(transport);
-
- if (!ref)
+ if (transport_disconnect(transport))
return 1;
-
for ( ; ref; ref = ref->next) {
if (!check_ref_type(ref, flags))
continue;
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index 7abe333ce..cb6171768 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -23,7 +23,7 @@ static int chomp_prefix;
static const char *ls_tree_prefix;
static const char ls_tree_usage[] =
- "git-ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
+ "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
static int show_recursive(const char *base, int baselen, const char *pathname)
{
@@ -56,7 +56,7 @@ static int show_recursive(const char *base, int baselen, const char *pathname)
}
static int show_tree(const unsigned char *sha1, const char *base, int baselen,
- const char *pathname, unsigned mode, int stage)
+ const char *pathname, unsigned mode, int stage, void *context)
{
int retval = 0;
const char *type = blob_type;
@@ -66,17 +66,16 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
/*
* Maybe we want to have some recursive version here?
*
- * Something like:
+ * Something similar to this incomplete example:
*
if (show_subprojects(base, baselen, pathname)) {
- if (fork()) {
- chdir(base);
- exec ls-tree;
- }
- waitpid();
+ struct child_process ls_tree;
+
+ ls_tree.dir = base;
+ ls_tree.argv = ls-tree;
+ start_command(&ls_tree);
}
*
- * ..or similar..
*/
type = commit_type;
} else if (S_ISDIR(mode)) {
@@ -122,7 +121,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
unsigned char sha1[20];
struct tree *tree;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
ls_tree_prefix = prefix;
if (prefix && *prefix)
chomp_prefix = strlen(prefix);
@@ -189,7 +188,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
tree = parse_tree_indirect(sha1);
if (!tree)
die("not a tree object");
- read_tree_recursive(tree, "", 0, 0, pathspec, show_tree);
+ read_tree_recursive(tree, "", 0, 0, pathspec, show_tree, NULL);
return 0;
}
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 260084797..3577382d7 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -5,14 +5,15 @@
#include "cache.h"
#include "builtin.h"
#include "utf8.h"
+#include "strbuf.h"
static FILE *cmitmsg, *patchfile, *fin, *fout;
static int keep_subject;
static const char *metainfo_charset;
-static char line[1000];
-static char name[1000];
-static char email[1000];
+static struct strbuf line = STRBUF_INIT;
+static struct strbuf name = STRBUF_INIT;
+static struct strbuf email = STRBUF_INIT;
static enum {
TE_DONTCARE, TE_QP, TE_BASE64,
@@ -21,74 +22,79 @@ static enum {
TYPE_TEXT, TYPE_OTHER,
} message_type;
-static char charset[256];
+static struct strbuf charset = STRBUF_INIT;
static int patch_lines;
-static char **p_hdr_data, **s_hdr_data;
+static struct strbuf **p_hdr_data, **s_hdr_data;
#define MAX_HDR_PARSED 10
#define MAX_BOUNDARIES 5
-static char *sanity_check(char *name, char *email)
+static void get_sane_name(struct strbuf *out, struct strbuf *name, struct strbuf *email)
{
- int len = strlen(name);
- if (len < 3 || len > 60)
- return email;
- if (strchr(name, '@') || strchr(name, '<') || strchr(name, '>'))
- return email;
- return name;
+ struct strbuf *src = name;
+ if (name->len < 3 || 60 < name->len || strchr(name->buf, '@') ||
+ strchr(name->buf, '<') || strchr(name->buf, '>'))
+ src = email;
+ else if (name == out)
+ return;
+ strbuf_reset(out);
+ strbuf_addbuf(out, src);
}
-static int bogus_from(char *line)
+static void parse_bogus_from(const struct strbuf *line)
{
/* John Doe <johndoe> */
- char *bra, *ket, *dst, *cp;
+ char *bra, *ket;
/* This is fallback, so do not bother if we already have an
* e-mail address.
*/
- if (*email)
- return 0;
+ if (email.len)
+ return;
- bra = strchr(line, '<');
+ bra = strchr(line->buf, '<');
if (!bra)
- return 0;
+ return;
ket = strchr(bra, '>');
if (!ket)
- return 0;
+ return;
- for (dst = email, cp = bra+1; cp < ket; )
- *dst++ = *cp++;
- *dst = 0;
- for (cp = line; isspace(*cp); cp++)
- ;
- for (bra--; isspace(*bra); bra--)
- *bra = 0;
- cp = sanity_check(cp, email);
- strcpy(name, cp);
- return 1;
+ strbuf_reset(&email);
+ strbuf_add(&email, bra + 1, ket - bra - 1);
+
+ strbuf_reset(&name);
+ strbuf_add(&name, line->buf, bra - line->buf);
+ strbuf_trim(&name);
+ get_sane_name(&name, &name, &email);
}
-static int handle_from(char *in_line)
+static void handle_from(const struct strbuf *from)
{
- char line[1000];
char *at;
- char *dst;
+ size_t el;
+ struct strbuf f;
- strcpy(line, in_line);
- at = strchr(line, '@');
- if (!at)
- return bogus_from(line);
+ strbuf_init(&f, from->len);
+ strbuf_addbuf(&f, from);
+
+ at = strchr(f.buf, '@');
+ if (!at) {
+ parse_bogus_from(from);
+ return;
+ }
/*
* If we already have one email, don't take any confusing lines
*/
- if (*email && strchr(at+1, '@'))
- return 0;
+ if (email.len && strchr(at + 1, '@')) {
+ strbuf_release(&f);
+ return;
+ }
/* Pick up the string around '@', possibly delimited with <>
- * pair; that is the email part. White them out while copying.
+ * pair; that is the email part.
*/
- while (at > line) {
+ while (at > f.buf) {
char c = at[-1];
if (isspace(c))
break;
@@ -98,56 +104,35 @@ static int handle_from(char *in_line)
}
at--;
}
- dst = email;
- for (;;) {
- unsigned char c = *at;
- if (!c || c == '>' || isspace(c)) {
- if (c == '>')
- *at = ' ';
- break;
- }
- *at++ = ' ';
- *dst++ = c;
- }
- *dst++ = 0;
+ el = strcspn(at, " \n\t\r\v\f>");
+ strbuf_reset(&email);
+ strbuf_add(&email, at, el);
+ strbuf_remove(&f, at - f.buf, el + 1);
/* The remainder is name. It could be "John Doe <john.doe@xz>"
- * or "john.doe@xz (John Doe)", but we have whited out the
+ * or "john.doe@xz (John Doe)", but we have removed the
* email part, so trim from both ends, possibly removing
* the () pair at the end.
*/
- at = line + strlen(line);
- while (at > line) {
- unsigned char c = *--at;
- if (!isspace(c)) {
- at[(c == ')') ? 0 : 1] = 0;
- break;
- }
+ strbuf_trim(&f);
+ if (f.buf[0] == '(' && f.len && f.buf[f.len - 1] == ')') {
+ strbuf_remove(&f, 0, 1);
+ strbuf_setlen(&f, f.len - 1);
}
- at = line;
- for (;;) {
- unsigned char c = *at;
- if (!c || !isspace(c)) {
- if (c == '(')
- at++;
- break;
- }
- at++;
- }
- at = sanity_check(at, email);
- strcpy(name, at);
- return 1;
+ get_sane_name(&name, &f, &email);
+ strbuf_release(&f);
}
-static int handle_header(char *line, char *data, int ofs)
+static void handle_header(struct strbuf **out, const struct strbuf *line)
{
- if (!line || !data)
- return 1;
-
- strcpy(data, line+ofs);
+ if (!*out) {
+ *out = xmalloc(sizeof(struct strbuf));
+ strbuf_init(*out, line->len);
+ } else
+ strbuf_reset(*out);
- return 0;
+ strbuf_addbuf(*out, line);
}
/* NOTE NOTE NOTE. We do not claim we do full MIME. We just attempt
@@ -156,13 +141,13 @@ static int handle_header(char *line, char *data, int ofs)
* case insensitively.
*/
-static int slurp_attr(const char *line, const char *name, char *attr)
+static int slurp_attr(const char *line, const char *name, struct strbuf *attr)
{
const char *ends, *ap = strcasestr(line, name);
size_t sz;
if (!ap) {
- *attr = 0;
+ strbuf_setlen(attr, 0);
return 0;
}
ap += strlen(name);
@@ -173,180 +158,172 @@ static int slurp_attr(const char *line, const char *name, char *attr)
else
ends = "; \t";
sz = strcspn(ap, ends);
- memcpy(attr, ap, sz);
- attr[sz] = 0;
+ strbuf_add(attr, ap, sz);
return 1;
}
-struct content_type {
- char *boundary;
- int boundary_len;
-};
-
-static struct content_type content[MAX_BOUNDARIES];
+static struct strbuf *content[MAX_BOUNDARIES];
-static struct content_type *content_top = content;
+static struct strbuf **content_top = content;
-static int handle_content_type(char *line)
+static void handle_content_type(struct strbuf *line)
{
- char boundary[256];
+ struct strbuf *boundary = xmalloc(sizeof(struct strbuf));
+ strbuf_init(boundary, line->len);
- if (strcasestr(line, "text/") == NULL)
+ if (!strcasestr(line->buf, "text/"))
message_type = TYPE_OTHER;
- if (slurp_attr(line, "boundary=", boundary + 2)) {
- memcpy(boundary, "--", 2);
+ if (slurp_attr(line->buf, "boundary=", boundary)) {
+ strbuf_insert(boundary, 0, "--", 2);
if (content_top++ >= &content[MAX_BOUNDARIES]) {
fprintf(stderr, "Too many boundaries to handle\n");
exit(1);
}
- content_top->boundary_len = strlen(boundary);
- content_top->boundary = xmalloc(content_top->boundary_len+1);
- strcpy(content_top->boundary, boundary);
+ *content_top = boundary;
+ boundary = NULL;
}
- if (slurp_attr(line, "charset=", charset)) {
- int i, c;
- for (i = 0; (c = charset[i]) != 0; i++)
- charset[i] = tolower(c);
+ if (slurp_attr(line->buf, "charset=", &charset))
+ strbuf_tolower(&charset);
+
+ if (boundary) {
+ strbuf_release(boundary);
+ free(boundary);
}
- return 0;
}
-static int handle_content_transfer_encoding(char *line)
+static void handle_content_transfer_encoding(const struct strbuf *line)
{
- if (strcasestr(line, "base64"))
+ if (strcasestr(line->buf, "base64"))
transfer_encoding = TE_BASE64;
- else if (strcasestr(line, "quoted-printable"))
+ else if (strcasestr(line->buf, "quoted-printable"))
transfer_encoding = TE_QP;
else
transfer_encoding = TE_DONTCARE;
- return 0;
-}
-
-static int is_multipart_boundary(const char *line)
-{
- return (!memcmp(line, content_top->boundary, content_top->boundary_len));
}
-static int eatspace(char *line)
+static int is_multipart_boundary(const struct strbuf *line)
{
- int len = strlen(line);
- while (len > 0 && isspace(line[len-1]))
- line[--len] = 0;
- return len;
+ return (((*content_top)->len <= line->len) &&
+ !memcmp(line->buf, (*content_top)->buf, (*content_top)->len));
}
-static char *cleanup_subject(char *subject)
+static void cleanup_subject(struct strbuf *subject)
{
- for (;;) {
- char *p;
- int len, remove;
- switch (*subject) {
+ char *pos;
+ size_t remove;
+ while (subject->len) {
+ switch (*subject->buf) {
case 'r': case 'R':
- if (!memcmp("e:", subject+1, 2)) {
- subject += 3;
+ if (subject->len <= 3)
+ break;
+ if (!memcmp(subject->buf + 1, "e:", 2)) {
+ strbuf_remove(subject, 0, 3);
continue;
}
break;
case ' ': case '\t': case ':':
- subject++;
+ strbuf_remove(subject, 0, 1);
continue;
-
case '[':
- p = strchr(subject, ']');
- if (!p) {
- subject++;
- continue;
- }
- len = strlen(p);
- remove = p - subject;
- if (remove <= len *2) {
- subject = p+1;
- continue;
- }
+ if ((pos = strchr(subject->buf, ']'))) {
+ remove = pos - subject->buf;
+ if (remove <= (subject->len - remove) * 2) {
+ strbuf_remove(subject, 0, remove + 1);
+ continue;
+ }
+ } else
+ strbuf_remove(subject, 0, 1);
break;
}
- eatspace(subject);
- return subject;
+ strbuf_trim(subject);
+ return;
}
}
-static void cleanup_space(char *buf)
+static void cleanup_space(struct strbuf *sb)
{
- unsigned char c;
- while ((c = *buf) != 0) {
- buf++;
- if (isspace(c)) {
- buf[-1] = ' ';
- c = *buf;
- while (isspace(c)) {
- int len = strlen(buf);
- memmove(buf, buf+1, len);
- c = *buf;
- }
+ size_t pos, cnt;
+ for (pos = 0; pos < sb->len; pos++) {
+ if (isspace(sb->buf[pos])) {
+ sb->buf[pos] = ' ';
+ for (cnt = 0; isspace(sb->buf[pos + cnt + 1]); cnt++);
+ strbuf_remove(sb, pos + 1, cnt);
}
}
}
-static void decode_header(char *it, unsigned itsize);
+static void decode_header(struct strbuf *line);
static const char *header[MAX_HDR_PARSED] = {
"From","Subject","Date",
};
-static int check_header(char *line, unsigned linesize, char **hdr_data, int overwrite)
+static inline int cmp_header(const struct strbuf *line, const char *hdr)
{
- int i;
+ int len = strlen(hdr);
+ return !strncasecmp(line->buf, hdr, len) && line->len > len &&
+ line->buf[len] == ':' && isspace(line->buf[len + 1]);
+}
+static int check_header(const struct strbuf *line,
+ struct strbuf *hdr_data[], int overwrite)
+{
+ int i, ret = 0, len;
+ struct strbuf sb = STRBUF_INIT;
/* search for the interesting parts */
for (i = 0; header[i]; i++) {
int len = strlen(header[i]);
- if ((!hdr_data[i] || overwrite) &&
- !strncasecmp(line, header[i], len) &&
- line[len] == ':' && isspace(line[len + 1])) {
+ if ((!hdr_data[i] || overwrite) && cmp_header(line, header[i])) {
/* Unwrap inline B and Q encoding, and optionally
* normalize the meta information to utf8.
*/
- decode_header(line + len + 2, linesize - len - 2);
- hdr_data[i] = xmalloc(1000 * sizeof(char));
- if (! handle_header(line, hdr_data[i], len + 2)) {
- return 1;
- }
+ strbuf_add(&sb, line->buf + len + 2, line->len - len - 2);
+ decode_header(&sb);
+ handle_header(&hdr_data[i], &sb);
+ ret = 1;
+ goto check_header_out;
}
}
/* Content stuff */
- if (!strncasecmp(line, "Content-Type", 12) &&
- line[12] == ':' && isspace(line[12 + 1])) {
- decode_header(line + 12 + 2, linesize - 12 - 2);
- if (! handle_content_type(line)) {
- return 1;
- }
- }
- if (!strncasecmp(line, "Content-Transfer-Encoding", 25) &&
- line[25] == ':' && isspace(line[25 + 1])) {
- decode_header(line + 25 + 2, linesize - 25 - 2);
- if (! handle_content_transfer_encoding(line)) {
- return 1;
- }
+ if (cmp_header(line, "Content-Type")) {
+ len = strlen("Content-Type: ");
+ strbuf_add(&sb, line->buf + len, line->len - len);
+ decode_header(&sb);
+ strbuf_insert(&sb, 0, "Content-Type: ", len);
+ handle_content_type(&sb);
+ ret = 1;
+ goto check_header_out;
+ }
+ if (cmp_header(line, "Content-Transfer-Encoding")) {
+ len = strlen("Content-Transfer-Encoding: ");
+ strbuf_add(&sb, line->buf + len, line->len - len);
+ decode_header(&sb);
+ handle_content_transfer_encoding(&sb);
+ ret = 1;
+ goto check_header_out;
}
/* for inbody stuff */
- if (!memcmp(">From", line, 5) && isspace(line[5]))
- return 1;
- if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
+ if (!prefixcmp(line->buf, ">From") && isspace(line->buf[5])) {
+ ret = 1; /* Should this return 0? */
+ goto check_header_out;
+ }
+ if (!prefixcmp(line->buf, "[PATCH]") && isspace(line->buf[7])) {
for (i = 0; header[i]; i++) {
- if (!memcmp("Subject: ", header[i], 9)) {
- if (! handle_header(line, hdr_data[i], 0)) {
- return 1;
- }
+ if (!memcmp("Subject", header[i], 7)) {
+ handle_header(&hdr_data[i], line);
+ ret = 1;
+ goto check_header_out;
}
}
}
- /* no match */
- return 0;
+check_header_out:
+ strbuf_release(&sb);
+ return ret;
}
-static int is_rfc2822_header(char *line)
+static int is_rfc2822_header(const struct strbuf *line)
{
/*
* The section that defines the loosest possible
@@ -357,15 +334,15 @@ static int is_rfc2822_header(char *line)
* ftext = %d33-57 / %59-126
*/
int ch;
- char *cp = line;
+ char *cp = line->buf;
/* Count mbox From headers as headers */
- if (!memcmp(line, "From ", 5) || !memcmp(line, ">From ", 6))
+ if (!prefixcmp(cp, "From ") || !prefixcmp(cp, ">From "))
return 1;
while ((ch = *cp++)) {
if (ch == ':')
- return cp != line;
+ return 1;
if ((33 <= ch && ch <= 57) ||
(59 <= ch && ch <= 126))
continue;
@@ -374,34 +351,20 @@ static int is_rfc2822_header(char *line)
return 0;
}
-/*
- * sz is size of 'line' buffer in bytes. Must be reasonably
- * long enough to hold one physical real-world e-mail line.
- */
-static int read_one_header_line(char *line, int sz, FILE *in)
+static int read_one_header_line(struct strbuf *line, FILE *in)
{
- int len;
-
- /*
- * We will read at most (sz-1) bytes and then potentially
- * re-add NUL after it. Accessing line[sz] after this is safe
- * and we can allow len to grow up to and including sz.
- */
- sz--;
-
/* Get the first part of the line. */
- if (!fgets(line, sz, in))
+ if (strbuf_getline(line, in, '\n'))
return 0;
/*
* Is it an empty line or not a valid rfc2822 header?
* If so, stop here, and return false ("not a header")
*/
- len = eatspace(line);
- if (!len || !is_rfc2822_header(line)) {
+ strbuf_rtrim(line);
+ if (!line->len || !is_rfc2822_header(line)) {
/* Re-add the newline */
- line[len] = '\n';
- line[len + 1] = '\0';
+ strbuf_addch(line, '\n');
return 0;
}
@@ -410,63 +373,53 @@ static int read_one_header_line(char *line, int sz, FILE *in)
* Yuck, 2822 header "folding"
*/
for (;;) {
- int peek, addlen;
- static char continuation[1000];
+ int peek;
+ struct strbuf continuation = STRBUF_INIT;
peek = fgetc(in); ungetc(peek, in);
if (peek != ' ' && peek != '\t')
break;
- if (!fgets(continuation, sizeof(continuation), in))
+ if (strbuf_getline(&continuation, in, '\n'))
break;
- addlen = eatspace(continuation);
- if (len < sz - 1) {
- if (addlen >= sz - len)
- addlen = sz - len - 1;
- memcpy(line + len, continuation, addlen);
- line[len] = '\n';
- len += addlen;
- }
+ continuation.buf[0] = '\n';
+ strbuf_rtrim(&continuation);
+ strbuf_addbuf(line, &continuation);
}
- line[len] = 0;
return 1;
}
-static int decode_q_segment(char *in, char *ot, unsigned otsize, char *ep, int rfc2047)
+static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
{
- char *otend = ot + otsize;
+ const char *in = q_seg->buf;
int c;
- while ((c = *in++) != 0 && (in <= ep)) {
- if (ot == otend) {
- *--ot = '\0';
- return -1;
- }
+ struct strbuf *out = xmalloc(sizeof(struct strbuf));
+ strbuf_init(out, q_seg->len);
+
+ while ((c = *in++) != 0) {
if (c == '=') {
int d = *in++;
if (d == '\n' || !d)
break; /* drop trailing newline */
- *ot++ = ((hexval(d) << 4) | hexval(*in++));
+ strbuf_addch(out, (hexval(d) << 4) | hexval(*in++));
continue;
}
if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */
c = 0x20;
- *ot++ = c;
+ strbuf_addch(out, c);
}
- *ot = 0;
- return 0;
+ return out;
}
-static int decode_b_segment(char *in, char *ot, unsigned otsize, char *ep)
+static struct strbuf *decode_b_segment(const struct strbuf *b_seg)
{
/* Decode in..ep, possibly in-place to ot */
int c, pos = 0, acc = 0;
- char *otend = ot + otsize;
+ const char *in = b_seg->buf;
+ struct strbuf *out = xmalloc(sizeof(struct strbuf));
+ strbuf_init(out, b_seg->len);
- while ((c = *in++) != 0 && (in <= ep)) {
- if (ot == otend) {
- *--ot = '\0';
- return -1;
- }
+ while ((c = *in++) != 0) {
if (c == '+')
c = 62;
else if (c == '/')
@@ -491,21 +444,20 @@ static int decode_b_segment(char *in, char *ot, unsigned otsize, char *ep)
acc = (c << 2);
break;
case 1:
- *ot++ = (acc | (c >> 4));
+ strbuf_addch(out, (acc | (c >> 4)));
acc = (c & 15) << 4;
break;
case 2:
- *ot++ = (acc | (c >> 2));
+ strbuf_addch(out, (acc | (c >> 2)));
acc = (c & 3) << 6;
break;
case 3:
- *ot++ = (acc | c);
+ strbuf_addch(out, (acc | c));
acc = pos = 0;
break;
}
}
- *ot = 0;
- return 0;
+ return out;
}
/*
@@ -519,16 +471,16 @@ static int decode_b_segment(char *in, char *ot, unsigned otsize, char *ep)
* Otherwise, we default to assuming it is Latin1 for historical
* reasons.
*/
-static const char *guess_charset(const char *line, const char *target_charset)
+static const char *guess_charset(const struct strbuf *line, const char *target_charset)
{
if (is_encoding_utf8(target_charset)) {
- if (is_utf8(line))
+ if (is_utf8(line->buf))
return NULL;
}
return "latin1";
}
-static void convert_to_utf8(char *line, unsigned linesize, const char *charset)
+static void convert_to_utf8(struct strbuf *line, const char *charset)
{
char *out;
@@ -540,113 +492,118 @@ static void convert_to_utf8(char *line, unsigned linesize, const char *charset)
if (!strcmp(metainfo_charset, charset))
return;
- out = reencode_string(line, metainfo_charset, charset);
+ out = reencode_string(line->buf, metainfo_charset, charset);
if (!out)
die("cannot convert from %s to %s\n",
charset, metainfo_charset);
- strlcpy(line, out, linesize);
- free(out);
+ strbuf_attach(line, out, strlen(out), strlen(out));
}
-static int decode_header_bq(char *it, unsigned itsize)
+static int decode_header_bq(struct strbuf *it)
{
- char *in, *out, *ep, *cp, *sp;
- char outbuf[1000];
+ char *in, *ep, *cp;
+ struct strbuf outbuf = STRBUF_INIT, *dec;
+ struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
int rfc2047 = 0;
- in = it;
- out = outbuf;
- while ((ep = strstr(in, "=?")) != NULL) {
- int sz, encoding;
- char charset_q[256], piecebuf[256];
+ in = it->buf;
+ while (in - it->buf <= it->len && (ep = strstr(in, "=?")) != NULL) {
+ int encoding;
+ strbuf_reset(&charset_q);
+ strbuf_reset(&piecebuf);
rfc2047 = 1;
if (in != ep) {
- sz = ep - in;
- memcpy(out, in, sz);
- out += sz;
- in += sz;
+ strbuf_add(&outbuf, in, ep - in);
+ in = ep;
}
/* E.g.
* ep : "=?iso-2022-jp?B?GyR...?= foo"
* ep : "=?ISO-8859-1?Q?Foo=FCbar?= baz"
*/
ep += 2;
- cp = strchr(ep, '?');
- if (!cp)
- return rfc2047; /* no munging */
- for (sp = ep; sp < cp; sp++)
- charset_q[sp - ep] = tolower(*sp);
- charset_q[cp - ep] = 0;
+
+ if (ep - it->buf >= it->len || !(cp = strchr(ep, '?')))
+ goto decode_header_bq_out;
+
+ if (cp + 3 - it->buf > it->len)
+ goto decode_header_bq_out;
+ strbuf_add(&charset_q, ep, cp - ep);
+ strbuf_tolower(&charset_q);
+
encoding = cp[1];
if (!encoding || cp[2] != '?')
- return rfc2047; /* no munging */
+ goto decode_header_bq_out;
ep = strstr(cp + 3, "?=");
if (!ep)
- return rfc2047; /* no munging */
+ goto decode_header_bq_out;
+ strbuf_add(&piecebuf, cp + 3, ep - cp - 3);
switch (tolower(encoding)) {
default:
- return rfc2047; /* no munging */
+ goto decode_header_bq_out;
case 'b':
- sz = decode_b_segment(cp + 3, piecebuf, sizeof(piecebuf), ep);
+ dec = decode_b_segment(&piecebuf);
break;
case 'q':
- sz = decode_q_segment(cp + 3, piecebuf, sizeof(piecebuf), ep, 1);
+ dec = decode_q_segment(&piecebuf, 1);
break;
}
- if (sz < 0)
- return rfc2047;
if (metainfo_charset)
- convert_to_utf8(piecebuf, sizeof(piecebuf), charset_q);
+ convert_to_utf8(dec, charset_q.buf);
- sz = strlen(piecebuf);
- if (outbuf + sizeof(outbuf) <= out + sz)
- return rfc2047; /* no munging */
- strcpy(out, piecebuf);
- out += sz;
+ strbuf_addbuf(&outbuf, dec);
+ strbuf_release(dec);
+ free(dec);
in = ep + 2;
}
- strcpy(out, in);
- strlcpy(it, outbuf, itsize);
+ strbuf_addstr(&outbuf, in);
+ strbuf_reset(it);
+ strbuf_addbuf(it, &outbuf);
+decode_header_bq_out:
+ strbuf_release(&outbuf);
+ strbuf_release(&charset_q);
+ strbuf_release(&piecebuf);
return rfc2047;
}
-static void decode_header(char *it, unsigned itsize)
+static void decode_header(struct strbuf *it)
{
-
- if (decode_header_bq(it, itsize))
+ if (decode_header_bq(it))
return;
/* otherwise "it" is a straight copy of the input.
* This can be binary guck but there is no charset specified.
*/
if (metainfo_charset)
- convert_to_utf8(it, itsize, "");
+ convert_to_utf8(it, "");
}
-static void decode_transfer_encoding(char *line, unsigned linesize)
+static void decode_transfer_encoding(struct strbuf *line)
{
- char *ep;
+ struct strbuf *ret;
switch (transfer_encoding) {
case TE_QP:
- ep = line + strlen(line);
- decode_q_segment(line, line, linesize, ep, 0);
+ ret = decode_q_segment(line, 0);
break;
case TE_BASE64:
- ep = line + strlen(line);
- decode_b_segment(line, line, linesize, ep);
+ ret = decode_b_segment(line);
break;
case TE_DONTCARE:
- break;
+ default:
+ return;
}
+ strbuf_reset(line);
+ strbuf_addbuf(line, ret);
+ strbuf_release(ret);
+ free(ret);
}
-static int handle_filter(char *line, unsigned linesize);
+static void handle_filter(struct strbuf *line);
static int find_boundary(void)
{
- while(fgets(line, sizeof(line), fin) != NULL) {
- if (is_multipart_boundary(line))
+ while (!strbuf_getline(&line, fin, '\n')) {
+ if (is_multipart_boundary(&line))
return 1;
}
return 0;
@@ -654,12 +611,17 @@ static int find_boundary(void)
static int handle_boundary(void)
{
- char newline[]="\n";
+ struct strbuf newline = STRBUF_INIT;
+
+ strbuf_addch(&newline, '\n');
again:
- if (!memcmp(line+content_top->boundary_len, "--", 2)) {
+ if (line.len >= (*content_top)->len + 2 &&
+ !memcmp(line.buf + (*content_top)->len, "--", 2)) {
/* we hit an end boundary */
/* pop the current boundary off the stack */
- free(content_top->boundary);
+ strbuf_release(*content_top);
+ free(*content_top);
+ *content_top = NULL;
/* technically won't happen as is_multipart_boundary()
will fail first. But just in case..
@@ -669,7 +631,8 @@ again:
"can't recover\n");
exit(1);
}
- handle_filter(newline, sizeof(newline));
+ handle_filter(&newline);
+ strbuf_release(&newline);
/* skip to the next boundary */
if (!find_boundary())
@@ -679,39 +642,47 @@ again:
/* set some defaults */
transfer_encoding = TE_DONTCARE;
- charset[0] = 0;
+ strbuf_reset(&charset);
message_type = TYPE_TEXT;
/* slurp in this section's info */
- while (read_one_header_line(line, sizeof(line), fin))
- check_header(line, sizeof(line), p_hdr_data, 0);
+ while (read_one_header_line(&line, fin))
+ check_header(&line, p_hdr_data, 0);
- /* eat the blank line after section info */
- return (fgets(line, sizeof(line), fin) != NULL);
+ strbuf_release(&newline);
+ /* replenish line */
+ if (strbuf_getline(&line, fin, '\n'))
+ return 0;
+ strbuf_addch(&line, '\n');
+ return 1;
}
-static inline int patchbreak(const char *line)
+static inline int patchbreak(const struct strbuf *line)
{
+ size_t i;
+
/* Beginning of a "diff -" header? */
- if (!memcmp("diff -", line, 6))
+ if (!prefixcmp(line->buf, "diff -"))
return 1;
/* CVS "Index: " line? */
- if (!memcmp("Index: ", line, 7))
+ if (!prefixcmp(line->buf, "Index: "))
return 1;
/*
* "--- <filename>" starts patches without headers
* "---<sp>*" is a manual separator
*/
- if (!memcmp("---", line, 3)) {
- line += 3;
+ if (line->len < 4)
+ return 0;
+
+ if (!prefixcmp(line->buf, "---")) {
/* space followed by a filename? */
- if (line[0] == ' ' && !isspace(line[1]))
+ if (line->buf[3] == ' ' && !isspace(line->buf[4]))
return 1;
/* Just whitespace? */
- for (;;) {
- unsigned char c = *line++;
+ for (i = 3; i < line->len; i++) {
+ unsigned char c = line->buf[i];
if (c == '\n')
return 1;
if (!isspace(c))
@@ -722,32 +693,24 @@ static inline int patchbreak(const char *line)
return 0;
}
-
-static int handle_commit_msg(char *line, unsigned linesize)
+static int handle_commit_msg(struct strbuf *line)
{
static int still_looking = 1;
- char *endline = line + linesize;
if (!cmitmsg)
return 0;
if (still_looking) {
- char *cp = line;
- if (isspace(*line)) {
- for (cp = line + 1; *cp; cp++) {
- if (!isspace(*cp))
- break;
- }
- if (!*cp)
- return 0;
- }
- if ((still_looking = check_header(cp, endline - cp, s_hdr_data, 0)) != 0)
+ strbuf_ltrim(line);
+ if (!line->len)
+ return 0;
+ if ((still_looking = check_header(line, s_hdr_data, 0)) != 0)
return 0;
}
/* normalize the log message to UTF-8. */
if (metainfo_charset)
- convert_to_utf8(line, endline - line, charset);
+ convert_to_utf8(line, charset.buf);
if (patchbreak(line)) {
fclose(cmitmsg);
@@ -755,135 +718,133 @@ static int handle_commit_msg(char *line, unsigned linesize)
return 1;
}
- fputs(line, cmitmsg);
+ fputs(line->buf, cmitmsg);
return 0;
}
-static int handle_patch(char *line)
+static void handle_patch(const struct strbuf *line)
{
- fputs(line, patchfile);
+ fwrite(line->buf, 1, line->len, patchfile);
patch_lines++;
- return 0;
}
-static int handle_filter(char *line, unsigned linesize)
+static void handle_filter(struct strbuf *line)
{
static int filter = 0;
- /* filter tells us which part we left off on
- * a non-zero return indicates we hit a filter point
- */
+ /* filter tells us which part we left off on */
switch (filter) {
case 0:
- if (!handle_commit_msg(line, linesize))
+ if (!handle_commit_msg(line))
break;
filter++;
case 1:
- if (!handle_patch(line))
- break;
- filter++;
- default:
- return 1;
+ handle_patch(line);
+ break;
}
-
- return 0;
}
static void handle_body(void)
{
- int rc = 0;
- static char newline[2000];
- static char *np = newline;
+ int len = 0;
+ struct strbuf prev = STRBUF_INIT;
/* Skip up to the first boundary */
- if (content_top->boundary) {
+ if (*content_top) {
if (!find_boundary())
- return;
+ goto handle_body_out;
}
do {
+ strbuf_setlen(&line, line.len + len);
+
/* process any boundary lines */
- if (content_top->boundary && is_multipart_boundary(line)) {
+ if (*content_top && is_multipart_boundary(&line)) {
/* flush any leftover */
- if ((transfer_encoding == TE_BASE64) &&
- (np != newline)) {
- handle_filter(newline, sizeof(newline));
+ if (prev.len) {
+ handle_filter(&prev);
+ strbuf_reset(&prev);
}
if (!handle_boundary())
- return;
+ goto handle_body_out;
}
/* Unwrap transfer encoding */
- decode_transfer_encoding(line, sizeof(line));
+ decode_transfer_encoding(&line);
switch (transfer_encoding) {
case TE_BASE64:
+ case TE_QP:
{
- char *op = line;
+ struct strbuf **lines, **it, *sb;
+
+ /* Prepend any previous partial lines */
+ strbuf_insert(&line, 0, prev.buf, prev.len);
+ strbuf_reset(&prev);
/* binary data most likely doesn't have newlines */
if (message_type != TYPE_TEXT) {
- rc = handle_filter(line, sizeof(newline));
+ handle_filter(&line);
break;
}
-
- /* this is a decoded line that may contain
+ /*
+ * This is a decoded line that may contain
* multiple new lines. Pass only one chunk
* at a time to handle_filter()
*/
-
- do {
- while (*op != '\n' && *op != 0)
- *np++ = *op++;
- *np = *op;
- if (*np != 0) {
- /* should be sitting on a new line */
- *(++np) = 0;
- op++;
- rc = handle_filter(newline, sizeof(newline));
- np = newline;
- }
- } while (*op != 0);
- /* the partial chunk is saved in newline and
- * will be appended by the next iteration of fgets
+ lines = strbuf_split(&line, '\n');
+ for (it = lines; (sb = *it); it++) {
+ if (*(it + 1) == NULL) /* The last line */
+ if (sb->buf[sb->len - 1] != '\n') {
+ /* Partial line, save it for later. */
+ strbuf_addbuf(&prev, sb);
+ break;
+ }
+ handle_filter(sb);
+ }
+ /*
+ * The partial chunk is saved in "prev" and will be
+ * appended by the next iteration of read_line_with_nul().
*/
+ strbuf_list_free(lines);
break;
}
default:
- rc = handle_filter(line, sizeof(newline));
+ handle_filter(&line);
}
- if (rc)
- /* nothing left to filter */
- break;
- } while (fgets(line, sizeof(line), fin));
- return;
+ strbuf_reset(&line);
+ if (strbuf_avail(&line) < 100)
+ strbuf_grow(&line, 100);
+ } while ((len = read_line_with_nul(line.buf, strbuf_avail(&line), fin)));
+
+handle_body_out:
+ strbuf_release(&prev);
}
-static void output_header_lines(FILE *fout, const char *hdr, char *data)
+static void output_header_lines(FILE *fout, const char *hdr, const struct strbuf *data)
{
+ const char *sp = data->buf;
while (1) {
- char *ep = strchr(data, '\n');
+ char *ep = strchr(sp, '\n');
int len;
if (!ep)
- len = strlen(data);
+ len = strlen(sp);
else
- len = ep - data;
- fprintf(fout, "%s: %.*s\n", hdr, len, data);
+ len = ep - sp;
+ fprintf(fout, "%s: %.*s\n", hdr, len, sp);
if (!ep)
break;
- data = ep + 1;
+ sp = ep + 1;
}
}
static void handle_info(void)
{
- char *sub;
- char *hdr;
+ struct strbuf *hdr;
int i;
for (i = 0; header[i]; i++) {
-
/* only print inbody headers if we output a patch file */
if (patch_lines && s_hdr_data[i])
hdr = s_hdr_data[i];
@@ -893,20 +854,18 @@ static void handle_info(void)
continue;
if (!memcmp(header[i], "Subject", 7)) {
- if (keep_subject)
- sub = hdr;
- else {
- sub = cleanup_subject(hdr);
- cleanup_space(sub);
+ if (!keep_subject) {
+ cleanup_subject(hdr);
+ cleanup_space(hdr);
}
- output_header_lines(fout, "Subject", sub);
+ output_header_lines(fout, "Subject", hdr);
} else if (!memcmp(header[i], "From", 4)) {
handle_from(hdr);
- fprintf(fout, "Author: %s\n", name);
- fprintf(fout, "Email: %s\n", email);
+ fprintf(fout, "Author: %s\n", name.buf);
+ fprintf(fout, "Email: %s\n", email.buf);
} else {
cleanup_space(hdr);
- fprintf(fout, "%s: %s\n", header[i], hdr);
+ fprintf(fout, "%s: %s\n", header[i], hdr->buf);
}
}
fprintf(fout, "\n");
@@ -933,8 +892,8 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
return -1;
}
- p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
- s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
+ p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*p_hdr_data));
+ s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*s_hdr_data));
do {
peek = fgetc(in);
@@ -942,8 +901,8 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
ungetc(peek, in);
/* process the email header */
- while (read_one_header_line(line, sizeof(line), fin))
- check_header(line, sizeof(line), p_hdr_data, 1);
+ while (read_one_header_line(&line, fin))
+ check_header(&line, p_hdr_data, 1);
handle_body();
handle_info();
@@ -952,7 +911,7 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
}
static const char mailinfo_usage[] =
- "git-mailinfo [-k] [-u | --encoding=<encoding>] msg patch <mail >info";
+ "git mailinfo [-k] [-u | --encoding=<encoding> | -n] msg patch <mail >info";
int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
@@ -961,7 +920,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
/* NEEDSWORK: might want to do the optional .git/ directory
* discovery
*/
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
def_charset = (git_commit_encoding ? git_commit_encoding : "utf-8");
metainfo_charset = def_charset;
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 46b27cdae..71f3b3b87 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -6,10 +6,10 @@
*/
#include "cache.h"
#include "builtin.h"
-#include "path-list.h"
+#include "string-list.h"
static const char git_mailsplit_usage[] =
-"git-mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> <mbox>|<Maildir>...";
+"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]";
static int is_from_line(const char *line, int len)
{
@@ -45,6 +45,24 @@ static int is_from_line(const char *line, int len)
/* Could be as small as 64, enough to hold a Unix "From " line. */
static char buf[4096];
+/* We cannot use fgets() because our lines can contain NULs */
+int read_line_with_nul(char *buf, int size, FILE *in)
+{
+ int len = 0, c;
+
+ for (;;) {
+ c = getc(in);
+ if (c == EOF)
+ break;
+ buf[len++] = c;
+ if (c == '\n' || len + 1 >= size)
+ break;
+ }
+ buf[len] = '\0';
+
+ return len;
+}
+
/* Called with the first line (potentially partial)
* already in buf[] -- normally that should begin with
* the Unix "From " line. Write it into the specified
@@ -70,19 +88,19 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
* "From " and having something that looks like a date format.
*/
for (;;) {
- int is_partial = (buf[len-1] != '\n');
+ int is_partial = len && buf[len-1] != '\n';
- if (fputs(buf, output) == EOF)
+ if (fwrite(buf, 1, len, output) != len)
die("cannot write output");
- if (fgets(buf, sizeof(buf), mbox) == NULL) {
+ len = read_line_with_nul(buf, sizeof(buf), mbox);
+ if (len == 0) {
if (feof(mbox)) {
status = 1;
break;
}
die("cannot read mbox");
}
- len = strlen(buf);
if (!is_partial && !is_bare && is_from_line(buf, len))
break; /* done with one message */
}
@@ -97,7 +115,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
exit(1);
}
-static int populate_maildir_list(struct path_list *list, const char *path)
+static int populate_maildir_list(struct string_list *list, const char *path)
{
DIR *dir;
struct dirent *dent;
@@ -118,7 +136,7 @@ static int populate_maildir_list(struct path_list *list, const char *path)
if (dent->d_name[0] == '.')
continue;
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
- path_list_insert(name, list);
+ string_list_insert(name, list);
}
closedir(dir);
@@ -134,14 +152,14 @@ static int split_maildir(const char *maildir, const char *dir,
char name[PATH_MAX];
int ret = -1;
int i;
- struct path_list list = {NULL, 0, 0, 1};
+ struct string_list list = {NULL, 0, 0, 1};
if (populate_maildir_list(&list, maildir) < 0)
goto out;
for (i = 0; i < list.nr; i++) {
FILE *f;
- snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].path);
+ snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].string);
f = fopen(file, "r");
if (!f) {
error("cannot open mail %s (%s)", file, strerror(errno));
@@ -161,7 +179,7 @@ static int split_maildir(const char *maildir, const char *dir,
ret = skip;
out:
- path_list_clear(&list, 1);
+ string_list_clear(&list, 1);
return ret;
}
diff --git a/builtin-merge-base.c b/builtin-merge-base.c
index 0108e22ad..3382b1382 100644
--- a/builtin-merge-base.c
+++ b/builtin-merge-base.c
@@ -20,15 +20,28 @@ static int show_merge_base(struct commit *rev1, struct commit *rev2, int show_al
}
static const char merge_base_usage[] =
-"git-merge-base [--all] <commit-id> <commit-id>";
+"git merge-base [--all] <commit-id> <commit-id>";
+
+static struct commit *get_commit_reference(const char *arg)
+{
+ unsigned char revkey[20];
+ struct commit *r;
+
+ if (get_sha1(arg, revkey))
+ die("Not a valid object name %s", arg);
+ r = lookup_commit_reference(revkey);
+ if (!r)
+ die("Not a valid commit name %s", arg);
+
+ return r;
+}
int cmd_merge_base(int argc, const char **argv, const char *prefix)
{
struct commit *rev1, *rev2;
- unsigned char rev1key[20], rev2key[20];
int show_all = 0;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
while (1 < argc && argv[1][0] == '-') {
const char *arg = argv[1];
@@ -40,13 +53,8 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
}
if (argc != 3)
usage(merge_base_usage);
- if (get_sha1(argv[1], rev1key))
- die("Not a valid object name %s", argv[1]);
- if (get_sha1(argv[2], rev2key))
- die("Not a valid object name %s", argv[2]);
- rev1 = lookup_commit_reference(rev1key);
- rev2 = lookup_commit_reference(rev2key);
- if (!rev1 || !rev2)
- return 1;
+ rev1 = get_commit_reference(argv[1]);
+ rev2 = get_commit_reference(argv[2]);
+
return show_merge_base(rev1, rev2, show_all);
}
diff --git a/builtin-merge-file.c b/builtin-merge-file.c
index 58deb62ac..3605960c2 100644
--- a/builtin-merge-file.c
+++ b/builtin-merge-file.c
@@ -46,7 +46,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
}
ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
- &xpp, XDL_MERGE_ZEALOUS, &result);
+ &xpp, XDL_MERGE_ZEALOUS_ALNUM, &result);
for (i = 0; i < 3; i++)
free(mmfs[i].ptr);
@@ -57,7 +57,8 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
if (!f)
ret = error("Could not open %s for writing", filename);
- else if (fwrite(result.ptr, result.size, 1, f) != 1)
+ else if (result.size &&
+ fwrite(result.ptr, result.size, 1, f) != 1)
ret = error("Could not write to %s", filename);
else if (fclose(f))
ret = error("Could not close %s", filename);
diff --git a/builtin-merge-recursive.c b/builtin-merge-recursive.c
index 558a58e4d..43e55bf90 100644
--- a/builtin-merge-recursive.c
+++ b/builtin-merge-recursive.c
@@ -11,11 +11,11 @@
#include "tree-walk.h"
#include "diff.h"
#include "diffcore.h"
-#include "run-command.h"
#include "tag.h"
#include "unpack-trees.h"
-#include "path-list.h"
+#include "string-list.h"
#include "xdiff-interface.h"
+#include "ll-merge.h"
#include "interpolate.h"
#include "attr.h"
#include "merge-recursive.h"
@@ -42,14 +42,6 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two)
* - *(int *)commit->object.sha1 set to the virtual id.
*/
-static unsigned commit_list_count(const struct commit_list *l)
-{
- unsigned c = 0;
- for (; l; l = l->next )
- c++;
- return c;
-}
-
static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
{
struct commit *commit = xcalloc(1, sizeof(struct commit));
@@ -87,12 +79,13 @@ struct stage_data
unsigned processed:1;
};
-static struct path_list current_file_set = {NULL, 0, 0, 1};
-static struct path_list current_directory_set = {NULL, 0, 0, 1};
+static struct string_list current_file_set = {NULL, 0, 0, 1};
+static struct string_list current_directory_set = {NULL, 0, 0, 1};
static int call_depth = 0;
static int verbosity = 2;
-static int rename_limit = -1;
+static int diff_rename_limit = -1;
+static int merge_rename_limit = -1;
static int buffer_output = 1;
static struct strbuf obuf = STRBUF_INIT;
@@ -213,6 +206,8 @@ static int git_merge_trees(int index_only,
opts.merge = 1;
opts.head_idx = 2;
opts.fn = threeway_merge;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
init_tree_desc_from_tree(t+0, common);
init_tree_desc_from_tree(t+1, head);
@@ -253,7 +248,7 @@ struct tree *write_tree_from_memory(void)
static int save_files_dirs(const unsigned char *sha1,
const char *base, int baselen, const char *path,
- unsigned int mode, int stage)
+ unsigned int mode, int stage, void *context)
{
int len = strlen(path);
char *newpath = xmalloc(baselen + len + 1);
@@ -262,9 +257,9 @@ static int save_files_dirs(const unsigned char *sha1,
newpath[baselen + len] = '\0';
if (S_ISDIR(mode))
- path_list_insert(newpath, &current_directory_set);
+ string_list_insert(newpath, &current_directory_set);
else
- path_list_insert(newpath, &current_file_set);
+ string_list_insert(newpath, &current_file_set);
free(newpath);
return READ_TREE_RECURSIVE;
@@ -273,7 +268,7 @@ static int save_files_dirs(const unsigned char *sha1,
static int get_files_dirs(struct tree *tree)
{
int n;
- if (read_tree_recursive(tree, "", 0, 0, NULL, save_files_dirs) != 0)
+ if (read_tree_recursive(tree, "", 0, 0, NULL, save_files_dirs, NULL))
return 0;
n = current_file_set.nr + current_directory_set.nr;
return n;
@@ -285,9 +280,9 @@ static int get_files_dirs(struct tree *tree)
*/
static struct stage_data *insert_stage_data(const char *path,
struct tree *o, struct tree *a, struct tree *b,
- struct path_list *entries)
+ struct string_list *entries)
{
- struct path_list_item *item;
+ struct string_list_item *item;
struct stage_data *e = xcalloc(1, sizeof(struct stage_data));
get_tree_entry(o->object.sha1, path,
e->stages[1].sha, &e->stages[1].mode);
@@ -295,7 +290,7 @@ static struct stage_data *insert_stage_data(const char *path,
e->stages[2].sha, &e->stages[2].mode);
get_tree_entry(b->object.sha1, path,
e->stages[3].sha, &e->stages[3].mode);
- item = path_list_insert(path, entries);
+ item = string_list_insert(path, entries);
item->util = e;
return e;
}
@@ -304,23 +299,23 @@ static struct stage_data *insert_stage_data(const char *path,
* Create a dictionary mapping file names to stage_data objects. The
* dictionary contains one entry for every path with a non-zero stage entry.
*/
-static struct path_list *get_unmerged(void)
+static struct string_list *get_unmerged(void)
{
- struct path_list *unmerged = xcalloc(1, sizeof(struct path_list));
+ struct string_list *unmerged = xcalloc(1, sizeof(struct string_list));
int i;
- unmerged->strdup_paths = 1;
+ unmerged->strdup_strings = 1;
for (i = 0; i < active_nr; i++) {
- struct path_list_item *item;
+ struct string_list_item *item;
struct stage_data *e;
struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce))
continue;
- item = path_list_lookup(ce->name, unmerged);
+ item = string_list_lookup(ce->name, unmerged);
if (!item) {
- item = path_list_insert(ce->name, unmerged);
+ item = string_list_insert(ce->name, unmerged);
item->util = xcalloc(1, sizeof(struct stage_data));
}
e = item->util;
@@ -345,28 +340,31 @@ struct rename
* 'b_tree') to be able to associate the correct cache entries with
* the rename information. 'tree' is always equal to either a_tree or b_tree.
*/
-static struct path_list *get_renames(struct tree *tree,
+static struct string_list *get_renames(struct tree *tree,
struct tree *o_tree,
struct tree *a_tree,
struct tree *b_tree,
- struct path_list *entries)
+ struct string_list *entries)
{
int i;
- struct path_list *renames;
+ struct string_list *renames;
struct diff_options opts;
- renames = xcalloc(1, sizeof(struct path_list));
+ renames = xcalloc(1, sizeof(struct string_list));
diff_setup(&opts);
DIFF_OPT_SET(&opts, RECURSIVE);
opts.detect_rename = DIFF_DETECT_RENAME;
- opts.rename_limit = rename_limit;
+ opts.rename_limit = merge_rename_limit >= 0 ? merge_rename_limit :
+ diff_rename_limit >= 0 ? diff_rename_limit :
+ 500;
+ opts.warn_on_too_large_rename = 1;
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
if (diff_setup_done(&opts) < 0)
die("diff setup failed");
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
diffcore_std(&opts);
for (i = 0; i < diff_queued_diff.nr; ++i) {
- struct path_list_item *item;
+ struct string_list_item *item;
struct rename *re;
struct diff_filepair *pair = diff_queued_diff.queue[i];
if (pair->status != 'R') {
@@ -376,20 +374,20 @@ static struct path_list *get_renames(struct tree *tree,
re = xmalloc(sizeof(*re));
re->processed = 0;
re->pair = pair;
- item = path_list_lookup(re->pair->one->path, entries);
+ item = string_list_lookup(re->pair->one->path, entries);
if (!item)
re->src_entry = insert_stage_data(re->pair->one->path,
o_tree, a_tree, b_tree, entries);
else
re->src_entry = item->util;
- item = path_list_lookup(re->pair->two->path, entries);
+ item = string_list_lookup(re->pair->two->path, entries);
if (!item)
re->dst_entry = insert_stage_data(re->pair->two->path,
o_tree, a_tree, b_tree, entries);
else
re->dst_entry = item->util;
- item = path_list_insert(pair->one->path, renames);
+ item = string_list_insert(pair->one->path, renames);
item->util = re;
}
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
@@ -466,24 +464,15 @@ static char *unique_path(const char *path, const char *branch)
for (; *p; ++p)
if ('/' == *p)
*p = '_';
- while (path_list_has_path(&current_file_set, newpath) ||
- path_list_has_path(&current_directory_set, newpath) ||
+ while (string_list_has_string(&current_file_set, newpath) ||
+ string_list_has_string(&current_directory_set, newpath) ||
lstat(newpath, &st) == 0)
sprintf(p, "_%d", suffix++);
- path_list_insert(newpath, &current_file_set);
+ string_list_insert(newpath, &current_file_set);
return newpath;
}
-static int mkdir_p(const char *path, unsigned long mode)
-{
- /* path points to cache entries, so xstrdup before messing with it */
- char *buf = xstrdup(path);
- int result = safe_create_leading_directories(buf);
- free(buf);
- return result;
-}
-
static void flush_buffer(int fd, const char *buf, unsigned long size)
{
while (size > 0) {
@@ -506,7 +495,7 @@ static int make_room_for_path(const char *path)
int status;
const char *msg = "failed to create path '%s'%s";
- status = mkdir_p(path, 0777);
+ status = safe_create_leading_directories_const(path);
if (status) {
if (status == -3) {
/* something else exists */
@@ -549,9 +538,19 @@ static void update_file_flags(const unsigned char *sha,
die("cannot read object %s '%s'", sha1_to_hex(sha), path);
if (type != OBJ_BLOB)
die("blob expected for %s '%s'", sha1_to_hex(sha), path);
+ if (S_ISREG(mode)) {
+ struct strbuf strbuf;
+ strbuf_init(&strbuf, 0);
+ if (convert_to_working_tree(path, buf, size, &strbuf)) {
+ free(buf);
+ size = strbuf.len;
+ buf = strbuf_detach(&strbuf, NULL);
+ }
+ }
if (make_room_for_path(path) < 0) {
update_wd = 0;
+ free(buf);
goto update_index;
}
if (S_ISREG(mode) || (!has_symlinks && S_ISLNK(mode))) {
@@ -567,13 +566,14 @@ static void update_file_flags(const unsigned char *sha,
close(fd);
} else if (S_ISLNK(mode)) {
char *lnk = xmemdupz(buf, size);
- mkdir_p(path, 0777);
+ safe_create_leading_directories_const(path);
unlink(path);
symlink(lnk, path);
free(lnk);
} else
die("do not know what to do with %06o %s '%s'",
mode, sha1_to_hex(sha), path);
+ free(buf);
}
update_index:
if (update_cache)
@@ -615,363 +615,16 @@ static void fill_mm(const unsigned char *sha1, mmfile_t *mm)
mm->size = size;
}
-/*
- * Customizable low-level merge drivers support.
- */
-
-struct ll_merge_driver;
-typedef int (*ll_merge_fn)(const struct ll_merge_driver *,
- const char *path,
- mmfile_t *orig,
- mmfile_t *src1, const char *name1,
- mmfile_t *src2, const char *name2,
- mmbuffer_t *result);
-
-struct ll_merge_driver {
- const char *name;
- const char *description;
- ll_merge_fn fn;
- const char *recursive;
- struct ll_merge_driver *next;
- char *cmdline;
-};
-
-/*
- * Built-in low-levels
- */
-static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
- const char *path_unused,
- mmfile_t *orig,
- mmfile_t *src1, const char *name1,
- mmfile_t *src2, const char *name2,
- mmbuffer_t *result)
-{
- /*
- * The tentative merge result is "ours" for the final round,
- * or common ancestor for an internal merge. Still return
- * "conflicted merge" status.
- */
- mmfile_t *stolen = index_only ? orig : src1;
-
- result->ptr = stolen->ptr;
- result->size = stolen->size;
- stolen->ptr = NULL;
- return 1;
-}
-
-static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
- const char *path_unused,
- mmfile_t *orig,
- mmfile_t *src1, const char *name1,
- mmfile_t *src2, const char *name2,
- mmbuffer_t *result)
-{
- xpparam_t xpp;
-
- if (buffer_is_binary(orig->ptr, orig->size) ||
- buffer_is_binary(src1->ptr, src1->size) ||
- buffer_is_binary(src2->ptr, src2->size)) {
- warning("Cannot merge binary files: %s vs. %s\n",
- name1, name2);
- return ll_binary_merge(drv_unused, path_unused,
- orig, src1, name1,
- src2, name2,
- result);
- }
-
- memset(&xpp, 0, sizeof(xpp));
- return xdl_merge(orig,
- src1, name1,
- src2, name2,
- &xpp, XDL_MERGE_ZEALOUS,
- result);
-}
-
-static int ll_union_merge(const struct ll_merge_driver *drv_unused,
- const char *path_unused,
- mmfile_t *orig,
- mmfile_t *src1, const char *name1,
- mmfile_t *src2, const char *name2,
- mmbuffer_t *result)
-{
- char *src, *dst;
- long size;
- const int marker_size = 7;
-
- int status = ll_xdl_merge(drv_unused, path_unused,
- orig, src1, NULL, src2, NULL, result);
- if (status <= 0)
- return status;
- size = result->size;
- src = dst = result->ptr;
- while (size) {
- char ch;
- if ((marker_size < size) &&
- (*src == '<' || *src == '=' || *src == '>')) {
- int i;
- ch = *src;
- for (i = 0; i < marker_size; i++)
- if (src[i] != ch)
- goto not_a_marker;
- if (src[marker_size] != '\n')
- goto not_a_marker;
- src += marker_size + 1;
- size -= marker_size + 1;
- continue;
- }
- not_a_marker:
- do {
- ch = *src++;
- *dst++ = ch;
- size--;
- } while (ch != '\n' && size);
- }
- result->size = dst - result->ptr;
- return 0;
-}
-
-#define LL_BINARY_MERGE 0
-#define LL_TEXT_MERGE 1
-#define LL_UNION_MERGE 2
-static struct ll_merge_driver ll_merge_drv[] = {
- { "binary", "built-in binary merge", ll_binary_merge },
- { "text", "built-in 3-way text merge", ll_xdl_merge },
- { "union", "built-in union merge", ll_union_merge },
-};
-
-static void create_temp(mmfile_t *src, char *path)
-{
- int fd;
-
- strcpy(path, ".merge_file_XXXXXX");
- fd = xmkstemp(path);
- if (write_in_full(fd, src->ptr, src->size) != src->size)
- die("unable to write temp-file");
- close(fd);
-}
-
-/*
- * User defined low-level merge driver support.
- */
-static int ll_ext_merge(const struct ll_merge_driver *fn,
- const char *path,
- mmfile_t *orig,
- mmfile_t *src1, const char *name1,
- mmfile_t *src2, const char *name2,
- mmbuffer_t *result)
-{
- char temp[3][50];
- char cmdbuf[2048];
- struct interp table[] = {
- { "%O" },
- { "%A" },
- { "%B" },
- };
- struct child_process child;
- const char *args[20];
- int status, fd, i;
- struct stat st;
-
- if (fn->cmdline == NULL)
- die("custom merge driver %s lacks command line.", fn->name);
-
- result->ptr = NULL;
- result->size = 0;
- create_temp(orig, temp[0]);
- create_temp(src1, temp[1]);
- create_temp(src2, temp[2]);
-
- interp_set_entry(table, 0, temp[0]);
- interp_set_entry(table, 1, temp[1]);
- interp_set_entry(table, 2, temp[2]);
-
- output(1, "merging %s using %s", path,
- fn->description ? fn->description : fn->name);
-
- interpolate(cmdbuf, sizeof(cmdbuf), fn->cmdline, table, 3);
-
- memset(&child, 0, sizeof(child));
- child.argv = args;
- args[0] = "sh";
- args[1] = "-c";
- args[2] = cmdbuf;
- args[3] = NULL;
-
- status = run_command(&child);
- if (status < -ERR_RUN_COMMAND_FORK)
- ; /* failure in run-command */
- else
- status = -status;
- fd = open(temp[1], O_RDONLY);
- if (fd < 0)
- goto bad;
- if (fstat(fd, &st))
- goto close_bad;
- result->size = st.st_size;
- result->ptr = xmalloc(result->size + 1);
- if (read_in_full(fd, result->ptr, result->size) != result->size) {
- free(result->ptr);
- result->ptr = NULL;
- result->size = 0;
- }
- close_bad:
- close(fd);
- bad:
- for (i = 0; i < 3; i++)
- unlink(temp[i]);
- return status;
-}
-
-/*
- * merge.default and merge.driver configuration items
- */
-static struct ll_merge_driver *ll_user_merge, **ll_user_merge_tail;
-static const char *default_ll_merge;
-
-static int read_merge_config(const char *var, const char *value)
-{
- struct ll_merge_driver *fn;
- const char *ep, *name;
- int namelen;
-
- if (!strcmp(var, "merge.default")) {
- if (value)
- default_ll_merge = strdup(value);
- return 0;
- }
-
- /*
- * We are not interested in anything but "merge.<name>.variable";
- * 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)
- 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;
- if (!fn) {
- fn = xcalloc(1, sizeof(struct ll_merge_driver));
- fn->name = xmemdupz(name, namelen);
- fn->fn = ll_ext_merge;
- *ll_user_merge_tail = fn;
- ll_user_merge_tail = &(fn->next);
- }
-
- ep++;
-
- if (!strcmp("name", ep)) {
- if (!value)
- return error("%s: lacks value", var);
- fn->description = strdup(value);
- return 0;
- }
-
- if (!strcmp("driver", ep)) {
- if (!value)
- return error("%s: lacks value", var);
- /*
- * merge.<name>.driver specifies the command line:
- *
- * command-line
- *
- * The command-line will be interpolated with the following
- * tokens and is given to the shell:
- *
- * %O - temporary file name for the merge base.
- * %A - temporary file name for our version.
- * %B - temporary file name for the other branches' version.
- *
- * The external merge driver should write the results in the
- * file named by %A, and signal that it has done with zero exit
- * status.
- */
- fn->cmdline = strdup(value);
- return 0;
- }
-
- if (!strcmp("recursive", ep)) {
- if (!value)
- return error("%s: lacks value", var);
- fn->recursive = strdup(value);
- return 0;
- }
-
- return 0;
-}
-
-static void initialize_ll_merge(void)
-{
- if (ll_user_merge_tail)
- return;
- ll_user_merge_tail = &ll_user_merge;
- git_config(read_merge_config);
-}
-
-static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr)
-{
- struct ll_merge_driver *fn;
- const char *name;
- int i;
-
- initialize_ll_merge();
-
- if (ATTR_TRUE(merge_attr))
- return &ll_merge_drv[LL_TEXT_MERGE];
- else if (ATTR_FALSE(merge_attr))
- return &ll_merge_drv[LL_BINARY_MERGE];
- else if (ATTR_UNSET(merge_attr)) {
- if (!default_ll_merge)
- return &ll_merge_drv[LL_TEXT_MERGE];
- else
- name = default_ll_merge;
- }
- else
- name = merge_attr;
-
- for (fn = ll_user_merge; fn; fn = fn->next)
- if (!strcmp(fn->name, name))
- return fn;
-
- for (i = 0; i < ARRAY_SIZE(ll_merge_drv); i++)
- if (!strcmp(ll_merge_drv[i].name, name))
- return &ll_merge_drv[i];
-
- /* default to the 3-way */
- return &ll_merge_drv[LL_TEXT_MERGE];
-}
-
-static const char *git_path_check_merge(const char *path)
-{
- static struct git_attr_check attr_merge_check;
-
- if (!attr_merge_check.attr)
- attr_merge_check.attr = git_attr("merge", 5);
-
- if (git_checkattr(path, 1, &attr_merge_check))
- return NULL;
- return attr_merge_check.value;
-}
-
-static int ll_merge(mmbuffer_t *result_buf,
- struct diff_filespec *o,
- struct diff_filespec *a,
- struct diff_filespec *b,
- const char *branch1,
- const char *branch2)
+static int merge_3way(mmbuffer_t *result_buf,
+ struct diff_filespec *o,
+ struct diff_filespec *a,
+ struct diff_filespec *b,
+ const char *branch1,
+ const char *branch2)
{
mmfile_t orig, src1, src2;
char *name1, *name2;
int merge_status;
- const char *ll_driver_name;
- const struct ll_merge_driver *driver;
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
@@ -980,14 +633,9 @@ static int ll_merge(mmbuffer_t *result_buf,
fill_mm(a->sha1, &src1);
fill_mm(b->sha1, &src2);
- ll_driver_name = git_path_check_merge(a->path);
- driver = find_ll_merge_driver(ll_driver_name);
-
- if (index_only && driver->recursive)
- driver = find_ll_merge_driver(driver->recursive);
- merge_status = driver->fn(driver, a->path,
- &orig, &src1, name1, &src2, name2,
- result_buf);
+ merge_status = ll_merge(result_buf, a->path, &orig,
+ &src1, name1, &src2, name2,
+ index_only);
free(name1);
free(name2);
@@ -1018,9 +666,20 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
if (!sha_eq(a->sha1, o->sha1) && !sha_eq(b->sha1, o->sha1))
result.merge = 1;
- result.mode = a->mode == o->mode ? b->mode: a->mode;
+ /*
+ * Merge modes
+ */
+ if (a->mode == b->mode || a->mode == o->mode)
+ result.mode = b->mode;
+ else {
+ result.mode = a->mode;
+ if (b->mode != o->mode) {
+ result.clean = 0;
+ result.merge = 1;
+ }
+ }
- if (sha_eq(a->sha1, o->sha1))
+ if (sha_eq(a->sha1, b->sha1) || sha_eq(a->sha1, o->sha1))
hashcpy(result.sha, b->sha1);
else if (sha_eq(b->sha1, o->sha1))
hashcpy(result.sha, a->sha1);
@@ -1028,8 +687,8 @@ static struct merge_file_info merge_file(struct diff_filespec *o,
mmbuffer_t result_buf;
int merge_status;
- merge_status = ll_merge(&result_buf, o, a, b,
- branch1, branch2);
+ merge_status = merge_3way(&result_buf, o, a, b,
+ branch1, branch2);
if ((merge_status < 0) || !result_buf.ptr)
die("Failed to execute internal merge");
@@ -1068,13 +727,13 @@ static void conflict_rename_rename(struct rename *ren1,
const char *ren2_dst = ren2->pair->two->path;
const char *dst_name1 = ren1_dst;
const char *dst_name2 = ren2_dst;
- if (path_list_has_path(&current_directory_set, ren1_dst)) {
+ if (string_list_has_string(&current_directory_set, ren1_dst)) {
dst_name1 = del[delp++] = unique_path(ren1_dst, branch1);
output(1, "%s is a directory in %s added as %s instead",
ren1_dst, branch2, dst_name1);
remove_file(0, ren1_dst, 0);
}
- if (path_list_has_path(&current_directory_set, ren2_dst)) {
+ if (string_list_has_string(&current_directory_set, ren2_dst)) {
dst_name2 = del[delp++] = unique_path(ren2_dst, branch2);
output(1, "%s is a directory in %s added as %s instead",
ren2_dst, branch1, dst_name2);
@@ -1124,30 +783,30 @@ static void conflict_rename_rename_2(struct rename *ren1,
free(new_path1);
}
-static int process_renames(struct path_list *a_renames,
- struct path_list *b_renames,
+static int process_renames(struct string_list *a_renames,
+ struct string_list *b_renames,
const char *a_branch,
const char *b_branch)
{
int clean_merge = 1, i, j;
- struct path_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0};
+ struct string_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0};
const struct rename *sre;
for (i = 0; i < a_renames->nr; i++) {
sre = a_renames->items[i].util;
- path_list_insert(sre->pair->two->path, &a_by_dst)->util
+ string_list_insert(sre->pair->two->path, &a_by_dst)->util
= sre->dst_entry;
}
for (i = 0; i < b_renames->nr; i++) {
sre = b_renames->items[i].util;
- path_list_insert(sre->pair->two->path, &b_by_dst)->util
+ string_list_insert(sre->pair->two->path, &b_by_dst)->util
= sre->dst_entry;
}
for (i = 0, j = 0; i < a_renames->nr || j < b_renames->nr;) {
int compare;
char *src;
- struct path_list *renames1, *renames2, *renames2Dst;
+ struct string_list *renames1, *renames2, *renames2Dst;
struct rename *ren1 = NULL, *ren2 = NULL;
const char *branch1, *branch2;
const char *ren1_src, *ren1_dst;
@@ -1159,8 +818,8 @@ static int process_renames(struct path_list *a_renames,
compare = -1;
ren1 = a_renames->items[i++].util;
} else {
- compare = strcmp(a_renames->items[i].path,
- b_renames->items[j].path);
+ compare = strcmp(a_renames->items[i].string,
+ b_renames->items[j].string);
if (compare <= 0)
ren1 = a_renames->items[i++].util;
if (compare >= 0)
@@ -1249,7 +908,7 @@ static int process_renames(struct path_list *a_renames,
}
} else {
/* Renamed in 1, maybe changed in 2 */
- struct path_list_item *item;
+ struct string_list_item *item;
/* we only use sha1 and mode of these */
struct diff_filespec src_other, dst_other;
int try_merge, stage = a_renames == renames1 ? 3: 2;
@@ -1263,7 +922,7 @@ static int process_renames(struct path_list *a_renames,
try_merge = 0;
- if (path_list_has_path(&current_directory_set, ren1_dst)) {
+ if (string_list_has_string(&current_directory_set, ren1_dst)) {
clean_merge = 0;
output(1, "CONFLICT (rename/directory): Renamed %s->%s in %s "
" directory %s added in %s",
@@ -1288,7 +947,7 @@ static int process_renames(struct path_list *a_renames,
new_path = unique_path(ren1_dst, branch2);
output(1, "Added as %s instead", new_path);
update_file(0, dst_other.sha1, dst_other.mode, new_path);
- } else if ((item = path_list_lookup(ren1_dst, renames2Dst))) {
+ } else if ((item = string_list_lookup(ren1_dst, renames2Dst))) {
ren2 = item->util;
clean_merge = 0;
ren2->processed = 1;
@@ -1344,8 +1003,8 @@ static int process_renames(struct path_list *a_renames,
}
}
}
- path_list_clear(&a_by_dst, 0);
- path_list_clear(&b_by_dst, 0);
+ string_list_clear(&a_by_dst, 0);
+ string_list_clear(&b_by_dst, 0);
return clean_merge;
}
@@ -1423,7 +1082,7 @@ static int process_entry(const char *path, struct stage_data *entry,
sha = b_sha;
conf = "directory/file";
}
- if (path_list_has_path(&current_directory_set, path)) {
+ if (string_list_has_string(&current_directory_set, path)) {
const char *new_path = unique_path(path, add_branch);
clean_merge = 0;
output(1, "CONFLICT (%s): There is a directory with name %s in %s. "
@@ -1514,10 +1173,10 @@ int merge_trees(struct tree *head,
sha1_to_hex(merge->object.sha1));
if (unmerged_cache()) {
- struct path_list *entries, *re_head, *re_merge;
+ struct string_list *entries, *re_head, *re_merge;
int i;
- path_list_clear(&current_file_set, 1);
- path_list_clear(&current_directory_set, 1);
+ string_list_clear(&current_file_set, 1);
+ string_list_clear(&current_directory_set, 1);
get_files_dirs(head);
get_files_dirs(merge);
@@ -1527,16 +1186,16 @@ int merge_trees(struct tree *head,
clean = process_renames(re_head, re_merge,
branch1, branch2);
for (i = 0; i < entries->nr; i++) {
- const char *path = entries->items[i].path;
+ const char *path = entries->items[i].string;
struct stage_data *e = entries->items[i].util;
if (!e->processed
&& !process_entry(path, e, branch1, branch2))
clean = 0;
}
- path_list_clear(re_merge, 0);
- path_list_clear(re_head, 0);
- path_list_clear(entries, 1);
+ string_list_clear(re_merge, 0);
+ string_list_clear(re_head, 0);
+ string_list_clear(entries, 1);
}
else
@@ -1663,6 +1322,8 @@ static struct commit *get_ref(const char *ref)
if (get_sha1(ref, sha1))
die("Could not resolve ref '%s'", ref);
object = deref_tag(parse_object(sha1), ref, strlen(ref));
+ if (!object)
+ return NULL;
if (object->type == OBJ_TREE)
return make_virtual_commit((struct tree*)object,
better_branch_name(ref));
@@ -1673,17 +1334,21 @@ static struct commit *get_ref(const char *ref)
return (struct commit *)object;
}
-static int merge_config(const char *var, const char *value)
+static int merge_config(const char *var, const char *value, void *cb)
{
if (!strcasecmp(var, "merge.verbosity")) {
verbosity = git_config_int(var, value);
return 0;
}
if (!strcasecmp(var, "diff.renamelimit")) {
- rename_limit = git_config_int(var, value);
+ diff_rename_limit = git_config_int(var, value);
+ return 0;
+ }
+ if (!strcasecmp(var, "merge.renamelimit")) {
+ merge_rename_limit = git_config_int(var, value);
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
@@ -1704,7 +1369,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
subtree_merge = 1;
}
- git_config(merge_config);
+ git_config(merge_config, NULL);
if (getenv("GIT_MERGE_VERBOSITY"))
verbosity = strtol(getenv("GIT_MERGE_VERBOSITY"), NULL, 10);
diff --git a/builtin-merge.c b/builtin-merge.c
new file mode 100644
index 000000000..dde0c7ed3
--- /dev/null
+++ b/builtin-merge.c
@@ -0,0 +1,1143 @@
+/*
+ * Builtin "git merge"
+ *
+ * Copyright (c) 2008 Miklos Vajna <vmiklos@frugalware.org>
+ *
+ * Based on git-merge.sh by Junio C Hamano.
+ */
+
+#include "cache.h"
+#include "parse-options.h"
+#include "builtin.h"
+#include "run-command.h"
+#include "diff.h"
+#include "refs.h"
+#include "commit.h"
+#include "diffcore.h"
+#include "revision.h"
+#include "unpack-trees.h"
+#include "cache-tree.h"
+#include "dir.h"
+#include "utf8.h"
+#include "log-tree.h"
+#include "color.h"
+#include "rerere.h"
+
+#define DEFAULT_TWOHEAD (1<<0)
+#define DEFAULT_OCTOPUS (1<<1)
+#define NO_FAST_FORWARD (1<<2)
+#define NO_TRIVIAL (1<<3)
+
+struct strategy {
+ const char *name;
+ unsigned attr;
+};
+
+static const char * const builtin_merge_usage[] = {
+ "git-merge [options] <remote>...",
+ "git-merge [options] <msg> HEAD <remote>",
+ NULL
+};
+
+static int show_diffstat = 1, option_log, squash;
+static int option_commit = 1, allow_fast_forward = 1;
+static int allow_trivial = 1, have_message;
+static struct strbuf merge_msg;
+static struct commit_list *remoteheads;
+static unsigned char head[20], stash[20];
+static struct strategy **use_strategies;
+static size_t use_strategies_nr, use_strategies_alloc;
+static const char *branch;
+
+static struct strategy all_strategy[] = {
+ { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL },
+ { "octopus", DEFAULT_OCTOPUS },
+ { "resolve", 0 },
+ { "ours", NO_FAST_FORWARD | NO_TRIVIAL },
+ { "subtree", NO_FAST_FORWARD | NO_TRIVIAL },
+};
+
+static const char *pull_twohead, *pull_octopus;
+
+static int option_parse_message(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct strbuf *buf = opt->value;
+
+ if (unset)
+ strbuf_setlen(buf, 0);
+ else if (arg) {
+ strbuf_addf(buf, "%s\n\n", arg);
+ have_message = 1;
+ } else
+ return error("switch `m' requires a value");
+ return 0;
+}
+
+static struct strategy *get_strategy(const char *name)
+{
+ int i;
+ struct strbuf err;
+
+ if (!name)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ if (!strcmp(name, all_strategy[i].name))
+ return &all_strategy[i];
+
+ strbuf_init(&err, 0);
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ strbuf_addf(&err, " %s", all_strategy[i].name);
+ fprintf(stderr, "Could not find merge strategy '%s'.\n", name);
+ fprintf(stderr, "Available strategies are:%s.\n", err.buf);
+ exit(1);
+}
+
+static void append_strategy(struct strategy *s)
+{
+ ALLOC_GROW(use_strategies, use_strategies_nr + 1, use_strategies_alloc);
+ use_strategies[use_strategies_nr++] = s;
+}
+
+static int option_parse_strategy(const struct option *opt,
+ const char *name, int unset)
+{
+ if (unset)
+ return 0;
+
+ append_strategy(get_strategy(name));
+ return 0;
+}
+
+static int option_parse_n(const struct option *opt,
+ const char *arg, int unset)
+{
+ show_diffstat = unset;
+ return 0;
+}
+
+static struct option builtin_merge_options[] = {
+ { OPTION_CALLBACK, 'n', NULL, NULL, NULL,
+ "do not show a diffstat at the end of the merge",
+ PARSE_OPT_NOARG, option_parse_n },
+ OPT_BOOLEAN(0, "stat", &show_diffstat,
+ "show a diffstat at the end of the merge"),
+ OPT_BOOLEAN(0, "summary", &show_diffstat, "(synonym to --stat)"),
+ OPT_BOOLEAN(0, "log", &option_log,
+ "add list of one-line log to merge commit message"),
+ OPT_BOOLEAN(0, "squash", &squash,
+ "create a single commit instead of doing a merge"),
+ OPT_BOOLEAN(0, "commit", &option_commit,
+ "perform a commit if the merge succeeds (default)"),
+ OPT_BOOLEAN(0, "ff", &allow_fast_forward,
+ "allow fast forward (default)"),
+ OPT_CALLBACK('s', "strategy", &use_strategies, "strategy",
+ "merge strategy to use", option_parse_strategy),
+ OPT_CALLBACK('m', "message", &merge_msg, "message",
+ "message to be used for the merge commit (if any)",
+ option_parse_message),
+ OPT_END()
+};
+
+/* Cleans up metadata that is uninteresting after a succeeded merge. */
+static void drop_save(void)
+{
+ unlink(git_path("MERGE_HEAD"));
+ unlink(git_path("MERGE_MSG"));
+}
+
+static void save_state(void)
+{
+ int len;
+ struct child_process cp;
+ struct strbuf buffer = STRBUF_INIT;
+ const char *argv[] = {"stash", "create", NULL};
+
+ memset(&cp, 0, sizeof(cp));
+ cp.argv = argv;
+ cp.out = -1;
+ cp.git_cmd = 1;
+
+ if (start_command(&cp))
+ die("could not run stash.");
+ len = strbuf_read(&buffer, cp.out, 1024);
+ close(cp.out);
+
+ if (finish_command(&cp) || len < 0)
+ die("stash failed");
+ else if (!len)
+ return;
+ strbuf_setlen(&buffer, buffer.len-1);
+ if (get_sha1(buffer.buf, stash))
+ die("not a valid object: %s", buffer.buf);
+}
+
+static void reset_hard(unsigned const char *sha1, int verbose)
+{
+ int i = 0;
+ const char *args[6];
+
+ args[i++] = "read-tree";
+ if (verbose)
+ args[i++] = "-v";
+ args[i++] = "--reset";
+ args[i++] = "-u";
+ args[i++] = sha1_to_hex(sha1);
+ args[i] = NULL;
+
+ if (run_command_v_opt(args, RUN_GIT_CMD))
+ die("read-tree failed");
+}
+
+static void restore_state(void)
+{
+ struct strbuf sb;
+ const char *args[] = { "stash", "apply", NULL, NULL };
+
+ if (is_null_sha1(stash))
+ return;
+
+ reset_hard(head, 1);
+
+ strbuf_init(&sb, 0);
+ args[2] = sha1_to_hex(stash);
+
+ /*
+ * It is OK to ignore error here, for example when there was
+ * nothing to restore.
+ */
+ run_command_v_opt(args, RUN_GIT_CMD);
+
+ strbuf_release(&sb);
+ refresh_cache(REFRESH_QUIET);
+}
+
+/* This is called when no merge was necessary. */
+static void finish_up_to_date(const char *msg)
+{
+ printf("%s%s\n", squash ? " (nothing to squash)" : "", msg);
+ drop_save();
+}
+
+static void squash_message(void)
+{
+ struct rev_info rev;
+ struct commit *commit;
+ struct strbuf out;
+ struct commit_list *j;
+ int fd;
+
+ printf("Squash commit -- not updating HEAD\n");
+ fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
+ if (fd < 0)
+ die("Could not write to %s", git_path("SQUASH_MSG"));
+
+ init_revisions(&rev, NULL);
+ rev.ignore_merges = 1;
+ rev.commit_format = CMIT_FMT_MEDIUM;
+
+ commit = lookup_commit(head);
+ commit->object.flags |= UNINTERESTING;
+ add_pending_object(&rev, &commit->object, NULL);
+
+ for (j = remoteheads; j; j = j->next)
+ add_pending_object(&rev, &j->item->object, NULL);
+
+ setup_revisions(0, NULL, &rev, NULL);
+ if (prepare_revision_walk(&rev))
+ die("revision walk setup failed");
+
+ strbuf_init(&out, 0);
+ strbuf_addstr(&out, "Squashed commit of the following:\n");
+ while ((commit = get_revision(&rev)) != NULL) {
+ strbuf_addch(&out, '\n');
+ strbuf_addf(&out, "commit %s\n",
+ sha1_to_hex(commit->object.sha1));
+ pretty_print_commit(rev.commit_format, commit, &out, rev.abbrev,
+ NULL, NULL, rev.date_mode, 0);
+ }
+ write(fd, out.buf, out.len);
+ close(fd);
+ strbuf_release(&out);
+}
+
+static int run_hook(const char *name)
+{
+ struct child_process hook;
+ const char *argv[3], *env[2];
+ char index[PATH_MAX];
+
+ argv[0] = git_path("hooks/%s", name);
+ if (access(argv[0], X_OK) < 0)
+ return 0;
+
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", get_index_file());
+ env[0] = index;
+ env[1] = NULL;
+
+ if (squash)
+ argv[1] = "1";
+ else
+ argv[1] = "0";
+ argv[2] = NULL;
+
+ memset(&hook, 0, sizeof(hook));
+ hook.argv = argv;
+ hook.no_stdin = 1;
+ hook.stdout_to_stderr = 1;
+ hook.env = env;
+
+ return run_command(&hook);
+}
+
+static void finish(const unsigned char *new_head, const char *msg)
+{
+ struct strbuf reflog_message;
+
+ strbuf_init(&reflog_message, 0);
+ if (!msg)
+ strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
+ else {
+ printf("%s\n", msg);
+ strbuf_addf(&reflog_message, "%s: %s",
+ getenv("GIT_REFLOG_ACTION"), msg);
+ }
+ if (squash) {
+ squash_message();
+ } else {
+ if (!merge_msg.len)
+ printf("No merge message -- not updating HEAD\n");
+ else {
+ const char *argv_gc_auto[] = { "gc", "--auto", NULL };
+ update_ref(reflog_message.buf, "HEAD",
+ new_head, head, 0,
+ DIE_ON_ERR);
+ /*
+ * We ignore errors in 'gc --auto', since the
+ * user should see them.
+ */
+ run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+ }
+ }
+ if (new_head && show_diffstat) {
+ struct diff_options opts;
+ diff_setup(&opts);
+ opts.output_format |=
+ DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
+ opts.detect_rename = DIFF_DETECT_RENAME;
+ if (diff_use_color_default > 0)
+ DIFF_OPT_SET(&opts, COLOR_DIFF);
+ if (diff_setup_done(&opts) < 0)
+ die("diff_setup_done failed");
+ diff_tree_sha1(head, new_head, "", &opts);
+ diffcore_std(&opts);
+ diff_flush(&opts);
+ }
+
+ /* Run a post-merge hook */
+ run_hook("post-merge");
+
+ strbuf_release(&reflog_message);
+}
+
+/* Get the name for the merge commit's message. */
+static void merge_name(const char *remote, struct strbuf *msg)
+{
+ struct object *remote_head;
+ unsigned char branch_head[20], buf_sha[20];
+ struct strbuf buf;
+ const char *ptr;
+ int len, early;
+
+ memset(branch_head, 0, sizeof(branch_head));
+ remote_head = peel_to_type(remote, 0, NULL, OBJ_COMMIT);
+ if (!remote_head)
+ die("'%s' does not point to a commit", remote);
+
+ strbuf_init(&buf, 0);
+ strbuf_addstr(&buf, "refs/heads/");
+ strbuf_addstr(&buf, remote);
+ resolve_ref(buf.buf, branch_head, 0, 0);
+
+ if (!hashcmp(remote_head->sha1, branch_head)) {
+ strbuf_addf(msg, "%s\t\tbranch '%s' of .\n",
+ sha1_to_hex(branch_head), remote);
+ return;
+ }
+
+ /* See if remote matches <name>^^^.. or <name>~<number> */
+ for (len = 0, ptr = remote + strlen(remote);
+ remote < ptr && ptr[-1] == '^';
+ ptr--)
+ len++;
+ if (len)
+ early = 1;
+ else {
+ early = 0;
+ ptr = strrchr(remote, '~');
+ if (ptr) {
+ int seen_nonzero = 0;
+
+ len++; /* count ~ */
+ while (*++ptr && isdigit(*ptr)) {
+ seen_nonzero |= (*ptr != '0');
+ len++;
+ }
+ if (*ptr)
+ len = 0; /* not ...~<number> */
+ else if (seen_nonzero)
+ early = 1;
+ else if (len == 1)
+ early = 1; /* "name~" is "name~1"! */
+ }
+ }
+ if (len) {
+ struct strbuf truname = STRBUF_INIT;
+ strbuf_addstr(&truname, "refs/heads/");
+ strbuf_addstr(&truname, remote);
+ strbuf_setlen(&truname, truname.len - len);
+ if (resolve_ref(truname.buf, buf_sha, 0, 0)) {
+ strbuf_addf(msg,
+ "%s\t\tbranch '%s'%s of .\n",
+ sha1_to_hex(remote_head->sha1),
+ truname.buf + 11,
+ (early ? " (early part)" : ""));
+ return;
+ }
+ }
+
+ if (!strcmp(remote, "FETCH_HEAD") &&
+ !access(git_path("FETCH_HEAD"), R_OK)) {
+ FILE *fp;
+ struct strbuf line;
+ char *ptr;
+
+ strbuf_init(&line, 0);
+ fp = fopen(git_path("FETCH_HEAD"), "r");
+ if (!fp)
+ die("could not open %s for reading: %s",
+ git_path("FETCH_HEAD"), strerror(errno));
+ strbuf_getline(&line, fp, '\n');
+ fclose(fp);
+ ptr = strstr(line.buf, "\tnot-for-merge\t");
+ if (ptr)
+ strbuf_remove(&line, ptr-line.buf+1, 13);
+ strbuf_addbuf(msg, &line);
+ strbuf_release(&line);
+ return;
+ }
+ strbuf_addf(msg, "%s\t\tcommit '%s'\n",
+ sha1_to_hex(remote_head->sha1), remote);
+}
+
+static int git_merge_config(const char *k, const char *v, void *cb)
+{
+ if (branch && !prefixcmp(k, "branch.") &&
+ !prefixcmp(k + 7, branch) &&
+ !strcmp(k + 7 + strlen(branch), ".mergeoptions")) {
+ const char **argv;
+ int argc;
+ char *buf;
+
+ buf = xstrdup(v);
+ argc = split_cmdline(buf, &argv);
+ argv = xrealloc(argv, sizeof(*argv) * (argc + 2));
+ memmove(argv + 1, argv, sizeof(*argv) * (argc + 1));
+ argc++;
+ parse_options(argc, argv, builtin_merge_options,
+ builtin_merge_usage, 0);
+ free(buf);
+ }
+
+ if (!strcmp(k, "merge.diffstat") || !strcmp(k, "merge.stat"))
+ show_diffstat = git_config_bool(k, v);
+ else if (!strcmp(k, "pull.twohead"))
+ return git_config_string(&pull_twohead, k, v);
+ else if (!strcmp(k, "pull.octopus"))
+ return git_config_string(&pull_octopus, k, v);
+ else if (!strcmp(k, "merge.log") || !strcmp(k, "merge.summary"))
+ option_log = git_config_bool(k, v);
+ return git_diff_ui_config(k, v, cb);
+}
+
+static int read_tree_trivial(unsigned char *common, unsigned char *head,
+ unsigned char *one)
+{
+ int i, nr_trees = 0;
+ struct tree *trees[MAX_UNPACK_TREES];
+ struct tree_desc t[MAX_UNPACK_TREES];
+ struct unpack_trees_options opts;
+
+ memset(&opts, 0, sizeof(opts));
+ opts.head_idx = 2;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
+ opts.update = 1;
+ opts.verbose_update = 1;
+ opts.trivial_merges_only = 1;
+ opts.merge = 1;
+ trees[nr_trees] = parse_tree_indirect(common);
+ if (!trees[nr_trees++])
+ return -1;
+ trees[nr_trees] = parse_tree_indirect(head);
+ if (!trees[nr_trees++])
+ return -1;
+ trees[nr_trees] = parse_tree_indirect(one);
+ if (!trees[nr_trees++])
+ return -1;
+ opts.fn = threeway_merge;
+ cache_tree_free(&active_cache_tree);
+ for (i = 0; i < nr_trees; i++) {
+ parse_tree(trees[i]);
+ init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
+ }
+ if (unpack_trees(nr_trees, t, &opts))
+ return -1;
+ return 0;
+}
+
+static void write_tree_trivial(unsigned char *sha1)
+{
+ if (write_cache_as_tree(sha1, 0, NULL))
+ die("git write-tree failed to write a tree");
+}
+
+static int try_merge_strategy(const char *strategy, struct commit_list *common,
+ const char *head_arg)
+{
+ const char **args;
+ int i = 0, ret;
+ struct commit_list *j;
+ struct strbuf buf;
+
+ args = xmalloc((4 + commit_list_count(common) +
+ commit_list_count(remoteheads)) * sizeof(char *));
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, "merge-%s", strategy);
+ args[i++] = buf.buf;
+ for (j = common; j; j = j->next)
+ args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1));
+ args[i++] = "--";
+ args[i++] = head_arg;
+ for (j = remoteheads; j; j = j->next)
+ args[i++] = xstrdup(sha1_to_hex(j->item->object.sha1));
+ args[i] = NULL;
+ ret = run_command_v_opt(args, RUN_GIT_CMD);
+ strbuf_release(&buf);
+ i = 1;
+ for (j = common; j; j = j->next)
+ free((void *)args[i++]);
+ i += 2;
+ for (j = remoteheads; j; j = j->next)
+ free((void *)args[i++]);
+ free(args);
+ return -ret;
+}
+
+static void count_diff_files(struct diff_queue_struct *q,
+ struct diff_options *opt, void *data)
+{
+ int *count = data;
+
+ (*count) += q->nr;
+}
+
+static int count_unmerged_entries(void)
+{
+ const struct index_state *state = &the_index;
+ int i, ret = 0;
+
+ for (i = 0; i < state->cache_nr; i++)
+ if (ce_stage(state->cache[i]))
+ ret++;
+
+ return ret;
+}
+
+static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
+{
+ struct tree *trees[MAX_UNPACK_TREES];
+ struct unpack_trees_options opts;
+ struct tree_desc t[MAX_UNPACK_TREES];
+ int i, fd, nr_trees = 0;
+ struct dir_struct dir;
+ struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+ if (read_cache_unmerged())
+ die("you need to resolve your current index first");
+
+ fd = hold_locked_index(lock_file, 1);
+
+ memset(&trees, 0, sizeof(trees));
+ memset(&opts, 0, sizeof(opts));
+ memset(&t, 0, sizeof(t));
+ memset(&dir, 0, sizeof(dir));
+ dir.show_ignored = 1;
+ dir.exclude_per_dir = ".gitignore";
+ opts.dir = &dir;
+
+ opts.head_idx = 1;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
+ opts.update = 1;
+ opts.verbose_update = 1;
+ opts.merge = 1;
+ opts.fn = twoway_merge;
+
+ trees[nr_trees] = parse_tree_indirect(head);
+ if (!trees[nr_trees++])
+ return -1;
+ trees[nr_trees] = parse_tree_indirect(remote);
+ if (!trees[nr_trees++])
+ return -1;
+ for (i = 0; i < nr_trees; i++) {
+ parse_tree(trees[i]);
+ init_tree_desc(t+i, trees[i]->buffer, trees[i]->size);
+ }
+ if (unpack_trees(nr_trees, t, &opts))
+ return -1;
+ if (write_cache(fd, active_cache, active_nr) ||
+ commit_locked_index(lock_file))
+ die("unable to write new index file");
+ return 0;
+}
+
+static void split_merge_strategies(const char *string, struct strategy **list,
+ int *nr, int *alloc)
+{
+ char *p, *q, *buf;
+
+ if (!string)
+ return;
+
+ buf = xstrdup(string);
+ q = buf;
+ for (;;) {
+ p = strchr(q, ' ');
+ if (!p) {
+ ALLOC_GROW(*list, *nr + 1, *alloc);
+ (*list)[(*nr)++].name = xstrdup(q);
+ free(buf);
+ return;
+ } else {
+ *p = '\0';
+ ALLOC_GROW(*list, *nr + 1, *alloc);
+ (*list)[(*nr)++].name = xstrdup(q);
+ q = ++p;
+ }
+ }
+}
+
+static void add_strategies(const char *string, unsigned attr)
+{
+ struct strategy *list = NULL;
+ int list_alloc = 0, list_nr = 0, i;
+
+ memset(&list, 0, sizeof(list));
+ split_merge_strategies(string, &list, &list_nr, &list_alloc);
+ if (list) {
+ for (i = 0; i < list_nr; i++)
+ append_strategy(get_strategy(list[i].name));
+ return;
+ }
+ for (i = 0; i < ARRAY_SIZE(all_strategy); i++)
+ if (all_strategy[i].attr & attr)
+ append_strategy(&all_strategy[i]);
+
+}
+
+static int merge_trivial(void)
+{
+ unsigned char result_tree[20], result_commit[20];
+ struct commit_list parent;
+
+ write_tree_trivial(result_tree);
+ printf("Wonderful.\n");
+ parent.item = remoteheads->item;
+ parent.next = NULL;
+ commit_tree(merge_msg.buf, result_tree, &parent, result_commit);
+ finish(result_commit, "In-index merge");
+ drop_save();
+ return 0;
+}
+
+static int finish_automerge(struct commit_list *common,
+ unsigned char *result_tree,
+ const char *wt_strategy)
+{
+ struct commit_list *parents = NULL, *j;
+ struct strbuf buf = STRBUF_INIT;
+ unsigned char result_commit[20];
+
+ free_commit_list(common);
+ if (allow_fast_forward) {
+ parents = remoteheads;
+ commit_list_insert(lookup_commit(head), &parents);
+ parents = reduce_heads(parents);
+ } else {
+ struct commit_list **pptr = &parents;
+
+ pptr = &commit_list_insert(lookup_commit(head),
+ pptr)->next;
+ for (j = remoteheads; j; j = j->next)
+ pptr = &commit_list_insert(j->item, pptr)->next;
+ }
+ free_commit_list(remoteheads);
+ strbuf_addch(&merge_msg, '\n');
+ commit_tree(merge_msg.buf, result_tree, parents, result_commit);
+ strbuf_addf(&buf, "Merge made by %s.", wt_strategy);
+ finish(result_commit, buf.buf);
+ strbuf_release(&buf);
+ drop_save();
+ return 0;
+}
+
+static int suggest_conflicts(void)
+{
+ FILE *fp;
+ int pos;
+
+ fp = fopen(git_path("MERGE_MSG"), "a");
+ if (!fp)
+ die("Could open %s for writing", git_path("MERGE_MSG"));
+ fprintf(fp, "\nConflicts:\n");
+ for (pos = 0; pos < active_nr; pos++) {
+ struct cache_entry *ce = active_cache[pos];
+
+ if (ce_stage(ce)) {
+ fprintf(fp, "\t%s\n", ce->name);
+ while (pos + 1 < active_nr &&
+ !strcmp(ce->name,
+ active_cache[pos + 1]->name))
+ pos++;
+ }
+ }
+ fclose(fp);
+ rerere();
+ printf("Automatic merge failed; "
+ "fix conflicts and then commit the result.\n");
+ return 1;
+}
+
+static struct commit *is_old_style_invocation(int argc, const char **argv)
+{
+ struct commit *second_token = NULL;
+ if (argc > 1) {
+ unsigned char second_sha1[20];
+
+ if (get_sha1(argv[1], second_sha1))
+ return NULL;
+ second_token = lookup_commit_reference_gently(second_sha1, 0);
+ if (!second_token)
+ die("'%s' is not a commit", argv[1]);
+ if (hashcmp(second_token->object.sha1, head))
+ return NULL;
+ }
+ return second_token;
+}
+
+static int evaluate_result(void)
+{
+ int cnt = 0;
+ struct rev_info rev;
+
+ if (read_cache() < 0)
+ die("failed to read the cache");
+
+ /* Check how many files differ. */
+ init_revisions(&rev, "");
+ setup_revisions(0, NULL, &rev, NULL);
+ rev.diffopt.output_format |=
+ DIFF_FORMAT_CALLBACK;
+ rev.diffopt.format_callback = count_diff_files;
+ rev.diffopt.format_callback_data = &cnt;
+ run_diff_files(&rev, 0);
+
+ /*
+ * Check how many unmerged entries are
+ * there.
+ */
+ cnt += count_unmerged_entries();
+
+ return cnt;
+}
+
+int cmd_merge(int argc, const char **argv, const char *prefix)
+{
+ unsigned char result_tree[20];
+ struct strbuf buf;
+ const char *head_arg;
+ int flag, head_invalid = 0, i;
+ int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
+ struct commit_list *common = NULL;
+ const char *best_strategy = NULL, *wt_strategy = NULL;
+ struct commit_list **remotes = &remoteheads;
+
+ setup_work_tree();
+ if (unmerged_cache())
+ die("You are in the middle of a conflicted merge.");
+
+ /*
+ * Check if we are _not_ on a detached HEAD, i.e. if there is a
+ * current branch.
+ */
+ branch = resolve_ref("HEAD", head, 0, &flag);
+ if (branch && !prefixcmp(branch, "refs/heads/"))
+ branch += 11;
+ if (is_null_sha1(head))
+ head_invalid = 1;
+
+ git_config(git_merge_config, NULL);
+
+ /* for color.ui */
+ if (diff_use_color_default == -1)
+ diff_use_color_default = git_use_color_default;
+
+ argc = parse_options(argc, argv, builtin_merge_options,
+ builtin_merge_usage, 0);
+
+ if (squash) {
+ if (!allow_fast_forward)
+ die("You cannot combine --squash with --no-ff.");
+ option_commit = 0;
+ }
+
+ if (!argc)
+ usage_with_options(builtin_merge_usage,
+ builtin_merge_options);
+
+ /*
+ * This could be traditional "merge <msg> HEAD <commit>..." and
+ * the way we can tell it is to see if the second token is HEAD,
+ * but some people might have misused the interface and used a
+ * committish that is the same as HEAD there instead.
+ * Traditional format never would have "-m" so it is an
+ * additional safety measure to check for it.
+ */
+ strbuf_init(&buf, 0);
+
+ if (!have_message && is_old_style_invocation(argc, argv)) {
+ strbuf_addstr(&merge_msg, argv[0]);
+ head_arg = argv[1];
+ argv += 2;
+ argc -= 2;
+ } else if (head_invalid) {
+ struct object *remote_head;
+ /*
+ * If the merged head is a valid one there is no reason
+ * to forbid "git merge" into a branch yet to be born.
+ * We do the same for "git pull".
+ */
+ if (argc != 1)
+ die("Can merge only exactly one commit into "
+ "empty head");
+ remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
+ if (!remote_head)
+ die("%s - not something we can merge", argv[0]);
+ update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
+ DIE_ON_ERR);
+ reset_hard(remote_head->sha1, 0);
+ return 0;
+ } else {
+ struct strbuf msg;
+
+ /* We are invoked directly as the first-class UI. */
+ head_arg = "HEAD";
+
+ /*
+ * All the rest are the commits being merged;
+ * prepare the standard merge summary message to
+ * be appended to the given message. If remote
+ * is invalid we will die later in the common
+ * codepath so we discard the error in this
+ * loop.
+ */
+ strbuf_init(&msg, 0);
+ for (i = 0; i < argc; i++)
+ merge_name(argv[i], &msg);
+ fmt_merge_msg(option_log, &msg, &merge_msg);
+ if (merge_msg.len)
+ strbuf_setlen(&merge_msg, merge_msg.len-1);
+ }
+
+ if (head_invalid || !argc)
+ usage_with_options(builtin_merge_usage,
+ builtin_merge_options);
+
+ strbuf_addstr(&buf, "merge");
+ for (i = 0; i < argc; i++)
+ strbuf_addf(&buf, " %s", argv[i]);
+ setenv("GIT_REFLOG_ACTION", buf.buf, 0);
+ strbuf_reset(&buf);
+
+ for (i = 0; i < argc; i++) {
+ struct object *o;
+
+ o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT);
+ if (!o)
+ die("%s - not something we can merge", argv[i]);
+ remotes = &commit_list_insert(lookup_commit(o->sha1),
+ remotes)->next;
+
+ strbuf_addf(&buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
+ setenv(buf.buf, argv[i], 1);
+ strbuf_reset(&buf);
+ }
+
+ if (!use_strategies) {
+ if (!remoteheads->next)
+ add_strategies(pull_twohead, DEFAULT_TWOHEAD);
+ else
+ add_strategies(pull_octopus, DEFAULT_OCTOPUS);
+ }
+
+ for (i = 0; i < use_strategies_nr; i++) {
+ if (use_strategies[i]->attr & NO_FAST_FORWARD)
+ allow_fast_forward = 0;
+ if (use_strategies[i]->attr & NO_TRIVIAL)
+ allow_trivial = 0;
+ }
+
+ if (!remoteheads->next)
+ common = get_merge_bases(lookup_commit(head),
+ remoteheads->item, 1);
+ else {
+ struct commit_list *list = remoteheads;
+ commit_list_insert(lookup_commit(head), &list);
+ common = get_octopus_merge_bases(list);
+ free(list);
+ }
+
+ update_ref("updating ORIG_HEAD", "ORIG_HEAD", head, NULL, 0,
+ DIE_ON_ERR);
+
+ if (!common)
+ ; /* No common ancestors found. We need a real merge. */
+ else if (!remoteheads->next && !common->next &&
+ common->item == remoteheads->item) {
+ /*
+ * If head can reach all the merge then we are up to date.
+ * but first the most common case of merging one remote.
+ */
+ finish_up_to_date("Already up-to-date.");
+ return 0;
+ } else if (allow_fast_forward && !remoteheads->next &&
+ !common->next &&
+ !hashcmp(common->item->object.sha1, head)) {
+ /* Again the most common case of merging one remote. */
+ struct strbuf msg;
+ struct object *o;
+ char hex[41];
+
+ strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV));
+
+ printf("Updating %s..%s\n",
+ hex,
+ find_unique_abbrev(remoteheads->item->object.sha1,
+ DEFAULT_ABBREV));
+ refresh_cache(REFRESH_QUIET);
+ strbuf_init(&msg, 0);
+ strbuf_addstr(&msg, "Fast forward");
+ if (have_message)
+ strbuf_addstr(&msg,
+ " (no commit created; -m option ignored)");
+ o = peel_to_type(sha1_to_hex(remoteheads->item->object.sha1),
+ 0, NULL, OBJ_COMMIT);
+ if (!o)
+ return 1;
+
+ if (checkout_fast_forward(head, remoteheads->item->object.sha1))
+ return 1;
+
+ finish(o->sha1, msg.buf);
+ drop_save();
+ return 0;
+ } else if (!remoteheads->next && common->next)
+ ;
+ /*
+ * We are not doing octopus and not fast forward. Need
+ * a real merge.
+ */
+ else if (!remoteheads->next && !common->next && option_commit) {
+ /*
+ * We are not doing octopus, not fast forward, and have
+ * only one common.
+ */
+ refresh_cache(REFRESH_QUIET);
+ if (allow_trivial) {
+ /* See if it is really trivial. */
+ git_committer_info(IDENT_ERROR_ON_NO_NAME);
+ printf("Trying really trivial in-index merge...\n");
+ if (!read_tree_trivial(common->item->object.sha1,
+ head, remoteheads->item->object.sha1))
+ return merge_trivial();
+ printf("Nope.\n");
+ }
+ } else {
+ /*
+ * An octopus. If we can reach all the remote we are up
+ * to date.
+ */
+ int up_to_date = 1;
+ struct commit_list *j;
+
+ for (j = remoteheads; j; j = j->next) {
+ struct commit_list *common_one;
+
+ /*
+ * Here we *have* to calculate the individual
+ * merge_bases again, otherwise "git merge HEAD^
+ * HEAD^^" would be missed.
+ */
+ common_one = get_merge_bases(lookup_commit(head),
+ j->item, 1);
+ if (hashcmp(common_one->item->object.sha1,
+ j->item->object.sha1)) {
+ up_to_date = 0;
+ break;
+ }
+ }
+ if (up_to_date) {
+ finish_up_to_date("Already up-to-date. Yeeah!");
+ return 0;
+ }
+ }
+
+ /* We are going to make a new commit. */
+ git_committer_info(IDENT_ERROR_ON_NO_NAME);
+
+ /*
+ * At this point, we need a real merge. No matter what strategy
+ * we use, it would operate on the index, possibly affecting the
+ * working tree, and when resolved cleanly, have the desired
+ * tree in the index -- this means that the index must be in
+ * sync with the head commit. The strategies are responsible
+ * to ensure this.
+ */
+ if (use_strategies_nr != 1) {
+ /*
+ * Stash away the local changes so that we can try more
+ * than one.
+ */
+ save_state();
+ } else {
+ memcpy(stash, null_sha1, 20);
+ }
+
+ for (i = 0; i < use_strategies_nr; i++) {
+ int ret;
+ if (i) {
+ printf("Rewinding the tree to pristine...\n");
+ restore_state();
+ }
+ if (use_strategies_nr != 1)
+ printf("Trying merge strategy %s...\n",
+ use_strategies[i]->name);
+ /*
+ * Remember which strategy left the state in the working
+ * tree.
+ */
+ wt_strategy = use_strategies[i]->name;
+
+ ret = try_merge_strategy(use_strategies[i]->name,
+ common, head_arg);
+ if (!option_commit && !ret) {
+ merge_was_ok = 1;
+ /*
+ * This is necessary here just to avoid writing
+ * the tree, but later we will *not* exit with
+ * status code 1 because merge_was_ok is set.
+ */
+ ret = 1;
+ }
+
+ if (ret) {
+ /*
+ * The backend exits with 1 when conflicts are
+ * left to be resolved, with 2 when it does not
+ * handle the given merge at all.
+ */
+ if (ret == 1) {
+ int cnt = evaluate_result();
+
+ if (best_cnt <= 0 || cnt <= best_cnt) {
+ best_strategy = use_strategies[i]->name;
+ best_cnt = cnt;
+ }
+ }
+ if (merge_was_ok)
+ break;
+ else
+ continue;
+ }
+
+ /* Automerge succeeded. */
+ write_tree_trivial(result_tree);
+ automerge_was_ok = 1;
+ break;
+ }
+
+ /*
+ * If we have a resulting tree, that means the strategy module
+ * auto resolved the merge cleanly.
+ */
+ if (automerge_was_ok)
+ return finish_automerge(common, result_tree, wt_strategy);
+
+ /*
+ * Pick the result from the best strategy and have the user fix
+ * it up.
+ */
+ if (!best_strategy) {
+ restore_state();
+ if (use_strategies_nr > 1)
+ fprintf(stderr,
+ "No merge strategy handled the merge.\n");
+ else
+ fprintf(stderr, "Merge with strategy %s failed.\n",
+ use_strategies[0]->name);
+ return 2;
+ } else if (best_strategy == wt_strategy)
+ ; /* We already have its result in the working tree. */
+ else {
+ printf("Rewinding the tree to pristine...\n");
+ restore_state();
+ printf("Using the %s to prepare resolving by hand.\n",
+ best_strategy);
+ try_merge_strategy(best_strategy, common, head_arg);
+ }
+
+ if (squash)
+ finish(NULL, NULL);
+ else {
+ int fd;
+ struct commit_list *j;
+
+ for (j = remoteheads; j; j = j->next)
+ strbuf_addf(&buf, "%s\n",
+ sha1_to_hex(j->item->object.sha1));
+ fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
+ if (fd < 0)
+ die("Could open %s for writing",
+ git_path("MERGE_HEAD"));
+ if (write_in_full(fd, buf.buf, buf.len) != buf.len)
+ die("Could not write to %s", git_path("MERGE_HEAD"));
+ close(fd);
+ strbuf_addch(&merge_msg, '\n');
+ fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
+ if (fd < 0)
+ die("Could open %s for writing", git_path("MERGE_MSG"));
+ if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
+ merge_msg.len)
+ die("Could not write to %s", git_path("MERGE_MSG"));
+ close(fd);
+ }
+
+ if (merge_was_ok) {
+ fprintf(stderr, "Automatic merge went well; "
+ "stopped before committing as requested\n");
+ return 0;
+ } else
+ return suggest_conflicts();
+}
diff --git a/builtin-mv.c b/builtin-mv.c
index 990e21355..4f65b5ae9 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -7,11 +7,11 @@
#include "builtin.h"
#include "dir.h"
#include "cache-tree.h"
-#include "path-list.h"
+#include "string-list.h"
#include "parse-options.h"
static const char * const builtin_mv_usage[] = {
- "git-mv [options] <source>... <destination>",
+ "git mv [options] <source>... <destination>",
NULL
};
@@ -36,17 +36,6 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
return get_pathspec(prefix, result);
}
-static void show_list(const char *label, struct path_list *list)
-{
- if (list->nr > 0) {
- int i;
- printf("%s", label);
- for (i = 0; i < list->nr; i++)
- printf("%s%s", i > 0 ? ", " : "", list->items[i].path);
- putchar('\n');
- }
-}
-
static const char *add_slash(const char *path)
{
int len = strlen(path);
@@ -75,13 +64,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
const char **source, **destination, **dest_path;
enum update_mode { BOTH = 0, WORKING_DIRECTORY, INDEX } *modes;
struct stat st;
- struct path_list overwritten = {NULL, 0, 0, 0};
- struct path_list src_for_dst = {NULL, 0, 0, 0};
- struct path_list added = {NULL, 0, 0, 0};
- struct path_list deleted = {NULL, 0, 0, 0};
- struct path_list changed = {NULL, 0, 0, 0};
+ struct string_list src_for_dst = {NULL, 0, 0, 0};
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
newfd = hold_locked_index(&lock_file, 1);
if (read_cache() < 0)
@@ -164,7 +149,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
}
dst = add_slash(dst);
- dst_len = strlen(dst) - 1;
+ dst_len = strlen(dst);
for (j = 0; j < last - first; j++) {
const char *path =
@@ -172,7 +157,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
source[argc + j] = path;
destination[argc + j] =
prefix_path(dst, dst_len,
- path + length);
+ path + length + 1);
modes[argc + j] = INDEX;
}
argc += last - first;
@@ -184,21 +169,20 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
* only files can overwrite each other:
* check both source and destination
*/
- if (S_ISREG(st.st_mode)) {
+ if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) {
fprintf(stderr, "Warning: %s;"
" will overwrite!\n",
bad);
bad = NULL;
- path_list_insert(dst, &overwritten);
} else
bad = "Cannot overwrite";
}
} else if (cache_name_pos(src, length) < 0)
bad = "not under version control";
- else if (path_list_has_path(&src_for_dst, dst))
+ else if (string_list_has_string(&src_for_dst, dst))
bad = "multiple sources for the same target";
else
- path_list_insert(dst, &src_for_dst);
+ string_list_insert(dst, &src_for_dst);
if (bad) {
if (ignore_errors) {
@@ -218,6 +202,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
for (i = 0; i < argc; i++) {
const char *src = source[i], *dst = destination[i];
enum update_mode mode = modes[i];
+ int pos;
if (show_only || verbose)
printf("Renaming %s to %s\n", src, dst);
if (!show_only && mode != INDEX &&
@@ -227,46 +212,16 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
if (mode == WORKING_DIRECTORY)
continue;
- if (cache_name_pos(src, strlen(src)) >= 0) {
- path_list_insert(src, &deleted);
-
- /* destination can be a directory with 1 file inside */
- if (path_list_has_path(&overwritten, dst))
- path_list_insert(dst, &changed);
- else
- path_list_insert(dst, &added);
- } else
- path_list_insert(dst, &added);
+ pos = cache_name_pos(src, strlen(src));
+ assert(pos >= 0);
+ if (!show_only)
+ rename_cache_entry_at(pos, dst);
}
- if (show_only) {
- show_list("Changed : ", &changed);
- show_list("Adding : ", &added);
- show_list("Deleting : ", &deleted);
- } else {
- for (i = 0; i < changed.nr; i++) {
- const char *path = changed.items[i].path;
- int j = cache_name_pos(path, strlen(path));
- struct cache_entry *ce = active_cache[j];
-
- if (j < 0)
- die ("Huh? Cache entry for %s unknown?", path);
- refresh_cache_entry(ce, 0);
- }
-
- for (i = 0; i < added.nr; i++) {
- const char *path = added.items[i].path;
- add_file_to_cache(path, verbose);
- }
-
- for (i = 0; i < deleted.nr; i++)
- remove_file_from_cache(deleted.items[i].path);
-
- if (active_cache_changed) {
- if (write_cache(newfd, active_cache, active_nr) ||
- commit_locked_index(&lock_file))
- die("Unable to write new index file");
- }
+ if (active_cache_changed) {
+ if (write_cache(newfd, active_cache, active_nr) ||
+ commit_locked_index(&lock_file))
+ die("Unable to write new index file");
}
return 0;
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index a0c89a827..08c8aabf9 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -125,18 +125,18 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
}
/* returns a static buffer */
-static const char* get_rev_name(struct object *o)
+static const char *get_rev_name(const struct object *o)
{
static char buffer[1024];
struct rev_name *n;
struct commit *c;
if (o->type != OBJ_COMMIT)
- return "undefined";
+ return NULL;
c = (struct commit *) o;
n = c->util;
if (!n)
- return "undefined";
+ return NULL;
if (!n->generation)
return n->tip_name;
@@ -151,15 +151,77 @@ static const char* get_rev_name(struct object *o)
}
}
+static void show_name(const struct object *obj,
+ const char *caller_name,
+ int always, int allow_undefined, int name_only)
+{
+ const char *name;
+ const unsigned char *sha1 = obj->sha1;
+
+ if (!name_only)
+ printf("%s ", caller_name ? caller_name : sha1_to_hex(sha1));
+ name = get_rev_name(obj);
+ if (name)
+ printf("%s\n", name);
+ else if (allow_undefined)
+ printf("undefined\n");
+ else if (always)
+ printf("%s\n", find_unique_abbrev(sha1, DEFAULT_ABBREV));
+ else
+ die("cannot describe '%s'", sha1_to_hex(sha1));
+}
+
static char const * const name_rev_usage[] = {
- "git-name-rev [options] ( --all | --stdin | <commit>... )",
+ "git name-rev [options] ( --all | --stdin | <commit>... )",
NULL
};
+static void name_rev_line(char *p, struct name_ref_data *data)
+{
+ int forty = 0;
+ char *p_start;
+ for (p_start = p; *p; p++) {
+#define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
+ if (!ishex(*p))
+ forty = 0;
+ else if (++forty == 40 &&
+ !ishex(*(p+1))) {
+ unsigned char sha1[40];
+ const char *name = NULL;
+ char c = *(p+1);
+ int p_len = p - p_start + 1;
+
+ forty = 0;
+
+ *(p+1) = 0;
+ if (!get_sha1(p - 39, sha1)) {
+ struct object *o =
+ lookup_object(sha1);
+ if (o)
+ name = get_rev_name(o);
+ }
+ *(p+1) = c;
+
+ if (!name)
+ continue;
+
+ if (data->name_only)
+ printf("%.*s%s", p_len - 40, p_start, name);
+ else
+ printf("%.*s (%s)", p_len, p_start, name);
+ p_start = p + 1;
+ }
+ }
+
+ /* flush */
+ if (p_start != p)
+ fwrite(p_start, p - p_start, 1, stdout);
+}
+
int cmd_name_rev(int argc, const char **argv, const char *prefix)
{
struct object_array revs = { 0, 0, NULL };
- int all = 0, transform_stdin = 0;
+ int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0;
struct name_ref_data data = { 0, 0, NULL };
struct option opts[] = {
OPT_BOOLEAN(0, "name-only", &data.name_only, "print only names (no SHA-1)"),
@@ -169,10 +231,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
OPT_GROUP(""),
OPT_BOOLEAN(0, "all", &all, "list all commits reachable from all refs"),
OPT_BOOLEAN(0, "stdin", &transform_stdin, "read from stdin"),
+ OPT_BOOLEAN(0, "undefined", &allow_undefined, "allow to print `undefined` names"),
+ OPT_BOOLEAN(0, "always", &always,
+ "show abbreviated commit object as fallback"),
OPT_END(),
};
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
argc = parse_options(argc, argv, opts, name_rev_usage, 0);
if (!!all + !!transform_stdin + !!argc > 1) {
error("Specify either a list, or --all, not both!");
@@ -211,68 +276,29 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
if (transform_stdin) {
char buffer[2048];
- char *p, *p_start;
while (!feof(stdin)) {
- int forty = 0;
- p = fgets(buffer, sizeof(buffer), stdin);
+ char *p = fgets(buffer, sizeof(buffer), stdin);
if (!p)
break;
-
- for (p_start = p; *p; p++) {
-#define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
- if (!ishex(*p))
- forty = 0;
- else if (++forty == 40 &&
- !ishex(*(p+1))) {
- unsigned char sha1[40];
- const char *name = "undefined";
- char c = *(p+1);
-
- forty = 0;
-
- *(p+1) = 0;
- if (!get_sha1(p - 39, sha1)) {
- struct object *o =
- lookup_object(sha1);
- if (o)
- name = get_rev_name(o);
- }
- *(p+1) = c;
-
- if (!strcmp(name, "undefined"))
- continue;
-
- fwrite(p_start, p - p_start + 1, 1,
- stdout);
- printf(" (%s)", name);
- p_start = p + 1;
- }
- }
-
- /* flush */
- if (p_start != p)
- fwrite(p_start, p - p_start, 1, stdout);
+ name_rev_line(p, &data);
}
} else if (all) {
int i, max;
max = get_max_object_index();
for (i = 0; i < max; i++) {
- struct object * obj = get_indexed_object(i);
+ struct object *obj = get_indexed_object(i);
if (!obj)
continue;
- if (!data.name_only)
- printf("%s ", sha1_to_hex(obj->sha1));
- printf("%s\n", get_rev_name(obj));
+ show_name(obj, NULL,
+ always, allow_undefined, data.name_only);
}
} else {
int i;
- for (i = 0; i < revs.nr; i++) {
- if (!data.name_only)
- printf("%s ", revs.objects[i].name);
- printf("%s\n", get_rev_name(revs.objects[i].item));
- }
+ for (i = 0; i < revs.nr; i++)
+ show_name(revs.objects[i].item, revs.objects[i].name,
+ always, allow_undefined, data.name_only);
}
return 0;
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index ec10238e4..2dadec163 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -8,14 +8,17 @@
#include "tree.h"
#include "delta.h"
#include "pack.h"
+#include "pack-revindex.h"
#include "csum-file.h"
#include "tree-walk.h"
#include "diff.h"
#include "revision.h"
#include "list-objects.h"
#include "progress.h"
+#include "refs.h"
#ifdef THREADED_DELTA_SEARCH
+#include "thread-utils.h"
#include <pthread.h>
#endif
@@ -25,7 +28,9 @@ git-pack-objects [{ -q | --progress | --all-progress }] \n\
[--window=N] [--window-memory=N] [--depth=N] \n\
[--no-reuse-delta] [--no-reuse-object] [--delta-base-offset] \n\
[--threads=N] [--non-empty] [--revs [--unpacked | --all]*] [--reflog] \n\
- [--stdout | base-name] [--keep-unreachable] [<ref-list | <object-list]";
+ [--stdout | base-name] [--include-tag] \n\
+ [--keep-unreachable | --unpack-unreachable] \n\
+ [<ref-list | <object-list]";
struct object_entry {
struct pack_idx_entry idx;
@@ -39,6 +44,7 @@ struct object_entry {
*/
void *delta_data; /* cached delta (uncompressed) */
unsigned long delta_size; /* delta data size (uncompressed) */
+ unsigned long z_delta_size; /* delta data size (compressed) */
unsigned int hash; /* name hint hash */
enum object_type type;
enum object_type in_pack_type; /* could be delta */
@@ -61,14 +67,15 @@ static struct pack_idx_entry **written_list;
static uint32_t nr_objects, nr_alloc, nr_result, nr_written;
static int non_empty;
-static int no_reuse_delta, no_reuse_object, keep_unreachable;
+static int reuse_delta = 1, reuse_object = 1;
+static int keep_unreachable, unpack_unreachable, include_tag;
static int local;
static int incremental;
static int allow_ofs_delta;
static const char *base_name;
static int progress = 1;
static int window = 10;
-static uint32_t pack_size_limit;
+static uint32_t pack_size_limit, pack_size_limit_cfg;
static int depth = 50;
static int delta_search_threads = 1;
static int pack_to_stdout;
@@ -92,176 +99,59 @@ static int *object_ix;
static int object_ix_hashsz;
/*
- * Pack index for existing packs give us easy access to the offsets into
- * corresponding pack file where each object's data starts, but the entries
- * do not store the size of the compressed representation (uncompressed
- * size is easily available by examining the pack entry header). It is
- * also rather expensive to find the sha1 for an object given its offset.
- *
- * We build a hashtable of existing packs (pack_revindex), and keep reverse
- * index here -- pack index file is sorted by object name mapping to offset;
- * this pack_revindex[].revindex array is a list of offset/index_nr pairs
- * ordered by offset, so if you know the offset of an object, next offset
- * is where its packed representation ends and the index_nr can be used to
- * get the object sha1 from the main index.
- */
-struct revindex_entry {
- off_t offset;
- unsigned int nr;
-};
-struct pack_revindex {
- struct packed_git *p;
- struct revindex_entry *revindex;
-};
-static struct pack_revindex *pack_revindex;
-static int pack_revindex_hashsz;
-
-/*
* stats
*/
static uint32_t written, written_delta;
static uint32_t reused, reused_delta;
-static int pack_revindex_ix(struct packed_git *p)
-{
- unsigned long ui = (unsigned long)p;
- int i;
-
- ui = ui ^ (ui >> 16); /* defeat structure alignment */
- i = (int)(ui % pack_revindex_hashsz);
- while (pack_revindex[i].p) {
- if (pack_revindex[i].p == p)
- return i;
- if (++i == pack_revindex_hashsz)
- i = 0;
- }
- return -1 - i;
-}
-static void prepare_pack_ix(void)
+static void *get_delta(struct object_entry *entry)
{
- int num;
- struct packed_git *p;
- for (num = 0, p = packed_git; p; p = p->next)
- num++;
- if (!num)
- return;
- pack_revindex_hashsz = num * 11;
- pack_revindex = xcalloc(sizeof(*pack_revindex), pack_revindex_hashsz);
- for (p = packed_git; p; p = p->next) {
- num = pack_revindex_ix(p);
- num = - 1 - num;
- pack_revindex[num].p = p;
- }
- /* revindex elements are lazily initialized */
-}
-
-static int cmp_offset(const void *a_, const void *b_)
-{
- const struct revindex_entry *a = a_;
- const struct revindex_entry *b = b_;
- return (a->offset < b->offset) ? -1 : (a->offset > b->offset) ? 1 : 0;
-}
-
-/*
- * Ordered list of offsets of objects in the pack.
- */
-static void prepare_pack_revindex(struct pack_revindex *rix)
-{
- struct packed_git *p = rix->p;
- int num_ent = p->num_objects;
- int i;
- const char *index = p->index_data;
-
- rix->revindex = xmalloc(sizeof(*rix->revindex) * (num_ent + 1));
- index += 4 * 256;
-
- if (p->index_version > 1) {
- const uint32_t *off_32 =
- (uint32_t *)(index + 8 + p->num_objects * (20 + 4));
- const uint32_t *off_64 = off_32 + p->num_objects;
- for (i = 0; i < num_ent; i++) {
- uint32_t off = ntohl(*off_32++);
- if (!(off & 0x80000000)) {
- rix->revindex[i].offset = off;
- } else {
- rix->revindex[i].offset =
- ((uint64_t)ntohl(*off_64++)) << 32;
- rix->revindex[i].offset |=
- ntohl(*off_64++);
- }
- rix->revindex[i].nr = i;
- }
- } else {
- for (i = 0; i < num_ent; i++) {
- uint32_t hl = *((uint32_t *)(index + 24 * i));
- rix->revindex[i].offset = ntohl(hl);
- rix->revindex[i].nr = i;
- }
- }
-
- /* This knows the pack format -- the 20-byte trailer
- * follows immediately after the last object data.
- */
- rix->revindex[num_ent].offset = p->pack_size - 20;
- rix->revindex[num_ent].nr = -1;
- qsort(rix->revindex, num_ent, sizeof(*rix->revindex), cmp_offset);
-}
-
-static struct revindex_entry * find_packed_object(struct packed_git *p,
- off_t ofs)
-{
- int num;
- int lo, hi;
- struct pack_revindex *rix;
- struct revindex_entry *revindex;
- num = pack_revindex_ix(p);
- if (num < 0)
- die("internal error: pack revindex uninitialized");
- rix = &pack_revindex[num];
- if (!rix->revindex)
- prepare_pack_revindex(rix);
- revindex = rix->revindex;
- lo = 0;
- hi = p->num_objects + 1;
- do {
- int mi = (lo + hi) / 2;
- if (revindex[mi].offset == ofs) {
- return revindex + mi;
- }
- else if (ofs < revindex[mi].offset)
- hi = mi;
- else
- lo = mi + 1;
- } while (lo < hi);
- die("internal error: pack revindex corrupt");
-}
-
-static const unsigned char *find_packed_object_name(struct packed_git *p,
- off_t ofs)
-{
- struct revindex_entry *entry = find_packed_object(p, ofs);
- return nth_packed_object_sha1(p, entry->nr);
-}
-
-static void *delta_against(void *buf, unsigned long size, struct object_entry *entry)
-{
- unsigned long othersize, delta_size;
+ unsigned long size, base_size, delta_size;
+ void *buf, *base_buf, *delta_buf;
enum object_type type;
- void *otherbuf = read_sha1_file(entry->delta->idx.sha1, &type, &othersize);
- void *delta_buf;
- if (!otherbuf)
+ buf = read_sha1_file(entry->idx.sha1, &type, &size);
+ if (!buf)
+ die("unable to read %s", sha1_to_hex(entry->idx.sha1));
+ base_buf = read_sha1_file(entry->delta->idx.sha1, &type, &base_size);
+ if (!base_buf)
die("unable to read %s", sha1_to_hex(entry->delta->idx.sha1));
- delta_buf = diff_delta(otherbuf, othersize,
+ delta_buf = diff_delta(base_buf, base_size,
buf, size, &delta_size, 0);
- if (!delta_buf || delta_size != entry->delta_size)
+ if (!delta_buf || delta_size != entry->delta_size)
die("delta size changed");
- free(buf);
- free(otherbuf);
+ free(buf);
+ free(base_buf);
return delta_buf;
}
+static unsigned long do_compress(void **pptr, unsigned long size)
+{
+ z_stream stream;
+ void *in, *out;
+ unsigned long maxsize;
+
+ memset(&stream, 0, sizeof(stream));
+ deflateInit(&stream, pack_compression_level);
+ maxsize = deflateBound(&stream, size);
+
+ in = *pptr;
+ out = xmalloc(maxsize);
+ *pptr = out;
+
+ stream.next_in = in;
+ stream.avail_in = size;
+ stream.next_out = out;
+ stream.avail_out = maxsize;
+ while (deflate(&stream, Z_FINISH) == Z_OK)
+ ; /* nothing */
+ deflateEnd(&stream);
+
+ free(in);
+ return stream.total_out;
+}
+
/*
* The per-object header is a pretty dense thing, which is
* - first byte: low four bits are "size", then three bits of "type",
@@ -319,28 +209,6 @@ static int check_pack_inflate(struct packed_git *p,
stream.total_in == len) ? 0 : -1;
}
-static int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
- off_t offset, off_t len, unsigned int nr)
-{
- const uint32_t *index_crc;
- uint32_t data_crc = crc32(0, Z_NULL, 0);
-
- do {
- unsigned int avail;
- void *data = use_pack(p, w_curs, offset, &avail);
- if (avail > len)
- avail = len;
- data_crc = crc32(data_crc, data, avail);
- offset += avail;
- len -= avail;
- } while (len);
-
- index_crc = p->index_data;
- index_crc += 2 + 256 + p->num_objects * (20/4) + nr;
-
- return data_crc != ntohl(*index_crc);
-}
-
static void copy_pack_data(struct sha1file *f,
struct packed_git *p,
struct pack_window **w_curs,
@@ -364,42 +232,42 @@ static unsigned long write_object(struct sha1file *f,
struct object_entry *entry,
off_t write_offset)
{
- unsigned long size;
- enum object_type type;
+ unsigned long size, limit, datalen;
void *buf;
- unsigned char header[10];
- unsigned char dheader[10];
+ unsigned char header[10], dheader[10];
unsigned hdrlen;
- off_t datalen;
- enum object_type obj_type;
- int to_reuse = 0;
- /* write limit if limited packsize and not first object */
- unsigned long limit = pack_size_limit && nr_written ?
- pack_size_limit - write_offset : 0;
- /* no if no delta */
- int usable_delta = !entry->delta ? 0 :
- /* yes if unlimited packfile */
- !pack_size_limit ? 1 :
- /* no if base written to previous pack */
- entry->delta->idx.offset == (off_t)-1 ? 0 :
- /* otherwise double-check written to this
- * pack, like we do below
- */
- entry->delta->idx.offset ? 1 : 0;
+ enum object_type type;
+ int usable_delta, to_reuse;
if (!pack_to_stdout)
crc32_begin(f);
- obj_type = entry->type;
- if (no_reuse_object)
+ type = entry->type;
+
+ /* write limit if limited packsize and not first object */
+ limit = pack_size_limit && nr_written ?
+ pack_size_limit - write_offset : 0;
+
+ if (!entry->delta)
+ usable_delta = 0; /* no delta */
+ else if (!pack_size_limit)
+ usable_delta = 1; /* unlimited packfile */
+ else if (entry->delta->idx.offset == (off_t)-1)
+ usable_delta = 0; /* base was written to another pack */
+ else if (entry->delta->idx.offset)
+ usable_delta = 1; /* base already exists in this pack */
+ else
+ usable_delta = 0; /* base could end up in another pack */
+
+ if (!reuse_object)
to_reuse = 0; /* explicit */
else if (!entry->in_pack)
to_reuse = 0; /* can't reuse what we don't have */
- else if (obj_type == OBJ_REF_DELTA || obj_type == OBJ_OFS_DELTA)
+ else if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA)
/* check_object() decided it for us ... */
to_reuse = usable_delta;
/* ... but pack split may override that */
- else if (obj_type != entry->in_pack_type)
+ else if (type != entry->in_pack_type)
to_reuse = 0; /* pack has delta which is unusable */
else if (entry->delta)
to_reuse = 0; /* we want to pack afresh */
@@ -409,50 +277,42 @@ static unsigned long write_object(struct sha1file *f,
*/
if (!to_reuse) {
- z_stream stream;
- unsigned long maxsize;
- void *out;
if (!usable_delta) {
- buf = read_sha1_file(entry->idx.sha1, &obj_type, &size);
+ buf = read_sha1_file(entry->idx.sha1, &type, &size);
if (!buf)
die("unable to read %s", sha1_to_hex(entry->idx.sha1));
+ /*
+ * make sure no cached delta data remains from a
+ * previous attempt before a pack split occured.
+ */
+ free(entry->delta_data);
+ entry->delta_data = NULL;
+ entry->z_delta_size = 0;
} else if (entry->delta_data) {
size = entry->delta_size;
buf = entry->delta_data;
entry->delta_data = NULL;
- obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
+ type = (allow_ofs_delta && entry->delta->idx.offset) ?
OBJ_OFS_DELTA : OBJ_REF_DELTA;
} else {
- buf = read_sha1_file(entry->idx.sha1, &type, &size);
- if (!buf)
- die("unable to read %s", sha1_to_hex(entry->idx.sha1));
- buf = delta_against(buf, size, entry);
+ buf = get_delta(entry);
size = entry->delta_size;
- obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
+ type = (allow_ofs_delta && entry->delta->idx.offset) ?
OBJ_OFS_DELTA : OBJ_REF_DELTA;
}
- /* compress the data to store and put compressed length in datalen */
- memset(&stream, 0, sizeof(stream));
- deflateInit(&stream, pack_compression_level);
- maxsize = deflateBound(&stream, size);
- out = xmalloc(maxsize);
- /* Compress it */
- stream.next_in = buf;
- stream.avail_in = size;
- stream.next_out = out;
- stream.avail_out = maxsize;
- while (deflate(&stream, Z_FINISH) == Z_OK)
- /* nothing */;
- deflateEnd(&stream);
- datalen = stream.total_out;
+
+ if (entry->z_delta_size)
+ datalen = entry->z_delta_size;
+ else
+ datalen = do_compress(&buf, size);
/*
* The object header is a byte of 'type' followed by zero or
* more bytes of length.
*/
- hdrlen = encode_header(obj_type, size, header);
+ hdrlen = encode_header(type, size, header);
- if (obj_type == OBJ_OFS_DELTA) {
+ if (type == OBJ_OFS_DELTA) {
/*
* Deltas with relative base contain an additional
* encoding of the relative offset for the delta
@@ -464,20 +324,18 @@ static unsigned long write_object(struct sha1file *f,
while (ofs >>= 7)
dheader[--pos] = 128 | (--ofs & 127);
if (limit && hdrlen + sizeof(dheader) - pos + datalen + 20 >= limit) {
- free(out);
free(buf);
return 0;
}
sha1write(f, header, hdrlen);
sha1write(f, dheader + pos, sizeof(dheader) - pos);
hdrlen += sizeof(dheader) - pos;
- } else if (obj_type == OBJ_REF_DELTA) {
+ } else if (type == OBJ_REF_DELTA) {
/*
* Deltas with a base reference contain
* an additional 20 bytes for the base sha1.
*/
if (limit && hdrlen + 20 + datalen + 20 >= limit) {
- free(out);
free(buf);
return 0;
}
@@ -486,14 +344,12 @@ static unsigned long write_object(struct sha1file *f,
hdrlen += 20;
} else {
if (limit && hdrlen + datalen + 20 >= limit) {
- free(out);
free(buf);
return 0;
}
sha1write(f, header, hdrlen);
}
- sha1write(f, out, datalen);
- free(out);
+ sha1write(f, buf, datalen);
free(buf);
}
else {
@@ -503,20 +359,20 @@ static unsigned long write_object(struct sha1file *f,
off_t offset;
if (entry->delta) {
- obj_type = (allow_ofs_delta && entry->delta->idx.offset) ?
+ type = (allow_ofs_delta && entry->delta->idx.offset) ?
OBJ_OFS_DELTA : OBJ_REF_DELTA;
reused_delta++;
}
- hdrlen = encode_header(obj_type, entry->size, header);
+ hdrlen = encode_header(type, entry->size, header);
offset = entry->in_pack_offset;
- revidx = find_packed_object(p, offset);
+ revidx = find_pack_revindex(p, offset);
datalen = revidx[1].offset - offset;
if (!pack_to_stdout && p->index_version > 1 &&
check_pack_crc(p, &w_curs, offset, datalen, revidx->nr))
die("bad packed object CRC for %s", sha1_to_hex(entry->idx.sha1));
offset += entry->in_pack_header_size;
datalen -= entry->in_pack_header_size;
- if (obj_type == OBJ_OFS_DELTA) {
+ if (type == OBJ_OFS_DELTA) {
off_t ofs = entry->idx.offset - entry->delta->idx.offset;
unsigned pos = sizeof(dheader) - 1;
dheader[pos] = ofs & 127;
@@ -527,7 +383,7 @@ static unsigned long write_object(struct sha1file *f,
sha1write(f, header, hdrlen);
sha1write(f, dheader + pos, sizeof(dheader) - pos);
hdrlen += sizeof(dheader) - pos;
- } else if (obj_type == OBJ_REF_DELTA) {
+ } else if (type == OBJ_REF_DELTA) {
if (limit && hdrlen + 20 + datalen + 20 >= limit)
return 0;
sha1write(f, header, hdrlen);
@@ -594,10 +450,10 @@ static void write_pack_file(void)
struct sha1file *f;
off_t offset, offset_one, last_obj_offset = 0;
struct pack_header hdr;
- int do_progress = progress >> pack_to_stdout;
uint32_t nr_remaining = nr_result;
+ time_t last_mtime = 0;
- if (do_progress)
+ if (progress > pack_to_stdout)
progress_state = start_progress("Writing objects", nr_result);
written_list = xmalloc(nr_objects * sizeof(*written_list));
@@ -636,16 +492,20 @@ static void write_pack_file(void)
* Did we write the wrong # entries in the header?
* If so, rewrite it like in fast-import
*/
- if (pack_to_stdout || nr_written == nr_remaining) {
- sha1close(f, sha1, 1);
+ if (pack_to_stdout) {
+ sha1close(f, sha1, CSUM_CLOSE);
+ } else if (nr_written == nr_remaining) {
+ sha1close(f, sha1, CSUM_FSYNC);
} else {
int fd = sha1close(f, NULL, 0);
fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
+ fsync_or_die(fd, pack_tmp_name);
close(fd);
}
if (!pack_to_stdout) {
mode_t mode = umask(0);
+ struct stat st;
char *idx_tmp_name, tmpname[PATH_MAX];
umask(mode);
@@ -653,6 +513,7 @@ static void write_pack_file(void)
idx_tmp_name = write_idx_file(NULL, written_list,
nr_written, sha1);
+
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
base_name, sha1_to_hex(sha1));
if (adjust_perm(pack_tmp_name, mode))
@@ -661,6 +522,28 @@ static void write_pack_file(void)
if (rename(pack_tmp_name, tmpname))
die("unable to rename temporary pack file: %s",
strerror(errno));
+
+ /*
+ * Packs are runtime accessed in their mtime
+ * order since newer packs are more likely to contain
+ * younger objects. So if we are creating multiple
+ * packs then we should modify the mtime of later ones
+ * to preserve this property.
+ */
+ if (stat(tmpname, &st) < 0) {
+ warning("failed to stat %s: %s",
+ tmpname, strerror(errno));
+ } else if (!last_mtime) {
+ last_mtime = st.st_mtime;
+ } else {
+ struct utimbuf utb;
+ utb.actime = st.st_atime;
+ utb.modtime = --last_mtime;
+ if (utime(tmpname, &utb) < 0)
+ warning("failed utime() on %s: %s",
+ tmpname, strerror(errno));
+ }
+
snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
base_name, sha1_to_hex(sha1));
if (adjust_perm(idx_tmp_name, mode))
@@ -669,6 +552,7 @@ static void write_pack_file(void)
if (rename(idx_tmp_name, tmpname))
die("unable to rename temporary index file: %s",
strerror(errno));
+
free(idx_tmp_name);
free(pack_tmp_name);
puts(sha1_to_hex(sha1));
@@ -684,7 +568,8 @@ static void write_pack_file(void)
free(written_list);
stop_progress(&progress_state);
if (written != nr_result)
- die("wrote %u objects while expecting %u", written, nr_result);
+ die("wrote %"PRIu32" objects while expecting %"PRIu32,
+ written, nr_result);
/*
* We have scanned through [0 ... i). Since we have written
* the correct number of objects, the remaining [i ... nr_objects)
@@ -696,7 +581,8 @@ static void write_pack_file(void)
j += !e->idx.offset && !e->preferred_base;
}
if (j)
- die("wrote %u objects as expected but %u unwritten", written, j);
+ die("wrote %"PRIu32" objects as expected but %"PRIu32
+ " unwritten", written, j);
}
static int locate_object_entry_hash(const unsigned char *sha1)
@@ -1138,7 +1024,7 @@ static void check_object(struct object_entry *entry)
unuse_pack(&w_curs);
return;
case OBJ_REF_DELTA:
- if (!no_reuse_delta && !entry->preferred_base)
+ if (reuse_delta && !entry->preferred_base)
base_ref = use_pack(p, &w_curs,
entry->in_pack_offset + used, NULL);
entry->in_pack_header_size = used + 20;
@@ -1161,8 +1047,11 @@ static void check_object(struct object_entry *entry)
die("delta base offset out of bound for %s",
sha1_to_hex(entry->idx.sha1));
ofs = entry->in_pack_offset - ofs;
- if (!no_reuse_delta && !entry->preferred_base)
- base_ref = find_packed_object_name(p, ofs);
+ if (reuse_delta && !entry->preferred_base) {
+ struct revindex_entry *revidx;
+ revidx = find_pack_revindex(p, ofs);
+ base_ref = nth_packed_object_sha1(p, revidx->nr);
+ }
entry->in_pack_header_size = used + used_0;
break;
}
@@ -1239,9 +1128,9 @@ static void get_object_details(void)
sorted_by_offset[i] = objects + i;
qsort(sorted_by_offset, nr_objects, sizeof(*sorted_by_offset), pack_offset_sort);
- prepare_pack_ix();
for (i = 0; i < nr_objects; i++)
check_object(sorted_by_offset[i]);
+
free(sorted_by_offset);
}
@@ -1344,7 +1233,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
* We do not bother to try a delta that we discarded
* on an earlier try, but only when reusing delta data.
*/
- if (!no_reuse_delta && trg_entry->in_pack &&
+ if (reuse_delta && trg_entry->in_pack &&
trg_entry->in_pack == src_entry->in_pack &&
trg_entry->in_pack_type != OBJ_REF_DELTA &&
trg_entry->in_pack_type != OBJ_OFS_DELTA)
@@ -1428,8 +1317,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
* accounting lock. Compiler will optimize the strangeness
* away when THREADED_DELTA_SEARCH is not defined.
*/
- if (trg_entry->delta_data)
- free(trg_entry->delta_data);
+ free(trg_entry->delta_data);
cache_lock();
if (trg_entry->delta_data) {
delta_cache_size -= trg_entry->delta_size;
@@ -1553,11 +1441,34 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
best_base = other_idx;
}
+ /*
+ * If we decided to cache the delta data, then it is best
+ * to compress it right away. First because we have to do
+ * it anyway, and doing it here while we're threaded will
+ * save a lot of time in the non threaded write phase,
+ * as well as allow for caching more deltas within
+ * the same cache size limit.
+ * ...
+ * But only if not writing to stdout, since in that case
+ * the network is most likely throttling writes anyway,
+ * and therefore it is best to go to the write phase ASAP
+ * instead, as we can afford spending more time compressing
+ * between writes at that moment.
+ */
+ if (entry->delta_data && !pack_to_stdout) {
+ entry->z_delta_size = do_compress(&entry->delta_data,
+ entry->delta_size);
+ cache_lock();
+ delta_cache_size -= entry->delta_size;
+ delta_cache_size += entry->z_delta_size;
+ cache_unlock();
+ }
+
/* if we made n a delta, and if n is already at max
* depth, leaving it in the window is pointless. we
* should evict it first.
*/
- if (entry->delta && depth <= n->depth)
+ if (entry->delta && max_depth <= n->depth)
continue;
/*
@@ -1672,7 +1583,8 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
p[i].data_ready = 0;
/* try to split chunks on "path" boundaries */
- while (sub_size < list_size && list[sub_size]->hash &&
+ while (sub_size && sub_size < list_size &&
+ list[sub_size]->hash &&
list[sub_size]->hash == list[sub_size-1]->hash)
sub_size++;
@@ -1769,10 +1681,23 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
#define ll_find_deltas(l, s, w, d, p) find_deltas(l, &s, w, d, p)
#endif
+static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+{
+ unsigned char peeled[20];
+
+ if (!prefixcmp(path, "refs/tags/") && /* is a tag? */
+ !peel_ref(path, peeled) && /* peelable? */
+ !is_null_sha1(peeled) && /* annotated tag? */
+ locate_object_entry(peeled)) /* object packed? */
+ add_object_entry(sha1, OBJ_TAG, NULL, 0);
+ return 0;
+}
+
static void prepare_pack(int window, int depth)
{
struct object_entry **delta_list;
- uint32_t i, n, nr_deltas;
+ uint32_t i, nr_deltas;
+ unsigned n;
get_object_details();
@@ -1787,7 +1712,7 @@ static void prepare_pack(int window, int depth)
if (entry->delta)
/* This happens if we decided to reuse existing
- * delta from a pack. "!no_reuse_delta &&" is implied.
+ * delta from a pack. "reuse_delta &&" is implied.
*/
continue;
@@ -1817,7 +1742,7 @@ static void prepare_pack(int window, int depth)
free(delta_list);
}
-static int git_pack_config(const char *k, const char *v)
+static int git_pack_config(const char *k, const char *v, void *cb)
{
if(!strcmp(k, "pack.window")) {
window = git_config_int(k, v);
@@ -1851,11 +1776,11 @@ static int git_pack_config(const char *k, const char *v)
}
if (!strcmp(k, "pack.threads")) {
delta_search_threads = git_config_int(k, v);
- if (delta_search_threads < 1)
+ if (delta_search_threads < 0)
die("invalid number of threads specified (%d)",
delta_search_threads);
#ifndef THREADED_DELTA_SEARCH
- if (delta_search_threads > 1)
+ if (delta_search_threads != 1)
warning("no threads support, ignoring %s", k);
#endif
return 0;
@@ -1863,10 +1788,15 @@ static int git_pack_config(const char *k, const char *v)
if (!strcmp(k, "pack.indexversion")) {
pack_idx_default_version = git_config_int(k, v);
if (pack_idx_default_version > 2)
- die("bad pack.indexversion=%d", pack_idx_default_version);
+ die("bad pack.indexversion=%"PRIu32,
+ pack_idx_default_version);
return 0;
}
- return git_default_config(k, v);
+ if (!strcmp(k, "pack.packsizelimit")) {
+ pack_size_limit_cfg = git_config_ulong(k, v);
+ return 0;
+ }
+ return git_default_config(k, v, cb);
}
static void read_object_list_from_stdin(void)
@@ -2000,6 +1930,32 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
free(in_pack.array);
}
+static void loosen_unused_packed_objects(struct rev_info *revs)
+{
+ struct packed_git *p;
+ uint32_t i;
+ const unsigned char *sha1;
+
+ for (p = packed_git; p; p = p->next) {
+ for (i = 0; i < revs->num_ignore_packed; i++) {
+ if (matches_pack_name(p, revs->ignore_packed[i]))
+ break;
+ }
+ if (revs->num_ignore_packed <= i)
+ continue;
+
+ if (open_pack_index(p))
+ die("cannot open pack index");
+
+ for (i = 0; i < p->num_objects; i++) {
+ sha1 = nth_packed_object_sha1(p, i);
+ if (!locate_object_entry(sha1))
+ if (force_object_loose(sha1, p->mtime))
+ die("unable to force loose object");
+ }
+ }
+}
+
static void get_object_list(int ac, const char **av)
{
struct rev_info revs;
@@ -2008,7 +1964,6 @@ static void get_object_list(int ac, const char **av)
init_revisions(&revs, NULL);
save_commit_buffer = 0;
- track_object_refs = 0;
setup_revisions(ac, av, &revs, NULL);
while (fgets(line, sizeof(line), stdin) != NULL) {
@@ -2028,12 +1983,15 @@ static void get_object_list(int ac, const char **av)
die("bad revision '%s'", line);
}
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
mark_edges_uninteresting(revs.commits, &revs, show_edge);
traverse_commit_list(&revs, show_commit, show_object);
if (keep_unreachable)
add_objects_in_unpacked_packs(&revs);
+ if (unpack_unreachable)
+ loosen_unused_packed_objects(&revs);
}
static int adjust_perm(const char *path, mode_t mode)
@@ -2058,7 +2016,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
rp_av[1] = "--objects"; /* --thin will make it --objects-edge */
rp_ac = 2;
- git_config(git_pack_config);
+ git_config(git_pack_config, NULL);
if (!pack_compression_seen && core_compression_seen)
pack_compression_level = core_compression_level;
@@ -2095,6 +2053,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
}
if (!prefixcmp(arg, "--max-pack-size=")) {
char *end;
+ pack_size_limit_cfg = 0;
pack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;
if (!arg[16] || *end)
usage(pack_usage);
@@ -2115,10 +2074,10 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (!prefixcmp(arg, "--threads=")) {
char *end;
delta_search_threads = strtoul(arg+10, &end, 0);
- if (!arg[10] || *end || delta_search_threads < 1)
+ if (!arg[10] || *end || delta_search_threads < 0)
usage(pack_usage);
#ifndef THREADED_DELTA_SEARCH
- if (delta_search_threads > 1)
+ if (delta_search_threads != 1)
warning("no threads support, "
"ignoring %s", arg);
#endif
@@ -2144,11 +2103,11 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp("--no-reuse-delta", arg)) {
- no_reuse_delta = 1;
+ reuse_delta = 0;
continue;
}
if (!strcmp("--no-reuse-object", arg)) {
- no_reuse_object = no_reuse_delta = 1;
+ reuse_object = reuse_delta = 0;
continue;
}
if (!strcmp("--delta-base-offset", arg)) {
@@ -2167,6 +2126,14 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
keep_unreachable = 1;
continue;
}
+ if (!strcmp("--unpack-unreachable", arg)) {
+ unpack_unreachable = 1;
+ continue;
+ }
+ if (!strcmp("--include-tag", arg)) {
+ include_tag = 1;
+ continue;
+ }
if (!strcmp("--unpacked", arg) ||
!prefixcmp(arg, "--unpacked=") ||
!strcmp("--reflog", arg) ||
@@ -2219,12 +2186,23 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
if (pack_to_stdout != !base_name)
usage(pack_usage);
+ if (!pack_to_stdout && !pack_size_limit)
+ pack_size_limit = pack_size_limit_cfg;
+
if (pack_to_stdout && pack_size_limit)
die("--max-pack-size cannot be used to build a pack for transfer.");
if (!pack_to_stdout && thin)
die("--thin cannot be used to build an indexable pack.");
+ if (keep_unreachable && unpack_unreachable)
+ die("--keep-unreachable and --unpack-unreachable are incompatible.");
+
+#ifdef THREADED_DELTA_SEARCH
+ if (!delta_search_threads) /* --threads=0 means autodetect */
+ delta_search_threads = online_cpus();
+#endif
+
prepare_packed_git();
if (progress)
@@ -2235,6 +2213,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
rp_av[rp_ac] = NULL;
get_object_list(rp_ac, rp_av);
}
+ if (include_tag && nr_result)
+ for_each_ref(add_ref_tag, NULL);
stop_progress(&progress_state);
if (non_empty && !nr_result)
@@ -2243,7 +2223,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
prepare_pack(window, depth);
write_pack_file();
if (progress)
- fprintf(stderr, "Total %u (delta %u), reused %u (delta %u)\n",
+ fprintf(stderr, "Total %"PRIu32" (delta %"PRIu32"),"
+ " reused %"PRIu32" (delta %"PRIu32")\n",
written, written_delta, reused, reused_delta);
return 0;
}
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 1aaa76dd1..34246df4e 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -1,128 +1,9 @@
-#include "builtin.h"
#include "cache.h"
-#include "refs.h"
-#include "object.h"
-#include "tag.h"
#include "parse-options.h"
-
-struct ref_to_prune {
- struct ref_to_prune *next;
- unsigned char sha1[20];
- char name[FLEX_ARRAY];
-};
-
-#define PACK_REFS_PRUNE 0x0001
-#define PACK_REFS_ALL 0x0002
-
-struct pack_refs_cb_data {
- unsigned int flags;
- struct ref_to_prune *ref_to_prune;
- FILE *refs_file;
-};
-
-static int do_not_prune(int flags)
-{
- /* If it is already packed or if it is a symref,
- * do not prune it.
- */
- return (flags & (REF_ISSYMREF|REF_ISPACKED));
-}
-
-static int handle_one_ref(const char *path, const unsigned char *sha1,
- int flags, void *cb_data)
-{
- struct pack_refs_cb_data *cb = cb_data;
- int is_tag_ref;
-
- /* Do not pack the symbolic refs */
- if ((flags & REF_ISSYMREF))
- return 0;
- is_tag_ref = !prefixcmp(path, "refs/tags/");
-
- /* ALWAYS pack refs that were already packed or are tags */
- if (!(cb->flags & PACK_REFS_ALL) && !is_tag_ref && !(flags & REF_ISPACKED))
- return 0;
-
- fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
- if (is_tag_ref) {
- struct object *o = parse_object(sha1);
- if (o->type == OBJ_TAG) {
- o = deref_tag(o, path, 0);
- if (o)
- fprintf(cb->refs_file, "^%s\n",
- sha1_to_hex(o->sha1));
- }
- }
-
- if ((cb->flags & PACK_REFS_PRUNE) && !do_not_prune(flags)) {
- int namelen = strlen(path) + 1;
- struct ref_to_prune *n = xcalloc(1, sizeof(*n) + namelen);
- hashcpy(n->sha1, sha1);
- strcpy(n->name, path);
- n->next = cb->ref_to_prune;
- cb->ref_to_prune = n;
- }
- return 0;
-}
-
-/* make sure nobody touched the ref, and unlink */
-static void prune_ref(struct ref_to_prune *r)
-{
- struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
-
- if (lock) {
- unlink(git_path("%s", r->name));
- unlock_ref(lock);
- }
-}
-
-static void prune_refs(struct ref_to_prune *r)
-{
- while (r) {
- prune_ref(r);
- r = r->next;
- }
-}
-
-static struct lock_file packed;
-
-static int pack_refs(unsigned int flags)
-{
- int fd;
- struct pack_refs_cb_data cbdata;
-
- memset(&cbdata, 0, sizeof(cbdata));
- cbdata.flags = flags;
-
- fd = hold_lock_file_for_update(&packed, git_path("packed-refs"), 1);
- cbdata.refs_file = fdopen(fd, "w");
- if (!cbdata.refs_file)
- die("unable to create ref-pack file structure (%s)",
- strerror(errno));
-
- /* perhaps other traits later as well */
- fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");
-
- for_each_ref(handle_one_ref, &cbdata);
- if (ferror(cbdata.refs_file))
- die("failed to write ref-pack file");
- if (fflush(cbdata.refs_file) || fsync(fd) || fclose(cbdata.refs_file))
- die("failed to write ref-pack file (%s)", strerror(errno));
- /*
- * Since the lock file was fdopen()'ed and then fclose()'ed above,
- * assign -1 to the lock file descriptor so that commit_lock_file()
- * won't try to close() it.
- */
- packed.fd = -1;
- if (commit_lock_file(&packed) < 0)
- die("unable to overwrite old ref-pack file (%s)", strerror(errno));
- if (cbdata.flags & PACK_REFS_PRUNE)
- prune_refs(cbdata.ref_to_prune);
- return 0;
-}
+#include "pack-refs.h"
static char const * const pack_refs_usage[] = {
- "git-pack-refs [options]",
+ "git pack-refs [options]",
NULL
};
diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c
index 23faf3129..10cb8df84 100644
--- a/builtin-prune-packed.c
+++ b/builtin-prune-packed.c
@@ -3,7 +3,7 @@
#include "progress.h"
static const char prune_packed_usage[] =
-"git-prune-packed [-n] [-q]";
+"git prune-packed [-n] [-q]";
#define DRY_RUN 01
#define VERBOSE 02
@@ -85,7 +85,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
/* Handle arguments here .. */
usage(prune_packed_usage);
}
- sync();
prune_packed_objects(opts);
return 0;
}
diff --git a/builtin-prune.c b/builtin-prune.c
index b5e768421..c767a0ac8 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -4,11 +4,31 @@
#include "revision.h"
#include "builtin.h"
#include "reachable.h"
+#include "parse-options.h"
-static const char prune_usage[] = "git-prune [-n]";
+static const char * const prune_usage[] = {
+ "git prune [-n] [--expire <time>] [--] [<head>...]",
+ NULL
+};
static int show_only;
static unsigned long expire;
+static int prune_tmp_object(char *path, const char *filename)
+{
+ const char *fullpath = mkpath("%s/%s", path, filename);
+ if (expire) {
+ struct stat st;
+ if (lstat(fullpath, &st))
+ return error("Could not stat '%s'", fullpath);
+ if (st.st_mtime > expire)
+ return 0;
+ }
+ printf("Removing stale temporary file %s\n", fullpath);
+ if (!show_only)
+ unlink(fullpath);
+ return 0;
+}
+
static int prune_object(char *path, const char *filename, const unsigned char *sha1)
{
const char *fullpath = mkpath("%s/%s", path, filename);
@@ -65,6 +85,10 @@ static int prune_dir(int i, char *path)
prune_object(path, de->d_name, sha1);
continue;
}
+ if (!prefixcmp(de->d_name, "tmp_obj_")) {
+ prune_tmp_object(path, de->d_name);
+ continue;
+ }
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
}
if (!show_only)
@@ -83,37 +107,62 @@ static void prune_object_dir(const char *path)
}
}
-int cmd_prune(int argc, const char **argv, const char *prefix)
+/*
+ * Write errors (particularly out of space) can result in
+ * failed temporary packs (and more rarely indexes and other
+ * files begining with "tmp_") accumulating in the
+ * object directory.
+ */
+static void remove_temporary_files(void)
{
- int i;
- struct rev_info revs;
+ DIR *dir;
+ struct dirent *de;
+ char* dirname=get_object_directory();
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
- if (!strcmp(arg, "-n")) {
- show_only = 1;
- continue;
- }
- if (!strcmp(arg, "--expire")) {
- if (++i < argc) {
- expire = approxidate(argv[i]);
- continue;
- }
- }
- else if (!prefixcmp(arg, "--expire=")) {
- expire = approxidate(arg + 9);
- continue;
- }
- usage(prune_usage);
+ dir = opendir(dirname);
+ if (!dir) {
+ fprintf(stderr, "Unable to open object directory %s\n",
+ dirname);
+ return;
}
+ while ((de = readdir(dir)) != NULL)
+ if (!prefixcmp(de->d_name, "tmp_"))
+ prune_tmp_object(dirname, de->d_name);
+ closedir(dir);
+}
+
+int cmd_prune(int argc, const char **argv, const char *prefix)
+{
+ struct rev_info revs;
+ const struct option options[] = {
+ OPT_BOOLEAN('n', NULL, &show_only,
+ "do not remove, show only"),
+ OPT_DATE(0, "expire", &expire,
+ "expire objects older than <time>"),
+ OPT_END()
+ };
save_commit_buffer = 0;
init_revisions(&revs, prefix);
- mark_reachable_objects(&revs, 1);
+ argc = parse_options(argc, argv, options, prune_usage, 0);
+ while (argc--) {
+ unsigned char sha1[20];
+ const char *name = *argv++;
+
+ if (!get_sha1(name, sha1)) {
+ struct object *object = parse_object(sha1);
+ if (!object)
+ die("bad object: %s", name);
+ add_pending_object(&revs, object, "");
+ }
+ else
+ die("unrecognized argument: %s", name);
+ }
+ mark_reachable_objects(&revs, 1);
prune_object_dir(get_object_directory());
- sync();
prune_packed_objects(show_only);
+ remove_temporary_files();
return 0;
}
diff --git a/builtin-push.c b/builtin-push.c
index c8cb63e23..c1ed68d93 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,11 +10,11 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git-push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
-static int thin, verbose;
+static int thin;
static const char *receivepack;
static const char **refspec;
@@ -44,15 +44,6 @@ static void set_refspecs(const char **refs, int nr)
strcat(tag, refs[i]);
ref = tag;
}
- if (!strcmp("HEAD", ref)) {
- unsigned char sha1_dummy[20];
- ref = resolve_ref(ref, sha1_dummy, 1, NULL);
- if (!ref)
- die("HEAD cannot be resolved.");
- if (prefixcmp(ref, "refs/heads/"))
- die("HEAD cannot be resolved to branch.");
- ref = xstrdup(ref + 11);
- }
add_refspec(ref);
}
}
@@ -65,6 +56,17 @@ static int do_push(const char *repo, int flags)
if (!remote)
die("bad repository '%s'", repo);
+ if (remote->mirror)
+ flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
+ return -1;
+
+ if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
+ (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
+ return error("--all and --mirror are incompatible");
+ }
+
if (!refspec
&& !(flags & TRANSPORT_PUSH_ALL)
&& remote->push_refspec_nr) {
@@ -82,7 +84,7 @@ static int do_push(const char *repo, int flags)
if (thin)
transport_set_option(transport, TRANS_OPT_THIN, "yes");
- if (verbose)
+ if (flags & TRANSPORT_PUSH_VERBOSE)
fprintf(stderr, "Pushing to %s\n", remote->url[i]);
err = transport_push(transport, refspec_nr, refspec, flags);
err |= transport_disconnect(transport);
@@ -90,7 +92,7 @@ static int do_push(const char *repo, int flags)
if (!err)
continue;
- error("failed to push to '%s'", remote->url[i]);
+ error("failed to push some refs to '%s'", remote->url[i]);
errs++;
}
return !!errs;
@@ -99,21 +101,19 @@ static int do_push(const char *repo, int flags)
int cmd_push(int argc, const char **argv, const char *prefix)
{
int flags = 0;
- int all = 0;
- int mirror = 0;
- int dry_run = 0;
- int force = 0;
int tags = 0;
+ int rc;
const char *repo = NULL; /* default repository */
struct option options[] = {
- OPT__VERBOSE(&verbose),
+ OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
- OPT_BOOLEAN( 0 , "all", &all, "push all refs"),
- OPT_BOOLEAN( 0 , "mirror", &mirror, "mirror all refs"),
+ OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
+ OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
+ (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
- OPT_BOOLEAN( 0 , "dry-run", &dry_run, "dry run"),
- OPT_BOOLEAN('f', "force", &force, "force updates"),
+ OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
+ OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
OPT_STRING( 0 , "receive-pack", &receivepack, "receive-pack", "receive pack program"),
OPT_STRING( 0 , "exec", &receivepack, "receive-pack", "receive pack program"),
@@ -122,31 +122,17 @@ int cmd_push(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, options, push_usage, 0);
- if (force)
- flags |= TRANSPORT_PUSH_FORCE;
- if (dry_run)
- flags |= TRANSPORT_PUSH_DRY_RUN;
- if (verbose)
- flags |= TRANSPORT_PUSH_VERBOSE;
if (tags)
add_refspec("refs/tags/*");
- if (all)
- flags |= TRANSPORT_PUSH_ALL;
- if (mirror)
- flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
if (argc > 0) {
repo = argv[0];
set_refspecs(argv + 1, argc - 1);
}
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) && refspec)
- usage_with_options(push_usage, options);
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
- (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
- error("--all and --mirror are incompatible");
+ rc = do_push(repo, flags);
+ if (rc == -1)
usage_with_options(push_usage, options);
- }
-
- return do_push(repo, flags);
+ else
+ return rc;
}
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 1d9d125b9..72a6de302 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -13,16 +13,15 @@
#include "dir.h"
#include "builtin.h"
-#define MAX_TREES 8
static int nr_trees;
-static struct tree *trees[MAX_TREES];
+static struct tree *trees[MAX_UNPACK_TREES];
static int list_tree(unsigned char *sha1)
{
struct tree *tree;
- if (nr_trees >= MAX_TREES)
- die("I cannot read more than %d trees", MAX_TREES);
+ if (nr_trees >= MAX_UNPACK_TREES)
+ die("I cannot read more than %d trees", MAX_UNPACK_TREES);
tree = parse_tree_indirect(sha1);
if (!tree)
return -1;
@@ -30,29 +29,6 @@ static int list_tree(unsigned char *sha1)
return 0;
}
-static int read_cache_unmerged(void)
-{
- int i;
- struct cache_entry **dst;
- struct cache_entry *last = NULL;
-
- read_cache();
- dst = active_cache;
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce)) {
- if (last && !strcmp(ce->name, last->name))
- continue;
- cache_tree_invalidate_path(active_cache_tree, ce->name);
- last = ce;
- ce->ce_flags |= CE_REMOVE;
- }
- *dst++ = ce;
- }
- active_nr = dst - active_cache;
- return !!last;
-}
-
static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree)
{
struct tree_desc desc;
@@ -96,18 +72,18 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{
int i, newfd, stage = 0;
unsigned char sha1[20];
- struct tree_desc t[MAX_TREES];
+ struct tree_desc t[MAX_UNPACK_TREES];
struct unpack_trees_options opts;
memset(&opts, 0, sizeof(opts));
opts.head_idx = -1;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
newfd = hold_locked_index(&lock_file, 1);
- git_config(git_default_config);
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -219,27 +195,6 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
if ((opts.dir && !opts.update))
die("--exclude-per-directory is meaningless unless -u");
- if (opts.prefix) {
- int pfxlen = strlen(opts.prefix);
- int pos;
- if (opts.prefix[pfxlen-1] != '/')
- die("prefix must end with /");
- if (stage != 2)
- die("binding merge takes only one tree");
- pos = cache_name_pos(opts.prefix, pfxlen);
- if (0 <= pos)
- die("corrupt index file");
- pos = -pos-1;
- if (pos < active_nr &&
- !strncmp(active_cache[pos]->name, opts.prefix, pfxlen))
- die("subdirectory '%s' already exists.", opts.prefix);
- pos = cache_name_pos(opts.prefix, pfxlen-1);
- if (0 <= pos)
- die("file '%.*s' already exists.",
- pfxlen-1, opts.prefix);
- opts.pos = -1 - pos;
- }
-
if (opts.merge) {
if (stage < 2)
die("just how do you expect me to merge %d trees?", stage-1);
diff --git a/builtin-reflog.c b/builtin-reflog.c
index ce093cad7..196fa03b7 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -13,7 +13,9 @@
*/
static const char reflog_expire_usage[] =
-"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+static const char reflog_delete_usage[] =
+"git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...";
static unsigned long default_reflog_expire;
static unsigned long default_reflog_expire_unreachable;
@@ -22,9 +24,12 @@ struct cmd_reflog_expire_cb {
struct rev_info revs;
int dry_run;
int stalefix;
+ int rewrite;
+ int updateref;
int verbose;
unsigned long expire_total;
unsigned long expire_unreachable;
+ int recno;
};
struct expire_reflog_cb {
@@ -32,6 +37,17 @@ struct expire_reflog_cb {
const char *ref;
struct commit *ref_commit;
struct cmd_reflog_expire_cb *cmd;
+ unsigned char last_kept_sha1[20];
+};
+
+struct collected_reflog {
+ unsigned char sha1[20];
+ char reflog[FLEX_ARRAY];
+};
+struct collect_reflog_cb {
+ struct collected_reflog **e;
+ int alloc;
+ int nr;
};
#define INCOMPLETE (1u<<10)
@@ -203,6 +219,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
if (timestamp < cb->cmd->expire_total)
goto prune;
+ if (cb->cmd->rewrite)
+ osha1 = cb->last_kept_sha1;
+
old = new = NULL;
if (cb->cmd->stalefix &&
(!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
@@ -220,6 +239,9 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
goto prune;
}
+ if (cb->cmd->recno && --(cb->cmd->recno) == 0)
+ goto prune;
+
if (cb->newlog) {
char sign = (tz < 0) ? '-' : '+';
int zone = (tz < 0) ? (-tz) : tz;
@@ -227,6 +249,7 @@ static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
sha1_to_hex(osha1), sha1_to_hex(nsha1),
email, timestamp, sign, zone,
message);
+ hashcpy(cb->last_kept_sha1, nsha1);
}
if (cb->cmd->verbose)
printf("keep %s", message);
@@ -246,7 +269,9 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
int status = 0;
memset(&cb, 0, sizeof(cb));
- /* we take the lock for the ref itself to prevent it from
+
+ /*
+ * we take the lock for the ref itself to prevent it from
* getting updated.
*/
lock = lock_any_ref_for_update(ref, sha1, 0);
@@ -266,13 +291,26 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
for_each_reflog_ent(ref, expire_reflog_ent, &cb);
finish:
if (cb.newlog) {
- if (fclose(cb.newlog))
+ if (fclose(cb.newlog)) {
status |= error("%s: %s", strerror(errno),
newlog_path);
- if (rename(newlog_path, log_file)) {
+ unlink(newlog_path);
+ } else if (cmd->updateref &&
+ (write_in_full(lock->lock_fd,
+ sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
+ write_in_full(lock->lock_fd, "\n", 1) != 1 ||
+ close_ref(lock) < 0)) {
+ status |= error("Couldn't write %s",
+ lock->lk->filename);
+ unlink(newlog_path);
+ } else if (rename(newlog_path, log_file)) {
status |= error("cannot rename %s to %s",
newlog_path, log_file);
unlink(newlog_path);
+ } else if (cmd->updateref && commit_ref(lock)) {
+ status |= error("Couldn't set %s", lock->ref_name);
+ } else {
+ adjust_shared_perm(log_file);
}
}
free(newlog_path);
@@ -281,24 +319,154 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
return status;
}
-static int reflog_expire_config(const char *var, const char *value)
+static int collect_reflog(const char *ref, const unsigned char *sha1, int unused, void *cb_data)
+{
+ struct collected_reflog *e;
+ struct collect_reflog_cb *cb = cb_data;
+ size_t namelen = strlen(ref);
+
+ e = xmalloc(sizeof(*e) + namelen + 1);
+ hashcpy(e->sha1, sha1);
+ memcpy(e->reflog, ref, namelen + 1);
+ ALLOC_GROW(cb->e, cb->nr + 1, cb->alloc);
+ cb->e[cb->nr++] = e;
+ return 0;
+}
+
+static struct reflog_expire_cfg {
+ struct reflog_expire_cfg *next;
+ unsigned long expire_total;
+ unsigned long expire_unreachable;
+ size_t len;
+ char pattern[FLEX_ARRAY];
+} *reflog_expire_cfg, **reflog_expire_cfg_tail;
+
+static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
+{
+ struct reflog_expire_cfg *ent;
+
+ if (!reflog_expire_cfg_tail)
+ reflog_expire_cfg_tail = &reflog_expire_cfg;
+
+ for (ent = reflog_expire_cfg; ent; ent = ent->next)
+ if (ent->len == len &&
+ !memcmp(ent->pattern, pattern, len))
+ return ent;
+
+ ent = xcalloc(1, (sizeof(*ent) + len));
+ memcpy(ent->pattern, pattern, len);
+ ent->len = len;
+ *reflog_expire_cfg_tail = ent;
+ reflog_expire_cfg_tail = &(ent->next);
+ return ent;
+}
+
+static int parse_expire_cfg_value(const char *var, const char *value, unsigned long *expire)
+{
+ if (!value)
+ return config_error_nonbool(var);
+ if (!strcmp(value, "never") || !strcmp(value, "false")) {
+ *expire = 0;
+ return 0;
+ }
+ *expire = approxidate(value);
+ return 0;
+}
+
+/* expiry timer slot */
+#define EXPIRE_TOTAL 01
+#define EXPIRE_UNREACH 02
+
+static int reflog_expire_config(const char *var, const char *value, void *cb)
{
- if (!strcmp(var, "gc.reflogexpire"))
- default_reflog_expire = approxidate(value);
- else if (!strcmp(var, "gc.reflogexpireunreachable"))
- default_reflog_expire_unreachable = approxidate(value);
- else
- return git_default_config(var, value);
+ const char *lastdot = strrchr(var, '.');
+ unsigned long expire;
+ int slot;
+ struct reflog_expire_cfg *ent;
+
+ if (!lastdot || prefixcmp(var, "gc."))
+ return git_default_config(var, value, cb);
+
+ if (!strcmp(lastdot, ".reflogexpire")) {
+ slot = EXPIRE_TOTAL;
+ if (parse_expire_cfg_value(var, value, &expire))
+ return -1;
+ } else if (!strcmp(lastdot, ".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) {
+ switch (slot) {
+ case EXPIRE_TOTAL:
+ default_reflog_expire = expire;
+ break;
+ case EXPIRE_UNREACH:
+ default_reflog_expire_unreachable = expire;
+ break;
+ }
+ return 0;
+ }
+
+ ent = find_cfg_ent(var + 3, lastdot - (var+3));
+ if (!ent)
+ return -1;
+ switch (slot) {
+ case EXPIRE_TOTAL:
+ ent->expire_total = expire;
+ break;
+ case EXPIRE_UNREACH:
+ ent->expire_unreachable = expire;
+ break;
+ }
return 0;
}
+static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, const char *ref)
+{
+ struct reflog_expire_cfg *ent;
+
+ if (slot == (EXPIRE_TOTAL|EXPIRE_UNREACH))
+ return; /* both given explicitly -- nothing to tweak */
+
+ for (ent = reflog_expire_cfg; ent; ent = ent->next) {
+ if (!fnmatch(ent->pattern, ref, 0)) {
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = ent->expire_total;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = ent->expire_unreachable;
+ return;
+ }
+ }
+
+ /*
+ * If unconfigured, make stash never expire
+ */
+ if (!strcmp(ref, "refs/stash")) {
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = 0;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = 0;
+ return;
+ }
+
+ /* Nothing matched -- use the default value */
+ if (!(slot & EXPIRE_TOTAL))
+ cb->expire_total = default_reflog_expire;
+ if (!(slot & EXPIRE_UNREACH))
+ cb->expire_unreachable = default_reflog_expire_unreachable;
+}
+
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
{
struct cmd_reflog_expire_cb cb;
unsigned long now = time(NULL);
int i, status, do_all;
+ int explicit_expiry = 0;
- git_config(reflog_expire_config);
+ git_config(reflog_expire_config, NULL);
save_commit_buffer = 0;
do_all = status = 0;
@@ -311,22 +479,24 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
cb.expire_total = default_reflog_expire;
cb.expire_unreachable = default_reflog_expire_unreachable;
- /*
- * We can trust the commits and objects reachable from refs
- * even in older repository. We cannot trust what's reachable
- * from reflog if the repository was pruned with older git.
- */
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
cb.dry_run = 1;
- else if (!prefixcmp(arg, "--expire="))
+ else if (!prefixcmp(arg, "--expire=")) {
cb.expire_total = approxidate(arg + 9);
- else if (!prefixcmp(arg, "--expire-unreachable="))
+ explicit_expiry |= EXPIRE_TOTAL;
+ }
+ else if (!prefixcmp(arg, "--expire-unreachable=")) {
cb.expire_unreachable = approxidate(arg + 21);
+ explicit_expiry |= EXPIRE_UNREACH;
+ }
else if (!strcmp(arg, "--stale-fix"))
cb.stalefix = 1;
+ else if (!strcmp(arg, "--rewrite"))
+ cb.rewrite = 1;
+ else if (!strcmp(arg, "--updateref"))
+ cb.updateref = 1;
else if (!strcmp(arg, "--all"))
do_all = 1;
else if (!strcmp(arg, "--verbose"))
@@ -340,6 +510,12 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
else
break;
}
+
+ /*
+ * We can trust the commits and objects reachable from refs
+ * even in older repository. We cannot trust what's reachable
+ * from reflog if the repository was pruned with older git.
+ */
if (cb.stalefix) {
init_revisions(&cb.revs, prefix);
if (cb.verbose)
@@ -349,8 +525,21 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
putchar('\n');
}
- if (do_all)
- status |= for_each_reflog(expire_reflog, &cb);
+ if (do_all) {
+ struct collect_reflog_cb collected;
+ int i;
+
+ memset(&collected, 0, sizeof(collected));
+ for_each_reflog(collect_reflog, &collected);
+ for (i = 0; i < collected.nr; i++) {
+ struct collected_reflog *e = collected.e[i];
+ set_reflog_expiry_param(&cb, explicit_expiry, e->reflog);
+ status |= expire_reflog(e->reflog, e->sha1, 0, &cb);
+ free(e);
+ }
+ free(collected.e);
+ }
+
while (i < argc) {
const char *ref = argv[i++];
unsigned char sha1[20];
@@ -358,7 +547,80 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
status |= error("%s points nowhere!", ref);
continue;
}
+ set_reflog_expiry_param(&cb, explicit_expiry, ref);
+ status |= expire_reflog(ref, sha1, 0, &cb);
+ }
+ return status;
+}
+
+static int count_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
+{
+ struct cmd_reflog_expire_cb *cb = cb_data;
+ if (!cb->expire_total || timestamp < cb->expire_total)
+ cb->recno++;
+ return 0;
+}
+
+static int cmd_reflog_delete(int argc, const char **argv, const char *prefix)
+{
+ struct cmd_reflog_expire_cb cb;
+ int i, status = 0;
+
+ memset(&cb, 0, sizeof(cb));
+
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+ if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
+ cb.dry_run = 1;
+ else if (!strcmp(arg, "--rewrite"))
+ cb.rewrite = 1;
+ else if (!strcmp(arg, "--updateref"))
+ cb.updateref = 1;
+ else if (!strcmp(arg, "--verbose"))
+ cb.verbose = 1;
+ else if (!strcmp(arg, "--")) {
+ i++;
+ break;
+ }
+ else if (arg[0] == '-')
+ usage(reflog_delete_usage);
+ else
+ break;
+ }
+
+ if (argc - i < 1)
+ return error("Nothing to delete?");
+
+ for ( ; i < argc; i++) {
+ const char *spec = strstr(argv[i], "@{");
+ unsigned char sha1[20];
+ char *ep, *ref;
+ int recno;
+
+ if (!spec) {
+ status |= error("Not a reflog: %s", argv[i]);
+ continue;
+ }
+
+ if (!dwim_log(argv[i], spec - argv[i], sha1, &ref)) {
+ status |= error("no reflog for '%s'", argv[i]);
+ continue;
+ }
+
+ recno = strtoul(spec + 2, &ep, 10);
+ if (*ep == '}') {
+ cb.recno = -recno;
+ for_each_reflog_ent(ref, count_reflog_ent, &cb);
+ } else {
+ cb.expire_total = approxidate(spec + 2);
+ for_each_reflog_ent(ref, count_reflog_ent, &cb);
+ cb.expire_total = 0;
+ }
+
status |= expire_reflog(ref, sha1, 0, &cb);
+ free(ref);
}
return status;
}
@@ -368,7 +630,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
*/
static const char reflog_usage[] =
-"git-reflog (expire | ...)";
+"git reflog (expire | ...)";
int cmd_reflog(int argc, const char **argv, const char *prefix)
{
@@ -382,6 +644,9 @@ int cmd_reflog(int argc, const char **argv, const char *prefix)
if (!strcmp(argv[1], "expire"))
return cmd_reflog_expire(argc - 1, argv + 1, prefix);
+ if (!strcmp(argv[1], "delete"))
+ return cmd_reflog_delete(argc - 1, argv + 1, prefix);
+
/* Not a recognized reflog command..*/
usage(reflog_usage);
}
diff --git a/builtin-remote.c b/builtin-remote.c
new file mode 100644
index 000000000..01945a865
--- /dev/null
+++ b/builtin-remote.c
@@ -0,0 +1,712 @@
+#include "cache.h"
+#include "parse-options.h"
+#include "transport.h"
+#include "remote.h"
+#include "string-list.h"
+#include "strbuf.h"
+#include "run-command.h"
+#include "refs.h"
+
+static const char * const builtin_remote_usage[] = {
+ "git remote",
+ "git remote add <name> <url>",
+ "git remote rm <name>",
+ "git remote show <name>",
+ "git remote prune <name>",
+ "git remote update [group]",
+ NULL
+};
+
+static int verbose;
+
+static int show_all(void);
+
+static inline int postfixcmp(const char *string, const char *postfix)
+{
+ int len1 = strlen(string), len2 = strlen(postfix);
+ if (len1 < len2)
+ return 1;
+ return strcmp(string + len1 - len2, postfix);
+}
+
+static int opt_parse_track(const struct option *opt, const char *arg, int not)
+{
+ struct string_list *list = opt->value;
+ if (not)
+ string_list_clear(list, 0);
+ else
+ string_list_append(arg, list);
+ return 0;
+}
+
+static int fetch_remote(const char *name)
+{
+ const char *argv[] = { "fetch", name, NULL };
+ printf("Updating %s\n", name);
+ if (run_command_v_opt(argv, RUN_GIT_CMD))
+ return error("Could not fetch %s", name);
+ return 0;
+}
+
+static int add(int argc, const char **argv)
+{
+ int fetch = 0, mirror = 0;
+ struct string_list track = { NULL, 0, 0 };
+ const char *master = NULL;
+ struct remote *remote;
+ struct strbuf buf, buf2;
+ const char *name, *url;
+ int i;
+
+ struct option options[] = {
+ OPT_GROUP("add specific options"),
+ OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
+ OPT_CALLBACK('t', "track", &track, "branch",
+ "branch(es) to track", opt_parse_track),
+ OPT_STRING('m', "master", &master, "branch", "master branch"),
+ OPT_BOOLEAN(0, "mirror", &mirror, "no separate remotes"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
+
+ if (argc < 2)
+ usage_with_options(builtin_remote_usage, options);
+
+ name = argv[0];
+ url = argv[1];
+
+ remote = remote_get(name);
+ if (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) ||
+ remote->fetch_refspec_nr))
+ die("remote %s already exists.", name);
+
+ strbuf_init(&buf, 0);
+ strbuf_init(&buf2, 0);
+
+ strbuf_addf(&buf2, "refs/heads/test:refs/remotes/%s/test", name);
+ if (!valid_fetch_refspec(buf2.buf))
+ die("'%s' is not a valid remote name", name);
+
+ strbuf_addf(&buf, "remote.%s.url", name);
+ if (git_config_set(buf.buf, url))
+ return 1;
+
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "remote.%s.fetch", name);
+
+ if (track.nr == 0)
+ string_list_append("*", &track);
+ for (i = 0; i < track.nr; i++) {
+ struct string_list_item *item = track.items + i;
+
+ strbuf_reset(&buf2);
+ strbuf_addch(&buf2, '+');
+ if (mirror)
+ strbuf_addf(&buf2, "refs/%s:refs/%s",
+ item->string, item->string);
+ else
+ strbuf_addf(&buf2, "refs/heads/%s:refs/remotes/%s/%s",
+ item->string, name, item->string);
+ if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
+ return 1;
+ }
+
+ if (mirror) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "remote.%s.mirror", name);
+ if (git_config_set(buf.buf, "true"))
+ return 1;
+ }
+
+ if (fetch && fetch_remote(name))
+ return 1;
+
+ if (master) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "refs/remotes/%s/HEAD", name);
+
+ strbuf_reset(&buf2);
+ strbuf_addf(&buf2, "refs/remotes/%s/%s", name, master);
+
+ if (create_symref(buf.buf, buf2.buf, "remote add"))
+ return error("Could not setup master '%s'", master);
+ }
+
+ strbuf_release(&buf);
+ strbuf_release(&buf2);
+ string_list_clear(&track, 0);
+
+ return 0;
+}
+
+struct branch_info {
+ char *remote;
+ struct string_list merge;
+};
+
+static struct string_list branch_list;
+
+static const char *abbrev_ref(const char *name, const char *prefix)
+{
+ const char *abbrev = skip_prefix(name, prefix);
+ if (abbrev)
+ return abbrev;
+ return name;
+}
+#define abbrev_branch(name) abbrev_ref((name), "refs/heads/")
+
+static int config_read_branches(const char *key, const char *value, void *cb)
+{
+ if (!prefixcmp(key, "branch.")) {
+ char *name;
+ struct string_list_item *item;
+ struct branch_info *info;
+ enum { REMOTE, MERGE } type;
+
+ key += 7;
+ if (!postfixcmp(key, ".remote")) {
+ name = xstrndup(key, strlen(key) - 7);
+ type = REMOTE;
+ } else if (!postfixcmp(key, ".merge")) {
+ name = xstrndup(key, strlen(key) - 6);
+ type = MERGE;
+ } else
+ return 0;
+
+ item = string_list_insert(name, &branch_list);
+
+ if (!item->util)
+ item->util = xcalloc(sizeof(struct branch_info), 1);
+ info = item->util;
+ if (type == REMOTE) {
+ if (info->remote)
+ warning("more than one branch.%s", key);
+ info->remote = xstrdup(value);
+ } else {
+ char *space = strchr(value, ' ');
+ value = abbrev_branch(value);
+ while (space) {
+ char *merge;
+ merge = xstrndup(value, space - value);
+ string_list_append(merge, &info->merge);
+ value = abbrev_branch(space + 1);
+ space = strchr(value, ' ');
+ }
+ string_list_append(xstrdup(value), &info->merge);
+ }
+ }
+ return 0;
+}
+
+static void read_branches(void)
+{
+ if (branch_list.nr)
+ return;
+ git_config(config_read_branches, NULL);
+ sort_string_list(&branch_list);
+}
+
+struct ref_states {
+ struct remote *remote;
+ struct string_list new, stale, tracked;
+};
+
+static int handle_one_branch(const char *refname,
+ const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct ref_states *states = cb_data;
+ struct refspec refspec;
+
+ memset(&refspec, 0, sizeof(refspec));
+ refspec.dst = (char *)refname;
+ if (!remote_find_tracking(states->remote, &refspec)) {
+ struct string_list_item *item;
+ const char *name = abbrev_branch(refspec.src);
+ /* symbolic refs pointing nowhere were handled already */
+ if ((flags & REF_ISSYMREF) ||
+ unsorted_string_list_has_string(&states->tracked,
+ name) ||
+ unsorted_string_list_has_string(&states->new,
+ name))
+ return 0;
+ item = string_list_append(name, &states->stale);
+ item->util = xstrdup(refname);
+ }
+ return 0;
+}
+
+static int get_ref_states(const struct ref *ref, struct ref_states *states)
+{
+ struct ref *fetch_map = NULL, **tail = &fetch_map;
+ int i;
+
+ for (i = 0; i < states->remote->fetch_refspec_nr; i++)
+ if (get_fetch_map(ref, states->remote->fetch + i, &tail, 1))
+ die("Could not get fetch map for refspec %s",
+ states->remote->fetch_refspec[i]);
+
+ states->new.strdup_strings = states->tracked.strdup_strings = 1;
+ for (ref = fetch_map; ref; ref = ref->next) {
+ struct string_list *target = &states->tracked;
+ unsigned char sha1[20];
+ void *util = NULL;
+
+ if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
+ target = &states->new;
+ else {
+ target = &states->tracked;
+ if (hashcmp(sha1, ref->new_sha1))
+ util = &states;
+ }
+ string_list_append(abbrev_branch(ref->name), target)->util = util;
+ }
+ free_refs(fetch_map);
+
+ for_each_ref(handle_one_branch, states);
+ sort_string_list(&states->stale);
+
+ return 0;
+}
+
+struct known_remote {
+ struct known_remote *next;
+ struct remote *remote;
+};
+
+struct known_remotes {
+ struct remote *to_delete;
+ struct known_remote *list;
+};
+
+static int add_known_remote(struct remote *remote, void *cb_data)
+{
+ struct known_remotes *all = cb_data;
+ struct known_remote *r;
+
+ if (!strcmp(all->to_delete->name, remote->name))
+ return 0;
+
+ r = xmalloc(sizeof(*r));
+ r->remote = remote;
+ r->next = all->list;
+ all->list = r;
+ return 0;
+}
+
+struct branches_for_remote {
+ struct remote *remote;
+ struct string_list *branches;
+ struct known_remotes *keep;
+};
+
+static int add_branch_for_removal(const char *refname,
+ const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct branches_for_remote *branches = cb_data;
+ struct refspec refspec;
+ struct string_list_item *item;
+ struct known_remote *kr;
+
+ memset(&refspec, 0, sizeof(refspec));
+ refspec.dst = (char *)refname;
+ if (remote_find_tracking(branches->remote, &refspec))
+ return 0;
+
+ /* don't delete a branch if another remote also uses it */
+ for (kr = branches->keep->list; kr; kr = kr->next) {
+ memset(&refspec, 0, sizeof(refspec));
+ refspec.dst = (char *)refname;
+ if (!remote_find_tracking(kr->remote, &refspec))
+ return 0;
+ }
+
+ /* make sure that symrefs are deleted */
+ if (flags & REF_ISSYMREF)
+ return unlink(git_path(refname));
+
+ item = string_list_append(refname, branches->branches);
+ item->util = xmalloc(20);
+ hashcpy(item->util, sha1);
+
+ return 0;
+}
+
+static int remove_branches(struct string_list *branches)
+{
+ int i, result = 0;
+ for (i = 0; i < branches->nr; i++) {
+ struct string_list_item *item = branches->items + i;
+ const char *refname = item->string;
+ unsigned char *sha1 = item->util;
+
+ if (delete_ref(refname, sha1))
+ result |= error("Could not remove branch %s", refname);
+ }
+ return result;
+}
+
+static int rm(int argc, const char **argv)
+{
+ struct option options[] = {
+ OPT_END()
+ };
+ struct remote *remote;
+ struct strbuf buf;
+ struct known_remotes known_remotes = { NULL, NULL };
+ struct string_list branches = { NULL, 0, 0, 1 };
+ struct branches_for_remote cb_data = { NULL, &branches, &known_remotes };
+ int i;
+
+ if (argc != 2)
+ usage_with_options(builtin_remote_usage, options);
+
+ remote = remote_get(argv[1]);
+ if (!remote)
+ die("No such remote: %s", argv[1]);
+
+ known_remotes.to_delete = remote;
+ for_each_remote(add_known_remote, &known_remotes);
+
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, "remote.%s", remote->name);
+ if (git_config_rename_section(buf.buf, NULL) < 1)
+ return error("Could not remove config section '%s'", buf.buf);
+
+ read_branches();
+ for (i = 0; i < branch_list.nr; i++) {
+ struct string_list_item *item = branch_list.items + i;
+ struct branch_info *info = item->util;
+ if (info->remote && !strcmp(info->remote, remote->name)) {
+ const char *keys[] = { "remote", "merge", NULL }, **k;
+ for (k = keys; *k; k++) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "branch.%s.%s",
+ item->string, *k);
+ if (git_config_set(buf.buf, NULL)) {
+ strbuf_release(&buf);
+ return -1;
+ }
+ }
+ }
+ }
+
+ /*
+ * We cannot just pass a function to for_each_ref() which deletes
+ * the branches one by one, since for_each_ref() relies on cached
+ * refs, which are invalidated when deleting a branch.
+ */
+ cb_data.remote = remote;
+ i = for_each_ref(add_branch_for_removal, &cb_data);
+ strbuf_release(&buf);
+
+ if (!i)
+ i = remove_branches(&branches);
+ string_list_clear(&branches, 1);
+
+ return i;
+}
+
+static void show_list(const char *title, struct string_list *list)
+{
+ int i;
+
+ if (!list->nr)
+ return;
+
+ printf(title, list->nr > 1 ? "es" : "");
+ printf("\n ");
+ for (i = 0; i < list->nr; i++)
+ printf("%s%s", i ? " " : "", list->items[i].string);
+ printf("\n");
+}
+
+static int get_remote_ref_states(const char *name,
+ struct ref_states *states,
+ int query)
+{
+ struct transport *transport;
+ const struct ref *ref;
+
+ states->remote = remote_get(name);
+ if (!states->remote)
+ return error("No such remote: %s", name);
+
+ read_branches();
+
+ if (query) {
+ transport = transport_get(NULL, states->remote->url_nr > 0 ?
+ states->remote->url[0] : NULL);
+ ref = transport_get_remote_refs(transport);
+ transport_disconnect(transport);
+
+ get_ref_states(ref, states);
+ }
+
+ return 0;
+}
+
+static int append_ref_to_tracked_list(const char *refname,
+ const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct ref_states *states = cb_data;
+ struct refspec refspec;
+
+ memset(&refspec, 0, sizeof(refspec));
+ refspec.dst = (char *)refname;
+ if (!remote_find_tracking(states->remote, &refspec))
+ string_list_append(abbrev_branch(refspec.src), &states->tracked);
+
+ return 0;
+}
+
+static int show(int argc, const char **argv)
+{
+ int no_query = 0, result = 0;
+ struct option options[] = {
+ OPT_GROUP("show specific options"),
+ OPT_BOOLEAN('n', NULL, &no_query, "do not query remotes"),
+ OPT_END()
+ };
+ struct ref_states states;
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
+
+ if (argc < 1)
+ return show_all();
+
+ memset(&states, 0, sizeof(states));
+ for (; argc; argc--, argv++) {
+ struct strbuf buf;
+ int i;
+
+ get_remote_ref_states(*argv, &states, !no_query);
+
+ printf("* remote %s\n URL: %s\n", *argv,
+ states.remote->url_nr > 0 ?
+ states.remote->url[0] : "(no URL)");
+
+ for (i = 0; i < branch_list.nr; i++) {
+ struct string_list_item *branch = branch_list.items + i;
+ struct branch_info *info = branch->util;
+ int j;
+
+ if (!info->merge.nr || strcmp(*argv, info->remote))
+ continue;
+ printf(" Remote branch%s merged with 'git pull' "
+ "while on branch %s\n ",
+ info->merge.nr > 1 ? "es" : "",
+ branch->string);
+ for (j = 0; j < info->merge.nr; j++)
+ printf(" %s", info->merge.items[j].string);
+ printf("\n");
+ }
+
+ if (!no_query) {
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, " New remote branch%%s (next fetch "
+ "will store in remotes/%s)", states.remote->name);
+ show_list(buf.buf, &states.new);
+ strbuf_release(&buf);
+ show_list(" Stale tracking branch%s (use 'git remote "
+ "prune')", &states.stale);
+ }
+
+ if (no_query)
+ for_each_ref(append_ref_to_tracked_list, &states);
+ show_list(" Tracked remote branch%s", &states.tracked);
+
+ if (states.remote->push_refspec_nr) {
+ printf(" Local branch%s pushed with 'git push'\n ",
+ states.remote->push_refspec_nr > 1 ?
+ "es" : "");
+ for (i = 0; i < states.remote->push_refspec_nr; i++) {
+ struct refspec *spec = states.remote->push + i;
+ printf(" %s%s%s%s", spec->force ? "+" : "",
+ abbrev_branch(spec->src),
+ spec->dst ? ":" : "",
+ spec->dst ? abbrev_branch(spec->dst) : "");
+ }
+ printf("\n");
+ }
+
+ /* NEEDSWORK: free remote */
+ string_list_clear(&states.new, 0);
+ string_list_clear(&states.stale, 0);
+ string_list_clear(&states.tracked, 0);
+ }
+
+ return result;
+}
+
+static int prune(int argc, const char **argv)
+{
+ int dry_run = 0, result = 0;
+ struct option options[] = {
+ OPT_GROUP("prune specific options"),
+ OPT__DRY_RUN(&dry_run),
+ OPT_END()
+ };
+ struct ref_states states;
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
+
+ if (argc < 1)
+ usage_with_options(builtin_remote_usage, options);
+
+ memset(&states, 0, sizeof(states));
+ for (; argc; argc--, argv++) {
+ int i;
+
+ get_remote_ref_states(*argv, &states, 1);
+
+ if (states.stale.nr) {
+ printf("Pruning %s\n", *argv);
+ printf("URL: %s\n",
+ states.remote->url_nr
+ ? states.remote->url[0]
+ : "(no URL)");
+ }
+
+ for (i = 0; i < states.stale.nr; i++) {
+ const char *refname = states.stale.items[i].util;
+
+ if (!dry_run)
+ result |= delete_ref(refname, NULL);
+
+ printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
+ abbrev_ref(refname, "refs/remotes/"));
+ }
+
+ /* NEEDSWORK: free remote */
+ string_list_clear(&states.new, 0);
+ string_list_clear(&states.stale, 0);
+ string_list_clear(&states.tracked, 0);
+ }
+
+ return result;
+}
+
+static int get_one_remote_for_update(struct remote *remote, void *priv)
+{
+ struct string_list *list = priv;
+ if (!remote->skip_default_update)
+ string_list_append(xstrdup(remote->name), list);
+ return 0;
+}
+
+struct remote_group {
+ const char *name;
+ struct string_list *list;
+} remote_group;
+
+static int get_remote_group(const char *key, const char *value, void *cb)
+{
+ if (!prefixcmp(key, "remotes.") &&
+ !strcmp(key + 8, remote_group.name)) {
+ /* split list by white space */
+ int space = strcspn(value, " \t\n");
+ while (*value) {
+ if (space > 1)
+ string_list_append(xstrndup(value, space),
+ remote_group.list);
+ value += space + (value[space] != '\0');
+ space = strcspn(value, " \t\n");
+ }
+ }
+
+ return 0;
+}
+
+static int update(int argc, const char **argv)
+{
+ int i, result = 0;
+ struct string_list list = { NULL, 0, 0, 0 };
+ static const char *default_argv[] = { NULL, "default", NULL };
+
+ if (argc < 2) {
+ argc = 2;
+ argv = default_argv;
+ }
+
+ remote_group.list = &list;
+ for (i = 1; i < argc; i++) {
+ remote_group.name = argv[i];
+ result = git_config(get_remote_group, NULL);
+ }
+
+ if (!result && !list.nr && argc == 2 && !strcmp(argv[1], "default"))
+ result = for_each_remote(get_one_remote_for_update, &list);
+
+ for (i = 0; i < list.nr; i++)
+ result |= fetch_remote(list.items[i].string);
+
+ /* all names were strdup()ed or strndup()ed */
+ list.strdup_strings = 1;
+ string_list_clear(&list, 0);
+
+ return result;
+}
+
+static int get_one_entry(struct remote *remote, void *priv)
+{
+ struct string_list *list = priv;
+
+ string_list_append(remote->name, list)->util = remote->url_nr ?
+ (void *)remote->url[0] : NULL;
+ if (remote->url_nr > 1)
+ warning("Remote %s has more than one URL", remote->name);
+
+ return 0;
+}
+
+static int show_all(void)
+{
+ struct string_list list = { NULL, 0, 0 };
+ int result = for_each_remote(get_one_entry, &list);
+
+ if (!result) {
+ int i;
+
+ sort_string_list(&list);
+ for (i = 0; i < list.nr; i++) {
+ struct string_list_item *item = list.items + i;
+ printf("%s%s%s\n", item->string,
+ verbose ? "\t" : "",
+ verbose && item->util ?
+ (const char *)item->util : "");
+ }
+ }
+ return result;
+}
+
+int cmd_remote(int argc, const char **argv, const char *prefix)
+{
+ struct option options[] = {
+ OPT__VERBOSE(&verbose),
+ OPT_END()
+ };
+ int result;
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
+
+ if (argc < 1)
+ result = show_all();
+ else if (!strcmp(argv[0], "add"))
+ result = add(argc, argv);
+ else if (!strcmp(argv[0], "rm"))
+ result = rm(argc, argv);
+ else if (!strcmp(argv[0], "show"))
+ result = show(argc, argv);
+ else if (!strcmp(argv[0], "prune"))
+ result = prune(argc, argv);
+ else if (!strcmp(argv[0], "update"))
+ result = update(argc, argv);
+ else {
+ error("Unknown subcommand: %s", argv[0]);
+ usage_with_options(builtin_remote_usage, options);
+ }
+
+ return result ? 1 : 0;
+}
diff --git a/builtin-rerere.c b/builtin-rerere.c
index b0c17bde8..dd4573fe8 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -1,193 +1,32 @@
#include "builtin.h"
#include "cache.h"
-#include "path-list.h"
+#include "string-list.h"
+#include "rerere.h"
#include "xdiff/xdiff.h"
#include "xdiff-interface.h"
-#include <time.h>
-
static const char git_rerere_usage[] =
-"git-rerere [clear | status | diff | gc]";
+"git rerere [clear | status | diff | gc]";
/* these values are days */
static int cutoff_noresolve = 15;
static int cutoff_resolve = 60;
-/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
-static int rerere_enabled = -1;
-
-static char *merge_rr_path;
-
static const char *rr_path(const char *name, const char *file)
{
return git_path("rr-cache/%s/%s", name, file);
}
-static void read_rr(struct path_list *rr)
-{
- unsigned char sha1[20];
- char buf[PATH_MAX];
- FILE *in = fopen(merge_rr_path, "r");
- if (!in)
- return;
- while (fread(buf, 40, 1, in) == 1) {
- int i;
- char *name;
- if (get_sha1_hex(buf, sha1))
- die("corrupt MERGE_RR");
- buf[40] = '\0';
- name = xstrdup(buf);
- if (fgetc(in) != '\t')
- die("corrupt MERGE_RR");
- for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++)
- ; /* do nothing */
- if (i == sizeof(buf))
- die("filename too long");
- path_list_insert(buf, rr)->util = xstrdup(name);
- }
- fclose(in);
-}
-
-static struct lock_file write_lock;
-
-static int write_rr(struct path_list *rr, int out_fd)
-{
- int i;
- for (i = 0; i < rr->nr; i++) {
- const char *path = rr->items[i].path;
- int length = strlen(path) + 1;
- if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
- write_in_full(out_fd, "\t", 1) != 1 ||
- write_in_full(out_fd, path, length) != length)
- die("unable to write rerere record");
- }
- if (commit_lock_file(&write_lock) != 0)
- die("unable to write rerere record");
- return 0;
-}
-
-static int handle_file(const char *path,
- unsigned char *sha1, const char *output)
-{
- SHA_CTX ctx;
- char buf[1024];
- int hunk = 0, hunk_no = 0;
- struct strbuf one, two;
- FILE *f = fopen(path, "r");
- FILE *out = NULL;
-
- if (!f)
- return error("Could not open %s", path);
-
- if (output) {
- out = fopen(output, "w");
- if (!out) {
- fclose(f);
- return error("Could not write %s", output);
- }
- }
-
- if (sha1)
- SHA1_Init(&ctx);
-
- strbuf_init(&one, 0);
- strbuf_init(&two, 0);
- while (fgets(buf, sizeof(buf), f)) {
- if (!prefixcmp(buf, "<<<<<<< "))
- hunk = 1;
- else if (!prefixcmp(buf, "======="))
- hunk = 2;
- else if (!prefixcmp(buf, ">>>>>>> ")) {
- int cmp = strbuf_cmp(&one, &two);
-
- hunk_no++;
- hunk = 0;
- if (cmp > 0) {
- strbuf_swap(&one, &two);
- }
- if (out) {
- fputs("<<<<<<<\n", out);
- fwrite(one.buf, one.len, 1, out);
- fputs("=======\n", out);
- fwrite(two.buf, two.len, 1, out);
- fputs(">>>>>>>\n", out);
- }
- if (sha1) {
- SHA1_Update(&ctx, one.buf ? one.buf : "",
- one.len + 1);
- SHA1_Update(&ctx, two.buf ? two.buf : "",
- two.len + 1);
- }
- strbuf_reset(&one);
- strbuf_reset(&two);
- } else if (hunk == 1)
- strbuf_addstr(&one, buf);
- else if (hunk == 2)
- strbuf_addstr(&two, buf);
- else if (out)
- fputs(buf, out);
- }
- strbuf_release(&one);
- strbuf_release(&two);
-
- fclose(f);
- if (out)
- fclose(out);
- if (sha1)
- SHA1_Final(sha1, &ctx);
- return hunk_no;
-}
-
-static int find_conflict(struct path_list *conflict)
+static time_t rerere_created_at(const char *name)
{
- int i;
- if (read_cache() < 0)
- return error("Could not read index");
- for (i = 0; i+1 < active_nr; i++) {
- struct cache_entry *e2 = active_cache[i];
- struct cache_entry *e3 = active_cache[i+1];
- if (ce_stage(e2) == 2 &&
- ce_stage(e3) == 3 &&
- ce_same_name(e2, e3) &&
- S_ISREG(e2->ce_mode) &&
- S_ISREG(e3->ce_mode)) {
- path_list_insert((const char *)e2->name, conflict);
- i++; /* skip over both #2 and #3 */
- }
- }
- return 0;
+ struct stat st;
+ return stat(rr_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
}
-static int merge(const char *name, const char *path)
+static int has_resolution(const char *name)
{
- int ret;
- mmfile_t cur, base, other;
- mmbuffer_t result = {NULL, 0};
- xpparam_t xpp = {XDF_NEED_MINIMAL};
-
- if (handle_file(path, NULL, rr_path(name, "thisimage")) < 0)
- return 1;
-
- if (read_mmfile(&cur, rr_path(name, "thisimage")) ||
- read_mmfile(&base, rr_path(name, "preimage")) ||
- read_mmfile(&other, rr_path(name, "postimage")))
- return 1;
- ret = xdl_merge(&base, &cur, "", &other, "",
- &xpp, XDL_MERGE_ZEALOUS, &result);
- if (!ret) {
- FILE *f = fopen(path, "w");
- if (!f)
- return error("Could not write to %s", path);
- fwrite(result.ptr, result.size, 1, f);
- fclose(f);
- }
-
- free(cur.ptr);
- free(base.ptr);
- free(other.ptr);
- free(result.ptr);
-
- return ret;
+ struct stat st;
+ return !stat(rr_path(name, "postimage"), &st);
}
static void unlink_rr_item(const char *name)
@@ -198,40 +37,43 @@ static void unlink_rr_item(const char *name)
rmdir(git_path("rr-cache/%s", name));
}
-static void garbage_collect(struct path_list *rr)
+static int git_rerere_gc_config(const char *var, const char *value, void *cb)
{
- struct path_list to_remove = { NULL, 0, 0, 1 };
- char buf[1024];
+ if (!strcmp(var, "gc.rerereresolved"))
+ cutoff_resolve = git_config_int(var, value);
+ else if (!strcmp(var, "gc.rerereunresolved"))
+ cutoff_noresolve = git_config_int(var, value);
+ else
+ return git_default_config(var, value, cb);
+ return 0;
+}
+
+static void garbage_collect(struct string_list *rr)
+{
+ struct string_list to_remove = { NULL, 0, 0, 1 };
DIR *dir;
struct dirent *e;
- int len, i, cutoff;
+ int i, cutoff;
time_t now = time(NULL), then;
- strlcpy(buf, git_path("rr-cache"), sizeof(buf));
- len = strlen(buf);
- dir = opendir(buf);
- strcpy(buf + len++, "/");
+ git_config(git_rerere_gc_config, NULL);
+ dir = opendir(git_path("rr-cache"));
while ((e = readdir(dir))) {
const char *name = e->d_name;
- struct stat st;
- if (name[0] == '.' && (name[1] == '\0' ||
- (name[1] == '.' && name[2] == '\0')))
+ if (name[0] == '.' &&
+ (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')))
continue;
- i = snprintf(buf + len, sizeof(buf) - len, "%s", name);
- strlcpy(buf + len + i, "/preimage", sizeof(buf) - len - i);
- if (stat(buf, &st))
+ then = rerere_created_at(name);
+ if (!then)
continue;
- then = st.st_mtime;
- strlcpy(buf + len + i, "/postimage", sizeof(buf) - len - i);
- cutoff = stat(buf, &st) ? cutoff_noresolve : cutoff_resolve;
- if (then < now - cutoff * 86400) {
- buf[len + i] = '\0';
- path_list_insert(xstrdup(name), &to_remove);
- }
+ cutoff = (has_resolution(name)
+ ? cutoff_resolve : cutoff_noresolve);
+ if (then < now - cutoff * 86400)
+ string_list_append(name, &to_remove);
}
for (i = 0; i < to_remove.nr; i++)
- unlink_rr_item(to_remove.items[i].path);
- path_list_clear(&to_remove, 0);
+ unlink_rr_item(to_remove.items[i].string);
+ string_list_clear(&to_remove, 0);
}
static int outf(void *dummy, mmbuffer_t *ptr, int nbuf)
@@ -267,188 +109,39 @@ static int diff_two(const char *file1, const char *label1,
return 0;
}
-static int copy_file(const char *src, const char *dest)
-{
- FILE *in, *out;
- char buffer[32768];
- int count;
-
- if (!(in = fopen(src, "r")))
- return error("Could not open %s", src);
- if (!(out = fopen(dest, "w")))
- return error("Could not open %s", dest);
- while ((count = fread(buffer, 1, sizeof(buffer), in)))
- fwrite(buffer, 1, count, out);
- fclose(in);
- fclose(out);
- return 0;
-}
-
-static int do_plain_rerere(struct path_list *rr, int fd)
-{
- struct path_list conflict = { NULL, 0, 0, 1 };
- int i;
-
- find_conflict(&conflict);
-
- /*
- * MERGE_RR records paths with conflicts immediately after merge
- * failed. Some of the conflicted paths might have been hand resolved
- * in the working tree since then, but the initial run would catch all
- * and register their preimages.
- */
-
- for (i = 0; i < conflict.nr; i++) {
- const char *path = conflict.items[i].path;
- if (!path_list_has_path(rr, path)) {
- unsigned char sha1[20];
- char *hex;
- int ret;
- ret = handle_file(path, sha1, NULL);
- if (ret < 1)
- continue;
- hex = xstrdup(sha1_to_hex(sha1));
- path_list_insert(path, rr)->util = hex;
- if (mkdir(git_path("rr-cache/%s", hex), 0755))
- continue;;
- handle_file(path, NULL, rr_path(hex, "preimage"));
- fprintf(stderr, "Recorded preimage for '%s'\n", path);
- }
- }
-
- /*
- * Now some of the paths that had conflicts earlier might have been
- * hand resolved. Others may be similar to a conflict already that
- * was resolved before.
- */
-
- for (i = 0; i < rr->nr; i++) {
- struct stat st;
- int ret;
- const char *path = rr->items[i].path;
- const char *name = (const char *)rr->items[i].util;
-
- if (!stat(rr_path(name, "preimage"), &st) &&
- !stat(rr_path(name, "postimage"), &st)) {
- if (!merge(name, path)) {
- fprintf(stderr, "Resolved '%s' using "
- "previous resolution.\n", path);
- goto tail_optimization;
- }
- }
-
- /* Let's see if we have resolved it. */
- ret = handle_file(path, NULL, NULL);
- if (ret)
- continue;
-
- fprintf(stderr, "Recorded resolution for '%s'.\n", path);
- copy_file(path, rr_path(name, "postimage"));
-tail_optimization:
- if (i < rr->nr - 1)
- memmove(rr->items + i,
- rr->items + i + 1,
- sizeof(rr->items[0]) * (rr->nr - i - 1));
- rr->nr--;
- i--;
- }
-
- return write_rr(rr, fd);
-}
-
-static int git_rerere_config(const char *var, const char *value)
-{
- if (!strcmp(var, "gc.rerereresolved"))
- cutoff_resolve = git_config_int(var, value);
- else if (!strcmp(var, "gc.rerereunresolved"))
- cutoff_noresolve = git_config_int(var, value);
- else if (!strcmp(var, "rerere.enabled"))
- rerere_enabled = git_config_bool(var, value);
- else
- return git_default_config(var, value);
- return 0;
-}
-
-static int is_rerere_enabled(void)
-{
- struct stat st;
- const char *rr_cache;
- int rr_cache_exists;
-
- if (!rerere_enabled)
- return 0;
-
- rr_cache = git_path("rr-cache");
- rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode);
- if (rerere_enabled < 0)
- return rr_cache_exists;
-
- if (!rr_cache_exists &&
- (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache)))
- die("Could not create directory %s", rr_cache);
- return 1;
-}
-
-static int setup_rerere(struct path_list *merge_rr)
-{
- int fd;
-
- git_config(git_rerere_config);
- if (!is_rerere_enabled())
- return -1;
-
- merge_rr_path = xstrdup(git_path("rr-cache/MERGE_RR"));
- fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
- read_rr(merge_rr);
- return fd;
-}
-
-int rerere(void)
-{
- struct path_list merge_rr = { NULL, 0, 0, 1 };
- int fd;
-
- fd = setup_rerere(&merge_rr);
- if (fd < 0)
- return 0;
- return do_plain_rerere(&merge_rr, fd);
-}
-
int cmd_rerere(int argc, const char **argv, const char *prefix)
{
- struct path_list merge_rr = { NULL, 0, 0, 1 };
+ struct string_list merge_rr = { NULL, 0, 0, 1 };
int i, fd;
+ if (argc < 2)
+ return rerere();
+
fd = setup_rerere(&merge_rr);
if (fd < 0)
return 0;
- if (argc < 2)
- return do_plain_rerere(&merge_rr, fd);
- else if (!strcmp(argv[1], "clear")) {
+ if (!strcmp(argv[1], "clear")) {
for (i = 0; i < merge_rr.nr; i++) {
- struct stat st;
const char *name = (const char *)merge_rr.items[i].util;
- if (!stat(git_path("rr-cache/%s", name), &st) &&
- S_ISDIR(st.st_mode) &&
- stat(rr_path(name, "postimage"), &st))
+ if (!has_resolution(name))
unlink_rr_item(name);
}
- unlink(merge_rr_path);
+ unlink(git_path("rr-cache/MERGE_RR"));
} else if (!strcmp(argv[1], "gc"))
garbage_collect(&merge_rr);
else if (!strcmp(argv[1], "status"))
for (i = 0; i < merge_rr.nr; i++)
- printf("%s\n", merge_rr.items[i].path);
+ printf("%s\n", merge_rr.items[i].string);
else if (!strcmp(argv[1], "diff"))
for (i = 0; i < merge_rr.nr; i++) {
- const char *path = merge_rr.items[i].path;
+ const char *path = merge_rr.items[i].string;
const char *name = (const char *)merge_rr.items[i].util;
diff_two(rr_path(name, "preimage"), path, path, path);
}
else
usage(git_rerere_usage);
- path_list_clear(&merge_rr, 1);
+ string_list_clear(&merge_rr, 1);
return 0;
}
diff --git a/builtin-reset.c b/builtin-reset.c
index af0037ec6..c24c21909 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -17,9 +17,13 @@
#include "diffcore.h"
#include "tree.h"
#include "branch.h"
+#include "parse-options.h"
-static const char builtin_reset_usage[] =
-"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]";
+static const char * const git_reset_usage[] = {
+ "git reset [--mixed | --soft | --hard] [-q] [<commit>]",
+ "git reset [--mixed] <commit> [--] <paths>...",
+ NULL
+};
static char *args_to_str(const char **argv)
{
@@ -45,13 +49,14 @@ static inline int is_merge(void)
return !access(git_path("MERGE_HEAD"), F_OK);
}
-static int reset_index_file(const unsigned char *sha1, int is_hard_reset)
+static int reset_index_file(const unsigned char *sha1, int is_hard_reset, int quiet)
{
int i = 0;
const char *args[6];
args[i++] = "read-tree";
- args[i++] = "-v";
+ if (!quiet)
+ args[i++] = "-v";
args[i++] = "--reset";
if (is_hard_reset)
args[i++] = "-u";
@@ -63,14 +68,10 @@ static int reset_index_file(const unsigned char *sha1, int is_hard_reset)
static void print_new_head_line(struct commit *commit)
{
- const char *hex, *dots = "...", *body;
+ const char *hex, *body;
hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
- if (!hex) {
- hex = sha1_to_hex(commit->object.sha1);
- dots = "";
- }
- printf("HEAD is now at %s%s", hex, dots);
+ printf("HEAD is now at %s", hex);
body = strstr(commit->buffer, "\n\n");
if (body) {
const char *eol;
@@ -84,7 +85,7 @@ static void print_new_head_line(struct commit *commit)
printf("\n");
}
-static int update_index_refresh(int fd, struct lock_file *index_lock)
+static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
{
int result;
@@ -95,7 +96,8 @@ static int update_index_refresh(int fd, struct lock_file *index_lock)
if (read_cache() < 0)
return error("Could not read index");
- result = refresh_cache(0) ? 1 : 0;
+
+ result = refresh_cache(flags) ? 1 : 0;
if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(index_lock))
return error ("Could not refresh index");
@@ -127,7 +129,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
}
static int read_from_tree(const char *prefix, const char **argv,
- unsigned char *tree_sha1)
+ unsigned char *tree_sha1, int refresh_flags)
{
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
int index_fd, index_was_discarded = 0;
@@ -151,7 +153,7 @@ static int read_from_tree(const char *prefix, const char **argv,
if (!index_was_discarded)
/* The index is still clobbered from do_diff_cache() */
discard_cache();
- return update_index_refresh(index_fd, lock);
+ return update_index_refresh(index_fd, lock, refresh_flags);
}
static void prepend_reflog_action(const char *action, char *buf, size_t size)
@@ -169,42 +171,65 @@ static const char *reset_type_names[] = { "mixed", "soft", "hard", NULL };
int cmd_reset(int argc, const char **argv, const char *prefix)
{
- int i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0;
+ int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0;
const char *rev = "HEAD";
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
*old_orig = NULL, sha1_old_orig[20];
struct commit *commit;
char *reflog_action, msg[1024];
-
- git_config(git_default_config);
-
+ const struct option options[] = {
+ OPT_SET_INT(0, "mixed", &reset_type,
+ "reset HEAD and index", MIXED),
+ OPT_SET_INT(0, "soft", &reset_type, "reset only HEAD", SOFT),
+ OPT_SET_INT(0, "hard", &reset_type,
+ "reset HEAD, index and working tree", HARD),
+ OPT_BOOLEAN('q', NULL, &quiet,
+ "disable showing new HEAD in hard reset and progress message"),
+ OPT_END()
+ };
+
+ git_config(git_default_config, NULL);
+
+ argc = parse_options(argc, argv, options, git_reset_usage,
+ PARSE_OPT_KEEP_DASHDASH);
reflog_action = args_to_str(argv);
setenv("GIT_REFLOG_ACTION", reflog_action, 0);
- while (i < argc) {
- if (!strcmp(argv[i], "--mixed")) {
- reset_type = MIXED;
- i++;
- }
- else if (!strcmp(argv[i], "--soft")) {
- reset_type = SOFT;
- i++;
- }
- else if (!strcmp(argv[i], "--hard")) {
- reset_type = HARD;
- i++;
+ /*
+ * Possible arguments are:
+ *
+ * git reset [-opts] <rev> <paths>...
+ * git reset [-opts] <rev> -- <paths>...
+ * git reset [-opts] -- <paths>...
+ * git reset [-opts] <paths>...
+ *
+ * At this point, argv[i] points immediately after [-opts].
+ */
+
+ if (i < argc) {
+ if (!strcmp(argv[i], "--")) {
+ i++; /* reset to HEAD, possibly with paths */
+ } else if (i + 1 < argc && !strcmp(argv[i+1], "--")) {
+ rev = argv[i];
+ i += 2;
}
- else if (!strcmp(argv[i], "-q")) {
- quiet = 1;
- i++;
+ /*
+ * Otherwise, argv[i] could be either <rev> or <paths> and
+ * has to be unambigous.
+ */
+ else if (!get_sha1(argv[i], sha1)) {
+ /*
+ * Ok, argv[i] looks like a rev; it should not
+ * be a filename.
+ */
+ verify_non_filename(prefix, argv[i]);
+ rev = argv[i++];
+ } else {
+ /* Otherwise we treat this as a filename */
+ verify_filename(prefix, argv[i]);
}
- else
- break;
}
- if (i < argc && argv[i][0] != '-')
- rev = argv[i++];
-
if (get_sha1(rev, sha1))
die("Failed to resolve '%s' as a valid ref.", rev);
@@ -213,11 +238,6 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die("Could not parse object '%s'.", rev);
hashcpy(sha1, commit->object.sha1);
- if (i < argc && !strcmp(argv[i], "--"))
- i++;
- else if (i < argc && argv[i][0] == '-')
- usage(builtin_reset_usage);
-
/* git reset tree [--] paths... can be used to
* load chosen paths from the tree into the index without
* affecting the working tree nor HEAD. */
@@ -227,7 +247,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
else if (reset_type != NONE)
die("Cannot do %s reset with paths.",
reset_type_names[reset_type]);
- return read_from_tree(prefix, argv + i, sha1);
+ return read_from_tree(prefix, argv + i, sha1,
+ quiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);
}
if (reset_type == NONE)
reset_type = MIXED; /* by default */
@@ -242,7 +263,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
if (is_merge() || read_cache() < 0 || unmerged_cache())
die("Cannot do a soft reset in the middle of a merge.");
}
- else if (reset_index_file(sha1, (reset_type == HARD)))
+ else if (reset_index_file(sha1, (reset_type == HARD), quiet))
die("Could not reset index file to revision '%s'.", rev);
/* Any resets update HEAD to the head being switched to,
@@ -267,7 +288,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
case SOFT: /* Nothing else to do. */
break;
case MIXED: /* Report what has not been updated. */
- update_index_refresh(0, NULL);
+ update_index_refresh(0, NULL,
+ quiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);
break;
}
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index de80158fd..893762c80 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -10,13 +10,14 @@
#include "list-objects.h"
#include "builtin.h"
#include "log-tree.h"
+#include "graph.h"
/* bits #0-15 in revision.h */
#define COUNTED (1u<<16)
static const char rev_list_usage[] =
-"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
+"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
" limiting output:\n"
" --max-count=nr\n"
" --max-age=epoch\n"
@@ -25,13 +26,18 @@ static const char rev_list_usage[] =
" --no-merges\n"
" --remove-empty\n"
" --all\n"
+" --branches\n"
+" --tags\n"
+" --remotes\n"
" --stdin\n"
" --quiet\n"
" ordering output:\n"
" --topo-order\n"
" --date-order\n"
+" --reverse\n"
" formatting output:\n"
" --parents\n"
+" --children\n"
" --objects | --objects-edge\n"
" --unpacked\n"
" --header | --pretty\n"
@@ -54,45 +60,100 @@ static const char *header_prefix;
static void finish_commit(struct commit *commit);
static void show_commit(struct commit *commit)
{
+ graph_show_commit(revs.graph);
+
if (show_timestamp)
printf("%lu ", commit->date);
if (header_prefix)
fputs(header_prefix, stdout);
- if (commit->object.flags & BOUNDARY)
- putchar('-');
- else if (revs.left_right) {
- if (commit->object.flags & SYMMETRIC_LEFT)
- putchar('<');
- else
- putchar('>');
+
+ if (!revs.graph) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & UNINTERESTING)
+ putchar('^');
+ else if (revs.left_right) {
+ if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
}
if (revs.abbrev_commit && revs.abbrev)
fputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),
stdout);
else
fputs(sha1_to_hex(commit->object.sha1), stdout);
- if (revs.parents) {
+ if (revs.print_parents) {
struct commit_list *parents = commit->parents;
while (parents) {
printf(" %s", sha1_to_hex(parents->item->object.sha1));
parents = parents->next;
}
}
+ if (revs.children.name) {
+ struct commit_list *children;
+
+ children = lookup_decoration(&revs.children, &commit->object);
+ while (children) {
+ printf(" %s", sha1_to_hex(children->item->object.sha1));
+ children = children->next;
+ }
+ }
show_decorations(commit);
if (revs.commit_format == CMIT_FMT_ONELINE)
putchar(' ');
else
putchar('\n');
- if (revs.verbose_header) {
+ if (revs.verbose_header && commit->buffer) {
struct strbuf buf;
strbuf_init(&buf, 0);
pretty_print_commit(revs.commit_format, commit,
&buf, revs.abbrev, NULL, NULL,
revs.date_mode, 0);
- if (buf.len)
- printf("%s%c", buf.buf, hdr_termination);
+ if (revs.graph) {
+ if (buf.len) {
+ if (revs.commit_format != CMIT_FMT_ONELINE)
+ graph_show_oneline(revs.graph);
+
+ graph_show_commit_msg(revs.graph, &buf);
+
+ /*
+ * Add a newline after the commit message.
+ *
+ * Usually, this newline produces a blank
+ * padding line between entries, in which case
+ * we need to add graph padding on this line.
+ *
+ * However, the commit message may not end in a
+ * newline. In this case the newline simply
+ * ends the last line of the commit message,
+ * and we don't need any graph output. (This
+ * always happens with CMIT_FMT_ONELINE, and it
+ * happens with CMIT_FMT_USERFORMAT when the
+ * format doesn't explicitly end in a newline.)
+ */
+ if (buf.len && buf.buf[buf.len - 1] == '\n')
+ graph_show_padding(revs.graph);
+ putchar('\n');
+ } else {
+ /*
+ * If the message buffer is empty, just show
+ * the rest of the graph output for this
+ * commit.
+ */
+ if (graph_show_remainder(revs.graph))
+ putchar('\n');
+ }
+ } else {
+ if (buf.len)
+ printf("%s%c", buf.buf, hdr_termination);
+ }
strbuf_release(&buf);
+ } else {
+ if (graph_show_remainder(revs.graph))
+ putchar('\n');
}
maybe_flush_or_die(stdout, "stdout");
finish_commit(commit);
@@ -514,23 +575,6 @@ static struct commit_list *find_bisection(struct commit_list *list,
return best;
}
-static void read_revisions_from_stdin(struct rev_info *revs)
-{
- char line[1000];
-
- while (fgets(line, sizeof(line), stdin) != NULL) {
- int len = strlen(line);
- if (len && line[len - 1] == '\n')
- line[--len] = 0;
- if (!len)
- break;
- if (line[0] == '-')
- die("options not supported in --stdin mode");
- if (handle_revision_arg(line, revs, 0, 1))
- die("bad revision '%s'", line);
- }
-}
-
int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct commit_list *list;
@@ -540,12 +584,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
int bisect_find_all = 0;
int quiet = 0;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
init_revisions(&revs, prefix);
revs.abbrev = 0;
revs.commit_format = CMIT_FMT_UNSPECIFIED;
argc = setup_revisions(argc, argv, &revs, NULL);
+ quiet = DIFF_OPT_TST(&revs.diffopt, QUIET);
for (i = 1 ; i < argc; i++) {
const char *arg = argv[i];
@@ -577,10 +622,6 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
read_revisions_from_stdin(&revs);
continue;
}
- if (!strcmp(arg, "--quiet")) {
- quiet = 1;
- continue;
- }
usage(rev_list_usage);
}
@@ -605,11 +646,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
usage(rev_list_usage);
save_commit_buffer = revs.verbose_header || revs.grep_filter;
- track_object_refs = 0;
if (bisect_list)
revs.limited = 1;
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
if (revs.tree_objects)
mark_edges_uninteresting(revs.commits, &revs, show_edge);
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index b9af1a5a5..9aa049ec1 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -28,8 +28,6 @@ static int symbolic;
static int abbrev;
static int output_sq;
-static int revs_count;
-
/*
* Some arguments are relevant "revision" arguments,
* others are about output format or other details.
@@ -96,16 +94,21 @@ static void show(const char *arg)
puts(arg);
}
+/* Like show(), but with a negation prefix according to type */
+static void show_with_type(int type, const char *arg)
+{
+ if (type != show_type)
+ putchar('^');
+ show(arg);
+}
+
/* Output a revision, only if filter allows it */
static void show_rev(int type, const unsigned char *sha1, const char *name)
{
if (!(filter & DO_REVS))
return;
def = NULL;
- revs_count++;
- if (type != show_type)
- putchar('^');
if (symbolic && name) {
if (symbolic == SHOW_SYMBOLIC_FULL) {
unsigned char discard[20];
@@ -122,20 +125,20 @@ static void show_rev(int type, const unsigned char *sha1, const char *name)
*/
break;
case 1: /* happy */
- show(full);
+ show_with_type(type, full);
break;
default: /* ambiguous */
error("refname '%s' is ambiguous", name);
break;
}
} else {
- show(name);
+ show_with_type(type, name);
}
}
else if (abbrev)
- show(find_unique_abbrev(sha1, abbrev));
+ show_with_type(type, find_unique_abbrev(sha1, abbrev));
else
- show(sha1_to_hex(sha1));
+ show_with_type(type, sha1_to_hex(sha1));
}
/* Output a flag, only if filter allows it. */
@@ -150,7 +153,7 @@ static int show_flag(const char *arg)
return 0;
}
-static void show_default(void)
+static int show_default(void)
{
const char *s = def;
@@ -160,9 +163,10 @@ static void show_default(void)
def = NULL;
if (!get_sha1(s, sha1)) {
show_rev(NORMAL, sha1, s);
- return;
+ return 1;
}
}
+ return 0;
}
static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
@@ -237,6 +241,36 @@ static int try_difference(const char *arg)
return 0;
}
+static int try_parent_shorthands(const char *arg)
+{
+ char *dotdot;
+ unsigned char sha1[20];
+ struct commit *commit;
+ struct commit_list *parents;
+ int parents_only;
+
+ if ((dotdot = strstr(arg, "^!")))
+ parents_only = 0;
+ else if ((dotdot = strstr(arg, "^@")))
+ parents_only = 1;
+
+ if (!dotdot || dotdot[2])
+ return 0;
+
+ *dotdot = 0;
+ if (get_sha1(arg, sha1))
+ return 0;
+
+ if (!parents_only)
+ show_rev(NORMAL, sha1, arg);
+ commit = lookup_commit_reference(sha1);
+ for (parents = commit->parents; parents; parents = parents->next)
+ show_rev(parents_only ? NORMAL : REVERSED,
+ parents->item->object.sha1, arg);
+
+ return 1;
+}
+
static int parseopt_dump(const struct option *o, const char *arg, int unset)
{
struct strbuf *parsed = o->value;
@@ -264,7 +298,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
{
static int keep_dashdash = 0;
static char const * const parseopt_usage[] = {
- "git-rev-parse --parseopt [options] -- [<args>...]",
+ "git rev-parse --parseopt [options] -- [<args>...]",
NULL
};
static struct option parseopt_opts[] = {
@@ -315,25 +349,31 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
s = strchr(sb.buf, ' ');
if (!s || *sb.buf == ' ') {
o->type = OPTION_GROUP;
- o->help = xstrdup(skipspaces(s));
+ o->help = xstrdup(skipspaces(sb.buf));
continue;
}
o->type = OPTION_CALLBACK;
o->help = xstrdup(skipspaces(s));
o->value = &parsed;
+ o->flags = PARSE_OPT_NOARG;
o->callback = &parseopt_dump;
- switch (s[-1]) {
- case '=':
- s--;
- break;
- case '?':
- o->flags = PARSE_OPT_OPTARG;
- s--;
- break;
- default:
- o->flags = PARSE_OPT_NOARG;
- break;
+ while (s > sb.buf && strchr("*=?!", s[-1])) {
+ switch (*--s) {
+ case '=':
+ o->flags &= ~PARSE_OPT_NOARG;
+ break;
+ case '?':
+ o->flags &= ~PARSE_OPT_NOARG;
+ o->flags |= PARSE_OPT_OPTARG;
+ break;
+ case '!':
+ o->flags |= PARSE_OPT_NONEG;
+ break;
+ case '*':
+ o->flags |= PARSE_OPT_HIDDEN;
+ break;
+ }
}
if (s - sb.buf == 1) /* short option only */
@@ -359,16 +399,25 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
return 0;
}
+static void die_no_single_rev(int quiet)
+{
+ if (quiet)
+ exit(1);
+ else
+ die("Needed a single revision");
+}
+
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
{
- int i, as_is = 0, verify = 0;
+ int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
unsigned char sha1[20];
+ const char *name = NULL;
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
prefix = setup_git_directory();
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -426,6 +475,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
verify = 1;
continue;
}
+ if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
+ quiet = 1;
+ continue;
+ }
if (!strcmp(arg, "--short") ||
!prefixcmp(arg, "--short=")) {
filter &= ~(DO_FLAGS|DO_NOREV);
@@ -543,30 +596,43 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (show_flag(arg) && verify)
- die("Needed a single revision");
+ die_no_single_rev(quiet);
continue;
}
/* Not a flag argument */
if (try_difference(arg))
continue;
- if (!get_sha1(arg, sha1)) {
- show_rev(NORMAL, sha1, arg);
+ if (try_parent_shorthands(arg))
continue;
+ name = arg;
+ type = NORMAL;
+ if (*arg == '^') {
+ name++;
+ type = REVERSED;
}
- if (*arg == '^' && !get_sha1(arg+1, sha1)) {
- show_rev(REVERSED, sha1, arg+1);
+ if (!get_sha1(name, sha1)) {
+ if (verify)
+ revs_count++;
+ else
+ show_rev(type, sha1, name);
continue;
}
+ if (verify)
+ die_no_single_rev(quiet);
as_is = 1;
if (!show_file(arg))
continue;
- if (verify)
- die("Needed a single revision");
verify_filename(prefix, arg);
}
- show_default();
- if (verify && revs_count != 1)
- die("Needed a single revision");
+ if (verify) {
+ if (revs_count == 1) {
+ show_rev(type, sha1, name);
+ return 0;
+ } else if (revs_count == 0 && show_default())
+ return 0;
+ die_no_single_rev(quiet);
+ } else
+ show_default();
return 0;
}
diff --git a/builtin-revert.c b/builtin-revert.c
index 358af5374..27881e949 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -8,6 +8,9 @@
#include "exec_cmd.h"
#include "utf8.h"
#include "parse-options.h"
+#include "cache-tree.h"
+#include "diff.h"
+#include "revision.h"
/*
* This implements the builtins revert and cherry-pick.
@@ -21,16 +24,16 @@
*/
static const char * const revert_usage[] = {
- "git-revert [options] <commit-ish>",
+ "git revert [options] <commit-ish>",
NULL
};
static const char * const cherry_pick_usage[] = {
- "git-cherry-pick [options] <commit-ish>",
+ "git cherry-pick [options] <commit-ish>",
NULL
};
-static int edit, no_replay, no_commit, mainline;
+static int edit, no_replay, no_commit, mainline, signoff;
static enum { REVERT, CHERRY_PICK } action;
static struct commit *commit;
@@ -50,6 +53,7 @@ static void parse_args(int argc, const char **argv)
OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
OPT_BOOLEAN('x', NULL, &no_replay, "append commit name when cherry-picking"),
OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
+ OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_INTEGER('m', "mainline", &mainline, "parent number"),
OPT_END(),
};
@@ -176,7 +180,7 @@ static void set_author_ident_env(const char *message)
email++;
timestamp = strchr(email, '>');
if (!timestamp)
- die ("Could not extract author email from %s",
+ die ("Could not extract author time from %s",
sha1_to_hex(commit->object.sha1));
*timestamp = '\0';
for (timestamp++; *timestamp && isspace(*timestamp);
@@ -202,6 +206,7 @@ static int merge_recursive(const char *base_sha1,
{
char buffer[256];
const char *argv[6];
+ int i = 0;
sprintf(buffer, "GITHEAD_%s", head_sha1);
setenv(buffer, head_name, 1);
@@ -214,12 +219,13 @@ static int merge_recursive(const char *base_sha1,
* and $prev on top of us (when reverting), or the change between
* $prev and $commit on top of us (when cherry-picking or replaying).
*/
- argv[0] = "merge-recursive";
- argv[1] = base_sha1;
- argv[2] = "--";
- argv[3] = head_sha1;
- argv[4] = next_sha1;
- argv[5] = NULL;
+ argv[i++] = "merge-recursive";
+ if (base_sha1)
+ argv[i++] = base_sha1;
+ argv[i++] = "--";
+ argv[i++] = head_sha1;
+ argv[i++] = next_sha1;
+ argv[i++] = NULL;
return run_command_v_opt(argv, RUN_COMMAND_NO_STDIN | RUN_GIT_CMD);
}
@@ -245,6 +251,17 @@ static char *help_msg(const unsigned char *sha1)
return helpbuf;
}
+static int index_is_dirty(void)
+{
+ struct rev_info rev;
+ init_revisions(&rev, NULL);
+ setup_revisions(0, NULL, &rev, "HEAD");
+ DIFF_OPT_SET(&rev.diffopt, QUIET);
+ DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
+ run_diff_index(&rev, 1);
+ return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
+}
+
static int revert_or_cherry_pick(int argc, const char **argv)
{
unsigned char head[20];
@@ -254,7 +271,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
const char *message, *encoding;
const char *defmsg = xstrdup(git_path("MERGE_MSG"));
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
me = action == REVERT ? "revert" : "cherry-pick";
setenv(GIT_REFLOG_ACTION, me, 0);
parse_args(argc, argv);
@@ -270,22 +287,24 @@ static int revert_or_cherry_pick(int argc, const char **argv)
* that represents the "current" state for merge-recursive
* to work on.
*/
- if (write_tree(head, 0, NULL))
+ if (write_cache_as_tree(head, 0, NULL))
die ("Your index file is unmerged.");
} else {
- struct wt_status s;
-
if (get_sha1("HEAD", head))
die ("You do not have a valid HEAD");
- wt_status_prepare(&s);
- if (s.commitable)
+ if (read_cache() < 0)
+ die("could not read the index");
+ if (index_is_dirty())
die ("Dirty index: cannot %s", me);
discard_cache();
}
- if (!commit->parents)
- die ("Cannot %s a root commit", me);
- if (commit->parents->next) {
+ if (!commit->parents) {
+ if (action == REVERT)
+ die ("Cannot revert a root commit");
+ parent = NULL;
+ }
+ else if (commit->parents->next) {
/* Reverting or cherry-picking a merge commit */
int cnt;
struct commit_list *p;
@@ -354,10 +373,11 @@ static int revert_or_cherry_pick(int argc, const char **argv)
}
}
- if (merge_recursive(sha1_to_hex(base->object.sha1),
+ if (merge_recursive(base == NULL ?
+ NULL : sha1_to_hex(base->object.sha1),
sha1_to_hex(head), "HEAD",
sha1_to_hex(next->object.sha1), oneline) ||
- write_tree(head, 0, NULL)) {
+ write_cache_as_tree(head, 0, NULL)) {
add_to_msg("\nConflicts:\n\n");
read_cache();
for (i = 0; i < active_nr;) {
@@ -391,13 +411,21 @@ static int revert_or_cherry_pick(int argc, const char **argv)
*/
if (!no_commit) {
- if (edit)
- return execl_git_cmd("commit", "-n", NULL);
- else
- return execl_git_cmd("commit", "-n", "-F", defmsg, NULL);
+ /* 6 is max possible length of our args array including NULL */
+ const char *args[6];
+ int i = 0;
+ args[i++] = "commit";
+ args[i++] = "-n";
+ if (signoff)
+ args[i++] = "-s";
+ if (!edit) {
+ args[i++] = "-F";
+ args[i++] = defmsg;
+ }
+ args[i] = NULL;
+ return execv_git_cmd(args);
}
- if (reencoded_message)
- free(reencoded_message);
+ free(reencoded_message);
return 0;
}
diff --git a/builtin-rm.c b/builtin-rm.c
index c0a8bb6cf..0ed26bb8f 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -11,7 +11,7 @@
#include "parse-options.h"
static const char * const builtin_rm_usage[] = {
- "git-rm [options] [--] <file>...",
+ "git rm [options] [--] <file>...",
NULL
};
@@ -131,7 +131,7 @@ static struct option builtin_rm_options[] = {
OPT__DRY_RUN(&show_only),
OPT__QUIET(&quiet),
OPT_BOOLEAN( 0 , "cached", &index_only, "only remove from the index"),
- OPT_BOOLEAN('f', NULL, &force, "override the up-to-date check"),
+ OPT_BOOLEAN('f', "force", &force, "override the up-to-date check"),
OPT_BOOLEAN('r', NULL, &recursive, "allow recursive removal"),
OPT_BOOLEAN( 0 , "ignore-unmatch", &ignore_unmatch,
"exit with a zero status even if nothing matched"),
@@ -144,12 +144,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
const char **pathspec;
char *seen;
- git_config(git_default_config);
-
- newfd = hold_locked_index(&lock_file, 1);
-
- if (read_cache() < 0)
- die("index file corrupt");
+ git_config(git_default_config, NULL);
argc = parse_options(argc, argv, builtin_rm_options, builtin_rm_usage, 0);
if (!argc)
@@ -158,6 +153,11 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
if (!index_only)
setup_work_tree();
+ newfd = hold_locked_index(&lock_file, 1);
+
+ if (read_cache() < 0)
+ die("index file corrupt");
+
pathspec = get_pathspec(prefix, argv);
seen = NULL;
for (i = 0; pathspec[i] ; i++)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 8afb1d0bc..7588d2288 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -8,7 +8,7 @@
#include "send-pack.h"
static const char send_pack_usage[] =
-"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
" --all and explicit <ref> specification are mutually exclusive.";
static struct send_pack_args args = {
@@ -71,6 +71,7 @@ static int pack_objects(int fd, struct ref *refs)
refs = refs->next;
}
+ close(po.in);
if (finish_command(&po))
return error("pack-objects died with strange error");
return 0;
@@ -225,8 +226,7 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref)
if (args.verbose)
fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst);
if (ref->deletion) {
- if (delete_ref(rs.dst, NULL))
- error("Failed to delete");
+ delete_ref(rs.dst, NULL);
} else
update_ref("update by push", rs.dst,
ref->new_sha1, NULL, 0, 0);
@@ -263,9 +263,7 @@ static void print_ref_status(char flag, const char *summary, struct ref *to, str
static const char *status_abbrev(unsigned char sha1[20])
{
- const char *abbrev;
- abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
- return abbrev ? abbrev : sha1_to_hex(sha1);
+ return find_unique_abbrev(sha1, DEFAULT_ABBREV);
}
static void print_ok_ref_status(struct ref *ref)
@@ -403,12 +401,15 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
if (!remote_tail)
remote_tail = &remote_refs;
if (match_refs(local_refs, remote_refs, &remote_tail,
- nr_refspec, refspec, flags))
+ nr_refspec, refspec, flags)) {
+ close(out);
return -1;
+ }
if (!remote_refs) {
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
"Perhaps you should specify a branch such as 'master'.\n");
+ close(out);
return 0;
}
@@ -495,12 +496,11 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
packet_flush(out);
if (new_refs && !args.dry_run) {
- if (pack_objects(out, remote_refs) < 0) {
- close(out);
+ if (pack_objects(out, remote_refs) < 0)
return -1;
- }
}
- close(out);
+ else
+ close(out);
if (expect_status_report)
ret = receive_status(in, remote_refs);
@@ -536,9 +536,17 @@ static void verify_remote_names(int nr_heads, const char **heads)
int i;
for (i = 0; i < nr_heads; i++) {
- const char *remote = strchr(heads[i], ':');
+ const char *local = heads[i];
+ const char *remote = strrchr(heads[i], ':');
+
+ if (*local == '+')
+ local++;
+
+ /* A matching refspec is okay. */
+ if (remote == local && remote[1] == '\0')
+ continue;
- remote = remote ? (remote + 1) : heads[i];
+ remote = remote ? (remote + 1) : local;
switch (check_ref_format(remote)) {
case 0: /* ok */
case CHECK_REF_FORMAT_ONELEVEL:
@@ -648,7 +656,7 @@ int send_pack(struct send_pack_args *my_args,
conn = git_connect(fd, dest, args.receivepack, args.verbose ? CONNECT_VERBOSE : 0);
ret = do_send_pack(fd[0], fd[1], remote, dest, nr_heads, heads);
close(fd[0]);
- close(fd[1]);
+ /* do_send_pack always closes fd[1] */
ret |= finish_connect(conn);
return !!ret;
}
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index fa8bc7d02..d03f14fda 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -2,21 +2,24 @@
#include "cache.h"
#include "commit.h"
#include "diff.h"
-#include "path-list.h"
+#include "string-list.h"
#include "revision.h"
#include "utf8.h"
#include "mailmap.h"
+#include "shortlog.h"
+#include "parse-options.h"
-static const char shortlog_usage[] =
-"git-shortlog [-n] [-s] [-e] [<commit-id>... ]";
-
-static char *common_repo_prefix;
-static int email;
+static char const * const shortlog_usage[] = {
+ "git shortlog [-n] [-s] [-e] [-w] [rev-opts] [--] [<commit-id>... ]",
+ "",
+ "[rev-opts] are documented in git-rev-list(1)",
+ NULL
+};
static int compare_by_number(const void *a1, const void *a2)
{
- const struct path_list_item *i1 = a1, *i2 = a2;
- const struct path_list *l1 = i1->util, *l2 = i2->util;
+ const struct string_list_item *i1 = a1, *i2 = a2;
+ const struct string_list *l1 = i1->util, *l2 = i2->util;
if (l1->nr < l2->nr)
return 1;
@@ -26,16 +29,14 @@ static int compare_by_number(const void *a1, const void *a2)
return -1;
}
-static struct path_list mailmap = {NULL, 0, 0, 0};
-
-static void insert_one_record(struct path_list *list,
+static void insert_one_record(struct shortlog *log,
const char *author,
const char *oneline)
{
- const char *dot3 = common_repo_prefix;
+ const char *dot3 = log->common_repo_prefix;
char *buffer, *p;
- struct path_list_item *item;
- struct path_list *onelines;
+ struct string_list_item *item;
+ struct string_list *onelines;
char namebuf[1024];
size_t len;
const char *eol;
@@ -47,7 +48,7 @@ static void insert_one_record(struct path_list *list,
eoemail = strchr(boemail, '>');
if (!eoemail)
return;
- if (!map_email(&mailmap, boemail+1, namebuf, sizeof(namebuf))) {
+ if (!map_email(&log->mailmap, boemail+1, namebuf, sizeof(namebuf))) {
while (author < boemail && isspace(*author))
author++;
for (len = 0;
@@ -61,24 +62,25 @@ static void insert_one_record(struct path_list *list,
else
len = strlen(namebuf);
- if (email) {
+ if (log->email) {
size_t room = sizeof(namebuf) - len - 1;
int maillen = eoemail - boemail + 1;
snprintf(namebuf + len, room, " %.*s", maillen, boemail);
}
buffer = xstrdup(namebuf);
- item = path_list_insert(buffer, list);
+ item = string_list_insert(buffer, &log->list);
if (item->util == NULL)
- item->util = xcalloc(1, sizeof(struct path_list));
+ item->util = xcalloc(1, sizeof(struct string_list));
else
free(buffer);
+ /* Skip any leading whitespace, including any blank lines. */
+ while (*oneline && isspace(*oneline))
+ oneline++;
eol = strchr(oneline, '\n');
if (!eol)
eol = oneline + strlen(oneline);
- while (*oneline && isspace(*oneline) && *oneline != '\n')
- oneline++;
if (!prefixcmp(oneline, "[PATCH")) {
char *eob = strchr(oneline, ']');
if (eob && (!eol || eob < eol))
@@ -107,14 +109,14 @@ static void insert_one_record(struct path_list *list,
onelines->alloc = alloc_nr(onelines->nr);
onelines->items = xrealloc(onelines->items,
onelines->alloc
- * sizeof(struct path_list_item));
+ * sizeof(struct string_list_item));
}
onelines->items[onelines->nr].util = NULL;
- onelines->items[onelines->nr++].path = buffer;
+ onelines->items[onelines->nr++].string = buffer;
}
-static void read_from_stdin(struct path_list *list)
+static void read_from_stdin(struct shortlog *log)
{
char author[1024], oneline[1024];
@@ -128,55 +130,67 @@ static void read_from_stdin(struct path_list *list)
while (fgets(oneline, sizeof(oneline), stdin) &&
oneline[0] == '\n')
; /* discard blanks */
- insert_one_record(list, author + 8, oneline);
+ insert_one_record(log, author + 8, oneline);
}
}
-static void get_from_rev(struct rev_info *rev, struct path_list *list)
+void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
- struct commit *commit;
-
- prepare_revision_walk(rev);
- while ((commit = get_revision(rev)) != NULL) {
- const char *author = NULL, *buffer;
+ const char *author = NULL, *buffer;
- buffer = commit->buffer;
- while (*buffer && *buffer != '\n') {
- const char *eol = strchr(buffer, '\n');
+ buffer = commit->buffer;
+ while (*buffer && *buffer != '\n') {
+ const char *eol = strchr(buffer, '\n');
- if (eol == NULL)
- eol = buffer + strlen(buffer);
- else
- eol++;
+ if (eol == NULL)
+ eol = buffer + strlen(buffer);
+ else
+ eol++;
- if (!prefixcmp(buffer, "author "))
- author = buffer + 7;
- buffer = eol;
- }
- if (!author)
- die("Missing author: %s",
- sha1_to_hex(commit->object.sha1));
- if (*buffer)
- buffer++;
- insert_one_record(list, author, !*buffer ? "<none>" : buffer);
+ if (!prefixcmp(buffer, "author "))
+ author = buffer + 7;
+ buffer = eol;
+ }
+ if (!author)
+ die("Missing author: %s",
+ sha1_to_hex(commit->object.sha1));
+ if (log->user_format) {
+ struct strbuf buf = STRBUF_INIT;
+
+ pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
+ DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
+ insert_one_record(log, author, buf.buf);
+ strbuf_release(&buf);
+ return;
}
+ if (*buffer)
+ buffer++;
+ insert_one_record(log, author, !*buffer ? "<none>" : buffer);
+}
+
+static void get_from_rev(struct rev_info *rev, struct shortlog *log)
+{
+ struct commit *commit;
+
+ if (prepare_revision_walk(rev))
+ die("revision walk setup failed");
+ while ((commit = get_revision(rev)) != NULL)
+ shortlog_add_commit(log, commit);
}
-static int parse_uint(char const **arg, int comma)
+static int parse_uint(char const **arg, int comma, int defval)
{
unsigned long ul;
int ret;
char *endp;
ul = strtoul(*arg, &endp, 10);
- if (endp != *arg && *endp && *endp != comma)
+ if (*endp && *endp != comma)
return -1;
- ret = (int) ul;
- if (ret != ul)
+ if (ul > INT_MAX)
return -1;
- *arg = endp;
- if (**arg)
- (*arg)++;
+ ret = *arg == endp ? defval : (int)ul;
+ *arg = *endp ? endp + 1 : endp;
return ret;
}
@@ -185,96 +199,121 @@ static const char wrap_arg_usage[] = "-w[<width>[,<indent1>[,<indent2>]]]";
#define DEFAULT_INDENT1 6
#define DEFAULT_INDENT2 9
-static void parse_wrap_args(const char *arg, int *in1, int *in2, int *wrap)
+static int parse_wrap_args(const struct option *opt, const char *arg, int unset)
{
- arg += 2; /* skip -w */
-
- *wrap = parse_uint(&arg, ',');
- if (*wrap < 0)
- die(wrap_arg_usage);
- *in1 = parse_uint(&arg, ',');
- if (*in1 < 0)
- die(wrap_arg_usage);
- *in2 = parse_uint(&arg, '\0');
- if (*in2 < 0)
- die(wrap_arg_usage);
-
- if (!*wrap)
- *wrap = DEFAULT_WRAPLEN;
- if (!*in1)
- *in1 = DEFAULT_INDENT1;
- if (!*in2)
- *in2 = DEFAULT_INDENT2;
- if (*wrap &&
- ((*in1 && *wrap <= *in1) ||
- (*in2 && *wrap <= *in2)))
- die(wrap_arg_usage);
+ struct shortlog *log = opt->value;
+
+ log->wrap_lines = !unset;
+ if (unset)
+ return 0;
+ if (!arg) {
+ log->wrap = DEFAULT_WRAPLEN;
+ log->in1 = DEFAULT_INDENT1;
+ log->in2 = DEFAULT_INDENT2;
+ return 0;
+ }
+
+ log->wrap = parse_uint(&arg, ',', DEFAULT_WRAPLEN);
+ log->in1 = parse_uint(&arg, ',', DEFAULT_INDENT1);
+ log->in2 = parse_uint(&arg, '\0', DEFAULT_INDENT2);
+ if (log->wrap < 0 || log->in1 < 0 || log->in2 < 0)
+ return error(wrap_arg_usage);
+ if (log->wrap &&
+ ((log->in1 && log->wrap <= log->in1) ||
+ (log->in2 && log->wrap <= log->in2)))
+ return error(wrap_arg_usage);
+ return 0;
+}
+
+void shortlog_init(struct shortlog *log)
+{
+ memset(log, 0, sizeof(*log));
+
+ read_mailmap(&log->mailmap, ".mailmap", &log->common_repo_prefix);
+
+ log->list.strdup_strings = 1;
+ log->wrap = DEFAULT_WRAPLEN;
+ log->in1 = DEFAULT_INDENT1;
+ log->in2 = DEFAULT_INDENT2;
}
int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
- struct rev_info rev;
- struct path_list list = { NULL, 0, 0, 1 };
- int i, j, sort_by_number = 0, summary = 0;
- int wrap_lines = 0;
- int wrap = DEFAULT_WRAPLEN;
- int in1 = DEFAULT_INDENT1;
- int in2 = DEFAULT_INDENT2;
-
- /* since -n is a shadowed rev argument, parse our args first */
- while (argc > 1) {
- if (!strcmp(argv[1], "-n") || !strcmp(argv[1], "--numbered"))
- sort_by_number = 1;
- else if (!strcmp(argv[1], "-s") ||
- !strcmp(argv[1], "--summary"))
- summary = 1;
- else if (!strcmp(argv[1], "-e") ||
- !strcmp(argv[1], "--email"))
- email = 1;
- else if (!prefixcmp(argv[1], "-w")) {
- wrap_lines = 1;
- parse_wrap_args(argv[1], &in1, &in2, &wrap);
+ static struct shortlog log;
+ static struct rev_info rev;
+ int nongit;
+
+ static const struct option options[] = {
+ OPT_BOOLEAN('n', "numbered", &log.sort_by_number,
+ "sort output according to the number of commits per author"),
+ OPT_BOOLEAN('s', "summary", &log.summary,
+ "Suppress commit descriptions, only provides commit count"),
+ OPT_BOOLEAN('e', "email", &log.email,
+ "Show the email address of each author"),
+ { OPTION_CALLBACK, 'w', NULL, &log, "w[,i1[,i2]]",
+ "Linewrap output", PARSE_OPT_OPTARG, &parse_wrap_args },
+ OPT_END(),
+ };
+
+ struct parse_opt_ctx_t ctx;
+
+ prefix = setup_git_directory_gently(&nongit);
+ shortlog_init(&log);
+ init_revisions(&rev, prefix);
+ parse_options_start(&ctx, argc, argv, PARSE_OPT_KEEP_DASHDASH |
+ PARSE_OPT_KEEP_ARGV0);
+
+ for (;;) {
+ switch (parse_options_step(&ctx, options, shortlog_usage)) {
+ case PARSE_OPT_HELP:
+ exit(129);
+ case PARSE_OPT_DONE:
+ goto parse_done;
}
- else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
- usage(shortlog_usage);
- else
- break;
- argv++;
- argc--;
+ parse_revision_opt(&rev, &ctx, options, shortlog_usage);
}
- init_revisions(&rev, prefix);
- argc = setup_revisions(argc, argv, &rev, NULL);
- if (argc > 1)
- die ("unrecognized argument: %s", argv[1]);
+parse_done:
+ argc = parse_options_end(&ctx);
- read_mailmap(&mailmap, ".mailmap", &common_repo_prefix);
+ if (setup_revisions(argc, argv, &rev, NULL) != 1) {
+ error("unrecognized argument: %s", argv[1]);
+ usage_with_options(shortlog_usage, options);
+ }
+
+ log.user_format = rev.commit_format == CMIT_FMT_USERFORMAT;
/* assume HEAD if from a tty */
- if (!rev.pending.nr && isatty(0))
+ if (!nongit && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev);
if (rev.pending.nr == 0) {
- read_from_stdin(&list);
+ read_from_stdin(&log);
}
else
- get_from_rev(&rev, &list);
+ get_from_rev(&rev, &log);
- if (sort_by_number)
- qsort(list.items, list.nr, sizeof(struct path_list_item),
- compare_by_number);
+ shortlog_output(&log);
+ return 0;
+}
- for (i = 0; i < list.nr; i++) {
- struct path_list *onelines = list.items[i].util;
+void shortlog_output(struct shortlog *log)
+{
+ int i, j;
+ if (log->sort_by_number)
+ qsort(log->list.items, log->list.nr, sizeof(struct string_list_item),
+ compare_by_number);
+ for (i = 0; i < log->list.nr; i++) {
+ struct string_list *onelines = log->list.items[i].util;
- if (summary) {
- printf("%6d\t%s\n", onelines->nr, list.items[i].path);
+ if (log->summary) {
+ printf("%6d\t%s\n", onelines->nr, log->list.items[i].string);
} else {
- printf("%s (%d):\n", list.items[i].path, onelines->nr);
+ printf("%s (%d):\n", log->list.items[i].string, onelines->nr);
for (j = onelines->nr - 1; j >= 0; j--) {
- const char *msg = onelines->items[j].path;
+ const char *msg = onelines->items[j].string;
- if (wrap_lines) {
- int col = print_wrapped_text(msg, in1, in2, wrap);
- if (col != wrap)
+ if (log->wrap_lines) {
+ int col = print_wrapped_text(msg, log->in1, log->in2, log->wrap);
+ if (col != log->wrap)
putchar('\n');
}
else
@@ -283,16 +322,14 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
putchar('\n');
}
- onelines->strdup_paths = 1;
- path_list_clear(onelines, 1);
+ onelines->strdup_strings = 1;
+ string_list_clear(onelines, 1);
free(onelines);
- list.items[i].util = NULL;
+ log->list.items[i].util = NULL;
}
- list.strdup_paths = 1;
- path_list_clear(&list, 1);
- mailmap.strdup_paths = 1;
- path_list_clear(&mailmap, 1);
-
- return 0;
+ log->list.strdup_strings = 1;
+ string_list_clear(&log->list, 1);
+ log->mailmap.strdup_strings = 1;
+ string_list_clear(&log->mailmap, 1);
}
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 6dc835d30..233eed499 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -4,7 +4,7 @@
#include "builtin.h"
static const char show_branch_usage[] =
-"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n[,b]] <branch>";
+"git show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n[,b]] <branch>";
static const char show_branch_usage_reflog[] =
"--reflog is incompatible with --all, --remotes, --independent or --merge-base";
@@ -533,9 +533,11 @@ static void append_one_rev(const char *av)
die("bad sha1 reference %s", av);
}
-static int git_show_branch_config(const char *var, const char *value)
+static int git_show_branch_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "showbranch.default")) {
+ if (!value)
+ return config_error_nonbool(var);
if (default_alloc <= default_num + 1) {
default_alloc = default_alloc * 3 / 2 + 20;
default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
@@ -545,7 +547,7 @@ static int git_show_branch_config(const char *var, const char *value)
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
@@ -609,7 +611,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
int reflog = 0;
const char *reflog_base = NULL;
- git_config(git_show_branch_config);
+ git_config(git_show_branch_config, NULL);
/* If nothing is specified, try the default first */
if (ac == 1 && default_num) {
@@ -780,8 +782,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
has_head++;
}
if (!has_head) {
- int pfxlen = strlen("refs/heads/");
- append_one_rev(head + pfxlen);
+ int offset = !prefixcmp(head, "refs/heads/") ? 11 : 0;
+ append_one_rev(head + offset);
}
}
diff --git a/builtin-show-ref.c b/builtin-show-ref.c
index 65051d14f..add16004f 100644
--- a/builtin-show-ref.c
+++ b/builtin-show-ref.c
@@ -3,7 +3,7 @@
#include "refs.h"
#include "object.h"
#include "tag.h"
-#include "path-list.h"
+#include "string-list.h"
static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list";
@@ -86,6 +86,9 @@ match:
sha1_to_hex(sha1));
if (obj->type == OBJ_TAG) {
obj = deref_tag(obj, refname, 0);
+ if (!obj)
+ die("git-show-ref: bad tag at ref %s (%s)", refname,
+ sha1_to_hex(sha1));
hex = find_unique_abbrev(obj->sha1, abbrev);
printf("%s %s^{}\n", hex, refname);
}
@@ -95,8 +98,8 @@ match:
static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
{
- struct path_list *list = (struct path_list *)cbdata;
- path_list_insert(refname, list);
+ struct string_list *list = (struct string_list *)cbdata;
+ string_list_insert(refname, list);
return 0;
}
@@ -111,7 +114,7 @@ static int add_existing(const char *refname, const unsigned char *sha1, int flag
*/
static int exclude_existing(const char *match)
{
- static struct path_list existing_refs = { NULL, 0, 0, 0 };
+ static struct string_list existing_refs = { NULL, 0, 0, 0 };
char buf[1024];
int matchlen = match ? strlen(match) : 0;
@@ -140,7 +143,7 @@ static int exclude_existing(const char *match)
fprintf(stderr, "warning: ref '%s' ignored\n", ref);
continue;
}
- if (!path_list_has_path(&existing_refs, ref)) {
+ if (!string_list_has_string(&existing_refs, ref)) {
printf("%s\n", buf);
}
}
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index d33982b96..bfc78bb3f 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -4,7 +4,7 @@
#include "parse-options.h"
static const char * const git_symbolic_ref_usage[] = {
- "git-symbolic-ref [options] name [ref]",
+ "git symbolic-ref [options] name [ref]",
NULL
};
@@ -35,7 +35,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
OPT_END(),
};
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
argc = parse_options(argc, argv, options, git_symbolic_ref_usage, 0);
if (msg &&!*msg)
die("Refusing to perform update with empty message");
diff --git a/builtin-tag.c b/builtin-tag.c
index 03e70155f..f2853d08c 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -14,64 +14,15 @@
#include "parse-options.h"
static const char * const git_tag_usage[] = {
- "git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
- "git-tag -d <tagname>...",
- "git-tag -l [-n [<num>]] [<pattern>]",
- "git-tag -v <tagname>...",
+ "git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
+ "git tag -d <tagname>...",
+ "git tag -l [-n[<num>]] [<pattern>]",
+ "git tag -v <tagname>...",
NULL
};
static char signingkey[1000];
-void launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
-{
- const char *editor, *terminal;
-
- editor = getenv("GIT_EDITOR");
- if (!editor && editor_program)
- editor = editor_program;
- if (!editor)
- editor = getenv("VISUAL");
- if (!editor)
- editor = getenv("EDITOR");
-
- terminal = getenv("TERM");
- if (!editor && (!terminal || !strcmp(terminal, "dumb"))) {
- fprintf(stderr,
- "Terminal is dumb but no VISUAL nor EDITOR defined.\n"
- "Please supply the message using either -m or -F option.\n");
- exit(1);
- }
-
- if (!editor)
- editor = "vi";
-
- if (strcmp(editor, ":")) {
- size_t len = strlen(editor);
- int i = 0;
- const char *args[6];
-
- if (strcspn(editor, "$ \t'") != len) {
- /* there are specials */
- args[i++] = "sh";
- args[i++] = "-c";
- args[i++] = "$0 \"$@\"";
- }
- args[i++] = editor;
- args[i++] = path;
- args[i] = NULL;
-
- if (run_command_v_opt_cd_env(args, 0, NULL, env))
- die("There was a problem with the editor %s.", editor);
- }
-
- if (!buffer)
- return;
- if (strbuf_read_file(buffer, path, 0) < 0)
- die("could not read message file '%s': %s",
- path, strerror(errno));
-}
-
struct tag_filter {
const char *pattern;
int lines;
@@ -198,6 +149,7 @@ static int do_sign(struct strbuf *buffer)
const char *args[4];
char *bracket;
int len;
+ int i, j;
if (!*signingkey) {
if (strlcpy(signingkey, git_committer_info(IDENT_ERROR_ON_NO_NAME),
@@ -226,18 +178,25 @@ static int do_sign(struct strbuf *buffer)
if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
close(gpg.in);
+ close(gpg.out);
finish_command(&gpg);
return error("gpg did not accept the tag data");
}
close(gpg.in);
- gpg.close_in = 0;
len = strbuf_read(buffer, gpg.out, 1024);
+ close(gpg.out);
if (finish_command(&gpg) || !len || len < 0)
return error("gpg failed to sign the tag");
- if (len < 0)
- return error("could not read the entire signature from gpg.");
+ /* Strip CR from the line endings, in case we are on Windows. */
+ for (i = j = 0; i < buffer->len; i++)
+ if (buffer->buf[i] != '\r') {
+ if (i != j)
+ buffer->buf[j] = buffer->buf[i];
+ j++;
+ }
+ strbuf_setlen(buffer, j);
return 0;
}
@@ -254,16 +213,16 @@ static void set_signingkey(const char *value)
die("signing key value too long (%.10s...)", value);
}
-static int git_tag_config(const char *var, const char *value)
+static int git_tag_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "user.signingkey")) {
if (!value)
- die("user.signingkey without value");
+ return config_error_nonbool(var);
set_signingkey(value);
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
static void write_tag_body(int fd, const unsigned char *sha1)
@@ -336,7 +295,11 @@ static void create_tag(const unsigned char *object, const char *tag,
write_or_die(fd, tag_template, strlen(tag_template));
close(fd);
- launch_editor(path, buf, NULL);
+ if (launch_editor(path, buf, NULL)) {
+ fprintf(stderr,
+ "Please supply the message using either -m or -F option.\n");
+ exit(1);
+ }
unlink(path);
free(path);
@@ -383,7 +346,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
int annotate = 0, sign = 0, force = 0, lines = 0,
list = 0, delete = 0, verify = 0;
- char *msgfile = NULL, *keyid = NULL;
+ const char *msgfile = NULL, *keyid = NULL;
struct msg_arg msg = { 0, STRBUF_INIT };
struct option options[] = {
OPT_BOOLEAN('l', NULL, &list, "list tag names"),
@@ -406,9 +369,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
OPT_END()
};
- git_config(git_tag_config);
+ git_config(git_tag_config, NULL);
argc = parse_options(argc, argv, options, git_tag_usage, 0);
+ msgfile = parse_options_fix_filename(prefix, msgfile);
if (keyid) {
sign = 1;
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index b04719ef2..f4bea4a32 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -8,7 +8,7 @@
#include "quote.h"
static const char tar_tree_usage[] =
-"git-tar-tree [--remote=<repo>] <tree-ish> [basedir]\n"
+"git tar-tree [--remote=<repo>] <tree-ish> [basedir]\n"
"*** Note that this command is now deprecated; use git-archive instead.";
int cmd_tar_tree(int argc, const char **argv, const char *prefix)
diff --git a/builtin-unpack-objects.c b/builtin-unpack-objects.c
index 1e51865c5..a89186666 100644
--- a/builtin-unpack-objects.c
+++ b/builtin-unpack-objects.c
@@ -7,10 +7,13 @@
#include "commit.h"
#include "tag.h"
#include "tree.h"
+#include "tree-walk.h"
#include "progress.h"
+#include "decorate.h"
+#include "fsck.h"
-static int dry_run, quiet, recover, has_errors;
-static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
+static int dry_run, quiet, recover, has_errors, strict;
+static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] [--strict] < pack-file";
/* We always read in 4kB chunks. */
static unsigned char buffer[4096];
@@ -19,6 +22,33 @@ static off_t consumed_bytes;
static SHA_CTX ctx;
/*
+ * When running under --strict mode, objects whose reachability are
+ * suspect are kept in core without getting written in the object
+ * store.
+ */
+struct obj_buffer {
+ char *buffer;
+ unsigned long size;
+};
+
+static struct decoration obj_decorate;
+
+static struct obj_buffer *lookup_object_buffer(struct object *base)
+{
+ return lookup_decoration(&obj_decorate, base);
+}
+
+static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
+{
+ struct obj_buffer *obj;
+ obj = xcalloc(1, sizeof(struct obj_buffer));
+ obj->buffer = buffer;
+ obj->size = size;
+ if (add_decoration(&obj_decorate, object, obj))
+ die("object %s tried to add buffer twice!", sha1_to_hex(object->sha1));
+}
+
+/*
* Make sure at least "min" bytes are available in the buffer, and
* return the pointer to the buffer.
*/
@@ -121,19 +151,110 @@ static void add_delta_to_list(unsigned nr, unsigned const char *base_sha1,
struct obj_info {
off_t offset;
unsigned char sha1[20];
+ struct object *obj;
};
+#define FLAG_OPEN (1u<<20)
+#define FLAG_WRITTEN (1u<<21)
+
static struct obj_info *obj_list;
+unsigned nr_objects;
+
+/*
+ * Called only from check_object() after it verified this object
+ * is Ok.
+ */
+static void write_cached_object(struct object *obj)
+{
+ unsigned char sha1[20];
+ struct obj_buffer *obj_buf = lookup_object_buffer(obj);
+ if (write_sha1_file(obj_buf->buffer, obj_buf->size, typename(obj->type), sha1) < 0)
+ die("failed to write object %s", sha1_to_hex(obj->sha1));
+ obj->flags |= FLAG_WRITTEN;
+}
+
+/*
+ * At the very end of the processing, write_rest() scans the objects
+ * that have reachability requirements and calls this function.
+ * Verify its reachability and validity recursively and write it out.
+ */
+static int check_object(struct object *obj, int type, void *data)
+{
+ if (!obj)
+ return 0;
+
+ if (obj->flags & FLAG_WRITTEN)
+ return 1;
+
+ if (type != OBJ_ANY && obj->type != type)
+ die("object type mismatch");
+
+ if (!(obj->flags & FLAG_OPEN)) {
+ unsigned long size;
+ int type = sha1_object_info(obj->sha1, &size);
+ if (type != obj->type || type <= 0)
+ die("object of unexpected type");
+ obj->flags |= FLAG_WRITTEN;
+ return 1;
+ }
+
+ if (fsck_object(obj, 1, fsck_error_function))
+ die("Error in object");
+ if (!fsck_walk(obj, check_object, 0))
+ die("Error on reachable objects of %s", sha1_to_hex(obj->sha1));
+ write_cached_object(obj);
+ return 1;
+}
+
+static void write_rest(void)
+{
+ unsigned i;
+ for (i = 0; i < nr_objects; i++)
+ check_object(obj_list[i].obj, OBJ_ANY, 0);
+}
static void added_object(unsigned nr, enum object_type type,
void *data, unsigned long size);
+/*
+ * Write out nr-th object from the list, now we know the contents
+ * of it. Under --strict, this buffers structured objects in-core,
+ * to be checked at the end.
+ */
static void write_object(unsigned nr, enum object_type type,
void *buf, unsigned long size)
{
- if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
- die("failed to write object");
- added_object(nr, type, buf, size);
+ if (!strict) {
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ die("failed to write object");
+ added_object(nr, type, buf, size);
+ free(buf);
+ obj_list[nr].obj = NULL;
+ } else if (type == OBJ_BLOB) {
+ struct blob *blob;
+ if (write_sha1_file(buf, size, typename(type), obj_list[nr].sha1) < 0)
+ die("failed to write object");
+ added_object(nr, type, buf, size);
+ free(buf);
+
+ blob = lookup_blob(obj_list[nr].sha1);
+ if (blob)
+ blob->object.flags |= FLAG_WRITTEN;
+ else
+ die("invalid blob object");
+ obj_list[nr].obj = NULL;
+ } else {
+ struct object *obj;
+ int eaten;
+ hash_sha1_file(buf, size, typename(type), obj_list[nr].sha1);
+ added_object(nr, type, buf, size);
+ obj = parse_object_buffer(obj_list[nr].sha1, type, size, buf, &eaten);
+ if (!obj)
+ die("invalid %s", typename(type));
+ add_object_buffer(obj, buf, size);
+ obj->flags |= FLAG_OPEN;
+ obj_list[nr].obj = obj;
+ }
}
static void resolve_delta(unsigned nr, enum object_type type,
@@ -150,9 +271,12 @@ static void resolve_delta(unsigned nr, enum object_type type,
die("failed to apply delta");
free(delta);
write_object(nr, type, result, result_size);
- free(result);
}
+/*
+ * We now know the contents of an object (which is nr-th in the pack);
+ * resolve all the deltified objects that are based on it.
+ */
static void added_object(unsigned nr, enum object_type type,
void *data, unsigned long size)
{
@@ -180,7 +304,24 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,
if (!dry_run && buf)
write_object(nr, type, buf, size);
- free(buf);
+ else
+ free(buf);
+}
+
+static int resolve_against_held(unsigned nr, const unsigned char *base,
+ void *delta_data, unsigned long delta_size)
+{
+ struct object *obj;
+ struct obj_buffer *obj_buffer;
+ obj = lookup_object(base);
+ if (!obj)
+ return 0;
+ obj_buffer = lookup_object_buffer(obj);
+ if (!obj_buffer)
+ return 0;
+ resolve_delta(nr, obj->type, obj_buffer->buffer,
+ obj_buffer->size, delta_data, delta_size);
+ return 1;
}
static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
@@ -198,7 +339,13 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
free(delta_data);
return;
}
- if (!has_sha1_file(base_sha1)) {
+ if (has_sha1_file(base_sha1))
+ ; /* Ok we have this one */
+ else if (resolve_against_held(nr, base_sha1,
+ delta_data, delta_size))
+ return; /* we are done */
+ else {
+ /* cannot resolve yet --- queue it */
hashcpy(obj_list[nr].sha1, null_sha1);
add_delta_to_list(nr, base_sha1, 0, delta_data, delta_size);
return;
@@ -244,14 +391,19 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
}
}
if (!base_found) {
- /* The delta base object is itself a delta that
- has not been resolved yet. */
+ /*
+ * The delta base object is itself a delta that
+ * has not been resolved yet.
+ */
hashcpy(obj_list[nr].sha1, null_sha1);
add_delta_to_list(nr, null_sha1, base_offset, delta_data, delta_size);
return;
}
}
+ if (resolve_against_held(nr, base_sha1, delta_data, delta_size))
+ return;
+
base = read_sha1_file(base_sha1, &type, &base_size);
if (!base) {
error("failed to read delta-pack base object %s",
@@ -313,17 +465,20 @@ static void unpack_all(void)
int i;
struct progress *progress = NULL;
struct pack_header *hdr = fill(sizeof(struct pack_header));
- unsigned nr_objects = ntohl(hdr->hdr_entries);
+
+ nr_objects = ntohl(hdr->hdr_entries);
if (ntohl(hdr->hdr_signature) != PACK_SIGNATURE)
die("bad pack file");
if (!pack_version_ok(hdr->hdr_version))
- die("unknown pack file version %d", ntohl(hdr->hdr_version));
+ die("unknown pack file version %"PRIu32,
+ ntohl(hdr->hdr_version));
use(sizeof(struct pack_header));
if (!quiet)
progress = start_progress("Unpacking objects", nr_objects);
obj_list = xmalloc(nr_objects * sizeof(*obj_list));
+ memset(obj_list, 0, nr_objects * sizeof(*obj_list));
for (i = 0; i < nr_objects; i++) {
unpack_one(i);
display_progress(progress, i + 1);
@@ -339,7 +494,7 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
int i;
unsigned char sha1[20];
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
quiet = !isatty(2);
@@ -359,6 +514,10 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
recover = 1;
continue;
}
+ if (!strcmp(arg, "--strict")) {
+ strict = 1;
+ continue;
+ }
if (!prefixcmp(arg, "--pack_header=")) {
struct pack_header *hdr;
char *c;
@@ -384,6 +543,8 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
unpack_all();
SHA1_Update(&ctx, buffer, offset);
SHA1_Final(sha1, &ctx);
+ if (strict)
+ write_rest();
if (hashcmp(fill(20), sha1))
die("final sha1 did not match");
use(20);
diff --git a/builtin-update-index.c b/builtin-update-index.c
index a8795d3d5..38eb53ccb 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -387,7 +387,7 @@ static void read_index_info(int line_termination)
}
static const char update_index_usage[] =
-"git-update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
+"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
static unsigned char head_sha1[20];
static unsigned char merge_head_sha1[20];
@@ -567,7 +567,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
int lock_error = 0;
struct lock_file *lock_file;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
/* We can't free this memory, it becomes part of a linked list parsed atexit() */
lock_file = xcalloc(1, sizeof(struct lock_file));
@@ -593,6 +593,10 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
refresh_flags |= REFRESH_QUIET;
continue;
}
+ if (!strcmp(path, "--ignore-submodules")) {
+ refresh_flags |= REFRESH_IGNORE_SUBMODULES;
+ continue;
+ }
if (!strcmp(path, "--add")) {
allow_add = 1;
continue;
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index e90737c35..56a0b1b39 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -4,14 +4,14 @@
#include "parse-options.h"
static const char * const git_update_ref_usage[] = {
- "git-update-ref [options] -d <refname> <oldval>",
- "git-update-ref [options] <refname> <newval> [<oldval>]",
+ "git update-ref [options] -d <refname> [<oldval>]",
+ "git update-ref [options] <refname> <newval> [<oldval>]",
NULL
};
int cmd_update_ref(int argc, const char **argv, const char *prefix)
{
- const char *refname, *value, *oldval, *msg=NULL;
+ const char *refname, *oldval, *msg=NULL;
unsigned char sha1[20], oldsha1[20];
int delete = 0, no_deref = 0;
struct option options[] = {
@@ -22,30 +22,34 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
OPT_END(),
};
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
argc = parse_options(argc, argv, options, git_update_ref_usage, 0);
if (msg && !*msg)
die("Refusing to perform update with empty message.");
- if (argc < 2 || argc > 3)
- usage_with_options(git_update_ref_usage, options);
- refname = argv[0];
- value = argv[1];
- oldval = argv[2];
-
- if (get_sha1(value, sha1))
- die("%s: not a valid SHA1", value);
-
if (delete) {
- if (oldval)
+ if (argc < 1 || argc > 2)
+ usage_with_options(git_update_ref_usage, options);
+ refname = argv[0];
+ oldval = argv[1];
+ } else {
+ const char *value;
+ if (argc < 2 || argc > 3)
usage_with_options(git_update_ref_usage, options);
- return delete_ref(refname, sha1);
+ refname = argv[0];
+ value = argv[1];
+ oldval = argv[2];
+ if (get_sha1(value, sha1))
+ die("%s: not a valid SHA1", value);
}
- hashclr(oldsha1);
+ hashclr(oldsha1); /* all-zero hash in case oldval is the empty string */
if (oldval && *oldval && get_sha1(oldval, oldsha1))
die("%s: not a valid old SHA1", oldval);
- return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
- no_deref ? REF_NODEREF : 0, DIE_ON_ERR);
+ if (delete)
+ return delete_ref(refname, oldval ? oldsha1 : NULL);
+ else
+ return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
+ no_deref ? REF_NODEREF : 0, DIE_ON_ERR);
}
diff --git a/builtin-upload-archive.c b/builtin-upload-archive.c
index 48ae09e9b..a9b02fa32 100644
--- a/builtin-upload-archive.c
+++ b/builtin-upload-archive.c
@@ -8,29 +8,28 @@
#include "sideband.h"
static const char upload_archive_usage[] =
- "git-upload-archive <repo>";
+ "git upload-archive <repo>";
static const char deadchild[] =
-"git-upload-archive: archiver died with error";
+"git upload-archive: archiver died with error";
static const char lostchild[] =
-"git-upload-archive: archiver process was lost";
+"git upload-archive: archiver process was lost";
+#define MAX_ARGS (64)
static int run_upload_archive(int argc, const char **argv, const char *prefix)
{
- struct archiver ar;
const char *sent_argv[MAX_ARGS];
const char *arg_cmd = "argument ";
char *p, buf[4096];
- int treeish_idx;
int sent_argc;
int len;
if (argc != 2)
usage(upload_archive_usage);
- if (strlen(argv[1]) > sizeof(buf))
+ if (strlen(argv[1]) + 1 > sizeof(buf))
die("insanely long repository name");
strcpy(buf, argv[1]); /* enter-repo smudges its argument */
@@ -47,7 +46,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
if (len == 0)
break; /* got a flush */
if (sent_argc > MAX_ARGS - 2)
- die("Too many options (>29)");
+ die("Too many options (>%d)", MAX_ARGS - 2);
if (p[len-1] == '\n') {
p[--len] = 0;
@@ -65,12 +64,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
sent_argv[sent_argc] = NULL;
/* parse all options sent by the client */
- treeish_idx = parse_archive_args(sent_argc, sent_argv, &ar);
-
- parse_treeish_arg(sent_argv + treeish_idx, &ar.args, prefix);
- parse_pathspec_arg(sent_argv + treeish_idx + 1, &ar.args);
-
- return ar.write_archive(&ar.args);
+ return write_archive(sent_argc, sent_argv, prefix, 0);
}
static void error_clnt(const char *fmt, ...)
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
index 4e31c273f..f4ac59569 100644
--- a/builtin-verify-pack.c
+++ b/builtin-verify-pack.c
@@ -2,6 +2,58 @@
#include "cache.h"
#include "pack.h"
+
+#define MAX_CHAIN 50
+
+static void show_pack_info(struct packed_git *p)
+{
+ uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
+
+ nr_objects = p->num_objects;
+ memset(chain_histogram, 0, sizeof(chain_histogram));
+
+ for (i = 0; i < nr_objects; i++) {
+ const unsigned char *sha1;
+ unsigned char base_sha1[20];
+ const char *type;
+ unsigned long size;
+ unsigned long store_size;
+ off_t offset;
+ unsigned int delta_chain_length;
+
+ sha1 = nth_packed_object_sha1(p, i);
+ if (!sha1)
+ die("internal error pack-check nth-packed-object");
+ offset = nth_packed_object_offset(p, i);
+ type = packed_object_info_detail(p, offset, &size, &store_size,
+ &delta_chain_length,
+ base_sha1);
+ printf("%s ", sha1_to_hex(sha1));
+ if (!delta_chain_length)
+ printf("%-6s %lu %lu %"PRIuMAX"\n",
+ type, size, store_size, (uintmax_t)offset);
+ else {
+ printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
+ type, size, store_size, (uintmax_t)offset,
+ delta_chain_length, sha1_to_hex(base_sha1));
+ if (delta_chain_length <= MAX_CHAIN)
+ chain_histogram[delta_chain_length]++;
+ else
+ chain_histogram[0]++;
+ }
+ }
+
+ for (i = 0; i <= MAX_CHAIN; i++) {
+ if (!chain_histogram[i])
+ continue;
+ printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
+ chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
+ }
+ if (chain_histogram[0])
+ printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
+ chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
+}
+
static int verify_one_pack(const char *path, int verbose)
{
char arg[PATH_MAX];
@@ -40,8 +92,17 @@ static int verify_one_pack(const char *path, int verbose)
if (!pack)
return error("packfile %s not found.", arg);
- err = verify_pack(pack, verbose);
- free(pack);
+ install_packed_git(pack);
+ err = verify_pack(pack);
+
+ if (verbose) {
+ if (err)
+ printf("%s: bad\n", pack->pack_name);
+ else {
+ show_pack_info(pack);
+ printf("%s: ok\n", pack->pack_name);
+ }
+ }
return err;
}
@@ -55,7 +116,7 @@ int cmd_verify_pack(int argc, const char **argv, const char *prefix)
int no_more_options = 0;
int nothing_done = 1;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
while (1 < argc) {
if (!no_more_options && argv[1][0] == '-') {
if (!strcmp("-v", argv[1]))
diff --git a/builtin-verify-tag.c b/builtin-verify-tag.c
index cc4c55d7e..729a1593e 100644
--- a/builtin-verify-tag.c
+++ b/builtin-verify-tag.c
@@ -12,7 +12,7 @@
#include <signal.h>
static const char builtin_verify_tag_usage[] =
- "git-verify-tag [-v|--verbose] <tag>...";
+ "git verify-tag [-v|--verbose] <tag>...";
#define PGP_SIGNATURE "-----BEGIN PGP SIGNATURE-----"
@@ -45,14 +45,14 @@ static int run_gpg_verify(const char *buf, unsigned long size, int verbose)
memset(&gpg, 0, sizeof(gpg));
gpg.argv = args_gpg;
gpg.in = -1;
- gpg.out = 1;
args_gpg[2] = path;
- if (start_command(&gpg))
+ if (start_command(&gpg)) {
+ unlink(path);
return error("could not run gpg.");
+ }
write_in_full(gpg.in, buf, len);
close(gpg.in);
- gpg.close_in = 0;
ret = finish_command(&gpg);
unlink(path);
@@ -90,16 +90,17 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
{
int i = 1, verbose = 0, had_error = 0;
- git_config(git_default_config);
-
- if (argc == 1)
- usage(builtin_verify_tag_usage);
+ git_config(git_default_config, NULL);
- if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")) {
+ if (argc > 1 &&
+ (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose"))) {
verbose = 1;
i++;
}
+ if (argc <= i)
+ usage(builtin_verify_tag_usage);
+
/* sometimes the program was terminated because this signal
* was received in the process of writing the gpg input: */
signal(SIGPIPE, SIG_IGN);
diff --git a/builtin-write-tree.c b/builtin-write-tree.c
index d16b9ed00..52a3c015f 100644
--- a/builtin-write-tree.c
+++ b/builtin-write-tree.c
@@ -9,67 +9,16 @@
#include "cache-tree.h"
static const char write_tree_usage[] =
-"git-write-tree [--missing-ok] [--prefix=<prefix>/]";
-
-int write_tree(unsigned char *sha1, int missing_ok, const char *prefix)
-{
- int entries, was_valid, newfd;
-
- /* We can't free this memory, it becomes part of a linked list parsed atexit() */
- struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
-
- newfd = hold_locked_index(lock_file, 1);
-
- entries = read_cache();
- if (entries < 0)
- die("git-write-tree: error reading cache");
-
- if (!active_cache_tree)
- active_cache_tree = cache_tree();
-
- was_valid = cache_tree_fully_valid(active_cache_tree);
-
- if (!was_valid) {
- if (cache_tree_update(active_cache_tree,
- active_cache, active_nr,
- missing_ok, 0) < 0)
- die("git-write-tree: error building trees");
- if (0 <= newfd) {
- if (!write_cache(newfd, active_cache, active_nr) &&
- !commit_lock_file(lock_file))
- newfd = -1;
- }
- /* Not being able to write is fine -- we are only interested
- * in updating the cache-tree part, and if the next caller
- * ends up using the old index with unupdated cache-tree part
- * it misses the work we did here, but that is just a
- * performance penalty and not a big deal.
- */
- }
-
- if (prefix) {
- struct cache_tree *subtree =
- cache_tree_find(active_cache_tree, prefix);
- if (!subtree)
- die("git-write-tree: prefix %s not found", prefix);
- hashcpy(sha1, subtree->sha1);
- }
- else
- hashcpy(sha1, active_cache_tree->sha1);
-
- if (0 <= newfd)
- rollback_lock_file(lock_file);
-
- return 0;
-}
+"git write-tree [--missing-ok] [--prefix=<prefix>/]";
int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
{
int missing_ok = 0, ret;
const char *prefix = NULL;
unsigned char sha1[20];
+ const char *me = "git-write-tree";
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--missing-ok"))
@@ -84,8 +33,20 @@ int cmd_write_tree(int argc, const char **argv, const char *unused_prefix)
if (argc > 2)
die("too many options");
- ret = write_tree(sha1, missing_ok, prefix);
- printf("%s\n", sha1_to_hex(sha1));
-
+ ret = write_cache_as_tree(sha1, missing_ok, prefix);
+ switch (ret) {
+ case 0:
+ printf("%s\n", sha1_to_hex(sha1));
+ break;
+ case WRITE_TREE_UNREADABLE_INDEX:
+ die("%s: error reading the index", me);
+ break;
+ case WRITE_TREE_UNMERGED_INDEX:
+ die("%s: error building trees; the index is unmerged?", me);
+ break;
+ case WRITE_TREE_PREFIX_ERROR:
+ die("%s: prefix %s not found", me, prefix);
+ break;
+ }
return ret;
}
diff --git a/builtin.h b/builtin.h
index 25d91bbfb..f3502d305 100644
--- a/builtin.h
+++ b/builtin.h
@@ -2,14 +2,23 @@
#define BUILTIN_H
#include "git-compat-util.h"
+#include "strbuf.h"
+#include "cache.h"
+#include "commit.h"
extern const char git_version_string[];
extern const char git_usage_string[];
+extern const char git_more_info_string[];
extern void list_common_cmds_help(void);
extern void help_unknown_cmd(const char *cmd);
-extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
extern void prune_packed_objects(int);
+extern int read_line_with_nul(char *buf, int size, FILE *file);
+extern int fmt_merge_msg(int merge_summary, struct strbuf *in,
+ struct strbuf *out);
+extern int commit_tree(const char *msg, unsigned char *tree,
+ struct commit_list *parents, unsigned char *ret);
+extern int check_pager_config(const char *cmd);
extern int cmd_add(int argc, const char **argv, const char *prefix);
extern int cmd_annotate(int argc, const char **argv, const char *prefix);
@@ -25,6 +34,7 @@ extern int cmd_check_attr(int argc, const char **argv, const char *prefix);
extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
extern int cmd_cherry(int argc, const char **argv, const char *prefix);
extern int cmd_cherry_pick(int argc, const char **argv, const char *prefix);
+extern int cmd_clone(int argc, const char **argv, const char *prefix);
extern int cmd_clean(int argc, const char **argv, const char *prefix);
extern int cmd_commit(int argc, const char **argv, const char *prefix);
extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
@@ -55,6 +65,7 @@ extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
extern int cmd_ls_remote(int argc, const char **argv, const char *prefix);
extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);
extern int cmd_mailsplit(int argc, const char **argv, const char *prefix);
+extern int cmd_merge(int argc, const char **argv, const char *prefix);
extern int cmd_merge_base(int argc, const char **argv, const char *prefix);
extern int cmd_merge_ours(int argc, const char **argv, const char *prefix);
extern int cmd_merge_file(int argc, const char **argv, const char *prefix);
@@ -68,6 +79,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
+extern int cmd_remote(int argc, const char **argv, const char *prefix);
extern int cmd_config(int argc, const char **argv, const char *prefix);
extern int cmd_rerere(int argc, const char **argv, const char *prefix);
extern int cmd_reset(int argc, const char **argv, const char *prefix);
diff --git a/bundle.c b/bundle.c
index 5c95eca07..00b2aabef 100644
--- a/bundle.c
+++ b/bundle.c
@@ -128,7 +128,8 @@ int verify_bundle(struct bundle_header *header, int verbose)
add_object_array(e->item, e->name, &refs);
}
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
i = req_nr;
while (i && (commit = get_revision(&revs)))
@@ -177,6 +178,7 @@ int create_bundle(struct bundle_header *header, const char *path,
int i, ref_count = 0;
char buffer[1024];
struct rev_info revs;
+ int read_from_stdin = 0;
struct child_process rls;
FILE *rls_fout;
@@ -226,8 +228,16 @@ int create_bundle(struct bundle_header *header, const char *path,
/* write references */
argc = setup_revisions(argc, argv, &revs, NULL);
- if (argc > 1)
- return error("unrecognized argument: %s'", argv[1]);
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "--stdin")) {
+ if (read_from_stdin++)
+ die("--stdin given twice?");
+ read_revisions_from_stdin(&revs);
+ continue;
+ }
+ return error("unrecognized argument: %s'", argv[i]);
+ }
for (i = 0; i < revs.pending.nr; i++) {
struct object_array_entry *e = revs.pending.objects + i;
@@ -332,10 +342,12 @@ int create_bundle(struct bundle_header *header, const char *path,
write_or_die(rls.in, sha1_to_hex(object->sha1), 40);
write_or_die(rls.in, "\n", 1);
}
+ close(rls.in);
if (finish_command(&rls))
return error ("pack-objects died");
-
- return bundle_to_stdout ? close(bundle_fd) : commit_lock_file(&lock);
+ if (!bundle_to_stdout)
+ commit_lock_file(&lock);
+ return 0;
}
int unbundle(struct bundle_header *header, int bundle_fd)
diff --git a/cache-tree.c b/cache-tree.c
index bfc95d2dc..5f8ee87bb 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -341,8 +341,11 @@ static int update_one(struct cache_tree *it,
if (dryrun)
hash_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
- else
- write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1);
+ else if (write_sha1_file(buffer.buf, buffer.len, tree_type, it->sha1)) {
+ strbuf_release(&buffer);
+ return -1;
+ }
+
strbuf_release(&buffer);
it->entry_count = i;
#if DEBUG
@@ -504,7 +507,7 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
return read_one(&buffer, &size);
}
-struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
+static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
{
while (*path) {
const char *slash;
@@ -529,3 +532,58 @@ struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
}
return it;
}
+
+int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix)
+{
+ int entries, was_valid, newfd;
+
+ /*
+ * We can't free this memory, it becomes part of a linked list
+ * parsed atexit()
+ */
+ struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+ newfd = hold_locked_index(lock_file, 1);
+
+ entries = read_cache();
+ if (entries < 0)
+ return WRITE_TREE_UNREADABLE_INDEX;
+
+ if (!active_cache_tree)
+ active_cache_tree = cache_tree();
+
+ was_valid = cache_tree_fully_valid(active_cache_tree);
+
+ if (!was_valid) {
+ if (cache_tree_update(active_cache_tree,
+ active_cache, active_nr,
+ missing_ok, 0) < 0)
+ return WRITE_TREE_UNMERGED_INDEX;
+ if (0 <= newfd) {
+ if (!write_cache(newfd, active_cache, active_nr) &&
+ !commit_lock_file(lock_file))
+ newfd = -1;
+ }
+ /* Not being able to write is fine -- we are only interested
+ * in updating the cache-tree part, and if the next caller
+ * ends up using the old index with unupdated cache-tree part
+ * it misses the work we did here, but that is just a
+ * performance penalty and not a big deal.
+ */
+ }
+
+ if (prefix) {
+ struct cache_tree *subtree =
+ cache_tree_find(active_cache_tree, prefix);
+ if (!subtree)
+ return WRITE_TREE_PREFIX_ERROR;
+ hashcpy(sha1, subtree->sha1);
+ }
+ else
+ hashcpy(sha1, active_cache_tree->sha1);
+
+ if (0 <= newfd)
+ rollback_lock_file(lock_file);
+
+ return 0;
+}
diff --git a/cache-tree.h b/cache-tree.h
index 8243228e4..cf8b79087 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -28,6 +28,9 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
int cache_tree_fully_valid(struct cache_tree *);
int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int);
-struct cache_tree *cache_tree_find(struct cache_tree *, const char *);
+#define WRITE_TREE_UNREADABLE_INDEX (-1)
+#define WRITE_TREE_UNMERGED_INDEX (-2)
+#define WRITE_TREE_PREFIX_ERROR (-3)
+int write_cache_as_tree(unsigned char *sha1, int missing_ok, const char *prefix);
#endif
diff --git a/cache.h b/cache.h
index 888895a96..2475de9fa 100644
--- a/cache.h
+++ b/cache.h
@@ -110,7 +110,6 @@ struct ondisk_cache_entry {
};
struct cache_entry {
- struct cache_entry *next;
unsigned int ce_ctime;
unsigned int ce_mtime;
unsigned int ce_dev;
@@ -121,6 +120,7 @@ struct cache_entry {
unsigned int ce_size;
unsigned int ce_flags;
unsigned char sha1[20];
+ struct cache_entry *next;
char name[FLEX_ARRAY]; /* more */
};
@@ -133,7 +133,26 @@ struct cache_entry {
#define CE_UPDATE (0x10000)
#define CE_REMOVE (0x20000)
#define CE_UPTODATE (0x40000)
-#define CE_UNHASHED (0x80000)
+#define CE_ADDED (0x80000)
+
+#define CE_HASHED (0x100000)
+#define CE_UNHASHED (0x200000)
+
+/*
+ * Copy the sha1 and stat state of a cache entry from one to
+ * another. But we never change the name, or the hash state!
+ */
+#define CE_STATE_MASK (CE_HASHED | CE_UNHASHED)
+static inline void copy_cache_entry(struct cache_entry *dst, struct cache_entry *src)
+{
+ unsigned int state = dst->ce_flags & CE_STATE_MASK;
+
+ /* Don't copy hash chain and name */
+ memcpy(dst, src, offsetof(struct cache_entry, next));
+
+ /* Restore the hash state */
+ dst->ce_flags = (dst->ce_flags & ~CE_STATE_MASK) | state;
+}
static inline unsigned create_ce_flags(size_t len, unsigned stage)
{
@@ -178,6 +197,18 @@ static inline unsigned int ce_mode_from_stat(struct cache_entry *ce, unsigned in
}
return create_ce_mode(mode);
}
+static inline int ce_to_dtype(const struct cache_entry *ce)
+{
+ unsigned ce_mode = ntohl(ce->ce_mode);
+ if (S_ISREG(ce_mode))
+ return DT_REG;
+ else if (S_ISDIR(ce_mode) || S_ISGITLINK(ce_mode))
+ return DT_DIR;
+ else if (S_ISLNK(ce_mode))
+ return DT_LNK;
+ else
+ return DT_UNKNOWN;
+}
#define canon_mode(mode) \
(S_ISREG(mode) ? (S_IFREG | ce_permissions(mode)) : \
S_ISLNK(mode) ? S_IFLNK : S_ISDIR(mode) ? S_IFDIR : S_IFGITLINK)
@@ -197,6 +228,23 @@ struct index_state {
extern struct index_state the_index;
+/* Name hashing */
+extern void add_name_hash(struct index_state *istate, struct cache_entry *ce);
+/*
+ * We don't actually *remove* it, we can just mark it invalid so that
+ * we won't find it in lookups.
+ *
+ * Not only would we have to search the lists (simple enough), but
+ * we'd also have to rehash other hash buckets in case this makes the
+ * hash bucket empty (common). So it's much better to just mark
+ * it.
+ */
+static inline void remove_name_hash(struct cache_entry *ce)
+{
+ ce->ce_flags |= CE_UNHASHED;
+}
+
+
#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS
#define active_cache (the_index.cache)
#define active_nr (the_index.cache_nr)
@@ -206,18 +254,21 @@ extern struct index_state the_index;
#define read_cache() read_index(&the_index)
#define read_cache_from(path) read_index_from(&the_index, (path))
+#define read_cache_unmerged() read_index_unmerged(&the_index)
#define write_cache(newfd, cache, entries) write_index(&the_index, (newfd))
#define discard_cache() discard_index(&the_index)
#define unmerged_cache() unmerged_index(&the_index)
#define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen))
#define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option))
+#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name))
#define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos))
#define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
-#define add_file_to_cache(path, verbose) add_file_to_index(&the_index, (path), (verbose))
+#define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags))
+#define add_file_to_cache(path, flags) add_file_to_index(&the_index, (path), (flags))
#define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL)
#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
#define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
-#define cache_name_exists(name, namelen) index_name_exists(&the_index, (name), (namelen))
+#define cache_name_exists(name, namelen, igncase) index_name_exists(&the_index, (name), (namelen), (igncase))
#endif
enum object_type {
@@ -230,6 +281,7 @@ enum object_type {
/* 5 for future expansion */
OBJ_OFS_DELTA = 6,
OBJ_REF_DELTA = 7,
+ OBJ_ANY,
OBJ_MAX,
};
@@ -248,8 +300,8 @@ static inline enum object_type object_type(unsigned int mode)
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
-#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
+#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
#define GITATTRIBUTES_FILE ".gitattributes"
#define INFOATTRIBUTES_FILE "info/attributes"
#define ATTRIBUTE_MACRO_PREFIX "[attr]"
@@ -261,11 +313,12 @@ extern char *git_work_tree_cfg;
extern int is_inside_work_tree(void);
extern const char *get_git_dir(void);
extern char *get_object_directory(void);
-extern char *get_refs_directory(void);
extern char *get_index_file(void);
extern char *get_graft_file(void);
extern int set_git_dir(const char *path);
extern const char *get_git_work_tree(void);
+extern const char *read_gitfile_gently(const char *path);
+extern void set_git_work_tree(const char *tree);
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
@@ -278,6 +331,10 @@ extern const char *prefix_filename(const char *prefix, int len, const char *path
extern void verify_filename(const char *prefix, const char *name);
extern void verify_non_filename(const char *prefix, const char *name);
+#define INIT_DB_QUIET 0x0001
+
+extern int init_db(const char *template_dir, unsigned int flags);
+
#define alloc_nr(x) (((x)+16)*3/2)
/*
@@ -301,21 +358,27 @@ extern void verify_non_filename(const char *prefix, const char *name);
/* Initialize and use the cache information */
extern int read_index(struct index_state *);
extern int read_index_from(struct index_state *, const char *path);
-extern int write_index(struct index_state *, int newfd);
+extern int read_index_unmerged(struct index_state *);
+extern int write_index(const struct index_state *, int newfd);
extern int discard_index(struct index_state *);
-extern int unmerged_index(struct index_state *);
+extern int unmerged_index(const struct index_state *);
extern int verify_path(const char *path);
-extern int index_name_exists(struct index_state *istate, const char *name, int namelen);
-extern int index_name_pos(struct index_state *, const char *name, int namelen);
+extern struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int igncase);
+extern int index_name_pos(const struct index_state *, const char *name, int namelen);
#define ADD_CACHE_OK_TO_ADD 1 /* Ok to add */
#define ADD_CACHE_OK_TO_REPLACE 2 /* Ok to replace file/directory */
#define ADD_CACHE_SKIP_DFCHECK 4 /* Ok to skip DF conflict checks */
#define ADD_CACHE_JUST_APPEND 8 /* Append only; tree.c::read_tree() */
extern int add_index_entry(struct index_state *, struct cache_entry *ce, int option);
extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
+extern void rename_index_entry_at(struct index_state *, int pos, const char *new_name);
extern int remove_index_entry_at(struct index_state *, int pos);
extern int remove_file_from_index(struct index_state *, const char *path);
-extern int add_file_to_index(struct index_state *, const char *path, int verbose);
+#define ADD_CACHE_VERBOSE 1
+#define ADD_CACHE_PRETEND 2
+#define ADD_CACHE_IGNORE_ERRORS 4
+extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags);
+extern int add_file_to_index(struct index_state *, const char *path, int flags);
extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh);
extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
@@ -323,8 +386,8 @@ extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
#define CE_MATCH_IGNORE_VALID 01
/* do not check the contents but report dirty on racily-clean entries */
#define CE_MATCH_RACY_IS_DIRTY 02
-extern int ie_match_stat(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
-extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
+extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
+extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int);
extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
@@ -336,6 +399,8 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
#define REFRESH_UNMERGED 0x0002 /* allow unmerged */
#define REFRESH_QUIET 0x0004 /* be quiet about it */
#define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */
+#define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */
+#define REFRESH_SAY_CHANGED 0x0020 /* say "changed" not "needs update" */
extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen);
struct lock_file {
@@ -346,6 +411,7 @@ struct lock_file {
char filename[PATH_MAX];
};
extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
+extern int hold_lock_file_for_append(struct lock_file *, const char *path, int);
extern int commit_lock_file(struct lock_file *);
extern int hold_locked_index(struct lock_file *, int);
@@ -357,8 +423,10 @@ extern int delete_ref(const char *, const unsigned char *sha1);
/* Environment bits from configuration mechanism */
extern int trust_executable_bit;
+extern int trust_ctime;
extern int quote_path_fully;
extern int has_symlinks;
+extern int ignore_case;
extern int assume_unchanged;
extern int prefer_symlink_refs;
extern int log_all_ref_updates;
@@ -372,6 +440,32 @@ extern size_t packed_git_window_size;
extern size_t packed_git_limit;
extern size_t delta_base_cache_limit;
extern int auto_crlf;
+extern int fsync_object_files;
+
+enum safe_crlf {
+ SAFE_CRLF_FALSE = 0,
+ SAFE_CRLF_FAIL = 1,
+ SAFE_CRLF_WARN = 2,
+};
+
+extern enum safe_crlf safe_crlf;
+
+enum branch_track {
+ BRANCH_TRACK_NEVER = 0,
+ BRANCH_TRACK_REMOTE,
+ BRANCH_TRACK_ALWAYS,
+ BRANCH_TRACK_EXPLICIT,
+};
+
+enum rebase_setup_type {
+ AUTOREBASE_NEVER = 0,
+ AUTOREBASE_LOCAL,
+ AUTOREBASE_REMOTE,
+ AUTOREBASE_ALWAYS,
+};
+
+extern enum branch_track git_branch_track;
+extern enum rebase_setup_type autorebase;
#define GIT_REPO_VERSION 0
extern int repository_format_version;
@@ -412,20 +506,35 @@ static inline void hashclr(unsigned char *hash)
int git_mkstemp(char *path, size_t n, const char *template);
+/*
+ * NOTE NOTE NOTE!!
+ *
+ * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
+ * not be changed. Old repositories have core.sharedrepository written in
+ * numeric format, and therefore these values are preserved for compatibility
+ * reasons.
+ */
enum sharedrepo {
- PERM_UMASK = 0,
- PERM_GROUP,
- PERM_EVERYBODY
+ PERM_UMASK = 0,
+ OLD_PERM_GROUP = 1,
+ OLD_PERM_EVERYBODY = 2,
+ PERM_GROUP = 0660,
+ PERM_EVERYBODY = 0664,
};
int git_config_perm(const char *var, const char *value);
int adjust_shared_perm(const char *path);
int safe_create_leading_directories(char *path);
+int safe_create_leading_directories_const(const char *path);
char *enter_repo(char *path, int strict);
static inline int is_absolute_path(const char *path)
{
- return path[0] == '/';
+ return path[0] == '/' || has_dos_drive_prefix(path);
}
const char *make_absolute_path(const char *path);
+const char *make_nonrelative_path(const char *path);
+const char *make_relative_path(const char *abs, const char *base);
+int normalize_absolute_path(char *buf, const char *path);
+int longest_ancestor_length(const char *path, const char *prefix_list);
/* Read and unpack a sha1 file into memory, write memory to a sha1 file */
extern int sha1_object_info(const unsigned char *, unsigned long *);
@@ -433,12 +542,13 @@ extern void * read_sha1_file(const unsigned char *sha1, enum object_type *type,
extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
+extern int force_object_loose(const unsigned char *sha1, time_t mtime);
+
+/* just like read_sha1_file(), but non fatal in presence of bad objects */
+extern void *read_object(const unsigned char *sha1, enum object_type *type, unsigned long *size);
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
-extern int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
- size_t bufsize, size_t *bufposn);
-extern int write_sha1_to_fd(int fd, const unsigned char *sha1);
extern int move_temp_to_file(const char *tmpfile, const char *filename);
extern int has_sha1_pack(const unsigned char *sha1, const char **ignore);
@@ -474,6 +584,7 @@ extern int create_symref(const char *ref, const char *refs_heads_master, const c
extern int validate_headref(const char *ref);
extern int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
+extern int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
extern int cache_name_compare(const char *name1, int len1, const char *name2, int len2);
extern void *read_object_with_reference(const unsigned char *sha1,
@@ -481,6 +592,9 @@ extern void *read_object_with_reference(const unsigned char *sha1,
unsigned long *size,
unsigned char *sha1_ret);
+extern struct object *peel_to_type(const char *name, int namelen,
+ struct object *o, enum object_type);
+
enum date_mode {
DATE_NORMAL = 0,
DATE_RELATIVE,
@@ -514,7 +628,7 @@ struct checkout {
};
extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath);
-extern int has_symlink_leading_path(const char *name, char *last_symlink);
+extern int has_symlink_leading_path(int len, const char *name);
extern struct alternate_object_database {
struct alternate_object_database *next;
@@ -522,6 +636,7 @@ extern struct alternate_object_database {
char base[FLEX_ARRAY]; /* more */
} *alt_odb_list;
extern void prepare_alt_odb(void);
+extern void add_to_alternates_file(const char *reference);
struct pack_window {
struct pack_window *next;
@@ -539,6 +654,8 @@ extern struct packed_git {
const void *index_data;
size_t index_size;
uint32_t num_objects;
+ uint32_t num_bad_objects;
+ unsigned char *bad_object_sha1;
int index_version;
time_t mtime;
int pack_fd;
@@ -558,6 +675,7 @@ struct ref {
struct ref *next;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
+ char *symref;
unsigned int force:1,
merge:1,
nonfastforward:1,
@@ -591,8 +709,6 @@ extern struct ref **get_remote_heads(int in, struct ref **list, int nr_match, ch
extern int server_supports(const char *feature);
extern struct packed_git *parse_pack_index(unsigned char *sha1);
-extern struct packed_git *parse_pack_index_file(const unsigned char *sha1,
- const char *idx_path);
extern void prepare_packed_git(void);
extern void reprepare_packed_git(void);
@@ -608,6 +724,7 @@ extern void close_pack_windows(struct packed_git *);
extern void unuse_pack(struct pack_window **);
extern struct packed_git *add_packed_git(const char *, int, int);
extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);
+extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);
extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
@@ -618,24 +735,31 @@ extern int matches_pack_name(struct packed_git *p, const char *name);
/* Dumb servers support */
extern int update_server_info(int);
-typedef int (*config_fn_t)(const char *, const char *);
-extern int git_default_config(const char *, const char *);
-extern int git_config_from_file(config_fn_t fn, const char *);
-extern int git_config(config_fn_t fn);
+typedef int (*config_fn_t)(const char *, const char *, void *);
+extern int git_default_config(const char *, const char *, void *);
+extern int git_config_from_file(config_fn_t fn, const char *, void *);
+extern int git_config(config_fn_t fn, void *);
extern int git_parse_long(const char *, long *);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
extern unsigned long git_config_ulong(const char *, const char *);
+extern int git_config_bool_or_int(const char *, const char *, int *);
extern int git_config_bool(const char *, const char *);
+extern int git_config_string(const char **, const char *, const char *);
extern int git_config_set(const char *, const char *);
extern int git_config_set_multivar(const char *, const char *, const char *, int);
extern int git_config_rename_section(const char *, const char *);
extern const char *git_etc_gitconfig(void);
-extern int check_repository_format_version(const char *var, const char *value);
+extern int check_repository_format_version(const char *var, const char *value, void *cb);
+extern int git_config_system(void);
+extern int git_config_global(void);
+extern int config_error_nonbool(const char *);
+extern const char *config_exclusive_filename;
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
extern char git_default_name[MAX_GITNAME];
+extern int user_ident_explicitly_given;
extern const char *git_commit_encoding;
extern const char *git_log_output_encoding;
@@ -643,20 +767,22 @@ extern const char *git_log_output_encoding;
/* IO helper functions */
extern void maybe_flush_or_die(FILE *, const char *);
extern int copy_fd(int ifd, int ofd);
-extern int read_in_full(int fd, void *buf, size_t count);
-extern int write_in_full(int fd, const void *buf, size_t count);
+extern int copy_file(const char *dst, const char *src, int mode);
+extern ssize_t read_in_full(int fd, void *buf, size_t count);
+extern ssize_t write_in_full(int fd, const void *buf, size_t count);
extern void write_or_die(int fd, const void *buf, size_t count);
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
+extern void fsync_or_die(int fd, const char *);
/* pager.c */
extern void setup_pager(void);
-extern char *pager_program;
+extern const char *pager_program;
extern int pager_in_use(void);
extern int pager_use_color;
-extern char *editor_program;
-extern char *excludes_file;
+extern const char *editor_program;
+extern const char *excludes_file;
/* base85 */
int decode_85(char *dst, const char *line, int linelen);
@@ -676,11 +802,16 @@ extern void trace_argv_printf(const char **argv, const char *format, ...);
/* convert.c */
/* returns 1 if *dst was used */
-extern int convert_to_git(const char *path, const char *src, size_t len, struct strbuf *dst);
+extern int convert_to_git(const char *path, const char *src, size_t len,
+ struct strbuf *dst, enum safe_crlf checksafe);
extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst);
/* add */
-void add_files_to_cache(int verbose, const char *prefix, const char **pathspec);
+/*
+ * return 0 if success, 1 - if addition of a file failed and
+ * ADD_FILES_IGNORE_ERRORS was specified in flags
+ */
+int add_files_to_cache(const char *prefix, const char **pathspec, int flags);
/* diff.c */
extern int diff_auto_refresh_index;
@@ -695,18 +826,23 @@ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, i
#define WS_TRAILING_SPACE 01
#define WS_SPACE_BEFORE_TAB 02
#define WS_INDENT_WITH_NON_TAB 04
+#define WS_CR_AT_EOL 010
#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB)
extern unsigned whitespace_rule_cfg;
extern unsigned whitespace_rule(const char *);
extern unsigned parse_whitespace_rule(const char *);
-extern unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
- FILE *stream, const char *set,
- const char *reset, const char *ws);
+extern unsigned ws_check(const char *line, int len, unsigned ws_rule);
+extern void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
extern char *whitespace_error_string(unsigned ws);
+extern int ws_fix_copy(char *, const char *, int, unsigned, int *);
+extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
/* ls-files */
int pathspec_match(const char **spec, char *matched, const char *filename, int skiplen);
int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset);
void overlay_tree_on_cache(const char *tree_name, const char *prefix);
+char *alias_lookup(const char *alias);
+int split_cmdline(char *cmdline, const char ***argv);
+
#endif /* CACHE_H */
diff --git a/check_bindir b/check_bindir
new file mode 100755
index 000000000..a1c4c3e8d
--- /dev/null
+++ b/check_bindir
@@ -0,0 +1,13 @@
+#!/bin/sh
+bindir="$1"
+gitexecdir="$2"
+gitcmd="$3"
+if test "$bindir" != "$gitexecdir" -a -x "$gitcmd"
+then
+ echo
+ echo "!! You have installed git-* commands to new gitexecdir."
+ echo "!! Old version git-* commands still remain in bindir."
+ echo "!! Mixing two versions of Git will lead to problems."
+ echo "!! Please remove old version commands in bindir now."
+ echo
+fi
diff --git a/color.c b/color.c
index 7f66c29fa..fc0b72ad5 100644
--- a/color.c
+++ b/color.c
@@ -3,6 +3,8 @@
#define COLOR_RESET "\033[m"
+int git_use_color_default = 0;
+
static int parse_color(const char *name, int len)
{
static const char * const color_names[] = {
@@ -17,7 +19,7 @@ static int parse_color(const char *name, int len)
return i - 1;
}
i = strtol(name, &end, 10);
- if (*name && !*end && i >= -1 && i <= 255)
+ if (end - name == len && i >= -1 && i <= 255)
return i;
return -2;
}
@@ -143,6 +145,16 @@ int git_config_colorbool(const char *var, const char *value, int stdout_is_tty)
return 0;
}
+int git_color_default_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "color.ui")) {
+ git_use_color_default = git_config_colorbool(var, value, -1);
+ return 0;
+ }
+
+ return git_default_config(var, value, cb);
+}
+
static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
va_list args, const char *trail)
{
diff --git a/color.h b/color.h
index ff63513d3..6cf5c88aa 100644
--- a/color.h
+++ b/color.h
@@ -4,6 +4,17 @@
/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
#define COLOR_MAXLEN 24
+/*
+ * This variable stores the value of color.ui
+ */
+extern int git_use_color_default;
+
+
+/*
+ * Use this instead of git_default_config if you need the value of color.ui.
+ */
+int git_color_default_config(const char *var, const char *value, void *cb);
+
int git_config_colorbool(const char *var, const char *value, int stdout_is_tty);
void color_parse(const char *var, const char *value, char *dst);
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
diff --git a/combine-diff.c b/combine-diff.c
index 0e19cbaac..9f80a1c5e 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -84,6 +84,7 @@ struct sline {
/* bit 0 up to (N-1) are on if the parent has this line (i.e.
* we did not change it).
* bit N is used for "interesting" lines, including context.
+ * bit (N+1) is used for "do not show deletion before this".
*/
unsigned long flag;
unsigned long *p_lno;
@@ -308,6 +309,7 @@ static int give_context(struct sline *sline, unsigned long cnt, int num_parent)
{
unsigned long all_mask = (1UL<<num_parent) - 1;
unsigned long mark = (1UL<<num_parent);
+ unsigned long no_pre_delete = (2UL<<num_parent);
unsigned long i;
/* Two groups of interesting lines may have a short gap of
@@ -329,7 +331,7 @@ static int give_context(struct sline *sline, unsigned long cnt, int num_parent)
/* Paint a few lines before the first interesting line. */
while (j < i)
- sline[j++].flag |= mark;
+ sline[j++].flag |= mark | no_pre_delete;
again:
/* we know up to i is to be included. where does the
@@ -502,6 +504,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
int use_color)
{
unsigned long mark = (1UL<<num_parent);
+ unsigned long no_pre_delete = (2UL<<num_parent);
int i;
unsigned long lno = 0;
const char *c_frag = diff_get_color(use_color, DIFF_FRAGINFO);
@@ -581,7 +584,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
int j;
unsigned long p_mask;
sl = &sline[lno++];
- ll = sl->lost_head;
+ ll = (sl->flag & no_pre_delete) ? NULL : sl->lost_head;
while (ll) {
fputs(c_old, stdout);
for (j = 0; j < num_parent; j++) {
@@ -701,7 +704,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
!fstat(fd, &st)) {
size_t len = xsize_t(st.st_size);
- size_t sz = 0;
+ ssize_t done;
int is_file, i;
elem->mode = canon_mode(st.st_mode);
@@ -716,14 +719,13 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
result_size = len;
result = xmalloc(len + 1);
- while (sz < len) {
- ssize_t done = xread(fd, result+sz, len-sz);
- if (done == 0)
- break;
- if (done < 0)
- die("read error '%s'", elem->path);
- sz += done;
- }
+
+ done = read_in_full(fd, result, len);
+ if (done < 0)
+ die("read error '%s'", elem->path);
+ else if (done < len)
+ die("early EOF '%s'", elem->path);
+
result[len] = 0;
}
else {
@@ -798,7 +800,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
int deleted = 0;
if (rev->loginfo && !rev->no_commit_id)
- show_log(rev, opt->msg_sep);
+ show_log(rev);
dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
"", elem->path, c_meta, c_reset);
printf("%sindex ", c_meta);
@@ -881,7 +883,7 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
inter_name_termination = 0;
if (rev->loginfo && !rev->no_commit_id)
- show_log(rev, opt->msg_sep);
+ show_log(rev);
if (opt->output_format & DIFF_FORMAT_RAW) {
offset = strlen(COLONS) - num_parent;
@@ -962,7 +964,7 @@ void diff_tree_combined(const unsigned char *sha1,
paths = intersect_paths(paths, i, num_parent);
if (show_log_first && i == 0) {
- show_log(rev, opt->msg_sep);
+ show_log(rev);
if (rev->verbose_header && opt->output_format)
putchar(opt->line_termination);
}
diff --git a/commit.c b/commit.c
index 8b8fb04d1..dc0c5bfda 100644
--- a/commit.c
+++ b/commit.c
@@ -193,7 +193,7 @@ static void prepare_commit_graft(void)
commit_graft_prepared = 1;
}
-static struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
+struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
{
int pos;
prepare_commit_graft();
@@ -243,7 +243,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
unsigned char parent[20];
struct commit_list **pptr;
struct commit_graft *graft;
- unsigned n_refs = 0;
if (item->object.parsed)
return 0;
@@ -255,8 +254,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
return error("bad tree pointer in commit %s",
sha1_to_hex(item->object.sha1));
item->tree = lookup_tree(parent);
- if (item->tree)
- n_refs++;
bufptr += 46; /* "tree " + "hex sha1" + "\n" */
pptr = &item->parents;
@@ -272,10 +269,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
if (graft)
continue;
new_parent = lookup_commit(parent);
- if (new_parent) {
+ if (new_parent)
pptr = &commit_list_insert(new_parent, pptr)->next;
- n_refs++;
- }
}
if (graft) {
int i;
@@ -285,22 +280,10 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
if (!new_parent)
continue;
pptr = &commit_list_insert(new_parent, pptr)->next;
- n_refs++;
}
}
item->date = parse_commit_date(bufptr, tail);
- if (track_object_refs) {
- unsigned i = 0;
- struct commit_list *p;
- struct object_refs *refs = alloc_object_refs(n_refs);
- if (item->tree)
- refs->ref[i++] = &item->tree->object;
- for (p = item->parents; p; p = p->next)
- refs->ref[i++] = &p->item->object;
- set_object_refs(&item->object, refs);
- }
-
return 0;
}
@@ -311,6 +294,8 @@ int parse_commit(struct commit *item)
unsigned long size;
int ret;
+ if (!item)
+ return -1;
if (item->object.parsed)
return 0;
buffer = read_sha1_file(item->object.sha1, &type, &size);
@@ -340,6 +325,14 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
return new_list;
}
+unsigned commit_list_count(const struct commit_list *l)
+{
+ unsigned c = 0;
+ for (; l; l = l->next )
+ c++;
+ return c;
+}
+
void free_commit_list(struct commit_list *list)
{
while (list) {
@@ -385,8 +378,7 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
while (parents) {
struct commit *commit = parents->item;
- parse_commit(commit);
- if (!(commit->object.flags & mark)) {
+ if (!parse_commit(commit) && !(commit->object.flags & mark)) {
commit->object.flags |= mark;
insert_by_date(commit, list);
}
@@ -444,8 +436,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
/* Mark them and clear the indegree */
for (next = orig; next; next = next->next) {
struct commit *commit = next->item;
- commit->object.flags |= TOPOSORT;
- commit->indegree = 0;
+ commit->indegree = 1;
}
/* update the indegree */
@@ -454,7 +445,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
while (parents) {
struct commit *parent = parents->item;
- if (parent->object.flags & TOPOSORT)
+ if (parent->indegree)
parent->indegree++;
parents = parents->next;
}
@@ -472,7 +463,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
for (next = orig; next; next = next->next) {
struct commit *commit = next->item;
- if (!commit->indegree)
+ if (commit->indegree == 1)
insert = &commit_list_insert(commit, insert)->next;
}
@@ -494,7 +485,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
for (parents = commit->parents; parents ; parents = parents->next) {
struct commit *parent=parents->item;
- if (!(parent->object.flags & TOPOSORT))
+ if (!parent->indegree)
continue;
/*
@@ -502,7 +493,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
* when all their children have been emitted thereby
* guaranteeing topological order.
*/
- if (!--parent->indegree) {
+ if (--parent->indegree == 1) {
if (!lifo)
insert_by_date(parent, &work);
else
@@ -513,7 +504,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
* work_item is a commit all of whose children
* have already been emitted. we can emit it now.
*/
- commit->object.flags &= ~TOPOSORT;
+ commit->indegree = 0;
*pptr = work_item;
pptr = &work_item->next;
}
@@ -541,24 +532,34 @@ static struct commit *interesting(struct commit_list *list)
return NULL;
}
-static struct commit_list *merge_bases(struct commit *one, struct commit *two)
+static struct commit_list *merge_bases_many(struct commit *one, int n, struct commit **twos)
{
struct commit_list *list = NULL;
struct commit_list *result = NULL;
+ int i;
- if (one == two)
- /* We do not mark this even with RESULT so we do not
- * have to clean it up.
- */
- return commit_list_insert(one, &result);
+ for (i = 0; i < n; i++) {
+ if (one == twos[i])
+ /*
+ * We do not mark this even with RESULT so we do not
+ * have to clean it up.
+ */
+ return commit_list_insert(one, &result);
+ }
- parse_commit(one);
- parse_commit(two);
+ if (parse_commit(one))
+ return NULL;
+ for (i = 0; i < n; i++) {
+ if (parse_commit(twos[i]))
+ return NULL;
+ }
one->object.flags |= PARENT1;
- two->object.flags |= PARENT2;
insert_by_date(one, &list);
- insert_by_date(two, &list);
+ for (i = 0; i < n; i++) {
+ twos[i]->object.flags |= PARENT2;
+ insert_by_date(twos[i], &list);
+ }
while (interesting(list)) {
struct commit *commit;
@@ -586,7 +587,8 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two)
parents = parents->next;
if ((p->object.flags & flags) == flags)
continue;
- parse_commit(p);
+ if (parse_commit(p))
+ return NULL;
p->object.flags |= flags;
insert_by_date(p, &list);
}
@@ -605,21 +607,53 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two)
return result;
}
-struct commit_list *get_merge_bases(struct commit *one,
- struct commit *two, int cleanup)
+struct commit_list *get_octopus_merge_bases(struct commit_list *in)
+{
+ struct commit_list *i, *j, *k, *ret = NULL;
+ struct commit_list **pptr = &ret;
+
+ for (i = in; i; i = i->next) {
+ if (!ret)
+ pptr = &commit_list_insert(i->item, pptr)->next;
+ else {
+ struct commit_list *new = NULL, *end = NULL;
+
+ for (j = ret; j; j = j->next) {
+ struct commit_list *bases;
+ bases = get_merge_bases(i->item, j->item, 1);
+ if (!new)
+ new = bases;
+ else
+ end->next = bases;
+ for (k = bases; k; k = k->next)
+ end = k;
+ }
+ ret = new;
+ }
+ }
+ return ret;
+}
+
+struct commit_list *get_merge_bases_many(struct commit *one,
+ int n,
+ struct commit **twos,
+ int cleanup)
{
struct commit_list *list;
struct commit **rslt;
struct commit_list *result;
int cnt, i, j;
- result = merge_bases(one, two);
- if (one == two)
- return result;
+ result = merge_bases_many(one, n, twos);
+ for (i = 0; i < n; i++) {
+ if (one == twos[i])
+ return result;
+ }
if (!result || !result->next) {
if (cleanup) {
clear_commit_marks(one, all_flags);
- clear_commit_marks(two, all_flags);
+ for (i = 0; i < n; i++)
+ clear_commit_marks(twos[i], all_flags);
}
return result;
}
@@ -637,12 +671,13 @@ struct commit_list *get_merge_bases(struct commit *one,
free_commit_list(result);
clear_commit_marks(one, all_flags);
- clear_commit_marks(two, all_flags);
+ for (i = 0; i < n; i++)
+ clear_commit_marks(twos[i], all_flags);
for (i = 0; i < cnt - 1; i++) {
for (j = i+1; j < cnt; j++) {
if (!rslt[i] || !rslt[j])
continue;
- result = merge_bases(rslt[i], rslt[j]);
+ result = merge_bases_many(rslt[i], 1, &rslt[j]);
clear_commit_marks(rslt[i], all_flags);
clear_commit_marks(rslt[j], all_flags);
for (list = result; list; list = list->next) {
@@ -664,6 +699,12 @@ struct commit_list *get_merge_bases(struct commit *one,
return result;
}
+struct commit_list *get_merge_bases(struct commit *one, struct commit *two,
+ int cleanup)
+{
+ return get_merge_bases_many(one, 1, &two, cleanup);
+}
+
int in_merge_bases(struct commit *commit, struct commit **reference, int num)
{
struct commit_list *bases, *b;
@@ -683,3 +724,55 @@ int in_merge_bases(struct commit *commit, struct commit **reference, int num)
free_commit_list(bases);
return ret;
}
+
+struct commit_list *reduce_heads(struct commit_list *heads)
+{
+ struct commit_list *p;
+ struct commit_list *result = NULL, **tail = &result;
+ struct commit **other;
+ size_t num_head, num_other;
+
+ if (!heads)
+ return NULL;
+
+ /* Avoid unnecessary reallocations */
+ for (p = heads, num_head = 0; p; p = p->next)
+ num_head++;
+ other = xcalloc(sizeof(*other), num_head);
+
+ /* For each commit, see if it can be reached by others */
+ for (p = heads; p; p = p->next) {
+ struct commit_list *q, *base;
+
+ /* Do we already have this in the result? */
+ for (q = result; q; q = q->next)
+ if (p->item == q->item)
+ break;
+ if (q)
+ continue;
+
+ num_other = 0;
+ for (q = heads; q; q = q->next) {
+ if (p->item == q->item)
+ continue;
+ other[num_other++] = q->item;
+ }
+ if (num_other)
+ base = get_merge_bases_many(p->item, num_other, other, 1);
+ else
+ base = NULL;
+ /*
+ * If p->item does not have anything common with other
+ * commits, there won't be any merge base. If it is
+ * reachable from some of the others, p->item will be
+ * the merge base. If its history is connected with
+ * others, but p->item is not reachable by others, we
+ * will get something other than p->item back.
+ */
+ if (!base || (base->item != p->item))
+ tail = &(commit_list_insert(p->item, tail)->next);
+ free_commit_list(base);
+ }
+ free(other);
+ return result;
+}
diff --git a/commit.h b/commit.h
index 10e2b5d4c..77de9621d 100644
--- a/commit.h
+++ b/commit.h
@@ -41,6 +41,7 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
int parse_commit(struct commit *item);
struct commit_list * commit_list_insert(struct commit *item, struct commit_list **list_p);
+unsigned commit_list_count(const struct commit_list *l);
struct commit_list * insert_by_date(struct commit *item, struct commit_list **list);
void free_commit_list(struct commit_list *list);
@@ -63,14 +64,30 @@ enum cmit_fmt {
};
extern int non_ascii(int);
-extern enum cmit_fmt get_commit_format(const char *arg);
+struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
+extern void get_commit_format(const char *arg, struct rev_info *);
extern void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb);
extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
struct strbuf *,
int abbrev, const char *subject,
const char *after_subject, enum date_mode,
- int non_ascii_present);
+ int need_8bit_cte);
+void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
+ const char *line, enum date_mode dmode,
+ const char *encoding);
+void pp_title_line(enum cmit_fmt fmt,
+ const char **msg_p,
+ struct strbuf *sb,
+ const char *subject,
+ const char *after_subject,
+ const char *encoding,
+ int need_8bit_cte);
+void pp_remainder(enum cmit_fmt fmt,
+ const char **msg_p,
+ struct strbuf *sb,
+ int indent);
+
/** Removes the first commit from a list sorted by date, and adds all
* of its parents.
@@ -101,8 +118,10 @@ struct commit_graft {
struct commit_graft *read_graft_line(char *buf, int len);
int register_commit_graft(struct commit_graft *, int);
int read_graft_file(const char *graft_file);
+struct commit_graft *lookup_commit_graft(const unsigned char *sha1);
extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
+extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);
extern int register_shallow(const unsigned char *sha1);
extern int unregister_shallow(const unsigned char *sha1);
@@ -114,11 +133,12 @@ extern struct commit_list *get_shallow_commits(struct object_array *heads,
int in_merge_bases(struct commit *, struct commit **, int);
extern int interactive_add(int argc, const char **argv, const char *prefix);
-extern int rerere(void);
static inline int single_parent(struct commit *commit)
{
return commit->parents && !commit->parents->next;
}
+struct commit_list *reduce_heads(struct commit_list *heads);
+
#endif /* COMMIT_H */
diff --git a/compat/fnmatch.c b/compat/fnmatch.c
new file mode 100644
index 000000000..1f4ead5f9
--- /dev/null
+++ b/compat/fnmatch.c
@@ -0,0 +1,488 @@
+/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Enable GNU extensions in fnmatch.h. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <errno.h>
+#include <fnmatch.h>
+#include <ctype.h>
+
+#if HAVE_STRING_H || defined _LIBC
+# include <string.h>
+#else
+# include <strings.h>
+#endif
+
+#if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+#endif
+
+/* For platform which support the ISO C amendement 1 functionality we
+ support user defined character classes. */
+#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
+# include <wchar.h>
+# include <wctype.h>
+#endif
+
+/* Comment out all this code if we are using the GNU C Library, and are not
+ actually compiling the library itself. This code is part of the GNU C
+ Library, but also included in many other GNU distributions. Compiling
+ and linking in this code is a waste when using the GNU C library
+ (especially if it is a shared library). Rather than having every GNU
+ program understand `configure --with-gnu-libc' and omit the object files,
+ it is simpler to just do this in the source for each such file. */
+
+#if defined _LIBC || !defined __GNU_LIBRARY__
+
+
+# if defined STDC_HEADERS || !defined isascii
+# define ISASCII(c) 1
+# else
+# define ISASCII(c) isascii(c)
+# endif
+
+# ifdef isblank
+# define ISBLANK(c) (ISASCII (c) && isblank (c))
+# else
+# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+# endif
+# ifdef isgraph
+# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
+# else
+# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
+# endif
+
+# define ISPRINT(c) (ISASCII (c) && isprint (c))
+# define ISDIGIT(c) (ISASCII (c) && isdigit (c))
+# define ISALNUM(c) (ISASCII (c) && isalnum (c))
+# define ISALPHA(c) (ISASCII (c) && isalpha (c))
+# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
+# define ISLOWER(c) (ISASCII (c) && islower (c))
+# define ISPUNCT(c) (ISASCII (c) && ispunct (c))
+# define ISSPACE(c) (ISASCII (c) && isspace (c))
+# define ISUPPER(c) (ISASCII (c) && isupper (c))
+# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
+
+# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
+
+# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+/* The GNU C library provides support for user-defined character classes
+ and the functions from ISO C amendement 1. */
+# ifdef CHARCLASS_NAME_MAX
+# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+# else
+/* This shouldn't happen but some implementation might still have this
+ problem. Use a reasonable default value. */
+# define CHAR_CLASS_MAX_LENGTH 256
+# endif
+
+# ifdef _LIBC
+# define IS_CHAR_CLASS(string) __wctype (string)
+# else
+# define IS_CHAR_CLASS(string) wctype (string)
+# endif
+# else
+# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+
+# define IS_CHAR_CLASS(string) \
+ (STREQ (string, "alpha") || STREQ (string, "upper") \
+ || STREQ (string, "lower") || STREQ (string, "digit") \
+ || STREQ (string, "alnum") || STREQ (string, "xdigit") \
+ || STREQ (string, "space") || STREQ (string, "print") \
+ || STREQ (string, "punct") || STREQ (string, "graph") \
+ || STREQ (string, "cntrl") || STREQ (string, "blank"))
+# endif
+
+/* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+# if !defined _LIBC && !defined getenv
+extern char *getenv ();
+# endif
+
+# ifndef errno
+extern int errno;
+# endif
+
+/* This function doesn't exist on most systems. */
+
+# if !defined HAVE___STRCHRNUL && !defined _LIBC
+static char *
+__strchrnul (s, c)
+ const char *s;
+ int c;
+{
+ char *result = strchr (s, c);
+ if (result == NULL)
+ result = strchr (s, '\0');
+ return result;
+}
+# endif
+
+# ifndef internal_function
+/* Inside GNU libc we mark some function in a special way. In other
+ environments simply ignore the marking. */
+# define internal_function
+# endif
+
+/* Match STRING against the filename pattern PATTERN, returning zero if
+ it matches, nonzero if not. */
+static int internal_fnmatch __P ((const char *pattern, const char *string,
+ int no_leading_period, int flags))
+ internal_function;
+static int
+internal_function
+internal_fnmatch (pattern, string, no_leading_period, flags)
+ const char *pattern;
+ const char *string;
+ int no_leading_period;
+ int flags;
+{
+ register const char *p = pattern, *n = string;
+ register unsigned char c;
+
+/* Note that this evaluates C many times. */
+# ifdef _LIBC
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
+# else
+# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
+# endif
+
+ while ((c = *p++) != '\0')
+ {
+ c = FOLD (c);
+
+ switch (c)
+ {
+ case '?':
+ if (*n == '\0')
+ return FNM_NOMATCH;
+ else if (*n == '/' && (flags & FNM_FILE_NAME))
+ return FNM_NOMATCH;
+ else if (*n == '.' && no_leading_period
+ && (n == string
+ || (n[-1] == '/' && (flags & FNM_FILE_NAME))))
+ return FNM_NOMATCH;
+ break;
+
+ case '\\':
+ if (!(flags & FNM_NOESCAPE))
+ {
+ c = *p++;
+ if (c == '\0')
+ /* Trailing \ loses. */
+ return FNM_NOMATCH;
+ c = FOLD (c);
+ }
+ if (FOLD ((unsigned char) *n) != c)
+ return FNM_NOMATCH;
+ break;
+
+ case '*':
+ if (*n == '.' && no_leading_period
+ && (n == string
+ || (n[-1] == '/' && (flags & FNM_FILE_NAME))))
+ return FNM_NOMATCH;
+
+ for (c = *p++; c == '?' || c == '*'; c = *p++)
+ {
+ if (*n == '/' && (flags & FNM_FILE_NAME))
+ /* A slash does not match a wildcard under FNM_FILE_NAME. */
+ return FNM_NOMATCH;
+ else if (c == '?')
+ {
+ /* A ? needs to match one character. */
+ if (*n == '\0')
+ /* There isn't another character; no match. */
+ return FNM_NOMATCH;
+ else
+ /* One character of the string is consumed in matching
+ this ? wildcard, so *??? won't match if there are
+ less than three characters. */
+ ++n;
+ }
+ }
+
+ if (c == '\0')
+ /* The wildcard(s) is/are the last element of the pattern.
+ If the name is a file name and contains another slash
+ this does mean it cannot match. */
+ return ((flags & FNM_FILE_NAME) && strchr (n, '/') != NULL
+ ? FNM_NOMATCH : 0);
+ else
+ {
+ const char *endp;
+
+ endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
+
+ if (c == '[')
+ {
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+
+ for (--p; n < endp; ++n)
+ if (internal_fnmatch (p, n,
+ (no_leading_period
+ && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME)))),
+ flags2)
+ == 0)
+ return 0;
+ }
+ else if (c == '/' && (flags & FNM_FILE_NAME))
+ {
+ while (*n != '\0' && *n != '/')
+ ++n;
+ if (*n == '/'
+ && (internal_fnmatch (p, n + 1, flags & FNM_PERIOD,
+ flags) == 0))
+ return 0;
+ }
+ else
+ {
+ int flags2 = ((flags & FNM_FILE_NAME)
+ ? flags : (flags & ~FNM_PERIOD));
+
+ if (c == '\\' && !(flags & FNM_NOESCAPE))
+ c = *p;
+ c = FOLD (c);
+ for (--p; n < endp; ++n)
+ if (FOLD ((unsigned char) *n) == c
+ && (internal_fnmatch (p, n,
+ (no_leading_period
+ && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME)))),
+ flags2) == 0))
+ return 0;
+ }
+ }
+
+ /* If we come here no match is possible with the wildcard. */
+ return FNM_NOMATCH;
+
+ case '[':
+ {
+ /* Nonzero if the sense of the character class is inverted. */
+ static int posixly_correct;
+ register int not;
+ char cold;
+
+ if (posixly_correct == 0)
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+ if (*n == '\0')
+ return FNM_NOMATCH;
+
+ if (*n == '.' && no_leading_period && (n == string
+ || (n[-1] == '/'
+ && (flags
+ & FNM_FILE_NAME))))
+ return FNM_NOMATCH;
+
+ if (*n == '/' && (flags & FNM_FILE_NAME))
+ /* `/' cannot be matched. */
+ return FNM_NOMATCH;
+
+ not = (*p == '!' || (posixly_correct < 0 && *p == '^'));
+ if (not)
+ ++p;
+
+ c = *p++;
+ for (;;)
+ {
+ unsigned char fn = FOLD ((unsigned char) *n);
+
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
+ {
+ if (*p == '\0')
+ return FNM_NOMATCH;
+ c = FOLD ((unsigned char) *p);
+ ++p;
+
+ if (c == fn)
+ goto matched;
+ }
+ else if (c == '[' && *p == ':')
+ {
+ /* Leave room for the null. */
+ char str[CHAR_CLASS_MAX_LENGTH + 1];
+ size_t c1 = 0;
+# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+ wctype_t wt;
+# endif
+ const char *startp = p;
+
+ for (;;)
+ {
+ if (c1 == CHAR_CLASS_MAX_LENGTH)
+ /* The name is too long and therefore the pattern
+ is ill-formed. */
+ return FNM_NOMATCH;
+
+ c = *++p;
+ if (c == ':' && p[1] == ']')
+ {
+ p += 2;
+ break;
+ }
+ if (c < 'a' || c >= 'z')
+ {
+ /* This cannot possibly be a character class name.
+ Match it as a normal range. */
+ p = startp;
+ c = '[';
+ goto normal_bracket;
+ }
+ str[c1++] = c;
+ }
+ str[c1] = '\0';
+
+# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
+ wt = IS_CHAR_CLASS (str);
+ if (wt == 0)
+ /* Invalid character class name. */
+ return FNM_NOMATCH;
+
+ if (__iswctype (__btowc ((unsigned char) *n), wt))
+ goto matched;
+# else
+ if ((STREQ (str, "alnum") && ISALNUM ((unsigned char) *n))
+ || (STREQ (str, "alpha") && ISALPHA ((unsigned char) *n))
+ || (STREQ (str, "blank") && ISBLANK ((unsigned char) *n))
+ || (STREQ (str, "cntrl") && ISCNTRL ((unsigned char) *n))
+ || (STREQ (str, "digit") && ISDIGIT ((unsigned char) *n))
+ || (STREQ (str, "graph") && ISGRAPH ((unsigned char) *n))
+ || (STREQ (str, "lower") && ISLOWER ((unsigned char) *n))
+ || (STREQ (str, "print") && ISPRINT ((unsigned char) *n))
+ || (STREQ (str, "punct") && ISPUNCT ((unsigned char) *n))
+ || (STREQ (str, "space") && ISSPACE ((unsigned char) *n))
+ || (STREQ (str, "upper") && ISUPPER ((unsigned char) *n))
+ || (STREQ (str, "xdigit") && ISXDIGIT ((unsigned char) *n)))
+ goto matched;
+# endif
+ }
+ else if (c == '\0')
+ /* [ (unterminated) loses. */
+ return FNM_NOMATCH;
+ else
+ {
+ normal_bracket:
+ if (FOLD (c) == fn)
+ goto matched;
+
+ cold = c;
+ c = *p++;
+
+ if (c == '-' && *p != ']')
+ {
+ /* It is a range. */
+ unsigned char cend = *p++;
+ if (!(flags & FNM_NOESCAPE) && cend == '\\')
+ cend = *p++;
+ if (cend == '\0')
+ return FNM_NOMATCH;
+
+ if (cold <= fn && fn <= FOLD (cend))
+ goto matched;
+
+ c = *p++;
+ }
+ }
+
+ if (c == ']')
+ break;
+ }
+
+ if (!not)
+ return FNM_NOMATCH;
+ break;
+
+ matched:
+ /* Skip the rest of the [...] that already matched. */
+ while (c != ']')
+ {
+ if (c == '\0')
+ /* [... (unterminated) loses. */
+ return FNM_NOMATCH;
+
+ c = *p++;
+ if (!(flags & FNM_NOESCAPE) && c == '\\')
+ {
+ if (*p == '\0')
+ return FNM_NOMATCH;
+ /* XXX 1003.2d11 is unclear if this is right. */
+ ++p;
+ }
+ else if (c == '[' && *p == ':')
+ {
+ do
+ if (*++p == '\0')
+ return FNM_NOMATCH;
+ while (*p != ':' || p[1] == ']');
+ p += 2;
+ c = *p;
+ }
+ }
+ if (not)
+ return FNM_NOMATCH;
+ }
+ break;
+
+ default:
+ if (c != FOLD ((unsigned char) *n))
+ return FNM_NOMATCH;
+ }
+
+ ++n;
+ }
+
+ if (*n == '\0')
+ return 0;
+
+ if ((flags & FNM_LEADING_DIR) && *n == '/')
+ /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
+ return 0;
+
+ return FNM_NOMATCH;
+
+# undef FOLD
+}
+
+
+int
+fnmatch (pattern, string, flags)
+ const char *pattern;
+ const char *string;
+ int flags;
+{
+ return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
+}
+
+#endif /* _LIBC or not __GNU_LIBRARY__. */
diff --git a/compat/fnmatch.h b/compat/fnmatch.h
new file mode 100644
index 000000000..cc3ec3794
--- /dev/null
+++ b/compat/fnmatch.h
@@ -0,0 +1,84 @@
+/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _FNMATCH_H
+#define _FNMATCH_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
+# if !defined __GLIBC__ || !defined __P
+# undef __P
+# define __P(protos) protos
+# endif
+#else /* Not C++ or ANSI C. */
+# undef __P
+# define __P(protos) ()
+/* We can get away without defining `const' here only because in this file
+ it is used only inside the prototype for `fnmatch', which is elided in
+ non-ANSI C where `const' is problematical. */
+#endif /* C++ or ANSI C. */
+
+#ifndef const
+# if (defined __STDC__ && __STDC__) || defined __cplusplus
+# define __const const
+# else
+# define __const
+# endif
+#endif
+
+/* We #undef these before defining them because some losing systems
+ (HP-UX A.08.07 for example) define these in <unistd.h>. */
+#undef FNM_PATHNAME
+#undef FNM_NOESCAPE
+#undef FNM_PERIOD
+
+/* Bits set in the FLAGS argument to `fnmatch'. */
+#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
+#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
+#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
+
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
+# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
+# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
+# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
+#endif
+
+/* Value returned by `fnmatch' if STRING does not match PATTERN. */
+#define FNM_NOMATCH 1
+
+/* This value is returned if the implementation does not support
+ `fnmatch'. Since this is not the case here it will never be
+ returned but the conformance test suites still require the symbol
+ to be defined. */
+#ifdef _XOPEN_SOURCE
+# define FNM_NOSYS (-1)
+#endif
+
+/* Match NAME against the filename pattern PATTERN,
+ returning zero if it matches, FNM_NOMATCH if not. */
+extern int fnmatch __P ((__const char *__pattern, __const char *__name,
+ int __flags));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* fnmatch.h */
diff --git a/compat/fopen.c b/compat/fopen.c
new file mode 100644
index 000000000..b5ca142fe
--- /dev/null
+++ b/compat/fopen.c
@@ -0,0 +1,37 @@
+/*
+ * The order of the following two lines is important.
+ *
+ * FREAD_READS_DIRECTORIES is undefined before including git-compat-util.h
+ * to avoid the redefinition of fopen within git-compat-util.h. This is
+ * necessary since fopen is a macro on some platforms which may be set
+ * based on compiler options. For example, on AIX fopen is set to fopen64
+ * when _LARGE_FILES is defined. The previous technique of merely undefining
+ * fopen after including git-compat-util.h is inadequate in this case.
+ */
+#undef FREAD_READS_DIRECTORIES
+#include "../git-compat-util.h"
+
+FILE *git_fopen(const char *path, const char *mode)
+{
+ FILE *fp;
+ struct stat st;
+
+ if (mode[0] == 'w' || mode[0] == 'a')
+ return fopen(path, mode);
+
+ if (!(fp = fopen(path, mode)))
+ return NULL;
+
+ if (fstat(fileno(fp), &st)) {
+ fclose(fp);
+ return NULL;
+ }
+
+ if (S_ISDIR(st.st_mode)) {
+ fclose(fp);
+ errno = EISDIR;
+ return NULL;
+ }
+
+ return fp;
+}
diff --git a/compat/mingw.c b/compat/mingw.c
new file mode 100644
index 000000000..772cad510
--- /dev/null
+++ b/compat/mingw.c
@@ -0,0 +1,1042 @@
+#include "../git-compat-util.h"
+#include "../strbuf.h"
+
+unsigned int _CRT_fmode = _O_BINARY;
+
+#undef open
+int mingw_open (const char *filename, int oflags, ...)
+{
+ va_list args;
+ unsigned mode;
+ va_start(args, oflags);
+ mode = va_arg(args, int);
+ va_end(args);
+
+ if (!strcmp(filename, "/dev/null"))
+ filename = "nul";
+ int fd = open(filename, oflags, mode);
+ if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
+ DWORD attrs = GetFileAttributes(filename);
+ if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
+ errno = EISDIR;
+ }
+ return fd;
+}
+
+static inline time_t filetime_to_time_t(const FILETIME *ft)
+{
+ long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime;
+ winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
+ winTime /= 10000000; /* Nano to seconds resolution */
+ return (time_t)winTime;
+}
+
+static inline size_t size_to_blocks(size_t s)
+{
+ return (s+511)/512;
+}
+
+extern int _getdrive( void );
+/* We keep the do_lstat code in a separate function to avoid recursion.
+ * When a path ends with a slash, the stat will fail with ENOENT. In
+ * this case, we strip the trailing slashes and stat again.
+ */
+static int do_lstat(const char *file_name, struct stat *buf)
+{
+ WIN32_FILE_ATTRIBUTE_DATA fdata;
+
+ if (GetFileAttributesExA(file_name, GetFileExInfoStandard, &fdata)) {
+ int fMode = S_IREAD;
+ if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ fMode |= S_IFDIR;
+ else
+ fMode |= S_IFREG;
+ if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ fMode |= S_IWRITE;
+
+ buf->st_ino = 0;
+ buf->st_gid = 0;
+ buf->st_uid = 0;
+ buf->st_mode = fMode;
+ buf->st_size = fdata.nFileSizeLow; /* Can't use nFileSizeHigh, since it's not a stat64 */
+ buf->st_blocks = size_to_blocks(buf->st_size);
+ buf->st_dev = _getdrive() - 1;
+ buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
+ buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
+ buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
+ errno = 0;
+ return 0;
+ }
+
+ switch (GetLastError()) {
+ case ERROR_ACCESS_DENIED:
+ case ERROR_SHARING_VIOLATION:
+ case ERROR_LOCK_VIOLATION:
+ case ERROR_SHARING_BUFFER_EXCEEDED:
+ errno = EACCES;
+ break;
+ case ERROR_BUFFER_OVERFLOW:
+ errno = ENAMETOOLONG;
+ break;
+ case ERROR_NOT_ENOUGH_MEMORY:
+ errno = ENOMEM;
+ break;
+ default:
+ errno = ENOENT;
+ break;
+ }
+ return -1;
+}
+
+/* We provide our own lstat/fstat functions, since the provided
+ * lstat/fstat functions are so slow. These stat functions are
+ * tailored for Git's usage (read: fast), and are not meant to be
+ * complete. Note that Git stat()s are redirected to mingw_lstat()
+ * too, since Windows doesn't really handle symlinks that well.
+ */
+int mingw_lstat(const char *file_name, struct mingw_stat *buf)
+{
+ int namelen;
+ static char alt_name[PATH_MAX];
+
+ if (!do_lstat(file_name, buf))
+ return 0;
+
+ /* if file_name ended in a '/', Windows returned ENOENT;
+ * try again without trailing slashes
+ */
+ if (errno != ENOENT)
+ return -1;
+
+ namelen = strlen(file_name);
+ if (namelen && file_name[namelen-1] != '/')
+ return -1;
+ while (namelen && file_name[namelen-1] == '/')
+ --namelen;
+ if (!namelen || namelen >= PATH_MAX)
+ return -1;
+
+ memcpy(alt_name, file_name, namelen);
+ alt_name[namelen] = 0;
+ return do_lstat(alt_name, buf);
+}
+
+#undef fstat
+#undef stat
+int mingw_fstat(int fd, struct mingw_stat *buf)
+{
+ HANDLE fh = (HANDLE)_get_osfhandle(fd);
+ BY_HANDLE_FILE_INFORMATION fdata;
+
+ if (fh == INVALID_HANDLE_VALUE) {
+ errno = EBADF;
+ return -1;
+ }
+ /* direct non-file handles to MS's fstat() */
+ if (GetFileType(fh) != FILE_TYPE_DISK) {
+ struct stat st;
+ if (fstat(fd, &st))
+ return -1;
+ buf->st_ino = st.st_ino;
+ buf->st_gid = st.st_gid;
+ buf->st_uid = st.st_uid;
+ buf->st_mode = st.st_mode;
+ buf->st_size = st.st_size;
+ buf->st_blocks = size_to_blocks(buf->st_size);
+ buf->st_dev = st.st_dev;
+ buf->st_atime = st.st_atime;
+ buf->st_mtime = st.st_mtime;
+ buf->st_ctime = st.st_ctime;
+ return 0;
+ }
+
+ if (GetFileInformationByHandle(fh, &fdata)) {
+ int fMode = S_IREAD;
+ if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ fMode |= S_IFDIR;
+ else
+ fMode |= S_IFREG;
+ if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
+ fMode |= S_IWRITE;
+
+ buf->st_ino = 0;
+ buf->st_gid = 0;
+ buf->st_uid = 0;
+ buf->st_mode = fMode;
+ buf->st_size = fdata.nFileSizeLow; /* Can't use nFileSizeHigh, since it's not a stat64 */
+ buf->st_blocks = size_to_blocks(buf->st_size);
+ buf->st_dev = _getdrive() - 1;
+ buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
+ buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
+ buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
+ return 0;
+ }
+ errno = EBADF;
+ return -1;
+}
+
+static inline void time_t_to_filetime(time_t t, FILETIME *ft)
+{
+ long long winTime = t * 10000000LL + 116444736000000000LL;
+ ft->dwLowDateTime = winTime;
+ ft->dwHighDateTime = winTime >> 32;
+}
+
+int mingw_utime (const char *file_name, const struct utimbuf *times)
+{
+ FILETIME mft, aft;
+ int fh, rc;
+
+ /* must have write permission */
+ if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0)
+ return -1;
+
+ time_t_to_filetime(times->modtime, &mft);
+ time_t_to_filetime(times->actime, &aft);
+ if (!SetFileTime((HANDLE)_get_osfhandle(fh), NULL, &aft, &mft)) {
+ errno = EINVAL;
+ rc = -1;
+ } else
+ rc = 0;
+ close(fh);
+ return rc;
+}
+
+unsigned int sleep (unsigned int seconds)
+{
+ Sleep(seconds*1000);
+ return 0;
+}
+
+int mkstemp(char *template)
+{
+ char *filename = mktemp(template);
+ if (filename == NULL)
+ return -1;
+ return open(filename, O_RDWR | O_CREAT, 0600);
+}
+
+int gettimeofday(struct timeval *tv, void *tz)
+{
+ SYSTEMTIME st;
+ struct tm tm;
+ GetSystemTime(&st);
+ tm.tm_year = st.wYear-1900;
+ tm.tm_mon = st.wMonth-1;
+ tm.tm_mday = st.wDay;
+ tm.tm_hour = st.wHour;
+ tm.tm_min = st.wMinute;
+ tm.tm_sec = st.wSecond;
+ tv->tv_sec = tm_to_time_t(&tm);
+ if (tv->tv_sec < 0)
+ return -1;
+ tv->tv_usec = st.wMilliseconds*1000;
+ return 0;
+}
+
+int pipe(int filedes[2])
+{
+ int fd;
+ HANDLE h[2], parent;
+
+ if (_pipe(filedes, 8192, 0) < 0)
+ return -1;
+
+ parent = GetCurrentProcess();
+
+ if (!DuplicateHandle (parent, (HANDLE)_get_osfhandle(filedes[0]),
+ parent, &h[0], 0, FALSE, DUPLICATE_SAME_ACCESS)) {
+ close(filedes[0]);
+ close(filedes[1]);
+ return -1;
+ }
+ if (!DuplicateHandle (parent, (HANDLE)_get_osfhandle(filedes[1]),
+ parent, &h[1], 0, FALSE, DUPLICATE_SAME_ACCESS)) {
+ close(filedes[0]);
+ close(filedes[1]);
+ CloseHandle(h[0]);
+ return -1;
+ }
+ fd = _open_osfhandle((int)h[0], O_NOINHERIT);
+ if (fd < 0) {
+ close(filedes[0]);
+ close(filedes[1]);
+ CloseHandle(h[0]);
+ CloseHandle(h[1]);
+ return -1;
+ }
+ close(filedes[0]);
+ filedes[0] = fd;
+ fd = _open_osfhandle((int)h[1], O_NOINHERIT);
+ if (fd < 0) {
+ close(filedes[0]);
+ close(filedes[1]);
+ CloseHandle(h[1]);
+ return -1;
+ }
+ close(filedes[1]);
+ filedes[1] = fd;
+ return 0;
+}
+
+int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
+{
+ int i, pending;
+
+ if (timeout != -1)
+ return errno = EINVAL, error("poll timeout not supported");
+
+ /* When there is only one fd to wait for, then we pretend that
+ * input is available and let the actual wait happen when the
+ * caller invokes read().
+ */
+ if (nfds == 1) {
+ if (!(ufds[0].events & POLLIN))
+ return errno = EINVAL, error("POLLIN not set");
+ ufds[0].revents = POLLIN;
+ return 0;
+ }
+
+repeat:
+ pending = 0;
+ for (i = 0; i < nfds; i++) {
+ DWORD avail = 0;
+ HANDLE h = (HANDLE) _get_osfhandle(ufds[i].fd);
+ if (h == INVALID_HANDLE_VALUE)
+ return -1; /* errno was set */
+
+ if (!(ufds[i].events & POLLIN))
+ return errno = EINVAL, error("POLLIN not set");
+
+ /* this emulation works only for pipes */
+ if (!PeekNamedPipe(h, NULL, 0, NULL, &avail, NULL)) {
+ int err = GetLastError();
+ if (err == ERROR_BROKEN_PIPE) {
+ ufds[i].revents = POLLHUP;
+ pending++;
+ } else {
+ errno = EINVAL;
+ return error("PeekNamedPipe failed,"
+ " GetLastError: %u", err);
+ }
+ } else if (avail) {
+ ufds[i].revents = POLLIN;
+ pending++;
+ } else
+ ufds[i].revents = 0;
+ }
+ if (!pending) {
+ /* The only times that we spin here is when the process
+ * that is connected through the pipes is waiting for
+ * its own input data to become available. But since
+ * the process (pack-objects) is itself CPU intensive,
+ * it will happily pick up the time slice that we are
+ * relinguishing here.
+ */
+ Sleep(0);
+ goto repeat;
+ }
+ return 0;
+}
+
+struct tm *gmtime_r(const time_t *timep, struct tm *result)
+{
+ /* gmtime() in MSVCRT.DLL is thread-safe, but not reentrant */
+ memcpy(result, gmtime(timep), sizeof(struct tm));
+ return result;
+}
+
+struct tm *localtime_r(const time_t *timep, struct tm *result)
+{
+ /* localtime() in MSVCRT.DLL is thread-safe, but not reentrant */
+ memcpy(result, localtime(timep), sizeof(struct tm));
+ return result;
+}
+
+#undef getcwd
+char *mingw_getcwd(char *pointer, int len)
+{
+ int i;
+ char *ret = getcwd(pointer, len);
+ if (!ret)
+ return ret;
+ for (i = 0; pointer[i]; i++)
+ if (pointer[i] == '\\')
+ pointer[i] = '/';
+ return ret;
+}
+
+#undef getenv
+char *mingw_getenv(const char *name)
+{
+ char *result = getenv(name);
+ if (!result && !strcmp(name, "TMPDIR")) {
+ /* on Windows it is TMP and TEMP */
+ result = getenv("TMP");
+ if (!result)
+ result = getenv("TEMP");
+ }
+ return result;
+}
+
+/*
+ * See http://msdn2.microsoft.com/en-us/library/17w5ykft(vs.71).aspx
+ * (Parsing C++ Command-Line Arguments)
+ */
+static const char *quote_arg(const char *arg)
+{
+ /* count chars to quote */
+ int len = 0, n = 0;
+ int force_quotes = 0;
+ char *q, *d;
+ const char *p = arg;
+ if (!*p) force_quotes = 1;
+ while (*p) {
+ if (isspace(*p) || *p == '*' || *p == '?' || *p == '{')
+ force_quotes = 1;
+ else if (*p == '"')
+ n++;
+ else if (*p == '\\') {
+ int count = 0;
+ while (*p == '\\') {
+ count++;
+ p++;
+ len++;
+ }
+ if (*p == '"')
+ n += count*2 + 1;
+ continue;
+ }
+ len++;
+ p++;
+ }
+ if (!force_quotes && n == 0)
+ return arg;
+
+ /* insert \ where necessary */
+ d = q = xmalloc(len+n+3);
+ *d++ = '"';
+ while (*arg) {
+ if (*arg == '"')
+ *d++ = '\\';
+ else if (*arg == '\\') {
+ int count = 0;
+ while (*arg == '\\') {
+ count++;
+ *d++ = *arg++;
+ }
+ if (*arg == '"') {
+ while (count-- > 0)
+ *d++ = '\\';
+ *d++ = '\\';
+ }
+ }
+ *d++ = *arg++;
+ }
+ *d++ = '"';
+ *d++ = 0;
+ return q;
+}
+
+static const char *parse_interpreter(const char *cmd)
+{
+ static char buf[100];
+ char *p, *opt;
+ int n, fd;
+
+ /* don't even try a .exe */
+ n = strlen(cmd);
+ if (n >= 4 && !strcasecmp(cmd+n-4, ".exe"))
+ return NULL;
+
+ fd = open(cmd, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+ n = read(fd, buf, sizeof(buf)-1);
+ close(fd);
+ if (n < 4) /* at least '#!/x' and not error */
+ return NULL;
+
+ if (buf[0] != '#' || buf[1] != '!')
+ return NULL;
+ buf[n] = '\0';
+ p = strchr(buf, '\n');
+ if (!p)
+ return NULL;
+
+ *p = '\0';
+ if (!(p = strrchr(buf+2, '/')) && !(p = strrchr(buf+2, '\\')))
+ return NULL;
+ /* strip options */
+ if ((opt = strchr(p+1, ' ')))
+ *opt = '\0';
+ return p+1;
+}
+
+/*
+ * Splits the PATH into parts.
+ */
+static char **get_path_split(void)
+{
+ char *p, **path, *envpath = getenv("PATH");
+ int i, n = 0;
+
+ if (!envpath || !*envpath)
+ return NULL;
+
+ envpath = xstrdup(envpath);
+ p = envpath;
+ while (p) {
+ char *dir = p;
+ p = strchr(p, ';');
+ if (p) *p++ = '\0';
+ if (*dir) { /* not earlier, catches series of ; */
+ ++n;
+ }
+ }
+ if (!n)
+ return NULL;
+
+ path = xmalloc((n+1)*sizeof(char*));
+ p = envpath;
+ i = 0;
+ do {
+ if (*p)
+ path[i++] = xstrdup(p);
+ p = p+strlen(p)+1;
+ } while (i < n);
+ path[i] = NULL;
+
+ free(envpath);
+
+ return path;
+}
+
+static void free_path_split(char **path)
+{
+ if (!path)
+ return;
+
+ char **p = path;
+ while (*p)
+ free(*p++);
+ free(path);
+}
+
+/*
+ * exe_only means that we only want to detect .exe files, but not scripts
+ * (which do not have an extension)
+ */
+static char *lookup_prog(const char *dir, const char *cmd, int isexe, int exe_only)
+{
+ char path[MAX_PATH];
+ snprintf(path, sizeof(path), "%s/%s.exe", dir, cmd);
+
+ if (!isexe && access(path, F_OK) == 0)
+ return xstrdup(path);
+ path[strlen(path)-4] = '\0';
+ if ((!exe_only || isexe) && access(path, F_OK) == 0)
+ if (!(GetFileAttributes(path) & FILE_ATTRIBUTE_DIRECTORY))
+ return xstrdup(path);
+ return NULL;
+}
+
+/*
+ * Determines the absolute path of cmd using the the split path in path.
+ * If cmd contains a slash or backslash, no lookup is performed.
+ */
+static char *path_lookup(const char *cmd, char **path, int exe_only)
+{
+ char *prog = NULL;
+ int len = strlen(cmd);
+ int isexe = len >= 4 && !strcasecmp(cmd+len-4, ".exe");
+
+ if (strchr(cmd, '/') || strchr(cmd, '\\'))
+ prog = xstrdup(cmd);
+
+ while (!prog && *path)
+ prog = lookup_prog(*path++, cmd, isexe, exe_only);
+
+ return prog;
+}
+
+static int env_compare(const void *a, const void *b)
+{
+ char *const *ea = a;
+ char *const *eb = b;
+ return strcasecmp(*ea, *eb);
+}
+
+static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,
+ int prepend_cmd)
+{
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ struct strbuf envblk, args;
+ unsigned flags;
+ BOOL ret;
+
+ /* Determine whether or not we are associated to a console */
+ HANDLE cons = CreateFile("CONOUT$", GENERIC_WRITE,
+ FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (cons == INVALID_HANDLE_VALUE) {
+ /* There is no console associated with this process.
+ * Since the child is a console process, Windows
+ * would normally create a console window. But
+ * since we'll be redirecting std streams, we do
+ * not need the console.
+ */
+ flags = CREATE_NO_WINDOW;
+ } else {
+ /* There is already a console. If we specified
+ * CREATE_NO_WINDOW here, too, Windows would
+ * disassociate the child from the console.
+ * Go figure!
+ */
+ flags = 0;
+ CloseHandle(cons);
+ }
+ memset(&si, 0, sizeof(si));
+ si.cb = sizeof(si);
+ si.dwFlags = STARTF_USESTDHANDLES;
+ si.hStdInput = (HANDLE) _get_osfhandle(0);
+ si.hStdOutput = (HANDLE) _get_osfhandle(1);
+ si.hStdError = (HANDLE) _get_osfhandle(2);
+
+ /* concatenate argv, quoting args as we go */
+ strbuf_init(&args, 0);
+ if (prepend_cmd) {
+ char *quoted = (char *)quote_arg(cmd);
+ strbuf_addstr(&args, quoted);
+ if (quoted != cmd)
+ free(quoted);
+ }
+ for (; *argv; argv++) {
+ char *quoted = (char *)quote_arg(*argv);
+ if (*args.buf)
+ strbuf_addch(&args, ' ');
+ strbuf_addstr(&args, quoted);
+ if (quoted != *argv)
+ free(quoted);
+ }
+
+ if (env) {
+ int count = 0;
+ char **e, **sorted_env;
+
+ for (e = env; *e; e++)
+ count++;
+
+ /* environment must be sorted */
+ sorted_env = xmalloc(sizeof(*sorted_env) * (count + 1));
+ memcpy(sorted_env, env, sizeof(*sorted_env) * (count + 1));
+ qsort(sorted_env, count, sizeof(*sorted_env), env_compare);
+
+ strbuf_init(&envblk, 0);
+ for (e = sorted_env; *e; e++) {
+ strbuf_addstr(&envblk, *e);
+ strbuf_addch(&envblk, '\0');
+ }
+ free(sorted_env);
+ }
+
+ memset(&pi, 0, sizeof(pi));
+ ret = CreateProcess(cmd, args.buf, NULL, NULL, TRUE, flags,
+ env ? envblk.buf : NULL, NULL, &si, &pi);
+
+ if (env)
+ strbuf_release(&envblk);
+ strbuf_release(&args);
+
+ if (!ret) {
+ errno = ENOENT;
+ return -1;
+ }
+ CloseHandle(pi.hThread);
+ return (pid_t)pi.hProcess;
+}
+
+pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env)
+{
+ pid_t pid;
+ char **path = get_path_split();
+ char *prog = path_lookup(cmd, path, 0);
+
+ if (!prog) {
+ errno = ENOENT;
+ pid = -1;
+ }
+ else {
+ const char *interpr = parse_interpreter(prog);
+
+ if (interpr) {
+ const char *argv0 = argv[0];
+ char *iprog = path_lookup(interpr, path, 1);
+ argv[0] = prog;
+ if (!iprog) {
+ errno = ENOENT;
+ pid = -1;
+ }
+ else {
+ pid = mingw_spawnve(iprog, argv, env, 1);
+ free(iprog);
+ }
+ argv[0] = argv0;
+ }
+ else
+ pid = mingw_spawnve(prog, argv, env, 0);
+ free(prog);
+ }
+ free_path_split(path);
+ return pid;
+}
+
+static int try_shell_exec(const char *cmd, char *const *argv, char **env)
+{
+ const char *interpr = parse_interpreter(cmd);
+ char **path;
+ char *prog;
+ int pid = 0;
+
+ if (!interpr)
+ return 0;
+ path = get_path_split();
+ prog = path_lookup(interpr, path, 1);
+ if (prog) {
+ int argc = 0;
+ const char **argv2;
+ while (argv[argc]) argc++;
+ argv2 = xmalloc(sizeof(*argv) * (argc+1));
+ argv2[0] = (char *)cmd; /* full path to the script file */
+ memcpy(&argv2[1], &argv[1], sizeof(*argv) * argc);
+ pid = mingw_spawnve(prog, argv2, env, 1);
+ if (pid >= 0) {
+ int status;
+ if (waitpid(pid, &status, 0) < 0)
+ status = 255;
+ exit(status);
+ }
+ pid = 1; /* indicate that we tried but failed */
+ free(prog);
+ free(argv2);
+ }
+ free_path_split(path);
+ return pid;
+}
+
+static void mingw_execve(const char *cmd, char *const *argv, char *const *env)
+{
+ /* check if git_command is a shell script */
+ if (!try_shell_exec(cmd, argv, (char **)env)) {
+ int pid, status;
+
+ pid = mingw_spawnve(cmd, (const char **)argv, (char **)env, 0);
+ if (pid < 0)
+ return;
+ if (waitpid(pid, &status, 0) < 0)
+ status = 255;
+ exit(status);
+ }
+}
+
+void mingw_execvp(const char *cmd, char *const *argv)
+{
+ char **path = get_path_split();
+ char *prog = path_lookup(cmd, path, 0);
+
+ if (prog) {
+ mingw_execve(prog, argv, environ);
+ free(prog);
+ } else
+ errno = ENOENT;
+
+ free_path_split(path);
+}
+
+char **copy_environ()
+{
+ char **env;
+ int i = 0;
+ while (environ[i])
+ i++;
+ env = xmalloc((i+1)*sizeof(*env));
+ for (i = 0; environ[i]; i++)
+ env[i] = xstrdup(environ[i]);
+ env[i] = NULL;
+ return env;
+}
+
+void free_environ(char **env)
+{
+ int i;
+ for (i = 0; env[i]; i++)
+ free(env[i]);
+ free(env);
+}
+
+static int lookup_env(char **env, const char *name, size_t nmln)
+{
+ int i;
+
+ for (i = 0; env[i]; i++) {
+ if (0 == strncmp(env[i], name, nmln)
+ && '=' == env[i][nmln])
+ /* matches */
+ return i;
+ }
+ return -1;
+}
+
+/*
+ * If name contains '=', then sets the variable, otherwise it unsets it
+ */
+char **env_setenv(char **env, const char *name)
+{
+ char *eq = strchrnul(name, '=');
+ int i = lookup_env(env, name, eq-name);
+
+ if (i < 0) {
+ if (*eq) {
+ for (i = 0; env[i]; i++)
+ ;
+ env = xrealloc(env, (i+2)*sizeof(*env));
+ env[i] = xstrdup(name);
+ env[i+1] = NULL;
+ }
+ }
+ else {
+ free(env[i]);
+ if (*eq)
+ env[i] = xstrdup(name);
+ else
+ for (; env[i]; i++)
+ env[i] = env[i+1];
+ }
+ return env;
+}
+
+/* this is the first function to call into WS_32; initialize it */
+#undef gethostbyname
+struct hostent *mingw_gethostbyname(const char *host)
+{
+ WSADATA wsa;
+
+ if (WSAStartup(MAKEWORD(2,2), &wsa))
+ die("unable to initialize winsock subsystem, error %d",
+ WSAGetLastError());
+ atexit((void(*)(void)) WSACleanup);
+ return gethostbyname(host);
+}
+
+int mingw_socket(int domain, int type, int protocol)
+{
+ int sockfd;
+ SOCKET s = WSASocket(domain, type, protocol, NULL, 0, 0);
+ if (s == INVALID_SOCKET) {
+ /*
+ * WSAGetLastError() values are regular BSD error codes
+ * biased by WSABASEERR.
+ * However, strerror() does not know about networking
+ * specific errors, which are values beginning at 38 or so.
+ * Therefore, we choose to leave the biased error code
+ * in errno so that _if_ someone looks up the code somewhere,
+ * then it is at least the number that are usually listed.
+ */
+ errno = WSAGetLastError();
+ return -1;
+ }
+ /* convert into a file descriptor */
+ if ((sockfd = _open_osfhandle(s, O_RDWR|O_BINARY)) < 0) {
+ closesocket(s);
+ return error("unable to make a socket file descriptor: %s",
+ strerror(errno));
+ }
+ return sockfd;
+}
+
+#undef connect
+int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz)
+{
+ SOCKET s = (SOCKET)_get_osfhandle(sockfd);
+ return connect(s, sa, sz);
+}
+
+#undef rename
+int mingw_rename(const char *pold, const char *pnew)
+{
+ /*
+ * Try native rename() first to get errno right.
+ * It is based on MoveFile(), which cannot overwrite existing files.
+ */
+ if (!rename(pold, pnew))
+ return 0;
+ if (errno != EEXIST)
+ return -1;
+ if (MoveFileEx(pold, pnew, MOVEFILE_REPLACE_EXISTING))
+ return 0;
+ /* TODO: translate more errors */
+ if (GetLastError() == ERROR_ACCESS_DENIED) {
+ DWORD attrs = GetFileAttributes(pnew);
+ if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
+ errno = EISDIR;
+ return -1;
+ }
+ }
+ errno = EACCES;
+ return -1;
+}
+
+struct passwd *getpwuid(int uid)
+{
+ static char user_name[100];
+ static struct passwd p;
+
+ DWORD len = sizeof(user_name);
+ if (!GetUserName(user_name, &len))
+ return NULL;
+ p.pw_name = user_name;
+ p.pw_gecos = "unknown";
+ p.pw_dir = NULL;
+ return &p;
+}
+
+static HANDLE timer_event;
+static HANDLE timer_thread;
+static int timer_interval;
+static int one_shot;
+static sig_handler_t timer_fn = SIG_DFL;
+
+/* The timer works like this:
+ * The thread, ticktack(), is a trivial routine that most of the time
+ * only waits to receive the signal to terminate. The main thread tells
+ * the thread to terminate by setting the timer_event to the signalled
+ * state.
+ * But ticktack() interrupts the wait state after the timer's interval
+ * length to call the signal handler.
+ */
+
+static __stdcall unsigned ticktack(void *dummy)
+{
+ while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
+ if (timer_fn == SIG_DFL)
+ die("Alarm");
+ if (timer_fn != SIG_IGN)
+ timer_fn(SIGALRM);
+ if (one_shot)
+ break;
+ }
+ return 0;
+}
+
+static int start_timer_thread(void)
+{
+ timer_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (timer_event) {
+ timer_thread = (HANDLE) _beginthreadex(NULL, 0, ticktack, NULL, 0, NULL);
+ if (!timer_thread )
+ return errno = ENOMEM,
+ error("cannot start timer thread");
+ } else
+ return errno = ENOMEM,
+ error("cannot allocate resources for timer");
+ return 0;
+}
+
+static void stop_timer_thread(void)
+{
+ if (timer_event)
+ SetEvent(timer_event); /* tell thread to terminate */
+ if (timer_thread) {
+ int rc = WaitForSingleObject(timer_thread, 1000);
+ if (rc == WAIT_TIMEOUT)
+ error("timer thread did not terminate timely");
+ else if (rc != WAIT_OBJECT_0)
+ error("waiting for timer thread failed: %lu",
+ GetLastError());
+ CloseHandle(timer_thread);
+ }
+ if (timer_event)
+ CloseHandle(timer_event);
+ timer_event = NULL;
+ timer_thread = NULL;
+}
+
+static inline int is_timeval_eq(const struct timeval *i1, const struct timeval *i2)
+{
+ return i1->tv_sec == i2->tv_sec && i1->tv_usec == i2->tv_usec;
+}
+
+int setitimer(int type, struct itimerval *in, struct itimerval *out)
+{
+ static const struct timeval zero;
+ static int atexit_done;
+
+ if (out != NULL)
+ return errno = EINVAL,
+ error("setitimer param 3 != NULL not implemented");
+ if (!is_timeval_eq(&in->it_interval, &zero) &&
+ !is_timeval_eq(&in->it_interval, &in->it_value))
+ return errno = EINVAL,
+ error("setitimer: it_interval must be zero or eq it_value");
+
+ if (timer_thread)
+ stop_timer_thread();
+
+ if (is_timeval_eq(&in->it_value, &zero) &&
+ is_timeval_eq(&in->it_interval, &zero))
+ return 0;
+
+ timer_interval = in->it_value.tv_sec * 1000 + in->it_value.tv_usec / 1000;
+ one_shot = is_timeval_eq(&in->it_interval, &zero);
+ if (!atexit_done) {
+ atexit(stop_timer_thread);
+ atexit_done = 1;
+ }
+ return start_timer_thread();
+}
+
+int sigaction(int sig, struct sigaction *in, struct sigaction *out)
+{
+ if (sig != SIGALRM)
+ return errno = EINVAL,
+ error("sigaction only implemented for SIGALRM");
+ if (out != NULL)
+ return errno = EINVAL,
+ error("sigaction: param 3 != NULL not implemented");
+
+ timer_fn = in->sa_handler;
+ return 0;
+}
+
+#undef signal
+sig_handler_t mingw_signal(int sig, sig_handler_t handler)
+{
+ if (sig != SIGALRM)
+ return signal(sig, handler);
+ sig_handler_t old = timer_fn;
+ timer_fn = handler;
+ return old;
+}
+
+static const char *make_backslash_path(const char *path)
+{
+ static char buf[PATH_MAX + 1];
+ char *c;
+
+ if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
+ die("Too long path: %.*s", 60, path);
+
+ for (c = buf; *c; c++) {
+ if (*c == '/')
+ *c = '\\';
+ }
+ return buf;
+}
+
+void mingw_open_html(const char *unixpath)
+{
+ const char *htmlpath = make_backslash_path(unixpath);
+ printf("Launching default browser to display HTML ...\n");
+ ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0);
+}
diff --git a/compat/mingw.h b/compat/mingw.h
new file mode 100644
index 000000000..a52e657c5
--- /dev/null
+++ b/compat/mingw.h
@@ -0,0 +1,238 @@
+#include <winsock2.h>
+
+/*
+ * things that are not available in header files
+ */
+
+typedef int pid_t;
+#define hstrerror strerror
+
+#define S_IFLNK 0120000 /* Symbolic link */
+#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
+#define S_ISSOCK(x) 0
+#define S_IRGRP 0
+#define S_IWGRP 0
+#define S_IXGRP 0
+#define S_ISGID 0
+#define S_IROTH 0
+#define S_IXOTH 0
+
+#define WIFEXITED(x) ((unsigned)(x) < 259) /* STILL_ACTIVE */
+#define WEXITSTATUS(x) ((x) & 0xff)
+#define WIFSIGNALED(x) ((unsigned)(x) > 259)
+
+#define SIGKILL 0
+#define SIGCHLD 0
+#define SIGPIPE 0
+#define SIGHUP 0
+#define SIGQUIT 0
+#define SIGALRM 100
+
+#define F_GETFD 1
+#define F_SETFD 2
+#define FD_CLOEXEC 0x1
+
+struct passwd {
+ char *pw_name;
+ char *pw_gecos;
+ char *pw_dir;
+};
+
+struct pollfd {
+ int fd; /* file descriptor */
+ short events; /* requested events */
+ short revents; /* returned events */
+};
+#define POLLIN 1
+#define POLLHUP 2
+
+typedef void (__cdecl *sig_handler_t)(int);
+struct sigaction {
+ sig_handler_t sa_handler;
+ unsigned sa_flags;
+};
+#define sigemptyset(x) (void)0
+#define SA_RESTART 0
+
+struct itimerval {
+ struct timeval it_value, it_interval;
+};
+#define ITIMER_REAL 0
+
+/*
+ * trivial stubs
+ */
+
+static inline int readlink(const char *path, char *buf, size_t bufsiz)
+{ errno = ENOSYS; return -1; }
+static inline int symlink(const char *oldpath, const char *newpath)
+{ errno = ENOSYS; return -1; }
+static inline int link(const char *oldpath, const char *newpath)
+{ errno = ENOSYS; return -1; }
+static inline int fchmod(int fildes, mode_t mode)
+{ errno = ENOSYS; return -1; }
+static inline int fork(void)
+{ errno = ENOSYS; return -1; }
+static inline unsigned int alarm(unsigned int seconds)
+{ return 0; }
+static inline int fsync(int fd)
+{ return 0; }
+static inline int getppid(void)
+{ return 1; }
+static inline void sync(void)
+{}
+static inline int getuid()
+{ return 1; }
+static inline struct passwd *getpwnam(const char *name)
+{ return NULL; }
+static inline int fcntl(int fd, int cmd, long arg)
+{
+ if (cmd == F_GETFD || cmd == F_SETFD)
+ return 0;
+ errno = EINVAL;
+ return -1;
+}
+
+/*
+ * simple adaptors
+ */
+
+static inline int mingw_mkdir(const char *path, int mode)
+{
+ return mkdir(path);
+}
+#define mkdir mingw_mkdir
+
+static inline int mingw_unlink(const char *pathname)
+{
+ /* read-only files cannot be removed */
+ chmod(pathname, 0666);
+ return unlink(pathname);
+}
+#define unlink mingw_unlink
+
+static inline int waitpid(pid_t pid, unsigned *status, unsigned options)
+{
+ if (options == 0)
+ return _cwait(status, pid, 0);
+ errno = EINVAL;
+ return -1;
+}
+
+/*
+ * implementations of missing functions
+ */
+
+int pipe(int filedes[2]);
+unsigned int sleep (unsigned int seconds);
+int mkstemp(char *template);
+int gettimeofday(struct timeval *tv, void *tz);
+int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
+struct tm *gmtime_r(const time_t *timep, struct tm *result);
+struct tm *localtime_r(const time_t *timep, struct tm *result);
+int getpagesize(void); /* defined in MinGW's libgcc.a */
+struct passwd *getpwuid(int uid);
+int setitimer(int type, struct itimerval *in, struct itimerval *out);
+int sigaction(int sig, struct sigaction *in, struct sigaction *out);
+
+/*
+ * replacements of existing functions
+ */
+
+int mingw_open (const char *filename, int oflags, ...);
+#define open mingw_open
+
+char *mingw_getcwd(char *pointer, int len);
+#define getcwd mingw_getcwd
+
+char *mingw_getenv(const char *name);
+#define getenv mingw_getenv
+
+struct hostent *mingw_gethostbyname(const char *host);
+#define gethostbyname mingw_gethostbyname
+
+int mingw_socket(int domain, int type, int protocol);
+#define socket mingw_socket
+
+int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
+#define connect mingw_connect
+
+int mingw_rename(const char*, const char*);
+#define rename mingw_rename
+
+/* Use mingw_lstat() instead of lstat()/stat() and
+ * mingw_fstat() instead of fstat() on Windows.
+ * struct stat is redefined because it lacks the st_blocks member.
+ */
+struct mingw_stat {
+ unsigned st_mode;
+ time_t st_mtime, st_atime, st_ctime;
+ unsigned st_dev, st_ino, st_uid, st_gid;
+ size_t st_size;
+ size_t st_blocks;
+};
+int mingw_lstat(const char *file_name, struct mingw_stat *buf);
+int mingw_fstat(int fd, struct mingw_stat *buf);
+#define fstat mingw_fstat
+#define lstat mingw_lstat
+#define stat mingw_stat
+static inline int mingw_stat(const char *file_name, struct mingw_stat *buf)
+{ return mingw_lstat(file_name, buf); }
+
+int mingw_utime(const char *file_name, const struct utimbuf *times);
+#define utime mingw_utime
+
+pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env);
+void mingw_execvp(const char *cmd, char *const *argv);
+#define execvp mingw_execvp
+
+static inline unsigned int git_ntohl(unsigned int x)
+{ return (unsigned int)ntohl(x); }
+#define ntohl git_ntohl
+
+sig_handler_t mingw_signal(int sig, sig_handler_t handler);
+#define signal mingw_signal
+
+/*
+ * ANSI emulation wrappers
+ */
+
+int winansi_fputs(const char *str, FILE *stream);
+int winansi_printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
+int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3)));
+#define fputs winansi_fputs
+#define printf(...) winansi_printf(__VA_ARGS__)
+#define fprintf(...) winansi_fprintf(__VA_ARGS__)
+
+/*
+ * git specific compatibility
+ */
+
+#define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
+#define is_dir_sep(c) ((c) == '/' || (c) == '\\')
+#define PATH_SEP ';'
+#define PRIuMAX "I64u"
+
+void mingw_open_html(const char *path);
+#define open_html mingw_open_html
+
+/*
+ * helpers
+ */
+
+char **copy_environ(void);
+void free_environ(char **env);
+char **env_setenv(char **env, const char *name);
+
+/*
+ * A replacement of main() that ensures that argv[0] has a path
+ */
+
+#define main(c,v) dummy_decl_mingw_main(); \
+static int mingw_main(); \
+int main(int argc, const char **argv) \
+{ \
+ argv[0] = xstrdup(_pgmptr); \
+ return mingw_main(argc, argv); \
+} \
+static int mingw_main(c,v)
diff --git a/compat/qsort.c b/compat/qsort.c
new file mode 100644
index 000000000..d93dce2cf
--- /dev/null
+++ b/compat/qsort.c
@@ -0,0 +1,62 @@
+#include "../git-compat-util.h"
+
+/*
+ * A merge sort implementation, simplified from the qsort implementation
+ * by Mike Haertel, which is a part of the GNU C Library.
+ */
+
+static void msort_with_tmp(void *b, size_t n, size_t s,
+ int (*cmp)(const void *, const void *),
+ char *t)
+{
+ char *tmp;
+ char *b1, *b2;
+ size_t n1, n2;
+
+ if (n <= 1)
+ return;
+
+ n1 = n / 2;
+ n2 = n - n1;
+ b1 = b;
+ b2 = (char *)b + (n1 * s);
+
+ msort_with_tmp(b1, n1, s, cmp, t);
+ msort_with_tmp(b2, n2, s, cmp, t);
+
+ tmp = t;
+
+ while (n1 > 0 && n2 > 0) {
+ if (cmp(b1, b2) <= 0) {
+ memcpy(tmp, b1, s);
+ tmp += s;
+ b1 += s;
+ --n1;
+ } else {
+ memcpy(tmp, b2, s);
+ tmp += s;
+ b2 += s;
+ --n2;
+ }
+ }
+ if (n1 > 0)
+ memcpy(tmp, b1, n1 * s);
+ memcpy(b, t, (n - n2) * s);
+}
+
+void git_qsort(void *b, size_t n, size_t s,
+ int (*cmp)(const void *, const void *))
+{
+ const size_t size = n * s;
+ char buf[1024];
+
+ if (size < sizeof(buf)) {
+ /* The temporary array fits on the small on-stack buffer. */
+ msort_with_tmp(b, n, s, cmp, buf);
+ } else {
+ /* It's somewhat large, so malloc it. */
+ char *tmp = malloc(size);
+ msort_with_tmp(b, n, s, cmp, tmp);
+ free(tmp);
+ }
+}
diff --git a/compat/regex.c b/compat/regex.c
new file mode 100644
index 000000000..87b33e466
--- /dev/null
+++ b/compat/regex.c
@@ -0,0 +1,4927 @@
+/* Extended regular expression matching and search library,
+ version 0.12.
+ (Implements POSIX draft P10003.2/D11.2, except for
+ internationalization features.)
+
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* AIX requires this to be the first thing in the file. */
+#if defined (_AIX) && !defined (REGEX_MALLOC)
+ #pragma alloca
+#endif
+
+#define _GNU_SOURCE
+
+/* We need this for `regex.h', and perhaps for the Emacs include files. */
+#include <sys/types.h>
+
+/* We used to test for `BSTRING' here, but only GCC and Emacs define
+ `BSTRING', as far as I know, and neither of them use this code. */
+#include <string.h>
+#ifndef bcmp
+#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
+#endif
+#ifndef bcopy
+#define bcopy(s, d, n) memcpy ((d), (s), (n))
+#endif
+#ifndef bzero
+#define bzero(s, n) memset ((s), 0, (n))
+#endif
+
+#include <stdlib.h>
+
+
+/* Define the syntax stuff for \<, \>, etc. */
+
+/* This must be nonzero for the wordchar and notwordchar pattern
+ commands in re_match_2. */
+#ifndef Sword
+#define Sword 1
+#endif
+
+#ifdef SYNTAX_TABLE
+
+extern char *re_syntax_table;
+
+#else /* not SYNTAX_TABLE */
+
+/* How many characters in the character set. */
+#define CHAR_SET_SIZE 256
+
+static char re_syntax_table[CHAR_SET_SIZE];
+
+static void
+init_syntax_once ()
+{
+ register int c;
+ static int done = 0;
+
+ if (done)
+ return;
+
+ bzero (re_syntax_table, sizeof re_syntax_table);
+
+ for (c = 'a'; c <= 'z'; c++)
+ re_syntax_table[c] = Sword;
+
+ for (c = 'A'; c <= 'Z'; c++)
+ re_syntax_table[c] = Sword;
+
+ for (c = '0'; c <= '9'; c++)
+ re_syntax_table[c] = Sword;
+
+ re_syntax_table['_'] = Sword;
+
+ done = 1;
+}
+
+#endif /* not SYNTAX_TABLE */
+
+#define SYNTAX(c) re_syntax_table[c]
+
+
+/* Get the interface, including the syntax bits. */
+#include "regex.h"
+
+/* isalpha etc. are used for the character classes. */
+#include <ctype.h>
+
+#ifndef isascii
+#define isascii(c) 1
+#endif
+
+#ifdef isblank
+#define ISBLANK(c) (isascii (c) && isblank (c))
+#else
+#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+#endif
+#ifdef isgraph
+#define ISGRAPH(c) (isascii (c) && isgraph (c))
+#else
+#define ISGRAPH(c) (isascii (c) && isprint (c) && !isspace (c))
+#endif
+
+#define ISPRINT(c) (isascii (c) && isprint (c))
+#define ISDIGIT(c) (isascii (c) && isdigit (c))
+#define ISALNUM(c) (isascii (c) && isalnum (c))
+#define ISALPHA(c) (isascii (c) && isalpha (c))
+#define ISCNTRL(c) (isascii (c) && iscntrl (c))
+#define ISLOWER(c) (isascii (c) && islower (c))
+#define ISPUNCT(c) (isascii (c) && ispunct (c))
+#define ISSPACE(c) (isascii (c) && isspace (c))
+#define ISUPPER(c) (isascii (c) && isupper (c))
+#define ISXDIGIT(c) (isascii (c) && isxdigit (c))
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/* We remove any previous definition of `SIGN_EXTEND_CHAR',
+ since ours (we hope) works properly with all combinations of
+ machines, compilers, `char' and `unsigned char' argument types.
+ (Per Bothner suggested the basic approach.) */
+#undef SIGN_EXTEND_CHAR
+#if __STDC__
+#define SIGN_EXTEND_CHAR(c) ((signed char) (c))
+#else /* not __STDC__ */
+/* As in Harbison and Steele. */
+#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
+#endif
+
+/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
+ use `alloca' instead of `malloc'. This is because using malloc in
+ re_search* or re_match* could cause memory leaks when C-g is used in
+ Emacs; also, malloc is slower and causes storage fragmentation. On
+ the other hand, malloc is more portable, and easier to debug.
+
+ Because we sometimes use alloca, some routines have to be macros,
+ not functions -- `alloca'-allocated space disappears at the end of the
+ function it is called in. */
+
+#ifdef REGEX_MALLOC
+
+#define REGEX_ALLOCATE malloc
+#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
+
+#else /* not REGEX_MALLOC */
+
+/* Emacs already defines alloca, sometimes. */
+#ifndef alloca
+
+/* Make alloca work the best possible way. */
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not __GNUC__ */
+#if HAVE_ALLOCA_H
+#include <alloca.h>
+#else /* not __GNUC__ or HAVE_ALLOCA_H */
+#ifndef _AIX /* Already did AIX, up at the top. */
+char *alloca ();
+#endif /* not _AIX */
+#endif /* not HAVE_ALLOCA_H */
+#endif /* not __GNUC__ */
+
+#endif /* not alloca */
+
+#define REGEX_ALLOCATE alloca
+
+/* Assumes a `char *destination' variable. */
+#define REGEX_REALLOCATE(source, osize, nsize) \
+ (destination = (char *) alloca (nsize), \
+ bcopy (source, destination, osize), \
+ destination)
+
+#endif /* not REGEX_MALLOC */
+
+
+/* True if `size1' is non-NULL and PTR is pointing anywhere inside
+ `string1' or just past its end. This works if PTR is NULL, which is
+ a good thing. */
+#define FIRST_STRING_P(ptr) \
+ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
+
+/* (Re)Allocate N items of type T using malloc, or fail. */
+#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
+#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
+#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
+
+#define BYTEWIDTH 8 /* In bits. */
+
+#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
+
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+typedef char boolean;
+#define false 0
+#define true 1
+
+/* These are the command codes that appear in compiled regular
+ expressions. Some opcodes are followed by argument bytes. A
+ command code can specify any interpretation whatsoever for its
+ arguments. Zero bytes may appear in the compiled regular expression.
+
+ The value of `exactn' is needed in search.c (search_buffer) in Emacs.
+ So regex.h defines a symbol `RE_EXACTN_VALUE' to be 1; the value of
+ `exactn' we use here must also be 1. */
+
+typedef enum
+{
+ no_op = 0,
+
+ /* Followed by one byte giving n, then by n literal bytes. */
+ exactn = 1,
+
+ /* Matches any (more or less) character. */
+ anychar,
+
+ /* Matches any one char belonging to specified set. First
+ following byte is number of bitmap bytes. Then come bytes
+ for a bitmap saying which chars are in. Bits in each byte
+ are ordered low-bit-first. A character is in the set if its
+ bit is 1. A character too large to have a bit in the map is
+ automatically not in the set. */
+ charset,
+
+ /* Same parameters as charset, but match any character that is
+ not one of those specified. */
+ charset_not,
+
+ /* Start remembering the text that is matched, for storing in a
+ register. Followed by one byte with the register number, in
+ the range 0 to one less than the pattern buffer's re_nsub
+ field. Then followed by one byte with the number of groups
+ inner to this one. (This last has to be part of the
+ start_memory only because we need it in the on_failure_jump
+ of re_match_2.) */
+ start_memory,
+
+ /* Stop remembering the text that is matched and store it in a
+ memory register. Followed by one byte with the register
+ number, in the range 0 to one less than `re_nsub' in the
+ pattern buffer, and one byte with the number of inner groups,
+ just like `start_memory'. (We need the number of inner
+ groups here because we don't have any easy way of finding the
+ corresponding start_memory when we're at a stop_memory.) */
+ stop_memory,
+
+ /* Match a duplicate of something remembered. Followed by one
+ byte containing the register number. */
+ duplicate,
+
+ /* Fail unless at beginning of line. */
+ begline,
+
+ /* Fail unless at end of line. */
+ endline,
+
+ /* Succeeds if at beginning of buffer (if emacs) or at beginning
+ of string to be matched (if not). */
+ begbuf,
+
+ /* Analogously, for end of buffer/string. */
+ endbuf,
+
+ /* Followed by two byte relative address to which to jump. */
+ jump,
+
+ /* Same as jump, but marks the end of an alternative. */
+ jump_past_alt,
+
+ /* Followed by two-byte relative address of place to resume at
+ in case of failure. */
+ on_failure_jump,
+
+ /* Like on_failure_jump, but pushes a placeholder instead of the
+ current string position when executed. */
+ on_failure_keep_string_jump,
+
+ /* Throw away latest failure point and then jump to following
+ two-byte relative address. */
+ pop_failure_jump,
+
+ /* Change to pop_failure_jump if know won't have to backtrack to
+ match; otherwise change to jump. This is used to jump
+ back to the beginning of a repeat. If what follows this jump
+ clearly won't match what the repeat does, such that we can be
+ sure that there is no use backtracking out of repetitions
+ already matched, then we change it to a pop_failure_jump.
+ Followed by two-byte address. */
+ maybe_pop_jump,
+
+ /* Jump to following two-byte address, and push a dummy failure
+ point. This failure point will be thrown away if an attempt
+ is made to use it for a failure. A `+' construct makes this
+ before the first repeat. Also used as an intermediary kind
+ of jump when compiling an alternative. */
+ dummy_failure_jump,
+
+ /* Push a dummy failure point and continue. Used at the end of
+ alternatives. */
+ push_dummy_failure,
+
+ /* Followed by two-byte relative address and two-byte number n.
+ After matching N times, jump to the address upon failure. */
+ succeed_n,
+
+ /* Followed by two-byte relative address, and two-byte number n.
+ Jump to the address N times, then fail. */
+ jump_n,
+
+ /* Set the following two-byte relative address to the
+ subsequent two-byte number. The address *includes* the two
+ bytes of number. */
+ set_number_at,
+
+ wordchar, /* Matches any word-constituent character. */
+ notwordchar, /* Matches any char that is not a word-constituent. */
+
+ wordbeg, /* Succeeds if at word beginning. */
+ wordend, /* Succeeds if at word end. */
+
+ wordbound, /* Succeeds if at a word boundary. */
+ notwordbound /* Succeeds if not at a word boundary. */
+
+#ifdef emacs
+ ,before_dot, /* Succeeds if before point. */
+ at_dot, /* Succeeds if at point. */
+ after_dot, /* Succeeds if after point. */
+
+ /* Matches any character whose syntax is specified. Followed by
+ a byte which contains a syntax code, e.g., Sword. */
+ syntaxspec,
+
+ /* Matches any character whose syntax is not that specified. */
+ notsyntaxspec
+#endif /* emacs */
+} re_opcode_t;
+
+/* Common operations on the compiled pattern. */
+
+/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
+
+#define STORE_NUMBER(destination, number) \
+ do { \
+ (destination)[0] = (number) & 0377; \
+ (destination)[1] = (number) >> 8; \
+ } while (0)
+
+/* Same as STORE_NUMBER, except increment DESTINATION to
+ the byte after where the number is stored. Therefore, DESTINATION
+ must be an lvalue. */
+
+#define STORE_NUMBER_AND_INCR(destination, number) \
+ do { \
+ STORE_NUMBER (destination, number); \
+ (destination) += 2; \
+ } while (0)
+
+/* Put into DESTINATION a number stored in two contiguous bytes starting
+ at SOURCE. */
+
+#define EXTRACT_NUMBER(destination, source) \
+ do { \
+ (destination) = *(source) & 0377; \
+ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
+ } while (0)
+
+#ifdef DEBUG
+static void
+extract_number (dest, source)
+ int *dest;
+ unsigned char *source;
+{
+ int temp = SIGN_EXTEND_CHAR (*(source + 1));
+ *dest = *source & 0377;
+ *dest += temp << 8;
+}
+
+#ifndef EXTRACT_MACROS /* To debug the macros. */
+#undef EXTRACT_NUMBER
+#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
+#endif /* not EXTRACT_MACROS */
+
+#endif /* DEBUG */
+
+/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
+ SOURCE must be an lvalue. */
+
+#define EXTRACT_NUMBER_AND_INCR(destination, source) \
+ do { \
+ EXTRACT_NUMBER (destination, source); \
+ (source) += 2; \
+ } while (0)
+
+#ifdef DEBUG
+static void
+extract_number_and_incr (destination, source)
+ int *destination;
+ unsigned char **source;
+{
+ extract_number (destination, *source);
+ *source += 2;
+}
+
+#ifndef EXTRACT_MACROS
+#undef EXTRACT_NUMBER_AND_INCR
+#define EXTRACT_NUMBER_AND_INCR(dest, src) \
+ extract_number_and_incr (&dest, &src)
+#endif /* not EXTRACT_MACROS */
+
+#endif /* DEBUG */
+
+/* If DEBUG is defined, Regex prints many voluminous messages about what
+ it is doing (if the variable `debug' is nonzero). If linked with the
+ main program in `iregex.c', you can enter patterns and strings
+ interactively. And if linked with the main program in `main.c' and
+ the other test files, you can run the already-written tests. */
+
+#ifdef DEBUG
+
+/* We use standard I/O for debugging. */
+#include <stdio.h>
+
+/* It is useful to test things that ``must'' be true when debugging. */
+#include <assert.h>
+
+static int debug = 0;
+
+#define DEBUG_STATEMENT(e) e
+#define DEBUG_PRINT1(x) if (debug) printf (x)
+#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
+#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
+#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
+#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
+ if (debug) print_partial_compiled_pattern (s, e)
+#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
+ if (debug) print_double_string (w, s1, sz1, s2, sz2)
+
+
+extern void printchar ();
+
+/* Print the fastmap in human-readable form. */
+
+void
+print_fastmap (fastmap)
+ char *fastmap;
+{
+ unsigned was_a_range = 0;
+ unsigned i = 0;
+
+ while (i < (1 << BYTEWIDTH))
+ {
+ if (fastmap[i++])
+ {
+ was_a_range = 0;
+ printchar (i - 1);
+ while (i < (1 << BYTEWIDTH) && fastmap[i])
+ {
+ was_a_range = 1;
+ i++;
+ }
+ if (was_a_range)
+ {
+ printf ("-");
+ printchar (i - 1);
+ }
+ }
+ }
+ putchar ('\n');
+}
+
+
+/* Print a compiled pattern string in human-readable form, starting at
+ the START pointer into it and ending just before the pointer END. */
+
+void
+print_partial_compiled_pattern (start, end)
+ unsigned char *start;
+ unsigned char *end;
+{
+ int mcnt, mcnt2;
+ unsigned char *p = start;
+ unsigned char *pend = end;
+
+ if (start == NULL)
+ {
+ printf ("(null)\n");
+ return;
+ }
+
+ /* Loop over pattern commands. */
+ while (p < pend)
+ {
+ switch ((re_opcode_t) *p++)
+ {
+ case no_op:
+ printf ("/no_op");
+ break;
+
+ case exactn:
+ mcnt = *p++;
+ printf ("/exactn/%d", mcnt);
+ do
+ {
+ putchar ('/');
+ printchar (*p++);
+ }
+ while (--mcnt);
+ break;
+
+ case start_memory:
+ mcnt = *p++;
+ printf ("/start_memory/%d/%d", mcnt, *p++);
+ break;
+
+ case stop_memory:
+ mcnt = *p++;
+ printf ("/stop_memory/%d/%d", mcnt, *p++);
+ break;
+
+ case duplicate:
+ printf ("/duplicate/%d", *p++);
+ break;
+
+ case anychar:
+ printf ("/anychar");
+ break;
+
+ case charset:
+ case charset_not:
+ {
+ register int c;
+
+ printf ("/charset%s",
+ (re_opcode_t) *(p - 1) == charset_not ? "_not" : "");
+
+ assert (p + *p < pend);
+
+ for (c = 0; c < *p; c++)
+ {
+ unsigned bit;
+ unsigned char map_byte = p[1 + c];
+
+ putchar ('/');
+
+ for (bit = 0; bit < BYTEWIDTH; bit++)
+ if (map_byte & (1 << bit))
+ printchar (c * BYTEWIDTH + bit);
+ }
+ p += 1 + *p;
+ break;
+ }
+
+ case begline:
+ printf ("/begline");
+ break;
+
+ case endline:
+ printf ("/endline");
+ break;
+
+ case on_failure_jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/on_failure_jump/0/%d", mcnt);
+ break;
+
+ case on_failure_keep_string_jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/on_failure_keep_string_jump/0/%d", mcnt);
+ break;
+
+ case dummy_failure_jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/dummy_failure_jump/0/%d", mcnt);
+ break;
+
+ case push_dummy_failure:
+ printf ("/push_dummy_failure");
+ break;
+
+ case maybe_pop_jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/maybe_pop_jump/0/%d", mcnt);
+ break;
+
+ case pop_failure_jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/pop_failure_jump/0/%d", mcnt);
+ break;
+
+ case jump_past_alt:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/jump_past_alt/0/%d", mcnt);
+ break;
+
+ case jump:
+ extract_number_and_incr (&mcnt, &p);
+ printf ("/jump/0/%d", mcnt);
+ break;
+
+ case succeed_n:
+ extract_number_and_incr (&mcnt, &p);
+ extract_number_and_incr (&mcnt2, &p);
+ printf ("/succeed_n/0/%d/0/%d", mcnt, mcnt2);
+ break;
+
+ case jump_n:
+ extract_number_and_incr (&mcnt, &p);
+ extract_number_and_incr (&mcnt2, &p);
+ printf ("/jump_n/0/%d/0/%d", mcnt, mcnt2);
+ break;
+
+ case set_number_at:
+ extract_number_and_incr (&mcnt, &p);
+ extract_number_and_incr (&mcnt2, &p);
+ printf ("/set_number_at/0/%d/0/%d", mcnt, mcnt2);
+ break;
+
+ case wordbound:
+ printf ("/wordbound");
+ break;
+
+ case notwordbound:
+ printf ("/notwordbound");
+ break;
+
+ case wordbeg:
+ printf ("/wordbeg");
+ break;
+
+ case wordend:
+ printf ("/wordend");
+
+#ifdef emacs
+ case before_dot:
+ printf ("/before_dot");
+ break;
+
+ case at_dot:
+ printf ("/at_dot");
+ break;
+
+ case after_dot:
+ printf ("/after_dot");
+ break;
+
+ case syntaxspec:
+ printf ("/syntaxspec");
+ mcnt = *p++;
+ printf ("/%d", mcnt);
+ break;
+
+ case notsyntaxspec:
+ printf ("/notsyntaxspec");
+ mcnt = *p++;
+ printf ("/%d", mcnt);
+ break;
+#endif /* emacs */
+
+ case wordchar:
+ printf ("/wordchar");
+ break;
+
+ case notwordchar:
+ printf ("/notwordchar");
+ break;
+
+ case begbuf:
+ printf ("/begbuf");
+ break;
+
+ case endbuf:
+ printf ("/endbuf");
+ break;
+
+ default:
+ printf ("?%d", *(p-1));
+ }
+ }
+ printf ("/\n");
+}
+
+
+void
+print_compiled_pattern (bufp)
+ struct re_pattern_buffer *bufp;
+{
+ unsigned char *buffer = bufp->buffer;
+
+ print_partial_compiled_pattern (buffer, buffer + bufp->used);
+ printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated);
+
+ if (bufp->fastmap_accurate && bufp->fastmap)
+ {
+ printf ("fastmap: ");
+ print_fastmap (bufp->fastmap);
+ }
+
+ printf ("re_nsub: %d\t", bufp->re_nsub);
+ printf ("regs_alloc: %d\t", bufp->regs_allocated);
+ printf ("can_be_null: %d\t", bufp->can_be_null);
+ printf ("newline_anchor: %d\n", bufp->newline_anchor);
+ printf ("no_sub: %d\t", bufp->no_sub);
+ printf ("not_bol: %d\t", bufp->not_bol);
+ printf ("not_eol: %d\t", bufp->not_eol);
+ printf ("syntax: %d\n", bufp->syntax);
+ /* Perhaps we should print the translate table? */
+}
+
+
+void
+print_double_string (where, string1, size1, string2, size2)
+ const char *where;
+ const char *string1;
+ const char *string2;
+ int size1;
+ int size2;
+{
+ unsigned this_char;
+
+ if (where == NULL)
+ printf ("(null)");
+ else
+ {
+ if (FIRST_STRING_P (where))
+ {
+ for (this_char = where - string1; this_char < size1; this_char++)
+ printchar (string1[this_char]);
+
+ where = string2;
+ }
+
+ for (this_char = where - string2; this_char < size2; this_char++)
+ printchar (string2[this_char]);
+ }
+}
+
+#else /* not DEBUG */
+
+#undef assert
+#define assert(e)
+
+#define DEBUG_STATEMENT(e)
+#define DEBUG_PRINT1(x)
+#define DEBUG_PRINT2(x1, x2)
+#define DEBUG_PRINT3(x1, x2, x3)
+#define DEBUG_PRINT4(x1, x2, x3, x4)
+#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
+#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
+
+#endif /* not DEBUG */
+
+/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
+ also be assigned to arbitrarily: each pattern buffer stores its own
+ syntax, so it can be changed between regex compilations. */
+reg_syntax_t re_syntax_options = RE_SYNTAX_EMACS;
+
+
+/* Specify the precise syntax of regexps for compilation. This provides
+ for compatibility for various utilities which historically have
+ different, incompatible syntaxes.
+
+ The argument SYNTAX is a bit mask comprised of the various bits
+ defined in regex.h. We return the old syntax. */
+
+reg_syntax_t
+re_set_syntax (syntax)
+ reg_syntax_t syntax;
+{
+ reg_syntax_t ret = re_syntax_options;
+
+ re_syntax_options = syntax;
+ return ret;
+}
+
+/* This table gives an error message for each of the error codes listed
+ in regex.h. Obviously the order here has to be same as there. */
+
+static const char *re_error_msg[] =
+ { NULL, /* REG_NOERROR */
+ "No match", /* REG_NOMATCH */
+ "Invalid regular expression", /* REG_BADPAT */
+ "Invalid collation character", /* REG_ECOLLATE */
+ "Invalid character class name", /* REG_ECTYPE */
+ "Trailing backslash", /* REG_EESCAPE */
+ "Invalid back reference", /* REG_ESUBREG */
+ "Unmatched [ or [^", /* REG_EBRACK */
+ "Unmatched ( or \\(", /* REG_EPAREN */
+ "Unmatched \\{", /* REG_EBRACE */
+ "Invalid content of \\{\\}", /* REG_BADBR */
+ "Invalid range end", /* REG_ERANGE */
+ "Memory exhausted", /* REG_ESPACE */
+ "Invalid preceding regular expression", /* REG_BADRPT */
+ "Premature end of regular expression", /* REG_EEND */
+ "Regular expression too big", /* REG_ESIZE */
+ "Unmatched ) or \\)", /* REG_ERPAREN */
+ };
+
+/* Subroutine declarations and macros for regex_compile. */
+
+static void store_op1 (), store_op2 ();
+static void insert_op1 (), insert_op2 ();
+static boolean at_begline_loc_p (), at_endline_loc_p ();
+static boolean group_in_compile_stack ();
+static reg_errcode_t compile_range ();
+
+/* Fetch the next character in the uncompiled pattern---translating it
+ if necessary. Also cast from a signed character in the constant
+ string passed to us by the user to an unsigned char that we can use
+ as an array index (in, e.g., `translate'). */
+#define PATFETCH(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (unsigned char) *p++; \
+ if (translate) c = translate[c]; \
+ } while (0)
+
+/* Fetch the next character in the uncompiled pattern, with no
+ translation. */
+#define PATFETCH_RAW(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (unsigned char) *p++; \
+ } while (0)
+
+/* Go backwards one character in the pattern. */
+#define PATUNFETCH p--
+
+
+/* If `translate' is non-null, return translate[D], else just D. We
+ cast the subscript to translate because some data is declared as
+ `char *', to avoid warnings when a string constant is passed. But
+ when we use a character as a subscript we must make it unsigned. */
+#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d))
+
+
+/* Macros for outputting the compiled pattern into `buffer'. */
+
+/* If the buffer isn't allocated when it comes in, use this. */
+#define INIT_BUF_SIZE 32
+
+/* Make sure we have at least N more bytes of space in buffer. */
+#define GET_BUFFER_SPACE(n) \
+ while (b - bufp->buffer + (n) > bufp->allocated) \
+ EXTEND_BUFFER ()
+
+/* Make sure we have one more byte of buffer space and then add C to it. */
+#define BUF_PUSH(c) \
+ do { \
+ GET_BUFFER_SPACE (1); \
+ *b++ = (unsigned char) (c); \
+ } while (0)
+
+
+/* Ensure we have two more bytes of buffer space and then append C1 and C2. */
+#define BUF_PUSH_2(c1, c2) \
+ do { \
+ GET_BUFFER_SPACE (2); \
+ *b++ = (unsigned char) (c1); \
+ *b++ = (unsigned char) (c2); \
+ } while (0)
+
+
+/* As with BUF_PUSH_2, except for three bytes. */
+#define BUF_PUSH_3(c1, c2, c3) \
+ do { \
+ GET_BUFFER_SPACE (3); \
+ *b++ = (unsigned char) (c1); \
+ *b++ = (unsigned char) (c2); \
+ *b++ = (unsigned char) (c3); \
+ } while (0)
+
+
+/* Store a jump with opcode OP at LOC to location TO. We store a
+ relative address offset by the three bytes the jump itself occupies. */
+#define STORE_JUMP(op, loc, to) \
+ store_op1 (op, loc, (to) - (loc) - 3)
+
+/* Likewise, for a two-argument jump. */
+#define STORE_JUMP2(op, loc, to, arg) \
+ store_op2 (op, loc, (to) - (loc) - 3, arg)
+
+/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */
+#define INSERT_JUMP(op, loc, to) \
+ insert_op1 (op, loc, (to) - (loc) - 3, b)
+
+/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */
+#define INSERT_JUMP2(op, loc, to, arg) \
+ insert_op2 (op, loc, (to) - (loc) - 3, arg, b)
+
+
+/* This is not an arbitrary limit: the arguments which represent offsets
+ into the pattern are two bytes long. So if 2^16 bytes turns out to
+ be too small, many things would have to change. */
+#define MAX_BUF_SIZE (1L << 16)
+
+
+/* Extend the buffer by twice its current size via realloc and
+ reset the pointers that pointed into the old block to point to the
+ correct places in the new one. If extending the buffer results in it
+ being larger than MAX_BUF_SIZE, then flag memory exhausted. */
+#define EXTEND_BUFFER() \
+ do { \
+ unsigned char *old_buffer = bufp->buffer; \
+ if (bufp->allocated == MAX_BUF_SIZE) \
+ return REG_ESIZE; \
+ bufp->allocated <<= 1; \
+ if (bufp->allocated > MAX_BUF_SIZE) \
+ bufp->allocated = MAX_BUF_SIZE; \
+ bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\
+ if (bufp->buffer == NULL) \
+ return REG_ESPACE; \
+ /* If the buffer moved, move all the pointers into it. */ \
+ if (old_buffer != bufp->buffer) \
+ { \
+ b = (b - old_buffer) + bufp->buffer; \
+ begalt = (begalt - old_buffer) + bufp->buffer; \
+ if (fixup_alt_jump) \
+ fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
+ if (laststart) \
+ laststart = (laststart - old_buffer) + bufp->buffer; \
+ if (pending_exact) \
+ pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
+ } \
+ } while (0)
+
+
+/* Since we have one byte reserved for the register number argument to
+ {start,stop}_memory, the maximum number of groups we can report
+ things about is what fits in that byte. */
+#define MAX_REGNUM 255
+
+/* But patterns can have more than `MAX_REGNUM' registers. We just
+ ignore the excess. */
+typedef unsigned regnum_t;
+
+
+/* Macros for the compile stack. */
+
+/* Since offsets can go either forwards or backwards, this type needs to
+ be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */
+typedef int pattern_offset_t;
+
+typedef struct
+{
+ pattern_offset_t begalt_offset;
+ pattern_offset_t fixup_alt_jump;
+ pattern_offset_t inner_group_offset;
+ pattern_offset_t laststart_offset;
+ regnum_t regnum;
+} compile_stack_elt_t;
+
+
+typedef struct
+{
+ compile_stack_elt_t *stack;
+ unsigned size;
+ unsigned avail; /* Offset of next open position. */
+} compile_stack_type;
+
+
+#define INIT_COMPILE_STACK_SIZE 32
+
+#define COMPILE_STACK_EMPTY (compile_stack.avail == 0)
+#define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size)
+
+/* The next available element. */
+#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
+
+
+/* Set the bit for character C in a list. */
+#define SET_LIST_BIT(c) \
+ (b[((unsigned char) (c)) / BYTEWIDTH] \
+ |= 1 << (((unsigned char) c) % BYTEWIDTH))
+
+
+/* Get the next unsigned number in the uncompiled pattern. */
+#define GET_UNSIGNED_NUMBER(num) \
+ { if (p != pend) \
+ { \
+ PATFETCH (c); \
+ while (ISDIGIT (c)) \
+ { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ if (p == pend) \
+ break; \
+ PATFETCH (c); \
+ } \
+ } \
+ }
+
+#define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+
+#define IS_CHAR_CLASS(string) \
+ (STREQ (string, "alpha") || STREQ (string, "upper") \
+ || STREQ (string, "lower") || STREQ (string, "digit") \
+ || STREQ (string, "alnum") || STREQ (string, "xdigit") \
+ || STREQ (string, "space") || STREQ (string, "print") \
+ || STREQ (string, "punct") || STREQ (string, "graph") \
+ || STREQ (string, "cntrl") || STREQ (string, "blank"))
+
+/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
+ Returns one of error codes defined in `regex.h', or zero for success.
+
+ Assumes the `allocated' (and perhaps `buffer') and `translate'
+ fields are set in BUFP on entry.
+
+ If it succeeds, results are put in BUFP (if it returns an error, the
+ contents of BUFP are undefined):
+ `buffer' is the compiled pattern;
+ `syntax' is set to SYNTAX;
+ `used' is set to the length of the compiled pattern;
+ `fastmap_accurate' is zero;
+ `re_nsub' is the number of subexpressions in PATTERN;
+ `not_bol' and `not_eol' are zero;
+
+ The `fastmap' and `newline_anchor' fields are neither
+ examined nor set. */
+
+static reg_errcode_t
+regex_compile (pattern, size, syntax, bufp)
+ const char *pattern;
+ int size;
+ reg_syntax_t syntax;
+ struct re_pattern_buffer *bufp;
+{
+ /* We fetch characters from PATTERN here. Even though PATTERN is
+ `char *' (i.e., signed), we declare these variables as unsigned, so
+ they can be reliably used as array indices. */
+ register unsigned char c, c1;
+
+ /* A random tempory spot in PATTERN. */
+ const char *p1;
+
+ /* Points to the end of the buffer, where we should append. */
+ register unsigned char *b;
+
+ /* Keeps track of unclosed groups. */
+ compile_stack_type compile_stack;
+
+ /* Points to the current (ending) position in the pattern. */
+ const char *p = pattern;
+ const char *pend = pattern + size;
+
+ /* How to translate the characters in the pattern. */
+ char *translate = bufp->translate;
+
+ /* Address of the count-byte of the most recently inserted `exactn'
+ command. This makes it possible to tell if a new exact-match
+ character can be added to that command or if the character requires
+ a new `exactn' command. */
+ unsigned char *pending_exact = 0;
+
+ /* Address of start of the most recently finished expression.
+ This tells, e.g., postfix * where to find the start of its
+ operand. Reset at the beginning of groups and alternatives. */
+ unsigned char *laststart = 0;
+
+ /* Address of beginning of regexp, or inside of last group. */
+ unsigned char *begalt;
+
+ /* Place in the uncompiled pattern (i.e., the {) to
+ which to go back if the interval is invalid. */
+ const char *beg_interval;
+
+ /* Address of the place where a forward jump should go to the end of
+ the containing expression. Each alternative of an `or' -- except the
+ last -- ends with a forward jump of this sort. */
+ unsigned char *fixup_alt_jump = 0;
+
+ /* Counts open-groups as they are encountered. Remembered for the
+ matching close-group on the compile stack, so the same register
+ number is put in the stop_memory as the start_memory. */
+ regnum_t regnum = 0;
+
+#ifdef DEBUG
+ DEBUG_PRINT1 ("\nCompiling pattern: ");
+ if (debug)
+ {
+ unsigned debug_count;
+
+ for (debug_count = 0; debug_count < size; debug_count++)
+ printchar (pattern[debug_count]);
+ putchar ('\n');
+ }
+#endif /* DEBUG */
+
+ /* Initialize the compile stack. */
+ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
+ if (compile_stack.stack == NULL)
+ return REG_ESPACE;
+
+ compile_stack.size = INIT_COMPILE_STACK_SIZE;
+ compile_stack.avail = 0;
+
+ /* Initialize the pattern buffer. */
+ bufp->syntax = syntax;
+ bufp->fastmap_accurate = 0;
+ bufp->not_bol = bufp->not_eol = 0;
+
+ /* Set `used' to zero, so that if we return an error, the pattern
+ printer (for debugging) will think there's no pattern. We reset it
+ at the end. */
+ bufp->used = 0;
+
+ /* Always count groups, whether or not bufp->no_sub is set. */
+ bufp->re_nsub = 0;
+
+#if !defined (emacs) && !defined (SYNTAX_TABLE)
+ /* Initialize the syntax table. */
+ init_syntax_once ();
+#endif
+
+ if (bufp->allocated == 0)
+ {
+ if (bufp->buffer)
+ { /* If zero allocated, but buffer is non-null, try to realloc
+ enough space. This loses if buffer's address is bogus, but
+ that is the user's responsibility. */
+ RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
+ }
+ else
+ { /* Caller did not allocate a buffer. Do it for them. */
+ bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
+ }
+ if (!bufp->buffer) return REG_ESPACE;
+
+ bufp->allocated = INIT_BUF_SIZE;
+ }
+
+ begalt = b = bufp->buffer;
+
+ /* Loop through the uncompiled pattern until we're at the end. */
+ while (p != pend)
+ {
+ PATFETCH (c);
+
+ switch (c)
+ {
+ case '^':
+ {
+ if ( /* If at start of pattern, it's an operator. */
+ p == pattern + 1
+ /* If context independent, it's an operator. */
+ || syntax & RE_CONTEXT_INDEP_ANCHORS
+ /* Otherwise, depends on what's come before. */
+ || at_begline_loc_p (pattern, p, syntax))
+ BUF_PUSH (begline);
+ else
+ goto normal_char;
+ }
+ break;
+
+
+ case '$':
+ {
+ if ( /* If at end of pattern, it's an operator. */
+ p == pend
+ /* If context independent, it's an operator. */
+ || syntax & RE_CONTEXT_INDEP_ANCHORS
+ /* Otherwise, depends on what's next. */
+ || at_endline_loc_p (p, pend, syntax))
+ BUF_PUSH (endline);
+ else
+ goto normal_char;
+ }
+ break;
+
+
+ case '+':
+ case '?':
+ if ((syntax & RE_BK_PLUS_QM)
+ || (syntax & RE_LIMITED_OPS))
+ goto normal_char;
+ handle_plus:
+ case '*':
+ /* If there is no previous pattern... */
+ if (!laststart)
+ {
+ if (syntax & RE_CONTEXT_INVALID_OPS)
+ return REG_BADRPT;
+ else if (!(syntax & RE_CONTEXT_INDEP_OPS))
+ goto normal_char;
+ }
+
+ {
+ /* Are we optimizing this jump? */
+ boolean keep_string_p = false;
+
+ /* 1 means zero (many) matches is allowed. */
+ char zero_times_ok = 0, many_times_ok = 0;
+
+ /* If there is a sequence of repetition chars, collapse it
+ down to just one (the right one). We can't combine
+ interval operators with these because of, e.g., `a{2}*',
+ which should only match an even number of `a's. */
+
+ for (;;)
+ {
+ zero_times_ok |= c != '+';
+ many_times_ok |= c != '?';
+
+ if (p == pend)
+ break;
+
+ PATFETCH (c);
+
+ if (c == '*'
+ || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
+ ;
+
+ else if (syntax & RE_BK_PLUS_QM && c == '\\')
+ {
+ if (p == pend) return REG_EESCAPE;
+
+ PATFETCH (c1);
+ if (!(c1 == '+' || c1 == '?'))
+ {
+ PATUNFETCH;
+ PATUNFETCH;
+ break;
+ }
+
+ c = c1;
+ }
+ else
+ {
+ PATUNFETCH;
+ break;
+ }
+
+ /* If we get here, we found another repeat character. */
+ }
+
+ /* Star, etc. applied to an empty pattern is equivalent
+ to an empty pattern. */
+ if (!laststart)
+ break;
+
+ /* Now we know whether or not zero matches is allowed
+ and also whether or not two or more matches is allowed. */
+ if (many_times_ok)
+ { /* More than one repetition is allowed, so put in at the
+ end a backward relative jump from `b' to before the next
+ jump we're going to put in below (which jumps from
+ laststart to after this jump).
+
+ But if we are at the `*' in the exact sequence `.*\n',
+ insert an unconditional jump backwards to the .,
+ instead of the beginning of the loop. This way we only
+ push a failure point once, instead of every time
+ through the loop. */
+ assert (p - 1 > pattern);
+
+ /* Allocate the space for the jump. */
+ GET_BUFFER_SPACE (3);
+
+ /* We know we are not at the first character of the pattern,
+ because laststart was nonzero. And we've already
+ incremented `p', by the way, to be the character after
+ the `*'. Do we have to do something analogous here
+ for null bytes, because of RE_DOT_NOT_NULL? */
+ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
+ && zero_times_ok
+ && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
+ && !(syntax & RE_DOT_NEWLINE))
+ { /* We have .*\n. */
+ STORE_JUMP (jump, b, laststart);
+ keep_string_p = true;
+ }
+ else
+ /* Anything else. */
+ STORE_JUMP (maybe_pop_jump, b, laststart - 3);
+
+ /* We've added more stuff to the buffer. */
+ b += 3;
+ }
+
+ /* On failure, jump from laststart to b + 3, which will be the
+ end of the buffer after this jump is inserted. */
+ GET_BUFFER_SPACE (3);
+ INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
+ : on_failure_jump,
+ laststart, b + 3);
+ pending_exact = 0;
+ b += 3;
+
+ if (!zero_times_ok)
+ {
+ /* At least one repetition is required, so insert a
+ `dummy_failure_jump' before the initial
+ `on_failure_jump' instruction of the loop. This
+ effects a skip over that instruction the first time
+ we hit that loop. */
+ GET_BUFFER_SPACE (3);
+ INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6);
+ b += 3;
+ }
+ }
+ break;
+
+
+ case '.':
+ laststart = b;
+ BUF_PUSH (anychar);
+ break;
+
+
+ case '[':
+ {
+ boolean had_char_class = false;
+
+ if (p == pend) return REG_EBRACK;
+
+ /* Ensure that we have enough space to push a charset: the
+ opcode, the length count, and the bitset; 34 bytes in all. */
+ GET_BUFFER_SPACE (34);
+
+ laststart = b;
+
+ /* We test `*p == '^' twice, instead of using an if
+ statement, so we only need one BUF_PUSH. */
+ BUF_PUSH (*p == '^' ? charset_not : charset);
+ if (*p == '^')
+ p++;
+
+ /* Remember the first position in the bracket expression. */
+ p1 = p;
+
+ /* Push the number of bytes in the bitmap. */
+ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
+
+ /* Clear the whole map. */
+ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
+
+ /* charset_not matches newline according to a syntax bit. */
+ if ((re_opcode_t) b[-2] == charset_not
+ && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
+ SET_LIST_BIT ('\n');
+
+ /* Read in characters and ranges, setting map bits. */
+ for (;;)
+ {
+ if (p == pend) return REG_EBRACK;
+
+ PATFETCH (c);
+
+ /* \ might escape characters inside [...] and [^...]. */
+ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
+ {
+ if (p == pend) return REG_EESCAPE;
+
+ PATFETCH (c1);
+ SET_LIST_BIT (c1);
+ continue;
+ }
+
+ /* Could be the end of the bracket expression. If it's
+ not (i.e., when the bracket expression is `[]' so
+ far), the ']' character bit gets set way below. */
+ if (c == ']' && p != p1 + 1)
+ break;
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character class. */
+ if (had_char_class && c == '-' && *p != ']')
+ return REG_ERANGE;
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character: if this is a hyphen not at the
+ beginning or the end of a list, then it's the range
+ operator. */
+ if (c == '-'
+ && !(p - 2 >= pattern && p[-2] == '[')
+ && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
+ && *p != ']')
+ {
+ reg_errcode_t ret
+ = compile_range (&p, pend, translate, syntax, b);
+ if (ret != REG_NOERROR) return ret;
+ }
+
+ else if (p[0] == '-' && p[1] != ']')
+ { /* This handles ranges made up of characters only. */
+ reg_errcode_t ret;
+
+ /* Move past the `-'. */
+ PATFETCH (c1);
+
+ ret = compile_range (&p, pend, translate, syntax, b);
+ if (ret != REG_NOERROR) return ret;
+ }
+
+ /* See if we're at the beginning of a possible character
+ class. */
+
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
+ { /* Leave room for the null. */
+ char str[CHAR_CLASS_MAX_LENGTH + 1];
+
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[:'. */
+ if (p == pend) return REG_EBRACK;
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if (c == ':' || c == ']' || p == pend
+ || c1 == CHAR_CLASS_MAX_LENGTH)
+ break;
+ str[c1++] = c;
+ }
+ str[c1] = '\0';
+
+ /* If isn't a word bracketed by `[:' and:`]':
+ undo the ending character, the letters, and leave
+ the leading `:' and `[' (but set bits for them). */
+ if (c == ':' && *p == ']')
+ {
+ int ch;
+ boolean is_alnum = STREQ (str, "alnum");
+ boolean is_alpha = STREQ (str, "alpha");
+ boolean is_blank = STREQ (str, "blank");
+ boolean is_cntrl = STREQ (str, "cntrl");
+ boolean is_digit = STREQ (str, "digit");
+ boolean is_graph = STREQ (str, "graph");
+ boolean is_lower = STREQ (str, "lower");
+ boolean is_print = STREQ (str, "print");
+ boolean is_punct = STREQ (str, "punct");
+ boolean is_space = STREQ (str, "space");
+ boolean is_upper = STREQ (str, "upper");
+ boolean is_xdigit = STREQ (str, "xdigit");
+
+ if (!IS_CHAR_CLASS (str)) return REG_ECTYPE;
+
+ /* Throw away the ] at the end of the character
+ class. */
+ PATFETCH (c);
+
+ if (p == pend) return REG_EBRACK;
+
+ for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
+ {
+ if ( (is_alnum && ISALNUM (ch))
+ || (is_alpha && ISALPHA (ch))
+ || (is_blank && ISBLANK (ch))
+ || (is_cntrl && ISCNTRL (ch))
+ || (is_digit && ISDIGIT (ch))
+ || (is_graph && ISGRAPH (ch))
+ || (is_lower && ISLOWER (ch))
+ || (is_print && ISPRINT (ch))
+ || (is_punct && ISPUNCT (ch))
+ || (is_space && ISSPACE (ch))
+ || (is_upper && ISUPPER (ch))
+ || (is_xdigit && ISXDIGIT (ch)))
+ SET_LIST_BIT (ch);
+ }
+ had_char_class = true;
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ SET_LIST_BIT ('[');
+ SET_LIST_BIT (':');
+ had_char_class = false;
+ }
+ }
+ else
+ {
+ had_char_class = false;
+ SET_LIST_BIT (c);
+ }
+ }
+
+ /* Discard any (non)matching list bytes that are all 0 at the
+ end of the map. Decrease the map-length byte too. */
+ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
+ b[-1]--;
+ b += b[-1];
+ }
+ break;
+
+
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ goto handle_open;
+ else
+ goto normal_char;
+
+
+ case ')':
+ if (syntax & RE_NO_BK_PARENS)
+ goto handle_close;
+ else
+ goto normal_char;
+
+
+ case '\n':
+ if (syntax & RE_NEWLINE_ALT)
+ goto handle_alt;
+ else
+ goto normal_char;
+
+
+ case '|':
+ if (syntax & RE_NO_BK_VBAR)
+ goto handle_alt;
+ else
+ goto normal_char;
+
+
+ case '{':
+ if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
+ goto handle_interval;
+ else
+ goto normal_char;
+
+
+ case '\\':
+ if (p == pend) return REG_EESCAPE;
+
+ /* Do not translate the character after the \, so that we can
+ distinguish, e.g., \B from \b, even if we normally would
+ translate, e.g., B to b. */
+ PATFETCH_RAW (c);
+
+ switch (c)
+ {
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ goto normal_backslash;
+
+ handle_open:
+ bufp->re_nsub++;
+ regnum++;
+
+ if (COMPILE_STACK_FULL)
+ {
+ RETALLOC (compile_stack.stack, compile_stack.size << 1,
+ compile_stack_elt_t);
+ if (compile_stack.stack == NULL) return REG_ESPACE;
+
+ compile_stack.size <<= 1;
+ }
+
+ /* These are the values to restore when we hit end of this
+ group. They are all relative offsets, so that if the
+ whole pattern moves because of realloc, they will still
+ be valid. */
+ COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
+ COMPILE_STACK_TOP.fixup_alt_jump
+ = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
+ COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
+ COMPILE_STACK_TOP.regnum = regnum;
+
+ /* We will eventually replace the 0 with the number of
+ groups inner to this one. But do not push a
+ start_memory for groups beyond the last one we can
+ represent in the compiled pattern. */
+ if (regnum <= MAX_REGNUM)
+ {
+ COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
+ BUF_PUSH_3 (start_memory, regnum, 0);
+ }
+
+ compile_stack.avail++;
+
+ fixup_alt_jump = 0;
+ laststart = 0;
+ begalt = b;
+ /* If we've reached MAX_REGNUM groups, then this open
+ won't actually generate any code, so we'll have to
+ clear pending_exact explicitly. */
+ pending_exact = 0;
+ break;
+
+
+ case ')':
+ if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
+
+ if (COMPILE_STACK_EMPTY)
+ {
+ if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+ goto normal_backslash;
+ else
+ return REG_ERPAREN;
+ }
+
+ handle_close:
+ if (fixup_alt_jump)
+ { /* Push a dummy failure point at the end of the
+ alternative for a possible future
+ `pop_failure_jump' to pop. See comments at
+ `push_dummy_failure' in `re_match_2'. */
+ BUF_PUSH (push_dummy_failure);
+
+ /* We allocated space for this jump when we assigned
+ to `fixup_alt_jump', in the `handle_alt' case below. */
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
+ }
+
+ /* See similar code for backslashed left paren above. */
+ if (COMPILE_STACK_EMPTY)
+ {
+ if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+ goto normal_char;
+ else
+ return REG_ERPAREN;
+ }
+
+ /* Since we just checked for an empty stack above, this
+ ``can't happen''. */
+ assert (compile_stack.avail != 0);
+ {
+ /* We don't just want to restore into `regnum', because
+ later groups should continue to be numbered higher,
+ as in `(ab)c(de)' -- the second group is #2. */
+ regnum_t this_group_regnum;
+
+ compile_stack.avail--;
+ begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
+ fixup_alt_jump
+ = COMPILE_STACK_TOP.fixup_alt_jump
+ ? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1
+ : 0;
+ laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
+ this_group_regnum = COMPILE_STACK_TOP.regnum;
+ /* If we've reached MAX_REGNUM groups, then this open
+ won't actually generate any code, so we'll have to
+ clear pending_exact explicitly. */
+ pending_exact = 0;
+
+ /* We're at the end of the group, so now we know how many
+ groups were inside this one. */
+ if (this_group_regnum <= MAX_REGNUM)
+ {
+ unsigned char *inner_group_loc
+ = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
+
+ *inner_group_loc = regnum - this_group_regnum;
+ BUF_PUSH_3 (stop_memory, this_group_regnum,
+ regnum - this_group_regnum);
+ }
+ }
+ break;
+
+
+ case '|': /* `\|'. */
+ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
+ goto normal_backslash;
+ handle_alt:
+ if (syntax & RE_LIMITED_OPS)
+ goto normal_char;
+
+ /* Insert before the previous alternative a jump which
+ jumps to this alternative if the former fails. */
+ GET_BUFFER_SPACE (3);
+ INSERT_JUMP (on_failure_jump, begalt, b + 6);
+ pending_exact = 0;
+ b += 3;
+
+ /* The alternative before this one has a jump after it
+ which gets executed if it gets matched. Adjust that
+ jump so it will jump to this alternative's analogous
+ jump (put in below, which in turn will jump to the next
+ (if any) alternative's such jump, etc.). The last such
+ jump jumps to the correct final destination. A picture:
+ _____ _____
+ | | | |
+ | v | v
+ a | b | c
+
+ If we are at `b', then fixup_alt_jump right now points to a
+ three-byte space after `a'. We'll put in the jump, set
+ fixup_alt_jump to right after `b', and leave behind three
+ bytes which we'll fill in when we get to after `c'. */
+
+ if (fixup_alt_jump)
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
+
+ /* Mark and leave space for a jump after this alternative,
+ to be filled in later either by next alternative or
+ when know we're at the end of a series of alternatives. */
+ fixup_alt_jump = b;
+ GET_BUFFER_SPACE (3);
+ b += 3;
+
+ laststart = 0;
+ begalt = b;
+ break;
+
+
+ case '{':
+ /* If \{ is a literal. */
+ if (!(syntax & RE_INTERVALS)
+ /* If we're at `\{' and it's not the open-interval
+ operator. */
+ || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
+ || (p - 2 == pattern && p == pend))
+ goto normal_backslash;
+
+ handle_interval:
+ {
+ /* If got here, then the syntax allows intervals. */
+
+ /* At least (most) this many matches must be made. */
+ int lower_bound = -1, upper_bound = -1;
+
+ beg_interval = p - 1;
+
+ if (p == pend)
+ {
+ if (syntax & RE_NO_BK_BRACES)
+ goto unfetch_interval;
+ else
+ return REG_EBRACE;
+ }
+
+ GET_UNSIGNED_NUMBER (lower_bound);
+
+ if (c == ',')
+ {
+ GET_UNSIGNED_NUMBER (upper_bound);
+ if (upper_bound < 0) upper_bound = RE_DUP_MAX;
+ }
+ else
+ /* Interval such as `{1}' => match exactly once. */
+ upper_bound = lower_bound;
+
+ if (lower_bound < 0 || upper_bound > RE_DUP_MAX
+ || lower_bound > upper_bound)
+ {
+ if (syntax & RE_NO_BK_BRACES)
+ goto unfetch_interval;
+ else
+ return REG_BADBR;
+ }
+
+ if (!(syntax & RE_NO_BK_BRACES))
+ {
+ if (c != '\\') return REG_EBRACE;
+
+ PATFETCH (c);
+ }
+
+ if (c != '}')
+ {
+ if (syntax & RE_NO_BK_BRACES)
+ goto unfetch_interval;
+ else
+ return REG_BADBR;
+ }
+
+ /* We just parsed a valid interval. */
+
+ /* If it's invalid to have no preceding re. */
+ if (!laststart)
+ {
+ if (syntax & RE_CONTEXT_INVALID_OPS)
+ return REG_BADRPT;
+ else if (syntax & RE_CONTEXT_INDEP_OPS)
+ laststart = b;
+ else
+ goto unfetch_interval;
+ }
+
+ /* If the upper bound is zero, don't want to succeed at
+ all; jump from `laststart' to `b + 3', which will be
+ the end of the buffer after we insert the jump. */
+ if (upper_bound == 0)
+ {
+ GET_BUFFER_SPACE (3);
+ INSERT_JUMP (jump, laststart, b + 3);
+ b += 3;
+ }
+
+ /* Otherwise, we have a nontrivial interval. When
+ we're all done, the pattern will look like:
+ set_number_at <jump count> <upper bound>
+ set_number_at <succeed_n count> <lower bound>
+ succeed_n <after jump addr> <succed_n count>
+ <body of loop>
+ jump_n <succeed_n addr> <jump count>
+ (The upper bound and `jump_n' are omitted if
+ `upper_bound' is 1, though.) */
+ else
+ { /* If the upper bound is > 1, we need to insert
+ more at the end of the loop. */
+ unsigned nbytes = 10 + (upper_bound > 1) * 10;
+
+ GET_BUFFER_SPACE (nbytes);
+
+ /* Initialize lower bound of the `succeed_n', even
+ though it will be set during matching by its
+ attendant `set_number_at' (inserted next),
+ because `re_compile_fastmap' needs to know.
+ Jump to the `jump_n' we might insert below. */
+ INSERT_JUMP2 (succeed_n, laststart,
+ b + 5 + (upper_bound > 1) * 5,
+ lower_bound);
+ b += 5;
+
+ /* Code to initialize the lower bound. Insert
+ before the `succeed_n'. The `5' is the last two
+ bytes of this `set_number_at', plus 3 bytes of
+ the following `succeed_n'. */
+ insert_op2 (set_number_at, laststart, 5, lower_bound, b);
+ b += 5;
+
+ if (upper_bound > 1)
+ { /* More than one repetition is allowed, so
+ append a backward jump to the `succeed_n'
+ that starts this interval.
+
+ When we've reached this during matching,
+ we'll have matched the interval once, so
+ jump back only `upper_bound - 1' times. */
+ STORE_JUMP2 (jump_n, b, laststart + 5,
+ upper_bound - 1);
+ b += 5;
+
+ /* The location we want to set is the second
+ parameter of the `jump_n'; that is `b-2' as
+ an absolute address. `laststart' will be
+ the `set_number_at' we're about to insert;
+ `laststart+3' the number to set, the source
+ for the relative address. But we are
+ inserting into the middle of the pattern --
+ so everything is getting moved up by 5.
+ Conclusion: (b - 2) - (laststart + 3) + 5,
+ i.e., b - laststart.
+
+ We insert this at the beginning of the loop
+ so that if we fail during matching, we'll
+ reinitialize the bounds. */
+ insert_op2 (set_number_at, laststart, b - laststart,
+ upper_bound - 1, b);
+ b += 5;
+ }
+ }
+ pending_exact = 0;
+ beg_interval = NULL;
+ }
+ break;
+
+ unfetch_interval:
+ /* If an invalid interval, match the characters as literals. */
+ assert (beg_interval);
+ p = beg_interval;
+ beg_interval = NULL;
+
+ /* normal_char and normal_backslash need `c'. */
+ PATFETCH (c);
+
+ if (!(syntax & RE_NO_BK_BRACES))
+ {
+ if (p > pattern && p[-1] == '\\')
+ goto normal_backslash;
+ }
+ goto normal_char;
+
+#ifdef emacs
+ /* There is no way to specify the before_dot and after_dot
+ operators. rms says this is ok. --karl */
+ case '=':
+ BUF_PUSH (at_dot);
+ break;
+
+ case 's':
+ laststart = b;
+ PATFETCH (c);
+ BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
+ break;
+
+ case 'S':
+ laststart = b;
+ PATFETCH (c);
+ BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
+ break;
+#endif /* emacs */
+
+
+ case 'w':
+ laststart = b;
+ BUF_PUSH (wordchar);
+ break;
+
+
+ case 'W':
+ laststart = b;
+ BUF_PUSH (notwordchar);
+ break;
+
+
+ case '<':
+ BUF_PUSH (wordbeg);
+ break;
+
+ case '>':
+ BUF_PUSH (wordend);
+ break;
+
+ case 'b':
+ BUF_PUSH (wordbound);
+ break;
+
+ case 'B':
+ BUF_PUSH (notwordbound);
+ break;
+
+ case '`':
+ BUF_PUSH (begbuf);
+ break;
+
+ case '\'':
+ BUF_PUSH (endbuf);
+ break;
+
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (syntax & RE_NO_BK_REFS)
+ goto normal_char;
+
+ c1 = c - '0';
+
+ if (c1 > regnum)
+ return REG_ESUBREG;
+
+ /* Can't back reference to a subexpression if inside of it. */
+ if (group_in_compile_stack (compile_stack, c1))
+ goto normal_char;
+
+ laststart = b;
+ BUF_PUSH_2 (duplicate, c1);
+ break;
+
+
+ case '+':
+ case '?':
+ if (syntax & RE_BK_PLUS_QM)
+ goto handle_plus;
+ else
+ goto normal_backslash;
+
+ default:
+ normal_backslash:
+ /* You might think it would be useful for \ to mean
+ not to translate; but if we don't translate it
+ it will never match anything. */
+ c = TRANSLATE (c);
+ goto normal_char;
+ }
+ break;
+
+
+ default:
+ /* Expects the character in `c'. */
+ normal_char:
+ /* If no exactn currently being built. */
+ if (!pending_exact
+
+ /* If last exactn not at current position. */
+ || pending_exact + *pending_exact + 1 != b
+
+ /* We have only one byte following the exactn for the count. */
+ || *pending_exact == (1 << BYTEWIDTH) - 1
+
+ /* If followed by a repetition operator. */
+ || *p == '*' || *p == '^'
+ || ((syntax & RE_BK_PLUS_QM)
+ ? *p == '\\' && (p[1] == '+' || p[1] == '?')
+ : (*p == '+' || *p == '?'))
+ || ((syntax & RE_INTERVALS)
+ && ((syntax & RE_NO_BK_BRACES)
+ ? *p == '{'
+ : (p[0] == '\\' && p[1] == '{'))))
+ {
+ /* Start building a new exactn. */
+
+ laststart = b;
+
+ BUF_PUSH_2 (exactn, 0);
+ pending_exact = b - 1;
+ }
+
+ BUF_PUSH (c);
+ (*pending_exact)++;
+ break;
+ } /* switch (c) */
+ } /* while p != pend */
+
+
+ /* Through the pattern now. */
+
+ if (fixup_alt_jump)
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
+
+ if (!COMPILE_STACK_EMPTY)
+ return REG_EPAREN;
+
+ free (compile_stack.stack);
+
+ /* We have succeeded; set the length of the buffer. */
+ bufp->used = b - bufp->buffer;
+
+#ifdef DEBUG
+ if (debug)
+ {
+ DEBUG_PRINT1 ("\nCompiled pattern: ");
+ print_compiled_pattern (bufp);
+ }
+#endif /* DEBUG */
+
+ return REG_NOERROR;
+} /* regex_compile */
+
+/* Subroutines for `regex_compile'. */
+
+/* Store OP at LOC followed by two-byte integer parameter ARG. */
+
+static void
+store_op1 (op, loc, arg)
+ re_opcode_t op;
+ unsigned char *loc;
+ int arg;
+{
+ *loc = (unsigned char) op;
+ STORE_NUMBER (loc + 1, arg);
+}
+
+
+/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
+
+static void
+store_op2 (op, loc, arg1, arg2)
+ re_opcode_t op;
+ unsigned char *loc;
+ int arg1, arg2;
+{
+ *loc = (unsigned char) op;
+ STORE_NUMBER (loc + 1, arg1);
+ STORE_NUMBER (loc + 3, arg2);
+}
+
+
+/* Copy the bytes from LOC to END to open up three bytes of space at LOC
+ for OP followed by two-byte integer parameter ARG. */
+
+static void
+insert_op1 (op, loc, arg, end)
+ re_opcode_t op;
+ unsigned char *loc;
+ int arg;
+ unsigned char *end;
+{
+ register unsigned char *pfrom = end;
+ register unsigned char *pto = end + 3;
+
+ while (pfrom != loc)
+ *--pto = *--pfrom;
+
+ store_op1 (op, loc, arg);
+}
+
+
+/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
+
+static void
+insert_op2 (op, loc, arg1, arg2, end)
+ re_opcode_t op;
+ unsigned char *loc;
+ int arg1, arg2;
+ unsigned char *end;
+{
+ register unsigned char *pfrom = end;
+ register unsigned char *pto = end + 5;
+
+ while (pfrom != loc)
+ *--pto = *--pfrom;
+
+ store_op2 (op, loc, arg1, arg2);
+}
+
+
+/* P points to just after a ^ in PATTERN. Return true if that ^ comes
+ after an alternative or a begin-subexpression. We assume there is at
+ least one character before the ^. */
+
+static boolean
+at_begline_loc_p (pattern, p, syntax)
+ const char *pattern, *p;
+ reg_syntax_t syntax;
+{
+ const char *prev = p - 2;
+ boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
+
+ return
+ /* After a subexpression? */
+ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
+ /* After an alternative? */
+ || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
+}
+
+
+/* The dual of at_begline_loc_p. This one is for $. We assume there is
+ at least one character after the $, i.e., `P < PEND'. */
+
+static boolean
+at_endline_loc_p (p, pend, syntax)
+ const char *p, *pend;
+ int syntax;
+{
+ const char *next = p;
+ boolean next_backslash = *next == '\\';
+ const char *next_next = p + 1 < pend ? p + 1 : NULL;
+
+ return
+ /* Before a subexpression? */
+ (syntax & RE_NO_BK_PARENS ? *next == ')'
+ : next_backslash && next_next && *next_next == ')')
+ /* Before an alternative? */
+ || (syntax & RE_NO_BK_VBAR ? *next == '|'
+ : next_backslash && next_next && *next_next == '|');
+}
+
+
+/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
+ false if it's not. */
+
+static boolean
+group_in_compile_stack (compile_stack, regnum)
+ compile_stack_type compile_stack;
+ regnum_t regnum;
+{
+ int this_element;
+
+ for (this_element = compile_stack.avail - 1;
+ this_element >= 0;
+ this_element--)
+ if (compile_stack.stack[this_element].regnum == regnum)
+ return true;
+
+ return false;
+}
+
+
+/* Read the ending character of a range (in a bracket expression) from the
+ uncompiled pattern *P_PTR (which ends at PEND). We assume the
+ starting character is in `P[-2]'. (`P[-1]' is the character `-'.)
+ Then we set the translation of all bits between the starting and
+ ending characters (inclusive) in the compiled pattern B.
+
+ Return an error code.
+
+ We use these short variable names so we can use the same macros as
+ `regex_compile' itself. */
+
+static reg_errcode_t
+compile_range (p_ptr, pend, translate, syntax, b)
+ const char **p_ptr, *pend;
+ char *translate;
+ reg_syntax_t syntax;
+ unsigned char *b;
+{
+ unsigned this_char;
+
+ const char *p = *p_ptr;
+ int range_start, range_end;
+
+ if (p == pend)
+ return REG_ERANGE;
+
+ /* Even though the pattern is a signed `char *', we need to fetch
+ with unsigned char *'s; if the high bit of the pattern character
+ is set, the range endpoints will be negative if we fetch using a
+ signed char *.
+
+ We also want to fetch the endpoints without translating them; the
+ appropriate translation is done in the bit-setting loop below. */
+ range_start = ((unsigned char *) p)[-2];
+ range_end = ((unsigned char *) p)[0];
+
+ /* Have to increment the pointer into the pattern string, so the
+ caller isn't still at the ending character. */
+ (*p_ptr)++;
+
+ /* If the start is after the end, the range is empty. */
+ if (range_start > range_end)
+ return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
+
+ /* Here we see why `this_char' has to be larger than an `unsigned
+ char' -- the range is inclusive, so if `range_end' == 0xff
+ (assuming 8-bit characters), we would otherwise go into an infinite
+ loop, since all characters <= 0xff. */
+ for (this_char = range_start; this_char <= range_end; this_char++)
+ {
+ SET_LIST_BIT (TRANSLATE (this_char));
+ }
+
+ return REG_NOERROR;
+}
+
+/* Failure stack declarations and macros; both re_compile_fastmap and
+ re_match_2 use a failure stack. These have to be macros because of
+ REGEX_ALLOCATE. */
+
+
+/* Number of failure points for which to initially allocate space
+ when matching. If this number is exceeded, we allocate more
+ space, so it is not a hard limit. */
+#ifndef INIT_FAILURE_ALLOC
+#define INIT_FAILURE_ALLOC 5
+#endif
+
+/* Roughly the maximum number of failure points on the stack. Would be
+ exactly that if always used MAX_FAILURE_SPACE each time we failed.
+ This is a variable only so users of regex can assign to it; we never
+ change it ourselves. */
+int re_max_failures = 2000;
+
+typedef const unsigned char *fail_stack_elt_t;
+
+typedef struct
+{
+ fail_stack_elt_t *stack;
+ unsigned size;
+ unsigned avail; /* Offset of next open position. */
+} fail_stack_type;
+
+#define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
+#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
+#define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size)
+#define FAIL_STACK_TOP() (fail_stack.stack[fail_stack.avail])
+
+
+/* Initialize `fail_stack'. Do `return -2' if the alloc fails. */
+
+#define INIT_FAIL_STACK() \
+ do { \
+ fail_stack.stack = (fail_stack_elt_t *) \
+ REGEX_ALLOCATE (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t)); \
+ \
+ if (fail_stack.stack == NULL) \
+ return -2; \
+ \
+ fail_stack.size = INIT_FAILURE_ALLOC; \
+ fail_stack.avail = 0; \
+ } while (0)
+
+
+/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
+
+ Return 1 if succeeds, and 0 if either ran out of memory
+ allocating space for it or it was already too large.
+
+ REGEX_REALLOCATE requires `destination' be declared. */
+
+#define DOUBLE_FAIL_STACK(fail_stack) \
+ ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS \
+ ? 0 \
+ : ((fail_stack).stack = (fail_stack_elt_t *) \
+ REGEX_REALLOCATE ((fail_stack).stack, \
+ (fail_stack).size * sizeof (fail_stack_elt_t), \
+ ((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \
+ \
+ (fail_stack).stack == NULL \
+ ? 0 \
+ : ((fail_stack).size <<= 1, \
+ 1)))
+
+
+/* Push PATTERN_OP on FAIL_STACK.
+
+ Return 1 if was able to do so and 0 if ran out of memory allocating
+ space to do so. */
+#define PUSH_PATTERN_OP(pattern_op, fail_stack) \
+ ((FAIL_STACK_FULL () \
+ && !DOUBLE_FAIL_STACK (fail_stack)) \
+ ? 0 \
+ : ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
+ 1))
+
+/* This pushes an item onto the failure stack. Must be a four-byte
+ value. Assumes the variable `fail_stack'. Probably should only
+ be called from within `PUSH_FAILURE_POINT'. */
+#define PUSH_FAILURE_ITEM(item) \
+ fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item
+
+/* The complement operation. Assumes `fail_stack' is nonempty. */
+#define POP_FAILURE_ITEM() fail_stack.stack[--fail_stack.avail]
+
+/* Used to omit pushing failure point id's when we're not debugging. */
+#ifdef DEBUG
+#define DEBUG_PUSH PUSH_FAILURE_ITEM
+#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_ITEM ()
+#else
+#define DEBUG_PUSH(item)
+#define DEBUG_POP(item_addr)
+#endif
+
+
+/* Push the information about the state we will need
+ if we ever fail back to it.
+
+ Requires variables fail_stack, regstart, regend, reg_info, and
+ num_regs be declared. DOUBLE_FAIL_STACK requires `destination' be
+ declared.
+
+ Does `return FAILURE_CODE' if runs out of memory. */
+
+#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
+ do { \
+ char *destination; \
+ /* Must be int, so when we don't save any registers, the arithmetic \
+ of 0 + -1 isn't done as unsigned. */ \
+ int this_reg; \
+ \
+ DEBUG_STATEMENT (failure_id++); \
+ DEBUG_STATEMENT (nfailure_points_pushed++); \
+ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
+ DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\
+ DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\
+ \
+ DEBUG_PRINT2 (" slots needed: %d\n", NUM_FAILURE_ITEMS); \
+ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
+ \
+ /* Ensure we have enough space allocated for what we will push. */ \
+ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
+ { \
+ if (!DOUBLE_FAIL_STACK (fail_stack)) \
+ return failure_code; \
+ \
+ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
+ (fail_stack).size); \
+ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
+ } \
+ \
+ /* Push the info, starting with the registers. */ \
+ DEBUG_PRINT1 ("\n"); \
+ \
+ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
+ this_reg++) \
+ { \
+ DEBUG_PRINT2 (" Pushing reg: %d\n", this_reg); \
+ DEBUG_STATEMENT (num_regs_pushed++); \
+ \
+ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
+ PUSH_FAILURE_ITEM (regstart[this_reg]); \
+ \
+ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
+ PUSH_FAILURE_ITEM (regend[this_reg]); \
+ \
+ DEBUG_PRINT2 (" info: 0x%x\n ", reg_info[this_reg]); \
+ DEBUG_PRINT2 (" match_null=%d", \
+ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" matched_something=%d", \
+ MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" ever_matched=%d", \
+ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT1 ("\n"); \
+ PUSH_FAILURE_ITEM (reg_info[this_reg].word); \
+ } \
+ \
+ DEBUG_PRINT2 (" Pushing low active reg: %d\n", lowest_active_reg);\
+ PUSH_FAILURE_ITEM (lowest_active_reg); \
+ \
+ DEBUG_PRINT2 (" Pushing high active reg: %d\n", highest_active_reg);\
+ PUSH_FAILURE_ITEM (highest_active_reg); \
+ \
+ DEBUG_PRINT2 (" Pushing pattern 0x%x: ", pattern_place); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
+ PUSH_FAILURE_ITEM (pattern_place); \
+ \
+ DEBUG_PRINT2 (" Pushing string 0x%x: `", string_place); \
+ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
+ size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ PUSH_FAILURE_ITEM (string_place); \
+ \
+ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
+ DEBUG_PUSH (failure_id); \
+ } while (0)
+
+/* This is the number of items that are pushed and popped on the stack
+ for each register. */
+#define NUM_REG_ITEMS 3
+
+/* Individual items aside from the registers. */
+#ifdef DEBUG
+#define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
+#else
+#define NUM_NONREG_ITEMS 4
+#endif
+
+/* We push at most this many items on the stack. */
+#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
+
+/* We actually push this many items. */
+#define NUM_FAILURE_ITEMS \
+ ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \
+ + NUM_NONREG_ITEMS)
+
+/* How many items can still be added to the stack without overflowing it. */
+#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail)
+
+
+/* Pops what PUSH_FAIL_STACK pushes.
+
+ We restore into the parameters, all of which should be lvalues:
+ STR -- the saved data position.
+ PAT -- the saved pattern position.
+ LOW_REG, HIGH_REG -- the highest and lowest active registers.
+ REGSTART, REGEND -- arrays of string positions.
+ REG_INFO -- array of information about each subexpression.
+
+ Also assumes the variables `fail_stack' and (if debugging), `bufp',
+ `pend', `string1', `size1', `string2', and `size2'. */
+
+#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
+{ \
+ DEBUG_STATEMENT (fail_stack_elt_t failure_id;) \
+ int this_reg; \
+ const unsigned char *string_temp; \
+ \
+ assert (!FAIL_STACK_EMPTY ()); \
+ \
+ /* Remove failure points and point to how many regs pushed. */ \
+ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
+ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
+ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
+ \
+ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
+ \
+ DEBUG_POP (&failure_id); \
+ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
+ \
+ /* If the saved string location is NULL, it came from an \
+ on_failure_keep_string_jump opcode, and we want to throw away the \
+ saved NULL, thus retaining our current position in the string. */ \
+ string_temp = POP_FAILURE_ITEM (); \
+ if (string_temp != NULL) \
+ str = (const char *) string_temp; \
+ \
+ DEBUG_PRINT2 (" Popping string 0x%x: `", str); \
+ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ \
+ pat = (unsigned char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping pattern 0x%x: ", pat); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
+ \
+ /* Restore register info. */ \
+ high_reg = (unsigned) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping high active reg: %d\n", high_reg); \
+ \
+ low_reg = (unsigned) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" Popping low active reg: %d\n", low_reg); \
+ \
+ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
+ { \
+ DEBUG_PRINT2 (" Popping reg: %d\n", this_reg); \
+ \
+ reg_info[this_reg].word = POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" info: 0x%x\n", reg_info[this_reg]); \
+ \
+ regend[this_reg] = (const char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" end: 0x%x\n", regend[this_reg]); \
+ \
+ regstart[this_reg] = (const char *) POP_FAILURE_ITEM (); \
+ DEBUG_PRINT2 (" start: 0x%x\n", regstart[this_reg]); \
+ } \
+ \
+ DEBUG_STATEMENT (nfailure_points_popped++); \
+} /* POP_FAILURE_POINT */
+
+/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
+ BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible
+ characters can start a string that matches the pattern. This fastmap
+ is used by re_search to skip quickly over impossible starting points.
+
+ The caller must supply the address of a (1 << BYTEWIDTH)-byte data
+ area as BUFP->fastmap.
+
+ We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in
+ the pattern buffer.
+
+ Returns 0 if we succeed, -2 if an internal error. */
+
+int
+re_compile_fastmap (bufp)
+ struct re_pattern_buffer *bufp;
+{
+ int j, k;
+ fail_stack_type fail_stack;
+#ifndef REGEX_MALLOC
+ char *destination;
+#endif
+ /* We don't push any register information onto the failure stack. */
+ unsigned num_regs = 0;
+
+ register char *fastmap = bufp->fastmap;
+ unsigned char *pattern = bufp->buffer;
+ unsigned long size = bufp->used;
+ const unsigned char *p = pattern;
+ register unsigned char *pend = pattern + size;
+
+ /* Assume that each path through the pattern can be null until
+ proven otherwise. We set this false at the bottom of switch
+ statement, to which we get only if a particular path doesn't
+ match the empty string. */
+ boolean path_can_be_null = true;
+
+ /* We aren't doing a `succeed_n' to begin with. */
+ boolean succeed_n_p = false;
+
+ assert (fastmap != NULL && p != NULL);
+
+ INIT_FAIL_STACK ();
+ bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */
+ bufp->fastmap_accurate = 1; /* It will be when we're done. */
+ bufp->can_be_null = 0;
+
+ while (p != pend || !FAIL_STACK_EMPTY ())
+ {
+ if (p == pend)
+ {
+ bufp->can_be_null |= path_can_be_null;
+
+ /* Reset for next path. */
+ path_can_be_null = true;
+
+ p = fail_stack.stack[--fail_stack.avail];
+ }
+
+ /* We should never be about to go beyond the end of the pattern. */
+ assert (p < pend);
+
+#ifdef SWITCH_ENUM_BUG
+ switch ((int) ((re_opcode_t) *p++))
+#else
+ switch ((re_opcode_t) *p++)
+#endif
+ {
+
+ /* I guess the idea here is to simply not bother with a fastmap
+ if a backreference is used, since it's too hard to figure out
+ the fastmap for the corresponding group. Setting
+ `can_be_null' stops `re_search_2' from using the fastmap, so
+ that is all we do. */
+ case duplicate:
+ bufp->can_be_null = 1;
+ return 0;
+
+
+ /* Following are the cases which match a character. These end
+ with `break'. */
+
+ case exactn:
+ fastmap[p[1]] = 1;
+ break;
+
+
+ case charset:
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
+ fastmap[j] = 1;
+ break;
+
+
+ case charset_not:
+ /* Chars beyond end of map must be allowed. */
+ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
+ fastmap[j] = 1;
+
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
+ fastmap[j] = 1;
+ break;
+
+
+ case wordchar:
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) == Sword)
+ fastmap[j] = 1;
+ break;
+
+
+ case notwordchar:
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) != Sword)
+ fastmap[j] = 1;
+ break;
+
+
+ case anychar:
+ /* `.' matches anything ... */
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ fastmap[j] = 1;
+
+ /* ... except perhaps newline. */
+ if (!(bufp->syntax & RE_DOT_NEWLINE))
+ fastmap['\n'] = 0;
+
+ /* Return if we have already set `can_be_null'; if we have,
+ then the fastmap is irrelevant. Something's wrong here. */
+ else if (bufp->can_be_null)
+ return 0;
+
+ /* Otherwise, have to check alternative paths. */
+ break;
+
+
+#ifdef emacs
+ case syntaxspec:
+ k = *p++;
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) == (enum syntaxcode) k)
+ fastmap[j] = 1;
+ break;
+
+
+ case notsyntaxspec:
+ k = *p++;
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) != (enum syntaxcode) k)
+ fastmap[j] = 1;
+ break;
+
+
+ /* All cases after this match the empty string. These end with
+ `continue'. */
+
+
+ case before_dot:
+ case at_dot:
+ case after_dot:
+ continue;
+#endif /* not emacs */
+
+
+ case no_op:
+ case begline:
+ case endline:
+ case begbuf:
+ case endbuf:
+ case wordbound:
+ case notwordbound:
+ case wordbeg:
+ case wordend:
+ case push_dummy_failure:
+ continue;
+
+
+ case jump_n:
+ case pop_failure_jump:
+ case maybe_pop_jump:
+ case jump:
+ case jump_past_alt:
+ case dummy_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (j, p);
+ p += j;
+ if (j > 0)
+ continue;
+
+ /* Jump backward implies we just went through the body of a
+ loop and matched nothing. Opcode jumped to should be
+ `on_failure_jump' or `succeed_n'. Just treat it like an
+ ordinary jump. For a * loop, it has pushed its failure
+ point already; if so, discard that as redundant. */
+ if ((re_opcode_t) *p != on_failure_jump
+ && (re_opcode_t) *p != succeed_n)
+ continue;
+
+ p++;
+ EXTRACT_NUMBER_AND_INCR (j, p);
+ p += j;
+
+ /* If what's on the stack is where we are now, pop it. */
+ if (!FAIL_STACK_EMPTY ()
+ && fail_stack.stack[fail_stack.avail - 1] == p)
+ fail_stack.avail--;
+
+ continue;
+
+
+ case on_failure_jump:
+ case on_failure_keep_string_jump:
+ handle_on_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (j, p);
+
+ /* For some patterns, e.g., `(a?)?', `p+j' here points to the
+ end of the pattern. We don't want to push such a point,
+ since when we restore it above, entering the switch will
+ increment `p' past the end of the pattern. We don't need
+ to push such a point since we obviously won't find any more
+ fastmap entries beyond `pend'. Such a pattern can match
+ the null string, though. */
+ if (p + j < pend)
+ {
+ if (!PUSH_PATTERN_OP (p + j, fail_stack))
+ return -2;
+ }
+ else
+ bufp->can_be_null = 1;
+
+ if (succeed_n_p)
+ {
+ EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */
+ succeed_n_p = false;
+ }
+
+ continue;
+
+
+ case succeed_n:
+ /* Get to the number of times to succeed. */
+ p += 2;
+
+ /* Increment p past the n for when k != 0. */
+ EXTRACT_NUMBER_AND_INCR (k, p);
+ if (k == 0)
+ {
+ p -= 4;
+ succeed_n_p = true; /* Spaghetti code alert. */
+ goto handle_on_failure_jump;
+ }
+ continue;
+
+
+ case set_number_at:
+ p += 4;
+ continue;
+
+
+ case start_memory:
+ case stop_memory:
+ p += 2;
+ continue;
+
+
+ default:
+ abort (); /* We have listed all the cases. */
+ } /* switch *p++ */
+
+ /* Getting here means we have found the possible starting
+ characters for one path of the pattern -- and that the empty
+ string does not match. We need not follow this path further.
+ Instead, look at the next alternative (remembered on the
+ stack), or quit if no more. The test at the top of the loop
+ does these things. */
+ path_can_be_null = false;
+ p = pend;
+ } /* while p */
+
+ /* Set `can_be_null' for the last path (also the first path, if the
+ pattern is empty). */
+ bufp->can_be_null |= path_can_be_null;
+ return 0;
+} /* re_compile_fastmap */
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
+ this memory for recording register information. STARTS and ENDS
+ must be allocated using the malloc library routine, and must each
+ be at least NUM_REGS * sizeof (regoff_t) bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+
+void
+re_set_registers (bufp, regs, num_regs, starts, ends)
+ struct re_pattern_buffer *bufp;
+ struct re_registers *regs;
+ unsigned num_regs;
+ regoff_t *starts, *ends;
+{
+ if (num_regs)
+ {
+ bufp->regs_allocated = REGS_REALLOCATE;
+ regs->num_regs = num_regs;
+ regs->start = starts;
+ regs->end = ends;
+ }
+ else
+ {
+ bufp->regs_allocated = REGS_UNALLOCATED;
+ regs->num_regs = 0;
+ regs->start = regs->end = (regoff_t) 0;
+ }
+}
+
+/* Searching routines. */
+
+/* Like re_search_2, below, but only one string is specified, and
+ doesn't let you say where to stop matching. */
+
+int
+re_search (bufp, string, size, startpos, range, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, startpos, range;
+ struct re_registers *regs;
+{
+ return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
+ regs, size);
+}
+
+
+/* Using the compiled pattern in BUFP->buffer, first tries to match the
+ virtual concatenation of STRING1 and STRING2, starting first at index
+ STARTPOS, then at STARTPOS + 1, and so on.
+
+ STRING1 and STRING2 have length SIZE1 and SIZE2, respectively.
+
+ RANGE is how far to scan while trying to match. RANGE = 0 means try
+ only at STARTPOS; in general, the last start tried is STARTPOS +
+ RANGE.
+
+ In REGS, return the indices of the virtual concatenation of STRING1
+ and STRING2 that matched the entire BUFP->buffer and its contained
+ subexpressions.
+
+ Do not consider matching one past the index STOP in the virtual
+ concatenation of STRING1 and STRING2.
+
+ We return either the position in the strings at which the match was
+ found, -1 if no match, or -2 if error (such as failure
+ stack overflow). */
+
+int
+re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int startpos;
+ int range;
+ struct re_registers *regs;
+ int stop;
+{
+ int val;
+ register char *fastmap = bufp->fastmap;
+ register char *translate = bufp->translate;
+ int total_size = size1 + size2;
+ int endpos = startpos + range;
+
+ /* Check for out-of-range STARTPOS. */
+ if (startpos < 0 || startpos > total_size)
+ return -1;
+
+ /* Fix up RANGE if it might eventually take us outside
+ the virtual concatenation of STRING1 and STRING2. */
+ if (endpos < -1)
+ range = -1 - startpos;
+ else if (endpos > total_size)
+ range = total_size - startpos;
+
+ /* If the search isn't to be a backwards one, don't waste time in a
+ search for a pattern that must be anchored. */
+ if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
+ {
+ if (startpos > 0)
+ return -1;
+ else
+ range = 1;
+ }
+
+ /* Update the fastmap now if not correct already. */
+ if (fastmap && !bufp->fastmap_accurate)
+ if (re_compile_fastmap (bufp) == -2)
+ return -2;
+
+ /* Loop through the string, looking for a place to start matching. */
+ for (;;)
+ {
+ /* If a fastmap is supplied, skip quickly over characters that
+ cannot be the start of a match. If the pattern can match the
+ null string, however, we don't need to skip characters; we want
+ the first null string. */
+ if (fastmap && startpos < total_size && !bufp->can_be_null)
+ {
+ if (range > 0) /* Searching forwards. */
+ {
+ register const char *d;
+ register int lim = 0;
+ int irange = range;
+
+ if (startpos < size1 && startpos + range >= size1)
+ lim = range - (size1 - startpos);
+
+ d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
+
+ /* Written out as an if-else to avoid testing `translate'
+ inside the loop. */
+ if (translate)
+ while (range > lim
+ && !fastmap[(unsigned char)
+ translate[(unsigned char) *d++]])
+ range--;
+ else
+ while (range > lim && !fastmap[(unsigned char) *d++])
+ range--;
+
+ startpos += irange - range;
+ }
+ else /* Searching backwards. */
+ {
+ register char c = (size1 == 0 || startpos >= size1
+ ? string2[startpos - size1]
+ : string1[startpos]);
+
+ if (!fastmap[(unsigned char) TRANSLATE (c)])
+ goto advance;
+ }
+ }
+
+ /* If can't match the null string, and that's all we have left, fail. */
+ if (range >= 0 && startpos == total_size && fastmap
+ && !bufp->can_be_null)
+ return -1;
+
+ val = re_match_2 (bufp, string1, size1, string2, size2,
+ startpos, regs, stop);
+ if (val >= 0)
+ return startpos;
+
+ if (val == -2)
+ return -2;
+
+ advance:
+ if (!range)
+ break;
+ else if (range > 0)
+ {
+ range--;
+ startpos++;
+ }
+ else
+ {
+ range++;
+ startpos--;
+ }
+ }
+ return -1;
+} /* re_search_2 */
+
+/* Declarations and macros for re_match_2. */
+
+static int bcmp_translate ();
+static boolean alt_match_null_string_p (),
+ common_op_match_null_string_p (),
+ group_match_null_string_p ();
+
+/* Structure for per-register (a.k.a. per-group) information.
+ This must not be longer than one word, because we push this value
+ onto the failure stack. Other register information, such as the
+ starting and ending positions (which are addresses), and the list of
+ inner groups (which is a bits list) are maintained in separate
+ variables.
+
+ We are making a (strictly speaking) nonportable assumption here: that
+ the compiler will pack our bit fields into something that fits into
+ the type of `word', i.e., is something that fits into one item on the
+ failure stack. */
+typedef union
+{
+ fail_stack_elt_t word;
+ struct
+ {
+ /* This field is one if this group can match the empty string,
+ zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */
+#define MATCH_NULL_UNSET_VALUE 3
+ unsigned match_null_string_p : 2;
+ unsigned is_active : 1;
+ unsigned matched_something : 1;
+ unsigned ever_matched_something : 1;
+ } bits;
+} register_info_type;
+
+#define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
+#define IS_ACTIVE(R) ((R).bits.is_active)
+#define MATCHED_SOMETHING(R) ((R).bits.matched_something)
+#define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something)
+
+
+/* Call this when have matched a real character; it sets `matched' flags
+ for the subexpressions which we are currently inside. Also records
+ that those subexprs have matched. */
+#define SET_REGS_MATCHED() \
+ do \
+ { \
+ unsigned r; \
+ for (r = lowest_active_reg; r <= highest_active_reg; r++) \
+ { \
+ MATCHED_SOMETHING (reg_info[r]) \
+ = EVER_MATCHED_SOMETHING (reg_info[r]) \
+ = 1; \
+ } \
+ } \
+ while (0)
+
+
+/* This converts PTR, a pointer into one of the search strings `string1'
+ and `string2' into an offset from the beginning of that string. */
+#define POINTER_TO_OFFSET(ptr) \
+ (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1)
+
+/* Registers are set to a sentinel when they haven't yet matched. */
+#define REG_UNSET_VALUE ((char *) -1)
+#define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
+
+
+/* Macros for dealing with the split strings in re_match_2. */
+
+#define MATCHING_IN_FIRST_STRING (dend == end_match_1)
+
+/* Call before fetching a character with *d. This switches over to
+ string2 if necessary. */
+#define PREFETCH() \
+ while (d == dend) \
+ { \
+ /* End of string2 => fail. */ \
+ if (dend == end_match_2) \
+ goto fail; \
+ /* End of string1 => advance to string2. */ \
+ d = string2; \
+ dend = end_match_2; \
+ }
+
+
+/* Test if at very beginning or at very end of the virtual concatenation
+ of `string1' and `string2'. If only one string, it's `string2'. */
+#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
+#define AT_STRINGS_END(d) ((d) == end2)
+
+
+/* Test if D points to a character which is word-constituent. We have
+ two special cases to check for: if past the end of string1, look at
+ the first character in string2; and if before the beginning of
+ string2, look at the last character in string1. */
+#define WORDCHAR_P(d) \
+ (SYNTAX ((d) == end1 ? *string2 \
+ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \
+ == Sword)
+
+/* Test if the character before D and the one at D differ with respect
+ to being word-constituent. */
+#define AT_WORD_BOUNDARY(d) \
+ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \
+ || WORDCHAR_P (d - 1) != WORDCHAR_P (d))
+
+
+/* Free everything we malloc. */
+#ifdef REGEX_MALLOC
+#define FREE_VAR(var) if (var) free (var); var = NULL
+#define FREE_VARIABLES() \
+ do { \
+ FREE_VAR (fail_stack.stack); \
+ FREE_VAR (regstart); \
+ FREE_VAR (regend); \
+ FREE_VAR (old_regstart); \
+ FREE_VAR (old_regend); \
+ FREE_VAR (best_regstart); \
+ FREE_VAR (best_regend); \
+ FREE_VAR (reg_info); \
+ FREE_VAR (reg_dummy); \
+ FREE_VAR (reg_info_dummy); \
+ } while (0)
+#else /* not REGEX_MALLOC */
+/* Some MIPS systems (at least) want this to free alloca'd storage. */
+#define FREE_VARIABLES() alloca (0)
+#endif /* not REGEX_MALLOC */
+
+
+/* These values must meet several constraints. They must not be valid
+ register values; since we have a limit of 255 registers (because
+ we use only one byte in the pattern for the register number), we can
+ use numbers larger than 255. They must differ by 1, because of
+ NUM_FAILURE_ITEMS above. And the value for the lowest register must
+ be larger than the value for the highest register, so we do not try
+ to actually save any registers when none are active. */
+#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH)
+#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1)
+
+/* Matching routines. */
+
+#ifndef emacs /* Emacs never uses this. */
+/* re_match is like re_match_2 except it takes only a single string. */
+
+int
+re_match (bufp, string, size, pos, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, pos;
+ struct re_registers *regs;
+ {
+ return re_match_2 (bufp, NULL, 0, string, size, pos, regs, size);
+}
+#endif /* not emacs */
+
+
+/* re_match_2 matches the compiled pattern in BUFP against the
+ the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
+ and SIZE2, respectively). We start matching at POS, and stop
+ matching at STOP.
+
+ If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
+ store offsets for the substring each group matched in REGS. See the
+ documentation for exactly how many groups we fill.
+
+ We return -1 if no match, -2 if an internal error (such as the
+ failure stack overflowing). Otherwise, we return the length of the
+ matched substring. */
+
+int
+re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int pos;
+ struct re_registers *regs;
+ int stop;
+{
+ /* General temporaries. */
+ int mcnt;
+ unsigned char *p1;
+
+ /* Just past the end of the corresponding string. */
+ const char *end1, *end2;
+
+ /* Pointers into string1 and string2, just past the last characters in
+ each to consider matching. */
+ const char *end_match_1, *end_match_2;
+
+ /* Where we are in the data, and the end of the current string. */
+ const char *d, *dend;
+
+ /* Where we are in the pattern, and the end of the pattern. */
+ unsigned char *p = bufp->buffer;
+ register unsigned char *pend = p + bufp->used;
+
+ /* We use this to map every character in the string. */
+ char *translate = bufp->translate;
+
+ /* Failure point stack. Each place that can handle a failure further
+ down the line pushes a failure point on this stack. It consists of
+ restart, regend, and reg_info for all registers corresponding to
+ the subexpressions we're currently inside, plus the number of such
+ registers, and, finally, two char *'s. The first char * is where
+ to resume scanning the pattern; the second one is where to resume
+ scanning the strings. If the latter is zero, the failure point is
+ a ``dummy''; if a failure happens and the failure point is a dummy,
+ it gets discarded and the next next one is tried. */
+ fail_stack_type fail_stack;
+#ifdef DEBUG
+ static unsigned failure_id = 0;
+ unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
+#endif
+
+ /* We fill all the registers internally, independent of what we
+ return, for use in backreferences. The number here includes
+ an element for register zero. */
+ unsigned num_regs = bufp->re_nsub + 1;
+
+ /* The currently active registers. */
+ unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+
+ /* Information on the contents of registers. These are pointers into
+ the input strings; they record just what was matched (on this
+ attempt) by a subexpression part of the pattern, that is, the
+ regnum-th regstart pointer points to where in the pattern we began
+ matching and the regnum-th regend points to right after where we
+ stopped matching the regnum-th subexpression. (The zeroth register
+ keeps track of what the whole pattern matches.) */
+ const char **regstart = NULL, **regend = NULL;
+
+ /* If a group that's operated upon by a repetition operator fails to
+ match anything, then the register for its start will need to be
+ restored because it will have been set to wherever in the string we
+ are when we last see its open-group operator. Similarly for a
+ register's end. */
+ const char **old_regstart = NULL, **old_regend = NULL;
+
+ /* The is_active field of reg_info helps us keep track of which (possibly
+ nested) subexpressions we are currently in. The matched_something
+ field of reg_info[reg_num] helps us tell whether or not we have
+ matched any of the pattern so far this time through the reg_num-th
+ subexpression. These two fields get reset each time through any
+ loop their register is in. */
+ register_info_type *reg_info = NULL;
+
+ /* The following record the register info as found in the above
+ variables when we find a match better than any we've seen before.
+ This happens as we backtrack through the failure points, which in
+ turn happens only if we have not yet matched the entire string. */
+ unsigned best_regs_set = false;
+ const char **best_regstart = NULL, **best_regend = NULL;
+
+ /* Logically, this is `best_regend[0]'. But we don't want to have to
+ allocate space for that if we're not allocating space for anything
+ else (see below). Also, we never need info about register 0 for
+ any of the other register vectors, and it seems rather a kludge to
+ treat `best_regend' differently than the rest. So we keep track of
+ the end of the best match so far in a separate variable. We
+ initialize this to NULL so that when we backtrack the first time
+ and need to test it, it's not garbage. */
+ const char *match_end = NULL;
+
+ /* Used when we pop values we don't care about. */
+ const char **reg_dummy = NULL;
+ register_info_type *reg_info_dummy = NULL;
+
+#ifdef DEBUG
+ /* Counts the total number of registers pushed. */
+ unsigned num_regs_pushed = 0;
+#endif
+
+ DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
+
+ INIT_FAIL_STACK ();
+
+ /* Do not bother to initialize all the register variables if there are
+ no groups in the pattern, as it takes a fair amount of time. If
+ there are groups, we include space for register 0 (the whole
+ pattern), even though we never use it, since it simplifies the
+ array indexing. We should fix this. */
+ if (bufp->re_nsub)
+ {
+ regstart = REGEX_TALLOC (num_regs, const char *);
+ regend = REGEX_TALLOC (num_regs, const char *);
+ old_regstart = REGEX_TALLOC (num_regs, const char *);
+ old_regend = REGEX_TALLOC (num_regs, const char *);
+ best_regstart = REGEX_TALLOC (num_regs, const char *);
+ best_regend = REGEX_TALLOC (num_regs, const char *);
+ reg_info = REGEX_TALLOC (num_regs, register_info_type);
+ reg_dummy = REGEX_TALLOC (num_regs, const char *);
+ reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);
+
+ if (!(regstart && regend && old_regstart && old_regend && reg_info
+ && best_regstart && best_regend && reg_dummy && reg_info_dummy))
+ {
+ FREE_VARIABLES ();
+ return -2;
+ }
+ }
+#ifdef REGEX_MALLOC
+ else
+ {
+ /* We must initialize all our variables to NULL, so that
+ `FREE_VARIABLES' doesn't try to free them. */
+ regstart = regend = old_regstart = old_regend = best_regstart
+ = best_regend = reg_dummy = NULL;
+ reg_info = reg_info_dummy = (register_info_type *) NULL;
+ }
+#endif /* REGEX_MALLOC */
+
+ /* The starting position is bogus. */
+ if (pos < 0 || pos > size1 + size2)
+ {
+ FREE_VARIABLES ();
+ return -1;
+ }
+
+ /* Initialize subexpression text positions to -1 to mark ones that no
+ start_memory/stop_memory has been seen for. Also initialize the
+ register information struct. */
+ for (mcnt = 1; mcnt < num_regs; mcnt++)
+ {
+ regstart[mcnt] = regend[mcnt]
+ = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
+
+ REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
+ IS_ACTIVE (reg_info[mcnt]) = 0;
+ MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+ EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+ }
+
+ /* We move `string1' into `string2' if the latter's empty -- but not if
+ `string1' is null. */
+ if (size2 == 0 && string1 != NULL)
+ {
+ string2 = string1;
+ size2 = size1;
+ string1 = 0;
+ size1 = 0;
+ }
+ end1 = string1 + size1;
+ end2 = string2 + size2;
+
+ /* Compute where to stop matching, within the two strings. */
+ if (stop <= size1)
+ {
+ end_match_1 = string1 + stop;
+ end_match_2 = string2;
+ }
+ else
+ {
+ end_match_1 = end1;
+ end_match_2 = string2 + stop - size1;
+ }
+
+ /* `p' scans through the pattern as `d' scans through the data.
+ `dend' is the end of the input string that `d' points within. `d'
+ is advanced into the following input string whenever necessary, but
+ this happens before fetching; therefore, at the beginning of the
+ loop, `d' can be pointing at the end of a string, but it cannot
+ equal `string2'. */
+ if (size1 > 0 && pos <= size1)
+ {
+ d = string1 + pos;
+ dend = end_match_1;
+ }
+ else
+ {
+ d = string2 + pos - size1;
+ dend = end_match_2;
+ }
+
+ DEBUG_PRINT1 ("The compiled pattern is: ");
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
+ DEBUG_PRINT1 ("The string to match is: `");
+ DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
+ DEBUG_PRINT1 ("'\n");
+
+ /* This loops over pattern commands. It exits by returning from the
+ function if the match is complete, or it drops through if the match
+ fails at this starting point in the input data. */
+ for (;;)
+ {
+ DEBUG_PRINT2 ("\n0x%x: ", p);
+
+ if (p == pend)
+ { /* End of pattern means we might have succeeded. */
+ DEBUG_PRINT1 ("end of pattern ... ");
+
+ /* If we haven't matched the entire string, and we want the
+ longest match, try backtracking. */
+ if (d != end_match_2)
+ {
+ DEBUG_PRINT1 ("backtracking.\n");
+
+ if (!FAIL_STACK_EMPTY ())
+ { /* More failure points to try. */
+ boolean same_str_p = (FIRST_STRING_P (match_end)
+ == MATCHING_IN_FIRST_STRING);
+
+ /* If exceeds best match so far, save it. */
+ if (!best_regs_set
+ || (same_str_p && d > match_end)
+ || (!same_str_p && !MATCHING_IN_FIRST_STRING))
+ {
+ best_regs_set = true;
+ match_end = d;
+
+ DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
+
+ for (mcnt = 1; mcnt < num_regs; mcnt++)
+ {
+ best_regstart[mcnt] = regstart[mcnt];
+ best_regend[mcnt] = regend[mcnt];
+ }
+ }
+ goto fail;
+ }
+
+ /* If no failure points, don't restore garbage. */
+ else if (best_regs_set)
+ {
+ restore_best_regs:
+ /* Restore best match. It may happen that `dend ==
+ end_match_1' while the restored d is in string2.
+ For example, the pattern `x.*y.*z' against the
+ strings `x-' and `y-z-', if the two strings are
+ not consecutive in memory. */
+ DEBUG_PRINT1 ("Restoring best registers.\n");
+
+ d = match_end;
+ dend = ((d >= string1 && d <= end1)
+ ? end_match_1 : end_match_2);
+
+ for (mcnt = 1; mcnt < num_regs; mcnt++)
+ {
+ regstart[mcnt] = best_regstart[mcnt];
+ regend[mcnt] = best_regend[mcnt];
+ }
+ }
+ } /* d != end_match_2 */
+
+ DEBUG_PRINT1 ("Accepting match.\n");
+
+ /* If caller wants register contents data back, do it. */
+ if (regs && !bufp->no_sub)
+ {
+ /* Have the register data arrays been allocated? */
+ if (bufp->regs_allocated == REGS_UNALLOCATED)
+ { /* No. So allocate them with malloc. We need one
+ extra element beyond `num_regs' for the `-1' marker
+ GNU code uses. */
+ regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+ regs->start = TALLOC (regs->num_regs, regoff_t);
+ regs->end = TALLOC (regs->num_regs, regoff_t);
+ if (regs->start == NULL || regs->end == NULL)
+ return -2;
+ bufp->regs_allocated = REGS_REALLOCATE;
+ }
+ else if (bufp->regs_allocated == REGS_REALLOCATE)
+ { /* Yes. If we need more elements than were already
+ allocated, reallocate them. If we need fewer, just
+ leave it alone. */
+ if (regs->num_regs < num_regs + 1)
+ {
+ regs->num_regs = num_regs + 1;
+ RETALLOC (regs->start, regs->num_regs, regoff_t);
+ RETALLOC (regs->end, regs->num_regs, regoff_t);
+ if (regs->start == NULL || regs->end == NULL)
+ return -2;
+ }
+ }
+ else
+ assert (bufp->regs_allocated == REGS_FIXED);
+
+ /* Convert the pointer data in `regstart' and `regend' to
+ indices. Register zero has to be set differently,
+ since we haven't kept track of any info for it. */
+ if (regs->num_regs > 0)
+ {
+ regs->start[0] = pos;
+ regs->end[0] = (MATCHING_IN_FIRST_STRING ? d - string1
+ : d - string2 + size1);
+ }
+
+ /* Go through the first `min (num_regs, regs->num_regs)'
+ registers, since that is all we initialized. */
+ for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
+ {
+ if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
+ regs->start[mcnt] = regs->end[mcnt] = -1;
+ else
+ {
+ regs->start[mcnt] = POINTER_TO_OFFSET (regstart[mcnt]);
+ regs->end[mcnt] = POINTER_TO_OFFSET (regend[mcnt]);
+ }
+ }
+
+ /* If the regs structure we return has more elements than
+ were in the pattern, set the extra elements to -1. If
+ we (re)allocated the registers, this is the case,
+ because we always allocate enough to have at least one
+ -1 at the end. */
+ for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
+ regs->start[mcnt] = regs->end[mcnt] = -1;
+ } /* regs && !bufp->no_sub */
+
+ FREE_VARIABLES ();
+ DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
+ nfailure_points_pushed, nfailure_points_popped,
+ nfailure_points_pushed - nfailure_points_popped);
+ DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
+
+ mcnt = d - pos - (MATCHING_IN_FIRST_STRING
+ ? string1
+ : string2 - size1);
+
+ DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
+
+ return mcnt;
+ }
+
+ /* Otherwise match next pattern command. */
+#ifdef SWITCH_ENUM_BUG
+ switch ((int) ((re_opcode_t) *p++))
+#else
+ switch ((re_opcode_t) *p++)
+#endif
+ {
+ /* Ignore these. Used to ignore the n of succeed_n's which
+ currently have n == 0. */
+ case no_op:
+ DEBUG_PRINT1 ("EXECUTING no_op.\n");
+ break;
+
+
+ /* Match the next n pattern characters exactly. The following
+ byte in the pattern defines n, and the n bytes after that
+ are the characters to match. */
+ case exactn:
+ mcnt = *p++;
+ DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
+
+ /* This is written out as an if-else so we don't waste time
+ testing `translate' inside the loop. */
+ if (translate)
+ {
+ do
+ {
+ PREFETCH ();
+ if (translate[(unsigned char) *d++] != (char) *p++)
+ goto fail;
+ }
+ while (--mcnt);
+ }
+ else
+ {
+ do
+ {
+ PREFETCH ();
+ if (*d++ != (char) *p++) goto fail;
+ }
+ while (--mcnt);
+ }
+ SET_REGS_MATCHED ();
+ break;
+
+
+ /* Match any character except possibly a newline or a null. */
+ case anychar:
+ DEBUG_PRINT1 ("EXECUTING anychar.\n");
+
+ PREFETCH ();
+
+ if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
+ || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
+ goto fail;
+
+ SET_REGS_MATCHED ();
+ DEBUG_PRINT2 (" Matched `%d'.\n", *d);
+ d++;
+ break;
+
+
+ case charset:
+ case charset_not:
+ {
+ register unsigned char c;
+ boolean not = (re_opcode_t) *(p - 1) == charset_not;
+
+ DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
+
+ PREFETCH ();
+ c = TRANSLATE (*d); /* The character to match. */
+
+ /* Cast to `unsigned' instead of `unsigned char' in case the
+ bit list is a full 32 bytes long. */
+ if (c < (unsigned) (*p * BYTEWIDTH)
+ && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+ not = !not;
+
+ p += 1 + *p;
+
+ if (!not) goto fail;
+
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+ }
+
+
+ /* The beginning of a group is represented by start_memory.
+ The arguments are the register number in the next byte, and the
+ number of groups inner to this one in the next. The text
+ matched within the group is recorded (in the internal
+ registers data structure) under the register number. */
+ case start_memory:
+ DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]);
+
+ /* Find out if this group can match the empty string. */
+ p1 = p; /* To send to group_match_null_string_p. */
+
+ if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
+ REG_MATCH_NULL_STRING_P (reg_info[*p])
+ = group_match_null_string_p (&p1, pend, reg_info);
+
+ /* Save the position in the string where we were the last time
+ we were at this open-group operator in case the group is
+ operated upon by a repetition operator, e.g., with `(a*)*b'
+ against `ab'; then we want to ignore where we are now in
+ the string in case this attempt to match fails. */
+ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+ ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
+ : regstart[*p];
+ DEBUG_PRINT2 (" old_regstart: %d\n",
+ POINTER_TO_OFFSET (old_regstart[*p]));
+
+ regstart[*p] = d;
+ DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
+
+ IS_ACTIVE (reg_info[*p]) = 1;
+ MATCHED_SOMETHING (reg_info[*p]) = 0;
+
+ /* This is the new highest active register. */
+ highest_active_reg = *p;
+
+ /* If nothing was active before, this is the new lowest active
+ register. */
+ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+ lowest_active_reg = *p;
+
+ /* Move past the register number and inner group count. */
+ p += 2;
+ break;
+
+
+ /* The stop_memory opcode represents the end of a group. Its
+ arguments are the same as start_memory's: the register
+ number, and the number of inner groups. */
+ case stop_memory:
+ DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
+
+ /* We need to save the string position the last time we were at
+ this close-group operator in case the group is operated
+ upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
+ against `aba'; then we want to ignore where we are now in
+ the string in case this attempt to match fails. */
+ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+ ? REG_UNSET (regend[*p]) ? d : regend[*p]
+ : regend[*p];
+ DEBUG_PRINT2 (" old_regend: %d\n",
+ POINTER_TO_OFFSET (old_regend[*p]));
+
+ regend[*p] = d;
+ DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
+
+ /* This register isn't active anymore. */
+ IS_ACTIVE (reg_info[*p]) = 0;
+
+ /* If this was the only register active, nothing is active
+ anymore. */
+ if (lowest_active_reg == highest_active_reg)
+ {
+ lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+ }
+ else
+ { /* We must scan for the new highest active register, since
+ it isn't necessarily one less than now: consider
+ (a(b)c(d(e)f)g). When group 3 ends, after the f), the
+ new highest active register is 1. */
+ unsigned char r = *p - 1;
+ while (r > 0 && !IS_ACTIVE (reg_info[r]))
+ r--;
+
+ /* If we end up at register zero, that means that we saved
+ the registers as the result of an `on_failure_jump', not
+ a `start_memory', and we jumped to past the innermost
+ `stop_memory'. For example, in ((.)*) we save
+ registers 1 and 2 as a result of the *, but when we pop
+ back to the second ), we are at the stop_memory 1.
+ Thus, nothing is active. */
+ if (r == 0)
+ {
+ lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+ }
+ else
+ highest_active_reg = r;
+ }
+
+ /* If just failed to match something this time around with a
+ group that's operated on by a repetition operator, try to
+ force exit from the ``loop'', and restore the register
+ information for this group that we had before trying this
+ last match. */
+ if ((!MATCHED_SOMETHING (reg_info[*p])
+ || (re_opcode_t) p[-3] == start_memory)
+ && (p + 2) < pend)
+ {
+ boolean is_a_jump_n = false;
+
+ p1 = p + 2;
+ mcnt = 0;
+ switch ((re_opcode_t) *p1++)
+ {
+ case jump_n:
+ is_a_jump_n = true;
+ case pop_failure_jump:
+ case maybe_pop_jump:
+ case jump:
+ case dummy_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if (is_a_jump_n)
+ p1 += 2;
+ break;
+
+ default:
+ /* do nothing */ ;
+ }
+ p1 += mcnt;
+
+ /* If the next operation is a jump backwards in the pattern
+ to an on_failure_jump right before the start_memory
+ corresponding to this stop_memory, exit from the loop
+ by forcing a failure after pushing on the stack the
+ on_failure_jump's jump in the pattern, and d. */
+ if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump
+ && (re_opcode_t) p1[3] == start_memory && p1[4] == *p)
+ {
+ /* If this group ever matched anything, then restore
+ what its registers were before trying this last
+ failed match, e.g., with `(a*)*b' against `ab' for
+ regstart[1], and, e.g., with `((a*)*(b*)*)*'
+ against `aba' for regend[3].
+
+ Also restore the registers for inner groups for,
+ e.g., `((a*)(b*))*' against `aba' (register 3 would
+ otherwise get trashed). */
+
+ if (EVER_MATCHED_SOMETHING (reg_info[*p]))
+ {
+ unsigned r;
+
+ EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
+
+ /* Restore this and inner groups' (if any) registers. */
+ for (r = *p; r < *p + *(p + 1); r++)
+ {
+ regstart[r] = old_regstart[r];
+
+ /* xx why this test? */
+ if ((int) old_regend[r] >= (int) regstart[r])
+ regend[r] = old_regend[r];
+ }
+ }
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
+
+ goto fail;
+ }
+ }
+
+ /* Move past the register number and the inner group count. */
+ p += 2;
+ break;
+
+
+ /* \<digit> has been turned into a `duplicate' command which is
+ followed by the numeric value of <digit> as the register number. */
+ case duplicate:
+ {
+ register const char *d2, *dend2;
+ int regno = *p++; /* Get which register to match against. */
+ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
+
+ /* Can't back reference a group which we've never matched. */
+ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
+ goto fail;
+
+ /* Where in input to try to start matching. */
+ d2 = regstart[regno];
+
+ /* Where to stop matching; if both the place to start and
+ the place to stop matching are in the same string, then
+ set to the place to stop, otherwise, for now have to use
+ the end of the first string. */
+
+ dend2 = ((FIRST_STRING_P (regstart[regno])
+ == FIRST_STRING_P (regend[regno]))
+ ? regend[regno] : end_match_1);
+ for (;;)
+ {
+ /* If necessary, advance to next segment in register
+ contents. */
+ while (d2 == dend2)
+ {
+ if (dend2 == end_match_2) break;
+ if (dend2 == regend[regno]) break;
+
+ /* End of string1 => advance to string2. */
+ d2 = string2;
+ dend2 = regend[regno];
+ }
+ /* At end of register contents => success */
+ if (d2 == dend2) break;
+
+ /* If necessary, advance to next segment in data. */
+ PREFETCH ();
+
+ /* How many characters left in this segment to match. */
+ mcnt = dend - d;
+
+ /* Want how many consecutive characters we can match in
+ one shot, so, if necessary, adjust the count. */
+ if (mcnt > dend2 - d2)
+ mcnt = dend2 - d2;
+
+ /* Compare that many; failure if mismatch, else move
+ past them. */
+ if (translate
+ ? bcmp_translate (d, d2, mcnt, translate)
+ : bcmp (d, d2, mcnt))
+ goto fail;
+ d += mcnt, d2 += mcnt;
+ }
+ }
+ break;
+
+
+ /* begline matches the empty string at the beginning of the string
+ (unless `not_bol' is set in `bufp'), and, if
+ `newline_anchor' is set, after newlines. */
+ case begline:
+ DEBUG_PRINT1 ("EXECUTING begline.\n");
+
+ if (AT_STRINGS_BEG (d))
+ {
+ if (!bufp->not_bol) break;
+ }
+ else if (d[-1] == '\n' && bufp->newline_anchor)
+ {
+ break;
+ }
+ /* In all other cases, we fail. */
+ goto fail;
+
+
+ /* endline is the dual of begline. */
+ case endline:
+ DEBUG_PRINT1 ("EXECUTING endline.\n");
+
+ if (AT_STRINGS_END (d))
+ {
+ if (!bufp->not_eol) break;
+ }
+
+ /* We have to ``prefetch'' the next character. */
+ else if ((d == end1 ? *string2 : *d) == '\n'
+ && bufp->newline_anchor)
+ {
+ break;
+ }
+ goto fail;
+
+
+ /* Match at the very beginning of the data. */
+ case begbuf:
+ DEBUG_PRINT1 ("EXECUTING begbuf.\n");
+ if (AT_STRINGS_BEG (d))
+ break;
+ goto fail;
+
+
+ /* Match at the very end of the data. */
+ case endbuf:
+ DEBUG_PRINT1 ("EXECUTING endbuf.\n");
+ if (AT_STRINGS_END (d))
+ break;
+ goto fail;
+
+
+ /* on_failure_keep_string_jump is used to optimize `.*\n'. It
+ pushes NULL as the value for the string on the stack. Then
+ `pop_failure_point' will keep the current value for the
+ string, instead of restoring it. To see why, consider
+ matching `foo\nbar' against `.*\n'. The .* matches the foo;
+ then the . fails against the \n. But the next thing we want
+ to do is match the \n against the \n; if we restored the
+ string value, we would be back at the foo.
+
+ Because this is used only in specific cases, we don't need to
+ check all the things that `on_failure_jump' does, to make
+ sure the right things get saved on the stack. Hence we don't
+ share its code. The only reason to push anything on the
+ stack at all is that otherwise we would have to change
+ `anychar's code to do something besides goto fail in this
+ case; that seems worse than this. */
+ case on_failure_keep_string_jump:
+ DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
+
+ PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
+ break;
+
+
+ /* Uses of on_failure_jump:
+
+ Each alternative starts with an on_failure_jump that points
+ to the beginning of the next alternative. Each alternative
+ except the last ends with a jump that in effect jumps past
+ the rest of the alternatives. (They really jump to the
+ ending jump of the following alternative, because tensioning
+ these jumps is a hassle.)
+
+ Repeats start with an on_failure_jump that points past both
+ the repetition text and either the following jump or
+ pop_failure_jump back to this on_failure_jump. */
+ case on_failure_jump:
+ on_failure:
+ DEBUG_PRINT1 ("EXECUTING on_failure_jump");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
+
+ /* If this on_failure_jump comes right before a group (i.e.,
+ the original * applied to a group), save the information
+ for that group and all inner ones, so that if we fail back
+ to this point, the group's information will be correct.
+ For example, in \(a*\)*\1, we need the preceding group,
+ and in \(\(a*\)b*\)\2, we need the inner group. */
+
+ /* We can't use `p' to check ahead because we push
+ a failure point to `p + mcnt' after we do this. */
+ p1 = p;
+
+ /* We need to skip no_op's before we look for the
+ start_memory in case this on_failure_jump is happening as
+ the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
+ against aba. */
+ while (p1 < pend && (re_opcode_t) *p1 == no_op)
+ p1++;
+
+ if (p1 < pend && (re_opcode_t) *p1 == start_memory)
+ {
+ /* We have a new highest active register now. This will
+ get reset at the start_memory we are about to get to,
+ but we will have saved all the registers relevant to
+ this repetition op, as described above. */
+ highest_active_reg = *(p1 + 1) + *(p1 + 2);
+ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+ lowest_active_reg = *(p1 + 1);
+ }
+
+ DEBUG_PRINT1 (":\n");
+ PUSH_FAILURE_POINT (p + mcnt, d, -2);
+ break;
+
+
+ /* A smart repeat ends with `maybe_pop_jump'.
+ We change it to either `pop_failure_jump' or `jump'. */
+ case maybe_pop_jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
+ {
+ register unsigned char *p2 = p;
+
+ /* Compare the beginning of the repeat with what in the
+ pattern follows its end. If we can establish that there
+ is nothing that they would both match, i.e., that we
+ would have to backtrack because of (as in, e.g., `a*a')
+ then we can change to pop_failure_jump, because we'll
+ never have to backtrack.
+
+ This is not true in the case of alternatives: in
+ `(a|ab)*' we do need to backtrack to the `ab' alternative
+ (e.g., if the string was `ab'). But instead of trying to
+ detect that here, the alternative has put on a dummy
+ failure point which is what we will end up popping. */
+
+ /* Skip over open/close-group commands. */
+ while (p2 + 2 < pend
+ && ((re_opcode_t) *p2 == stop_memory
+ || (re_opcode_t) *p2 == start_memory))
+ p2 += 3; /* Skip over args, too. */
+
+ /* If we're at the end of the pattern, we can change. */
+ if (p2 == pend)
+ {
+ /* Consider what happens when matching ":\(.*\)"
+ against ":/". I don't really understand this code
+ yet. */
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1
+ (" End of pattern: change to `pop_failure_jump'.\n");
+ }
+
+ else if ((re_opcode_t) *p2 == exactn
+ || (bufp->newline_anchor && (re_opcode_t) *p2 == endline))
+ {
+ register unsigned char c
+ = *p2 == (unsigned char) endline ? '\n' : p2[2];
+ p1 = p + mcnt;
+
+ /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
+ to the `maybe_finalize_jump' of this case. Examine what
+ follows. */
+ if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
+ c, p1[5]);
+ }
+
+ else if ((re_opcode_t) p1[3] == charset
+ || (re_opcode_t) p1[3] == charset_not)
+ {
+ int not = (re_opcode_t) p1[3] == charset_not;
+
+ if (c < (unsigned char) (p1[4] * BYTEWIDTH)
+ && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+ not = !not;
+
+ /* `not' is equal to 1 if c would match, which means
+ that we can't change to pop_failure_jump. */
+ if (!not)
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
+ }
+ }
+ }
+ }
+ p -= 2; /* Point at relative address again. */
+ if ((re_opcode_t) p[-1] != pop_failure_jump)
+ {
+ p[-1] = (unsigned char) jump;
+ DEBUG_PRINT1 (" Match => jump.\n");
+ goto unconditional_jump;
+ }
+ /* Note fall through. */
+
+
+ /* The end of a simple repeat has a pop_failure_jump back to
+ its matching on_failure_jump, where the latter will push a
+ failure point. The pop_failure_jump takes off failure
+ points put on by this pop_failure_jump's matching
+ on_failure_jump; we got through the pattern to here from the
+ matching on_failure_jump, so didn't fail. */
+ case pop_failure_jump:
+ {
+ /* We need to pass separate storage for the lowest and
+ highest registers, even though we don't care about the
+ actual values. Otherwise, we will restore only one
+ register from the stack, since lowest will == highest in
+ `pop_failure_point'. */
+ unsigned dummy_low_reg, dummy_high_reg;
+ unsigned char *pdummy;
+ const char *sdummy;
+
+ DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
+ POP_FAILURE_POINT (sdummy, pdummy,
+ dummy_low_reg, dummy_high_reg,
+ reg_dummy, reg_dummy, reg_info_dummy);
+ }
+ /* Note fall through. */
+
+
+ /* Unconditionally jump (without popping any failure points). */
+ case jump:
+ unconditional_jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
+ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
+ p += mcnt; /* Do the jump. */
+ DEBUG_PRINT2 ("(to 0x%x).\n", p);
+ break;
+
+
+ /* We need this opcode so we can detect where alternatives end
+ in `group_match_null_string_p' et al. */
+ case jump_past_alt:
+ DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
+ goto unconditional_jump;
+
+
+ /* Normally, the on_failure_jump pushes a failure point, which
+ then gets popped at pop_failure_jump. We will end up at
+ pop_failure_jump, also, and with a pattern of, say, `a+', we
+ are skipping over the on_failure_jump, so we have to push
+ something meaningless for pop_failure_jump to pop. */
+ case dummy_failure_jump:
+ DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
+ /* It doesn't matter what we push for the string here. What
+ the code at `fail' tests is the value for the pattern. */
+ PUSH_FAILURE_POINT (0, 0, -2);
+ goto unconditional_jump;
+
+
+ /* At the end of an alternative, we need to push a dummy failure
+ point in case we are followed by a `pop_failure_jump', because
+ we don't want the failure point for the alternative to be
+ popped. For example, matching `(a|ab)*' against `aab'
+ requires that we match the `ab' alternative. */
+ case push_dummy_failure:
+ DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
+ /* See comments just above at `dummy_failure_jump' about the
+ two zeroes. */
+ PUSH_FAILURE_POINT (0, 0, -2);
+ break;
+
+ /* Have to succeed matching what follows at least n times.
+ After that, handle like `on_failure_jump'. */
+ case succeed_n:
+ EXTRACT_NUMBER (mcnt, p + 2);
+ DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
+
+ assert (mcnt >= 0);
+ /* Originally, this is how many times we HAVE to succeed. */
+ if (mcnt > 0)
+ {
+ mcnt--;
+ p += 2;
+ STORE_NUMBER_AND_INCR (p, mcnt);
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p, mcnt);
+ }
+ else if (mcnt == 0)
+ {
+ DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n", p+2);
+ p[2] = (unsigned char) no_op;
+ p[3] = (unsigned char) no_op;
+ goto on_failure;
+ }
+ break;
+
+ case jump_n:
+ EXTRACT_NUMBER (mcnt, p + 2);
+ DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
+
+ /* Originally, this is how many times we CAN jump. */
+ if (mcnt)
+ {
+ mcnt--;
+ STORE_NUMBER (p + 2, mcnt);
+ goto unconditional_jump;
+ }
+ /* If don't have to jump any more, skip over the rest of command. */
+ else
+ p += 4;
+ break;
+
+ case set_number_at:
+ {
+ DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ p1 = p + mcnt;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt);
+ STORE_NUMBER (p1, mcnt);
+ break;
+ }
+
+ case wordbound:
+ DEBUG_PRINT1 ("EXECUTING wordbound.\n");
+ if (AT_WORD_BOUNDARY (d))
+ break;
+ goto fail;
+
+ case notwordbound:
+ DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
+ if (AT_WORD_BOUNDARY (d))
+ goto fail;
+ break;
+
+ case wordbeg:
+ DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
+ if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
+ break;
+ goto fail;
+
+ case wordend:
+ DEBUG_PRINT1 ("EXECUTING wordend.\n");
+ if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
+ && (!WORDCHAR_P (d) || AT_STRINGS_END (d)))
+ break;
+ goto fail;
+
+#ifdef emacs
+#ifdef emacs19
+ case before_dot:
+ DEBUG_PRINT1 ("EXECUTING before_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) >= point)
+ goto fail;
+ break;
+
+ case at_dot:
+ DEBUG_PRINT1 ("EXECUTING at_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) != point)
+ goto fail;
+ break;
+
+ case after_dot:
+ DEBUG_PRINT1 ("EXECUTING after_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) <= point)
+ goto fail;
+ break;
+#else /* not emacs19 */
+ case at_dot:
+ DEBUG_PRINT1 ("EXECUTING at_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point)
+ goto fail;
+ break;
+#endif /* not emacs19 */
+
+ case syntaxspec:
+ DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
+ mcnt = *p++;
+ goto matchsyntax;
+
+ case wordchar:
+ DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
+ mcnt = (int) Sword;
+ matchsyntax:
+ PREFETCH ();
+ if (SYNTAX (*d++) != (enum syntaxcode) mcnt)
+ goto fail;
+ SET_REGS_MATCHED ();
+ break;
+
+ case notsyntaxspec:
+ DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
+ mcnt = *p++;
+ goto matchnotsyntax;
+
+ case notwordchar:
+ DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
+ mcnt = (int) Sword;
+ matchnotsyntax:
+ PREFETCH ();
+ if (SYNTAX (*d++) == (enum syntaxcode) mcnt)
+ goto fail;
+ SET_REGS_MATCHED ();
+ break;
+
+#else /* not emacs */
+ case wordchar:
+ DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
+ PREFETCH ();
+ if (!WORDCHAR_P (d))
+ goto fail;
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+
+ case notwordchar:
+ DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
+ PREFETCH ();
+ if (WORDCHAR_P (d))
+ goto fail;
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+#endif /* not emacs */
+
+ default:
+ abort ();
+ }
+ continue; /* Successfully executed one pattern command; keep going. */
+
+
+ /* We goto here if a matching operation fails. */
+ fail:
+ if (!FAIL_STACK_EMPTY ())
+ { /* A restart point is known. Restore to that state. */
+ DEBUG_PRINT1 ("\nFAIL:\n");
+ POP_FAILURE_POINT (d, p,
+ lowest_active_reg, highest_active_reg,
+ regstart, regend, reg_info);
+
+ /* If this failure point is a dummy, try the next one. */
+ if (!p)
+ goto fail;
+
+ /* If we failed to the end of the pattern, don't examine *p. */
+ assert (p <= pend);
+ if (p < pend)
+ {
+ boolean is_a_jump_n = false;
+
+ /* If failed to a backwards jump that's part of a repetition
+ loop, need to pop this failure point and use the next one. */
+ switch ((re_opcode_t) *p)
+ {
+ case jump_n:
+ is_a_jump_n = true;
+ case maybe_pop_jump:
+ case pop_failure_jump:
+ case jump:
+ p1 = p + 1;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+
+ if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
+ || (!is_a_jump_n
+ && (re_opcode_t) *p1 == on_failure_jump))
+ goto fail;
+ break;
+ default:
+ /* do nothing */ ;
+ }
+ }
+
+ if (d >= string1 && d <= end1)
+ dend = end_match_1;
+ }
+ else
+ break; /* Matching at this starting point really fails. */
+ } /* for (;;) */
+
+ if (best_regs_set)
+ goto restore_best_regs;
+
+ FREE_VARIABLES ();
+
+ return -1; /* Failure to match. */
+} /* re_match_2 */
+
+/* Subroutine definitions for re_match_2. */
+
+
+/* We are passed P pointing to a register number after a start_memory.
+
+ Return true if the pattern up to the corresponding stop_memory can
+ match the empty string, and false otherwise.
+
+ If we find the matching stop_memory, sets P to point to one past its number.
+ Otherwise, sets P to an undefined byte less than or equal to END.
+
+ We don't handle duplicates properly (yet). */
+
+static boolean
+group_match_null_string_p (p, end, reg_info)
+ unsigned char **p, *end;
+ register_info_type *reg_info;
+{
+ int mcnt;
+ /* Point to after the args to the start_memory. */
+ unsigned char *p1 = *p + 2;
+
+ while (p1 < end)
+ {
+ /* Skip over opcodes that can match nothing, and return true or
+ false, as appropriate, when we get to one that can't, or to the
+ matching stop_memory. */
+
+ switch ((re_opcode_t) *p1)
+ {
+ /* Could be either a loop or a series of alternatives. */
+ case on_failure_jump:
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+
+ /* If the next operation is not a jump backwards in the
+ pattern. */
+
+ if (mcnt >= 0)
+ {
+ /* Go through the on_failure_jumps of the alternatives,
+ seeing if any of the alternatives cannot match nothing.
+ The last alternative starts with only a jump,
+ whereas the rest start with on_failure_jump and end
+ with a jump, e.g., here is the pattern for `a|b|c':
+
+ /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
+ /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
+ /exactn/1/c
+
+ So, we have to first go through the first (n-1)
+ alternatives and then deal with the last one separately. */
+
+
+ /* Deal with the first (n-1) alternatives, which start
+ with an on_failure_jump (see above) that jumps to right
+ past a jump_past_alt. */
+
+ while ((re_opcode_t) p1[mcnt-3] == jump_past_alt)
+ {
+ /* `mcnt' holds how many bytes long the alternative
+ is, including the ending `jump_past_alt' and
+ its number. */
+
+ if (!alt_match_null_string_p (p1, p1 + mcnt - 3,
+ reg_info))
+ return false;
+
+ /* Move to right after this alternative, including the
+ jump_past_alt. */
+ p1 += mcnt;
+
+ /* Break if it's the beginning of an n-th alternative
+ that doesn't begin with an on_failure_jump. */
+ if ((re_opcode_t) *p1 != on_failure_jump)
+ break;
+
+ /* Still have to check that it's not an n-th
+ alternative that starts with an on_failure_jump. */
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if ((re_opcode_t) p1[mcnt-3] != jump_past_alt)
+ {
+ /* Get to the beginning of the n-th alternative. */
+ p1 -= 3;
+ break;
+ }
+ }
+
+ /* Deal with the last alternative: go back and get number
+ of the `jump_past_alt' just before it. `mcnt' contains
+ the length of the alternative. */
+ EXTRACT_NUMBER (mcnt, p1 - 2);
+
+ if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info))
+ return false;
+
+ p1 += mcnt; /* Get past the n-th alternative. */
+ } /* if mcnt > 0 */
+ break;
+
+
+ case stop_memory:
+ assert (p1[1] == **p);
+ *p = p1 + 2;
+ return true;
+
+
+ default:
+ if (!common_op_match_null_string_p (&p1, end, reg_info))
+ return false;
+ }
+ } /* while p1 < end */
+
+ return false;
+} /* group_match_null_string_p */
+
+
+/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
+ It expects P to be the first byte of a single alternative and END one
+ byte past the last. The alternative can contain groups. */
+
+static boolean
+alt_match_null_string_p (p, end, reg_info)
+ unsigned char *p, *end;
+ register_info_type *reg_info;
+{
+ int mcnt;
+ unsigned char *p1 = p;
+
+ while (p1 < end)
+ {
+ /* Skip over opcodes that can match nothing, and break when we get
+ to one that can't. */
+
+ switch ((re_opcode_t) *p1)
+ {
+ /* It's a loop. */
+ case on_failure_jump:
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+ break;
+
+ default:
+ if (!common_op_match_null_string_p (&p1, end, reg_info))
+ return false;
+ }
+ } /* while p1 < end */
+
+ return true;
+} /* alt_match_null_string_p */
+
+
+/* Deals with the ops common to group_match_null_string_p and
+ alt_match_null_string_p.
+
+ Sets P to one after the op and its arguments, if any. */
+
+static boolean
+common_op_match_null_string_p (p, end, reg_info)
+ unsigned char **p, *end;
+ register_info_type *reg_info;
+{
+ int mcnt;
+ boolean ret;
+ int reg_no;
+ unsigned char *p1 = *p;
+
+ switch ((re_opcode_t) *p1++)
+ {
+ case no_op:
+ case begline:
+ case endline:
+ case begbuf:
+ case endbuf:
+ case wordbeg:
+ case wordend:
+ case wordbound:
+ case notwordbound:
+#ifdef emacs
+ case before_dot:
+ case at_dot:
+ case after_dot:
+#endif
+ break;
+
+ case start_memory:
+ reg_no = *p1;
+ assert (reg_no > 0 && reg_no <= MAX_REGNUM);
+ ret = group_match_null_string_p (&p1, end, reg_info);
+
+ /* Have to set this here in case we're checking a group which
+ contains a group and a back reference to it. */
+
+ if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
+ REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;
+
+ if (!ret)
+ return false;
+ break;
+
+ /* If this is an optimized succeed_n for zero times, make the jump. */
+ case jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if (mcnt >= 0)
+ p1 += mcnt;
+ else
+ return false;
+ break;
+
+ case succeed_n:
+ /* Get to the number of times to succeed. */
+ p1 += 2;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+
+ if (mcnt == 0)
+ {
+ p1 -= 4;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+ }
+ else
+ return false;
+ break;
+
+ case duplicate:
+ if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
+ return false;
+ break;
+
+ case set_number_at:
+ p1 += 4;
+
+ default:
+ /* All other opcodes mean we cannot match the empty string. */
+ return false;
+ }
+
+ *p = p1;
+ return true;
+} /* common_op_match_null_string_p */
+
+
+/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
+ bytes; nonzero otherwise. */
+
+static int
+bcmp_translate(
+ unsigned char *s1,
+ unsigned char *s2,
+ int len,
+ char *translate
+)
+{
+ register unsigned char *p1 = s1, *p2 = s2;
+ while (len)
+ {
+ if (translate[*p1++] != translate[*p2++]) return 1;
+ len--;
+ }
+ return 0;
+}
+
+/* Entry points for GNU code. */
+
+/* re_compile_pattern is the GNU regular expression compiler: it
+ compiles PATTERN (of length SIZE) and puts the result in BUFP.
+ Returns 0 if the pattern was valid, otherwise an error string.
+
+ Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+ are set in BUFP on entry.
+
+ We call regex_compile to do the actual compilation. */
+
+const char *
+re_compile_pattern (pattern, length, bufp)
+ const char *pattern;
+ int length;
+ struct re_pattern_buffer *bufp;
+{
+ reg_errcode_t ret;
+
+ /* GNU code is written to assume at least RE_NREGS registers will be set
+ (and at least one extra will be -1). */
+ bufp->regs_allocated = REGS_UNALLOCATED;
+
+ /* And GNU code determines whether or not to get register information
+ by passing null for the REGS argument to re_match, etc., not by
+ setting no_sub. */
+ bufp->no_sub = 0;
+
+ /* Match anchors at newline. */
+ bufp->newline_anchor = 1;
+
+ ret = regex_compile (pattern, length, re_syntax_options, bufp);
+
+ return re_error_msg[(int) ret];
+}
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them if this is an Emacs or POSIX compilation. */
+
+#if !defined (emacs) && !defined (_POSIX_SOURCE)
+
+/* BSD has one and only one pattern buffer. */
+static struct re_pattern_buffer re_comp_buf;
+
+char *
+re_comp (s)
+ const char *s;
+{
+ reg_errcode_t ret;
+
+ if (!s)
+ {
+ if (!re_comp_buf.buffer)
+ return "No previous regular expression";
+ return 0;
+ }
+
+ if (!re_comp_buf.buffer)
+ {
+ re_comp_buf.buffer = (unsigned char *) malloc (200);
+ if (re_comp_buf.buffer == NULL)
+ return "Memory exhausted";
+ re_comp_buf.allocated = 200;
+
+ re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
+ if (re_comp_buf.fastmap == NULL)
+ return "Memory exhausted";
+ }
+
+ /* Since `re_exec' always passes NULL for the `regs' argument, we
+ don't need to initialize the pattern buffer fields which affect it. */
+
+ /* Match anchors at newlines. */
+ re_comp_buf.newline_anchor = 1;
+
+ ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
+
+ /* Yes, we're discarding `const' here. */
+ return (char *) re_error_msg[(int) ret];
+}
+
+
+int
+re_exec (s)
+ const char *s;
+{
+ const int len = strlen (s);
+ return
+ 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
+}
+#endif /* not emacs and not _POSIX_SOURCE */
+
+/* POSIX.2 functions. Don't define these for Emacs. */
+
+#ifndef emacs
+
+/* regcomp takes a regular expression as a string and compiles it.
+
+ PREG is a regex_t *. We do not expect any fields to be initialized,
+ since POSIX says we shouldn't. Thus, we set
+
+ `buffer' to the compiled pattern;
+ `used' to the length of the compiled pattern;
+ `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+ REG_EXTENDED bit in CFLAGS is set; otherwise, to
+ RE_SYNTAX_POSIX_BASIC;
+ `newline_anchor' to REG_NEWLINE being set in CFLAGS;
+ `fastmap' and `fastmap_accurate' to zero;
+ `re_nsub' to the number of subexpressions in PATTERN.
+
+ PATTERN is the address of the pattern string.
+
+ CFLAGS is a series of bits which affect compilation.
+
+ If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
+ use POSIX basic syntax.
+
+ If REG_NEWLINE is set, then . and [^...] don't match newline.
+ Also, regexec will try a match beginning after every newline.
+
+ If REG_ICASE is set, then we considers upper- and lowercase
+ versions of letters to be equivalent when matching.
+
+ If REG_NOSUB is set, then when PREG is passed to regexec, that
+ routine will report only success or failure, and nothing about the
+ registers.
+
+ It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
+ the return codes and their meanings.) */
+
+int
+regcomp (preg, pattern, cflags)
+ regex_t *preg;
+ const char *pattern;
+ int cflags;
+{
+ reg_errcode_t ret;
+ unsigned syntax
+ = (cflags & REG_EXTENDED) ?
+ RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
+
+ /* regex_compile will allocate the space for the compiled pattern. */
+ preg->buffer = 0;
+ preg->allocated = 0;
+
+ /* Don't bother to use a fastmap when searching. This simplifies the
+ REG_NEWLINE case: if we used a fastmap, we'd have to put all the
+ characters after newlines into the fastmap. This way, we just try
+ every character. */
+ preg->fastmap = 0;
+
+ if (cflags & REG_ICASE)
+ {
+ unsigned i;
+
+ preg->translate = (char *) malloc (CHAR_SET_SIZE);
+ if (preg->translate == NULL)
+ return (int) REG_ESPACE;
+
+ /* Map uppercase characters to corresponding lowercase ones. */
+ for (i = 0; i < CHAR_SET_SIZE; i++)
+ preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
+ }
+ else
+ preg->translate = NULL;
+
+ /* If REG_NEWLINE is set, newlines are treated differently. */
+ if (cflags & REG_NEWLINE)
+ { /* REG_NEWLINE implies neither . nor [^...] match newline. */
+ syntax &= ~RE_DOT_NEWLINE;
+ syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+ /* It also changes the matching behavior. */
+ preg->newline_anchor = 1;
+ }
+ else
+ preg->newline_anchor = 0;
+
+ preg->no_sub = !!(cflags & REG_NOSUB);
+
+ /* POSIX says a null character in the pattern terminates it, so we
+ can use strlen here in compiling the pattern. */
+ ret = regex_compile (pattern, strlen (pattern), syntax, preg);
+
+ /* POSIX doesn't distinguish between an unmatched open-group and an
+ unmatched close-group: both are REG_EPAREN. */
+ if (ret == REG_ERPAREN) ret = REG_EPAREN;
+
+ return (int) ret;
+}
+
+
+/* regexec searches for a given pattern, specified by PREG, in the
+ string STRING.
+
+ If NMATCH is zero or REG_NOSUB was set in the cflags argument to
+ `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
+ least NMATCH elements, and we set them to the offsets of the
+ corresponding matched substrings.
+
+ EFLAGS specifies `execution flags' which affect matching: if
+ REG_NOTBOL is set, then ^ does not match at the beginning of the
+ string; if REG_NOTEOL is set, then $ does not match at the end.
+
+ We return 0 if we find a match and REG_NOMATCH if not. */
+
+int
+regexec (preg, string, nmatch, pmatch, eflags)
+ const regex_t *preg;
+ const char *string;
+ size_t nmatch;
+ regmatch_t pmatch[];
+ int eflags;
+{
+ int ret;
+ struct re_registers regs;
+ regex_t private_preg;
+ int len = strlen (string);
+ boolean want_reg_info = !preg->no_sub && nmatch > 0;
+
+ private_preg = *preg;
+
+ private_preg.not_bol = !!(eflags & REG_NOTBOL);
+ private_preg.not_eol = !!(eflags & REG_NOTEOL);
+
+ /* The user has told us exactly how many registers to return
+ information about, via `nmatch'. We have to pass that on to the
+ matching routines. */
+ private_preg.regs_allocated = REGS_FIXED;
+
+ if (want_reg_info)
+ {
+ regs.num_regs = nmatch;
+ regs.start = TALLOC (nmatch, regoff_t);
+ regs.end = TALLOC (nmatch, regoff_t);
+ if (regs.start == NULL || regs.end == NULL)
+ return (int) REG_NOMATCH;
+ }
+
+ /* Perform the searching operation. */
+ ret = re_search (&private_preg, string, len,
+ /* start: */ 0, /* range: */ len,
+ want_reg_info ? &regs : (struct re_registers *) 0);
+
+ /* Copy the register information to the POSIX structure. */
+ if (want_reg_info)
+ {
+ if (ret >= 0)
+ {
+ unsigned r;
+
+ for (r = 0; r < nmatch; r++)
+ {
+ pmatch[r].rm_so = regs.start[r];
+ pmatch[r].rm_eo = regs.end[r];
+ }
+ }
+
+ /* If we needed the temporary register info, free the space now. */
+ free (regs.start);
+ free (regs.end);
+ }
+
+ /* We want zero return to mean success, unlike `re_search'. */
+ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
+}
+
+
+/* Returns a message corresponding to an error code, ERRCODE, returned
+ from either regcomp or regexec. We don't use PREG here. */
+
+size_t
+regerror (errcode, preg, errbuf, errbuf_size)
+ int errcode;
+ const regex_t *preg;
+ char *errbuf;
+ size_t errbuf_size;
+{
+ const char *msg;
+ size_t msg_size;
+
+ if (errcode < 0
+ || errcode >= (sizeof (re_error_msg) / sizeof (re_error_msg[0])))
+ /* Only error codes returned by the rest of the code should be passed
+ to this routine. If we are given anything else, or if other regex
+ code generates an invalid error code, then the program has a bug.
+ Dump core so we can fix it. */
+ abort ();
+
+ msg = re_error_msg[errcode];
+
+ /* POSIX doesn't require that we do anything in this case, but why
+ not be nice. */
+ if (! msg)
+ msg = "Success";
+
+ msg_size = strlen (msg) + 1; /* Includes the null. */
+
+ if (errbuf_size != 0)
+ {
+ if (msg_size > errbuf_size)
+ {
+ strncpy (errbuf, msg, errbuf_size - 1);
+ errbuf[errbuf_size - 1] = 0;
+ }
+ else
+ strcpy (errbuf, msg);
+ }
+
+ return msg_size;
+}
+
+
+/* Free dynamically allocated space used by PREG. */
+
+void
+regfree (preg)
+ regex_t *preg;
+{
+ if (preg->buffer != NULL)
+ free (preg->buffer);
+ preg->buffer = NULL;
+
+ preg->allocated = 0;
+ preg->used = 0;
+
+ if (preg->fastmap != NULL)
+ free (preg->fastmap);
+ preg->fastmap = NULL;
+ preg->fastmap_accurate = 0;
+
+ if (preg->translate != NULL)
+ free (preg->translate);
+ preg->translate = NULL;
+}
+
+#endif /* not emacs */
+
+/*
+Local variables:
+make-backup-files: t
+version-control: t
+trim-versions-without-asking: nil
+End:
+*/
diff --git a/compat/regex.h b/compat/regex.h
new file mode 100644
index 000000000..6eb64f140
--- /dev/null
+++ b/compat/regex.h
@@ -0,0 +1,490 @@
+/* Definitions for data structures and routines for the regular
+ expression library, version 0.12.
+
+ Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef __REGEXP_LIBRARY_H__
+#define __REGEXP_LIBRARY_H__
+
+/* POSIX says that <sys/types.h> must be included (by the caller) before
+ <regex.h>. */
+
+#ifdef VMS
+/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
+ should be there. */
+#include <stddef.h>
+#endif
+
+
+/* The following bits are used to determine the regexp syntax we
+ recognize. The set/not-set meanings are chosen so that Emacs syntax
+ remains the value 0. The bits are given in alphabetical order, and
+ the definitions shifted by one from the previous bit; thus, when we
+ add or remove a bit, only one other definition need change. */
+typedef unsigned reg_syntax_t;
+
+/* If this bit is not set, then \ inside a bracket expression is literal.
+ If set, then such a \ quotes the following character. */
+#define RE_BACKSLASH_ESCAPE_IN_LISTS (1)
+
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+ literals.
+ If set, then \+ and \? are operators and + and ? are literals. */
+#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+
+/* If this bit is set, then character classes are supported. They are:
+ [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
+ [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+ If not set, then character classes are not supported. */
+#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+ expressions, of course).
+ If this bit is not set, then it depends:
+ ^ is an anchor if it is at the beginning of a regular
+ expression or after an open-group or an alternation operator;
+ $ is an anchor if it is at the end of a regular expression, or
+ before a close-group or an alternation operator.
+
+ This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+ POSIX draft 11.2 says that * etc. in leading positions is undefined.
+ We already implemented a previous draft which made those constructs
+ invalid, though, so we haven't changed the code back. */
+#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+
+/* If this bit is set, then special characters are always special
+ regardless of where they are in the pattern.
+ If this bit is not set, then special characters are special only in
+ some contexts; otherwise they are ordinary. Specifically,
+ * + ? and intervals are only special when not after the beginning,
+ open-group, or alternation operator. */
+#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+ immediately after an alternation or begin-group operator. */
+#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+
+/* If this bit is set, then . matches newline.
+ If not set, then it doesn't. */
+#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+
+/* If this bit is set, then . doesn't match NUL.
+ If not set, then it does. */
+#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+ If not set, they do. */
+#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+
+/* If this bit is set, either \{...\} or {...} defines an
+ interval, depending on RE_NO_BK_BRACES.
+ If not set, \{, \}, {, and } are literals. */
+#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
+/* If this bit is set, +, ? and | aren't recognized as operators.
+ If not set, they are. */
+#define RE_LIMITED_OPS (RE_INTERVALS << 1)
+
+/* If this bit is set, newline is an alternation operator.
+ If not set, newline is literal. */
+#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+
+/* If this bit is set, then `{...}' defines an interval, and \{ and \}
+ are literals.
+ If not set, then `\{...\}' defines an interval. */
+#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+ If not set, \(...\) defines a group, and ( and ) are literals. */
+#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+
+/* If this bit is set, then \<digit> matches <digit>.
+ If not set, then \<digit> is a back-reference. */
+#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+ If not set, then \| is an alternation operator, and | is literal. */
+#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+
+/* If this bit is set, then an ending range point collating higher
+ than the starting range point, as in [z-a], is invalid.
+ If not set, then when ending range point collates higher than the
+ starting range point, the range is ignored. */
+#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+
+/* If this bit is set, then an unmatched ) is ordinary.
+ If not set, then an unmatched ) is invalid. */
+#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+
+/* This global variable defines the particular regexp syntax to use (for
+ some interfaces). When a regexp is compiled, the syntax used is
+ stored in the pattern buffer, so changing this does not affect
+ already-compiled regexps. */
+extern reg_syntax_t re_syntax_options;
+
+/* Define combinations of the above bits for the standard possibilities.
+ (The [[[ comments delimit what gets put into the Texinfo file, so
+ don't delete them!) */
+/* [[[begin syntaxes]]] */
+#define RE_SYNTAX_EMACS 0
+
+#define RE_SYNTAX_AWK \
+ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
+ | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+#define RE_SYNTAX_POSIX_AWK \
+ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS)
+
+#define RE_SYNTAX_GREP \
+ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
+ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
+ | RE_NEWLINE_ALT)
+
+#define RE_SYNTAX_EGREP \
+ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
+ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \
+ | RE_NO_BK_VBAR)
+
+#define RE_SYNTAX_POSIX_EGREP \
+ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES)
+
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
+#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
+
+#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
+
+/* Syntax bits common to both basic and extended POSIX regex syntax. */
+#define _RE_SYNTAX_POSIX_COMMON \
+ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
+ | RE_INTERVALS | RE_NO_EMPTY_RANGES)
+
+#define RE_SYNTAX_POSIX_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
+
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+ RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
+ isn't minimal, since other operators, such as \`, aren't disabled. */
+#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
+ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
+
+#define RE_SYNTAX_POSIX_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \
+ | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS
+ replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */
+#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
+ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
+ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
+ | RE_NO_BK_PARENS | RE_NO_BK_REFS \
+ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+
+/* Maximum number of duplicates an interval can allow. Some systems
+ (erroneously) define this in other header files, but we want our
+ value, so remove any previous define. */
+#ifdef RE_DUP_MAX
+#undef RE_DUP_MAX
+#endif
+#define RE_DUP_MAX ((1 << 15) - 1)
+
+
+/* POSIX `cflags' bits (i.e., information for `regcomp'). */
+
+/* If this bit is set, then use extended regular expression syntax.
+ If not set, then use basic regular expression syntax. */
+#define REG_EXTENDED 1
+
+/* If this bit is set, then ignore case when matching.
+ If not set, then case is significant. */
+#define REG_ICASE (REG_EXTENDED << 1)
+
+/* If this bit is set, then anchors do not match at newline
+ characters in the string.
+ If not set, then anchors do match at newlines. */
+#define REG_NEWLINE (REG_ICASE << 1)
+
+/* If this bit is set, then report only success or fail in regexec.
+ If not set, then returns differ between not matching and errors. */
+#define REG_NOSUB (REG_NEWLINE << 1)
+
+
+/* POSIX `eflags' bits (i.e., information for regexec). */
+
+/* If this bit is set, then the beginning-of-line operator doesn't match
+ the beginning of the string (presumably because it's not the
+ beginning of a line).
+ If not set, then the beginning-of-line operator does match the
+ beginning of the string. */
+#define REG_NOTBOL 1
+
+/* Like REG_NOTBOL, except for the end-of-line. */
+#define REG_NOTEOL (1 << 1)
+
+
+/* If any error codes are removed, changed, or added, update the
+ `re_error_msg' table in regex.c. */
+typedef enum
+{
+ REG_NOERROR = 0, /* Success. */
+ REG_NOMATCH, /* Didn't find a match (for regexec). */
+
+ /* POSIX regcomp return error codes. (In the order listed in the
+ standard.) */
+ REG_BADPAT, /* Invalid pattern. */
+ REG_ECOLLATE, /* Not implemented. */
+ REG_ECTYPE, /* Invalid character class name. */
+ REG_EESCAPE, /* Trailing backslash. */
+ REG_ESUBREG, /* Invalid back reference. */
+ REG_EBRACK, /* Unmatched left bracket. */
+ REG_EPAREN, /* Parenthesis imbalance. */
+ REG_EBRACE, /* Unmatched \{. */
+ REG_BADBR, /* Invalid contents of \{\}. */
+ REG_ERANGE, /* Invalid range end. */
+ REG_ESPACE, /* Ran out of memory. */
+ REG_BADRPT, /* No preceding re for repetition op. */
+
+ /* Error codes we've added. */
+ REG_EEND, /* Premature end. */
+ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
+ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
+} reg_errcode_t;
+
+/* This data structure represents a compiled pattern. Before calling
+ the pattern compiler, the fields `buffer', `allocated', `fastmap',
+ `translate', and `no_sub' can be set. After the pattern has been
+ compiled, the `re_nsub' field is available. All other fields are
+ private to the regex routines. */
+
+struct re_pattern_buffer
+{
+/* [[[begin pattern_buffer]]] */
+ /* Space that holds the compiled pattern. It is declared as
+ `unsigned char *' because its elements are
+ sometimes used as array indexes. */
+ unsigned char *buffer;
+
+ /* Number of bytes to which `buffer' points. */
+ unsigned long allocated;
+
+ /* Number of bytes actually used in `buffer'. */
+ unsigned long used;
+
+ /* Syntax setting with which the pattern was compiled. */
+ reg_syntax_t syntax;
+
+ /* Pointer to a fastmap, if any, otherwise zero. re_search uses
+ the fastmap, if there is one, to skip over impossible
+ starting points for matches. */
+ char *fastmap;
+
+ /* Either a translate table to apply to all characters before
+ comparing them, or zero for no translation. The translation
+ is applied to a pattern when it is compiled and to a string
+ when it is matched. */
+ char *translate;
+
+ /* Number of subexpressions found by the compiler. */
+ size_t re_nsub;
+
+ /* Zero if this pattern cannot match the empty string, one else.
+ Well, in truth it's used only in `re_search_2', to see
+ whether or not we should use the fastmap, so we don't set
+ this absolutely perfectly; see `re_compile_fastmap' (the
+ `duplicate' case). */
+ unsigned can_be_null : 1;
+
+ /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+ for `max (RE_NREGS, re_nsub + 1)' groups.
+ If REGS_REALLOCATE, reallocate space if necessary.
+ If REGS_FIXED, use what's there. */
+#define REGS_UNALLOCATED 0
+#define REGS_REALLOCATE 1
+#define REGS_FIXED 2
+ unsigned regs_allocated : 2;
+
+ /* Set to zero when `regex_compile' compiles a pattern; set to one
+ by `re_compile_fastmap' if it updates the fastmap. */
+ unsigned fastmap_accurate : 1;
+
+ /* If set, `re_match_2' does not return information about
+ subexpressions. */
+ unsigned no_sub : 1;
+
+ /* If set, a beginning-of-line anchor doesn't match at the
+ beginning of the string. */
+ unsigned not_bol : 1;
+
+ /* Similarly for an end-of-line anchor. */
+ unsigned not_eol : 1;
+
+ /* If true, an anchor at a newline matches. */
+ unsigned newline_anchor : 1;
+
+/* [[[end pattern_buffer]]] */
+};
+
+typedef struct re_pattern_buffer regex_t;
+
+
+/* search.c (search_buffer) in Emacs needs this one opcode value. It is
+ defined both in `regex.c' and here. */
+#define RE_EXACTN_VALUE 1
+
+/* Type for byte offsets within the string. POSIX mandates this. */
+typedef int regoff_t;
+
+
+/* This is the structure we store register match data in. See
+ regex.texinfo for a full description of what registers match. */
+struct re_registers
+{
+ unsigned num_regs;
+ regoff_t *start;
+ regoff_t *end;
+};
+
+
+/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+ `re_match_2' returns information about at least this many registers
+ the first time a `regs' structure is passed. */
+#ifndef RE_NREGS
+#define RE_NREGS 30
+#endif
+
+
+/* POSIX specification for registers. Aside from the different names than
+ `re_registers', POSIX uses an array of structures, instead of a
+ structure of arrays. */
+typedef struct
+{
+ regoff_t rm_so; /* Byte offset from string's start to substring's start. */
+ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
+} regmatch_t;
+
+/* Declarations for routines. */
+
+/* To avoid duplicating every routine declaration -- once with a
+ prototype (if we are ANSI), and once without (if we aren't) -- we
+ use the following macro to declare argument types. This
+ unfortunately clutters up the declarations a bit, but I think it's
+ worth it. */
+
+#if __STDC__
+
+#define _RE_ARGS(args) args
+
+#else /* not __STDC__ */
+
+#define _RE_ARGS(args) ()
+
+#endif /* not __STDC__ */
+
+/* Sets the current default syntax to SYNTAX, and return the old syntax.
+ You can also simply assign to the `re_syntax_options' variable. */
+extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
+
+/* Compile the regular expression PATTERN, with length LENGTH
+ and syntax given by the global `re_syntax_options', into the buffer
+ BUFFER. Return NULL if successful, and an error string if not. */
+extern const char *re_compile_pattern
+ _RE_ARGS ((const char *pattern, int length,
+ struct re_pattern_buffer *buffer));
+
+
+/* Compile a fastmap for the compiled pattern in BUFFER; used to
+ accelerate searches. Return 0 if successful and -2 if was an
+ internal error. */
+extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
+
+
+/* Search in the string STRING (with length LENGTH) for the pattern
+ compiled into BUFFER. Start searching at position START, for RANGE
+ characters. Return the starting position of the match, -1 for no
+ match, or -2 for an internal error. Also return register
+ information in REGS (if REGS and BUFFER->no_sub are nonzero). */
+extern int re_search
+ _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
+ int length, int start, int range, struct re_registers *regs));
+
+
+/* Like `re_search', but search in the concatenation of STRING1 and
+ STRING2. Also, stop searching at index START + STOP. */
+extern int re_search_2
+ _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
+ int length1, const char *string2, int length2,
+ int start, int range, struct re_registers *regs, int stop));
+
+
+/* Like `re_search', but return how many characters in STRING the regexp
+ in BUFFER matched, starting at position START. */
+extern int re_match
+ _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
+ int length, int start, struct re_registers *regs));
+
+
+/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
+extern int re_match_2
+ _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
+ int length1, const char *string2, int length2,
+ int start, struct re_registers *regs, int stop));
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using BUFFER and REGS will use this memory
+ for recording register information. STARTS and ENDS must be
+ allocated with malloc, and must each be at least `NUM_REGS * sizeof
+ (regoff_t)' bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+extern void re_set_registers
+ _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
+ unsigned num_regs, regoff_t *starts, regoff_t *ends));
+
+/* 4.2 bsd compatibility. */
+extern char *re_comp _RE_ARGS ((const char *));
+extern int re_exec _RE_ARGS ((const char *));
+
+/* POSIX compatibility. */
+extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags));
+extern int regexec
+ _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags));
+extern size_t regerror
+ _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf,
+ size_t errbuf_size));
+extern void regfree _RE_ARGS ((regex_t *preg));
+
+#endif /* not __REGEXP_LIBRARY_H__ */
+
+/*
+Local variables:
+make-backup-files: t
+version-control: t
+trim-versions-without-asking: nil
+End:
+*/
diff --git a/compat/snprintf.c b/compat/snprintf.c
new file mode 100644
index 000000000..580966e56
--- /dev/null
+++ b/compat/snprintf.c
@@ -0,0 +1,53 @@
+#include "../git-compat-util.h"
+
+/*
+ * The size parameter specifies the available space, i.e. includes
+ * the trailing NUL byte; but Windows's vsnprintf expects the
+ * number of characters to write without the trailing NUL.
+ */
+#ifndef SNPRINTF_SIZE_CORR
+#define SNPRINTF_SIZE_CORR 0
+#endif
+
+#undef vsnprintf
+int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
+{
+ char *s;
+ int ret = -1;
+
+ if (maxsize > 0) {
+ ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap);
+ /* Windows does not NUL-terminate if result fills buffer */
+ str[maxsize-1] = 0;
+ }
+ if (ret != -1)
+ return ret;
+
+ s = NULL;
+ if (maxsize < 128)
+ maxsize = 128;
+
+ while (ret == -1) {
+ maxsize *= 4;
+ str = realloc(s, maxsize);
+ if (! str)
+ break;
+ s = str;
+ ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap);
+ }
+ free(s);
+ return ret;
+}
+
+int git_snprintf(char *str, size_t maxsize, const char *format, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, format);
+ ret = git_vsnprintf(str, maxsize, format, ap);
+ va_end(ap);
+
+ return ret;
+}
+
diff --git a/compat/winansi.c b/compat/winansi.c
new file mode 100644
index 000000000..e2d96dfe6
--- /dev/null
+++ b/compat/winansi.c
@@ -0,0 +1,345 @@
+/*
+ * Copyright 2008 Peter Harris <git@peter.is-a-geek.org>
+ */
+
+#include <windows.h>
+#include "../git-compat-util.h"
+
+/*
+ Functions to be wrapped:
+*/
+#undef printf
+#undef fprintf
+#undef fputs
+/* TODO: write */
+
+/*
+ ANSI codes used by git: m, K
+
+ This file is git-specific. Therefore, this file does not attempt
+ to implement any codes that are not used by git.
+
+ TODO: K
+*/
+
+static HANDLE console;
+static WORD plain_attr;
+static WORD attr;
+static int negative;
+
+static void init(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO sbi;
+
+ static int initialized = 0;
+ if (initialized)
+ return;
+
+ console = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (console == INVALID_HANDLE_VALUE)
+ console = NULL;
+
+ if (!console)
+ return;
+
+ GetConsoleScreenBufferInfo(console, &sbi);
+ attr = plain_attr = sbi.wAttributes;
+ negative = 0;
+
+ initialized = 1;
+}
+
+
+#define FOREGROUND_ALL (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
+#define BACKGROUND_ALL (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
+
+static void set_console_attr(void)
+{
+ WORD attributes = attr;
+ if (negative) {
+ attributes &= ~FOREGROUND_ALL;
+ attributes &= ~BACKGROUND_ALL;
+
+ /* This could probably use a bitmask
+ instead of a series of ifs */
+ if (attr & FOREGROUND_RED)
+ attributes |= BACKGROUND_RED;
+ if (attr & FOREGROUND_GREEN)
+ attributes |= BACKGROUND_GREEN;
+ if (attr & FOREGROUND_BLUE)
+ attributes |= BACKGROUND_BLUE;
+
+ if (attr & BACKGROUND_RED)
+ attributes |= FOREGROUND_RED;
+ if (attr & BACKGROUND_GREEN)
+ attributes |= FOREGROUND_GREEN;
+ if (attr & BACKGROUND_BLUE)
+ attributes |= FOREGROUND_BLUE;
+ }
+ SetConsoleTextAttribute(console, attributes);
+}
+
+static const char *set_attr(const char *str)
+{
+ const char *func;
+ size_t len = strspn(str, "0123456789;");
+ func = str + len;
+
+ switch (*func) {
+ case 'm':
+ do {
+ long val = strtol(str, (char **)&str, 10);
+ switch (val) {
+ case 0: /* reset */
+ attr = plain_attr;
+ negative = 0;
+ break;
+ case 1: /* bold */
+ attr |= FOREGROUND_INTENSITY;
+ break;
+ case 2: /* faint */
+ case 22: /* normal */
+ attr &= ~FOREGROUND_INTENSITY;
+ break;
+ case 3: /* italic */
+ /* Unsupported */
+ break;
+ case 4: /* underline */
+ case 21: /* double underline */
+ /* Wikipedia says this flag does nothing */
+ /* Furthermore, mingw doesn't define this flag
+ attr |= COMMON_LVB_UNDERSCORE; */
+ break;
+ case 24: /* no underline */
+ /* attr &= ~COMMON_LVB_UNDERSCORE; */
+ break;
+ case 5: /* slow blink */
+ case 6: /* fast blink */
+ /* We don't have blink, but we do have
+ background intensity */
+ attr |= BACKGROUND_INTENSITY;
+ break;
+ case 25: /* no blink */
+ attr &= ~BACKGROUND_INTENSITY;
+ break;
+ case 7: /* negative */
+ negative = 1;
+ break;
+ case 27: /* positive */
+ negative = 0;
+ break;
+ case 8: /* conceal */
+ case 28: /* reveal */
+ /* Unsupported */
+ break;
+ case 30: /* Black */
+ attr &= ~FOREGROUND_ALL;
+ break;
+ case 31: /* Red */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_RED;
+ break;
+ case 32: /* Green */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_GREEN;
+ break;
+ case 33: /* Yellow */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_RED | FOREGROUND_GREEN;
+ break;
+ case 34: /* Blue */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_BLUE;
+ break;
+ case 35: /* Magenta */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_RED | FOREGROUND_BLUE;
+ break;
+ case 36: /* Cyan */
+ attr &= ~FOREGROUND_ALL;
+ attr |= FOREGROUND_GREEN | FOREGROUND_BLUE;
+ break;
+ case 37: /* White */
+ attr |= FOREGROUND_RED |
+ FOREGROUND_GREEN |
+ FOREGROUND_BLUE;
+ break;
+ case 38: /* Unknown */
+ break;
+ case 39: /* reset */
+ attr &= ~FOREGROUND_ALL;
+ attr |= (plain_attr & FOREGROUND_ALL);
+ break;
+ case 40: /* Black */
+ attr &= ~BACKGROUND_ALL;
+ break;
+ case 41: /* Red */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_RED;
+ break;
+ case 42: /* Green */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_GREEN;
+ break;
+ case 43: /* Yellow */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_RED | BACKGROUND_GREEN;
+ break;
+ case 44: /* Blue */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_BLUE;
+ break;
+ case 45: /* Magenta */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_RED | BACKGROUND_BLUE;
+ break;
+ case 46: /* Cyan */
+ attr &= ~BACKGROUND_ALL;
+ attr |= BACKGROUND_GREEN | BACKGROUND_BLUE;
+ break;
+ case 47: /* White */
+ attr |= BACKGROUND_RED |
+ BACKGROUND_GREEN |
+ BACKGROUND_BLUE;
+ break;
+ case 48: /* Unknown */
+ break;
+ case 49: /* reset */
+ attr &= ~BACKGROUND_ALL;
+ attr |= (plain_attr & BACKGROUND_ALL);
+ break;
+ default:
+ /* Unsupported code */
+ break;
+ }
+ str++;
+ } while (*(str-1) == ';');
+
+ set_console_attr();
+ break;
+ case 'K':
+ /* TODO */
+ break;
+ default:
+ /* Unsupported code */
+ break;
+ }
+
+ return func + 1;
+}
+
+static int ansi_emulate(const char *str, FILE *stream)
+{
+ int rv = 0;
+ const char *pos = str;
+
+ while (*pos) {
+ pos = strstr(str, "\033[");
+ if (pos) {
+ size_t len = pos - str;
+
+ if (len) {
+ size_t out_len = fwrite(str, 1, len, stream);
+ rv += out_len;
+ if (out_len < len)
+ return rv;
+ }
+
+ str = pos + 2;
+ rv += 2;
+
+ fflush(stream);
+
+ pos = set_attr(str);
+ rv += pos - str;
+ str = pos;
+ } else {
+ rv += strlen(str);
+ fputs(str, stream);
+ return rv;
+ }
+ }
+ return rv;
+}
+
+int winansi_fputs(const char *str, FILE *stream)
+{
+ int rv;
+
+ if (!isatty(fileno(stream)))
+ return fputs(str, stream);
+
+ init();
+
+ if (!console)
+ return fputs(str, stream);
+
+ rv = ansi_emulate(str, stream);
+
+ if (rv >= 0)
+ return 0;
+ else
+ return EOF;
+}
+
+static int winansi_vfprintf(FILE *stream, const char *format, va_list list)
+{
+ int len, rv;
+ char small_buf[256];
+ char *buf = small_buf;
+ va_list cp;
+
+ if (!isatty(fileno(stream)))
+ goto abort;
+
+ init();
+
+ if (!console)
+ goto abort;
+
+ va_copy(cp, list);
+ len = vsnprintf(small_buf, sizeof(small_buf), format, cp);
+ va_end(cp);
+
+ if (len > sizeof(small_buf) - 1) {
+ buf = malloc(len + 1);
+ if (!buf)
+ goto abort;
+
+ len = vsnprintf(buf, len + 1, format, list);
+ }
+
+ rv = ansi_emulate(buf, stream);
+
+ if (buf != small_buf)
+ free(buf);
+ return rv;
+
+abort:
+ rv = vfprintf(stream, format, list);
+ return rv;
+}
+
+int winansi_fprintf(FILE *stream, const char *format, ...)
+{
+ va_list list;
+ int rv;
+
+ va_start(list, format);
+ rv = winansi_vfprintf(stream, format, list);
+ va_end(list);
+
+ return rv;
+}
+
+int winansi_printf(const char *format, ...)
+{
+ va_list list;
+ int rv;
+
+ va_start(list, format);
+ rv = winansi_vfprintf(stdout, format, list);
+ va_end(list);
+
+ return rv;
+}
diff --git a/config.c b/config.c
index 526a3f429..53f04a076 100644
--- a/config.c
+++ b/config.c
@@ -16,6 +16,8 @@ static int config_linenr;
static int config_file_eof;
static int zlib_compression_seen;
+const char *config_exclusive_filename = NULL;
+
static int get_next_char(void)
{
int c;
@@ -111,7 +113,7 @@ static inline int iskeychar(int c)
return isalnum(c) || c == '-';
}
-static int get_value(config_fn_t fn, char *name, unsigned int len)
+static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
{
int c;
char *value;
@@ -139,7 +141,7 @@ static int get_value(config_fn_t fn, char *name, unsigned int len)
if (!value)
return -1;
}
- return fn(name, value);
+ return fn(name, value, data);
}
static int get_extended_base_var(char *name, int baselen, int c)
@@ -197,7 +199,7 @@ static int get_base_var(char *name)
}
}
-static int git_parse_file(config_fn_t fn)
+static int git_parse_file(config_fn_t fn, void *data)
{
int comment = 0;
int baselen = 0;
@@ -228,7 +230,7 @@ static int git_parse_file(config_fn_t fn)
if (!isalpha(c))
break;
var[baselen] = tolower(c);
- if (get_value(fn, var, baselen+1) < 0)
+ if (get_value(fn, data, var, baselen+1) < 0)
break;
}
die("bad config file line %d in %s", config_linenr, config_file_name);
@@ -280,11 +282,18 @@ int git_parse_ulong(const char *value, unsigned long *ret)
return 0;
}
+static void die_bad_config(const char *name)
+{
+ if (config_file_name)
+ die("bad config value for '%s' in %s", name, config_file_name);
+ die("bad config value for '%s'", name);
+}
+
int git_config_int(const char *name, const char *value)
{
long ret;
if (!git_parse_long(value, &ret))
- die("bad config value for '%s' in %s", name, config_file_name);
+ die_bad_config(name);
return ret;
}
@@ -292,12 +301,13 @@ unsigned long git_config_ulong(const char *name, const char *value)
{
unsigned long ret;
if (!git_parse_ulong(value, &ret))
- die("bad config value for '%s' in %s", name, config_file_name);
+ die_bad_config(name);
return ret;
}
-int git_config_bool(const char *name, const char *value)
+int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
{
+ *is_bool = 1;
if (!value)
return 1;
if (!*value)
@@ -306,16 +316,35 @@ int git_config_bool(const char *name, const char *value)
return 1;
if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
return 0;
- return git_config_int(name, value) != 0;
+ *is_bool = 0;
+ return git_config_int(name, value);
+}
+
+int git_config_bool(const char *name, const char *value)
+{
+ int discard;
+ return !!git_config_bool_or_int(name, value, &discard);
}
-int git_default_config(const char *var, const char *value)
+int git_config_string(const char **dest, const char *var, const char *value)
+{
+ if (!value)
+ return config_error_nonbool(var);
+ *dest = xstrdup(value);
+ return 0;
+}
+
+static int git_default_core_config(const char *var, const char *value)
{
/* This needs a better name */
if (!strcmp(var, "core.filemode")) {
trust_executable_bit = git_config_bool(var, value);
return 0;
}
+ if (!strcmp(var, "core.trustctime")) {
+ trust_ctime = git_config_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "core.quotepath")) {
quote_path_fully = git_config_bool(var, value);
@@ -327,6 +356,11 @@ int git_default_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.ignorecase")) {
+ ignore_case = git_config_bool(var, value);
+ return 0;
+ }
+
if (!strcmp(var, "core.bare")) {
is_bare_repository_cfg = git_config_bool(var, value);
return 0;
@@ -407,51 +441,122 @@ int git_default_config(const char *var, const char *value)
return 0;
}
- if (!strcmp(var, "user.name")) {
- strlcpy(git_default_name, value, sizeof(git_default_name));
+ if (!strcmp(var, "core.safecrlf")) {
+ if (value && !strcasecmp(value, "warn")) {
+ safe_crlf = SAFE_CRLF_WARN;
+ return 0;
+ }
+ safe_crlf = git_config_bool(var, value);
return 0;
}
- if (!strcmp(var, "user.email")) {
- strlcpy(git_default_email, value, sizeof(git_default_email));
- return 0;
- }
+ if (!strcmp(var, "core.pager"))
+ return git_config_string(&pager_program, var, value);
- if (!strcmp(var, "i18n.commitencoding")) {
- git_commit_encoding = xstrdup(value);
+ if (!strcmp(var, "core.editor"))
+ return git_config_string(&editor_program, var, value);
+
+ if (!strcmp(var, "core.excludesfile"))
+ return git_config_string(&excludes_file, var, value);
+
+ if (!strcmp(var, "core.whitespace")) {
+ if (!value)
+ return config_error_nonbool(var);
+ whitespace_rule_cfg = parse_whitespace_rule(value);
return 0;
}
- if (!strcmp(var, "i18n.logoutputencoding")) {
- git_log_output_encoding = xstrdup(value);
+ if (!strcmp(var, "core.fsyncobjectfiles")) {
+ fsync_object_files = git_config_bool(var, value);
return 0;
}
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
- if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
- pager_use_color = git_config_bool(var,value);
+static int git_default_user_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "user.name")) {
+ if (!value)
+ return config_error_nonbool(var);
+ strlcpy(git_default_name, value, sizeof(git_default_name));
+ if (git_default_email[0])
+ user_ident_explicitly_given = 1;
return 0;
}
- if (!strcmp(var, "core.pager")) {
- pager_program = xstrdup(value);
+ if (!strcmp(var, "user.email")) {
+ if (!value)
+ return config_error_nonbool(var);
+ strlcpy(git_default_email, value, sizeof(git_default_email));
+ if (git_default_name[0])
+ user_ident_explicitly_given = 1;
return 0;
}
- if (!strcmp(var, "core.editor")) {
- editor_program = xstrdup(value);
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
+static int git_default_i18n_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "i18n.commitencoding"))
+ return git_config_string(&git_commit_encoding, var, value);
+
+ if (!strcmp(var, "i18n.logoutputencoding"))
+ return git_config_string(&git_log_output_encoding, var, value);
+
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
+static int git_default_branch_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "branch.autosetupmerge")) {
+ if (value && !strcasecmp(value, "always")) {
+ git_branch_track = BRANCH_TRACK_ALWAYS;
+ return 0;
+ }
+ git_branch_track = git_config_bool(var, value);
return 0;
}
-
- if (!strcmp(var, "core.excludesfile")) {
+ if (!strcmp(var, "branch.autosetuprebase")) {
if (!value)
- die("core.excludesfile without value");
- excludes_file = xstrdup(value);
+ return config_error_nonbool(var);
+ else if (!strcmp(value, "never"))
+ autorebase = AUTOREBASE_NEVER;
+ else if (!strcmp(value, "local"))
+ autorebase = AUTOREBASE_LOCAL;
+ else if (!strcmp(value, "remote"))
+ autorebase = AUTOREBASE_REMOTE;
+ else if (!strcmp(value, "always"))
+ autorebase = AUTOREBASE_ALWAYS;
+ else
+ return error("Malformed value for %s", var);
return 0;
}
- if (!strcmp(var, "core.whitespace")) {
- whitespace_rule_cfg = parse_whitespace_rule(value);
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
+int git_default_config(const char *var, const char *value, void *dummy)
+{
+ if (!prefixcmp(var, "core."))
+ return git_default_core_config(var, value);
+
+ if (!prefixcmp(var, "user."))
+ return git_default_user_config(var, value);
+
+ if (!prefixcmp(var, "i18n."))
+ return git_default_i18n_config(var, value);
+
+ if (!prefixcmp(var, "branch."))
+ return git_default_branch_config(var, value);
+
+ if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) {
+ pager_use_color = git_config_bool(var,value);
return 0;
}
@@ -459,7 +564,7 @@ int git_default_config(const char *var, const char *value)
return 0;
}
-int git_config_from_file(config_fn_t fn, const char *filename)
+int git_config_from_file(config_fn_t fn, const char *filename, void *data)
{
int ret;
FILE *f = fopen(filename, "r");
@@ -470,7 +575,7 @@ int git_config_from_file(config_fn_t fn, const char *filename)
config_file_name = filename;
config_linenr = 1;
config_file_eof = 0;
- ret = git_parse_file(fn);
+ ret = git_parse_file(fn, data);
fclose(f);
config_file_name = NULL;
}
@@ -480,46 +585,53 @@ int git_config_from_file(config_fn_t fn, const char *filename)
const char *git_etc_gitconfig(void)
{
static const char *system_wide;
- if (!system_wide) {
- system_wide = ETC_GITCONFIG;
- if (!is_absolute_path(system_wide)) {
- /* interpret path relative to exec-dir */
- const char *exec_path = git_exec_path();
- system_wide = prefix_path(exec_path, strlen(exec_path),
- system_wide);
- }
- }
+ if (!system_wide)
+ system_wide = system_path(ETC_GITCONFIG);
return system_wide;
}
-int git_config(config_fn_t fn)
+static int git_env_bool(const char *k, int def)
+{
+ const char *v = getenv(k);
+ return v ? git_config_bool(k, v) : def;
+}
+
+int git_config_system(void)
+{
+ return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
+}
+
+int git_config_global(void)
+{
+ return !git_env_bool("GIT_CONFIG_NOGLOBAL", 0);
+}
+
+int git_config(config_fn_t fn, void *data)
{
int ret = 0;
char *repo_config = NULL;
- const char *home = NULL, *filename;
+ const char *home = NULL;
/* $GIT_CONFIG makes git read _only_ the given config file,
* $GIT_CONFIG_LOCAL will make it process it in addition to the
* global config file, the same way it would the per-repository
* config file otherwise. */
- filename = getenv(CONFIG_ENVIRONMENT);
- if (!filename) {
- if (!access(git_etc_gitconfig(), R_OK))
- ret += git_config_from_file(fn, git_etc_gitconfig());
- home = getenv("HOME");
- filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!filename)
- filename = repo_config = xstrdup(git_path("config"));
- }
-
- if (home) {
+ if (config_exclusive_filename)
+ return git_config_from_file(fn, config_exclusive_filename, data);
+ if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
+ ret += git_config_from_file(fn, git_etc_gitconfig(),
+ data);
+
+ home = getenv("HOME");
+ if (git_config_global() && home) {
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
if (!access(user_config, R_OK))
- ret = git_config_from_file(fn, user_config);
+ ret += git_config_from_file(fn, user_config, data);
free(user_config);
}
- ret += git_config_from_file(fn, filename);
+ repo_config = xstrdup(git_path("config"));
+ ret += git_config_from_file(fn, repo_config, data);
free(repo_config);
return ret;
}
@@ -549,7 +661,7 @@ static int matches(const char* key, const char* value)
!regexec(store.value_regex, value, 0, NULL, 0)));
}
-static int store_aux(const char* key, const char* value)
+static int store_aux(const char* key, const char* value, void *cb)
{
const char *ep;
size_t section_len;
@@ -558,11 +670,9 @@ static int store_aux(const char* key, const char* value)
case KEY_SEEN:
if (matches(key, value)) {
if (store.seen == 1 && store.multi_replace == 0) {
- fprintf(stderr,
- "Warning: %s has multiple values\n",
- key);
+ warning("%s has multiple values", key);
} else if (store.seen >= MAX_MATCHES) {
- fprintf(stderr, "Too many matches\n");
+ error("too many matches for %s", key);
return 1;
}
@@ -612,9 +722,9 @@ static int store_aux(const char* key, const char* value)
return 0;
}
-static int write_error(void)
+static int write_error(const char *filename)
{
- fprintf(stderr, "Failed to write new configuration file\n");
+ error("failed to write new configuration file %s", filename);
/* Same error code as "failed to rename". */
return 4;
@@ -631,7 +741,7 @@ static int store_write_section(int fd, const char* key)
if (dot) {
strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key);
for (i = dot - key + 1; i < store.baselen; i++) {
- if (key[i] == '"')
+ if (key[i] == '"' || key[i] == '\\')
strbuf_addch(&sb, '\\');
strbuf_addch(&sb, key[i]);
}
@@ -701,12 +811,17 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,
size_t equal_offset = size, bracket_offset = size;
ssize_t offset;
+contline:
for (offset = offset_-2; offset > 0
&& contents[offset] != '\n'; offset--)
switch (contents[offset]) {
case '=': equal_offset = offset; break;
case ']': bracket_offset = offset; break;
}
+ if (offset > 0 && contents[offset-1] == '\\') {
+ offset_ = offset;
+ goto contline;
+ }
if (bracket_offset < equal_offset) {
*found_bracket = 1;
offset = bracket_offset+1;
@@ -754,13 +869,10 @@ int git_config_set_multivar(const char* key, const char* value,
struct lock_file *lock = NULL;
const char* last_dot = strrchr(key, '.');
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
/*
* Since "key" actually contains the section name and the real
@@ -768,7 +880,7 @@ int git_config_set_multivar(const char* key, const char* value,
*/
if (last_dot == NULL) {
- fprintf(stderr, "key does not contain a section: %s\n", key);
+ error("key does not contain a section: %s", key);
ret = 2;
goto out_free;
}
@@ -788,14 +900,14 @@ int git_config_set_multivar(const char* key, const char* value,
/* Leave the extended basename untouched.. */
if (!dot || i > store.baselen) {
if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) {
- fprintf(stderr, "invalid key: %s\n", key);
+ error("invalid key: %s", key);
free(store.key);
ret = 1;
goto out_free;
}
c = tolower(c);
} else if (c == '\n') {
- fprintf(stderr, "invalid key (newline): %s\n", key);
+ error("invalid key (newline): %s", key);
free(store.key);
ret = 1;
goto out_free;
@@ -811,7 +923,7 @@ int git_config_set_multivar(const char* key, const char* value,
lock = xcalloc(sizeof(struct lock_file), 1);
fd = hold_lock_file_for_update(lock, config_filename, 0);
if (fd < 0) {
- fprintf(stderr, "could not lock config file\n");
+ error("could not lock config file %s", config_filename);
free(store.key);
ret = -1;
goto out_free;
@@ -858,8 +970,7 @@ int git_config_set_multivar(const char* key, const char* value,
store.value_regex = (regex_t*)xmalloc(sizeof(regex_t));
if (regcomp(store.value_regex, value_regex,
REG_EXTENDED)) {
- fprintf(stderr, "Invalid pattern: %s\n",
- value_regex);
+ error("invalid pattern: %s", value_regex);
free(store.value_regex);
ret = 6;
goto out_free;
@@ -876,8 +987,8 @@ int git_config_set_multivar(const char* key, const char* value,
* As a side effect, we make sure to transform only a valid
* existing config file.
*/
- if (git_config_from_file(store_aux, config_filename)) {
- fprintf(stderr, "invalid config file\n");
+ if (git_config_from_file(store_aux, config_filename, NULL)) {
+ error("invalid config file %s", config_filename);
free(store.key);
if (store.value_regex != NULL) {
regfree(store.value_regex);
@@ -956,7 +1067,7 @@ int git_config_set_multivar(const char* key, const char* value,
}
if (commit_lock_file(lock) < 0) {
- fprintf(stderr, "Cannot commit config file!\n");
+ error("could not commit config file %s", config_filename);
ret = 4;
goto out_free;
}
@@ -977,7 +1088,7 @@ out_free:
return ret;
write_err_out:
- ret = write_error();
+ ret = write_error(lock->filename);
goto out_free;
}
@@ -1018,16 +1129,13 @@ int git_config_rename_section(const char *old_name, const char *new_name)
int out_fd;
char buf[1024];
- config_filename = getenv(CONFIG_ENVIRONMENT);
- if (!config_filename) {
- config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
- if (!config_filename)
- config_filename = git_path("config");
- }
- config_filename = xstrdup(config_filename);
+ if (config_exclusive_filename)
+ config_filename = xstrdup(config_exclusive_filename);
+ else
+ config_filename = xstrdup(git_path("config"));
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0) {
- ret = error("Could not lock config file!");
+ ret = error("could not lock config file %s", config_filename);
goto out;
}
@@ -1051,7 +1159,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
}
store.baselen = strlen(new_name);
if (!store_write_section(out_fd, new_name)) {
- ret = write_error();
+ ret = write_error(lock->filename);
goto out;
}
continue;
@@ -1062,15 +1170,24 @@ int git_config_rename_section(const char *old_name, const char *new_name)
continue;
length = strlen(buf);
if (write_in_full(out_fd, buf, length) != length) {
- ret = write_error();
+ ret = write_error(lock->filename);
goto out;
}
}
fclose(config_file);
unlock_and_out:
if (commit_lock_file(lock) < 0)
- ret = error("Cannot commit config file!");
+ ret = error("could not commit config file %s", config_filename);
out:
free(config_filename);
return ret;
}
+
+/*
+ * Call this to report error for your variable that should not
+ * get a boolean value (i.e. "[my] var" means "true").
+ */
+int config_error_nonbool(const char *var)
+{
+ return error("Missing value for '%s'", var);
+}
diff --git a/config.mak.in b/config.mak.in
index 40b14d985..b77614953 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -11,7 +11,7 @@ TCLTK_PATH = @TCLTK_PATH@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
-#gitexecdir = @libexecdir@/git-core/
+gitexecdir = @libexecdir@/git-core/
datarootdir = @datarootdir@
template_dir = @datadir@/git-core/templates/
@@ -30,6 +30,7 @@ NO_CURL=@NO_CURL@
NO_EXPAT=@NO_EXPAT@
NEEDS_LIBICONV=@NEEDS_LIBICONV@
NEEDS_SOCKET=@NEEDS_SOCKET@
+NO_SYS_SELECT_H=@NO_SYS_SELECT_H@
NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@
NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@
NO_SOCKADDR_STORAGE=@NO_SOCKADDR_STORAGE@
@@ -45,3 +46,5 @@ NO_MKDTEMP=@NO_MKDTEMP@
NO_ICONV=@NO_ICONV@
OLD_ICONV=@OLD_ICONV@
NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
+FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
+SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
diff --git a/configure.ac b/configure.ac
index af177fdb4..7c2856efc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,7 +158,7 @@ AC_CHECK_LIB([crypto], [SHA1_Init],
AC_SUBST(NEEDS_SSL_WITH_CRYPTO)
AC_SUBST(NO_OPENSSL)
#
-# Define NO_CURL if you do not have curl installed. git-http-pull and
+# Define NO_CURL if you do not have libcurl installed. git-http-pull and
# git-http-push are not built, and you cannot use http:// and https://
# transports.
AC_CHECK_LIB([curl], [curl_global_init],
@@ -235,6 +235,12 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
## Checks for header files.
AC_MSG_NOTICE([CHECKS for header files])
#
+# Define NO_SYS_SELECT_H if you don't have sys/select.h.
+AC_CHECK_HEADER([sys/select.h],
+[NO_SYS_SELECT_H=],
+[NO_SYS_SELECT_H=UnfortunatelyYes])
+AC_SUBST(NO_SYS_SELECT_H)
+#
# Define OLD_ICONV if your library has an old iconv(), where the second
# (input buffer pointer) parameter is declared with type (const char **).
AC_DEFUN([OLDICONVTEST_SRC], [[
@@ -320,6 +326,60 @@ else
NO_C99_FORMAT=
fi
AC_SUBST(NO_C99_FORMAT)
+#
+# Define FREAD_READS_DIRECTORIES if your are on a system which succeeds
+# when attempting to read from an fopen'ed directory.
+AC_CACHE_CHECK([whether system succeeds to read fopen'ed directory],
+ [ac_cv_fread_reads_directories],
+[
+AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+ [[char c;
+ FILE *f = fopen(".", "r");
+ return f && fread(&c, 1, 1, f)]])],
+ [ac_cv_fread_reads_directories=no],
+ [ac_cv_fread_reads_directories=yes])
+])
+if test $ac_cv_fread_reads_directories = yes; then
+ FREAD_READS_DIRECTORIES=UnfortunatelyYes
+else
+ FREAD_READS_DIRECTORIES=
+fi
+AC_SUBST(FREAD_READS_DIRECTORIES)
+#
+# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
+# or vsnprintf() return -1 instead of number of characters which would
+# have been written to the final string if enough space had been available.
+AC_CACHE_CHECK([whether snprintf() and/or vsnprintf() return bogus value],
+ [ac_cv_snprintf_returns_bogus],
+[
+AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+ #include "stdarg.h"
+
+ int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
+ {
+ int ret;
+ va_list ap;
+ va_start(ap, format);
+ ret = vsnprintf(str, maxsize, format, ap);
+ va_end(ap);
+ return ret;
+ }],
+ [[char buf[6];
+ if (test_vsnprintf(buf, 3, "%s", "12345") != 5
+ || strcmp(buf, "12")) return 1;
+ if (snprintf(buf, 3, "%s", "12345") != 5
+ || strcmp(buf, "12")) return 1]])],
+ [ac_cv_snprintf_returns_bogus=no],
+ [ac_cv_snprintf_returns_bogus=yes])
+])
+if test $ac_cv_snprintf_returns_bogus = yes; then
+ SNPRINTF_RETURNS_BOGUS=UnfortunatelyYes
+else
+ SNPRINTF_RETURNS_BOGUS=
+fi
+AC_SUBST(SNPRINTF_RETURNS_BOGUS)
## Checks for library functions.
diff --git a/connect.c b/connect.c
index 3aefd4ace..574f42fa4 100644
--- a/connect.c
+++ b/connect.c
@@ -68,8 +68,7 @@ struct ref **get_remote_heads(int in, struct ref **list,
name_len = strlen(name);
if (len != name_len + 41) {
- if (server_capabilities)
- free(server_capabilities);
+ free(server_capabilities);
server_capabilities = xstrdup(name + name_len + 1);
}
@@ -361,7 +360,8 @@ static char *git_proxy_command;
static const char *rhost_name;
static int rhost_len;
-static int git_proxy_command_options(const char *var, const char *value)
+static int git_proxy_command_options(const char *var, const char *value,
+ void *cb)
{
if (!strcmp(var, "core.gitproxy")) {
const char *for_pos;
@@ -370,6 +370,8 @@ static int git_proxy_command_options(const char *var, const char *value)
if (git_proxy_command)
return 0;
+ if (!value)
+ return config_error_nonbool(var);
/* [core]
* ;# matches www.kernel.org as well
* gitproxy = netcatter-1 for kernel.org
@@ -403,7 +405,7 @@ static int git_proxy_command_options(const char *var, const char *value)
return 0;
}
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
static int git_use_proxy(const char *host)
@@ -411,7 +413,7 @@ static int git_use_proxy(const char *host)
rhost_name = host;
rhost_len = strlen(host);
git_proxy_command = getenv("GIT_PROXY_COMMAND");
- git_config(git_proxy_command_options);
+ git_config(git_proxy_command_options, NULL);
rhost_name = NULL;
return (git_proxy_command && *git_proxy_command);
}
@@ -472,14 +474,18 @@ char *get_port(char *host)
return NULL;
}
+static struct child_process no_fork;
+
/*
- * This returns NULL if the transport protocol does not need fork(2), or a
- * struct child_process object if it does. Once done, finish the connection
- * with finish_connect() with the value returned from this function
- * (it is safe to call finish_connect() with NULL to support the former
- * case).
+ * This returns a dummy child_process if the transport protocol does not
+ * need fork(2), or a struct child_process object if it does. Once done,
+ * finish the connection with finish_connect() with the value returned from
+ * this function (it is safe to call finish_connect() with NULL to support
+ * the former case).
*
- * If it returns, the connect is successful; it just dies on errors.
+ * If it returns, the connect is successful; it just dies on errors (this
+ * will hopefully be changed in a libification effort, to return NULL when
+ * the connection failed).
*/
struct child_process *git_connect(int fd[2], const char *url_orig,
const char *prog, int flags)
@@ -523,7 +529,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
end = host;
path = strchr(end, c);
- if (path) {
+ if (path && !has_dos_drive_prefix(end)) {
if (c == ':') {
protocol = PROTO_SSH;
*path++ = '\0';
@@ -577,7 +583,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
free(url);
if (free_path)
free(path);
- return NULL;
+ return &no_fork;
}
conn = xcalloc(1, sizeof(*conn));
@@ -635,7 +641,7 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
int finish_connect(struct child_process *conn)
{
int code;
- if (!conn)
+ if (!conn || conn == &no_fork)
return 0;
code = finish_command(conn);
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0d33f9a3d..158b91284 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -45,6 +45,11 @@
# git@vger.kernel.org
#
+case "$COMP_WORDBREAKS" in
+*:*) : great ;;
+*) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
+esac
+
__gitdir ()
{
if [ -z "$1" ]; then
@@ -64,33 +69,85 @@ __gitdir ()
__git_ps1 ()
{
- local b="$(git symbolic-ref HEAD 2>/dev/null)"
- if [ -n "$b" ]; then
+ local g="$(git rev-parse --git-dir 2>/dev/null)"
+ if [ -n "$g" ]; then
+ local r
+ local b
+ if [ -d "$g/rebase-apply" ]
+ then
+ if test -f "$g/rebase-apply/rebasing"
+ then
+ r="|REBASE"
+ elif test -f "$g/rebase-apply/applying"
+ then
+ r="|AM"
+ else
+ r="|AM/REBASE"
+ fi
+ b="$(git symbolic-ref HEAD 2>/dev/null)"
+ elif [ -f "$g/rebase-merge/interactive" ]
+ then
+ r="|REBASE-i"
+ b="$(cat "$g/rebase-merge/head-name")"
+ elif [ -d "$g/rebase-merge" ]
+ then
+ r="|REBASE-m"
+ b="$(cat "$g/rebase-merge/head-name")"
+ elif [ -f "$g/MERGE_HEAD" ]
+ then
+ r="|MERGING"
+ b="$(git symbolic-ref HEAD 2>/dev/null)"
+ else
+ if [ -f "$g/BISECT_LOG" ]
+ then
+ r="|BISECTING"
+ fi
+ if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
+ then
+ if ! b="$(git describe --exact-match HEAD 2>/dev/null)"
+ then
+ b="$(cut -c1-7 "$g/HEAD")..."
+ fi
+ fi
+ fi
+
if [ -n "$1" ]; then
- printf "$1" "${b##refs/heads/}"
+ printf "$1" "${b##refs/heads/}$r"
else
- printf " (%s)" "${b##refs/heads/}"
+ printf " (%s)" "${b##refs/heads/}$r"
fi
fi
}
+__gitcomp_1 ()
+{
+ local c IFS=' '$'\t'$'\n'
+ for c in $1; do
+ case "$c$2" in
+ --*=*) printf %s$'\n' "$c$2" ;;
+ *.) printf %s$'\n' "$c$2" ;;
+ *) printf %s$'\n' "$c$2 " ;;
+ esac
+ done
+}
+
__gitcomp ()
{
- local all c s=$'\n' IFS=' '$'\t'$'\n'
local cur="${COMP_WORDS[COMP_CWORD]}"
if [ $# -gt 2 ]; then
cur="$3"
fi
- for c in $1; do
- case "$c$4" in
- --*=*) all="$all$c$4$s" ;;
- *.) all="$all$c$4$s" ;;
- *) all="$all$c$4 $s" ;;
- esac
- done
- IFS=$s
- COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
- return
+ case "$cur" in
+ --*=)
+ COMPREPLY=()
+ ;;
+ *)
+ local IFS=$'\n'
+ COMPREPLY=($(compgen -P "$2" \
+ -W "$(__gitcomp_1 "$1" "$4")" \
+ -- "$cur"))
+ ;;
+ esac
}
__git_heads ()
@@ -104,7 +161,7 @@ __git_heads ()
done
return
fi
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -125,7 +182,7 @@ __git_tags ()
done
return
fi
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -152,7 +209,7 @@ __git_refs ()
done
return
fi
- for i in $(git-ls-remote "$dir" 2>/dev/null); do
+ for i in $(git ls-remote "$dir" 2>/dev/null); do
case "$is_hash,$i" in
y,*) is_hash=n ;;
n,*^{}) is_hash=y ;;
@@ -175,7 +232,7 @@ __git_refs2 ()
__git_refs_remotes ()
{
local cmd i is_hash=y
- for i in $(git-ls-remote "$1" 2>/dev/null); do
+ for i in $(git ls-remote "$1" 2>/dev/null); do
case "$is_hash,$i" in
n,refs/heads/*)
is_hash=y
@@ -242,9 +299,23 @@ __git_complete_file ()
ls="$ref"
;;
esac
+
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="$ref:$pfx" ;;
+ esac
+
+ local IFS=$'\n'
COMPREPLY=($(compgen -P "$pfx" \
-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
- | sed '/^100... blob /s,^.* ,,
+ | sed '/^100... blob /{
+ s,^.* ,,
+ s,$, ,
+ }
+ /^120000 blob /{
+ s,^.* ,,
+ s,$, ,
+ }
/^040000 tree /{
s,^.* ,,
s,$,/,
@@ -272,19 +343,16 @@ __git_complete_revlist ()
cur="${cur#*..}"
__gitcomp "$(__git_refs)" "$pfx" "$cur"
;;
- *.)
- __gitcomp "$cur."
- ;;
*)
__gitcomp "$(__git_refs)"
;;
esac
}
-__git_commands ()
+__git_all_commands ()
{
- if [ -n "$__git_commandlist" ]; then
- echo "$__git_commandlist"
+ if [ -n "$__git_all_commandlist" ]; then
+ echo "$__git_all_commandlist"
return
fi
local i IFS=" "$'\n'
@@ -292,6 +360,24 @@ __git_commands ()
do
case $i in
*--*) : helper pattern;;
+ *) echo $i;;
+ esac
+ done
+}
+__git_all_commandlist=
+__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
+
+__git_porcelain_commands ()
+{
+ if [ -n "$__git_porcelain_commandlist" ]; then
+ echo "$__git_porcelain_commandlist"
+ return
+ fi
+ local i IFS=" "$'\n'
+ for i in "help" $(__git_all_commands)
+ do
+ case $i in
+ *--*) : helper pattern;;
applymbox) : ask gittus;;
applypatch) : ask gittus;;
archimport) : import;;
@@ -344,7 +430,6 @@ __git_commands ()
show-index) : plumbing;;
ssh-*) : transport;;
stripspace) : plumbing;;
- svn) : import export;;
symbolic-ref) : plumbing;;
tar-tree) : deprecated;;
unpack-file) : plumbing;;
@@ -360,8 +445,8 @@ __git_commands ()
esac
done
}
-__git_commandlist=
-__git_commandlist="$(__git_commands 2>/dev/null)"
+__git_porcelain_commandlist=
+__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
__git_aliases ()
{
@@ -388,13 +473,41 @@ __git_aliased_command ()
done
}
-__git_whitespacelist="nowarn warn error error-all strip"
+__git_find_subcommand ()
+{
+ local word subcommand c=1
+
+ while [ $c -lt $COMP_CWORD ]; do
+ word="${COMP_WORDS[c]}"
+ for subcommand in $1; do
+ if [ "$subcommand" = "$word" ]; then
+ echo "$subcommand"
+ return
+ fi
+ done
+ c=$((++c))
+ done
+}
+
+__git_has_doubledash ()
+{
+ local c=1
+ while [ $c -lt $COMP_CWORD ]; do
+ if [ "--" = "${COMP_WORDS[c]}" ]; then
+ return 0
+ fi
+ c=$((++c))
+ done
+ return 1
+}
+
+__git_whitespacelist="nowarn warn error error-all fix"
_git_am ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- if [ -d .dotest ]; then
- __gitcomp "--skip --resolved"
+ local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
+ if [ -d "$dir"/rebase-apply ]; then
+ __gitcomp "--skip --resolved --abort"
return
fi
case "$cur" in
@@ -434,36 +547,56 @@ _git_apply ()
_git_add ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- __gitcomp "--interactive --refresh"
+ __gitcomp "
+ --interactive --refresh --patch --update --dry-run
+ --ignore-errors
+ "
return
esac
COMPREPLY=()
}
+_git_archive ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --format=*)
+ __gitcomp "$(git archive --list)" "" "${cur##--format=}"
+ return
+ ;;
+ --remote=*)
+ __gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --format= --list --verbose
+ --prefix= --remote= --exec=
+ "
+ return
+ ;;
+ esac
+ __git_complete_file
+}
+
_git_bisect ()
{
- local i c=1 command
- while [ $c -lt $COMP_CWORD ]; do
- i="${COMP_WORDS[c]}"
- case "$i" in
- start|bad|good|reset|visualize|replay|log)
- command="$i"
- break
- ;;
- esac
- c=$((++c))
- done
+ __git_has_doubledash && return
- if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
- __gitcomp "start bad good reset visualize replay log"
+ local subcommands="start bad good skip reset visualize replay log run"
+ local subcommand="$(__git_find_subcommand "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
return
fi
- case "$command" in
- bad|good|reset)
+ case "$subcommand" in
+ bad|good|reset|skip)
__gitcomp "$(__git_refs)"
;;
*)
@@ -474,7 +607,33 @@ _git_bisect ()
_git_branch ()
{
- __gitcomp "$(__git_refs)"
+ local i c=1 only_local_ref="n" has_r="n"
+
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ -d|-m) only_local_ref="y" ;;
+ -r) has_r="y" ;;
+ esac
+ c=$((++c))
+ done
+
+ case "${COMP_WORDS[COMP_CWORD]}" in
+ --*=*) COMPREPLY=() ;;
+ --*)
+ __gitcomp "
+ --color --no-color --verbose --abbrev= --no-abbrev
+ --track --no-track --contains --merged --no-merged
+ "
+ ;;
+ *)
+ if [ $only_local_ref = "y" -a $has_r = "n" ]; then
+ __gitcomp "$(__git_heads)"
+ else
+ __gitcomp "$(__git_refs)"
+ fi
+ ;;
+ esac
}
_git_bundle ()
@@ -508,6 +667,8 @@ _git_bundle ()
_git_checkout ()
{
+ __git_has_doubledash && return
+
__gitcomp "$(__git_refs)"
}
@@ -529,8 +690,49 @@ _git_cherry_pick ()
esac
}
+_git_clean ()
+{
+ __git_has_doubledash && return
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--dry-run --quiet"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_clone ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --local
+ --no-hardlinks
+ --shared
+ --reference
+ --quiet
+ --no-checkout
+ --bare
+ --mirror
+ --origin
+ --upload-pack
+ --template=
+ --depth
+ "
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_commit ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -545,11 +747,22 @@ _git_commit ()
_git_describe ()
{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --all --tags --contains --abbrev= --candidates=
+ --exact-match --debug --long --match --always
+ "
+ return
+ esac
__gitcomp "$(__git_refs)"
}
_git_diff ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -560,18 +773,16 @@ _git_diff ()
--find-copies-harder --pickaxe-all --pickaxe-regex
--text --ignore-space-at-eol --ignore-space-change
--ignore-all-space --exit-code --quiet --ext-diff
- --no-ext-diff"
+ --no-ext-diff
+ --no-prefix --src-prefix= --dst-prefix=
+ --base --ours --theirs
+ "
return
;;
esac
__git_complete_file
}
-_git_diff_tree ()
-{
- __gitcomp "$(__git_refs)"
-}
-
_git_fetch ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -586,7 +797,12 @@ _git_fetch ()
*)
case "$cur" in
*:*)
- __gitcomp "$(__git_refs)" "" "${cur#*:}"
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+ __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
;;
*)
local remote
@@ -616,6 +832,8 @@ _git_format_patch ()
--in-reply-to=
--full-index --binary
--not --all
+ --cover-letter
+ --no-prefix --src-prefix= --dst-prefix=
"
return
;;
@@ -635,6 +853,83 @@ _git_gc ()
COMPREPLY=()
}
+_git_grep ()
+{
+ __git_has_doubledash && return
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --cached
+ --text --ignore-case --word-regexp --invert-match
+ --full-name
+ --extended-regexp --basic-regexp --fixed-strings
+ --files-with-matches --name-only
+ --files-without-match
+ --count
+ --and --or --not --all-match
+ "
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_help ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--all --info --man --web"
+ return
+ ;;
+ esac
+ __gitcomp "$(__git_all_commands)
+ attributes cli core-tutorial cvs-migration
+ diffcore gitk glossary hooks ignore modules
+ repository-layout tutorial tutorial-2
+ "
+}
+
+_git_init ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --shared=*)
+ __gitcomp "
+ false true umask group all world everybody
+ " "" "${cur##--shared=}"
+ return
+ ;;
+ --*)
+ __gitcomp "--quiet --bare --template= --shared --shared="
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_ls_files ()
+{
+ __git_has_doubledash && return
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--cached --deleted --modified --others --ignored
+ --stage --directory --no-empty-directory --unmerged
+ --killed --exclude= --exclude-from=
+ --exclude-per-directory= --exclude-standard
+ --error-unmatch --with-tree= --full-name
+ --abbrev --ignored --exclude-per-directory
+ "
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_ls_remote ()
{
__gitcomp "$(__git_remotes)"
@@ -647,6 +942,8 @@ _git_ls_tree ()
_git_log ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--pretty=*)
@@ -674,6 +971,12 @@ _git_log ()
--pretty= --name-status --name-only --raw
--not --all
--left-right --cherry-pick
+ --graph
+ --stat --numstat --shortstat
+ --decorate --diff-filter=
+ --color-words --walk-reflogs
+ --parents --children --full-history
+ --merge
"
return
;;
@@ -696,18 +999,49 @@ _git_merge ()
;;
--*)
__gitcomp "
- --no-commit --no-summary --squash --strategy
+ --no-commit --no-stat --log --no-log --squash --strategy
"
return
esac
__gitcomp "$(__git_refs)"
}
+_git_mergetool ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --tool=*)
+ __gitcomp "
+ kdiff3 tkdiff meld xxdiff emerge
+ vimdiff gvimdiff ecmerge opendiff
+ " "" "${cur##--tool=}"
+ return
+ ;;
+ --*)
+ __gitcomp "--tool="
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_merge_base ()
{
__gitcomp "$(__git_refs)"
}
+_git_mv ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--dry-run"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_name_rev ()
{
__gitcomp "--tags --all --stdin"
@@ -754,7 +1088,14 @@ _git_push ()
git-push) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
+
+ local pfx=""
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *) pfx="${cur%%:*}:" ;;
+ esac
+
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
;;
+*)
__gitcomp "$(__git_refs)" + "${cur#+}"
@@ -769,8 +1110,8 @@ _git_push ()
_git_rebase ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
+ local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
+ if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
__gitcomp "--continue --skip --abort"
return
fi
@@ -785,12 +1126,30 @@ _git_rebase ()
return
;;
--*)
- __gitcomp "--onto --merge --strategy"
+ __gitcomp "--onto --merge --strategy --interactive"
return
esac
__gitcomp "$(__git_refs)"
}
+_git_send_email ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
+ --dry-run --envelope-sender --from --identity
+ --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
+ --no-suppress-from --no-thread --quiet
+ --signed-off-by-cc --smtp-pass --smtp-server
+ --smtp-server-port --smtp-ssl --smtp-user --subject
+ --suppress-cc --suppress-from --thread --to"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_config ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -889,7 +1248,6 @@ _git_config ()
core.sharedRepository
core.warnAmbiguousRefs
core.compression
- core.legacyHeaders
core.packedGitWindowSize
core.packedGitLimit
clean.requireForce
@@ -920,7 +1278,8 @@ _git_config ()
gitcvs.enabled
gitcvs.logfile
gitcvs.allbinary
- gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
+ gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dbpass
+ gitcvs.dbtablenameprefix
gc.packrefs
gc.reflogexpire
gc.reflogexpireunreachable
@@ -950,7 +1309,6 @@ _git_config ()
pull.octopus
pull.twohead
repack.useDeltaBaseOffset
- show.difftree
showbranch.default
tar.umask
transfer.unpackLimit
@@ -959,28 +1317,20 @@ _git_config ()
user.name
user.email
user.signingkey
- whatchanged.difftree
branch. remote.
"
}
_git_remote ()
{
- local i c=1 command
- while [ $c -lt $COMP_CWORD ]; do
- i="${COMP_WORDS[c]}"
- case "$i" in
- add|rm|show|prune|update) command="$i"; break ;;
- esac
- c=$((++c))
- done
-
- if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
- __gitcomp "add rm show prune update"
+ local subcommands="add rm show prune update"
+ local subcommand="$(__git_find_subcommand "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
return
fi
- case "$command" in
+ case "$subcommand" in
rm|show|prune)
__gitcomp "$(__git_remotes)"
;;
@@ -1004,6 +1354,8 @@ _git_remote ()
_git_reset ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -1014,8 +1366,36 @@ _git_reset ()
__gitcomp "$(__git_refs)"
}
+_git_revert ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_rm ()
+{
+ __git_has_doubledash && return
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
_git_shortlog ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
@@ -1052,36 +1432,148 @@ _git_show ()
__git_complete_file
}
+_git_show_branch ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --all --remotes --topo-order --current --more=
+ --list --independent --merge-base --no-name
+ --sha1-name --topics --reflog
+ "
+ return
+ ;;
+ esac
+ __git_complete_revlist
+}
+
_git_stash ()
{
- __gitcomp 'list show apply clear'
+ local subcommands='save list show apply clear drop pop create branch'
+ local subcommand="$(__git_find_subcommand "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ else
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$subcommand,$cur" in
+ save,--*)
+ __gitcomp "--keep-index"
+ ;;
+ apply,--*)
+ __gitcomp "--index"
+ ;;
+ show,--*|drop,--*|pop,--*|branch,--*)
+ COMPREPLY=()
+ ;;
+ show,*|apply,*|drop,*|pop,*|branch,*)
+ __gitcomp "$(git --git-dir="$(__gitdir)" stash list \
+ | sed -n -e 's/:.*//p')"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ fi
}
_git_submodule ()
{
- local i c=1 command
- while [ $c -lt $COMP_CWORD ]; do
- i="${COMP_WORDS[c]}"
- case "$i" in
- add|status|init|update) command="$i"; break ;;
- esac
- c=$((++c))
- done
+ __git_has_doubledash && return
- if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ local subcommands="add status init update"
+ if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
__gitcomp "--quiet --cached"
;;
*)
- __gitcomp "add status init update"
+ __gitcomp "$subcommands"
;;
esac
return
fi
}
+_git_svn ()
+{
+ local subcommands="
+ init fetch clone rebase dcommit log find-rev
+ set-tree commit-diff info create-ignore propget
+ proplist show-ignore show-externals
+ "
+ local subcommand="$(__git_find_subcommand "$subcommands")"
+ if [ -z "$subcommand" ]; then
+ __gitcomp "$subcommands"
+ else
+ local remote_opts="--username= --config-dir= --no-auth-cache"
+ local fc_opts="
+ --follow-parent --authors-file= --repack=
+ --no-metadata --use-svm-props --use-svnsync-props
+ --log-window-size= --no-checkout --quiet
+ --repack-flags --user-log-author $remote_opts
+ "
+ local init_opts="
+ --template= --shared= --trunk= --tags=
+ --branches= --stdlayout --minimize-url
+ --no-metadata --use-svm-props --use-svnsync-props
+ --rewrite-root= $remote_opts
+ "
+ local cmt_opts="
+ --edit --rmdir --find-copies-harder --copy-similarity=
+ "
+
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$subcommand,$cur" in
+ fetch,--*)
+ __gitcomp "--revision= --fetch-all $fc_opts"
+ ;;
+ clone,--*)
+ __gitcomp "--revision= $fc_opts $init_opts"
+ ;;
+ init,--*)
+ __gitcomp "$init_opts"
+ ;;
+ dcommit,--*)
+ __gitcomp "
+ --merge --strategy= --verbose --dry-run
+ --fetch-all --no-rebase $cmt_opts $fc_opts
+ "
+ ;;
+ set-tree,--*)
+ __gitcomp "--stdin $cmt_opts $fc_opts"
+ ;;
+ create-ignore,--*|propget,--*|proplist,--*|show-ignore,--*|\
+ show-externals,--*)
+ __gitcomp "--revision="
+ ;;
+ log,--*)
+ __gitcomp "
+ --limit= --revision= --verbose --incremental
+ --oneline --show-commit --non-recursive
+ --authors-file=
+ "
+ ;;
+ rebase,--*)
+ __gitcomp "
+ --merge --verbose --strategy= --local
+ --fetch-all $fc_opts
+ "
+ ;;
+ commit-diff,--*)
+ __gitcomp "--message= --file= --revision= $cmt_opts"
+ ;;
+ info,--*)
+ __gitcomp "--url"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ fi
+}
+
_git_tag ()
{
local i c=1 f=0
@@ -1125,24 +1617,28 @@ _git ()
case "$i" in
--git-dir=*) __git_dir="${i#--git-dir=}" ;;
--bare) __git_dir="." ;;
- --version|--help|-p|--paginate) ;;
+ --version|-p|--paginate) ;;
+ --help) command="help"; break ;;
*) command="$i"; break ;;
esac
c=$((++c))
done
- if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ if [ -z "$command" ]; then
case "${COMP_WORDS[COMP_CWORD]}" in
--*=*) COMPREPLY=() ;;
--*) __gitcomp "
+ --paginate
--no-pager
--git-dir=
--bare
--version
--exec-path
+ --work-tree=
+ --help
"
;;
- *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+ *) __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
esac
return
fi
@@ -1154,12 +1650,15 @@ _git ()
am) _git_am ;;
add) _git_add ;;
apply) _git_apply ;;
+ archive) _git_archive ;;
bisect) _git_bisect ;;
bundle) _git_bundle ;;
branch) _git_branch ;;
checkout) _git_checkout ;;
cherry) _git_cherry ;;
cherry-pick) _git_cherry_pick ;;
+ clean) _git_clean ;;
+ clone) _git_clone ;;
commit) _git_commit ;;
config) _git_config ;;
describe) _git_describe ;;
@@ -1167,22 +1666,32 @@ _git ()
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
gc) _git_gc ;;
+ grep) _git_grep ;;
+ help) _git_help ;;
+ init) _git_init ;;
log) _git_log ;;
+ ls-files) _git_ls_files ;;
ls-remote) _git_ls_remote ;;
ls-tree) _git_ls_tree ;;
merge) _git_merge;;
+ mergetool) _git_mergetool;;
merge-base) _git_merge_base ;;
+ mv) _git_mv ;;
name-rev) _git_name_rev ;;
pull) _git_pull ;;
push) _git_push ;;
rebase) _git_rebase ;;
remote) _git_remote ;;
reset) _git_reset ;;
+ revert) _git_revert ;;
+ rm) _git_rm ;;
+ send-email) _git_send_email ;;
shortlog) _git_shortlog ;;
show) _git_show ;;
- show-branch) _git_log ;;
+ show-branch) _git_show_branch ;;
stash) _git_stash ;;
submodule) _git_submodule ;;
+ svn) _git_svn ;;
tag) _git_tag ;;
whatchanged) _git_log ;;
*) COMPREPLY=() ;;
@@ -1191,10 +1700,17 @@ _git ()
_gitk ()
{
+ __git_has_doubledash && return
+
local cur="${COMP_WORDS[COMP_CWORD]}"
+ local g="$(git rev-parse --git-dir 2>/dev/null)"
+ local merge=""
+ if [ -f $g/MERGE_HEAD ]; then
+ merge="--merge"
+ fi
case "$cur" in
--*)
- __gitcomp "--not --all"
+ __gitcomp "--not --all $merge"
return
;;
esac
@@ -1203,63 +1719,11 @@ _gitk ()
complete -o default -o nospace -F _git git
complete -o default -o nospace -F _gitk gitk
-complete -o default -o nospace -F _git_am git-am
-complete -o default -o nospace -F _git_apply git-apply
-complete -o default -o nospace -F _git_bisect git-bisect
-complete -o default -o nospace -F _git_branch git-branch
-complete -o default -o nospace -F _git_bundle git-bundle
-complete -o default -o nospace -F _git_checkout git-checkout
-complete -o default -o nospace -F _git_cherry git-cherry
-complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
-complete -o default -o nospace -F _git_commit git-commit
-complete -o default -o nospace -F _git_describe git-describe
-complete -o default -o nospace -F _git_diff git-diff
-complete -o default -o nospace -F _git_fetch git-fetch
-complete -o default -o nospace -F _git_format_patch git-format-patch
-complete -o default -o nospace -F _git_gc git-gc
-complete -o default -o nospace -F _git_log git-log
-complete -o default -o nospace -F _git_ls_remote git-ls-remote
-complete -o default -o nospace -F _git_ls_tree git-ls-tree
-complete -o default -o nospace -F _git_merge git-merge
-complete -o default -o nospace -F _git_merge_base git-merge-base
-complete -o default -o nospace -F _git_name_rev git-name-rev
-complete -o default -o nospace -F _git_pull git-pull
-complete -o default -o nospace -F _git_push git-push
-complete -o default -o nospace -F _git_rebase git-rebase
-complete -o default -o nospace -F _git_config git-config
-complete -o default -o nospace -F _git_remote git-remote
-complete -o default -o nospace -F _git_reset git-reset
-complete -o default -o nospace -F _git_shortlog git-shortlog
-complete -o default -o nospace -F _git_show git-show
-complete -o default -o nospace -F _git_stash git-stash
-complete -o default -o nospace -F _git_submodule git-submodule
-complete -o default -o nospace -F _git_log git-show-branch
-complete -o default -o nospace -F _git_tag git-tag
-complete -o default -o nospace -F _git_log git-whatchanged
# The following are necessary only for Cygwin, and only are needed
# when the user has tab-completed the executable name and consequently
# included the '.exe' suffix.
#
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-complete -o default -o nospace -F _git_add git-add.exe
-complete -o default -o nospace -F _git_apply git-apply.exe
complete -o default -o nospace -F _git git.exe
-complete -o default -o nospace -F _git_branch git-branch.exe
-complete -o default -o nospace -F _git_bundle git-bundle.exe
-complete -o default -o nospace -F _git_cherry git-cherry.exe
-complete -o default -o nospace -F _git_describe git-describe.exe
-complete -o default -o nospace -F _git_diff git-diff.exe
-complete -o default -o nospace -F _git_format_patch git-format-patch.exe
-complete -o default -o nospace -F _git_log git-log.exe
-complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
-complete -o default -o nospace -F _git_merge_base git-merge-base.exe
-complete -o default -o nospace -F _git_name_rev git-name-rev.exe
-complete -o default -o nospace -F _git_push git-push.exe
-complete -o default -o nospace -F _git_config git-config
-complete -o default -o nospace -F _git_shortlog git-shortlog.exe
-complete -o default -o nospace -F _git_show git-show.exe
-complete -o default -o nospace -F _git_log git-show-branch.exe
-complete -o default -o nospace -F _git_tag git-tag.exe
-complete -o default -o nospace -F _git_log git-whatchanged.exe
fi
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
index bb671d561..4fa70c5ad 100644
--- a/contrib/emacs/git-blame.el
+++ b/contrib/emacs/git-blame.el
@@ -105,6 +105,13 @@ selected element from l."
(setq ,l (remove e ,l))
e))
+(defvar git-blame-log-oneline-format
+ "format:[%cr] %cn: %s"
+ "*Formatting option used for describing current line in the minibuffer.
+
+This option is used to pass to git log --pretty= command-line option,
+and describe which commit the current line was made.")
+
(defvar git-blame-dark-colors
(git-blame-color-scale "0c" "04" "24" "1c" "2c" "34" "14" "3c")
"*List of colors (format #RGB) to use in a dark environment.
@@ -371,9 +378,10 @@ See also function `git-blame-mode'."
(defun git-describe-commit (hash)
(with-temp-buffer
(call-process "git" nil t nil
- "log" "-1" "--pretty=oneline"
+ "log" "-1"
+ (concat "--pretty=" git-blame-log-oneline-format)
hash)
- (buffer-substring (point-min) (1- (point-max)))))
+ (buffer-substring (point-min) (point-max))))
(defvar git-blame-last-identification nil)
(make-variable-buffer-local 'git-blame-last-identification)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index d8a06381f..c1cf1cbcc 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -35,7 +35,6 @@
;;
;; TODO
;; - portability to XEmacs
-;; - better handling of subprocess errors
;; - diff against other branch
;; - renaming files from the status buffer
;; - creating tags
@@ -186,14 +185,25 @@ if there is already one that displays the same directory."
(defun git-call-process-env (buffer env &rest args)
"Wrapper for call-process that sets environment strings."
- (if env
- (apply #'call-process "env" nil buffer nil
- (append (git-get-env-strings env) (list "git") args))
+ (let ((process-environment (append (git-get-env-strings env)
+ process-environment)))
(apply #'call-process "git" nil buffer nil args)))
+(defun git-call-process-display-error (&rest args)
+ "Wrapper for call-process that displays error messages."
+ (let* ((dir default-directory)
+ (buffer (get-buffer-create "*Git Command Output*"))
+ (ok (with-current-buffer buffer
+ (let ((default-directory dir)
+ (buffer-read-only nil))
+ (erase-buffer)
+ (eq 0 (apply 'call-process "git" nil (list buffer t) nil args))))))
+ (unless ok (display-message-or-buffer buffer))
+ ok))
+
(defun git-call-process-env-string (env &rest args)
"Wrapper for call-process that sets environment strings,
-and returns the process output as a string."
+and returns the process output as a string, or nil if the git failed."
(with-temp-buffer
(and (eq 0 (apply #' git-call-process-env t env args))
(buffer-string))))
@@ -377,7 +387,7 @@ and returns the process output as a string."
(when reason
(push reason args)
(push "-m" args))
- (eq 0 (apply #'git-call-process-env nil nil "update-ref" args))))
+ (apply 'git-call-process-display-error "update-ref" args)))
(defun git-read-tree (tree &optional index-file)
"Read a tree into the index file."
@@ -558,12 +568,15 @@ and returns the process output as a string."
(?\100 " (type change file -> subproject)")
(?\120 " (type change symlink -> subproject)")
(t " (subproject)")))
+ (?\110 nil) ;; directory (internal, not a real git state)
(?\000 ;; deleted or unknown
(case old-type
(?\120 " (symlink)")
(?\160 " (subproject)")))
(t (format " (unknown type %o)" new-type)))))
- (if str (propertize str 'face 'git-status-face) "")))
+ (cond (str (propertize str 'face 'git-status-face))
+ ((eq new-type ?\110) "/")
+ (t ""))))
(defun git-rename-as-string (info)
"Return a string describing the copy or rename associated with INFO, or an empty string if none."
@@ -666,9 +679,11 @@ Return the list of files that haven't been handled."
(with-temp-buffer
(apply #'git-call-process-env t nil "ls-files" "-z" (append options (list "--") files))
(goto-char (point-min))
- (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
+ (while (re-search-forward "\\([^\0]*?\\)\\(/?\\)\0" nil t 1)
(let ((name (match-string 1)))
- (push (git-create-fileinfo default-state name) infolist)
+ (push (git-create-fileinfo default-state name 0
+ (if (string-equal "/" (match-string 2)) (lsh ?\110 9) 0))
+ infolist)
(setq files (delete name files)))))
(git-insert-info-list status infolist)
files))
@@ -713,7 +728,7 @@ Return the list of files that haven't been handled."
(defun git-run-ls-files-with-excludes (status files default-state &rest options)
"Run git-ls-files on FILES with appropriate --exclude-from options."
(let ((exclude-files (git-get-exclude-files)))
- (apply #'git-run-ls-files status files default-state
+ (apply #'git-run-ls-files status files default-state "--directory" "--no-empty-directory"
(concat "--exclude-per-directory=" git-per-dir-ignore-file)
(append options (mapcar (lambda (f) (concat "--exclude-from=" f)) exclude-files)))))
@@ -735,6 +750,27 @@ Return the list of files that haven't been handled."
(git-refresh-files)
(git-refresh-ewoc-hf git-status)))
+(defun git-mark-files (status files)
+ "Mark all the specified FILES, and unmark the others."
+ (setq files (sort files #'string-lessp))
+ (let ((file (and files (pop files)))
+ (node (ewoc-nth status 0)))
+ (while node
+ (let ((info (ewoc-data node)))
+ (if (and file (string-equal (git-fileinfo->name info) file))
+ (progn
+ (unless (git-fileinfo->marked info)
+ (setf (git-fileinfo->marked info) t)
+ (setf (git-fileinfo->needs-refresh info) t))
+ (setq file (pop files))
+ (setq node (ewoc-next status node)))
+ (when (git-fileinfo->marked info)
+ (setf (git-fileinfo->marked info) nil)
+ (setf (git-fileinfo->needs-refresh info) t))
+ (if (and file (string-lessp file (git-fileinfo->name info)))
+ (setq file (pop files))
+ (setq node (ewoc-next status node))))))))
+
(defun git-marked-files ()
"Return a list of all marked files, or if none a list containing just the file at cursor position."
(unless git-status (error "Not in git-status buffer."))
@@ -840,16 +876,17 @@ Return the list of files that haven't been handled."
(if (or (not (string-equal tree head-tree))
(yes-or-no-p "The tree was not modified, do you really want to perform an empty commit? "))
(let ((commit (git-commit-tree buffer tree head)))
- (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
- (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
- (with-current-buffer buffer (erase-buffer))
- (git-update-status-files (git-get-filenames files) 'uptodate)
- (git-call-process-env nil nil "rerere")
- (git-call-process-env nil nil "gc" "--auto")
- (git-refresh-files)
- (git-refresh-ewoc-hf git-status)
- (message "Committed %s." commit)
- (git-run-hook "post-commit" nil))
+ (when commit
+ (condition-case nil (delete-file ".git/MERGE_HEAD") (error nil))
+ (condition-case nil (delete-file ".git/MERGE_MSG") (error nil))
+ (with-current-buffer buffer (erase-buffer))
+ (git-update-status-files (git-get-filenames files) 'uptodate)
+ (git-call-process-env nil nil "rerere")
+ (git-call-process-env nil nil "gc" "--auto")
+ (git-refresh-files)
+ (git-refresh-ewoc-hf git-status)
+ (message "Committed %s." commit)
+ (git-run-hook "post-commit" nil)))
(message "Commit aborted."))))
(message "No files to commit.")))
(delete-file index-file))))))
@@ -957,11 +994,12 @@ Return the list of files that haven't been handled."
"Add marked file(s) to the index cache."
(interactive)
(let ((files (git-get-filenames (git-marked-files-state 'unknown 'ignored))))
+ ;; FIXME: add support for directories
(unless files
(push (file-relative-name (read-file-name "File to add: " nil nil t)) files))
- (apply #'git-call-process-env nil nil "update-index" "--add" "--" files)
- (git-update-status-files files 'uptodate)
- (git-success-message "Added" files)))
+ (when (apply 'git-call-process-display-error "update-index" "--add" "--" files)
+ (git-update-status-files files 'uptodate)
+ (git-success-message "Added" files))))
(defun git-ignore-file ()
"Add marked file(s) to the ignore list."
@@ -983,16 +1021,19 @@ Return the list of files that haven't been handled."
(format "Remove %d file%s? " (length files) (if (> (length files) 1) "s" "")))
(progn
(dolist (name files)
- (when (file-exists-p name) (delete-file name)))
- (apply #'git-call-process-env nil nil "update-index" "--remove" "--" files)
- (git-update-status-files files nil)
- (git-success-message "Removed" files))
+ (ignore-errors
+ (if (file-directory-p name)
+ (delete-directory name)
+ (delete-file name))))
+ (when (apply 'git-call-process-display-error "update-index" "--remove" "--" files)
+ (git-update-status-files files nil)
+ (git-success-message "Removed" files)))
(message "Aborting"))))
(defun git-revert-file ()
"Revert changes to the marked file(s)."
(interactive)
- (let ((files (git-marked-files))
+ (let ((files (git-marked-files-state 'added 'deleted 'modified 'unmerged))
added modified)
(when (and files
(yes-or-no-p
@@ -1003,21 +1044,31 @@ Return the list of files that haven't been handled."
('deleted (push (git-fileinfo->name info) modified))
('unmerged (push (git-fileinfo->name info) modified))
('modified (push (git-fileinfo->name info) modified))))
- (when added
- (apply #'git-call-process-env nil nil "update-index" "--force-remove" "--" added))
- (when modified
- (apply #'git-call-process-env nil nil "checkout" "HEAD" modified))
- (git-update-status-files (append added modified) 'uptodate)
- (git-success-message "Reverted" (git-get-filenames files)))))
+ ;; check if a buffer contains one of the files and isn't saved
+ (dolist (file modified)
+ (let ((buffer (get-file-buffer file)))
+ (when (and buffer (buffer-modified-p buffer))
+ (error "Buffer %s is modified. Please kill or save modified buffers before reverting." (buffer-name buffer)))))
+ (let ((ok (and
+ (or (not added)
+ (apply 'git-call-process-display-error "update-index" "--force-remove" "--" added))
+ (or (not modified)
+ (apply 'git-call-process-display-error "checkout" "HEAD" modified)))))
+ (git-update-status-files (append added modified) 'uptodate)
+ (when ok
+ (dolist (file modified)
+ (let ((buffer (get-file-buffer file)))
+ (when buffer (with-current-buffer buffer (revert-buffer t t t)))))
+ (git-success-message "Reverted" (git-get-filenames files)))))))
(defun git-resolve-file ()
"Resolve conflicts in marked file(s)."
(interactive)
(let ((files (git-get-filenames (git-marked-files-state 'unmerged))))
(when files
- (apply #'git-call-process-env nil nil "update-index" "--" files)
- (git-update-status-files files 'uptodate)
- (git-success-message "Resolved" files))))
+ (when (apply 'git-call-process-display-error "update-index" "--" files)
+ (git-update-status-files files 'uptodate)
+ (git-success-message "Resolved" files)))))
(defun git-remove-handled ()
"Remove handled files from the status list."
@@ -1063,6 +1114,16 @@ Return the list of files that haven't been handled."
(message "Inserting unknown files...done"))
(git-remove-handled)))
+(defun git-expand-directory (info)
+ "Expand the directory represented by INFO to list its files."
+ (when (eq (lsh (git-fileinfo->new-perm info) -9) ?\110)
+ (let ((dir (git-fileinfo->name info)))
+ (git-set-filenames-state git-status (list dir) nil)
+ (git-run-ls-files-with-excludes git-status (list (concat dir "/")) 'unknown "-o")
+ (git-refresh-files)
+ (git-refresh-ewoc-hf git-status)
+ t)))
+
(defun git-setup-diff-buffer (buffer)
"Setup a buffer for displaying a diff."
(let ((dir default-directory))
@@ -1191,15 +1252,16 @@ Return the list of files that haven't been handled."
"\n")
(when subject (insert subject "\n\n"))
(cond (msg (insert msg "\n"))
- ((file-readable-p ".dotest/msg")
- (insert-file-contents ".dotest/msg"))
+ ((file-readable-p ".git/rebase-apply/msg")
+ (insert-file-contents ".git/rebase-apply/msg"))
((file-readable-p ".git/MERGE_MSG")
(insert-file-contents ".git/MERGE_MSG")))
; delete empty lines at end
(goto-char (point-min))
(when (re-search-forward "\n+\\'" nil t)
(replace-match "\n" t t))
- (when sign-off (git-append-sign-off committer-name committer-email)))))
+ (when sign-off (git-append-sign-off committer-name committer-email)))
+ buffer))
(defun git-commit-file ()
"Commit the marked file(s), asking for a commit message."
@@ -1210,9 +1272,9 @@ Return the list of files that haven't been handled."
(coding-system (git-get-commits-coding-system))
author-name author-email subject date)
(when (eq 0 (buffer-size buffer))
- (when (file-readable-p ".dotest/info")
+ (when (file-readable-p ".git/rebase-apply/info")
(with-temp-buffer
- (insert-file-contents ".dotest/info")
+ (insert-file-contents ".git/rebase-apply/info")
(goto-char (point-min))
(when (re-search-forward "^Author: \\(.*\\)\nEmail: \\(.*\\)$" nil t)
(setq author-name (match-string 1))
@@ -1232,14 +1294,61 @@ Return the list of files that haven't been handled."
(setq buffer-file-coding-system coding-system)
(re-search-forward (regexp-quote (concat git-log-msg-separator "\n")) nil t))))
+(defun git-setup-commit-buffer (commit)
+ "Setup the commit buffer with the contents of COMMIT."
+ (let (author-name author-email subject date msg)
+ (with-temp-buffer
+ (let ((coding-system (git-get-logoutput-coding-system)))
+ (git-call-process-env t nil "log" "-1" "--pretty=medium" commit)
+ (goto-char (point-min))
+ (when (re-search-forward "^Author: *\\(.*\\) <\\(.*\\)>$" nil t)
+ (setq author-name (match-string 1))
+ (setq author-email (match-string 2)))
+ (when (re-search-forward "^Date: *\\(.*\\)$" nil t)
+ (setq date (match-string 1)))
+ (while (re-search-forward "^ \\(.*\\)$" nil t)
+ (push (match-string 1) msg))
+ (setq msg (nreverse msg))
+ (setq subject (pop msg))
+ (while (and msg (zerop (length (car msg))) (pop msg)))))
+ (git-setup-log-buffer (get-buffer-create "*git-commit*")
+ author-name author-email subject date
+ (mapconcat #'identity msg "\n"))))
+
+(defun git-get-commit-files (commit)
+ "Retrieve the list of files modified by COMMIT."
+ (let (files)
+ (with-temp-buffer
+ (git-call-process-env t nil "diff-tree" "-r" "-z" "--name-only" "--no-commit-id" commit)
+ (goto-char (point-min))
+ (while (re-search-forward "\\([^\0]*\\)\0" nil t 1)
+ (push (match-string 1) files)))
+ files))
+
+(defun git-amend-commit ()
+ "Undo the last commit on HEAD, and set things up to commit an
+amended version of it."
+ (interactive)
+ (unless git-status (error "Not in git-status buffer."))
+ (when (git-empty-db-p) (error "No commit to amend."))
+ (let* ((commit (git-rev-parse "HEAD"))
+ (files (git-get-commit-files commit)))
+ (when (git-call-process-display-error "reset" "--soft" "HEAD^")
+ (git-update-status-files (copy-sequence files) 'uptodate)
+ (git-mark-files git-status files)
+ (git-refresh-files)
+ (git-setup-commit-buffer commit)
+ (git-commit-file))))
+
(defun git-find-file ()
"Visit the current file in its own buffer."
(interactive)
(unless git-status (error "Not in git-status buffer."))
(let ((info (ewoc-data (ewoc-locate git-status))))
- (find-file (git-fileinfo->name info))
- (when (eq 'unmerged (git-fileinfo->state info))
- (smerge-mode 1))))
+ (unless (git-expand-directory info)
+ (find-file (git-fileinfo->name info))
+ (when (eq 'unmerged (git-fileinfo->state info))
+ (smerge-mode 1)))))
(defun git-find-file-other-window ()
"Visit the current file in its own buffer in another window."
@@ -1309,6 +1418,7 @@ Return the list of files that haven't been handled."
(unless git-status-mode-map
(let ((map (make-keymap))
+ (commit-map (make-sparse-keymap))
(diff-map (make-sparse-keymap))
(toggle-map (make-sparse-keymap)))
(suppress-keymap map)
@@ -1317,6 +1427,7 @@ Return the list of files that haven't been handled."
(define-key map " " 'git-next-file)
(define-key map "a" 'git-add-file)
(define-key map "c" 'git-commit-file)
+ (define-key map "\C-c" commit-map)
(define-key map "d" diff-map)
(define-key map "=" 'git-diff-file)
(define-key map "f" 'git-find-file)
@@ -1342,6 +1453,8 @@ Return the list of files that haven't been handled."
(define-key map "x" 'git-remove-handled)
(define-key map "\C-?" 'git-unmark-file-up)
(define-key map "\M-\C-?" 'git-unmark-all)
+ ; the commit submap
+ (define-key commit-map "\C-a" 'git-amend-commit)
; the diff submap
(define-key diff-map "b" 'git-diff-file-base)
(define-key diff-map "c" 'git-diff-file-combined)
@@ -1432,7 +1545,7 @@ Commands:
(with-current-buffer buffer
(when (and list-buffers-directory
(string-equal fulldir (expand-file-name list-buffers-directory))
- (string-match "\\*git-status\\*$" (buffer-name buffer)))
+ (eq major-mode 'git-status-mode))
(setq found buffer))))
(setq list (cdr list)))
found))
diff --git a/contrib/examples/git-checkout.sh b/contrib/examples/git-checkout.sh
index 5621c69d8..1a7689a48 100755
--- a/contrib/examples/git-checkout.sh
+++ b/contrib/examples/git-checkout.sh
@@ -71,7 +71,8 @@ while test $# != 0; do
done
arg="$1"
-if rev=$(git rev-parse --verify "$arg^0" 2>/dev/null)
+rev=$(git rev-parse --verify "$arg" 2>/dev/null)
+if rev=$(git rev-parse --verify "$rev^0" 2>/dev/null)
then
[ -z "$rev" ] && die "unknown flag $arg"
new_name="$arg"
@@ -82,11 +83,11 @@ then
fi
new="$rev"
shift
-elif rev=$(git rev-parse --verify "$arg^{tree}" 2>/dev/null)
+elif rev=$(git rev-parse --verify "$rev^{tree}" 2>/dev/null)
then
# checking out selected paths from a tree-ish.
new="$rev"
- new_name="$arg^{tree}"
+ new_name="$rev^{tree}"
shift
fi
[ "$1" = "--" ] && shift
@@ -209,11 +210,14 @@ then
git read-tree $v --reset -u $new
else
git update-index --refresh >/dev/null
- merge_error=$(git read-tree -m -u --exclude-per-directory=.gitignore $old $new 2>&1) || (
- case "$merge" in
- '')
- echo >&2 "$merge_error"
+ git read-tree $v -m -u --exclude-per-directory=.gitignore $old $new || (
+ case "$merge,$v" in
+ ,*)
exit 1 ;;
+ 1,)
+ ;; # quiet
+ *)
+ echo >&2 "Falling back to 3-way merge..." ;;
esac
# Match the index to the working tree, and do a three-way.
diff --git a/git-clone.sh b/contrib/examples/git-clone.sh
index b4e858c38..547228e13 100755
--- a/git-clone.sh
+++ b/contrib/examples/git-clone.sh
@@ -210,11 +210,29 @@ if base=$(get_repo_base "$repo"); then
then
local=yes
fi
+elif test -f "$repo"
+then
+ case "$repo" in /*) ;; *) repo="$PWD/$repo" ;; esac
+fi
+
+# Decide the directory name of the new repository
+if test -n "$2"
+then
+ dir="$2"
+ test $# = 2 || die "excess parameter to git-clone"
+else
+ # Derive one from the repository name
+ # Try using "humanish" part of source repo if user didn't specify one
+ if test -f "$repo"
+ then
+ # Cloning from a bundle
+ dir=$(echo "$repo" | sed -e 's|/*\.bundle$||' -e 's|.*/||g')
+ else
+ dir=$(echo "$repo" |
+ sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
+ fi
fi
-dir="$2"
-# Try using "humanish" part of source repo if user didn't specify one
-[ -z "$dir" ] && dir=$(echo "$repo" | sed -e 's|/$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
[ -e "$dir" ] && die "destination directory '$dir' already exists."
[ yes = "$bare" ] && unset GIT_WORK_TREE
[ -n "$GIT_WORK_TREE" ] && [ -e "$GIT_WORK_TREE" ] &&
@@ -222,7 +240,6 @@ die "working tree '$GIT_WORK_TREE' already exists."
D=
W=
cleanup() {
- err=$?
test -z "$D" && rm -rf "$dir"
test -z "$W" && test -n "$GIT_WORK_TREE" && rm -rf "$GIT_WORK_TREE"
cd ..
@@ -230,7 +247,7 @@ cleanup() {
test -n "$W" && rm -rf "$W"
exit $err
}
-trap cleanup 0
+trap 'err=$?; cleanup' 0
mkdir -p "$dir" && D=$(cd "$dir" && pwd) || usage
test -n "$GIT_WORK_TREE" && mkdir -p "$GIT_WORK_TREE" &&
W=$(cd "$GIT_WORK_TREE" && pwd) && GIT_WORK_TREE="$W" && export GIT_WORK_TREE
@@ -293,6 +310,9 @@ yes)
mkdir -p "$GIT_DIR/objects/info"
echo "$repo/objects" >>"$GIT_DIR/objects/info/alternates"
else
+ cpio_quiet_flag=""
+ cpio --help 2>&1 | grep -- --quiet >/dev/null && \
+ cpio_quiet_flag=--quiet
l= &&
if test "$use_local_hardlink" = yes
then
@@ -313,7 +333,11 @@ yes)
fi
fi &&
cd "$repo" &&
- find objects -depth -print | cpio -pumd$l "$GIT_DIR/" || exit 1
+ # Create dirs using umask and permissions and destination
+ find objects -type d -print | (cd "$GIT_DIR" && xargs mkdir -p) &&
+ # Copy existing 0444 permissions on content
+ find objects ! -type d -print | cpio $cpio_quiet_flag -pumd$l "$GIT_DIR/" || \
+ exit 1
fi
git-ls-remote "$repo" >"$GIT_DIR/CLONE_HEAD" || exit 1
;;
@@ -364,11 +388,17 @@ yes)
fi
;;
*)
- case "$upload_pack" in
- '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
- *) git-fetch-pack --all -k $quiet "$upload_pack" $depth $no_progress "$repo" ;;
- esac >"$GIT_DIR/CLONE_HEAD" ||
+ if [ -f "$repo" ] ; then
+ git bundle unbundle "$repo" > "$GIT_DIR/CLONE_HEAD" ||
+ die "unbundle from '$repo' failed."
+ else
+ case "$upload_pack" in
+ '') git-fetch-pack --all -k $quiet $depth $no_progress "$repo";;
+ *) git-fetch-pack --all -k \
+ $quiet "$upload_pack" $depth $no_progress "$repo" ;;
+ esac >"$GIT_DIR/CLONE_HEAD" ||
die "fetch-pack from '$repo' failed."
+ fi
;;
esac
;;
@@ -409,11 +439,12 @@ else
cd "$D" || exit
fi
-if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
+if test -z "$bare"
then
# a non-bare repository is always in separate-remote layout
remote_top="refs/remotes/$origin"
- head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
+ head_sha1=
+ test ! -r "$GIT_DIR/REMOTE_HEAD" || head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
case "$head_sha1" in
'ref: refs/'*)
# Uh-oh, the remote told us (http transport done against
@@ -470,9 +501,16 @@ then
git config branch."$head_points_at".merge "refs/heads/$head_points_at"
;;
'')
- # Source had detached HEAD pointing nowhere
- git update-ref --no-deref HEAD "$head_sha1" &&
- rm -f "refs/remotes/$origin/HEAD"
+ if test -z "$head_sha1"
+ then
+ # Source had nonexistent ref in HEAD
+ echo >&2 "Warning: Remote HEAD refers to nonexistent ref, unable to checkout."
+ no_checkout=t
+ else
+ # Source had detached HEAD pointing nowhere
+ git update-ref --no-deref HEAD "$head_sha1" &&
+ rm -f "refs/remotes/$origin/HEAD"
+ fi
;;
esac
diff --git a/contrib/examples/git-commit.sh b/contrib/examples/git-commit.sh
index 2c4a4062a..5c72f655c 100755
--- a/contrib/examples/git-commit.sh
+++ b/contrib/examples/git-commit.sh
@@ -443,7 +443,7 @@ fi | git stripspace >"$GIT_DIR"/COMMIT_EDITMSG
case "$signoff" in
t)
- sign=$(git-var GIT_COMMITTER_IDENT | sed -e '
+ sign=$(git var GIT_COMMITTER_IDENT | sed -e '
s/>.*/>/
s/^/Signed-off-by: /
')
@@ -535,8 +535,8 @@ esac
case "$no_edit" in
'')
- git-var GIT_AUTHOR_IDENT > /dev/null || die
- git-var GIT_COMMITTER_IDENT > /dev/null || die
+ git var GIT_AUTHOR_IDENT > /dev/null || die
+ git var GIT_COMMITTER_IDENT > /dev/null || die
git_editor "$GIT_DIR/COMMIT_EDITMSG"
;;
esac
diff --git a/git-merge.sh b/contrib/examples/git-merge.sh
index 1c123a37e..e9588eec3 100755
--- a/git-merge.sh
+++ b/contrib/examples/git-merge.sh
@@ -5,13 +5,15 @@
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
-git-merge [options] <remote>...
-git-merge [options] <msg> HEAD <remote>
+git merge [options] <remote>...
+git merge [options] <msg> HEAD <remote>
--
-summary show a diffstat at the end of the merge
-n,no-summary don't show a diffstat at the end of the merge
+stat show a diffstat at the end of the merge
+n don't show a diffstat at the end of the merge
+summary (synonym to --stat)
+log add list of one-line log to merge commit message
squash create a single commit instead of doing a merge
-commit perform a commit if the merge sucesses (default)
+commit perform a commit if the merge succeeds (default)
ff allow fast forward (default)
s,strategy= merge strategy to use
m,message= message to be used for the merge commit (if any)
@@ -37,6 +39,7 @@ use_strategies=
allow_fast_forward=t
allow_trivial_merge=t
+squash= no_commit= log_arg=
dropsave() {
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -70,7 +73,7 @@ finish_up_to_date () {
squash_message () {
echo Squashed commit of the following:
echo
- git log --no-merges ^"$head" $remoteheads
+ git log --no-merges --pretty=medium ^"$head" $remoteheads
}
finish () {
@@ -147,22 +150,28 @@ merge_name () {
parse_config () {
while test $# != 0; do
case "$1" in
- -n|--no-summary)
+ -n|--no-stat|--no-summary)
show_diffstat=false ;;
- --summary)
+ --stat|--summary)
show_diffstat=t ;;
+ --log|--no-log)
+ log_arg=$1 ;;
--squash)
- allow_fast_forward=t squash=t no_commit=t ;;
+ test "$allow_fast_forward" = t ||
+ die "You cannot combine --squash with --no-ff."
+ squash=t no_commit=t ;;
--no-squash)
- allow_fast_forward=t squash= no_commit= ;;
+ squash= no_commit= ;;
--commit)
- allow_fast_forward=t squash= no_commit= ;;
+ no_commit= ;;
--no-commit)
- allow_fast_forward=t squash= no_commit=t ;;
+ no_commit=t ;;
--ff)
- allow_fast_forward=t squash= no_commit= ;;
+ allow_fast_forward=t ;;
--no-ff)
- allow_fast_forward=false squash= no_commit= ;;
+ test "$squash" != t ||
+ die "You cannot combine --squash with --no-ff."
+ allow_fast_forward=f ;;
-s|--strategy)
shift
case " $all_strategies " in
@@ -205,6 +214,7 @@ while test $args_left -lt $#; do shift; done
if test -z "$show_diffstat"; then
test "$(git config --bool merge.diffstat)" = false && show_diffstat=false
+ test "$(git config --bool merge.stat)" = false && show_diffstat=false
test -z "$show_diffstat" && show_diffstat=t
fi
@@ -253,7 +263,7 @@ else
merge_name=$(for remote
do
merge_name "$remote"
- done | git fmt-merge-msg
+ done | git fmt-merge-msg $log_arg
)
merge_msg="${merge_msg:+$merge_msg$LF$LF}$merge_name"
fi
diff --git a/git-remote.perl b/contrib/examples/git-remote.perl
index d13e4c1fe..36bd54c98 100755
--- a/git-remote.perl
+++ b/contrib/examples/git-remote.perl
@@ -1,15 +1,16 @@
#!/usr/bin/perl -w
+use strict;
use Git;
my $git = Git->repository();
sub add_remote_config {
my ($hash, $name, $what, $value) = @_;
if ($what eq 'url') {
- if (exists $hash->{$name}{'URL'}) {
- print STDERR "Warning: more than one remote.$name.url\n";
+ # Having more than one is Ok -- it is used for push.
+ if (! exists $hash->{'URL'}) {
+ $hash->{$name}{'URL'} = $value;
}
- $hash->{$name}{'URL'} = $value;
}
elsif ($what eq 'fetch') {
$hash->{$name}{'FETCH'} ||= [];
@@ -128,10 +129,7 @@ sub update_ls_remote {
return if (($harder == 0) ||
(($harder == 1) && exists $info->{'LS_REMOTE'}));
- my @ref = map {
- s|^[0-9a-f]{40}\s+refs/heads/||;
- $_;
- } $git->command(qw(ls-remote --heads), $info->{'URL'});
+ my @ref = map { s|refs/heads/||; $_; } keys %{$git->remote_refs($info->{'URL'}, [ 'heads' ])};
$info->{'LS_REMOTE'} = \@ref;
}
@@ -296,12 +294,13 @@ sub add_remote {
sub update_remote {
my ($name) = @_;
+ my @remotes;
my $conf = $git->config("remotes." . $name);
if (defined($conf)) {
@remotes = split(' ', $conf);
} elsif ($name eq 'default') {
- undef @remotes;
+ @remotes = ();
for (sort keys %$remote) {
my $do_fetch = $git->config_bool("remote." . $_ .
".skipDefaultUpdate");
@@ -341,7 +340,7 @@ sub rm_remote {
my @refs = $git->command('for-each-ref',
'--format=%(refname) %(objectname)', "refs/remotes/$name");
for (@refs) {
- ($ref, $object) = split;
+ my ($ref, $object) = split;
$git->command(qw(update-ref -d), $ref, $object);
}
return 0;
@@ -352,7 +351,7 @@ sub add_usage {
exit(1);
}
-local $VERBOSE = 0;
+my $VERBOSE = 0;
@ARGV = grep {
if ($_ eq '-v' or $_ eq '--verbose') {
$VERBOSE=1;
@@ -395,7 +394,7 @@ elsif ($ARGV[0] eq 'update') {
update_remote("default");
exit(1);
}
- for ($i = 1; $i < @ARGV; $i++) {
+ for (my $i = 1; $i < @ARGV; $i++) {
update_remote($ARGV[$i]);
}
}
diff --git a/contrib/examples/git-rerere.perl b/contrib/examples/git-rerere.perl
new file mode 100755
index 000000000..4f692091e
--- /dev/null
+++ b/contrib/examples/git-rerere.perl
@@ -0,0 +1,284 @@
+#!/usr/bin/perl
+#
+# REuse REcorded REsolve. This tool records a conflicted automerge
+# result and its hand resolution, and helps to resolve future
+# automerge that results in the same conflict.
+#
+# To enable this feature, create a directory 'rr-cache' under your
+# .git/ directory.
+
+use Digest;
+use File::Path;
+use File::Copy;
+
+my $git_dir = $::ENV{GIT_DIR} || ".git";
+my $rr_dir = "$git_dir/rr-cache";
+my $merge_rr = "$git_dir/rr-cache/MERGE_RR";
+
+my %merge_rr = ();
+
+sub read_rr {
+ if (!-f $merge_rr) {
+ %merge_rr = ();
+ return;
+ }
+ my $in;
+ local $/ = "\0";
+ open $in, "<$merge_rr" or die "$!: $merge_rr";
+ while (<$in>) {
+ chomp;
+ my ($name, $path) = /^([0-9a-f]{40})\t(.*)$/s;
+ $merge_rr{$path} = $name;
+ }
+ close $in;
+}
+
+sub write_rr {
+ my $out;
+ open $out, ">$merge_rr" or die "$!: $merge_rr";
+ for my $path (sort keys %merge_rr) {
+ my $name = $merge_rr{$path};
+ print $out "$name\t$path\0";
+ }
+ close $out;
+}
+
+sub compute_conflict_name {
+ my ($path) = @_;
+ my @side = ();
+ my $in;
+ open $in, "<$path" or die "$!: $path";
+
+ my $sha1 = Digest->new("SHA-1");
+ my $hunk = 0;
+ while (<$in>) {
+ if (/^<<<<<<< .*/) {
+ $hunk++;
+ @side = ([], undef);
+ }
+ elsif (/^=======$/) {
+ $side[1] = [];
+ }
+ elsif (/^>>>>>>> .*/) {
+ my ($one, $two);
+ $one = join('', @{$side[0]});
+ $two = join('', @{$side[1]});
+ if ($two le $one) {
+ ($one, $two) = ($two, $one);
+ }
+ $sha1->add($one);
+ $sha1->add("\0");
+ $sha1->add($two);
+ $sha1->add("\0");
+ @side = ();
+ }
+ elsif (@side == 0) {
+ next;
+ }
+ elsif (defined $side[1]) {
+ push @{$side[1]}, $_;
+ }
+ else {
+ push @{$side[0]}, $_;
+ }
+ }
+ close $in;
+ return ($sha1->hexdigest, $hunk);
+}
+
+sub record_preimage {
+ my ($path, $name) = @_;
+ my @side = ();
+ my ($in, $out);
+ open $in, "<$path" or die "$!: $path";
+ open $out, ">$name" or die "$!: $name";
+
+ while (<$in>) {
+ if (/^<<<<<<< .*/) {
+ @side = ([], undef);
+ }
+ elsif (/^=======$/) {
+ $side[1] = [];
+ }
+ elsif (/^>>>>>>> .*/) {
+ my ($one, $two);
+ $one = join('', @{$side[0]});
+ $two = join('', @{$side[1]});
+ if ($two le $one) {
+ ($one, $two) = ($two, $one);
+ }
+ print $out "<<<<<<<\n";
+ print $out $one;
+ print $out "=======\n";
+ print $out $two;
+ print $out ">>>>>>>\n";
+ @side = ();
+ }
+ elsif (@side == 0) {
+ print $out $_;
+ }
+ elsif (defined $side[1]) {
+ push @{$side[1]}, $_;
+ }
+ else {
+ push @{$side[0]}, $_;
+ }
+ }
+ close $out;
+ close $in;
+}
+
+sub find_conflict {
+ my $in;
+ local $/ = "\0";
+ my $pid = open($in, '-|');
+ die "$!" unless defined $pid;
+ if (!$pid) {
+ exec(qw(git ls-files -z -u)) or die "$!: ls-files";
+ }
+ my %path = ();
+ my @path = ();
+ while (<$in>) {
+ chomp;
+ my ($mode, $sha1, $stage, $path) =
+ /^([0-7]+) ([0-9a-f]{40}) ([123])\t(.*)$/s;
+ $path{$path} |= (1 << $stage);
+ }
+ close $in;
+ while (my ($path, $status) = each %path) {
+ if ($status == 14) { push @path, $path; }
+ }
+ return @path;
+}
+
+sub merge {
+ my ($name, $path) = @_;
+ record_preimage($path, "$rr_dir/$name/thisimage");
+ unless (system('git', 'merge-file', map { "$rr_dir/$name/${_}image" }
+ qw(this pre post))) {
+ my $in;
+ open $in, "<$rr_dir/$name/thisimage" or
+ die "$!: $name/thisimage";
+ my $out;
+ open $out, ">$path" or die "$!: $path";
+ while (<$in>) { print $out $_; }
+ close $in;
+ close $out;
+ return 1;
+ }
+ return 0;
+}
+
+sub garbage_collect_rerere {
+ # We should allow specifying these from the command line and
+ # that is why the caller gives @ARGV to us, but I am lazy.
+
+ my $cutoff_noresolve = 15; # two weeks
+ my $cutoff_resolve = 60; # two months
+ my @to_remove;
+ while (<$rr_dir/*/preimage>) {
+ my ($dir) = /^(.*)\/preimage$/;
+ my $cutoff = ((-f "$dir/postimage")
+ ? $cutoff_resolve
+ : $cutoff_noresolve);
+ my $age = -M "$_";
+ if ($cutoff <= $age) {
+ push @to_remove, $dir;
+ }
+ }
+ if (@to_remove) {
+ rmtree(\@to_remove);
+ }
+}
+
+-d "$rr_dir" || exit(0);
+
+read_rr();
+
+if (@ARGV) {
+ my $arg = shift @ARGV;
+ if ($arg eq 'clear') {
+ for my $path (keys %merge_rr) {
+ my $name = $merge_rr{$path};
+ if (-d "$rr_dir/$name" &&
+ ! -f "$rr_dir/$name/postimage") {
+ rmtree(["$rr_dir/$name"]);
+ }
+ }
+ unlink $merge_rr;
+ }
+ elsif ($arg eq 'status') {
+ for my $path (keys %merge_rr) {
+ print $path, "\n";
+ }
+ }
+ elsif ($arg eq 'diff') {
+ for my $path (keys %merge_rr) {
+ my $name = $merge_rr{$path};
+ system('diff', ((@ARGV == 0) ? ('-u') : @ARGV),
+ '-L', "a/$path", '-L', "b/$path",
+ "$rr_dir/$name/preimage", $path);
+ }
+ }
+ elsif ($arg eq 'gc') {
+ garbage_collect_rerere(@ARGV);
+ }
+ else {
+ die "$0 unknown command: $arg\n";
+ }
+ exit 0;
+}
+
+my %conflict = map { $_ => 1 } find_conflict();
+
+# MERGE_RR records paths with conflicts immediately after merge
+# failed. Some of the conflicted paths might have been hand resolved
+# in the working tree since then, but the initial run would catch all
+# and register their preimages.
+
+for my $path (keys %conflict) {
+ # This path has conflict. If it is not recorded yet,
+ # record the pre-image.
+ if (!exists $merge_rr{$path}) {
+ my ($name, $hunk) = compute_conflict_name($path);
+ next unless ($hunk);
+ $merge_rr{$path} = $name;
+ if (! -d "$rr_dir/$name") {
+ mkpath("$rr_dir/$name", 0, 0777);
+ print STDERR "Recorded preimage for '$path'\n";
+ record_preimage($path, "$rr_dir/$name/preimage");
+ }
+ }
+}
+
+# Now some of the paths that had conflicts earlier might have been
+# hand resolved. Others may be similar to a conflict already that
+# was resolved before.
+
+for my $path (keys %merge_rr) {
+ my $name = $merge_rr{$path};
+
+ # We could resolve this automatically if we have images.
+ if (-f "$rr_dir/$name/preimage" &&
+ -f "$rr_dir/$name/postimage") {
+ if (merge($name, $path)) {
+ print STDERR "Resolved '$path' using previous resolution.\n";
+ # Then we do not have to worry about this path
+ # anymore.
+ delete $merge_rr{$path};
+ next;
+ }
+ }
+
+ # Let's see if we have resolved it.
+ (undef, my $hunk) = compute_conflict_name($path);
+ next if ($hunk);
+
+ print STDERR "Recorded resolution for '$path'.\n";
+ copy($path, "$rr_dir/$name/postimage");
+ # And we do not have to worry about this path anymore.
+ delete $merge_rr{$path};
+}
+
+# Write out the rest.
+write_rr();
diff --git a/contrib/examples/git-svnimport.perl b/contrib/examples/git-svnimport.perl
index ea8c1b2f6..a13bb6afe 100755
--- a/contrib/examples/git-svnimport.perl
+++ b/contrib/examples/git-svnimport.perl
@@ -933,7 +933,7 @@ while ($to_rev < $opt_l) {
$to_rev = $from_rev + $repack_after;
$to_rev = $opt_l if $opt_l < $to_rev;
print "Fetching from $from_rev to $to_rev ...\n" if $opt_v;
- $svn->{'svn'}->get_log("/",$from_rev,$to_rev,0,1,1,\&commit_all);
+ $svn->{'svn'}->get_log("",$from_rev,$to_rev,0,1,1,\&commit_all);
my $pid = fork();
die "Fork: $!\n" unless defined $pid;
unless($pid) {
diff --git a/contrib/examples/git-tag.sh b/contrib/examples/git-tag.sh
index e9f3a228a..2c15bc955 100755
--- a/contrib/examples/git-tag.sh
+++ b/contrib/examples/git-tag.sh
@@ -164,7 +164,7 @@ git check-ref-format "tags/$name" ||
object=$(git rev-parse --verify --default HEAD "$@") || exit 1
type=$(git cat-file -t $object) || exit 1
-tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
+tagger=$(git var GIT_COMMITTER_IDENT) || exit 1
test -n "$username" ||
username=$(git config user.signingkey) ||
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index c80a6da25..f9865b444 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,46 @@ from sets import Set;
verbose = False
+
+def p4_build_cmd(cmd):
+ """Build a suitable p4 command line.
+
+ This consolidates building and returning a p4 command line into one
+ location. It means that hooking into the environment, or other configuration
+ can be done more easily.
+ """
+ real_cmd = "%s " % "p4"
+
+ user = gitConfig("git-p4.user")
+ if len(user) > 0:
+ real_cmd += "-u %s " % user
+
+ password = gitConfig("git-p4.password")
+ if len(password) > 0:
+ real_cmd += "-P %s " % password
+
+ port = gitConfig("git-p4.port")
+ if len(port) > 0:
+ real_cmd += "-p %s " % port
+
+ host = gitConfig("git-p4.host")
+ if len(host) > 0:
+ real_cmd += "-h %s " % host
+
+ client = gitConfig("git-p4.client")
+ if len(client) > 0:
+ real_cmd += "-c %s " % client
+
+ real_cmd += "%s" % (cmd)
+ if verbose:
+ print real_cmd
+ return real_cmd
+
+def chdir(dir):
+ if os.name == 'nt':
+ os.environ['PWD']=dir
+ os.chdir(dir)
+
def die(msg):
if verbose:
raise Exception(msg)
@@ -34,6 +74,10 @@ def write_pipe(c, str):
return val
+def p4_write_pipe(c, str):
+ real_cmd = p4_build_cmd(c)
+ return write_pipe(c, str)
+
def read_pipe(c, ignore_error=False):
if verbose:
sys.stderr.write('Reading pipe: %s\n' % c)
@@ -45,6 +89,9 @@ def read_pipe(c, ignore_error=False):
return val
+def p4_read_pipe(c, ignore_error=False):
+ real_cmd = p4_build_cmd(c)
+ return read_pipe(real_cmd, ignore_error)
def read_pipe_lines(c):
if verbose:
@@ -57,12 +104,22 @@ def read_pipe_lines(c):
return val
+def p4_read_pipe_lines(c):
+ """Specifically invoke p4 on the command supplied. """
+ real_cmd = p4_build_cmd(c)
+ return read_pipe_lines(real_cmd)
+
def system(cmd):
if verbose:
sys.stderr.write("executing %s\n" % cmd)
if os.system(cmd) != 0:
die("command failed: %s" % cmd)
+def p4_system(cmd):
+ """Specifically invoke p4 as the system command. """
+ real_cmd = p4_build_cmd(cmd)
+ return system(real_cmd)
+
def isP4Exec(kind):
"""Determine if a Perforce 'kind' should have execute permission
@@ -84,17 +141,17 @@ def setP4ExecBit(file, mode):
if p4Type[-1] == "+":
p4Type = p4Type[0:-1]
- system("p4 reopen -t %s %s" % (p4Type, file))
+ p4_system("reopen -t %s %s" % (p4Type, file))
def getP4OpenedType(file):
# Returns the perforce file type for the given file.
- result = read_pipe("p4 opened %s" % file)
- match = re.match(".*\((.+)\)$", result)
+ result = p4_read_pipe("opened %s" % file)
+ match = re.match(".*\((.+)\)\r?$", result)
if match:
return match.group(1)
else:
- die("Could not determine file type for %s" % file)
+ die("Could not determine file type for %s (result: '%s')" % (file, result))
def diffTreePattern():
# This is a simple generator for the diff tree regex pattern. This could be
@@ -145,7 +202,7 @@ def isModeExecChanged(src_mode, dst_mode):
return isModeExec(src_mode) != isModeExec(dst_mode)
def p4CmdList(cmd, stdin=None, stdin_mode='w+b'):
- cmd = "p4 -G %s" % cmd
+ cmd = p4_build_cmd("-G %s" % (cmd))
if verbose:
sys.stderr.write("Opening pipe: %s\n" % cmd)
@@ -364,7 +421,7 @@ def originP4BranchesExist():
def p4ChangesForPaths(depotPaths, changeRange):
assert depotPaths
- output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, changeRange)
+ output = p4_read_pipe_lines("changes " + ' '.join (["%s...%s" % (p, changeRange)
for p in depotPaths]))
changes = []
@@ -464,75 +521,47 @@ class P4Submit(Command):
def __init__(self):
Command.__init__(self)
self.options = [
- optparse.make_option("--continue", action="store_false", dest="firstTime"),
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--origin", dest="origin"),
- optparse.make_option("--reset", action="store_true", dest="reset"),
- optparse.make_option("--log-substitutions", dest="substFile"),
- optparse.make_option("--dry-run", action="store_true"),
- optparse.make_option("--direct", dest="directSubmit", action="store_true"),
- optparse.make_option("--trust-me-like-a-fool", dest="trustMeLikeAFool", action="store_true"),
optparse.make_option("-M", dest="detectRename", action="store_true"),
]
self.description = "Submit changes from git to the perforce depot."
self.usage += " [name of git branch to submit into perforce depot]"
- self.firstTime = True
- self.reset = False
self.interactive = True
- self.dryRun = False
- self.substFile = ""
- self.firstTime = True
self.origin = ""
- self.directSubmit = False
- self.trustMeLikeAFool = False
self.detectRename = False
self.verbose = False
self.isWindows = (platform.system() == "Windows")
- self.logSubstitutions = {}
- self.logSubstitutions["<enter description here>"] = "%log%"
- self.logSubstitutions["\tDetails:"] = "\tDetails: %log%"
-
def check(self):
if len(p4CmdList("opened ...")) > 0:
die("You have files opened with perforce! Close them before starting the sync.")
- def start(self):
- if len(self.config) > 0 and not self.reset:
- die("Cannot start sync. Previous sync config found at %s\n"
- "If you want to start submitting again from scratch "
- "maybe you want to call git-p4 submit --reset" % self.configFile)
-
- commits = []
- if self.directSubmit:
- commits.append("0")
- else:
- for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
- commits.append(line.strip())
- commits.reverse()
-
- self.config["commits"] = commits
-
+ # replaces everything between 'Description:' and the next P4 submit template field with the
+ # commit message
def prepareLogMessage(self, template, message):
result = ""
+ inDescriptionSection = False
+
for line in template.split("\n"):
if line.startswith("#"):
result += line + "\n"
continue
- substituted = False
- for key in self.logSubstitutions.keys():
- if line.find(key) != -1:
- value = self.logSubstitutions[key]
- value = value.replace("%log%", message)
- if value != "@remove@":
- result += line.replace(key, value) + "\n"
- substituted = True
- break
+ if inDescriptionSection:
+ if line.startswith("Files:"):
+ inDescriptionSection = False
+ else:
+ continue
+ else:
+ if line.startswith("Description:"):
+ inDescriptionSection = True
+ line += "\n"
+ for messageLine in message.split("\n"):
+ line += "\t" + messageLine + "\n"
- if not substituted:
- result += line + "\n"
+ result += line + "\n"
return result
@@ -540,7 +569,9 @@ class P4Submit(Command):
# remove lines in the Files section that show changes to files outside the depot path we're committing into
template = ""
inFilesSection = False
- for line in read_pipe_lines("p4 change -o"):
+ for line in p4_read_pipe_lines("change -o"):
+ if line.endswith("\r\n"):
+ line = line[:-2] + "\n"
if inFilesSection:
if line.startswith("\t"):
# path starts and ends with a tab
@@ -561,13 +592,9 @@ class P4Submit(Command):
return template
def applyCommit(self, id):
- if self.directSubmit:
- print "Applying local change in working directory/index"
- diff = self.diffStatus
- else:
- print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
- diffOpts = ("", "-M")[self.detectRename]
- diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
+ print "Applying %s" % (read_pipe("git log --max-count=1 --pretty=oneline %s" % id))
+ diffOpts = ("", "-M")[self.detectRename]
+ diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
filesToAdd = set()
filesToDelete = set()
editedFiles = set()
@@ -577,7 +604,7 @@ class P4Submit(Command):
modifier = diff['status']
path = diff['src']
if modifier == "M":
- system("p4 edit \"%s\"" % path)
+ p4_system("edit \"%s\"" % path)
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
filesToChangeExecBit[path] = diff['dst_mode']
editedFiles.add(path)
@@ -592,8 +619,8 @@ class P4Submit(Command):
filesToAdd.remove(path)
elif modifier == "R":
src, dest = diff['src'], diff['dst']
- system("p4 integrate -Dt \"%s\" \"%s\"" % (src, dest))
- system("p4 edit \"%s\"" % (dest))
+ p4_system("integrate -Dt \"%s\" \"%s\"" % (src, dest))
+ p4_system("edit \"%s\"" % (dest))
if isModeExecChanged(diff['src_mode'], diff['dst_mode']):
filesToChangeExecBit[dest] = diff['dst_mode']
os.unlink(dest)
@@ -602,10 +629,7 @@ class P4Submit(Command):
else:
die("unknown modifier %s for %s" % (modifier, path))
- if self.directSubmit:
- diffcmd = "cat \"%s\"" % self.diffFile
- else:
- diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
+ diffcmd = "git format-patch -k --stdout \"%s^\"..\"%s\"" % (id, id)
patchcmd = diffcmd + " | git apply "
tryPatchCmd = patchcmd + "--check -"
applyPatchCmd = patchcmd + "--check --apply -"
@@ -620,7 +644,7 @@ class P4Submit(Command):
if response == "s":
print "Skipping! Good luck with the next patches..."
for f in editedFiles:
- system("p4 revert \"%s\"" % f);
+ p4_system("revert \"%s\"" % f);
for f in filesToAdd:
system("rm %s" %f)
return
@@ -643,95 +667,64 @@ class P4Submit(Command):
system(applyPatchCmd)
for f in filesToAdd:
- system("p4 add \"%s\"" % f)
+ p4_system("add \"%s\"" % f)
for f in filesToDelete:
- system("p4 revert \"%s\"" % f)
- system("p4 delete \"%s\"" % f)
+ p4_system("revert \"%s\"" % f)
+ p4_system("delete \"%s\"" % f)
# Set/clear executable bits
for f in filesToChangeExecBit.keys():
mode = filesToChangeExecBit[f]
setP4ExecBit(f, mode)
- logMessage = ""
- if not self.directSubmit:
- logMessage = extractLogMessageFromGitCommit(id)
- logMessage = logMessage.replace("\n", "\n\t")
- if self.isWindows:
- logMessage = logMessage.replace("\n", "\r\n")
- logMessage = logMessage.strip()
+ logMessage = extractLogMessageFromGitCommit(id)
+ logMessage = logMessage.strip()
template = self.prepareSubmitTemplate()
if self.interactive:
submitTemplate = self.prepareLogMessage(template, logMessage)
- diff = read_pipe("p4 diff -du ...")
+ if os.environ.has_key("P4DIFF"):
+ del(os.environ["P4DIFF"])
+ diff = p4_read_pipe("diff -du ...")
+ newdiff = ""
for newFile in filesToAdd:
- diff += "==== new file ====\n"
- diff += "--- /dev/null\n"
- diff += "+++ %s\n" % newFile
+ newdiff += "==== new file ====\n"
+ newdiff += "--- /dev/null\n"
+ newdiff += "+++ %s\n" % newFile
f = open(newFile, "r")
for line in f.readlines():
- diff += "+" + line
+ newdiff += "+" + line
f.close()
- separatorLine = "######## everything below this line is just the diff #######"
+ separatorLine = "######## everything below this line is just the diff #######\n"
+
+ [handle, fileName] = tempfile.mkstemp()
+ tmpFile = os.fdopen(handle, "w+")
+ if self.isWindows:
+ submitTemplate = submitTemplate.replace("\n", "\r\n")
+ separatorLine = separatorLine.replace("\n", "\r\n")
+ newdiff = newdiff.replace("\n", "\r\n")
+ tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
+ tmpFile.close()
+ defaultEditor = "vi"
if platform.system() == "Windows":
- separatorLine += "\r"
- separatorLine += "\n"
-
- response = "e"
- if self.trustMeLikeAFool:
- response = "y"
-
- firstIteration = True
- while response == "e":
- if not firstIteration:
- response = raw_input("Do you want to submit this change? [y]es/[e]dit/[n]o/[s]kip ")
- firstIteration = False
- if response == "e":
- [handle, fileName] = tempfile.mkstemp()
- tmpFile = os.fdopen(handle, "w+")
- tmpFile.write(submitTemplate + separatorLine + diff)
- tmpFile.close()
- defaultEditor = "vi"
- if platform.system() == "Windows":
- defaultEditor = "notepad"
- editor = os.environ.get("EDITOR", defaultEditor);
- system(editor + " " + fileName)
- tmpFile = open(fileName, "rb")
- message = tmpFile.read()
- tmpFile.close()
- os.remove(fileName)
- submitTemplate = message[:message.index(separatorLine)]
- if self.isWindows:
- submitTemplate = submitTemplate.replace("\r\n", "\n")
-
- if response == "y" or response == "yes":
- if self.dryRun:
- print submitTemplate
- raw_input("Press return to continue...")
- else:
- if self.directSubmit:
- print "Submitting to git first"
- os.chdir(self.oldWorkingDirectory)
- write_pipe("git commit -a -F -", submitTemplate)
- os.chdir(self.clientPath)
-
- write_pipe("p4 submit -i", submitTemplate)
- elif response == "s":
- for f in editedFiles:
- system("p4 revert \"%s\"" % f);
- for f in filesToAdd:
- system("p4 revert \"%s\"" % f);
- system("rm %s" %f)
- for f in filesToDelete:
- system("p4 delete \"%s\"" % f);
- return
+ defaultEditor = "notepad"
+ if os.environ.has_key("P4EDITOR"):
+ editor = os.environ.get("P4EDITOR")
else:
- print "Not submitting!"
- self.interactive = False
+ editor = os.environ.get("EDITOR", defaultEditor);
+ system(editor + " " + fileName)
+ tmpFile = open(fileName, "rb")
+ message = tmpFile.read()
+ tmpFile.close()
+ os.remove(fileName)
+ submitTemplate = message[:message.index(separatorLine)]
+ if self.isWindows:
+ submitTemplate = submitTemplate.replace("\r\n", "\n")
+
+ p4_write_pipe("submit -i", submitTemplate)
else:
fileName = "submit.txt"
file = open(fileName, "w+")
@@ -751,6 +744,10 @@ class P4Submit(Command):
else:
return False
+ allowSubmit = gitConfig("git-p4.allowSubmit")
+ if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
+ die("%s is not in git-p4.allowSubmit" % self.master)
+
[upstream, settings] = findUpstreamBranchPoint()
self.depotPath = settings['depot-paths'][0]
if len(self.origin) == 0:
@@ -772,67 +769,33 @@ class P4Submit(Command):
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
self.oldWorkingDirectory = os.getcwd()
- if self.directSubmit:
- self.diffStatus = read_pipe_lines("git diff -r --name-status HEAD")
- if len(self.diffStatus) == 0:
- print "No changes in working directory to submit."
- return True
- patch = read_pipe("git diff -p --binary --diff-filter=ACMRTUXB HEAD")
- self.diffFile = self.gitdir + "/p4-git-diff"
- f = open(self.diffFile, "wb")
- f.write(patch)
- f.close();
-
- os.chdir(self.clientPath)
+ chdir(self.clientPath)
print "Syncronizing p4 checkout..."
- system("p4 sync ...")
-
- if self.reset:
- self.firstTime = True
-
- if len(self.substFile) > 0:
- for line in open(self.substFile, "r").readlines():
- tokens = line.strip().split("=")
- self.logSubstitutions[tokens[0]] = tokens[1]
+ p4_system("sync ...")
self.check()
- self.configFile = self.gitdir + "/p4-git-sync.cfg"
- self.config = shelve.open(self.configFile, writeback=True)
-
- if self.firstTime:
- self.start()
- commits = self.config.get("commits", [])
+ commits = []
+ for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
+ commits.append(line.strip())
+ commits.reverse()
while len(commits) > 0:
- self.firstTime = False
commit = commits[0]
commits = commits[1:]
- self.config["commits"] = commits
self.applyCommit(commit)
if not self.interactive:
break
- self.config.close()
-
- if self.directSubmit:
- os.remove(self.diffFile)
-
if len(commits) == 0:
- if self.firstTime:
- print "No changes found to apply between %s and current HEAD" % self.origin
- else:
- print "All changes applied!"
- os.chdir(self.oldWorkingDirectory)
+ print "All changes applied!"
+ chdir(self.oldWorkingDirectory)
- sync = P4Sync()
- sync.run([])
+ sync = P4Sync()
+ sync.run([])
- response = raw_input("Do you want to rebase current HEAD from Perforce now using git-p4 rebase? [y]es/[n]o ")
- if response == "y" or response == "yes":
- rebase = P4Rebase()
- rebase.rebase()
- os.remove(self.configFile)
+ rebase = P4Rebase()
+ rebase.rebase()
return True
@@ -850,7 +813,9 @@ class P4Sync(Command):
help="Import into refs/heads/ , not refs/remotes"),
optparse.make_option("--max-changes", dest="maxChanges"),
optparse.make_option("--keep-path", dest="keepRepoPath", action='store_true',
- help="Keep entire BRANCH/DIR/SUBDIR prefix during import")
+ help="Keep entire BRANCH/DIR/SUBDIR prefix during import"),
+ optparse.make_option("--use-client-spec", dest="useClientSpec", action='store_true',
+ help="Only sync files that are included in the Perforce Client Spec")
]
self.description = """Imports from Perforce into a git repository.\n
example:
@@ -876,18 +841,27 @@ class P4Sync(Command):
self.keepRepoPath = False
self.depotPaths = None
self.p4BranchesInGit = []
+ self.cloneExclude = []
+ self.useClientSpec = False
+ self.clientSpecDirs = []
if gitConfig("git-p4.syncFromOrigin") == "false":
self.syncWithOrigin = False
def extractFilesFromCommit(self, commit):
+ self.cloneExclude = [re.sub(r"\.\.\.$", "", path)
+ for path in self.cloneExclude]
files = []
fnum = 0
while commit.has_key("depotFile%s" % fnum):
path = commit["depotFile%s" % fnum]
- found = [p for p in self.depotPaths
- if path.startswith (p)]
+ if [p for p in self.cloneExclude
+ if path.startswith (p)]:
+ found = False
+ else:
+ found = [p for p in self.depotPaths
+ if path.startswith (p)]
if not found:
fnum = fnum + 1
continue
@@ -944,41 +918,61 @@ class P4Sync(Command):
## Should move this out, doesn't use SELF.
def readP4Files(self, files):
- files = [f for f in files
- if f['action'] != 'delete']
+ filesForCommit = []
+ filesToRead = []
- if not files:
- return
+ for f in files:
+ includeFile = True
+ for val in self.clientSpecDirs:
+ if f['path'].startswith(val[0]):
+ if val[1] <= 0:
+ includeFile = False
+ break
+
+ if includeFile:
+ filesForCommit.append(f)
+ if f['action'] != 'delete':
+ filesToRead.append(f)
+
+ filedata = []
+ if len(filesToRead) > 0:
+ filedata = p4CmdList('-x - print',
+ stdin='\n'.join(['%s#%s' % (f['path'], f['rev'])
+ for f in filesToRead]),
+ stdin_mode='w+')
- filedata = p4CmdList('-x - print',
- stdin='\n'.join(['%s#%s' % (f['path'], f['rev'])
- for f in files]),
- stdin_mode='w+')
- if "p4ExitCode" in filedata[0]:
- die("Problems executing p4. Error: [%d]."
- % (filedata[0]['p4ExitCode']));
+ if "p4ExitCode" in filedata[0]:
+ die("Problems executing p4. Error: [%d]."
+ % (filedata[0]['p4ExitCode']));
j = 0;
contents = {}
while j < len(filedata):
stat = filedata[j]
j += 1
- text = ''
- while j < len(filedata) and filedata[j]['code'] in ('text',
- 'binary'):
- text += filedata[j]['data']
+ text = [];
+ while j < len(filedata) and filedata[j]['code'] in ('text', 'unicode', 'binary'):
+ text.append(filedata[j]['data'])
j += 1
-
+ text = ''.join(text)
if not stat.has_key('depotFile'):
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
continue
+ if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+ text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
+ elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
+ text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
+
contents[stat['depotFile']] = text
- for f in files:
- assert not f.has_key('data')
- f['data'] = contents[f['path']]
+ for f in filesForCommit:
+ path = f['path']
+ if contents.has_key(path):
+ f['data'] = contents[path]
+
+ return filesForCommit
def commit(self, details, files, branch, branchPrefixes, parent = ""):
epoch = details["time"]
@@ -995,11 +989,7 @@ class P4Sync(Command):
new_files.append (f)
else:
sys.stderr.write("Ignoring file outside of prefix: %s\n" % path)
- files = new_files
- self.readP4Files(files)
-
-
-
+ files = self.readP4Files(new_files)
self.gitStream.write("commit %s\n" % branch)
# gitStream.write("mark :%s\n" % details["change"])
@@ -1414,6 +1404,26 @@ class P4Sync(Command):
print self.gitError.read()
+ def getClientSpec(self):
+ specList = p4CmdList( "client -o" )
+ temp = {}
+ for entry in specList:
+ for k,v in entry.iteritems():
+ if k.startswith("View"):
+ if v.startswith('"'):
+ start = 1
+ else:
+ start = 0
+ index = v.find("...")
+ v = v[start:index]
+ if v.startswith("-"):
+ v = v[1:]
+ temp[v] = -len(v)
+ else:
+ temp[v] = len(v)
+ self.clientSpecDirs = temp.items()
+ self.clientSpecDirs.sort( lambda x, y: abs( y[1] ) - abs( x[1] ) )
+
def run(self, args):
self.depotPaths = []
self.changeRange = ""
@@ -1446,6 +1456,9 @@ class P4Sync(Command):
if not gitBranchExists(self.refPrefix + "HEAD") and self.importIntoRemotes and gitBranchExists(self.branch):
system("git symbolic-ref %sHEAD %s" % (self.refPrefix, self.branch))
+ if self.useClientSpec or gitConfig("git-p4.useclientspec") == "true":
+ self.getClientSpec()
+
# TODO: should always look at previous commits,
# merge with previous imports, if possible.
if args == []:
@@ -1640,6 +1653,11 @@ class P4Rebase(Command):
return self.rebase()
def rebase(self):
+ if os.system("git update-index --refresh") != 0:
+ die("Some files in your working directory are modified and different than what is in your index. You can use git update-index <filename> to bring the index up-to-date or stash away all your changes with git stash.");
+ if len(read_pipe("git diff-index HEAD --")) > 0:
+ die("You have uncommited changes. Please commit them before rebasing or stash them away with git stash.");
+
[upstream, settings] = findUpstreamBranchPoint()
if len(upstream) == 0:
die("Cannot find upstream branchpoint for rebase")
@@ -1658,19 +1676,29 @@ class P4Clone(P4Sync):
P4Sync.__init__(self)
self.description = "Creates a new git repository and imports from Perforce into it"
self.usage = "usage: %prog [options] //depot/path[@revRange]"
- self.options.append(
+ self.options += [
optparse.make_option("--destination", dest="cloneDestination",
action='store', default=None,
- help="where to leave result of the clone"))
+ help="where to leave result of the clone"),
+ optparse.make_option("-/", dest="cloneExclude",
+ action="append", type="string",
+ help="exclude depot path")
+ ]
self.cloneDestination = None
self.needsGit = False
+ # This is required for the "append" cloneExclude action
+ def ensure_value(self, attr, value):
+ if not hasattr(self, attr) or getattr(self, attr) is None:
+ setattr(self, attr, value)
+ return getattr(self, attr)
+
def defaultDestination(self, args):
## TODO: use common prefix of args?
depotPath = args[0]
depotDir = re.sub("(@[^@]*)$", "", depotPath)
depotDir = re.sub("(#[^#]*)$", "", depotDir)
- depotDir = re.sub(r"\.\.\.$,", "", depotDir)
+ depotDir = re.sub(r"\.\.\.$", "", depotDir)
depotDir = re.sub(r"/$", "", depotDir)
return os.path.split(depotDir)[1]
@@ -1688,6 +1716,7 @@ class P4Clone(P4Sync):
self.cloneDestination = depotPaths[-1]
depotPaths = depotPaths[:-1]
+ self.cloneExclude = ["/"+p for p in self.cloneExclude]
for p in depotPaths:
if not p.startswith("//"):
return False
@@ -1698,7 +1727,7 @@ class P4Clone(P4Sync):
print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
if not os.path.exists(self.cloneDestination):
os.makedirs(self.cloneDestination)
- os.chdir(self.cloneDestination)
+ chdir(self.cloneDestination)
system("git init")
self.gitdir = os.getcwd() + "/.git"
if not P4Sync.run(self, depotPaths):
@@ -1810,7 +1839,7 @@ def main():
if os.path.exists(cmd.gitdir):
cdup = read_pipe("git rev-parse --show-cdup").strip()
if len(cdup) > 0:
- os.chdir(cdup);
+ chdir(cdup);
if not isValidGitDir(cmd.gitdir):
if isValidGitDir(cmd.gitdir + "/.git"):
diff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt
index b16a8384b..ac551d45f 100644
--- a/contrib/fast-import/git-p4.txt
+++ b/contrib/fast-import/git-p4.txt
@@ -63,18 +63,6 @@ It is recommended to run 'git repack -a -d -f' from time to time when using
incremental imports to optimally combine the individual git packs that each
incremental import creates through the use of git-fast-import.
-
-A useful setup may be that you have a periodically updated git repository
-somewhere that contains a complete import of a Perforce project. That git
-repository can be used to clone the working repository from and one would
-import from Perforce directly after cloning using git-p4. If the connection to
-the Perforce server is slow and the working repository hasn't been synced for a
-while it may be desirable to fetch changes from the origin git repository using
-the efficient git protocol. git-p4 supports this setup by calling "git fetch origin"
-by default if there is an origin branch. You can disable this using
-
- git config git-p4.syncFromOrigin false
-
Updating
========
@@ -140,6 +128,62 @@ Example
git-p4 rebase
+Configuration parameters
+========================
+
+git-p4.user ($P4USER)
+
+Allows you to specify the username to use to connect to the Perforce repository.
+
+ git config [--global] git-p4.user public
+
+git-p4.password ($P4PASS)
+
+Allows you to specify the password to use to connect to the Perforce repository.
+Warning this password will be visible on the command-line invocation of the p4 binary.
+
+ git config [--global] git-p4.password public1234
+
+git-p4.port ($P4PORT)
+
+Specify the port to be used to contact the Perforce server. As this will be passed
+directly to the p4 binary, it may be in the format host:port as well.
+
+ git config [--global] git-p4.port codes.zimbra.com:2666
+
+git-p4.host ($P4HOST)
+
+Specify the host to contact for a Perforce repository.
+
+ git config [--global] git-p4.host perforce.example.com
+
+git-p4.client ($P4CLIENT)
+
+Specify the client name to use
+
+ git config [--global] git-p4.client public-view
+
+git-p4.allowSubmit
+
+ git config [--global] git-p4.allowSubmit false
+
+git-p4.syncFromOrigin
+
+A useful setup may be that you have a periodically updated git repository
+somewhere that contains a complete import of a Perforce project. That git
+repository can be used to clone the working repository from and one would
+import from Perforce directly after cloning using git-p4. If the connection to
+the Perforce server is slow and the working repository hasn't been synced for a
+while it may be desirable to fetch changes from the origin git repository using
+the efficient git protocol. git-p4 supports this setup by calling "git fetch origin"
+by default if there is an origin branch. You can disable this using:
+
+ git config [--global] git-p4.syncFromOrigin false
+
+git-p4.useclientspec
+
+ git config [--global] git-p4.useclientspec false
+
Implementation Details...
=========================
diff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py
new file mode 100755
index 000000000..c674fa2d1
--- /dev/null
+++ b/contrib/fast-import/import-zips.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+
+## zip archive frontend for git-fast-import
+##
+## For example:
+##
+## mkdir project; cd project; git init
+## python import-zips.py *.zip
+## git log --stat import-zips
+
+from os import popen, path
+from sys import argv, exit
+from time import mktime
+from zipfile import ZipFile
+
+if len(argv) < 2:
+ print 'Usage:', argv[0], '<zipfile>...'
+ exit(1)
+
+branch_ref = 'refs/heads/import-zips'
+committer_name = 'Z Ip Creator'
+committer_email = 'zip@example.com'
+
+fast_import = popen('git fast-import --quiet', 'w')
+def printlines(list):
+ for str in list:
+ fast_import.write(str + "\n")
+
+for zipfile in argv[1:]:
+ commit_time = 0
+ next_mark = 1
+ common_prefix = None
+ mark = dict()
+
+ zip = ZipFile(zipfile, 'r')
+ for name in zip.namelist():
+ if name.endswith('/'):
+ continue
+ info = zip.getinfo(name)
+
+ if commit_time < info.date_time:
+ commit_time = info.date_time
+ if common_prefix == None:
+ common_prefix = name[:name.rfind('/') + 1]
+ else:
+ while not name.startswith(common_prefix):
+ common_prefix = name[:name.rfind('/') + 1]
+
+ mark[name] = ':' + str(next_mark)
+ next_mark += 1
+
+ printlines(('blob', 'mark ' + mark[name], \
+ 'data ' + str(info.file_size)))
+ fast_import.write(zip.read(name) + "\n")
+
+ committer = committer_name + ' <' + committer_email + '> %d +0000' % \
+ mktime(commit_time + (0, 0, 0))
+
+ printlines(('commit ' + branch_ref, 'committer ' + committer, \
+ 'data <<EOM', 'Imported from ' + zipfile + '.', 'EOM', \
+ '', 'deleteall'))
+
+ for name in mark.keys():
+ fast_import.write('M 100644 ' + mark[name] + ' ' +
+ name[len(common_prefix):] + "\n")
+
+ printlines(('', 'tag ' + path.basename(zipfile), \
+ 'from ' + branch_ref, 'tagger ' + committer, \
+ 'data <<EOM', 'Package ' + zipfile, 'EOM', ''))
+
+if fast_import.close():
+ exit(1)
diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index c35b15860..7b03204ed 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -46,6 +46,7 @@ options:
for incrementals
-n, --nrepack=INT: number of changesets that will trigger
a repack (default=0, -1 to deactivate)
+ -v, --verbose: be verbose
required:
hgprj: name of the HG project to import (directory)
@@ -75,17 +76,20 @@ def getgitenv(user, date):
state = ''
opt_nrepack = 0
+verbose = False
try:
- opts, args = getopt.getopt(sys.argv[1:], 's:t:n:', ['gitstate=', 'tempdir=', 'nrepack='])
+ opts, args = getopt.getopt(sys.argv[1:], 's:t:n:v', ['gitstate=', 'tempdir=', 'nrepack=', 'verbose'])
for o, a in opts:
if o in ('-s', '--gitstate'):
state = a
state = os.path.abspath(state)
if o in ('-n', '--nrepack'):
opt_nrepack = int(a)
+ if o in ('-v', '--verbose'):
+ verbose = True
if len(args) != 1:
- raise('params')
+ raise Exception('params')
except:
usage()
sys.exit(1)
@@ -95,23 +99,29 @@ os.chdir(hgprj)
if state:
if os.path.exists(state):
- print 'State does exist, reading'
+ if verbose:
+ print 'State does exist, reading'
f = open(state, 'r')
hgvers = pickle.load(f)
else:
print 'State does not exist, first run'
-tip = os.popen('hg tip --template "{rev}"').read()
-print 'tip is', tip
+sock = os.popen('hg tip --template "{rev}"')
+tip = sock.read()
+if sock.close():
+ sys.exit(1)
+if verbose:
+ print 'tip is', tip
# Calculate the branches
-print 'analysing the branches...'
+if verbose:
+ print 'analysing the branches...'
hgchildren["0"] = ()
hgparents["0"] = (None, None)
hgbranch["0"] = "master"
for cset in range(1, int(tip) + 1):
hgchildren[str(cset)] = ()
- prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().split(' ')
+ prnts = os.popen('hg log -r %d --template "{parents}"' % cset).read().strip().split(' ')
prnts = map(lambda x: x[:x.find(':')], prnts)
if prnts[0] != '':
parent = prnts[0].strip()
@@ -142,7 +152,7 @@ for cset in range(1, int(tip) + 1):
if not hgvers.has_key("0"):
print 'creating repository'
- os.system('git-init-db')
+ os.system('git init')
# loop through every hg changeset
for cset in range(int(tip) + 1):
@@ -184,10 +194,10 @@ for cset in range(int(tip) + 1):
if cset != 0:
if hgbranch[str(cset)] == "branch-" + str(cset):
print 'creating new branch', hgbranch[str(cset)]
- os.system('git-checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent]))
+ os.system('git checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent]))
else:
print 'checking out branch', hgbranch[str(cset)]
- os.system('git-checkout %s' % hgbranch[str(cset)])
+ os.system('git checkout %s' % hgbranch[str(cset)])
# merge
if mparent:
@@ -196,7 +206,7 @@ for cset in range(int(tip) + 1):
else:
otherbranch = hgbranch[parent]
print 'merging', otherbranch, 'into', hgbranch[str(cset)]
- os.system(getgitenv(user, date) + 'git-merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch))
+ os.system(getgitenv(user, date) + 'git merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch))
# remove everything except .git and .hg directories
os.system('find . \( -path "./.hg" -o -path "./.git" \) -prune -o ! -name "." -print | xargs rm -rf')
@@ -205,9 +215,9 @@ for cset in range(int(tip) + 1):
os.system('hg update -C %d' % cset)
# add new files
- os.system('git-ls-files -x .hg --others | git-update-index --add --stdin')
+ os.system('git ls-files -x .hg --others | git update-index --add --stdin')
# delete removed files
- os.system('git-ls-files -x .hg --deleted | git-update-index --remove --stdin')
+ os.system('git ls-files -x .hg --deleted | git update-index --remove --stdin')
# commit
os.system(getgitenv(user, date) + 'git commit --allow-empty -a -F %s' % filecomment)
@@ -215,24 +225,25 @@ for cset in range(int(tip) + 1):
# tag
if tag and tag != 'tip':
- os.system(getgitenv(user, date) + 'git-tag %s' % tag)
+ os.system(getgitenv(user, date) + 'git tag %s' % tag)
# delete branch if not used anymore...
if mparent and len(hgchildren[str(cset)]):
print "Deleting unused branch:", otherbranch
- os.system('git-branch -d %s' % otherbranch)
+ os.system('git branch -d %s' % otherbranch)
# retrieve and record the version
- vvv = os.popen('git-show --quiet --pretty=format:%H').read()
+ vvv = os.popen('git show --quiet --pretty=format:%H').read()
print 'record', cset, '->', vvv
hgvers[str(cset)] = vvv
if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
- os.system('git-repack -a -d')
+ os.system('git repack -a -d')
# write the state for incrementals
if state:
- print 'Writing state'
+ if verbose:
+ print 'Writing state'
f = open(state, 'w')
pickle.dump(hgvers, f)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 77c88ebf1..41368950d 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -202,11 +202,12 @@ generate_email_header()
generate_email_footer()
{
+ SPACE=" "
cat <<-EOF
hooks/post-receive
- --
+ --${SPACE}
$projectdesc
EOF
}
@@ -567,7 +568,7 @@ generate_general_email()
echo ""
if [ "$newrev_type" = "commit" ]; then
echo $LOGBEGIN
- git show --no-color --root -s $newrev
+ git show --no-color --root -s --pretty=medium $newrev
echo $LOGEND
else
# What can we do here? The tag marks an object that is not
diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
new file mode 100644
index 000000000..0096f57b7
--- /dev/null
+++ b/contrib/hooks/pre-auto-gc-battery
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# An example hook script to verify if you are on battery, in case you
+# are running Linux. Called by git-gc --auto with no arguments. The hook
+# should exit with non-zero status after issuing an appropriate message
+# if it wants to stop the auto repacking.
+#
+# This hook is stored in the contrib/hooks directory. Your distribution
+# may have put this somewhere else. If you want to use this hook, you
+# should make this script executable then link to it in the repository
+# you would like to use it in.
+#
+# For example, if the hook is stored in
+# /usr/share/git-core/contrib/hooks/pre-auto-gc-battery:
+#
+# chmod a+x pre-auto-gc-battery
+# cd /path/to/your/repository.git
+# ln -sf /usr/share/git-core/contrib/hooks/pre-auto-gc-battery \
+# hooks/pre-auto-gc
+
+if test -x /sbin/on_ac_power && /sbin/on_ac_power
+then
+ exit 0
+elif test "$(cat /sys/class/power_supply/AC/online 2>/dev/null)" = 1
+then
+ exit 0
+elif grep -q 'on-line' /proc/acpi/ac_adapter/AC/state 2>/dev/null
+then
+ exit 0
+elif grep -q '0x01$' /proc/apm 2>/dev/null
+then
+ exit 0
+fi
+
+echo "Auto packing deferred; not on AC"
+exit 1
diff --git a/contrib/hooks/update-paranoid b/contrib/hooks/update-paranoid
index 068fa3708..d18b317b2 100644
--- a/contrib/hooks/update-paranoid
+++ b/contrib/hooks/update-paranoid
@@ -136,6 +136,7 @@ sub parse_config ($$$$) {
local $ENV{GIT_DIR} = shift;
my $br = shift;
my $fn = shift;
+ return unless git_value('rev-list','--max-count=1',$br,'--',$fn);
info "Loading $br:$fn";
open(I,'-|','git','cat-file','blob',"$br:$fn");
my $section = '';
@@ -225,14 +226,12 @@ sub load_diff ($) {
local $/ = "\0";
my %this_diff;
if ($base =~ /^0{40}$/) {
- open(T,'-|','git','ls-tree',
- '-r','--name-only','-z',
- $new) or return undef;
- while (<T>) {
- chop;
- $this_diff{$_} = 'A';
- }
- close T or return undef;
+ # Don't load the diff at all; we are making the
+ # branch and have no base to compare to in this
+ # case. A file level ACL makes no sense in this
+ # context. Having an empty diff will allow the
+ # branch creation.
+ #
} else {
open(T,'-|','git','diff-tree',
'-r','--name-status','-z',
@@ -260,6 +259,7 @@ deny "Refusing funny ref $ref" unless $ref =~ s,^refs/,,;
deny "Bad old value $old" unless $old =~ /^[a-z0-9]{40}$/;
deny "Bad new value $new" unless $new =~ /^[a-z0-9]{40}$/;
deny "Cannot determine who you are." unless $this_user;
+grant "No change requested." if $old eq $new;
$repository_name = File::Spec->rel2abs($git_dir);
$repository_name =~ m,/([^/]+)(?:\.git|/\.git)$,;
diff --git a/contrib/stats/packinfo.pl b/contrib/stats/packinfo.pl
index aab501ea0..f4a7b62cd 100755
--- a/contrib/stats/packinfo.pl
+++ b/contrib/stats/packinfo.pl
@@ -93,7 +93,7 @@ my %depths;
my @depths;
while (<STDIN>) {
- my ($sha1, $type, $size, $offset, $depth, $parent) = split(/\s+/, $_);
+ my ($sha1, $type, $size, $space, $offset, $depth, $parent) = split(/\s+/, $_);
next unless ($sha1 =~ /^[0-9a-f]{40}$/);
$depths{$sha1} = $depth || 0;
push(@depths, $depth || 0);
diff --git a/contrib/thunderbird-patch-inline/README b/contrib/thunderbird-patch-inline/README
new file mode 100644
index 000000000..39f96aa11
--- /dev/null
+++ b/contrib/thunderbird-patch-inline/README
@@ -0,0 +1,20 @@
+appp.sh is a script that is supposed to be used together with ExternalEditor
+for Mozilla Thundebird. It will let you include patches inline in e-mails
+in an easy way.
+
+Usage:
+- Generate the patch with git format-patch.
+- Start writing a new e-mail in Thunderbird.
+- Press the external editor button (or Ctrl-E) to run appp.sh
+- Select the previosly generated patch file.
+- Finish editing the e-mail.
+
+Any text that is entered into the message editor before appp.sh is called
+will be moved to the section between the --- and the diffstat.
+
+All S-O-B:s and Cc:s in the patch will be added to the CC list.
+
+To set it up, just install External Editor and tell it to use appp.sh as the
+editor.
+
+Zenity is a required dependency.
diff --git a/contrib/thunderbird-patch-inline/appp.sh b/contrib/thunderbird-patch-inline/appp.sh
new file mode 100755
index 000000000..cc518f3c8
--- /dev/null
+++ b/contrib/thunderbird-patch-inline/appp.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+# Copyright 2008 Lukas Sandström <luksan@gmail.com>
+#
+# AppendPatch - A script to be used together with ExternalEditor
+# for Mozilla Thunderbird to properly include pathes inline i e-mails.
+
+# ExternalEditor can be downloaded at http://globs.org/articles.php?lng=en&pg=2
+
+CONFFILE=~/.appprc
+
+SEP="-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-"
+if [ -e "$CONFFILE" ] ; then
+ LAST_DIR=`grep -m 1 "^LAST_DIR=" "${CONFFILE}"|sed -e 's/^LAST_DIR=//'`
+ cd "${LAST_DIR}"
+else
+ cd > /dev/null
+fi
+
+PATCH=$(zenity --file-selection)
+
+if [ "$?" != "0" ] ; then
+ #zenity --error --text "No patchfile given."
+ exit 1
+fi
+
+cd - > /dev/null
+
+SUBJECT=`sed -n -e '/^Subject: /p' "${PATCH}"`
+HEADERS=`sed -e '/^'"${SEP}"'$/,$d' $1`
+BODY=`sed -e "1,/${SEP}/d" $1`
+CMT_MSG=`sed -e '1,/^$/d' -e '/^---$/,$d' "${PATCH}"`
+DIFF=`sed -e '1,/^---$/d' "${PATCH}"`
+
+CCS=`echo -e "$CMT_MSG\n$HEADERS" | sed -n -e 's/^Cc: \(.*\)$/\1,/gp' \
+ -e 's/^Signed-off-by: \(.*\)/\1,/gp'`
+
+echo "$SUBJECT" > $1
+echo "Cc: $CCS" >> $1
+echo "$HEADERS" | sed -e '/^Subject: /d' -e '/^Cc: /d' >> $1
+echo "$SEP" >> $1
+
+echo "$CMT_MSG" >> $1
+echo "---" >> $1
+if [ "x${BODY}x" != "xx" ] ; then
+ echo >> $1
+ echo "$BODY" >> $1
+ echo >> $1
+fi
+echo "$DIFF" >> $1
+
+LAST_DIR=`dirname "${PATCH}"`
+
+grep -v "^LAST_DIR=" "${CONFFILE}" > "${CONFFILE}_"
+echo "LAST_DIR=${LAST_DIR}" >> "${CONFFILE}_"
+mv "${CONFFILE}_" "${CONFFILE}"
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 2838546d1..7959eab90 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -63,7 +63,7 @@ mkdir -p "$new_workdir/.git" || die "unable to create \"$new_workdir\"!"
# create the links to the original repo. explictly exclude index, HEAD and
# logs/HEAD from the list since they are purely related to the current working
# directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache
+for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
do
case $x in
*/*)
diff --git a/convert.c b/convert.c
index 80f114b2e..78efed800 100644
--- a/convert.c
+++ b/convert.c
@@ -61,6 +61,10 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *
else
stats->printable++;
}
+
+ /* If file ends with EOF then don't count this EOF as non-printable. */
+ if (size >= 1 && buf[size-1] == '\032')
+ stats->nonprintable--;
}
/*
@@ -85,8 +89,39 @@ static int is_binary(unsigned long size, struct text_stat *stats)
return 0;
}
+static void check_safe_crlf(const char *path, int action,
+ struct text_stat *stats, enum safe_crlf checksafe)
+{
+ if (!checksafe)
+ return;
+
+ if (action == CRLF_INPUT || auto_crlf <= 0) {
+ /*
+ * CRLFs would not be restored by checkout:
+ * check if we'd remove CRLFs
+ */
+ if (stats->crlf) {
+ if (checksafe == SAFE_CRLF_WARN)
+ warning("CRLF will be replaced by LF in %s.", path);
+ else /* i.e. SAFE_CRLF_FAIL */
+ die("CRLF would be replaced by LF in %s.", path);
+ }
+ } else if (auto_crlf > 0) {
+ /*
+ * CRLFs would be added by checkout:
+ * check if we have "naked" LFs
+ */
+ if (stats->lf != stats->crlf) {
+ if (checksafe == SAFE_CRLF_WARN)
+ warning("LF will be replaced by CRLF in %s", path);
+ else /* i.e. SAFE_CRLF_FAIL */
+ die("LF would be replaced by CRLF in %s", path);
+ }
+ }
+}
+
static int crlf_to_git(const char *path, const char *src, size_t len,
- struct strbuf *buf, int action)
+ struct strbuf *buf, int action, enum safe_crlf checksafe)
{
struct text_stat stats;
char *dst;
@@ -95,9 +130,6 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
return 0;
gather_stats(src, len, &stats);
- /* No CR? Nothing to convert, regardless. */
- if (!stats.cr)
- return 0;
if (action == CRLF_GUESS) {
/*
@@ -115,6 +147,12 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
return 0;
}
+ check_safe_crlf(path, action, &stats, checksafe);
+
+ /* Optimization: No CR? Nothing to convert, regardless. */
+ if (!stats.cr)
+ return 0;
+
/* only grow if not in place */
if (strbuf_avail(buf) + buf->len < len)
strbuf_grow(buf, len - buf->len);
@@ -285,11 +323,11 @@ static int apply_filter(const char *path, const char *src, size_t len,
static struct convert_driver {
const char *name;
struct convert_driver *next;
- char *smudge;
- char *clean;
+ const char *smudge;
+ const char *clean;
} *user_convert, **user_convert_tail;
-static int read_convert_config(const char *var, const char *value)
+static int read_convert_config(const char *var, const char *value, void *cb)
{
const char *ep, *name;
int namelen;
@@ -324,19 +362,12 @@ static int read_convert_config(const char *var, const char *value)
* The command-line will not be interpolated in any way.
*/
- if (!strcmp("smudge", ep)) {
- if (!value)
- return error("%s: lacks value", var);
- drv->smudge = strdup(value);
- return 0;
- }
+ if (!strcmp("smudge", ep))
+ return git_config_string(&drv->smudge, var, value);
+
+ if (!strcmp("clean", ep))
+ return git_config_string(&drv->clean, var, value);
- if (!strcmp("clean", ep)) {
- if (!value)
- return error("%s: lacks value", var);
- drv->clean = strdup(value);
- return 0;
- }
return 0;
}
@@ -351,7 +382,7 @@ static void setup_convert_check(struct git_attr_check *check)
attr_ident = git_attr("ident", 5);
attr_filter = git_attr("filter", 6);
user_convert_tail = &user_convert;
- git_config(read_convert_config);
+ git_config(read_convert_config, NULL);
}
check[0].attr = attr_crlf;
check[1].attr = attr_ident;
@@ -536,12 +567,13 @@ static int git_path_check_ident(const char *path, struct git_attr_check *check)
return !!ATTR_TRUE(value);
}
-int convert_to_git(const char *path, const char *src, size_t len, struct strbuf *dst)
+int convert_to_git(const char *path, const char *src, size_t len,
+ struct strbuf *dst, enum safe_crlf checksafe)
{
struct git_attr_check check[3];
int crlf = CRLF_GUESS;
int ident = 0, ret = 0;
- char *filter = NULL;
+ const char *filter = NULL;
setup_convert_check(check);
if (!git_checkattr(path, ARRAY_SIZE(check), check)) {
@@ -558,7 +590,7 @@ int convert_to_git(const char *path, const char *src, size_t len, struct strbuf
src = dst->buf;
len = dst->len;
}
- ret |= crlf_to_git(path, src, len, dst, crlf);
+ ret |= crlf_to_git(path, src, len, dst, crlf, checksafe);
if (ret) {
src = dst->buf;
len = dst->len;
@@ -571,7 +603,7 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
struct git_attr_check check[3];
int crlf = CRLF_GUESS;
int ident = 0, ret = 0;
- char *filter = NULL;
+ const char *filter = NULL;
setup_convert_check(check);
if (!git_checkattr(path, ARRAY_SIZE(check), check)) {
diff --git a/copy.c b/copy.c
index c225d1b0f..e54d15ace 100644
--- a/copy.c
+++ b/copy.c
@@ -9,8 +9,7 @@ int copy_fd(int ifd, int ofd)
if (!len)
break;
if (len < 0) {
- int read_error;
- read_error = errno;
+ int read_error = errno;
close(ifd);
return error("copy-fd: read returned %s",
strerror(read_error));
@@ -25,12 +24,34 @@ int copy_fd(int ifd, int ofd)
close(ifd);
return error("copy-fd: write returned 0");
} else {
+ int write_error = errno;
close(ifd);
return error("copy-fd: write returned %s",
- strerror(errno));
+ strerror(write_error));
}
}
}
close(ifd);
return 0;
}
+
+int copy_file(const char *dst, const char *src, int mode)
+{
+ int fdi, fdo, status;
+
+ mode = (mode & 0111) ? 0777 : 0666;
+ if ((fdi = open(src, O_RDONLY)) < 0)
+ return fdi;
+ if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
+ close(fdi);
+ return fdo;
+ }
+ status = copy_fd(fdi, fdo);
+ if (close(fdo) != 0)
+ return error("%s: close error: %s", dst, strerror(errno));
+
+ if (!status && adjust_shared_perm(dst))
+ return -1;
+
+ return status;
+}
diff --git a/csum-file.c b/csum-file.c
index 9728a9954..ace64f165 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -32,21 +32,24 @@ static void sha1flush(struct sha1file *f, unsigned int count)
}
}
-int sha1close(struct sha1file *f, unsigned char *result, int final)
+int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
{
int fd;
unsigned offset = f->offset;
+
if (offset) {
SHA1_Update(&f->ctx, f->buffer, offset);
sha1flush(f, offset);
f->offset = 0;
}
- if (final) {
+ if (flags & (CSUM_CLOSE | CSUM_FSYNC)) {
/* write checksum and close fd */
SHA1_Final(f->buffer, &f->ctx);
if (result)
hashcpy(result, f->buffer);
sha1flush(f, 20);
+ if (flags & CSUM_FSYNC)
+ fsync_or_die(f->fd, f->name);
if (close(f->fd))
die("%s: sha1 file error on close (%s)",
f->name, strerror(errno));
diff --git a/csum-file.h b/csum-file.h
index 1af76562f..72c9487f4 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -16,9 +16,13 @@ struct sha1file {
unsigned char buffer[8192];
};
+/* sha1close flags */
+#define CSUM_CLOSE 1
+#define CSUM_FSYNC 2
+
extern struct sha1file *sha1fd(int fd, const char *name);
extern struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp);
-extern int sha1close(struct sha1file *, unsigned char *, int);
+extern int sha1close(struct sha1file *, unsigned char *, unsigned int);
extern int sha1write(struct sha1file *, void *, unsigned int);
extern void crc32_begin(struct sha1file *);
extern uint32_t crc32_end(struct sha1file *);
diff --git a/daemon.c b/daemon.c
index 41a60af62..8dcde7320 100644
--- a/daemon.c
+++ b/daemon.c
@@ -16,9 +16,10 @@
static int log_syslog;
static int verbose;
static int reuseaddr;
+static int child_handler_pipe[2];
static const char daemon_usage[] =
-"git-daemon [--verbose] [--syslog] [--export-all]\n"
+"git daemon [--verbose] [--syslog] [--export-all]\n"
" [--timeout=n] [--init-timeout=n] [--strict-paths]\n"
" [--base-path=path] [--base-path-relaxed]\n"
" [--user-path | --user-path=path]\n"
@@ -306,7 +307,7 @@ struct daemon_service {
static struct daemon_service *service_looking_at;
static int service_enabled;
-static int git_daemon_config(const char *var, const char *value)
+static int git_daemon_config(const char *var, const char *value, void *cb)
{
if (!prefixcmp(var, "daemon.") &&
!strcmp(var + 7, service_looking_at->config_name)) {
@@ -356,7 +357,7 @@ static int run_service(struct interp *itable, struct daemon_service *service)
if (service->overridable) {
service_looking_at = service;
service_enabled = -1;
- git_config(git_daemon_config);
+ git_config(git_daemon_config, NULL);
if (0 <= service_enabled)
enabled = service_enabled;
}
@@ -694,23 +695,47 @@ static void kill_some_children(int signo, unsigned start, unsigned stop)
}
}
+static void check_dead_children(void)
+{
+ unsigned spawned, reaped, deleted;
+
+ spawned = children_spawned;
+ reaped = children_reaped;
+ deleted = children_deleted;
+
+ while (deleted < reaped) {
+ pid_t pid = dead_child[deleted % MAX_CHILDREN];
+ const char *dead = pid < 0 ? " (with error)" : "";
+
+ if (pid < 0)
+ pid = -pid;
+
+ /* XXX: Custom logging, since we don't wanna getpid() */
+ if (verbose) {
+ if (log_syslog)
+ syslog(LOG_INFO, "[%d] Disconnected%s",
+ pid, dead);
+ else
+ fprintf(stderr, "[%d] Disconnected%s\n",
+ pid, dead);
+ }
+ remove_child(pid, deleted, spawned);
+ deleted++;
+ }
+ children_deleted = deleted;
+}
+
static void check_max_connections(void)
{
for (;;) {
int active;
- unsigned spawned, reaped, deleted;
+ unsigned spawned, deleted;
+
+ check_dead_children();
spawned = children_spawned;
- reaped = children_reaped;
deleted = children_deleted;
- while (deleted < reaped) {
- pid_t pid = dead_child[deleted % MAX_CHILDREN];
- remove_child(pid, deleted, spawned);
- deleted++;
- }
- children_deleted = deleted;
-
active = spawned - deleted;
if (active <= max_connections)
break;
@@ -760,22 +785,16 @@ static void child_handler(int signo)
if (pid > 0) {
unsigned reaped = children_reaped;
+ if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
+ pid = -pid;
dead_child[reaped % MAX_CHILDREN] = pid;
children_reaped = reaped + 1;
- /* XXX: Custom logging, since we don't wanna getpid() */
- if (verbose) {
- const char *dead = "";
- if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
- dead = " (with error)";
- if (log_syslog)
- syslog(LOG_INFO, "[%d] Disconnected%s", pid, dead);
- else
- fprintf(stderr, "[%d] Disconnected%s\n", pid, dead);
- }
+ write(child_handler_pipe[1], &status, 1);
continue;
}
break;
}
+ signal(SIGCHLD, child_handler);
}
static int set_reuse_addr(int sockfd)
@@ -917,19 +936,24 @@ static int service_loop(int socknum, int *socklist)
struct pollfd *pfd;
int i;
- pfd = xcalloc(socknum, sizeof(struct pollfd));
+ if (pipe(child_handler_pipe) < 0)
+ die ("Could not set up pipe for child handler");
+
+ pfd = xcalloc(socknum + 1, sizeof(struct pollfd));
for (i = 0; i < socknum; i++) {
pfd[i].fd = socklist[i];
pfd[i].events = POLLIN;
}
+ pfd[socknum].fd = child_handler_pipe[0];
+ pfd[socknum].events = POLLIN;
signal(SIGCHLD, child_handler);
for (;;) {
int i;
- if (poll(pfd, socknum, -1) < 0) {
+ if (poll(pfd, socknum + 1, -1) < 0) {
if (errno != EINTR) {
error("poll failed, resuming: %s",
strerror(errno));
@@ -937,6 +961,10 @@ static int service_loop(int socknum, int *socklist)
}
continue;
}
+ if (pfd[socknum].revents & POLLIN) {
+ read(child_handler_pipe[0], &i, 1);
+ check_dead_children();
+ }
for (i = 0; i < socknum; i++) {
if (pfd[i].revents & POLLIN) {
@@ -1149,6 +1177,11 @@ int main(int argc, char **argv)
usage(daemon_usage);
}
+ if (log_syslog) {
+ openlog("git-daemon", 0, LOG_DAEMON);
+ set_die_routine(daemon_die);
+ }
+
if (inetd_mode && (group_name || user_name))
die("--user and --group are incompatible with --inetd");
@@ -1176,14 +1209,17 @@ int main(int argc, char **argv)
}
}
- if (log_syslog) {
- openlog("git-daemon", 0, LOG_DAEMON);
- set_die_routine(daemon_die);
- }
-
if (strict_paths && (!ok_paths || !*ok_paths))
die("option --strict-paths requires a whitelist");
+ if (base_path) {
+ struct stat st;
+
+ if (stat(base_path, &st) || !S_ISDIR(st.st_mode))
+ die("base-path '%s' does not exist or "
+ "is not a directory", base_path);
+ }
+
if (inetd_mode) {
struct sockaddr_storage ss;
struct sockaddr *peer = (struct sockaddr *)&ss;
diff --git a/date.c b/date.c
index 8f7050027..35a52576c 100644
--- a/date.c
+++ b/date.c
@@ -6,7 +6,10 @@
#include "cache.h"
-static time_t my_mktime(struct tm *tm)
+/*
+ * This is like mktime, but without normalization of tm_wday and tm_yday.
+ */
+time_t tm_to_time_t(const struct tm *tm)
{
static const int mdays[] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
@@ -67,7 +70,7 @@ static int local_tzoffset(unsigned long time)
t = time;
localtime_r(&t, &tm);
- t_local = my_mktime(&tm);
+ t_local = tm_to_time_t(&tm);
if (t_local < t) {
eastwest = -1;
@@ -213,9 +216,9 @@ static const struct {
{ "EAST", +10, 0, }, /* Eastern Australian Standard */
{ "EADT", +10, 1, }, /* Eastern Australian Daylight */
{ "GST", +10, 0, }, /* Guam Standard, USSR Zone 9 */
- { "NZT", +11, 0, }, /* New Zealand */
- { "NZST", +11, 0, }, /* New Zealand Standard */
- { "NZDT", +11, 1, }, /* New Zealand Daylight */
+ { "NZT", +12, 0, }, /* New Zealand */
+ { "NZST", +12, 0, }, /* New Zealand Standard */
+ { "NZDT", +12, 1, }, /* New Zealand Daylight */
{ "IDLE", +12, 0, }, /* International Date Line East */
};
@@ -322,7 +325,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
if (!now_tm)
return 1;
- specified = my_mktime(r);
+ specified = tm_to_time_t(r);
/* Be it commit time or author time, it does not make
* sense to specify timestamp way into the future. Make
@@ -572,7 +575,7 @@ int parse_date(const char *date, char *result, int maxlen)
}
/* mktime uses local timezone */
- then = my_mktime(&tm);
+ then = tm_to_time_t(&tm);
if (offset == -1)
offset = (then - mktime(&tm)) / 60;
@@ -611,7 +614,7 @@ void datestamp(char *buf, int bufsize)
time(&now);
- offset = my_mktime(localtime(&now)) - now;
+ offset = tm_to_time_t(localtime(&now)) - now;
offset /= 60;
date_string(now, offset, buf, bufsize);
@@ -682,10 +685,8 @@ static void date_am(struct tm *tm, int *num)
static void date_never(struct tm *tm, int *num)
{
- tm->tm_mon = tm->tm_wday = tm->tm_yday
- = tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
- tm->tm_year = 70;
- tm->tm_mday = 1;
+ time_t n = 0;
+ localtime_r(&n, tm);
}
static const struct special {
diff --git a/decorate.c b/decorate.c
index 23f6b0040..d9668d2ef 100644
--- a/decorate.c
+++ b/decorate.c
@@ -37,10 +37,7 @@ static void grow_decoration(struct decoration *n)
{
int i;
int old_size = n->size;
- struct object_decoration *old_hash;
-
- old_size = n->size;
- old_hash = n->hash;
+ struct object_decoration *old_hash = n->hash;
n->size = (old_size + 1000) * 3 / 2;
n->hash = xcalloc(n->size, sizeof(struct object_decoration));
diff --git a/diff-lib.c b/diff-lib.c
index 94b150e83..e7eaff9a6 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -8,332 +8,52 @@
#include "diffcore.h"
#include "revision.h"
#include "cache-tree.h"
-#include "path-list.h"
#include "unpack-trees.h"
+#include "refs.h"
/*
* diff-files
*/
-static int read_directory(const char *path, struct path_list *list)
-{
- DIR *dir;
- struct dirent *e;
-
- if (!(dir = opendir(path)))
- return error("Could not open directory %s", path);
-
- while ((e = readdir(dir)))
- if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
- path_list_insert(e->d_name, list);
-
- closedir(dir);
- return 0;
-}
-
-static int get_mode(const char *path, int *mode)
-{
- struct stat st;
-
- if (!path || !strcmp(path, "/dev/null"))
- *mode = 0;
- else if (!strcmp(path, "-"))
- *mode = create_ce_mode(0666);
- else if (stat(path, &st))
- return error("Could not access '%s'", path);
- else
- *mode = st.st_mode;
- return 0;
-}
-
-static int queue_diff(struct diff_options *o,
- const char *name1, const char *name2)
-{
- int mode1 = 0, mode2 = 0;
-
- if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
- return -1;
-
- if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
- return error("file/directory conflict: %s, %s", name1, name2);
-
- if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
- char buffer1[PATH_MAX], buffer2[PATH_MAX];
- struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
- int len1 = 0, len2 = 0, i1, i2, ret = 0;
-
- if (name1 && read_directory(name1, &p1))
- return -1;
- if (name2 && read_directory(name2, &p2)) {
- path_list_clear(&p1, 0);
- return -1;
- }
-
- if (name1) {
- len1 = strlen(name1);
- if (len1 > 0 && name1[len1 - 1] == '/')
- len1--;
- memcpy(buffer1, name1, len1);
- buffer1[len1++] = '/';
- }
-
- if (name2) {
- len2 = strlen(name2);
- if (len2 > 0 && name2[len2 - 1] == '/')
- len2--;
- memcpy(buffer2, name2, len2);
- buffer2[len2++] = '/';
- }
-
- for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
- const char *n1, *n2;
- int comp;
-
- if (i1 == p1.nr)
- comp = 1;
- else if (i2 == p2.nr)
- comp = -1;
- else
- comp = strcmp(p1.items[i1].path,
- p2.items[i2].path);
-
- if (comp > 0)
- n1 = NULL;
- else {
- n1 = buffer1;
- strncpy(buffer1 + len1, p1.items[i1++].path,
- PATH_MAX - len1);
- }
-
- if (comp < 0)
- n2 = NULL;
- else {
- n2 = buffer2;
- strncpy(buffer2 + len2, p2.items[i2++].path,
- PATH_MAX - len2);
- }
-
- ret = queue_diff(o, n1, n2);
- }
- path_list_clear(&p1, 0);
- path_list_clear(&p2, 0);
-
- return ret;
- } else {
- struct diff_filespec *d1, *d2;
-
- if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
- unsigned tmp;
- const char *tmp_c;
- tmp = mode1; mode1 = mode2; mode2 = tmp;
- tmp_c = name1; name1 = name2; name2 = tmp_c;
- }
-
- if (!name1)
- name1 = "/dev/null";
- if (!name2)
- name2 = "/dev/null";
- d1 = alloc_filespec(name1);
- d2 = alloc_filespec(name2);
- fill_filespec(d1, null_sha1, mode1);
- fill_filespec(d2, null_sha1, mode2);
-
- diff_queue(&diff_queued_diff, d1, d2);
- return 0;
- }
-}
-
/*
- * Does the path name a blob in the working tree, or a directory
- * in the working tree?
+ * Has the work tree entity been removed?
+ *
+ * Return 1 if it was removed from the work tree, 0 if an entity to be
+ * compared with the cache entry ce still exists (the latter includes
+ * the case where a directory that is not a submodule repository
+ * exists for ce that is a submodule -- it is a submodule that is not
+ * checked out). Return negative for an error.
*/
-static int is_in_index(const char *path)
+static int check_removed(const struct cache_entry *ce, struct stat *st)
{
- int len, pos;
- struct cache_entry *ce;
-
- len = strlen(path);
- while (path[len-1] == '/')
- len--;
- if (!len)
- return 1; /* "." */
- pos = cache_name_pos(path, len);
- if (0 <= pos)
+ if (lstat(ce->name, st) < 0) {
+ if (errno != ENOENT && errno != ENOTDIR)
+ return -1;
return 1;
- pos = -1 - pos;
- while (pos < active_nr) {
- ce = active_cache[pos++];
- if (ce_namelen(ce) <= len ||
- strncmp(ce->name, path, len) ||
- (ce->name[len] > '/'))
- break; /* path cannot be a prefix */
- if (ce->name[len] == '/')
- return 1;
- }
- return 0;
-}
-
-static int handle_diff_files_args(struct rev_info *revs,
- int argc, const char **argv,
- unsigned int *options)
-{
- *options = 0;
-
- /* revs->max_count == -2 means --no-index */
- while (1 < argc && argv[1][0] == '-') {
- if (!strcmp(argv[1], "--base"))
- revs->max_count = 1;
- else if (!strcmp(argv[1], "--ours"))
- revs->max_count = 2;
- else if (!strcmp(argv[1], "--theirs"))
- revs->max_count = 3;
- else if (!strcmp(argv[1], "-n") ||
- !strcmp(argv[1], "--no-index")) {
- revs->max_count = -2;
- DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
- DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
- }
- else if (!strcmp(argv[1], "-q"))
- *options |= DIFF_SILENT_ON_REMOVED;
- else
- return error("invalid option: %s", argv[1]);
- argv++; argc--;
}
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
+ return 1;
+ if (S_ISDIR(st->st_mode)) {
+ unsigned char sub[20];
- if (revs->max_count == -1 && revs->diffopt.nr_paths == 2) {
/*
- * If two files are specified, and at least one is untracked,
- * default to no-index.
+ * If ce is already a gitlink, we can have a plain
+ * directory (i.e. the submodule is not checked out),
+ * or a checked out submodule. Either case this is not
+ * a case where something was removed from the work tree,
+ * so we will return 0.
+ *
+ * Otherwise, if the directory is not a submodule
+ * repository, that means ce which was a blob turned into
+ * a directory --- the blob was removed!
*/
- read_cache();
- if (!is_in_index(revs->diffopt.paths[0]) ||
- !is_in_index(revs->diffopt.paths[1])) {
- revs->max_count = -2;
- DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
- }
- }
-
- /*
- * Make sure there are NO revision (i.e. pending object) parameter,
- * rev.max_count is reasonable (0 <= n <= 3),
- * there is no other revision filtering parameters.
- */
- if (revs->pending.nr || revs->max_count > 3 ||
- revs->min_age != -1 || revs->max_age != -1)
- return error("no revision allowed with diff-files");
-
- if (revs->max_count == -1 &&
- (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
- revs->combine_merges = revs->dense_combined_merges = 1;
-
- return 0;
-}
-
-static int is_outside_repo(const char *path, int nongit, const char *prefix)
-{
- int i;
- if (nongit || !strcmp(path, "-") || is_absolute_path(path))
- return 1;
- if (prefixcmp(path, "../"))
- return 0;
- if (!prefix)
- return 1;
- for (i = strlen(prefix); !prefixcmp(path, "../"); ) {
- while (i > 0 && prefix[i - 1] != '/')
- i--;
- if (--i < 0)
+ if (!S_ISGITLINK(ce->ce_mode) &&
+ resolve_gitlink_ref(ce->name, "HEAD", sub))
return 1;
- path += 3;
}
return 0;
}
-int setup_diff_no_index(struct rev_info *revs,
- int argc, const char ** argv, int nongit, const char *prefix)
-{
- int i;
- for (i = 1; i < argc; i++)
- if (argv[i][0] != '-' || argv[i][1] == '\0')
- break;
- else if (!strcmp(argv[i], "--")) {
- i++;
- break;
- } else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) {
- i = argc - 3;
- DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
- break;
- }
- if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
- !is_outside_repo(argv[i], nongit, prefix)))
- return -1;
-
- diff_setup(&revs->diffopt);
- for (i = 1; i < argc - 2; )
- if (!strcmp(argv[i], "--no-index"))
- i++;
- else {
- int j = diff_opt_parse(&revs->diffopt,
- argv + i, argc - i);
- if (!j)
- die("invalid diff option/value: %s", argv[i]);
- i += j;
- }
-
- if (prefix) {
- int len = strlen(prefix);
-
- revs->diffopt.paths = xcalloc(2, sizeof(char*));
- for (i = 0; i < 2; i++) {
- const char *p = argv[argc - 2 + i];
- /*
- * stdin should be spelled as '-'; if you have
- * path that is '-', spell it as ./-.
- */
- p = (strcmp(p, "-")
- ? xstrdup(prefix_filename(prefix, len, p))
- : p);
- revs->diffopt.paths[i] = p;
- }
- }
- else
- revs->diffopt.paths = argv + argc - 2;
- revs->diffopt.nr_paths = 2;
- DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
- revs->max_count = -2;
- if (diff_setup_done(&revs->diffopt) < 0)
- die("diff_setup_done failed");
- return 0;
-}
-
-int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
-{
- unsigned int options;
-
- if (handle_diff_files_args(revs, argc, argv, &options))
- return -1;
-
- if (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {
- if (revs->diffopt.nr_paths != 2)
- return error("need two files/directories with --no-index");
- if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
- revs->diffopt.paths[1]))
- return -1;
- diffcore_std(&revs->diffopt);
- diff_flush(&revs->diffopt);
- /*
- * The return code for --no-index imitates diff(1):
- * 0 = no changes, 1 = changes, else error
- */
- return revs->diffopt.found_changes;
- }
-
- if (read_cache() < 0) {
- perror("read_cache");
- return -1;
- }
- return run_diff_files(revs, options);
-}
-
int run_diff_files(struct rev_info *revs, unsigned int option)
{
int entries, i;
@@ -341,10 +61,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
int silent_on_removed = option & DIFF_SILENT_ON_REMOVED;
unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
? CE_MATCH_RACY_IS_DIRTY : 0);
+ char symcache[PATH_MAX];
if (diff_unmerged_stage < 0)
diff_unmerged_stage = 2;
entries = active_nr;
+ symcache[0] = '\0';
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, newmode;
@@ -376,16 +98,17 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
memset(&(dpath->parent[0]), 0,
sizeof(struct combine_diff_parent)*5);
- if (lstat(ce->name, &st) < 0) {
- if (errno != ENOENT && errno != ENOTDIR) {
+ changed = check_removed(ce, &st);
+ if (!changed)
+ dpath->mode = ce_mode_from_stat(ce, st.st_mode);
+ else {
+ if (changed < 0) {
perror(ce->name);
continue;
}
if (silent_on_removed)
continue;
}
- else
- dpath->mode = ce_mode_from_stat(ce, st.st_mode);
while (i < entries) {
struct cache_entry *nce = active_cache[i];
@@ -438,25 +161,30 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (ce_uptodate(ce))
continue;
- if (lstat(ce->name, &st) < 0) {
- if (errno != ENOENT && errno != ENOTDIR) {
+
+ changed = check_removed(ce, &st);
+ if (changed) {
+ if (changed < 0) {
perror(ce->name);
continue;
}
if (silent_on_removed)
continue;
diff_addremove(&revs->diffopt, '-', ce->ce_mode,
- ce->sha1, ce->name, NULL);
+ ce->sha1, ce->name);
continue;
}
changed = ce_match_stat(ce, &st, ce_option);
- if (!changed && !DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
- continue;
+ if (!changed) {
+ ce_mark_uptodate(ce);
+ if (!DIFF_OPT_TST(&revs->diffopt, FIND_COPIES_HARDER))
+ continue;
+ }
oldmode = ce->ce_mode;
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_change(&revs->diffopt, oldmode, newmode,
ce->sha1, (changed ? null_sha1 : ce->sha1),
- ce->name, NULL);
+ ce->name);
}
diffcore_std(&revs->diffopt);
@@ -468,30 +196,38 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
* diff-index
*/
+struct oneway_unpack_data {
+ struct rev_info *revs;
+ char symcache[PATH_MAX];
+};
+
/* A file entry went away or appeared */
static void diff_index_show_file(struct rev_info *revs,
const char *prefix,
struct cache_entry *ce,
- unsigned char *sha1, unsigned int mode)
+ const unsigned char *sha1, unsigned int mode)
{
diff_addremove(&revs->diffopt, prefix[0], mode,
- sha1, ce->name, NULL);
+ sha1, ce->name);
}
static int get_stat_data(struct cache_entry *ce,
- unsigned char **sha1p,
+ const unsigned char **sha1p,
unsigned int *modep,
- int cached, int match_missing)
+ int cached, int match_missing,
+ struct oneway_unpack_data *cbdata)
{
- unsigned char *sha1 = ce->sha1;
+ const unsigned char *sha1 = ce->sha1;
unsigned int mode = ce->ce_mode;
if (!cached) {
- static unsigned char no_sha1[20];
int changed;
struct stat st;
- if (lstat(ce->name, &st) < 0) {
- if (errno == ENOENT && match_missing) {
+ changed = check_removed(ce, &st);
+ if (changed < 0)
+ return -1;
+ else if (changed) {
+ if (match_missing) {
*sha1p = sha1;
*modep = mode;
return 0;
@@ -501,7 +237,7 @@ static int get_stat_data(struct cache_entry *ce,
changed = ce_match_stat(ce, &st, 0);
if (changed) {
mode = ce_mode_from_stat(ce, st.st_mode);
- sha1 = no_sha1;
+ sha1 = null_sha1;
}
}
@@ -510,32 +246,35 @@ static int get_stat_data(struct cache_entry *ce,
return 0;
}
-static void show_new_file(struct rev_info *revs,
+static void show_new_file(struct oneway_unpack_data *cbdata,
struct cache_entry *new,
int cached, int match_missing)
{
- unsigned char *sha1;
+ const unsigned char *sha1;
unsigned int mode;
+ struct rev_info *revs = cbdata->revs;
- /* New file in the index: it might actually be different in
+ /*
+ * New file in the index: it might actually be different in
* the working copy.
*/
- if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0)
+ if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0)
return;
diff_index_show_file(revs, "+", new, sha1, mode);
}
-static int show_modified(struct rev_info *revs,
+static int show_modified(struct oneway_unpack_data *cbdata,
struct cache_entry *old,
struct cache_entry *new,
int report_missing,
int cached, int match_missing)
{
unsigned int mode, oldmode;
- unsigned char *sha1;
+ const unsigned char *sha1;
+ struct rev_info *revs = cbdata->revs;
- if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0) {
+ if (get_stat_data(new, &sha1, &mode, cached, match_missing, cbdata) < 0) {
if (report_missing)
diff_index_show_file(revs, "-", old,
old->sha1, old->ce_mode);
@@ -573,7 +312,7 @@ static int show_modified(struct rev_info *revs,
return 0;
diff_change(&revs->diffopt, oldmode, mode,
- old->sha1, sha1, old->name, NULL);
+ old->sha1, sha1, old->name);
return 0;
}
@@ -601,10 +340,10 @@ static void mark_merge_entries(void)
*/
static void do_oneway_diff(struct unpack_trees_options *o,
struct cache_entry *idx,
- struct cache_entry *tree,
- int idx_pos, int idx_nr)
+ struct cache_entry *tree)
{
- struct rev_info *revs = o->unpack_data;
+ struct oneway_unpack_data *cbdata = o->unpack_data;
+ struct rev_info *revs = cbdata->revs;
int match_missing, cached;
/*
@@ -627,7 +366,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
* Something added to the tree?
*/
if (!tree) {
- show_new_file(revs, idx, cached, match_missing);
+ show_new_file(cbdata, idx, cached, match_missing);
return;
}
@@ -640,35 +379,22 @@ static void do_oneway_diff(struct unpack_trees_options *o,
}
/* Show difference between old and new */
- show_modified(revs, tree, idx, 1, cached, match_missing);
+ show_modified(cbdata, tree, idx, 1, cached, match_missing);
}
-/*
- * Count how many index entries go with the first one
- */
-static inline int count_skip(const struct cache_entry *src, int pos)
+static inline void skip_same_name(struct cache_entry *ce, struct unpack_trees_options *o)
{
- int skip = 1;
-
- /* We can only have multiple entries if the first one is not stage-0 */
- if (ce_stage(src)) {
- struct cache_entry **p = active_cache + pos;
- int namelen = ce_namelen(src);
-
- for (;;) {
- const struct cache_entry *ce;
- pos++;
- if (pos >= active_nr)
- break;
- ce = *++p;
- if (ce_namelen(ce) != namelen)
- break;
- if (memcmp(ce->name, src->name, namelen))
- break;
- skip++;
- }
+ int len = ce_namelen(ce);
+ const struct index_state *index = o->src_index;
+
+ while (o->pos < index->cache_nr) {
+ struct cache_entry *next = index->cache[o->pos];
+ if (len != ce_namelen(next))
+ break;
+ if (memcmp(ce->name, next->name, len))
+ break;
+ o->pos++;
}
- return skip;
}
/*
@@ -686,17 +412,15 @@ static inline int count_skip(const struct cache_entry *src, int pos)
* the fairly complex unpack_trees() semantic requirements, including
* the skipping, the path matching, the type conflict cases etc.
*/
-static int oneway_diff(struct cache_entry **src,
- struct unpack_trees_options *o,
- int index_pos)
+static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
{
- int skip = 0;
struct cache_entry *idx = src[0];
struct cache_entry *tree = src[1];
- struct rev_info *revs = o->unpack_data;
+ struct oneway_unpack_data *cbdata = o->unpack_data;
+ struct rev_info *revs = cbdata->revs;
- if (index_pos >= 0)
- skip = count_skip(idx, index_pos);
+ if (idx && ce_stage(idx))
+ skip_same_name(idx, o);
/*
* Unpack-trees generates a DF/conflict entry if
@@ -708,9 +432,9 @@ static int oneway_diff(struct cache_entry **src,
tree = NULL;
if (ce_path_match(idx ? idx : tree, revs->prune_data))
- do_oneway_diff(o, idx, tree, index_pos, skip);
+ do_oneway_diff(o, idx, tree);
- return skip;
+ return 0;
}
int run_diff_index(struct rev_info *revs, int cached)
@@ -720,6 +444,7 @@ int run_diff_index(struct rev_info *revs, int cached)
const char *tree_name;
struct unpack_trees_options opts;
struct tree_desc t;
+ struct oneway_unpack_data unpack_cb;
mark_merge_entries();
@@ -729,12 +454,16 @@ int run_diff_index(struct rev_info *revs, int cached)
if (!tree)
return error("bad tree object %s", tree_name);
+ unpack_cb.revs = revs;
+ unpack_cb.symcache[0] = '\0';
memset(&opts, 0, sizeof(opts));
opts.head_idx = 1;
opts.index_only = cached;
opts.merge = 1;
opts.fn = oneway_diff;
- opts.unpack_data = revs;
+ opts.unpack_data = &unpack_cb;
+ opts.src_index = &the_index;
+ opts.dst_index = NULL;
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts))
@@ -754,6 +483,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
struct cache_entry *last = NULL;
struct unpack_trees_options opts;
struct tree_desc t;
+ struct oneway_unpack_data unpack_cb;
/*
* This is used by git-blame to run diff-cache internally;
@@ -782,12 +512,16 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
if (!tree)
die("bad tree object %s", sha1_to_hex(tree_sha1));
+ unpack_cb.revs = &revs;
+ unpack_cb.symcache[0] = '\0';
memset(&opts, 0, sizeof(opts));
opts.head_idx = 1;
opts.index_only = 1;
opts.merge = 1;
opts.fn = oneway_diff;
- opts.unpack_data = &revs;
+ opts.unpack_data = &unpack_cb;
+ opts.src_index = &the_index;
+ opts.dst_index = &the_index;
init_tree_desc(&t, tree->buffer, tree->size);
if (unpack_trees(1, &t, &opts))
diff --git a/diff-no-index.c b/diff-no-index.c
new file mode 100644
index 000000000..7d68b7f1b
--- /dev/null
+++ b/diff-no-index.c
@@ -0,0 +1,263 @@
+/*
+ * "diff --no-index" support
+ * Copyright (c) 2007 by Johannes Schindelin
+ * Copyright (c) 2008 by Junio C Hamano
+ */
+
+#include "cache.h"
+#include "color.h"
+#include "commit.h"
+#include "blob.h"
+#include "tag.h"
+#include "diff.h"
+#include "diffcore.h"
+#include "revision.h"
+#include "log-tree.h"
+#include "builtin.h"
+#include "string-list.h"
+
+static int read_directory(const char *path, struct string_list *list)
+{
+ DIR *dir;
+ struct dirent *e;
+
+ if (!(dir = opendir(path)))
+ return error("Could not open directory %s", path);
+
+ while ((e = readdir(dir)))
+ if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
+ string_list_insert(e->d_name, list);
+
+ closedir(dir);
+ return 0;
+}
+
+static int get_mode(const char *path, int *mode)
+{
+ struct stat st;
+
+ if (!path || !strcmp(path, "/dev/null"))
+ *mode = 0;
+ else if (!strcmp(path, "-"))
+ *mode = create_ce_mode(0666);
+ else if (stat(path, &st))
+ return error("Could not access '%s'", path);
+ else
+ *mode = st.st_mode;
+ return 0;
+}
+
+static int queue_diff(struct diff_options *o,
+ const char *name1, const char *name2)
+{
+ int mode1 = 0, mode2 = 0;
+
+ if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
+ return -1;
+
+ if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
+ return error("file/directory conflict: %s, %s", name1, name2);
+
+ if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
+ char buffer1[PATH_MAX], buffer2[PATH_MAX];
+ struct string_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
+ int len1 = 0, len2 = 0, i1, i2, ret = 0;
+
+ if (name1 && read_directory(name1, &p1))
+ return -1;
+ if (name2 && read_directory(name2, &p2)) {
+ string_list_clear(&p1, 0);
+ return -1;
+ }
+
+ if (name1) {
+ len1 = strlen(name1);
+ if (len1 > 0 && name1[len1 - 1] == '/')
+ len1--;
+ memcpy(buffer1, name1, len1);
+ buffer1[len1++] = '/';
+ }
+
+ if (name2) {
+ len2 = strlen(name2);
+ if (len2 > 0 && name2[len2 - 1] == '/')
+ len2--;
+ memcpy(buffer2, name2, len2);
+ buffer2[len2++] = '/';
+ }
+
+ for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
+ const char *n1, *n2;
+ int comp;
+
+ if (i1 == p1.nr)
+ comp = 1;
+ else if (i2 == p2.nr)
+ comp = -1;
+ else
+ comp = strcmp(p1.items[i1].string,
+ p2.items[i2].string);
+
+ if (comp > 0)
+ n1 = NULL;
+ else {
+ n1 = buffer1;
+ strncpy(buffer1 + len1, p1.items[i1++].string,
+ PATH_MAX - len1);
+ }
+
+ if (comp < 0)
+ n2 = NULL;
+ else {
+ n2 = buffer2;
+ strncpy(buffer2 + len2, p2.items[i2++].string,
+ PATH_MAX - len2);
+ }
+
+ ret = queue_diff(o, n1, n2);
+ }
+ string_list_clear(&p1, 0);
+ string_list_clear(&p2, 0);
+
+ return ret;
+ } else {
+ struct diff_filespec *d1, *d2;
+
+ if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
+ unsigned tmp;
+ const char *tmp_c;
+ tmp = mode1; mode1 = mode2; mode2 = tmp;
+ tmp_c = name1; name1 = name2; name2 = tmp_c;
+ }
+
+ if (!name1)
+ name1 = "/dev/null";
+ if (!name2)
+ name2 = "/dev/null";
+ d1 = alloc_filespec(name1);
+ d2 = alloc_filespec(name2);
+ fill_filespec(d1, null_sha1, mode1);
+ fill_filespec(d2, null_sha1, mode2);
+
+ diff_queue(&diff_queued_diff, d1, d2);
+ return 0;
+ }
+}
+
+static int path_outside_repo(const char *path)
+{
+ /*
+ * We have already done setup_git_directory_gently() so we
+ * know we are inside a git work tree already.
+ */
+ const char *work_tree;
+ size_t len;
+
+ if (!is_absolute_path(path))
+ return 0;
+ work_tree = get_git_work_tree();
+ len = strlen(work_tree);
+ if (strncmp(path, work_tree, len) ||
+ (path[len] != '\0' && path[len] != '/'))
+ return 1;
+ return 0;
+}
+
+void diff_no_index(struct rev_info *revs,
+ int argc, const char **argv,
+ int nongit, const char *prefix)
+{
+ int i;
+ int no_index = 0;
+ unsigned options = 0;
+
+ /* Were we asked to do --no-index explicitly? */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "--"))
+ return;
+ if (!strcmp(argv[i], "--no-index"))
+ no_index = 1;
+ if (argv[i][0] != '-')
+ break;
+ }
+
+ if (!no_index && !nongit) {
+ /*
+ * Inside a git repository, without --no-index. Only
+ * when a path outside the repository is given,
+ * e.g. "git diff /var/tmp/[12]", or "git diff
+ * Makefile /var/tmp/Makefile", allow it to be used as
+ * a colourful "diff" replacement.
+ */
+ if ((argc != i + 2) ||
+ (!path_outside_repo(argv[i]) &&
+ !path_outside_repo(argv[i+1])))
+ return;
+ }
+ if (argc != i + 2)
+ die("git diff %s takes two paths",
+ no_index ? "--no-index" : "[--no-index]");
+
+ /*
+ * If the user asked for our exit code then don't start a
+ * pager or we would end up reporting its exit code instead.
+ */
+ if (!DIFF_OPT_TST(&revs->diffopt, EXIT_WITH_STATUS))
+ setup_pager();
+
+ diff_setup(&revs->diffopt);
+ if (!revs->diffopt.output_format)
+ revs->diffopt.output_format = DIFF_FORMAT_PATCH;
+ for (i = 1; i < argc - 2; ) {
+ int j;
+ if (!strcmp(argv[i], "--no-index"))
+ i++;
+ else if (!strcmp(argv[1], "-q"))
+ options |= DIFF_SILENT_ON_REMOVED;
+ else {
+ j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
+ if (!j)
+ die("invalid diff option/value: %s", argv[i]);
+ i += j;
+ }
+ }
+
+ if (prefix) {
+ int len = strlen(prefix);
+
+ revs->diffopt.paths = xcalloc(2, sizeof(char*));
+ for (i = 0; i < 2; i++) {
+ const char *p = argv[argc - 2 + i];
+ /*
+ * stdin should be spelled as '-'; if you have
+ * path that is '-', spell it as ./-.
+ */
+ p = (strcmp(p, "-")
+ ? xstrdup(prefix_filename(prefix, len, p))
+ : p);
+ revs->diffopt.paths[i] = p;
+ }
+ }
+ else
+ revs->diffopt.paths = argv + argc - 2;
+ revs->diffopt.nr_paths = 2;
+
+ DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
+ DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
+
+ revs->max_count = -2;
+ if (diff_setup_done(&revs->diffopt) < 0)
+ die("diff_setup_done failed");
+
+ if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
+ revs->diffopt.paths[1]))
+ exit(1);
+ diffcore_std(&revs->diffopt);
+ diff_flush(&revs->diffopt);
+
+ /*
+ * The return code for --no-index imitates diff(1):
+ * 0 = no changes, 1 = changes, else error
+ */
+ exit(revs->diffopt.found_changes);
+}
diff --git a/diff.c b/diff.c
index d464fe3b2..bf5d5f15a 100644
--- a/diff.c
+++ b/diff.c
@@ -19,8 +19,8 @@
#endif
static int diff_detect_rename_default;
-static int diff_rename_limit_default = 100;
-static int diff_use_color_default;
+static int diff_rename_limit_default = 200;
+int diff_use_color_default = -1;
static const char *external_diff_cmd_cfg;
int diff_auto_refresh_index = 1;
@@ -57,7 +57,7 @@ static int parse_diff_color_slot(const char *var, int ofs)
static struct ll_diff_driver {
const char *name;
struct ll_diff_driver *next;
- char *cmd;
+ const char *cmd;
} *user_diff, **user_diff_tail;
/*
@@ -86,10 +86,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val
user_diff_tail = &(drv->next);
}
- if (!value)
- return error("%s: lacks value", var);
- drv->cmd = strdup(value);
- return 0;
+ return git_config_string(&(drv->cmd), var, value);
}
/*
@@ -121,8 +118,7 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v
pp->next = funcname_pattern_list;
funcname_pattern_list = pp;
}
- if (pp->pattern)
- free(pp->pattern);
+ free(pp->pattern);
pp->pattern = xstrdup(value);
return 0;
}
@@ -133,12 +129,8 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v
* never be affected by the setting of diff.renames
* the user happens to have in the configuration file.
*/
-int git_diff_ui_config(const char *var, const char *value)
+int git_diff_ui_config(const char *var, const char *value, void *cb)
{
- if (!strcmp(var, "diff.renamelimit")) {
- diff_rename_limit_default = git_config_int(var, value);
- return 0;
- }
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
diff_use_color_default = git_config_colorbool(var, value, -1);
return 0;
@@ -157,26 +149,29 @@ int git_diff_ui_config(const char *var, const char *value)
diff_auto_refresh_index = git_config_bool(var, value);
return 0;
}
- if (!strcmp(var, "diff.external")) {
- external_diff_cmd_cfg = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "diff.external"))
+ return git_config_string(&external_diff_cmd_cfg, var, value);
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
- if (ep != var + 4) {
- if (!strcmp(ep, ".command"))
- return parse_lldiff_command(var, ep, value);
- }
+ if (ep != var + 4 && !strcmp(ep, ".command"))
+ return parse_lldiff_command(var, ep, value);
}
- return git_diff_basic_config(var, value);
+ return git_diff_basic_config(var, value, cb);
}
-int git_diff_basic_config(const char *var, const char *value)
+int git_diff_basic_config(const char *var, const char *value, void *cb)
{
+ if (!strcmp(var, "diff.renamelimit")) {
+ diff_rename_limit_default = git_config_int(var, value);
+ return 0;
+ }
+
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
int slot = parse_diff_color_slot(var, 11);
+ if (!value)
+ return config_error_nonbool(var);
color_parse(value, var, diff_colors[slot]);
return 0;
}
@@ -184,12 +179,15 @@ int git_diff_basic_config(const char *var, const char *value)
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
- if (!strcmp(ep, ".funcname"))
+ if (!strcmp(ep, ".funcname")) {
+ if (!value)
+ return config_error_nonbool(var);
return parse_funcname_pattern(var, ep, value);
+ }
}
}
- return git_default_config(var, value);
+ return git_color_default_config(var, value, cb);
}
static char *quote_two(const char *one, const char *two)
@@ -255,40 +253,41 @@ static int count_lines(const char *data, int size)
return count;
}
-static void print_line_count(int count)
+static void print_line_count(FILE *file, int count)
{
switch (count) {
case 0:
- printf("0,0");
+ fprintf(file, "0,0");
break;
case 1:
- printf("1");
+ fprintf(file, "1");
break;
default:
- printf("1,%d", count);
+ fprintf(file, "1,%d", count);
break;
}
}
-static void copy_file(int prefix, const char *data, int size,
- const char *set, const char *reset)
+static void copy_file_with_prefix(FILE *file,
+ int prefix, const char *data, int size,
+ const char *set, const char *reset)
{
int ch, nl_just_seen = 1;
while (0 < size--) {
ch = *data++;
if (nl_just_seen) {
- fputs(set, stdout);
- putchar(prefix);
+ fputs(set, file);
+ putc(prefix, file);
}
if (ch == '\n') {
nl_just_seen = 1;
- fputs(reset, stdout);
+ fputs(reset, file);
} else
nl_just_seen = 0;
- putchar(ch);
+ putc(ch, file);
}
if (!nl_just_seen)
- printf("%s\n\\ No newline at end of file\n", reset);
+ fprintf(file, "%s\n\\ No newline at end of file\n", reset);
}
static void emit_rewrite_diff(const char *name_a,
@@ -321,17 +320,18 @@ static void emit_rewrite_diff(const char *name_a,
diff_populate_filespec(two, 0);
lc_a = count_lines(one->data, one->size);
lc_b = count_lines(two->data, two->size);
- printf("%s--- %s%s%s\n%s+++ %s%s%s\n%s@@ -",
- metainfo, a_name.buf, name_a_tab, reset,
- metainfo, b_name.buf, name_b_tab, reset, fraginfo);
- print_line_count(lc_a);
- printf(" +");
- print_line_count(lc_b);
- printf(" @@%s\n", reset);
+ fprintf(o->file,
+ "%s--- %s%s%s\n%s+++ %s%s%s\n%s@@ -",
+ metainfo, a_name.buf, name_a_tab, reset,
+ metainfo, b_name.buf, name_b_tab, reset, fraginfo);
+ print_line_count(o->file, lc_a);
+ fprintf(o->file, " +");
+ print_line_count(o->file, lc_b);
+ fprintf(o->file, " @@%s\n", reset);
if (lc_a)
- copy_file('-', one->data, one->size, old, reset);
+ copy_file_with_prefix(o->file, '-', one->data, one->size, old, reset);
if (lc_b)
- copy_file('+', two->data, two->size, new, reset);
+ copy_file_with_prefix(o->file, '+', two->data, two->size, new, reset);
}
static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
@@ -371,9 +371,10 @@ static void diff_words_append(char *line, unsigned long len,
struct diff_words_data {
struct xdiff_emit_state xm;
struct diff_words_buffer minus, plus;
+ FILE *file;
};
-static void print_word(struct diff_words_buffer *buffer, int len, int color,
+static void print_word(FILE *file, struct diff_words_buffer *buffer, int len, int color,
int suppress_newline)
{
const char *ptr;
@@ -390,15 +391,15 @@ static void print_word(struct diff_words_buffer *buffer, int len, int color,
len--;
}
- fputs(diff_get_color(1, color), stdout);
- fwrite(ptr, len, 1, stdout);
- fputs(diff_get_color(1, DIFF_RESET), stdout);
+ fputs(diff_get_color(1, color), file);
+ fwrite(ptr, len, 1, file);
+ fputs(diff_get_color(1, DIFF_RESET), file);
if (eol) {
if (suppress_newline)
buffer->suppressed_newline = 1;
else
- putchar('\n');
+ putc('\n', file);
}
}
@@ -408,20 +409,23 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
if (diff_words->minus.suppressed_newline) {
if (line[0] != '+')
- putchar('\n');
+ putc('\n', diff_words->file);
diff_words->minus.suppressed_newline = 0;
}
len--;
switch (line[0]) {
case '-':
- print_word(&diff_words->minus, len, DIFF_FILE_OLD, 1);
+ print_word(diff_words->file,
+ &diff_words->minus, len, DIFF_FILE_OLD, 1);
break;
case '+':
- print_word(&diff_words->plus, len, DIFF_FILE_NEW, 0);
+ print_word(diff_words->file,
+ &diff_words->plus, len, DIFF_FILE_NEW, 0);
break;
case ' ':
- print_word(&diff_words->plus, len, DIFF_PLAIN, 0);
+ print_word(diff_words->file,
+ &diff_words->plus, len, DIFF_PLAIN, 0);
diff_words->minus.current += len;
break;
}
@@ -465,7 +469,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
diff_words->minus.text.size = diff_words->plus.text.size = 0;
if (diff_words->minus.suppressed_newline) {
- putchar('\n');
+ putc('\n', diff_words->file);
diff_words->minus.suppressed_newline = 0;
}
}
@@ -480,6 +484,7 @@ struct emit_callback {
const char **label_path;
struct diff_words_data *diff_words;
int *found_changesp;
+ FILE *file;
};
static void free_diff_words_data(struct emit_callback *ecbdata)
@@ -490,10 +495,8 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
ecbdata->diff_words->plus.text.size)
diff_words_show(ecbdata->diff_words);
- if (ecbdata->diff_words->minus.text.ptr)
- free (ecbdata->diff_words->minus.text.ptr);
- if (ecbdata->diff_words->plus.text.ptr)
- free (ecbdata->diff_words->plus.text.ptr);
+ free (ecbdata->diff_words->minus.text.ptr);
+ free (ecbdata->diff_words->plus.text.ptr);
free(ecbdata->diff_words);
ecbdata->diff_words = NULL;
}
@@ -506,11 +509,17 @@ const char *diff_get_color(int diff_use_color, enum color_diff ix)
return "";
}
-static void emit_line(const char *set, const char *reset, const char *line, int len)
+static void emit_line(FILE *file, const char *set, const char *reset, const char *line, int len)
{
- fputs(set, stdout);
- fwrite(line, len, 1, stdout);
- fputs(reset, stdout);
+ int has_trailing_newline = (len > 0 && line[len-1] == '\n');
+ if (has_trailing_newline)
+ len--;
+
+ fputs(set, file);
+ fwrite(line, len, 1, file);
+ fputs(reset, file);
+ if (has_trailing_newline)
+ fputc('\n', file);
}
static void emit_add_line(const char *reset, struct emit_callback *ecbdata, const char *line, int len)
@@ -519,13 +528,13 @@ static void emit_add_line(const char *reset, struct emit_callback *ecbdata, cons
const char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_NEW);
if (!*ws)
- emit_line(set, reset, line, len);
+ emit_line(ecbdata->file, set, reset, line, len);
else {
/* Emit just the prefix, then the rest. */
- emit_line(set, reset, line, ecbdata->nparents);
- (void)check_and_emit_line(line + ecbdata->nparents,
- len - ecbdata->nparents, ecbdata->ws_rule,
- stdout, set, reset, ws);
+ emit_line(ecbdata->file, set, reset, line, ecbdata->nparents);
+ ws_check_emit(line + ecbdata->nparents,
+ len - ecbdata->nparents, ecbdata->ws_rule,
+ ecbdata->file, set, reset, ws);
}
}
@@ -564,10 +573,10 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
- printf("%s--- %s%s%s\n",
- meta, ecbdata->label_path[0], reset, name_a_tab);
- printf("%s+++ %s%s%s\n",
- meta, ecbdata->label_path[1], reset, name_b_tab);
+ fprintf(ecbdata->file, "%s--- %s%s%s\n",
+ meta, ecbdata->label_path[0], reset, name_a_tab);
+ fprintf(ecbdata->file, "%s+++ %s%s%s\n",
+ meta, ecbdata->label_path[1], reset, name_b_tab);
ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
}
@@ -579,15 +588,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
if (2 <= i && i < len && line[i] == ' ') {
ecbdata->nparents = i - 1;
len = sane_truncate_line(ecbdata, line, len);
- emit_line(diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO),
+ emit_line(ecbdata->file,
+ diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO),
reset, line, len);
if (line[len-1] != '\n')
- putchar('\n');
+ putc('\n', ecbdata->file);
return;
}
if (len < ecbdata->nparents) {
- emit_line(reset, reset, line, len);
+ emit_line(ecbdata->file, reset, reset, line, len);
return;
}
@@ -610,7 +620,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
diff_words_show(ecbdata->diff_words);
line++;
len--;
- emit_line(plain, reset, line, len);
+ emit_line(ecbdata->file, plain, reset, line, len);
return;
}
for (i = 0; i < ecbdata->nparents && len; i++) {
@@ -621,7 +631,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
}
if (color != DIFF_FILE_NEW) {
- emit_line(diff_get_color(ecbdata->color_diff, color),
+ emit_line(ecbdata->file,
+ diff_get_color(ecbdata->color_diff, color),
reset, line, len);
return;
}
@@ -760,20 +771,21 @@ static int scale_linear(int it, int width, int max_change)
return ((it - 1) * (width - 1) + max_change - 1) / (max_change - 1);
}
-static void show_name(const char *prefix, const char *name, int len,
+static void show_name(FILE *file,
+ const char *prefix, const char *name, int len,
const char *reset, const char *set)
{
- printf(" %s%s%-*s%s |", set, prefix, len, name, reset);
+ fprintf(file, " %s%s%-*s%s |", set, prefix, len, name, reset);
}
-static void show_graph(char ch, int cnt, const char *set, const char *reset)
+static void show_graph(FILE *file, char ch, int cnt, const char *set, const char *reset)
{
if (cnt <= 0)
return;
- printf("%s", set);
+ fprintf(file, "%s", set);
while (cnt--)
- putchar(ch);
- printf("%s", reset);
+ putc(ch, file);
+ fprintf(file, "%s", reset);
}
static void fill_print_name(struct diffstat_file *file)
@@ -815,12 +827,12 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
/* Sanity: give at least 5 columns to the graph,
* but leave at least 10 columns for the name.
*/
- if (width < name_width + 15) {
- if (name_width <= 25)
- width = name_width + 15;
- else
- name_width = width - 15;
- }
+ if (width < 25)
+ width = 25;
+ if (name_width < 10)
+ name_width = 10;
+ else if (width < name_width + 15)
+ name_width = width - 15;
/* Find the longest filename and max number of changes */
reset = diff_get_color_opt(options, DIFF_RESET);
@@ -878,18 +890,18 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
}
if (data->files[i]->is_binary) {
- show_name(prefix, name, len, reset, set);
- printf(" Bin ");
- printf("%s%d%s", del_c, deleted, reset);
- printf(" -> ");
- printf("%s%d%s", add_c, added, reset);
- printf(" bytes");
- printf("\n");
+ show_name(options->file, prefix, name, len, reset, set);
+ fprintf(options->file, " Bin ");
+ fprintf(options->file, "%s%d%s", del_c, deleted, reset);
+ fprintf(options->file, " -> ");
+ fprintf(options->file, "%s%d%s", add_c, added, reset);
+ fprintf(options->file, " bytes");
+ fprintf(options->file, "\n");
continue;
}
else if (data->files[i]->is_unmerged) {
- show_name(prefix, name, len, reset, set);
- printf(" Unmerged\n");
+ show_name(options->file, prefix, name, len, reset, set);
+ fprintf(options->file, " Unmerged\n");
continue;
}
else if (!data->files[i]->is_renamed &&
@@ -912,17 +924,19 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
del = scale_linear(del, width, max_change);
total = add + del;
}
- show_name(prefix, name, len, reset, set);
- printf("%5d ", added + deleted);
- show_graph('+', add, add_c, reset);
- show_graph('-', del, del_c, reset);
- putchar('\n');
- }
- printf("%s %d files changed, %d insertions(+), %d deletions(-)%s\n",
+ show_name(options->file, prefix, name, len, reset, set);
+ fprintf(options->file, "%5d%s", added + deleted,
+ added + deleted ? " " : "");
+ show_graph(options->file, '+', add, add_c, reset);
+ show_graph(options->file, '-', del, del_c, reset);
+ fprintf(options->file, "\n");
+ }
+ fprintf(options->file,
+ "%s %d files changed, %d insertions(+), %d deletions(-)%s\n",
set, total_files, adds, dels, reset);
}
-static void show_shortstats(struct diffstat_t* data)
+static void show_shortstats(struct diffstat_t* data, struct diff_options *options)
{
int i, adds = 0, dels = 0, total_files = data->nr;
@@ -943,7 +957,7 @@ static void show_shortstats(struct diffstat_t* data)
}
}
}
- printf(" %d files changed, %d insertions(+), %d deletions(-)\n",
+ fprintf(options->file, " %d files changed, %d insertions(+), %d deletions(-)\n",
total_files, adds, dels);
}
@@ -958,26 +972,148 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
struct diffstat_file *file = data->files[i];
if (file->is_binary)
- printf("-\t-\t");
+ fprintf(options->file, "-\t-\t");
else
- printf("%d\t%d\t", file->added, file->deleted);
+ fprintf(options->file,
+ "%d\t%d\t", file->added, file->deleted);
if (options->line_termination) {
fill_print_name(file);
if (!file->is_renamed)
- write_name_quoted(file->name, stdout,
+ write_name_quoted(file->name, options->file,
options->line_termination);
else {
- fputs(file->print_name, stdout);
- putchar(options->line_termination);
+ fputs(file->print_name, options->file);
+ putc(options->line_termination, options->file);
}
} else {
if (file->is_renamed) {
- putchar('\0');
- write_name_quoted(file->from_name, stdout, '\0');
+ putc('\0', options->file);
+ write_name_quoted(file->from_name, options->file, '\0');
+ }
+ write_name_quoted(file->name, options->file, '\0');
+ }
+ }
+}
+
+struct dirstat_file {
+ const char *name;
+ unsigned long changed;
+};
+
+struct dirstat_dir {
+ struct dirstat_file *files;
+ int alloc, nr, percent, cumulative;
+};
+
+static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long changed, const char *base, int baselen)
+{
+ unsigned long this_dir = 0;
+ unsigned int sources = 0;
+
+ while (dir->nr) {
+ struct dirstat_file *f = dir->files;
+ int namelen = strlen(f->name);
+ unsigned long this;
+ char *slash;
+
+ if (namelen < baselen)
+ break;
+ if (memcmp(f->name, base, baselen))
+ break;
+ slash = strchr(f->name + baselen, '/');
+ if (slash) {
+ int newbaselen = slash + 1 - f->name;
+ this = gather_dirstat(file, dir, changed, f->name, newbaselen);
+ sources++;
+ } else {
+ this = f->changed;
+ dir->files++;
+ dir->nr--;
+ sources += 2;
+ }
+ this_dir += this;
+ }
+
+ /*
+ * We don't report dirstat's for
+ * - the top level
+ * - or cases where everything came from a single directory
+ * under this directory (sources == 1).
+ */
+ if (baselen && sources != 1) {
+ int permille = this_dir * 1000 / changed;
+ if (permille) {
+ int percent = permille / 10;
+ if (percent >= dir->percent) {
+ fprintf(file, "%4d.%01d%% %.*s\n", percent, permille % 10, baselen, base);
+ if (!dir->cumulative)
+ return 0;
}
- write_name_quoted(file->name, stdout, '\0');
}
}
+ return this_dir;
+}
+
+static void show_dirstat(struct diff_options *options)
+{
+ int i;
+ unsigned long changed;
+ struct dirstat_dir dir;
+ struct diff_queue_struct *q = &diff_queued_diff;
+
+ dir.files = NULL;
+ dir.alloc = 0;
+ dir.nr = 0;
+ dir.percent = options->dirstat_percent;
+ dir.cumulative = options->output_format & DIFF_FORMAT_CUMULATIVE;
+
+ changed = 0;
+ for (i = 0; i < q->nr; i++) {
+ struct diff_filepair *p = q->queue[i];
+ const char *name;
+ unsigned long copied, added, damage;
+
+ name = p->one->path ? p->one->path : p->two->path;
+
+ if (DIFF_FILE_VALID(p->one) && DIFF_FILE_VALID(p->two)) {
+ diff_populate_filespec(p->one, 0);
+ diff_populate_filespec(p->two, 0);
+ diffcore_count_changes(p->one, p->two, NULL, NULL, 0,
+ &copied, &added);
+ diff_free_filespec_data(p->one);
+ diff_free_filespec_data(p->two);
+ } else if (DIFF_FILE_VALID(p->one)) {
+ diff_populate_filespec(p->one, 1);
+ copied = added = 0;
+ diff_free_filespec_data(p->one);
+ } else if (DIFF_FILE_VALID(p->two)) {
+ diff_populate_filespec(p->two, 1);
+ copied = 0;
+ added = p->two->size;
+ diff_free_filespec_data(p->two);
+ } else
+ continue;
+
+ /*
+ * Original minus copied is the removed material,
+ * added is the new material. They are both damages
+ * made to the preimage.
+ */
+ damage = (p->one->size - copied) + added;
+
+ ALLOC_GROW(dir.files, dir.nr + 1, dir.alloc);
+ dir.files[dir.nr].name = name;
+ dir.files[dir.nr].changed = damage;
+ changed += damage;
+ dir.nr++;
+ }
+
+ /* This can happen even with many files, if everything was renames */
+ if (!changed)
+ return;
+
+ /* Show all directories with more than x% of the changes */
+ gather_dirstat(options->file, &dir, changed, "", 0);
}
static void free_diffstat_info(struct diffstat_t *diffstat)
@@ -997,39 +1133,85 @@ static void free_diffstat_info(struct diffstat_t *diffstat)
struct checkdiff_t {
struct xdiff_emit_state xm;
const char *filename;
- int lineno, color_diff;
+ int lineno;
+ struct diff_options *o;
unsigned ws_rule;
unsigned status;
+ int trailing_blanks_start;
};
+static int is_conflict_marker(const char *line, unsigned long len)
+{
+ char firstchar;
+ int cnt;
+
+ if (len < 8)
+ return 0;
+ firstchar = line[0];
+ switch (firstchar) {
+ case '=': case '>': case '<':
+ break;
+ default:
+ return 0;
+ }
+ for (cnt = 1; cnt < 7; cnt++)
+ if (line[cnt] != firstchar)
+ return 0;
+ /* line[0] thru line[6] are same as firstchar */
+ if (firstchar == '=') {
+ /* divider between ours and theirs? */
+ if (len != 8 || line[7] != '\n')
+ return 0;
+ } else if (len < 8 || !isspace(line[7])) {
+ /* not divider before ours nor after theirs */
+ return 0;
+ }
+ return 1;
+}
+
static void checkdiff_consume(void *priv, char *line, unsigned long len)
{
struct checkdiff_t *data = priv;
- const char *ws = diff_get_color(data->color_diff, DIFF_WHITESPACE);
- const char *reset = diff_get_color(data->color_diff, DIFF_RESET);
- const char *set = diff_get_color(data->color_diff, DIFF_FILE_NEW);
+ int color_diff = DIFF_OPT_TST(data->o, COLOR_DIFF);
+ const char *ws = diff_get_color(color_diff, DIFF_WHITESPACE);
+ const char *reset = diff_get_color(color_diff, DIFF_RESET);
+ const char *set = diff_get_color(color_diff, DIFF_FILE_NEW);
char *err;
if (line[0] == '+') {
- data->status = check_and_emit_line(line + 1, len - 1,
- data->ws_rule, NULL, NULL, NULL, NULL);
- if (!data->status)
+ unsigned bad;
+ data->lineno++;
+ if (!ws_blank_line(line + 1, len - 1, data->ws_rule))
+ data->trailing_blanks_start = 0;
+ else if (!data->trailing_blanks_start)
+ data->trailing_blanks_start = data->lineno;
+ if (is_conflict_marker(line + 1, len - 1)) {
+ data->status |= 1;
+ fprintf(data->o->file,
+ "%s:%d: leftover conflict marker\n",
+ data->filename, data->lineno);
+ }
+ bad = ws_check(line + 1, len - 1, data->ws_rule);
+ if (!bad)
return;
- err = whitespace_error_string(data->status);
- printf("%s:%d: %s.\n", data->filename, data->lineno, err);
+ data->status |= bad;
+ err = whitespace_error_string(bad);
+ fprintf(data->o->file, "%s:%d: %s.\n",
+ data->filename, data->lineno, err);
free(err);
- emit_line(set, reset, line, 1);
- (void)check_and_emit_line(line + 1, len - 1, data->ws_rule,
- stdout, set, reset, ws);
+ emit_line(data->o->file, set, reset, line, 1);
+ ws_check_emit(line + 1, len - 1, data->ws_rule,
+ data->o->file, set, reset, ws);
+ } else if (line[0] == ' ') {
data->lineno++;
- } else if (line[0] == ' ')
- data->lineno++;
- else if (line[0] == '@') {
+ data->trailing_blanks_start = 0;
+ } else if (line[0] == '@') {
char *plus = strchr(line, '+');
if (plus)
- data->lineno = strtol(plus, NULL, 10);
+ data->lineno = strtol(plus, NULL, 10) - 1;
else
die("invalid diff");
+ data->trailing_blanks_start = 0;
}
}
@@ -1057,7 +1239,7 @@ static unsigned char *deflate_it(char *data,
return deflated;
}
-static void emit_binary_diff_body(mmfile_t *one, mmfile_t *two)
+static void emit_binary_diff_body(FILE *file, mmfile_t *one, mmfile_t *two)
{
void *cp;
void *delta;
@@ -1086,13 +1268,13 @@ static void emit_binary_diff_body(mmfile_t *one, mmfile_t *two)
}
if (delta && delta_size < deflate_size) {
- printf("delta %lu\n", orig_size);
+ fprintf(file, "delta %lu\n", orig_size);
free(deflated);
data = delta;
data_size = delta_size;
}
else {
- printf("literal %lu\n", two->size);
+ fprintf(file, "literal %lu\n", two->size);
free(delta);
data = deflated;
data_size = deflate_size;
@@ -1110,17 +1292,18 @@ static void emit_binary_diff_body(mmfile_t *one, mmfile_t *two)
line[0] = bytes - 26 + 'a' - 1;
encode_85(line + 1, cp, bytes);
cp = (char *) cp + bytes;
- puts(line);
+ fputs(line, file);
+ fputc('\n', file);
}
- printf("\n");
+ fprintf(file, "\n");
free(data);
}
-static void emit_binary_diff(mmfile_t *one, mmfile_t *two)
+static void emit_binary_diff(FILE *file, mmfile_t *one, mmfile_t *two)
{
- printf("GIT binary patch\n");
- emit_binary_diff_body(one, two);
- emit_binary_diff_body(two, one);
+ fprintf(file, "GIT binary patch\n");
+ emit_binary_diff_body(file, one, two);
+ emit_binary_diff_body(file, two, one);
}
static void setup_diff_attr_check(struct git_attr_check *check)
@@ -1197,8 +1380,16 @@ static struct builtin_funcname_pattern {
"new\\|return\\|switch\\|throw\\|while\\)\n"
"^[ ]*\\(\\([ ]*"
"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
- "[ ]*([^;]*$\\)" },
- { "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
+ "[ ]*([^;]*\\)$" },
+ { "pascal", "^\\(\\(procedure\\|function\\|constructor\\|"
+ "destructor\\|interface\\|implementation\\|"
+ "initialization\\|finalization\\)[ \t]*.*\\)$"
+ "\\|"
+ "^\\(.*=[ \t]*\\(class\\|record\\).*\\)$"
+ },
+ { "bibtex", "\\(@[a-zA-Z]\\{1,\\}[ \t]*{\\{0,1\\}[ \t]*[^ \t\"@',\\#}{~%]*\\).*$" },
+ { "tex", "^\\(\\\\\\(\\(sub\\)*section\\|chapter\\|part\\)\\*\\{0,1\\}{.*\\)$" },
+ { "ruby", "^\\s*\\(\\(class\\|module\\|def\\)\\s.*\\)$" },
};
static const char *diff_funcname_pattern(struct diff_filespec *one)
@@ -1251,25 +1442,25 @@ static void builtin_diff(const char *name_a,
b_two = quote_two(o->b_prefix, name_b + (*name_b == '/'));
lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null";
- printf("%sdiff --git %s %s%s\n", set, a_one, b_two, reset);
+ fprintf(o->file, "%sdiff --git %s %s%s\n", set, a_one, b_two, reset);
if (lbl[0][0] == '/') {
/* /dev/null */
- printf("%snew file mode %06o%s\n", set, two->mode, reset);
+ fprintf(o->file, "%snew file mode %06o%s\n", set, two->mode, reset);
if (xfrm_msg && xfrm_msg[0])
- printf("%s%s%s\n", set, xfrm_msg, reset);
+ fprintf(o->file, "%s%s%s\n", set, xfrm_msg, reset);
}
else if (lbl[1][0] == '/') {
- printf("%sdeleted file mode %06o%s\n", set, one->mode, reset);
+ fprintf(o->file, "%sdeleted file mode %06o%s\n", set, one->mode, reset);
if (xfrm_msg && xfrm_msg[0])
- printf("%s%s%s\n", set, xfrm_msg, reset);
+ fprintf(o->file, "%s%s%s\n", set, xfrm_msg, reset);
}
else {
if (one->mode != two->mode) {
- printf("%sold mode %06o%s\n", set, one->mode, reset);
- printf("%snew mode %06o%s\n", set, two->mode, reset);
+ fprintf(o->file, "%sold mode %06o%s\n", set, one->mode, reset);
+ fprintf(o->file, "%snew mode %06o%s\n", set, two->mode, reset);
}
if (xfrm_msg && xfrm_msg[0])
- printf("%s%s%s\n", set, xfrm_msg, reset);
+ fprintf(o->file, "%s%s%s\n", set, xfrm_msg, reset);
/*
* we do not run diff between different kind
* of objects.
@@ -1293,10 +1484,10 @@ static void builtin_diff(const char *name_a,
!memcmp(mf1.ptr, mf2.ptr, mf1.size))
goto free_ab_and_return;
if (DIFF_OPT_TST(o, BINARY))
- emit_binary_diff(&mf1, &mf2);
+ emit_binary_diff(o->file, &mf1, &mf2);
else
- printf("Binary files %s and %s differ\n",
- lbl[0], lbl[1]);
+ fprintf(o->file, "Binary files %s and %s differ\n",
+ lbl[0], lbl[1]);
o->found_changes = 1;
}
else {
@@ -1318,6 +1509,7 @@ static void builtin_diff(const char *name_a,
ecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
ecbdata.found_changesp = &o->found_changes;
ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a);
+ ecbdata.file = o->file;
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
xecfg.ctxlen = o->context;
xecfg.flags = XDL_EMIT_FUNCNAMES;
@@ -1332,9 +1524,11 @@ static void builtin_diff(const char *name_a,
ecb.outf = xdiff_outf;
ecb.priv = &ecbdata;
ecbdata.xm.consume = fn_out_consume;
- if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
+ if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS)) {
ecbdata.diff_words =
xcalloc(1, sizeof(struct diff_words_data));
+ ecbdata.diff_words->file = o->file;
+ }
xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
free_diff_words_data(&ecbdata);
@@ -1397,8 +1591,10 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
}
static void builtin_checkdiff(const char *name_a, const char *name_b,
- struct diff_filespec *one,
- struct diff_filespec *two, struct diff_options *o)
+ const char *attr_path,
+ struct diff_filespec *one,
+ struct diff_filespec *two,
+ struct diff_options *o)
{
mmfile_t mf1, mf2;
struct checkdiff_t data;
@@ -1410,12 +1606,18 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
data.xm.consume = checkdiff_consume;
data.filename = name_b ? name_b : name_a;
data.lineno = 0;
- data.color_diff = DIFF_OPT_TST(o, COLOR_DIFF);
- data.ws_rule = whitespace_rule(data.filename);
+ data.o = o;
+ data.ws_rule = whitespace_rule(attr_path);
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
die("unable to read files to diff");
+ /*
+ * All the other codepaths check both sides, but not checking
+ * the "old" side here is deliberate. We are checking the newly
+ * introduced changes, and as long as the "new" side is text, we
+ * can and should check what it introduces.
+ */
if (diff_filespec_is_binary(two))
goto free_and_return;
else {
@@ -1429,6 +1631,13 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
ecb.outf = xdiff_outf;
ecb.priv = &data;
xdi_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
+
+ if ((data.ws_rule & WS_TRAILING_SPACE) &&
+ data.trailing_blanks_start) {
+ fprintf(o->file, "%s:%d: ends with blank lines.\n",
+ data.filename, data.trailing_blanks_start);
+ data.status = 1; /* report errors */
+ }
}
free_and_return:
diff_free_filespec_data(one);
@@ -1629,7 +1838,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
* Convert from working tree format to canonical git format
*/
strbuf_init(&buf, 0);
- if (convert_to_git(s->path, s->data, s->size, &buf)) {
+ if (convert_to_git(s->path, s->data, s->size, &buf, safe_crlf)) {
size_t size = 0;
munmap(s->data, s->size);
s->should_munmap = 0;
@@ -1836,6 +2045,9 @@ static const char *external_diff_attr(const char *name)
{
struct git_attr_check attr_diff_check;
+ if (!name)
+ return NULL;
+
setup_diff_attr_check(&attr_diff_check);
if (!git_checkattr(name, 1, &attr_diff_check)) {
const char *value = attr_diff_check.value;
@@ -1855,6 +2067,7 @@ static const char *external_diff_attr(const char *name)
static void run_diff_cmd(const char *pgm,
const char *name,
const char *other,
+ const char *attr_path,
struct diff_filespec *one,
struct diff_filespec *two,
const char *xfrm_msg,
@@ -1864,7 +2077,7 @@ static void run_diff_cmd(const char *pgm,
if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
pgm = NULL;
else {
- const char *cmd = external_diff_attr(name);
+ const char *cmd = external_diff_attr(attr_path);
if (cmd)
pgm = cmd;
}
@@ -1878,7 +2091,7 @@ static void run_diff_cmd(const char *pgm,
builtin_diff(name, other ? other : name,
one, two, xfrm_msg, o, complete_rewrite);
else
- printf("* Unmerged path %s\n", name);
+ fprintf(o->file, "* Unmerged path %s\n", name);
}
static void diff_fill_sha1_info(struct diff_filespec *one)
@@ -1905,6 +2118,15 @@ static int similarity_index(struct diff_filepair *p)
return p->score * 100 / MAX_SCORE;
}
+static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
+{
+ /* Strip the prefix but do not molest /dev/null and absolute paths */
+ if (*namep && **namep != '/')
+ *namep += prefix_length;
+ if (*otherp && **otherp != '/')
+ *otherp += prefix_length;
+}
+
static void run_diff(struct diff_filepair *p, struct diff_options *o)
{
const char *pgm = external_diff();
@@ -1914,16 +2136,21 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
struct diff_filespec *two = p->two;
const char *name;
const char *other;
+ const char *attr_path;
int complete_rewrite = 0;
+ name = p->one->path;
+ other = (strcmp(name, p->two->path) ? p->two->path : NULL);
+ attr_path = name;
+ if (o->prefix_length)
+ strip_prefix(o->prefix_length, &name, &other);
if (DIFF_PAIR_UNMERGED(p)) {
- run_diff_cmd(pgm, p->one->path, NULL, NULL, NULL, NULL, o, 0);
+ run_diff_cmd(pgm, name, NULL, attr_path,
+ NULL, NULL, NULL, o, 0);
return;
}
- name = p->one->path;
- other = (strcmp(name, p->two->path) ? p->two->path : NULL);
diff_fill_sha1_info(one);
diff_fill_sha1_info(two);
@@ -1986,15 +2213,17 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
* needs to be split into deletion and creation.
*/
struct diff_filespec *null = alloc_filespec(two->path);
- run_diff_cmd(NULL, name, other, one, null, xfrm_msg, o, 0);
+ run_diff_cmd(NULL, name, other, attr_path,
+ one, null, xfrm_msg, o, 0);
free(null);
null = alloc_filespec(one->path);
- run_diff_cmd(NULL, name, other, null, two, xfrm_msg, o, 0);
+ run_diff_cmd(NULL, name, other, attr_path,
+ null, two, xfrm_msg, o, 0);
free(null);
}
else
- run_diff_cmd(pgm, name, other, one, two, xfrm_msg, o,
- complete_rewrite);
+ run_diff_cmd(pgm, name, other, attr_path,
+ one, two, xfrm_msg, o, complete_rewrite);
strbuf_release(&msg);
}
@@ -2015,6 +2244,9 @@ static void run_diffstat(struct diff_filepair *p, struct diff_options *o,
name = p->one->path;
other = (strcmp(name, p->two->path) ? p->two->path : NULL);
+ if (o->prefix_length)
+ strip_prefix(o->prefix_length, &name, &other);
+
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
@@ -2027,6 +2259,7 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
{
const char *name;
const char *other;
+ const char *attr_path;
if (DIFF_PAIR_UNMERGED(p)) {
/* unmerged */
@@ -2035,25 +2268,32 @@ static void run_checkdiff(struct diff_filepair *p, struct diff_options *o)
name = p->one->path;
other = (strcmp(name, p->two->path) ? p->two->path : NULL);
+ attr_path = other ? other : name;
+
+ if (o->prefix_length)
+ strip_prefix(o->prefix_length, &name, &other);
diff_fill_sha1_info(p->one);
diff_fill_sha1_info(p->two);
- builtin_checkdiff(name, other, p->one, p->two, o);
+ builtin_checkdiff(name, other, attr_path, p->one, p->two, o);
}
void diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
+
+ options->file = stdout;
+
options->line_termination = '\n';
options->break_opt = -1;
options->rename_limit = -1;
+ options->dirstat_percent = 3;
options->context = 3;
- options->msg_sep = "";
options->change = diff_change;
options->add_remove = diff_addremove;
- if (diff_use_color_default)
+ if (diff_use_color_default > 0)
DIFF_OPT_SET(options, COLOR_DIFF);
else
DIFF_OPT_CLR(options, COLOR_DIFF);
@@ -2081,6 +2321,13 @@ int diff_setup_done(struct diff_options *options)
if (DIFF_OPT_TST(options, FIND_COPIES_HARDER))
options->detect_rename = DIFF_DETECT_COPY;
+ if (!DIFF_OPT_TST(options, RELATIVE_NAME))
+ options->prefix = NULL;
+ if (options->prefix)
+ options->prefix_length = strlen(options->prefix);
+ else
+ options->prefix_length = 0;
+
if (options->output_format & (DIFF_FORMAT_NAME |
DIFF_FORMAT_NAME_STATUS |
DIFF_FORMAT_CHECKDIFF |
@@ -2089,6 +2336,7 @@ int diff_setup_done(struct diff_options *options)
DIFF_FORMAT_NUMSTAT |
DIFF_FORMAT_DIFFSTAT |
DIFF_FORMAT_SHORTSTAT |
+ DIFF_FORMAT_DIRSTAT |
DIFF_FORMAT_SUMMARY |
DIFF_FORMAT_PATCH);
@@ -2100,6 +2348,7 @@ int diff_setup_done(struct diff_options *options)
DIFF_FORMAT_NUMSTAT |
DIFF_FORMAT_DIFFSTAT |
DIFF_FORMAT_SHORTSTAT |
+ DIFF_FORMAT_DIRSTAT |
DIFF_FORMAT_SUMMARY |
DIFF_FORMAT_CHECKDIFF))
DIFF_OPT_SET(options, RECURSIVE);
@@ -2210,6 +2459,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->output_format |= DIFF_FORMAT_NUMSTAT;
else if (!strcmp(arg, "--shortstat"))
options->output_format |= DIFF_FORMAT_SHORTSTAT;
+ else if (opt_arg(arg, 'X', "dirstat", &options->dirstat_percent))
+ options->output_format |= DIFF_FORMAT_DIRSTAT;
+ else if (!strcmp(arg, "--cumulative"))
+ options->output_format |= DIFF_FORMAT_CUMULATIVE;
else if (!strcmp(arg, "--check"))
options->output_format |= DIFF_FORMAT_CHECKDIFF;
else if (!strcmp(arg, "--summary"))
@@ -2269,6 +2522,12 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
}
else if (!strcmp(arg, "--no-renames"))
options->detect_rename = 0;
+ else if (!strcmp(arg, "--relative"))
+ DIFF_OPT_SET(options, RELATIVE_NAME);
+ else if (!prefixcmp(arg, "--relative=")) {
+ DIFF_OPT_SET(options, RELATIVE_NAME);
+ options->prefix = arg + 11;
+ }
/* xdiff options */
else if (!strcmp(arg, "-w") || !strcmp(arg, "--ignore-all-space"))
@@ -2307,6 +2566,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
DIFF_OPT_SET(options, ALLOW_EXTERNAL);
else if (!strcmp(arg, "--no-ext-diff"))
DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
+ else if (!strcmp(arg, "--ignore-submodules"))
+ DIFF_OPT_SET(options, IGNORE_SUBMODULES);
/* misc options */
else if (!strcmp(arg, "-z"))
@@ -2338,7 +2599,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->b_prefix = arg + 13;
else if (!strcmp(arg, "--no-prefix"))
options->a_prefix = options->b_prefix = "";
- else
+ else if (!prefixcmp(arg, "--output=")) {
+ options->file = fopen(arg + strlen("--output="), "w");
+ options->close_file = 1;
+ } else
return 0;
return 1;
}
@@ -2449,8 +2713,6 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len)
return sha1_to_hex(sha1);
abbrev = find_unique_abbrev(sha1, len);
- if (!abbrev)
- return sha1_to_hex(sha1);
abblen = strlen(abbrev);
if (abblen < 37) {
static char hex[41];
@@ -2469,23 +2731,31 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
int inter_name_termination = line_termination ? '\t' : '\0';
if (!(opt->output_format & DIFF_FORMAT_NAME_STATUS)) {
- printf(":%06o %06o %s ", p->one->mode, p->two->mode,
- diff_unique_abbrev(p->one->sha1, opt->abbrev));
- printf("%s ", diff_unique_abbrev(p->two->sha1, opt->abbrev));
+ fprintf(opt->file, ":%06o %06o %s ", p->one->mode, p->two->mode,
+ diff_unique_abbrev(p->one->sha1, opt->abbrev));
+ fprintf(opt->file, "%s ", diff_unique_abbrev(p->two->sha1, opt->abbrev));
}
if (p->score) {
- printf("%c%03d%c", p->status, similarity_index(p),
- inter_name_termination);
+ fprintf(opt->file, "%c%03d%c", p->status, similarity_index(p),
+ inter_name_termination);
} else {
- printf("%c%c", p->status, inter_name_termination);
+ fprintf(opt->file, "%c%c", p->status, inter_name_termination);
}
- if (p->status == DIFF_STATUS_COPIED || p->status == DIFF_STATUS_RENAMED) {
- write_name_quoted(p->one->path, stdout, inter_name_termination);
- write_name_quoted(p->two->path, stdout, line_termination);
+ if (p->status == DIFF_STATUS_COPIED ||
+ p->status == DIFF_STATUS_RENAMED) {
+ const char *name_a, *name_b;
+ name_a = p->one->path;
+ name_b = p->two->path;
+ strip_prefix(opt->prefix_length, &name_a, &name_b);
+ write_name_quoted(name_a, opt->file, inter_name_termination);
+ write_name_quoted(name_b, opt->file, line_termination);
} else {
- const char *path = p->one->mode ? p->one->path : p->two->path;
- write_name_quoted(path, stdout, line_termination);
+ const char *name_a, *name_b;
+ name_a = p->one->mode ? p->one->path : p->two->path;
+ name_b = NULL;
+ strip_prefix(opt->prefix_length, &name_a, &name_b);
+ write_name_quoted(name_a, opt->file, line_termination);
}
}
@@ -2682,62 +2952,67 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
diff_flush_checkdiff(p, opt);
else if (fmt & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS))
diff_flush_raw(p, opt);
- else if (fmt & DIFF_FORMAT_NAME)
- write_name_quoted(p->two->path, stdout, opt->line_termination);
+ else if (fmt & DIFF_FORMAT_NAME) {
+ const char *name_a, *name_b;
+ name_a = p->two->path;
+ name_b = NULL;
+ strip_prefix(opt->prefix_length, &name_a, &name_b);
+ write_name_quoted(name_a, opt->file, opt->line_termination);
+ }
}
-static void show_file_mode_name(const char *newdelete, struct diff_filespec *fs)
+static void show_file_mode_name(FILE *file, const char *newdelete, struct diff_filespec *fs)
{
if (fs->mode)
- printf(" %s mode %06o ", newdelete, fs->mode);
+ fprintf(file, " %s mode %06o ", newdelete, fs->mode);
else
- printf(" %s ", newdelete);
- write_name_quoted(fs->path, stdout, '\n');
+ fprintf(file, " %s ", newdelete);
+ write_name_quoted(fs->path, file, '\n');
}
-static void show_mode_change(struct diff_filepair *p, int show_name)
+static void show_mode_change(FILE *file, struct diff_filepair *p, int show_name)
{
if (p->one->mode && p->two->mode && p->one->mode != p->two->mode) {
- printf(" mode change %06o => %06o%c", p->one->mode, p->two->mode,
+ fprintf(file, " mode change %06o => %06o%c", p->one->mode, p->two->mode,
show_name ? ' ' : '\n');
if (show_name) {
- write_name_quoted(p->two->path, stdout, '\n');
+ write_name_quoted(p->two->path, file, '\n');
}
}
}
-static void show_rename_copy(const char *renamecopy, struct diff_filepair *p)
+static void show_rename_copy(FILE *file, const char *renamecopy, struct diff_filepair *p)
{
char *names = pprint_rename(p->one->path, p->two->path);
- printf(" %s %s (%d%%)\n", renamecopy, names, similarity_index(p));
+ fprintf(file, " %s %s (%d%%)\n", renamecopy, names, similarity_index(p));
free(names);
- show_mode_change(p, 0);
+ show_mode_change(file, p, 0);
}
-static void diff_summary(struct diff_filepair *p)
+static void diff_summary(FILE *file, struct diff_filepair *p)
{
switch(p->status) {
case DIFF_STATUS_DELETED:
- show_file_mode_name("delete", p->one);
+ show_file_mode_name(file, "delete", p->one);
break;
case DIFF_STATUS_ADDED:
- show_file_mode_name("create", p->two);
+ show_file_mode_name(file, "create", p->two);
break;
case DIFF_STATUS_COPIED:
- show_rename_copy("copy", p);
+ show_rename_copy(file, "copy", p);
break;
case DIFF_STATUS_RENAMED:
- show_rename_copy("rename", p);
+ show_rename_copy(file, "rename", p);
break;
default:
if (p->score) {
- fputs(" rewrite ", stdout);
- write_name_quoted(p->two->path, stdout, ' ');
- printf("(%d%%)\n", similarity_index(p));
+ fputs(" rewrite ", file);
+ write_name_quoted(p->two->path, file, ' ');
+ fprintf(file, "(%d%%)\n", similarity_index(p));
}
- show_mode_change(p, !p->score);
+ show_mode_change(file, p, !p->score);
break;
}
}
@@ -2943,24 +3218,25 @@ void diff_flush(struct diff_options *options)
if (output_format & DIFF_FORMAT_DIFFSTAT)
show_stats(&diffstat, options);
if (output_format & DIFF_FORMAT_SHORTSTAT)
- show_shortstats(&diffstat);
+ show_shortstats(&diffstat, options);
free_diffstat_info(&diffstat);
separator++;
}
+ if (output_format & DIFF_FORMAT_DIRSTAT)
+ show_dirstat(options);
if (output_format & DIFF_FORMAT_SUMMARY && !is_summary_empty(q)) {
for (i = 0; i < q->nr; i++)
- diff_summary(q->queue[i]);
+ diff_summary(options->file, q->queue[i]);
separator++;
}
if (output_format & DIFF_FORMAT_PATCH) {
if (separator) {
+ putc(options->line_termination, options->file);
if (options->stat_sep) {
/* attach patch instead of inline */
- fputs(options->stat_sep, stdout);
- } else {
- putchar(options->line_termination);
+ fputs(options->stat_sep, options->file);
}
}
@@ -2980,6 +3256,8 @@ free_queue:
free(q->queue);
q->queue = NULL;
q->nr = q->alloc = 0;
+ if (options->close_file)
+ fclose(options->file);
}
static void diffcore_apply_filter(const char *filter)
@@ -3042,11 +3320,8 @@ static void diffcore_apply_filter(const char *filter)
static int diff_filespec_is_identical(struct diff_filespec *one,
struct diff_filespec *two)
{
- if (S_ISGITLINK(one->mode)) {
- diff_fill_sha1_info(one);
- diff_fill_sha1_info(two);
- return !hashcmp(one->sha1, two->sha1);
- }
+ if (S_ISGITLINK(one->mode))
+ return 0;
if (diff_populate_filespec(one, 0))
return 0;
if (diff_populate_filespec(two, 0))
@@ -3146,11 +3421,13 @@ int diff_result_code(struct diff_options *opt, int status)
void diff_addremove(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
- const char *base, const char *path)
+ const char *concatpath)
{
- char concatpath[PATH_MAX];
struct diff_filespec *one, *two;
+ if (DIFF_OPT_TST(options, IGNORE_SUBMODULES) && S_ISGITLINK(mode))
+ return;
+
/* This may look odd, but it is a preparation for
* feeding "there are unchanged files which should
* not produce diffs, but when you are doing copy
@@ -3167,8 +3444,10 @@ void diff_addremove(struct diff_options *options,
addremove = (addremove == '+' ? '-' :
addremove == '-' ? '+' : addremove);
- if (!path) path = "";
- sprintf(concatpath, "%s%s", base, path);
+ if (options->prefix &&
+ strncmp(concatpath, options->prefix, options->prefix_length))
+ return;
+
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
@@ -3185,19 +3464,25 @@ void diff_change(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
- const char *base, const char *path)
+ const char *concatpath)
{
- char concatpath[PATH_MAX];
struct diff_filespec *one, *two;
+ if (DIFF_OPT_TST(options, IGNORE_SUBMODULES) && S_ISGITLINK(old_mode)
+ && S_ISGITLINK(new_mode))
+ return;
+
if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
unsigned tmp;
const unsigned char *tmp_c;
tmp = old_mode; old_mode = new_mode; new_mode = tmp;
tmp_c = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_c;
}
- if (!path) path = "";
- sprintf(concatpath, "%s%s", base, path);
+
+ if (options->prefix &&
+ strncmp(concatpath, options->prefix, options->prefix_length))
+ return;
+
one = alloc_filespec(concatpath);
two = alloc_filespec(concatpath);
fill_filespec(one, old_sha1, old_mode);
@@ -3212,6 +3497,11 @@ void diff_unmerge(struct diff_options *options,
unsigned mode, const unsigned char *sha1)
{
struct diff_filespec *one, *two;
+
+ if (options->prefix &&
+ strncmp(path, options->prefix, options->prefix_length))
+ return;
+
one = alloc_filespec(path);
two = alloc_filespec(path);
fill_filespec(one, sha1, mode);
diff --git a/diff.h b/diff.h
index 073d5cbf1..50fb5ddb0 100644
--- a/diff.h
+++ b/diff.h
@@ -14,12 +14,12 @@ typedef void (*change_fn_t)(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
- const char *base, const char *path);
+ const char *fullpath);
typedef void (*add_remove_fn_t)(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
- const char *base, const char *path);
+ const char *fullpath);
typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
struct diff_options *options, void *data);
@@ -30,6 +30,8 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
#define DIFF_FORMAT_SUMMARY 0x0008
#define DIFF_FORMAT_PATCH 0x0010
#define DIFF_FORMAT_SHORTSTAT 0x0020
+#define DIFF_FORMAT_DIRSTAT 0x0040
+#define DIFF_FORMAT_CUMULATIVE 0x0080
/* These override all above */
#define DIFF_FORMAT_NAME 0x0100
@@ -60,6 +62,8 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
#define DIFF_OPT_EXIT_WITH_STATUS (1 << 14)
#define DIFF_OPT_REVERSE_DIFF (1 << 15)
#define DIFF_OPT_CHECK_FAILED (1 << 16)
+#define DIFF_OPT_RELATIVE_NAME (1 << 17)
+#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
#define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
#define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
#define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)
@@ -80,9 +84,12 @@ struct diff_options {
int pickaxe_opts;
int rename_score;
int rename_limit;
+ int warn_on_too_large_rename;
+ int dirstat_percent;
int setup;
int abbrev;
- const char *msg_sep;
+ const char *prefix;
+ int prefix_length;
const char *stat_sep;
long xdl_opts;
@@ -92,6 +99,9 @@ struct diff_options {
/* this is set by diffcore for DIFF_FORMAT_PATCH */
int found_changes;
+ FILE *file;
+ int close_file;
+
int nr_paths;
const char **paths;
int *pathlens;
@@ -154,14 +164,13 @@ extern void diff_addremove(struct diff_options *,
int addremove,
unsigned mode,
const unsigned char *sha1,
- const char *base,
- const char *path);
+ const char *fullpath);
extern void diff_change(struct diff_options *,
unsigned mode1, unsigned mode2,
const unsigned char *sha1,
const unsigned char *sha2,
- const char *base, const char *path);
+ const char *fullpath);
extern void diff_unmerge(struct diff_options *,
const char *path,
@@ -172,8 +181,9 @@ extern void diff_unmerge(struct diff_options *,
#define DIFF_SETUP_USE_CACHE 2
#define DIFF_SETUP_USE_SIZE_CACHE 4
-extern int git_diff_basic_config(const char *var, const char *value);
-extern int git_diff_ui_config(const char *var, const char *value);
+extern int git_diff_basic_config(const char *var, const char *value, void *cb);
+extern int git_diff_ui_config(const char *var, const char *value, void *cb);
+extern int diff_use_color_default;
extern void diff_setup(struct diff_options *);
extern int diff_opt_parse(struct diff_options *, const char **, int);
extern int diff_setup_done(struct diff_options *);
@@ -240,10 +250,6 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);
/* report racily-clean paths as modified */
#define DIFF_RACY_IS_MODIFIED 02
extern int run_diff_files(struct rev_info *revs, unsigned int option);
-extern int setup_diff_no_index(struct rev_info *revs,
- int argc, const char ** argv, int nongit, const char *prefix);
-extern int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv);
-
extern int run_diff_index(struct rev_info *revs, int cached);
extern int do_diff_cache(const unsigned char *, struct diff_options *);
@@ -251,4 +257,6 @@ extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
extern int diff_result_code(struct diff_options *, int);
+extern void diff_no_index(struct rev_info *, int, const char **, int, const char *);
+
#endif /* DIFF_H */
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 3d377251b..1b2ebb400 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -112,8 +112,8 @@ static int basename_same(struct diff_filespec *src, struct diff_filespec *dst)
struct diff_score {
int src; /* index in rename_src */
int dst; /* index in rename_dst */
- int score;
- int name_score;
+ unsigned short score;
+ short name_score;
};
static int estimate_similarity(struct diff_filespec *src,
@@ -223,6 +223,12 @@ static int score_compare(const void *a_, const void *b_)
{
const struct diff_score *a = a_, *b = b_;
+ /* sink the unused ones to the bottom */
+ if (a->dst < 0)
+ return (0 <= b->dst);
+ else if (b->dst < 0)
+ return -1;
+
if (a->score == b->score)
return b->name_score - a->name_score;
@@ -387,6 +393,22 @@ static int find_exact_renames(void)
return i;
}
+#define NUM_CANDIDATE_PER_DST 4
+static void record_if_better(struct diff_score m[], struct diff_score *o)
+{
+ int i, worst;
+
+ /* find the worst one */
+ worst = 0;
+ for (i = 1; i < NUM_CANDIDATE_PER_DST; i++)
+ if (score_compare(&m[i], &m[worst]) > 0)
+ worst = i;
+
+ /* is it better than the worst one? */
+ if (score_compare(&m[worst], o) > 0)
+ m[worst] = *o;
+}
+
void diffcore_rename(struct diff_options *options)
{
int detect_rename = options->detect_rename;
@@ -468,52 +490,68 @@ void diffcore_rename(struct diff_options *options)
*/
if (rename_limit <= 0 || rename_limit > 32767)
rename_limit = 32767;
- if (num_create > rename_limit && num_src > rename_limit)
- goto cleanup;
- if (num_create * num_src > rename_limit * rename_limit)
+ if ((num_create > rename_limit && num_src > rename_limit) ||
+ (num_create * num_src > rename_limit * rename_limit)) {
+ if (options->warn_on_too_large_rename)
+ warning("too many files, skipping inexact rename detection");
goto cleanup;
+ }
- mx = xmalloc(sizeof(*mx) * num_create * num_src);
+ mx = xcalloc(num_create * NUM_CANDIDATE_PER_DST, sizeof(*mx));
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
- int base = dst_cnt * num_src;
struct diff_filespec *two = rename_dst[i].two;
+ struct diff_score *m;
+
if (rename_dst[i].pair)
continue; /* dealt with exact match already. */
+
+ m = &mx[dst_cnt * NUM_CANDIDATE_PER_DST];
+ for (j = 0; j < NUM_CANDIDATE_PER_DST; j++)
+ m[j].dst = -1;
+
for (j = 0; j < rename_src_nr; j++) {
struct diff_filespec *one = rename_src[j].one;
- struct diff_score *m = &mx[base+j];
- m->src = j;
- m->dst = i;
- m->score = estimate_similarity(one, two,
- minimum_score);
- m->name_score = basename_same(one, two);
+ struct diff_score this_src;
+ this_src.score = estimate_similarity(one, two,
+ minimum_score);
+ this_src.name_score = basename_same(one, two);
+ this_src.dst = i;
+ this_src.src = j;
+ record_if_better(m, &this_src);
diff_free_filespec_blob(one);
}
/* We do not need the text anymore */
diff_free_filespec_blob(two);
dst_cnt++;
}
+
/* cost matrix sorted by most to least similar pair */
- qsort(mx, num_create * num_src, sizeof(*mx), score_compare);
- for (i = 0; i < num_create * num_src; i++) {
- struct diff_rename_dst *dst = &rename_dst[mx[i].dst];
- struct diff_filespec *src;
+ qsort(mx, dst_cnt * NUM_CANDIDATE_PER_DST, sizeof(*mx), score_compare);
+
+ for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
+ struct diff_rename_dst *dst;
+
+ if ((mx[i].dst < 0) ||
+ (mx[i].score < minimum_score))
+ break; /* there is no more usable pair. */
+ dst = &rename_dst[mx[i].dst];
if (dst->pair)
continue; /* already done, either exact or fuzzy. */
- if (mx[i].score < minimum_score)
- break; /* there is no more usable pair. */
- src = rename_src[mx[i].src].one;
- if (src->rename_used)
+ if (rename_src[mx[i].src].one->rename_used)
continue;
record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
rename_count++;
}
- for (i = 0; i < num_create * num_src; i++) {
- struct diff_rename_dst *dst = &rename_dst[mx[i].dst];
+
+ for (i = 0; i < dst_cnt * NUM_CANDIDATE_PER_DST; i++) {
+ struct diff_rename_dst *dst;
+
+ if ((mx[i].dst < 0) ||
+ (mx[i].score < minimum_score))
+ break; /* there is no more usable pair. */
+ dst = &rename_dst[mx[i].dst];
if (dst->pair)
continue; /* already done, either exact or fuzzy. */
- if (mx[i].score < minimum_score)
- break; /* there is no more usable pair. */
record_rename_pair(mx[i].dst, mx[i].src, mx[i].score);
rename_count++;
}
diff --git a/dir.c b/dir.c
index 6543105b9..109e05b01 100644
--- a/dir.c
+++ b/dir.c
@@ -17,6 +17,7 @@ struct path_simplify {
static int read_directory_recursive(struct dir_struct *dir,
const char *path, const char *base, int baselen,
int check_only, const struct path_simplify *simplify);
+static int get_dtype(struct dirent *de, const char *path);
int common_prefix(const char **pathspec)
{
@@ -51,6 +52,11 @@ int common_prefix(const char **pathspec)
return prefix;
}
+static inline int special_char(unsigned char c1)
+{
+ return !c1 || c1 == '*' || c1 == '[' || c1 == '?' || c1 == '\\';
+}
+
/*
* Does 'match' matches the given name?
* A match is found if
@@ -68,18 +74,31 @@ static int match_one(const char *match, const char *name, int namelen)
int matchlen;
/* If the match was just the prefix, we matched */
- matchlen = strlen(match);
- if (!matchlen)
+ if (!*match)
return MATCHED_RECURSIVELY;
+ for (;;) {
+ unsigned char c1 = *match;
+ unsigned char c2 = *name;
+ if (special_char(c1))
+ break;
+ if (c1 != c2)
+ return 0;
+ match++;
+ name++;
+ namelen--;
+ }
+
+
/*
* If we don't match the matchstring exactly,
* we need to match by fnmatch
*/
+ matchlen = strlen(match);
if (strncmp(match, name, matchlen))
return !fnmatch(match, name, 0) ? MATCHED_FNMATCH : 0;
- if (!name[matchlen])
+ if (namelen == matchlen)
return MATCHED_EXACTLY;
if (match[matchlen-1] == '/' || name[matchlen] == '/')
return MATCHED_RECURSIVELY;
@@ -126,18 +145,34 @@ static int no_wildcard(const char *string)
void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which)
{
- struct exclude *x = xmalloc(sizeof (*x));
+ struct exclude *x;
+ size_t len;
+ int to_exclude = 1;
+ int flags = 0;
- x->to_exclude = 1;
if (*string == '!') {
- x->to_exclude = 0;
+ to_exclude = 0;
string++;
}
- x->pattern = string;
+ len = strlen(string);
+ if (len && string[len - 1] == '/') {
+ char *s;
+ x = xmalloc(sizeof(*x) + len);
+ s = (char*)(x+1);
+ memcpy(s, string, len - 1);
+ s[len - 1] = '\0';
+ string = s;
+ x->pattern = s;
+ flags = EXC_FLAG_MUSTBEDIR;
+ } else {
+ x = xmalloc(sizeof(*x));
+ x->pattern = string;
+ }
+ x->to_exclude = to_exclude;
x->patternlen = strlen(string);
x->base = base;
x->baselen = baselen;
- x->flags = 0;
+ x->flags = flags;
if (!strchr(string, '/'))
x->flags |= EXC_FLAG_NODIR;
if (no_wildcard(string))
@@ -261,7 +296,7 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
* Return 1 for exclude, 0 for include and -1 for undecided.
*/
static int excluded_1(const char *pathname,
- int pathlen, const char *basename,
+ int pathlen, const char *basename, int *dtype,
struct exclude_list *el)
{
int i;
@@ -272,6 +307,13 @@ static int excluded_1(const char *pathname,
const char *exclude = x->pattern;
int to_exclude = x->to_exclude;
+ if (x->flags & EXC_FLAG_MUSTBEDIR) {
+ if (*dtype == DT_UNKNOWN)
+ *dtype = get_dtype(NULL, pathname);
+ if (*dtype != DT_DIR)
+ continue;
+ }
+
if (x->flags & EXC_FLAG_NODIR) {
/* match basename */
if (x->flags & EXC_FLAG_NOWILDCARD) {
@@ -314,7 +356,7 @@ static int excluded_1(const char *pathname,
return -1; /* undecided */
}
-int excluded(struct dir_struct *dir, const char *pathname)
+int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
{
int pathlen = strlen(pathname);
int st;
@@ -323,7 +365,8 @@ int excluded(struct dir_struct *dir, const char *pathname)
prep_exclude(dir, pathname, basename-pathname);
for (st = EXC_CMDL; st <= EXC_FILE; st++) {
- switch (excluded_1(pathname, pathlen, basename, &dir->exclude_list[st])) {
+ switch (excluded_1(pathname, pathlen, basename,
+ dtype_p, &dir->exclude_list[st])) {
case 0:
return 0;
case 1:
@@ -346,7 +389,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
{
- if (cache_name_exists(pathname, len))
+ if (cache_name_exists(pathname, len, ignore_case))
return NULL;
ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
@@ -508,7 +551,7 @@ static int in_pathspec(const char *path, int len, const struct path_simplify *si
static int get_dtype(struct dirent *de, const char *path)
{
- int dtype = DTYPE(de);
+ int dtype = de ? DTYPE(de) : DT_UNKNOWN;
struct stat st;
if (dtype != DT_UNKNOWN)
@@ -560,7 +603,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
if (simplify_away(fullname, baselen + len, simplify))
continue;
- exclude = excluded(dir, fullname);
+ dtype = DTYPE(de);
+ exclude = excluded(dir, fullname, &dtype);
if (exclude && dir->collect_ignored
&& in_pathspec(fullname, baselen + len, simplify))
dir_add_ignored(dir, fullname, baselen + len);
@@ -572,7 +616,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co
if (exclude && !dir->show_ignored)
continue;
- dtype = get_dtype(de, fullname);
+ if (dtype == DT_UNKNOWN)
+ dtype = get_dtype(de, fullname);
/*
* Do we want to see just the ignored files?
@@ -677,8 +722,7 @@ static struct path_simplify *create_simplify(const char **pathspec)
static void free_simplify(struct path_simplify *simplify)
{
- if (simplify)
- free(simplify);
+ free(simplify);
}
int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen, const char **pathspec)
diff --git a/dir.h b/dir.h
index d8814dccb..2df15defb 100644
--- a/dir.h
+++ b/dir.h
@@ -9,6 +9,7 @@ struct dir_entry {
#define EXC_FLAG_NODIR 1
#define EXC_FLAG_NOWILDCARD 2
#define EXC_FLAG_ENDSWITH 4
+#define EXC_FLAG_MUSTBEDIR 8
struct exclude_list {
int nr;
@@ -67,7 +68,7 @@ extern int match_pathspec(const char **pathspec, const char *name, int namelen,
extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec);
-extern int excluded(struct dir_struct *, const char *);
+extern int excluded(struct dir_struct *, const char *, int *);
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which);
diff --git a/editor.c b/editor.c
new file mode 100644
index 000000000..eebc3e95f
--- /dev/null
+++ b/editor.c
@@ -0,0 +1,56 @@
+#include "cache.h"
+#include "strbuf.h"
+#include "run-command.h"
+
+int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
+{
+ const char *editor, *terminal;
+
+ editor = getenv("GIT_EDITOR");
+ if (!editor && editor_program)
+ editor = editor_program;
+ if (!editor)
+ editor = getenv("VISUAL");
+ if (!editor)
+ editor = getenv("EDITOR");
+
+ terminal = getenv("TERM");
+ if (!editor && (!terminal || !strcmp(terminal, "dumb")))
+ return error("Terminal is dumb but no VISUAL nor EDITOR defined.");
+
+ if (!editor)
+ editor = "vi";
+
+ if (strcmp(editor, ":")) {
+ size_t len = strlen(editor);
+ int i = 0;
+ int failed;
+ const char *args[6];
+ struct strbuf arg0;
+
+ strbuf_init(&arg0, 0);
+ if (strcspn(editor, "$ \t'") != len) {
+ /* there are specials */
+ strbuf_addf(&arg0, "%s \"$@\"", editor);
+ args[i++] = "sh";
+ args[i++] = "-c";
+ args[i++] = arg0.buf;
+ }
+ args[i++] = editor;
+ args[i++] = path;
+ args[i] = NULL;
+
+ failed = run_command_v_opt_cd_env(args, 0, NULL, env);
+ strbuf_release(&arg0);
+ if (failed)
+ return error("There was a problem with the editor '%s'.",
+ editor);
+ }
+
+ if (!buffer)
+ return 0;
+ if (strbuf_read_file(buffer, path, 0) < 0)
+ return error("could not read file '%s': %s",
+ path, strerror(errno));
+ return 0;
+}
diff --git a/entry.c b/entry.c
index 44f4b897d..222aaa374 100644
--- a/entry.c
+++ b/entry.c
@@ -218,7 +218,6 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
* to emulate by hand - much easier to let the system
* just do the right thing)
*/
- unlink(path);
if (S_ISDIR(st.st_mode)) {
/* If it is a gitlink, leave it alone! */
if (S_ISGITLINK(ce->ce_mode))
@@ -226,7 +225,8 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
if (!state->force)
return error("%s is a directory", path);
remove_subtree(path);
- }
+ } else if (unlink(path))
+ return error("unable to unlink old '%s' (%s)", path, strerror(errno));
} else if (state->not_new)
return 0;
create_directories(path, state);
diff --git a/environment.c b/environment.c
index 18a1c4eec..0c6d11f6a 100644
--- a/environment.c
+++ b/environment.c
@@ -11,9 +11,11 @@
char git_default_email[MAX_GITNAME];
char git_default_name[MAX_GITNAME];
+int user_ident_explicitly_given;
int trust_executable_bit = 1;
-int quote_path_fully = 1;
+int trust_ctime = 1;
int has_symlinks = 1;
+int ignore_case;
int assume_unchanged;
int prefer_symlink_refs;
int is_bare_repository_cfg = -1; /* unspecified */
@@ -27,19 +29,23 @@ const char *apply_default_whitespace;
int zlib_compression_level = Z_BEST_SPEED;
int core_compression_level;
int core_compression_seen;
+int fsync_object_files;
size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
size_t delta_base_cache_limit = 16 * 1024 * 1024;
-char *pager_program;
+const char *pager_program;
int pager_use_color = 1;
-char *editor_program;
-char *excludes_file;
+const char *editor_program;
+const char *excludes_file;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
+enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
+enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
+enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
/* This is set by setup_git_dir_gently() and/or git_default_config() */
char *git_work_tree_cfg;
-static const char *work_tree;
+static char *work_tree;
static const char *git_dir;
static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;
@@ -48,6 +54,8 @@ static void setup_git_env(void)
{
git_dir = getenv(GIT_DIR_ENVIRONMENT);
if (!git_dir)
+ git_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (!git_dir)
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
git_object_dir = getenv(DB_ENVIRONMENT);
if (!git_object_dir) {
@@ -79,10 +87,26 @@ const char *get_git_dir(void)
return git_dir;
}
+static int git_work_tree_initialized;
+
+/*
+ * Note. This works only before you used a work tree. This was added
+ * primarily to support git-clone to work in a new repository it just
+ * created, and is not meant to flip between different work trees.
+ */
+void set_git_work_tree(const char *new_work_tree)
+{
+ if (is_bare_repository_cfg >= 0)
+ die("cannot set work tree after initialization");
+ git_work_tree_initialized = 1;
+ free(work_tree);
+ work_tree = xstrdup(make_absolute_path(new_work_tree));
+ is_bare_repository_cfg = 0;
+}
+
const char *get_git_work_tree(void)
{
- static int initialized = 0;
- if (!initialized) {
+ if (!git_work_tree_initialized) {
work_tree = getenv(GIT_WORK_TREE_ENVIRONMENT);
/* core.bare = true overrides implicit and config work tree */
if (!work_tree && is_bare_repository_cfg < 1) {
@@ -92,7 +116,7 @@ const char *get_git_work_tree(void)
work_tree = xstrdup(make_absolute_path(git_path(work_tree)));
} else if (work_tree)
work_tree = xstrdup(make_absolute_path(work_tree));
- initialized = 1;
+ git_work_tree_initialized = 1;
if (work_tree)
is_bare_repository_cfg = 0;
}
@@ -106,13 +130,6 @@ char *get_object_directory(void)
return git_object_dir;
}
-char *get_refs_directory(void)
-{
- if (!git_refs_dir)
- setup_git_env();
- return git_refs_dir;
-}
-
char *get_index_file(void)
{
if (!git_index_file)
diff --git a/exec_cmd.c b/exec_cmd.c
index e189caca6..ce6741eb6 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -4,8 +4,23 @@
#define MAX_ARGS 32
extern char **environ;
-static const char *builtin_exec_path = GIT_EXEC_PATH;
static const char *argv_exec_path;
+static const char *argv0_path;
+
+const char *system_path(const char *path)
+{
+ if (!is_absolute_path(path) && argv0_path) {
+ struct strbuf d = STRBUF_INIT;
+ strbuf_addf(&d, "%s/%s", argv0_path, path);
+ path = strbuf_detach(&d, NULL);
+ }
+ return path;
+}
+
+void git_set_argv0_path(const char *path)
+{
+ argv0_path = path;
+}
void git_set_argv_exec_path(const char *exec_path)
{
@@ -26,7 +41,7 @@ const char *git_exec_path(void)
return env;
}
- return builtin_exec_path;
+ return system_path(GIT_EXEC_PATH);
}
static void add_path(struct strbuf *out, const char *path)
@@ -35,13 +50,13 @@ static void add_path(struct strbuf *out, const char *path)
if (is_absolute_path(path))
strbuf_addstr(out, path);
else
- strbuf_addstr(out, make_absolute_path(path));
+ strbuf_addstr(out, make_nonrelative_path(path));
- strbuf_addch(out, ':');
+ strbuf_addch(out, PATH_SEP);
}
}
-void setup_path(const char *cmd_path)
+void setup_path(void)
{
const char *old_path = getenv("PATH");
struct strbuf new_path;
@@ -50,8 +65,8 @@ void setup_path(const char *cmd_path)
add_path(&new_path, argv_exec_path);
add_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));
- add_path(&new_path, builtin_exec_path);
- add_path(&new_path, cmd_path);
+ add_path(&new_path, system_path(GIT_EXEC_PATH));
+ add_path(&new_path, argv0_path);
if (old_path)
strbuf_addstr(&new_path, old_path);
@@ -63,34 +78,32 @@ void setup_path(const char *cmd_path)
strbuf_release(&new_path);
}
-int execv_git_cmd(const char **argv)
+const char **prepare_git_cmd(const char **argv)
{
- struct strbuf cmd;
- const char *tmp;
+ int argc;
+ const char **nargv;
- strbuf_init(&cmd, 0);
- strbuf_addf(&cmd, "git-%s", argv[0]);
+ for (argc = 0; argv[argc]; argc++)
+ ; /* just counting */
+ nargv = xmalloc(sizeof(*nargv) * (argc + 2));
- /*
- * argv[0] must be the git command, but the argv array
- * belongs to the caller, and may be reused in
- * subsequent loop iterations. Save argv[0] and
- * restore it on error.
- */
- tmp = argv[0];
- argv[0] = cmd.buf;
+ nargv[0] = "git";
+ for (argc = 0; argv[argc]; argc++)
+ nargv[argc + 1] = argv[argc];
+ nargv[argc + 1] = NULL;
+ return nargv;
+}
- trace_argv_printf(argv, "trace: exec:");
+int execv_git_cmd(const char **argv) {
+ const char **nargv = prepare_git_cmd(argv);
+ trace_argv_printf(nargv, "trace: exec:");
/* execvp() can only ever return if it fails */
- execvp(cmd.buf, (char **)argv);
+ execvp("git", (char **)nargv);
trace_printf("trace: exec failed: %s\n", strerror(errno));
- argv[0] = tmp;
-
- strbuf_release(&cmd);
-
+ free(nargv);
return -1;
}
diff --git a/exec_cmd.h b/exec_cmd.h
index a892355c8..594f96138 100644
--- a/exec_cmd.h
+++ b/exec_cmd.h
@@ -2,10 +2,12 @@
#define GIT_EXEC_CMD_H
extern void git_set_argv_exec_path(const char *exec_path);
+extern void git_set_argv0_path(const char *path);
extern const char* git_exec_path(void);
-extern void setup_path(const char *);
+extern void setup_path(void);
+extern const char **prepare_git_cmd(const char **argv);
extern int execv_git_cmd(const char **argv); /* NULL terminated */
extern int execl_git_cmd(const char *cmd, ...);
-
+extern const char *system_path(const char *path);
#endif /* GIT_EXEC_CMD_H */
diff --git a/fast-import.c b/fast-import.c
index 45b4edf36..7089e6f9e 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -275,6 +275,8 @@ struct recent_command
static unsigned long max_depth = 10;
static off_t max_packsize = (1LL << 32) - 1;
static int force_update;
+static int pack_compression_level = Z_DEFAULT_COMPRESSION;
+static int pack_compression_seen;
/* Stats and misc. counters */
static uintmax_t alloc_count;
@@ -370,6 +372,8 @@ static void write_branch_report(FILE *rpt, struct branch *b)
fputc('\n', rpt);
}
+static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
+
static void write_crash_report(const char *err)
{
char *loc = git_path("fast_import_crash_%d", getpid());
@@ -428,12 +432,37 @@ static void write_crash_report(const char *err)
write_branch_report(rpt, b);
}
+ if (first_tag) {
+ struct tag *tg;
+ fputc('\n', rpt);
+ fputs("Annotated Tags\n", rpt);
+ fputs("--------------\n", rpt);
+ for (tg = first_tag; tg; tg = tg->next_tag) {
+ fputs(sha1_to_hex(tg->sha1), rpt);
+ fputc(' ', rpt);
+ fputs(tg->name, rpt);
+ fputc('\n', rpt);
+ }
+ }
+
+ fputc('\n', rpt);
+ fputs("Marks\n", rpt);
+ fputs("-----\n", rpt);
+ if (mark_file)
+ fprintf(rpt, " exported to %s\n", mark_file);
+ else
+ dump_marks_helper(rpt, 0, marks);
+
fputc('\n', rpt);
fputs("-------------------\n", rpt);
fputs("END OF CRASH REPORT\n", rpt);
fclose(rpt);
}
+static void end_packfile(void);
+static void unkeep_all_packs(void);
+static void dump_marks(void);
+
static NORETURN void die_nicely(const char *err, va_list params)
{
static int zombie;
@@ -447,6 +476,9 @@ static NORETURN void die_nicely(const char *err, va_list params)
if (!zombie) {
zombie = 1;
write_crash_report(message);
+ end_packfile();
+ unkeep_all_packs();
+ dump_marks();
}
exit(128);
}
@@ -858,7 +890,7 @@ static char *create_index(void)
SHA1_Update(&ctx, (*c)->sha1, 20);
}
sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
- sha1close(f, NULL, 1);
+ sha1close(f, NULL, CSUM_FSYNC);
free(idx);
SHA1_Final(pack_data->sha1, &ctx);
return tmpfile;
@@ -1038,7 +1070,7 @@ static int store_object(
delta = NULL;
memset(&s, 0, sizeof(s));
- deflateInit(&s, zlib_compression_level);
+ deflateInit(&s, pack_compression_level);
if (delta) {
s.next_in = delta;
s.avail_in = deltalen;
@@ -1066,7 +1098,7 @@ static int store_object(
delta = NULL;
memset(&s, 0, sizeof(s));
- deflateInit(&s, zlib_compression_level);
+ deflateInit(&s, pack_compression_level);
s.next_in = (void *)dat->buf;
s.avail_in = dat->len;
s.avail_out = deflateBound(&s, s.avail_in);
@@ -1123,6 +1155,24 @@ static int store_object(
return 0;
}
+/* All calls must be guarded by find_object() or find_mark() to
+ * ensure the 'struct object_entry' passed was written by this
+ * process instance. We unpack the entry by the offset, avoiding
+ * the need for the corresponding .idx file. This unpacking rule
+ * works because we only use OBJ_REF_DELTA within the packfiles
+ * created by fast-import.
+ *
+ * oe must not be NULL. Such an oe usually comes from giving
+ * an unknown SHA-1 to find_object() or an undefined mark to
+ * find_mark(). Callers must test for this condition and use
+ * the standard read_sha1_file() when it happens.
+ *
+ * oe->pack_id must not be MAX_PACK_ID. Such an oe is usually from
+ * find_mark(), where the mark was reloaded from an existing marks
+ * file and is referencing an object that this fast-import process
+ * instance did not write out to a packfile. Callers must test for
+ * this condition and use read_sha1_file() instead.
+ */
static void *gfi_unpack_entry(
struct object_entry *oe,
unsigned long *sizep)
@@ -1130,7 +1180,22 @@ static void *gfi_unpack_entry(
enum object_type type;
struct packed_git *p = all_packs[oe->pack_id];
if (p == pack_data && p->pack_size < (pack_size + 20)) {
+ /* The object is stored in the packfile we are writing to
+ * and we have modified it since the last time we scanned
+ * back to read a previously written object. If an old
+ * window covered [p->pack_size, p->pack_size + 20) its
+ * data is stale and is not valid. Closing all windows
+ * and updating the packfile length ensures we can read
+ * the newly written data.
+ */
close_pack_windows(p);
+
+ /* We have to offer 20 bytes additional on the end of
+ * the packfile as the core unpacker code assumes the
+ * footer is present at the file end and must promise
+ * at least 20 bytes within any window it maps. But
+ * we don't actually create the footer here.
+ */
p->pack_size = pack_size + 20;
}
return unpack_entry(p, oe->offset, &type, sizep);
@@ -1169,6 +1234,8 @@ static void load_tree(struct tree_entry *root)
die("Not a tree: %s", sha1_to_hex(sha1));
t->delta_depth = myoe->depth;
buf = gfi_unpack_entry(myoe, &size);
+ if (!buf)
+ die("Can't load tree %s", sha1_to_hex(sha1));
} else {
enum object_type type;
buf = read_sha1_file(sha1, &type, &size);
@@ -1449,6 +1516,8 @@ static int update_branch(struct branch *b)
struct ref_lock *lock;
unsigned char old_sha1[20];
+ if (is_null_sha1(b->sha1))
+ return 0;
if (read_ref(b->name, old_sha1))
hashclr(old_sha1);
lock = lock_any_ref_for_update(b->name, old_sha1, 0);
@@ -1621,7 +1690,7 @@ static void skip_optional_lf(void)
ungetc(term_char, stdin);
}
-static void cmd_mark(void)
+static void parse_mark(void)
{
if (!prefixcmp(command_buf.buf, "mark :")) {
next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
@@ -1631,7 +1700,7 @@ static void cmd_mark(void)
next_mark = 0;
}
-static void cmd_data(struct strbuf *sb)
+static void parse_data(struct strbuf *sb)
{
strbuf_reset(sb);
@@ -1729,13 +1798,13 @@ static char *parse_ident(const char *buf)
return ident;
}
-static void cmd_new_blob(void)
+static void parse_new_blob(void)
{
static struct strbuf buf = STRBUF_INIT;
read_next_command();
- cmd_mark();
- cmd_data(&buf);
+ parse_mark();
+ parse_data(&buf);
store_object(OBJ_BLOB, &buf, &last_blob, NULL, next_mark);
}
@@ -1799,6 +1868,7 @@ static void file_change_m(struct branch *b)
case S_IFREG | 0644:
case S_IFREG | 0755:
case S_IFLNK:
+ case S_IFGITLINK:
case 0644:
case 0755:
/* ok */
@@ -1831,7 +1901,20 @@ static void file_change_m(struct branch *b)
p = uq.buf;
}
- if (inline_data) {
+ if (S_ISGITLINK(mode)) {
+ if (inline_data)
+ die("Git links cannot be specified 'inline': %s",
+ command_buf.buf);
+ else if (oe) {
+ if (oe->type != OBJ_COMMIT)
+ die("Not a commit (actually a %s): %s",
+ typename(oe->type), command_buf.buf);
+ }
+ /*
+ * Accept the sha1 without checking; it expected to be in
+ * another repository.
+ */
+ } else if (inline_data) {
static struct strbuf buf = STRBUF_INIT;
if (p != uq.buf) {
@@ -1839,7 +1922,7 @@ static void file_change_m(struct branch *b)
p = uq.buf;
}
read_next_command();
- cmd_data(&buf);
+ parse_data(&buf);
store_object(OBJ_BLOB, &buf, &last_blob, sha1, 0);
} else if (oe) {
if (oe->type != OBJ_BLOB)
@@ -1926,7 +2009,7 @@ static void file_change_deleteall(struct branch *b)
load_tree(&b->branch_tree);
}
-static void cmd_from_commit(struct branch *b, char *buf, unsigned long size)
+static void parse_from_commit(struct branch *b, char *buf, unsigned long size)
{
if (!buf || size < 46)
die("Not a valid commit: %s", sha1_to_hex(b->sha1));
@@ -1937,7 +2020,7 @@ static void cmd_from_commit(struct branch *b, char *buf, unsigned long size)
b->branch_tree.versions[1].sha1);
}
-static void cmd_from_existing(struct branch *b)
+static void parse_from_existing(struct branch *b)
{
if (is_null_sha1(b->sha1)) {
hashclr(b->branch_tree.versions[0].sha1);
@@ -1948,12 +2031,12 @@ static void cmd_from_existing(struct branch *b)
buf = read_object_with_reference(b->sha1,
commit_type, &size, b->sha1);
- cmd_from_commit(b, buf, size);
+ parse_from_commit(b, buf, size);
free(buf);
}
}
-static int cmd_from(struct branch *b)
+static int parse_from(struct branch *b)
{
const char *from;
struct branch *s;
@@ -1984,12 +2067,12 @@ static int cmd_from(struct branch *b)
if (oe->pack_id != MAX_PACK_ID) {
unsigned long size;
char *buf = gfi_unpack_entry(oe, &size);
- cmd_from_commit(b, buf, size);
+ parse_from_commit(b, buf, size);
free(buf);
} else
- cmd_from_existing(b);
+ parse_from_existing(b);
} else if (!get_sha1(from, b->sha1))
- cmd_from_existing(b);
+ parse_from_existing(b);
else
die("Invalid ref name or SHA1 expression: %s", from);
@@ -1997,7 +2080,7 @@ static int cmd_from(struct branch *b)
return 1;
}
-static struct hash_list *cmd_merge(unsigned int *count)
+static struct hash_list *parse_merge(unsigned int *count)
{
struct hash_list *list = NULL, *n, *e = e;
const char *from;
@@ -2038,7 +2121,7 @@ static struct hash_list *cmd_merge(unsigned int *count)
return list;
}
-static void cmd_new_commit(void)
+static void parse_new_commit(void)
{
static struct strbuf msg = STRBUF_INIT;
struct branch *b;
@@ -2055,7 +2138,7 @@ static void cmd_new_commit(void)
b = new_branch(sp);
read_next_command();
- cmd_mark();
+ parse_mark();
if (!prefixcmp(command_buf.buf, "author ")) {
author = parse_ident(command_buf.buf + 7);
read_next_command();
@@ -2066,10 +2149,10 @@ static void cmd_new_commit(void)
}
if (!committer)
die("Expected committer but didn't get one");
- cmd_data(&msg);
+ parse_data(&msg);
read_next_command();
- cmd_from(b);
- merge_list = cmd_merge(&merge_count);
+ parse_from(b);
+ merge_list = parse_merge(&merge_count);
/* ensure the branch is active/loaded */
if (!b->branch_tree.tree || !max_active_branches) {
@@ -2127,7 +2210,7 @@ static void cmd_new_commit(void)
b->last_commit = object_count_by_type[OBJ_COMMIT];
}
-static void cmd_new_tag(void)
+static void parse_new_tag(void)
{
static struct strbuf msg = STRBUF_INIT;
char *sp;
@@ -2184,7 +2267,7 @@ static void cmd_new_tag(void)
/* tag payload/message */
read_next_command();
- cmd_data(&msg);
+ parse_data(&msg);
/* build the tag object */
strbuf_reset(&new_data);
@@ -2204,7 +2287,7 @@ static void cmd_new_tag(void)
t->pack_id = pack_id;
}
-static void cmd_reset_branch(void)
+static void parse_reset_branch(void)
{
struct branch *b;
char *sp;
@@ -2224,11 +2307,12 @@ static void cmd_reset_branch(void)
else
b = new_branch(sp);
read_next_command();
- if (!cmd_from(b) && command_buf.len > 0)
+ parse_from(b);
+ if (command_buf.len > 0)
unread_command_buf = 1;
}
-static void cmd_checkpoint(void)
+static void parse_checkpoint(void)
{
if (object_count) {
cycle_packfile();
@@ -2239,7 +2323,7 @@ static void cmd_checkpoint(void)
skip_optional_lf();
}
-static void cmd_progress(void)
+static void parse_progress(void)
{
fwrite(command_buf.buf, 1, command_buf.len, stdout);
fputc('\n', stdout);
@@ -2282,14 +2366,39 @@ static void import_marks(const char *input_file)
fclose(f);
}
+static int git_pack_config(const char *k, const char *v, void *cb)
+{
+ if (!strcmp(k, "pack.depth")) {
+ max_depth = git_config_int(k, v);
+ if (max_depth > MAX_DEPTH)
+ max_depth = MAX_DEPTH;
+ return 0;
+ }
+ if (!strcmp(k, "pack.compression")) {
+ int level = git_config_int(k, v);
+ if (level == -1)
+ level = Z_DEFAULT_COMPRESSION;
+ else if (level < 0 || level > Z_BEST_COMPRESSION)
+ die("bad pack compression level %d", level);
+ pack_compression_level = level;
+ pack_compression_seen = 1;
+ return 0;
+ }
+ return git_default_config(k, v, cb);
+}
+
static const char fast_import_usage[] =
-"git-fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
+"git fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
int main(int argc, const char **argv)
{
unsigned int i, show_stats = 1;
- git_config(git_default_config);
+ setup_git_directory();
+ git_config(git_pack_config, NULL);
+ if (!pack_compression_seen && core_compression_seen)
+ pack_compression_level = core_compression_level;
+
alloc_objects(object_entry_alloc);
strbuf_init(&command_buf, 0);
atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));
@@ -2354,17 +2463,17 @@ int main(int argc, const char **argv)
set_die_routine(die_nicely);
while (read_next_command() != EOF) {
if (!strcmp("blob", command_buf.buf))
- cmd_new_blob();
+ parse_new_blob();
else if (!prefixcmp(command_buf.buf, "commit "))
- cmd_new_commit();
+ parse_new_commit();
else if (!prefixcmp(command_buf.buf, "tag "))
- cmd_new_tag();
+ parse_new_tag();
else if (!prefixcmp(command_buf.buf, "reset "))
- cmd_reset_branch();
+ parse_reset_branch();
else if (!strcmp("checkpoint", command_buf.buf))
- cmd_checkpoint();
+ parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
- cmd_progress();
+ parse_progress();
else
die("Unsupported command: %s", command_buf.buf);
}
diff --git a/fetch-pack.h b/fetch-pack.h
index a7888ea30..8bd9c3256 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -12,10 +12,13 @@ struct fetch_pack_args
use_thin_pack:1,
fetch_all:1,
verbose:1,
- no_progress:1;
+ no_progress:1,
+ include_tag:1;
};
struct ref *fetch_pack(struct fetch_pack_args *args,
+ int fd[], struct child_process *conn,
+ const struct ref *ref,
const char *dest,
int nr_heads,
char **heads,
diff --git a/fixup-builtins b/fixup-builtins
index 49e861d2a..63dfa4c47 100755
--- a/fixup-builtins
+++ b/fixup-builtins
@@ -1,16 +1,16 @@
#!/bin/sh
while [ "$1" ]
do
- old="$1"
- new=$(echo "$1" | sed 's/git-/git /')
- echo "Converting '$old' to '$new'"
- git ls-files '*.sh' | while read file
- do
- sed "s/\\<$old\\>/$new/g" < $file > $file.new
- chmod --reference=$file $file.new
- mv $file.new $file
- done
+ if [ "$1" != "git-sh-setup" -a "$1" != "git-parse-remote" -a "$1" != "git-svn" ]; then
+ old="$1"
+ new=$(echo "$1" | sed 's/git-/git /')
+ echo "Converting '$old' to '$new'"
+ sed -i "s/\\<$old\\>/$new/g" $(git ls-files '*.sh')
+ fi
shift
done
+
+sed -i 's/git merge-one-file/git-merge-one-file/g
+s/git rebase-todo/git-rebase-todo/g' $(git ls-files '*.sh')
git update-index --refresh >& /dev/null
exit 0
diff --git a/fsck.c b/fsck.c
new file mode 100644
index 000000000..797e3178a
--- /dev/null
+++ b/fsck.c
@@ -0,0 +1,333 @@
+#include "cache.h"
+#include "object.h"
+#include "blob.h"
+#include "tree.h"
+#include "tree-walk.h"
+#include "commit.h"
+#include "tag.h"
+#include "fsck.h"
+
+static int fsck_walk_tree(struct tree *tree, fsck_walk_func walk, void *data)
+{
+ struct tree_desc desc;
+ struct name_entry entry;
+ int res = 0;
+
+ if (parse_tree(tree))
+ return -1;
+
+ init_tree_desc(&desc, tree->buffer, tree->size);
+ while (tree_entry(&desc, &entry)) {
+ int result;
+
+ if (S_ISGITLINK(entry.mode))
+ continue;
+ if (S_ISDIR(entry.mode))
+ result = walk(&lookup_tree(entry.sha1)->object, OBJ_TREE, data);
+ else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
+ result = walk(&lookup_blob(entry.sha1)->object, OBJ_BLOB, data);
+ else {
+ result = error("in tree %s: entry %s has bad mode %.6o\n",
+ sha1_to_hex(tree->object.sha1), entry.path, entry.mode);
+ }
+ if (result < 0)
+ return result;
+ if (!res)
+ res = result;
+ }
+ return res;
+}
+
+static int fsck_walk_commit(struct commit *commit, fsck_walk_func walk, void *data)
+{
+ struct commit_list *parents;
+ int res;
+ int result;
+
+ if (parse_commit(commit))
+ return -1;
+
+ result = walk((struct object *)commit->tree, OBJ_TREE, data);
+ if (result < 0)
+ return result;
+ res = result;
+
+ parents = commit->parents;
+ while (parents) {
+ result = walk((struct object *)parents->item, OBJ_COMMIT, data);
+ if (result < 0)
+ return result;
+ if (!res)
+ res = result;
+ parents = parents->next;
+ }
+ return res;
+}
+
+static int fsck_walk_tag(struct tag *tag, fsck_walk_func walk, void *data)
+{
+ if (parse_tag(tag))
+ return -1;
+ return walk(tag->tagged, OBJ_ANY, data);
+}
+
+int fsck_walk(struct object *obj, fsck_walk_func walk, void *data)
+{
+ if (!obj)
+ return -1;
+ switch (obj->type) {
+ case OBJ_BLOB:
+ return 0;
+ case OBJ_TREE:
+ return fsck_walk_tree((struct tree *)obj, walk, data);
+ case OBJ_COMMIT:
+ return fsck_walk_commit((struct commit *)obj, walk, data);
+ case OBJ_TAG:
+ return fsck_walk_tag((struct tag *)obj, walk, data);
+ default:
+ error("Unknown object type for %s", sha1_to_hex(obj->sha1));
+ return -1;
+ }
+}
+
+/*
+ * The entries in a tree are ordered in the _path_ order,
+ * which means that a directory entry is ordered by adding
+ * a slash to the end of it.
+ *
+ * So a directory called "a" is ordered _after_ a file
+ * called "a.c", because "a/" sorts after "a.c".
+ */
+#define TREE_UNORDERED (-1)
+#define TREE_HAS_DUPS (-2)
+
+static int verify_ordered(unsigned mode1, const char *name1, unsigned mode2, const char *name2)
+{
+ int len1 = strlen(name1);
+ int len2 = strlen(name2);
+ int len = len1 < len2 ? len1 : len2;
+ unsigned char c1, c2;
+ int cmp;
+
+ cmp = memcmp(name1, name2, len);
+ if (cmp < 0)
+ return 0;
+ if (cmp > 0)
+ return TREE_UNORDERED;
+
+ /*
+ * Ok, the first <len> characters are the same.
+ * Now we need to order the next one, but turn
+ * a '\0' into a '/' for a directory entry.
+ */
+ c1 = name1[len];
+ c2 = name2[len];
+ if (!c1 && !c2)
+ /*
+ * git-write-tree used to write out a nonsense tree that has
+ * entries with the same name, one blob and one tree. Make
+ * sure we do not have duplicate entries.
+ */
+ return TREE_HAS_DUPS;
+ if (!c1 && S_ISDIR(mode1))
+ c1 = '/';
+ if (!c2 && S_ISDIR(mode2))
+ c2 = '/';
+ return c1 < c2 ? 0 : TREE_UNORDERED;
+}
+
+static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
+{
+ int retval;
+ int has_full_path = 0;
+ int has_empty_name = 0;
+ int has_zero_pad = 0;
+ int has_bad_modes = 0;
+ int has_dup_entries = 0;
+ int not_properly_sorted = 0;
+ struct tree_desc desc;
+ unsigned o_mode;
+ const char *o_name;
+ const unsigned char *o_sha1;
+
+ init_tree_desc(&desc, item->buffer, item->size);
+
+ o_mode = 0;
+ o_name = NULL;
+ o_sha1 = NULL;
+
+ while (desc.size) {
+ unsigned mode;
+ const char *name;
+ const unsigned char *sha1;
+
+ sha1 = tree_entry_extract(&desc, &name, &mode);
+
+ if (strchr(name, '/'))
+ has_full_path = 1;
+ if (!*name)
+ has_empty_name = 1;
+ has_zero_pad |= *(char *)desc.buffer == '0';
+ update_tree_entry(&desc);
+
+ switch (mode) {
+ /*
+ * Standard modes..
+ */
+ case S_IFREG | 0755:
+ case S_IFREG | 0644:
+ case S_IFLNK:
+ case S_IFDIR:
+ case S_IFGITLINK:
+ break;
+ /*
+ * This is nonstandard, but we had a few of these
+ * early on when we honored the full set of mode
+ * bits..
+ */
+ case S_IFREG | 0664:
+ if (!strict)
+ break;
+ default:
+ has_bad_modes = 1;
+ }
+
+ if (o_name) {
+ switch (verify_ordered(o_mode, o_name, mode, name)) {
+ case TREE_UNORDERED:
+ not_properly_sorted = 1;
+ break;
+ case TREE_HAS_DUPS:
+ has_dup_entries = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ o_mode = mode;
+ o_name = name;
+ o_sha1 = sha1;
+ }
+
+ retval = 0;
+ if (has_full_path)
+ retval += error_func(&item->object, FSCK_WARN, "contains full pathnames");
+ if (has_empty_name)
+ retval += error_func(&item->object, FSCK_WARN, "contains empty pathname");
+ if (has_zero_pad)
+ retval += error_func(&item->object, FSCK_WARN, "contains zero-padded file modes");
+ if (has_bad_modes)
+ retval += error_func(&item->object, FSCK_WARN, "contains bad file modes");
+ if (has_dup_entries)
+ retval += error_func(&item->object, FSCK_ERROR, "contains duplicate file entries");
+ if (not_properly_sorted)
+ retval += error_func(&item->object, FSCK_ERROR, "not properly sorted");
+ return retval;
+}
+
+static int fsck_commit(struct commit *commit, fsck_error error_func)
+{
+ char *buffer = commit->buffer;
+ unsigned char tree_sha1[20], sha1[20];
+ struct commit_graft *graft;
+ int parents = 0;
+
+ if (!commit->date)
+ return error_func(&commit->object, FSCK_ERROR, "invalid author/committer line");
+
+ if (memcmp(buffer, "tree ", 5))
+ return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'tree' line");
+ if (get_sha1_hex(buffer+5, tree_sha1) || buffer[45] != '\n')
+ return error_func(&commit->object, FSCK_ERROR, "invalid 'tree' line format - bad sha1");
+ buffer += 46;
+ while (!memcmp(buffer, "parent ", 7)) {
+ if (get_sha1_hex(buffer+7, sha1) || buffer[47] != '\n')
+ return error_func(&commit->object, FSCK_ERROR, "invalid 'parent' line format - bad sha1");
+ buffer += 48;
+ parents++;
+ }
+ graft = lookup_commit_graft(commit->object.sha1);
+ if (graft) {
+ struct commit_list *p = commit->parents;
+ parents = 0;
+ while (p) {
+ p = p->next;
+ parents++;
+ }
+ if (graft->nr_parent == -1 && !parents)
+ ; /* shallow commit */
+ else if (graft->nr_parent != parents)
+ return error_func(&commit->object, FSCK_ERROR, "graft objects missing");
+ } else {
+ struct commit_list *p = commit->parents;
+ while (p && parents) {
+ p = p->next;
+ parents--;
+ }
+ if (p || parents)
+ return error_func(&commit->object, FSCK_ERROR, "parent objects missing");
+ }
+ if (memcmp(buffer, "author ", 7))
+ return error_func(&commit->object, FSCK_ERROR, "invalid format - expected 'author' line");
+ if (!commit->tree)
+ return error_func(&commit->object, FSCK_ERROR, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
+
+ return 0;
+}
+
+static int fsck_tag(struct tag *tag, fsck_error error_func)
+{
+ struct object *tagged = tag->tagged;
+
+ if (!tagged)
+ return error_func(&tag->object, FSCK_ERROR, "could not load tagged object");
+ return 0;
+}
+
+int fsck_object(struct object *obj, int strict, fsck_error error_func)
+{
+ if (!obj)
+ return error_func(obj, FSCK_ERROR, "no valid object to fsck");
+
+ if (obj->type == OBJ_BLOB)
+ return 0;
+ if (obj->type == OBJ_TREE)
+ return fsck_tree((struct tree *) obj, strict, error_func);
+ if (obj->type == OBJ_COMMIT)
+ return fsck_commit((struct commit *) obj, error_func);
+ if (obj->type == OBJ_TAG)
+ return fsck_tag((struct tag *) obj, error_func);
+
+ return error_func(obj, FSCK_ERROR, "unknown type '%d' (internal fsck error)",
+ obj->type);
+}
+
+int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
+{
+ va_list ap;
+ int len;
+ struct strbuf sb;
+
+ strbuf_init(&sb, 0);
+ strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)");
+
+ va_start(ap, fmt);
+ len = vsnprintf(sb.buf + sb.len, strbuf_avail(&sb), fmt, ap);
+ va_end(ap);
+
+ if (len < 0)
+ len = 0;
+ if (len >= strbuf_avail(&sb)) {
+ strbuf_grow(&sb, len + 2);
+ va_start(ap, fmt);
+ len = vsnprintf(sb.buf + sb.len, strbuf_avail(&sb), fmt, ap);
+ va_end(ap);
+ if (len >= strbuf_avail(&sb))
+ die("this should not happen, your snprintf is broken");
+ }
+
+ error(sb.buf);
+ strbuf_release(&sb);
+ return 1;
+}
diff --git a/fsck.h b/fsck.h
new file mode 100644
index 000000000..990ee0233
--- /dev/null
+++ b/fsck.h
@@ -0,0 +1,32 @@
+#ifndef GIT_FSCK_H
+#define GIT_FSCK_H
+
+#define FSCK_ERROR 1
+#define FSCK_WARN 2
+
+/*
+ * callback function for fsck_walk
+ * type is the expected type of the object or OBJ_ANY
+ * the return value is:
+ * 0 everything OK
+ * <0 error signaled and abort
+ * >0 error signaled and do not abort
+ */
+typedef int (*fsck_walk_func)(struct object *obj, int type, void *data);
+
+/* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
+typedef int (*fsck_error)(struct object *obj, int type, const char *err, ...);
+
+int fsck_error_function(struct object *obj, int type, const char *fmt, ...);
+
+/* descend in all linked child objects
+ * the return value is:
+ * -1 error in processing the object
+ * <0 return value of the callback, which lead to an abort
+ * >0 return value of the first sigaled error >0 (in the case of no other errors)
+ * 0 everything OK
+ */
+int fsck_walk(struct object *obj, fsck_walk_func walk, void *data);
+int fsck_object(struct object *obj, int strict, fsck_error error_func);
+
+#endif
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 17ca5b84f..da768ee7a 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -18,6 +18,18 @@ my ($fraginfo_color) =
$diff_use_color ? (
$repo->get_color('color.diff.frag', 'cyan'),
) : ();
+my ($diff_plain_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.plain', ''),
+ ) : ();
+my ($diff_old_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.old', 'red'),
+ ) : ();
+my ($diff_new_color) =
+ $diff_use_color ? (
+ $repo->get_color('color.diff.new', 'green'),
+ ) : ();
my $normal_color = $repo->get_color("", "reset");
@@ -42,7 +54,7 @@ sub colored {
my $patch_mode;
sub run_cmd_pipe {
- if ($^O eq 'MSWin32') {
+ if ($^O eq 'MSWin32' || $^O eq 'msys') {
my @invalid = grep {m/[":*]/} @_;
die "$^O does not support: @invalid\n" if @invalid;
my @args = map { m/ /o ? "\"$_\"": $_ } @_;
@@ -82,6 +94,19 @@ sub list_untracked {
my $status_fmt = '%12s %12s %s';
my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
+{
+ my $initial;
+ sub is_initial_commit {
+ $initial = system('git rev-parse HEAD -- >/dev/null 2>&1') != 0
+ unless defined $initial;
+ return $initial;
+ }
+}
+
+sub get_empty_tree {
+ return '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
+}
+
# Returns list of hashes, contents of each of which are:
# VALUE: pathname
# BINARY: is a binary path
@@ -103,8 +128,10 @@ sub list_modified {
return if (!@tracked);
}
+ my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
for (run_cmd_pipe(qw(git diff-index --cached
- --numstat --summary HEAD --), @tracked)) {
+ --numstat --summary), $reference,
+ '--', @tracked)) {
if (($add, $del, $file) =
/^([-\d]+) ([-\d]+) (.*)/) {
my ($change, $bin);
@@ -379,9 +406,9 @@ sub list_and_choose {
if ($choice =~ s/^-//) {
$choose = 0;
}
- # A range can be specified like 5-7
- if ($choice =~ /^(\d+)-(\d+)$/) {
- ($bottom, $top) = ($1, $2);
+ # A range can be specified like 5-7 or 5-.
+ if ($choice =~ /^(\d+)-(\d*)$/) {
+ ($bottom, $top) = ($1, length($2) ? $2 : 1 + @stuff);
}
elsif ($choice =~ /^\d+$/) {
$bottom = $top = $choice;
@@ -476,21 +503,27 @@ sub revert_cmd {
HEADER => $status_head, },
list_modified());
if (@update) {
- my @lines = run_cmd_pipe(qw(git ls-tree HEAD --),
- map { $_->{VALUE} } @update);
- my $fh;
- open $fh, '| git update-index --index-info'
- or die;
- for (@lines) {
- print $fh $_;
+ if (is_initial_commit()) {
+ system(qw(git rm --cached),
+ map { $_->{VALUE} } @update);
}
- close($fh);
- for (@update) {
- if ($_->{INDEX_ADDDEL} &&
- $_->{INDEX_ADDDEL} eq 'create') {
- system(qw(git update-index --force-remove --),
- $_->{VALUE});
- print "note: $_->{VALUE} is untracked now.\n";
+ else {
+ my @lines = run_cmd_pipe(qw(git ls-tree HEAD --),
+ map { $_->{VALUE} } @update);
+ my $fh;
+ open $fh, '| git update-index --index-info'
+ or die;
+ for (@lines) {
+ print $fh $_;
+ }
+ close($fh);
+ for (@update) {
+ if ($_->{INDEX_ADDDEL} &&
+ $_->{INDEX_ADDDEL} eq 'create') {
+ system(qw(git update-index --force-remove --),
+ $_->{VALUE});
+ print "note: $_->{VALUE} is untracked now.\n";
+ }
}
}
refresh();
@@ -529,6 +562,21 @@ sub parse_diff {
return @hunk;
}
+sub parse_diff_header {
+ my $src = shift;
+
+ my $head = { TEXT => [], DISPLAY => [] };
+ my $mode = { TEXT => [], DISPLAY => [] };
+
+ for (my $i = 0; $i < @{$src->{TEXT}}; $i++) {
+ my $dest = $src->{TEXT}->[$i] =~ /^(old|new) mode (\d+)$/ ?
+ $mode : $head;
+ push @{$dest->{TEXT}}, $src->{TEXT}->[$i];
+ push @{$dest->{DISPLAY}}, $src->{DISPLAY}->[$i];
+ }
+ return ($head, $mode);
+}
+
sub hunk_splittable {
my ($text) = @_;
@@ -646,92 +694,104 @@ sub split_hunk {
return @split;
}
-sub find_last_o_ctx {
- my ($it) = @_;
- my $text = $it->{TEXT};
- my ($o_ofs, $o_cnt) = parse_hunk_header($text->[0]);
- my $i = @{$text};
- my $last_o_ctx = $o_ofs + $o_cnt;
- while (0 < --$i) {
- my $line = $text->[$i];
- if ($line =~ /^ /) {
- $last_o_ctx--;
- next;
- }
- last;
- }
- return $last_o_ctx;
+
+sub color_diff {
+ return map {
+ colored((/^@/ ? $fraginfo_color :
+ /^\+/ ? $diff_new_color :
+ /^-/ ? $diff_old_color :
+ $diff_plain_color),
+ $_);
+ } @_;
}
-sub merge_hunk {
- my ($prev, $this) = @_;
- my ($o0_ofs, $o0_cnt, $n0_ofs, $n0_cnt) =
- parse_hunk_header($prev->{TEXT}[0]);
- my ($o1_ofs, $o1_cnt, $n1_ofs, $n1_cnt) =
- parse_hunk_header($this->{TEXT}[0]);
-
- my (@line, $i, $ofs, $o_cnt, $n_cnt);
- $ofs = $o0_ofs;
- $o_cnt = $n_cnt = 0;
- for ($i = 1; $i < @{$prev->{TEXT}}; $i++) {
- my $line = $prev->{TEXT}[$i];
- if ($line =~ /^\+/) {
- $n_cnt++;
- push @line, $line;
- next;
- }
+sub edit_hunk_manually {
+ my ($oldtext) = @_;
+
+ my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
+ my $fh;
+ open $fh, '>', $hunkfile
+ or die "failed to open hunk edit file for writing: " . $!;
+ print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
+ print $fh @$oldtext;
+ print $fh <<EOF;
+# ---
+# To remove '-' lines, make them ' ' lines (context).
+# To remove '+' lines, delete them.
+# Lines starting with # will be removed.
+#
+# If the patch applies cleanly, the edited hunk will immediately be
+# marked for staging. If it does not apply cleanly, you will be given
+# an opportunity to edit again. If all lines of the hunk are removed,
+# then the edit is aborted and the hunk is left unchanged.
+EOF
+ close $fh;
- last if ($o1_ofs <= $ofs);
+ my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor")
+ || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+ system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
- $o_cnt++;
- $ofs++;
- if ($line =~ /^ /) {
- $n_cnt++;
- }
- push @line, $line;
+ open $fh, '<', $hunkfile
+ or die "failed to open hunk edit file for reading: " . $!;
+ my @newtext = grep { !/^#/ } <$fh>;
+ close $fh;
+ unlink $hunkfile;
+
+ # Abort if nothing remains
+ if (!grep { /\S/ } @newtext) {
+ return undef;
}
- for ($i = 1; $i < @{$this->{TEXT}}; $i++) {
- my $line = $this->{TEXT}[$i];
- if ($line =~ /^\+/) {
- $n_cnt++;
- push @line, $line;
- next;
- }
- $ofs++;
- $o_cnt++;
- if ($line =~ /^ /) {
- $n_cnt++;
- }
- push @line, $line;
+ # Reinsert the first hunk header if the user accidentally deleted it
+ if ($newtext[0] !~ /^@/) {
+ unshift @newtext, $oldtext->[0];
}
- my $head = ("@@ -$o0_ofs" .
- (($o_cnt != 1) ? ",$o_cnt" : '') .
- " +$n0_ofs" .
- (($n_cnt != 1) ? ",$n_cnt" : '') .
- " @@\n");
- @{$prev->{TEXT}} = ($head, @line);
+ return \@newtext;
}
-sub coalesce_overlapping_hunks {
- my (@in) = @_;
- my @out = ();
+sub diff_applies {
+ my $fh;
+ open $fh, '| git apply --recount --cached --check';
+ for my $h (@_) {
+ print $fh @{$h->{TEXT}};
+ }
+ return close $fh;
+}
- my ($last_o_ctx);
+sub prompt_yesno {
+ my ($prompt) = @_;
+ while (1) {
+ print colored $prompt_color, $prompt;
+ my $line = <STDIN>;
+ return 0 if $line =~ /^n/i;
+ return 1 if $line =~ /^y/i;
+ }
+}
- for (grep { $_->{USE} } @in) {
- my $text = $_->{TEXT};
- my ($o_ofs) = parse_hunk_header($text->[0]);
- if (defined $last_o_ctx &&
- $o_ofs <= $last_o_ctx) {
- merge_hunk($out[-1], $_);
+sub edit_hunk_loop {
+ my ($head, $hunk, $ix) = @_;
+ my $text = $hunk->[$ix]->{TEXT};
+
+ while (1) {
+ $text = edit_hunk_manually($text);
+ if (!defined $text) {
+ return undef;
+ }
+ my $newhunk = { TEXT => $text, USE => 1 };
+ if (diff_applies($head,
+ @{$hunk}[0..$ix-1],
+ $newhunk,
+ @{$hunk}[$ix+1..$#{$hunk}])) {
+ $newhunk->{DISPLAY} = [color_diff(@{$text})];
+ return $newhunk;
}
else {
- push @out, $_;
+ prompt_yesno(
+ 'Your edited hunk does not apply. Edit again '
+ . '(saying "no" discards!) [y/n]? '
+ ) or return undef;
}
- $last_o_ctx = find_last_o_ctx($out[-1]);
}
- return @out;
}
sub help_patch_cmd {
@@ -745,6 +805,7 @@ J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
+e - manually edit the current hunk
? - print help
EOF
}
@@ -774,9 +835,40 @@ sub patch_update_file {
my ($ix, $num);
my $path = shift;
my ($head, @hunk) = parse_diff($path);
+ ($head, my $mode) = parse_diff_header($head);
for (@{$head->{DISPLAY}}) {
print;
}
+
+ if (@{$mode->{TEXT}}) {
+ while (1) {
+ print @{$mode->{DISPLAY}};
+ print colored $prompt_color,
+ "Stage mode change [y/n/a/d/?]? ";
+ my $line = <STDIN>;
+ if ($line =~ /^y/i) {
+ $mode->{USE} = 1;
+ last;
+ }
+ elsif ($line =~ /^n/i) {
+ $mode->{USE} = 0;
+ last;
+ }
+ elsif ($line =~ /^a/i) {
+ $_->{USE} = 1 foreach ($mode, @hunk);
+ last;
+ }
+ elsif ($line =~ /^d/i) {
+ $_->{USE} = 0 foreach ($mode, @hunk);
+ last;
+ }
+ else {
+ help_patch_cmd('');
+ next;
+ }
+ }
+ }
+
$num = scalar @hunk;
$ix = 0;
@@ -818,6 +910,7 @@ sub patch_update_file {
if (hunk_splittable($hunk[$ix]{TEXT})) {
$other .= '/s';
}
+ $other .= '/e';
for (@{$hunk[$ix]{DISPLAY}}) {
print;
}
@@ -882,6 +975,12 @@ sub patch_update_file {
$num = scalar @hunk;
next;
}
+ elsif ($line =~ /^e/) {
+ my $newhunk = edit_hunk_loop($head, \@hunk, $ix);
+ if (defined $newhunk) {
+ splice @hunk, $ix, 1, $newhunk;
+ }
+ }
else {
help_patch_cmd($other);
next;
@@ -895,44 +994,21 @@ sub patch_update_file {
}
}
- @hunk = coalesce_overlapping_hunks(@hunk);
-
my $n_lofs = 0;
my @result = ();
+ if ($mode->{USE}) {
+ push @result, @{$mode->{TEXT}};
+ }
for (@hunk) {
- my $text = $_->{TEXT};
- my ($o_ofs, $o_cnt, $n_ofs, $n_cnt) =
- parse_hunk_header($text->[0]);
-
- if (!$_->{USE}) {
- # We would have added ($n_cnt - $o_cnt) lines
- # to the postimage if we were to use this hunk,
- # but we didn't. So the line number that the next
- # hunk starts at would be shifted by that much.
- $n_lofs -= ($n_cnt - $o_cnt);
- next;
- }
- else {
- if ($n_lofs) {
- $n_ofs += $n_lofs;
- $text->[0] = ("@@ -$o_ofs" .
- (($o_cnt != 1)
- ? ",$o_cnt" : '') .
- " +$n_ofs" .
- (($n_cnt != 1)
- ? ",$n_cnt" : '') .
- " @@\n");
- }
- for (@$text) {
- push @result, $_;
- }
+ if ($_->{USE}) {
+ push @result, @{$_->{TEXT}};
}
}
if (@result) {
my $fh;
- open $fh, '| git apply --cached';
+ open $fh, '| git apply --cached --recount';
for (@{$head->{TEXT}}, @result) {
print $fh $_;
}
@@ -956,7 +1032,9 @@ sub diff_cmd {
HEADER => $status_head, },
@mods);
return if (!@them);
- system(qw(git diff -p --cached HEAD --), map { $_->{VALUE} } @them);
+ my $reference = is_initial_commit() ? get_empty_tree() : 'HEAD';
+ system(qw(git diff -p --cached), $reference, '--',
+ map { $_->{VALUE} } @them);
}
sub quit_cmd {
diff --git a/git-am.sh b/git-am.sh
index 5f0f241ad..aa602618e 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -2,31 +2,36 @@
#
# Copyright (c) 2005, 2006 Junio C Hamano
+SUBDIRECTORY_OK=Yes
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
-git-am [options] <mbox>|<Maildir>...
-git-am [options] --resolved
-git-am [options] --skip
+git am [options] [<mbox>|<Maildir>...]
+git am [options] (--resolved | --skip | --abort)
--
-d,dotest= use <dir> and not .dotest
+d,dotest= (removed -- do not use)
i,interactive run interactively
-b,binary pass --allo-binary-replacement to git-apply
+b,binary (historical option -- no-op)
3,3way allow fall back on 3way merging if needed
s,signoff add a Signed-off-by line to the commit message
u,utf8 recode into utf8 (default)
-k,keep pass -k flagg to git-mailinfo
+k,keep pass -k flag to git-mailinfo
whitespace= pass it through git-apply
C= pass it through git-apply
p= pass it through git-apply
resolvemsg= override error message when patch failure occurs
r,resolved to be used after a patch failure
-skip skip the current patch"
+skip skip the current patch
+abort restore the original branch and abort the patching operation.
+rebasing (internal use for git-rebase)"
. git-sh-setup
+prefix=$(git rev-parse --show-prefix)
set_reflog_action am
require_work_tree
+cd_to_toplevel
-git var GIT_COMMITTER_IDENT >/dev/null || exit
+git var GIT_COMMITTER_IDENT >/dev/null ||
+ die "You need to set your committer info first"
stop_here () {
echo "$1" >"$dotest/next"
@@ -38,7 +43,7 @@ stop_here_user_resolve () {
printf '%s\n' "$resolvemsg"
stop_here $1
fi
- cmdline=$(basename $0)
+ cmdline="git am"
if test '' != "$interactive"
then
cmdline="$cmdline -i"
@@ -47,12 +52,9 @@ stop_here_user_resolve () {
then
cmdline="$cmdline -3"
fi
- if test '.dotest' != "$dotest"
- then
- cmdline="$cmdline -d=$dotest"
- fi
echo "When you have resolved this problem run \"$cmdline --resolved\"."
echo "If you would prefer to skip this patch, instead run \"$cmdline --skip\"."
+ echo "To restore the original branch and stop patching run \"$cmdline --abort\"."
stop_here $1
}
@@ -85,7 +87,7 @@ fall_back_3way () {
echo Using index info to reconstruct a base tree...
if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
- git apply $binary --cached <"$dotest/patch"
+ git apply --cached <"$dotest/patch"
then
mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
@@ -107,7 +109,7 @@ It does not apply to blobs recorded in its index."
# patch did not touch, so recursive ends up canceling them,
# saying that we reverted all those changes.
- eval GITHEAD_$his_tree='"$SUBJECT"'
+ eval GITHEAD_$his_tree='"$FIRSTLINE"'
export GITHEAD_$his_tree
git-merge-recursive $orig_tree -- HEAD $his_tree || {
git rerere
@@ -117,12 +119,9 @@ It does not apply to blobs recorded in its index."
unset GITHEAD_$his_tree
}
-reread_subject () {
- git stripspace <"$1" | sed -e 1q
-}
-
prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary=
+dotest="$GIT_DIR/rebase-apply"
+sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
resolvemsg= resume=
git_apply_opt=
@@ -132,7 +131,7 @@ do
-i|--interactive)
interactive=t ;;
-b|--binary)
- binary=t ;;
+ : ;;
-3|--3way)
threeway=t ;;
-s|--signoff)
@@ -147,8 +146,13 @@ do
resolved=t ;;
--skip)
skip=t ;;
+ --abort)
+ abort=t ;;
+ --rebasing)
+ rebasing=t threeway=t keep=t ;;
-d|--dotest)
- shift; dotest=$1;;
+ die "-d option is no longer supported. Do not use."
+ ;;
--resolvemsg)
shift; resolvemsg=$1 ;;
--whitespace)
@@ -176,7 +180,7 @@ fi
if test -d "$dotest"
then
- case "$#,$skip$resolved" in
+ case "$#,$skip$resolved$abort" in
0,*t*)
# Explicit resume command and we do not have file, so
# we are happy.
@@ -184,7 +188,7 @@ then
0,)
# No file input but without resume parameters; catch
# user error to feed us a patch from standard input
- # when there is already .dotest. This is somewhat
+ # when there is already $dotest. This is somewhat
# unreliable -- stdin could be /dev/null for example
# and the caller did not intend to feed us a patch but
# wanted to continue unattended.
@@ -194,30 +198,70 @@ then
false
;;
esac ||
- die "previous dotest directory $dotest still exists but mbox given."
+ die "previous rebase directory $dotest still exists but mbox given."
resume=yes
+
+ case "$skip,$abort" in
+ t,)
+ git rerere clear
+ git read-tree --reset -u HEAD HEAD
+ orig_head=$(cat "$GIT_DIR/ORIG_HEAD")
+ git reset HEAD
+ git update-ref ORIG_HEAD $orig_head
+ ;;
+ ,t)
+ git rerere clear
+ git read-tree --reset -u HEAD ORIG_HEAD
+ git reset ORIG_HEAD
+ rm -fr "$dotest"
+ exit ;;
+ esac
else
- # Make sure we are not given --skip nor --resolved
- test ",$skip,$resolved," = ,,, ||
+ # Make sure we are not given --skip, --resolved, nor --abort
+ test "$skip$resolved$abort" = "" ||
die "Resolve operation not in progress, we are not resuming."
# Start afresh.
mkdir -p "$dotest" || exit
+ if test -n "$prefix" && test $# != 0
+ then
+ first=t
+ for arg
+ do
+ test -n "$first" && {
+ set x
+ first=
+ }
+ case "$arg" in
+ /*)
+ set "$@" "$arg" ;;
+ *)
+ set "$@" "$prefix$arg" ;;
+ esac
+ done
+ shift
+ fi
git mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" || {
rm -fr "$dotest"
exit 1
}
- # -b, -s, -u, -k and --whitespace flags are kept for the
+ # -s, -u, -k and --whitespace flags are kept for the
# resuming session after a patch failure.
# -3 and -i can and must be given when resuming.
- echo "$binary" >"$dotest/binary"
echo " $ws" >"$dotest/whitespace"
echo "$sign" >"$dotest/sign"
echo "$utf8" >"$dotest/utf8"
echo "$keep" >"$dotest/keep"
echo 1 >"$dotest/next"
+ if test -n "$rebasing"
+ then
+ : >"$dotest/rebasing"
+ else
+ : >"$dotest/applying"
+ git update-ref ORIG_HEAD HEAD
+ fi
fi
case "$resolved" in
@@ -229,10 +273,6 @@ case "$resolved" in
fi
esac
-if test "$(cat "$dotest/binary")" = t
-then
- binary=--allow-binary-replacement
-fi
if test "$(cat "$dotest/utf8")" = t
then
utf8=-u
@@ -246,7 +286,7 @@ fi
ws=`cat "$dotest/whitespace"`
if test "$(cat "$dotest/sign")" = t
then
- SIGNOFF=`git-var GIT_COMMITTER_IDENT | sed -e '
+ SIGNOFF=`git var GIT_COMMITTER_IDENT | sed -e '
s/>.*/>/
s/^/Signed-off-by: /'
`
@@ -258,7 +298,6 @@ last=`cat "$dotest/last"`
this=`cat "$dotest/next"`
if test "$skip" = t
then
- git rerere clear
this=`expr "$this" + 1`
resume=
fi
@@ -299,11 +338,24 @@ do
<"$dotest"/info >/dev/null &&
go_next && continue
- test -s $dotest/patch || {
+ test -s "$dotest/patch" || {
echo "Patch is empty. Was it split wrong?"
stop_here $this
}
- git stripspace < "$dotest/msg" > "$dotest/msg-clean"
+ if test -f "$dotest/rebasing" &&
+ commit=$(sed -e 's/^From \([0-9a-f]*\) .*/\1/' \
+ -e q "$dotest/$msgnum") &&
+ test "$(git cat-file -t "$commit")" = commit
+ then
+ git cat-file commit "$commit" |
+ sed -e '1,/^$/d' >"$dotest/msg-clean"
+ else
+ SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
+ case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
+
+ (printf '%s\n\n' "$SUBJECT"; cat "$dotest/msg") |
+ git stripspace > "$dotest/msg-clean"
+ fi
;;
esac
@@ -319,9 +371,6 @@ do
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
- SUBJECT="$(sed -n '/^Subject/ s/Subject: //p' "$dotest/info")"
- case "$keep_subject" in -k) SUBJECT="[PATCH] $SUBJECT" ;; esac
-
case "$resume" in
'')
if test '' != "$SIGNOFF"
@@ -329,7 +378,7 @@ do
LAST_SIGNED_OFF_BY=`
sed -ne '/^Signed-off-by: /p' \
"$dotest/msg-clean" |
- tail -n 1
+ sed -ne '$p'
`
ADD_SIGNOFF=`
test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || {
@@ -340,10 +389,8 @@ do
ADD_SIGNOFF=
fi
{
- printf '%s\n' "$SUBJECT"
if test -s "$dotest/msg-clean"
then
- echo
cat "$dotest/msg-clean"
fi
if test '' != "$ADD_SIGNOFF"
@@ -380,7 +427,6 @@ do
[aA]*) action=yes interactive= ;;
[nN]*) action=skip ;;
[eE]*) git_editor "$dotest/final-commit"
- SUBJECT=$(reread_subject "$dotest/final-commit")
action=again ;;
[vV]*) action=again
LESS=-S ${PAGER:-less} "$dotest/patch" ;;
@@ -390,6 +436,7 @@ do
else
action=yes
fi
+ FIRSTLINE=$(sed 1q "$dotest/final-commit")
if test $action = skip
then
@@ -403,11 +450,11 @@ do
stop_here $this
fi
- printf 'Applying %s\n' "$SUBJECT"
+ printf 'Applying: %s\n' "$FIRSTLINE"
case "$resolved" in
'')
- git apply $git_apply_opt $binary --index "$dotest/patch"
+ git apply $git_apply_opt --index "$dotest/patch"
apply_status=$?
;;
t)
@@ -461,7 +508,7 @@ do
tree=$(git write-tree) &&
parent=$(git rev-parse --verify HEAD) &&
commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
- git update-ref -m "$GIT_REFLOG_ACTION: $SUBJECT" HEAD $commit $parent ||
+ git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
stop_here $this
if test -x "$GIT_DIR"/hooks/post-applypatch
diff --git a/git-archimport.perl b/git-archimport.perl
index 9a7a90640..98f3ede56 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -9,7 +9,7 @@
=head1 Invocation
- git-archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ]
+ git archimport [ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ]
[ -D depth] [ -t tempdir ] <archive>/<branch> [ <archive>/<branch> ]
Imports a project from one or more Arch repositories. It will follow branches
@@ -74,7 +74,7 @@ our($opt_h,$opt_f,$opt_v,$opt_T,$opt_t,$opt_D,$opt_a,$opt_o);
sub usage() {
print STDERR <<END;
-Usage: ${\basename $0} # fetch/update GIT from Arch
+Usage: git archimport # fetch/update GIT from Arch
[ -h ] [ -v ] [ -o ] [ -a ] [ -f ] [ -T ] [ -D depth ] [ -t tempdir ]
repository/arch-branch [ repository/arch-branch] ...
END
diff --git a/git-bisect.sh b/git-bisect.sh
index 538524989..97ac60087 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,7 +1,9 @@
#!/bin/sh
-USAGE='[start|bad|good|skip|next|reset|visualize|replay|log|run]'
-LONG_USAGE='git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
+USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
+LONG_USAGE='git bisect help
+ print this long help message.
+git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
reset bisect state and start bisection.
git bisect bad [<rev>]
mark <rev> a known-bad revision.
@@ -20,12 +22,17 @@ git bisect replay <logfile>
git bisect log
show bisect log.
git bisect run <cmd>...
- use <cmd>... to automatically bisect.'
+ use <cmd>... to automatically bisect.
+
+Please use "git help bisect" to get the full man page.'
OPTIONS_SPEC=
. git-sh-setup
require_work_tree
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
sq() {
@@PERL@@ -e '
for (@ARGV) {
@@ -37,7 +44,7 @@ sq() {
}
bisect_autostart() {
- test -f "$GIT_DIR/BISECT_NAMES" || {
+ test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start"'
if test -t 0
then
@@ -56,33 +63,42 @@ bisect_autostart() {
bisect_start() {
#
- # Verify HEAD. If we were bisecting before this, reset to the
- # top-of-line master first!
+ # Verify HEAD.
#
- head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
- die "Bad HEAD - I need a symbolic ref"
- case "$head" in
- refs/heads/bisect)
- if [ -s "$GIT_DIR/head-name" ]; then
- branch=`cat "$GIT_DIR/head-name"`
- else
- branch=master
- fi
- git checkout $branch || exit
- ;;
- refs/heads/*)
- [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
- echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
- ;;
- *)
- die "Bad HEAD - strange symbolic ref"
- ;;
- esac
+ head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
+ head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
+ die "Bad HEAD - I need a HEAD"
+
+ #
+ # Check if we are bisecting.
+ #
+ start_head=''
+ if test -s "$GIT_DIR/BISECT_START"
+ then
+ # Reset to the rev from where we started.
+ start_head=$(cat "$GIT_DIR/BISECT_START")
+ git checkout "$start_head" || exit
+ else
+ # Get rev from where we start.
+ case "$head" in
+ refs/heads/*|$_x40)
+ # This error message should only be triggered by
+ # cogito usage, and cogito users should understand
+ # it relates to cg-seek.
+ [ -s "$GIT_DIR/head-name" ] &&
+ die "won't bisect on seeked tree"
+ start_head="${head#refs/heads/}"
+ ;;
+ *)
+ die "Bad HEAD - strange symbolic ref"
+ ;;
+ esac
+ fi
#
- # Get rid of any old bisect state
+ # Get rid of any old bisect state.
#
- bisect_clean_state
+ bisect_clean_state || exit
#
# Check for one bad and then some good revisions.
@@ -93,6 +109,7 @@ bisect_start() {
done
orig_args=$(sq "$@")
bad_seen=0
+ eval=''
while [ $# -gt 0 ]; do
arg="$1"
case "$arg" in
@@ -101,7 +118,7 @@ bisect_start() {
break
;;
*)
- rev=$(git rev-parse --verify "$arg^{commit}" 2>/dev/null) || {
+ rev=$(git rev-parse -q --verify "$arg^{commit}") || {
test $has_double_dash -eq 1 &&
die "'$arg' does not appear to be a valid revision"
break
@@ -110,15 +127,35 @@ bisect_start() {
0) state='bad' ; bad_seen=1 ;;
*) state='good' ;;
esac
- bisect_write "$state" "$rev" 'nolog'
+ eval="$eval bisect_write '$state' '$rev' 'nolog'; "
shift
;;
esac
done
- sq "$@" >"$GIT_DIR/BISECT_NAMES"
- echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG"
+ #
+ # Change state.
+ # In case of mistaken revs or checkout error, or signals received,
+ # "bisect_auto_next" below may exit or misbehave.
+ # We have to trap this to be able to clean up using
+ # "bisect_clean_state".
+ #
+ trap 'bisect_clean_state' 0
+ trap 'exit 255' 1 2 3 15
+
+ #
+ # Write new start state.
+ #
+ echo "$start_head" >"$GIT_DIR/BISECT_START" &&
+ sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
+ eval "$eval" &&
+ echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
+ #
+ # Check if we can proceed to the next bisect state.
+ #
bisect_auto_next
+
+ trap '-' 0
}
bisect_write() {
@@ -130,9 +167,9 @@ bisect_write() {
good|skip) tag="$state"-"$rev" ;;
*) die "Bad bisect_write argument: $state" ;;
esac
- git update-ref "refs/bisect/$tag" "$rev"
- echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
- test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
+ git update-ref "refs/bisect/$tag" "$rev" || exit
+ echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
+ test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
}
bisect_state() {
@@ -145,20 +182,18 @@ bisect_state() {
rev=$(git rev-parse --verify HEAD) ||
die "Bad rev input: HEAD"
bisect_write "$state" "$rev" ;;
- 2,bad)
- rev=$(git rev-parse --verify "$2^{commit}") ||
- die "Bad rev input: $2"
- bisect_write "$state" "$rev" ;;
- *,good|*,skip)
+ 2,bad|*,good|*,skip)
shift
- revs=$(git rev-parse --revs-only --no-flags "$@") &&
- test '' != "$revs" || die "Bad rev input: $@"
- for rev in $revs
+ eval=''
+ for rev in "$@"
do
- rev=$(git rev-parse --verify "$rev^{commit}") ||
- die "Bad rev commit: $rev^{commit}"
- bisect_write "$state" "$rev"
- done ;;
+ sha=$(git rev-parse --verify "$rev^{commit}") ||
+ die "Bad rev input: $rev"
+ eval="$eval bisect_write '$state' '$sha'; "
+ done
+ eval "$eval" ;;
+ *,bad)
+ die "'git bisect bad' can take only one argument." ;;
*)
usage ;;
esac
@@ -185,13 +220,14 @@ bisect_next_check() {
if test -t 0
then
printf >&2 'Are you sure [Y/n]? '
- case "$(read yesno)" in [Nn]*) exit 1 ;; esac
+ read yesno
+ case "$yesno" in [Nn]*) exit 1 ;; esac
fi
: bisect without good...
;;
*)
THEN=''
- test -f "$GIT_DIR/BISECT_NAMES" || {
+ test -s "$GIT_DIR/BISECT_START" || {
echo >&2 'You need to start by "git bisect start".'
THEN='then '
}
@@ -207,18 +243,33 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
+eval_rev_list() {
+ _eval="$1"
+
+ eval $_eval
+ res=$?
+
+ if [ $res -ne 0 ]; then
+ echo >&2 "'git rev-list --bisect-vars' failed:"
+ echo >&2 "maybe you mistake good and bad revs?"
+ exit $res
+ fi
+
+ return $res
+}
+
filter_skipped() {
_eval="$1"
_skip="$2"
if [ -z "$_skip" ]; then
- eval $_eval
+ eval_rev_list "$_eval"
return
fi
# Let's parse the output of:
# "git rev-list --bisect-vars --bisect-all ..."
- eval $_eval | while read hash line
+ eval_rev_list "$_eval" | while read hash line
do
case "$VARS,$FOUND,$TRIED,$hash" in
# We display some vars.
@@ -287,14 +338,14 @@ bisect_next() {
bisect_next_check good
skip=$(git for-each-ref --format='%(objectname)' \
- "refs/bisect/skip-*" | tr '[\012]' ' ') || exit
+ "refs/bisect/skip-*" | tr '\012' ' ') || exit
BISECT_OPT=''
test -n "$skip" && BISECT_OPT='--bisect-all'
bad=$(git rev-parse --verify refs/bisect/bad) &&
good=$(git for-each-ref --format='^%(objectname)' \
- "refs/bisect/good-*" | tr '[\012]' ' ') &&
+ "refs/bisect/good-*" | tr '\012' ' ') &&
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
eval=$(filter_skipped "$eval" "$skip") &&
@@ -316,9 +367,7 @@ bisect_next() {
exit_if_skipped_commits "$bisect_rev"
echo "Bisecting: $bisect_nr revisions left to test after this"
- git branch -f new-bisect "$bisect_rev"
- git checkout -q new-bisect || exit
- git branch -M new-bisect bisect
+ git checkout -q "$bisect_rev" || exit
git show-branch "$bisect_rev"
}
@@ -327,9 +376,9 @@ bisect_visualize() {
if test $# = 0
then
- case "${DISPLAY+set}" in
+ case "${DISPLAY+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" in
'') set git log ;;
- set) set gitk ;;
+ set*) set gitk ;;
esac
else
case "$1" in
@@ -344,46 +393,47 @@ bisect_visualize() {
}
bisect_reset() {
- test -f "$GIT_DIR/BISECT_NAMES" || {
+ test -s "$GIT_DIR/BISECT_START" || {
echo "We are not bisecting."
return
}
case "$#" in
- 0) if [ -s "$GIT_DIR/head-name" ]; then
- branch=`cat "$GIT_DIR/head-name"`
- else
- branch=master
- fi ;;
+ 0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
1) git show-ref --verify --quiet -- "refs/heads/$1" ||
die "$1 does not seem to be a valid branch"
branch="$1" ;;
*)
usage ;;
esac
- if git checkout "$branch"; then
- rm -f "$GIT_DIR/head-name"
- bisect_clean_state
- fi
+ git checkout "$branch" && bisect_clean_state
}
bisect_clean_state() {
# There may be some refs packed during bisection.
- git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* refs/heads/bisect |
+ git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
while read ref hash
do
- git update-ref -d $ref $hash
+ git update-ref -d $ref $hash || exit
done
- rm -f "$GIT_DIR/BISECT_LOG"
- rm -f "$GIT_DIR/BISECT_NAMES"
- rm -f "$GIT_DIR/BISECT_RUN"
+ rm -f "$GIT_DIR/BISECT_LOG" &&
+ rm -f "$GIT_DIR/BISECT_NAMES" &&
+ rm -f "$GIT_DIR/BISECT_RUN" &&
+ # Cleanup head-name if it got left by an old version of git-bisect
+ rm -f "$GIT_DIR/head-name" &&
+
+ rm -f "$GIT_DIR/BISECT_START"
}
bisect_replay () {
test -r "$1" || die "cannot read $1 for replaying"
bisect_reset
- while read bisect command rev
+ while read git bisect command rev
do
- test "$bisect" = "git-bisect" || continue
+ test "$git $bisect" = "git bisect" -o "$git" = "git-bisect" || continue
+ if test "$git" = "git-bisect"; then
+ rev="$command"
+ command="$bisect"
+ fi
case "$command" in
start)
cmd="bisect_start $rev"
@@ -457,6 +507,8 @@ case "$#" in
cmd="$1"
shift
case "$cmd" in
+ help)
+ git bisect -h ;;
start)
bisect_start "$@" ;;
bad|good|skip)
diff --git a/git-compat-util.h b/git-compat-util.h
index b6ef5442b..cf89cdf45 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -39,7 +39,7 @@
/* Approximation of the length of the decimal representation of this type. */
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX)
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#endif
@@ -63,14 +63,18 @@
#include <sys/time.h>
#include <time.h>
#include <signal.h>
-#include <sys/wait.h>
#include <fnmatch.h>
+#include <assert.h>
+#include <regex.h>
+#include <utime.h>
+#ifndef __MINGW32__
+#include <sys/wait.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
+#ifndef NO_SYS_SELECT_H
#include <sys/select.h>
-#include <assert.h>
-#include <regex.h>
+#endif
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
@@ -86,6 +90,10 @@
#include <grp.h>
#define _ALL_SOURCE 1
#endif
+#else /* __MINGW32__ */
+/* pull in Windows compatibility stuff */
+#include "compat/mingw.h"
+#endif /* __MINGW32__ */
#ifndef NO_ICONV
#include <iconv.h>
@@ -102,6 +110,30 @@
#define PRIuMAX "llu"
#endif
+#ifndef PRIu32
+#define PRIu32 "u"
+#endif
+
+#ifndef PRIx32
+#define PRIx32 "x"
+#endif
+
+#ifndef PATH_SEP
+#define PATH_SEP ':'
+#endif
+
+#ifndef STRIP_EXTENSION
+#define STRIP_EXTENSION ""
+#endif
+
+#ifndef has_dos_drive_prefix
+#define has_dos_drive_prefix(path) 0
+#endif
+
+#ifndef is_dir_sep
+#define is_dir_sep(c) ((c) == '/')
+#endif
+
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
#else
@@ -123,6 +155,13 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));
extern void set_warn_routine(void (*routine)(const char *warn, va_list params));
extern int prefixcmp(const char *str, const char *prefix);
+extern time_t tm_to_time_t(const struct tm *tm);
+
+static inline const char *skip_prefix(const char *str, const char *prefix)
+{
+ size_t len = strlen(prefix);
+ return strncmp(str, prefix, len) ? NULL : str + len;
+}
#ifdef NO_MMAP
@@ -160,6 +199,12 @@ extern int git_munmap(void *start, size_t length);
#define pread git_pread
extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
#endif
+/*
+ * Forward decl that will remind us if its twin in cache.h changes.
+ * This function is used in compat/pread.c. But we can't include
+ * cache.h there.
+ */
+extern ssize_t read_in_full(int fd, void *buf, size_t count);
#ifdef NO_SETENV
#define setenv gitsetenv
@@ -202,6 +247,23 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
#endif
+#ifdef FREAD_READS_DIRECTORIES
+#ifdef fopen
+#undef fopen
+#endif
+#define fopen(a,b) git_fopen(a,b)
+extern FILE *git_fopen(const char*, const char*);
+#endif
+
+#ifdef SNPRINTF_RETURNS_BOGUS
+#define snprintf git_snprintf
+extern int git_snprintf(char *str, size_t maxsize,
+ const char *format, ...);
+#define vsnprintf git_vsnprintf
+extern int git_vsnprintf(char *str, size_t maxsize,
+ const char *format, va_list ap);
+#endif
+
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 1)
#define HAVE_STRCHRNUL
@@ -220,145 +282,18 @@ static inline char *gitstrchrnul(const char *s, int c)
extern void release_pack_memory(size_t, int);
-static inline char* xstrdup(const char *str)
-{
- char *ret = strdup(str);
- if (!ret) {
- release_pack_memory(strlen(str) + 1, -1);
- ret = strdup(str);
- if (!ret)
- die("Out of memory, strdup failed");
- }
- return ret;
-}
-
-static inline void *xmalloc(size_t size)
-{
- void *ret = malloc(size);
- if (!ret && !size)
- ret = malloc(1);
- if (!ret) {
- release_pack_memory(size, -1);
- ret = malloc(size);
- if (!ret && !size)
- ret = malloc(1);
- if (!ret)
- die("Out of memory, malloc failed");
- }
-#ifdef XMALLOC_POISON
- memset(ret, 0xA5, size);
-#endif
- return ret;
-}
-
-static inline void *xmemdupz(const void *data, size_t len)
-{
- char *p = xmalloc(len + 1);
- memcpy(p, data, len);
- p[len] = '\0';
- return p;
-}
-
-static inline char *xstrndup(const char *str, size_t len)
-{
- char *p = memchr(str, '\0', len);
- return xmemdupz(str, p ? p - str : len);
-}
-
-static inline void *xrealloc(void *ptr, size_t size)
-{
- void *ret = realloc(ptr, size);
- if (!ret && !size)
- ret = realloc(ptr, 1);
- if (!ret) {
- release_pack_memory(size, -1);
- ret = realloc(ptr, size);
- if (!ret && !size)
- ret = realloc(ptr, 1);
- if (!ret)
- die("Out of memory, realloc failed");
- }
- return ret;
-}
-
-static inline void *xcalloc(size_t nmemb, size_t size)
-{
- void *ret = calloc(nmemb, size);
- if (!ret && (!nmemb || !size))
- ret = calloc(1, 1);
- if (!ret) {
- release_pack_memory(nmemb * size, -1);
- ret = calloc(nmemb, size);
- if (!ret && (!nmemb || !size))
- ret = calloc(1, 1);
- if (!ret)
- die("Out of memory, calloc failed");
- }
- return ret;
-}
-
-static inline void *xmmap(void *start, size_t length,
- int prot, int flags, int fd, off_t offset)
-{
- void *ret = mmap(start, length, prot, flags, fd, offset);
- if (ret == MAP_FAILED) {
- if (!length)
- return NULL;
- release_pack_memory(length, fd);
- ret = mmap(start, length, prot, flags, fd, offset);
- if (ret == MAP_FAILED)
- die("Out of memory? mmap failed: %s", strerror(errno));
- }
- return ret;
-}
-
-static inline ssize_t xread(int fd, void *buf, size_t len)
-{
- ssize_t nr;
- while (1) {
- nr = read(fd, buf, len);
- if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
- continue;
- return nr;
- }
-}
-
-static inline ssize_t xwrite(int fd, const void *buf, size_t len)
-{
- ssize_t nr;
- while (1) {
- nr = write(fd, buf, len);
- if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
- continue;
- return nr;
- }
-}
-
-static inline int xdup(int fd)
-{
- int ret = dup(fd);
- if (ret < 0)
- die("dup failed: %s", strerror(errno));
- return ret;
-}
-
-static inline FILE *xfdopen(int fd, const char *mode)
-{
- FILE *stream = fdopen(fd, mode);
- if (stream == NULL)
- die("Out of memory? fdopen failed: %s", strerror(errno));
- return stream;
-}
-
-static inline int xmkstemp(char *template)
-{
- int fd;
-
- fd = mkstemp(template);
- if (fd < 0)
- die("Unable to create temporary file: %s", strerror(errno));
- return fd;
-}
+extern char *xstrdup(const char *str);
+extern void *xmalloc(size_t size);
+extern void *xmemdupz(const void *data, size_t len);
+extern char *xstrndup(const char *str, size_t len);
+extern void *xrealloc(void *ptr, size_t size);
+extern void *xcalloc(size_t nmemb, size_t size);
+extern void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
+extern ssize_t xread(int fd, void *buf, size_t len);
+extern ssize_t xwrite(int fd, const void *buf, size_t len);
+extern int xdup(int fd);
+extern FILE *xfdopen(int fd, const char *mode);
+extern int xmkstemp(char *template);
static inline size_t xsize_t(off_t len)
{
@@ -424,4 +359,16 @@ static inline int strtol_i(char const *s, int base, int *result)
return 0;
}
+#ifdef INTERNAL_QSORT
+void git_qsort(void *base, size_t nmemb, size_t size,
+ int(*compar)(const void *, const void *));
+#define qsort git_qsort
+#endif
+
+#ifndef DIR_HAS_BSD_GROUP_SEMANTICS
+# define FORCE_DIR_SET_GID S_ISGID
+#else
+# define FORCE_DIR_SET_GID 0
+#endif
+
#endif
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index d2e50c342..6d9f0ef0f 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -5,28 +5,34 @@ use Getopt::Std;
use File::Temp qw(tempdir);
use Data::Dumper;
use File::Basename qw(basename dirname);
+use File::Spec;
+use Git;
-our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w);
+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d, $opt_u, $opt_w, $opt_W);
-getopts('uhPpvcfam:d:w:');
+getopts('uhPpvcfam:d:w:W');
$opt_h && usage();
die "Need at least one commit identifier!" unless @ARGV;
-if ($opt_w) {
+# Get git-config settings
+my $repo = Git->repository();
+$opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;
+
+if ($opt_w || $opt_W) {
+ # Remember where GIT_DIR is before changing to CVS checkout
unless ($ENV{GIT_DIR}) {
- # Remember where our GIT_DIR is before changing to CVS checkout
+ # No GIT_DIR set. Figure it out for ourselves
my $gd =`git-rev-parse --git-dir`;
chomp($gd);
- if ($gd eq '.git') {
- my $wd = `pwd`;
- chomp($wd);
- $gd = $wd."/.git" ;
- }
$ENV{GIT_DIR} = $gd;
}
+ # Make sure GIT_DIR is absolute
+ $ENV{GIT_DIR} = File::Spec->rel2abs($ENV{GIT_DIR});
+}
+if ($opt_w) {
if (! -d $opt_w."/CVS" ) {
die "$opt_w is not a CVS checkout";
}
@@ -117,6 +123,15 @@ if ($parent) {
}
}
+my $go_back_to = 0;
+
+if ($opt_W) {
+ $opt_v && print "Resetting to $parent\n";
+ $go_back_to = `git symbolic-ref HEAD 2> /dev/null ||
+ git rev-parse HEAD` || die "Could not determine current branch";
+ system("git checkout -q $parent^0") && die "Could not check out $parent^0";
+}
+
$opt_v && print "Applying to CVS commit $commit from parent $parent\n";
# grab the commit message
@@ -198,15 +213,40 @@ if (@canstatusfiles) {
my @updated = xargs_safe_pipe_capture([@cvs, 'update'], @canstatusfiles);
print @updated;
}
- my @cvsoutput;
- @cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles);
- my $matchcount = 0;
- foreach my $l (@cvsoutput) {
- chomp $l;
- if ( $l =~ /^File:/ and $l =~ /Status: (.*)$/ ) {
- $cvsstat{$canstatusfiles[$matchcount]} = $1;
- $matchcount++;
+ # "cvs status" reorders the parameters, notably when there are multiple
+ # arguments with the same basename. So be precise here.
+
+ my %added = map { $_ => 1 } @afiles;
+ my %todo = map { $_ => 1 } @canstatusfiles;
+
+ while (%todo) {
+ my @canstatusfiles2 = ();
+ my %fullname = ();
+ foreach my $name (keys %todo) {
+ my $basename = basename($name);
+
+ $basename = "no file " . $basename if (exists($added{$basename}));
+ $basename =~ s/^\s+//;
+ $basename =~ s/\s+$//;
+
+ if (!exists($fullname{$basename})) {
+ $fullname{$basename} = $name;
+ push (@canstatusfiles2, $name);
+ delete($todo{$name});
}
+ }
+ my @cvsoutput;
+ @cvsoutput = xargs_safe_pipe_capture([@cvs, 'status'], @canstatusfiles2);
+ foreach my $l (@cvsoutput) {
+ chomp $l;
+ if ($l =~ /^File:\s+(.*\S)\s+Status: (.*)$/) {
+ if (!exists($fullname{$1})) {
+ print STDERR "Huh? Status reported for unexpected file '$1'\n";
+ } else {
+ $cvsstat{$fullname{$1}} = $2;
+ }
+ }
+ }
}
}
@@ -236,7 +276,11 @@ if ($dirty) {
}
print "Applying\n";
-`GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
+if ($opt_W) {
+ system("git checkout -q $commit^0") && die "cannot patch";
+} else {
+ `GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
+}
print "Patch applied successfully. Adding new files and directories to CVS\n";
my $dirtypatch = 0;
@@ -289,7 +333,9 @@ if ($dirtypatch) {
print "using a patch program. After applying the patch and resolving the\n";
print "problems you may commit using:";
print "\n cd \"$opt_w\"" if $opt_w;
- print "\n $cmd\n\n";
+ print "\n $cmd\n";
+ print "\n git checkout $go_back_to\n" if $go_back_to;
+ print "\n";
exit(1);
}
@@ -309,6 +355,14 @@ if ($opt_c) {
# clean up
unlink(".cvsexportcommit.diff");
+if ($opt_W) {
+ system("git checkout $go_back_to") && die "cannot move back to $go_back_to";
+ if (!($go_back_to =~ /^[0-9a-fA-F]{40}$/)) {
+ system("git symbolic-ref HEAD $go_back_to") &&
+ die "cannot move back to $go_back_to";
+ }
+}
+
# CVS version 1.11.x and 1.12.x sleeps the wrong way to ensure the timestamp
# used by CVS and the one set by subsequence file modifications are different.
# If they are not different CVS will not detect changes.
@@ -316,7 +370,7 @@ sleep(1);
sub usage {
print STDERR <<END;
-Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [-f] [-u] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
+Usage: GIT_DIR=/path/to/.git git cvsexportcommit [-h] [-p] [-v] [-c] [-f] [-u] [-w cvsworkdir] [-m msgprefix] [ parent ] commit
END
exit(1);
}
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 5694978c4..e43920296 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -15,7 +15,7 @@
use strict;
use warnings;
-use Getopt::Std;
+use Getopt::Long;
use File::Spec;
use File::Temp qw(tempfile tmpnam);
use File::Path qw(mkpath);
@@ -29,14 +29,14 @@ use IPC::Open2;
$SIG{'PIPE'}="IGNORE";
$ENV{'TZ'}="UTC";
-our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
+our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r);
my (%conv_author_name, %conv_author_email);
sub usage(;$) {
my $msg = shift;
print(STDERR "Error: $msg\n") if $msg;
print STDERR <<END;
-Usage: ${\basename $0} # fetch/update GIT from CVS
+Usage: git cvsimport # fetch/update GIT from CVS
[-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
[-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]
[-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]
@@ -112,7 +112,12 @@ sub read_repo_config {
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
read_repo_config($opts);
-getopts($opts) or usage();
+Getopt::Long::Configure( 'no_ignore_case', 'bundling' );
+
+# turn the Getopt::Std specification in a Getopt::Long one,
+# with support for multiple -M options
+GetOptions( map { s/:/=s/; /M/ ? "$_\@" : $_ } split( /(?!:)/, $opts ) )
+ or usage();
usage if $opt_h;
if (@ARGV == 0) {
@@ -164,10 +169,10 @@ if ($#ARGV == 0) {
our @mergerx = ();
if ($opt_m) {
- @mergerx = ( qr/\W(?:from|of|merge|merging|merged) (\w+)/i );
+ @mergerx = ( qr/\b(?:from|of|merge|merging|merged) ([-\w]+)/i );
}
-if ($opt_M) {
- push (@mergerx, qr/$opt_M/);
+if (@opt_M) {
+ push (@mergerx, map { qr/$_/ } @opt_M);
}
# Remember UTC of our starting time
@@ -222,6 +227,7 @@ sub conn {
$proxyport = $1;
}
}
+ $repo ||= '/';
# if username is not explicit in CVSROOT, then use current user, as cvs would
$user=(getlogin() || $ENV{'LOGNAME'} || $ENV{'USER'} || "anonymous") unless $user;
@@ -730,7 +736,7 @@ sub commit {
next unless $logmsg =~ $rx && $1;
my $mparent = $1 eq 'HEAD' ? $opt_o : $1;
if (my $sha1 = get_headref("$remote/$mparent")) {
- push @commit_args, '-p', $mparent;
+ push @commit_args, '-p', "$remote/$mparent";
print "Merge parent branch: $mparent\n" if $opt_v;
}
}
@@ -767,7 +773,7 @@ sub commit {
waitpid($pid,0);
die "Error running git-commit-tree: $?\n" if $?;
- system("git-update-ref $remote/$branch $cid") == 0
+ system('git-update-ref', "$remote/$branch", $cid) == 0
or die "Cannot write branch $branch for update: $!\n";
if ($tag) {
@@ -775,6 +781,7 @@ sub commit {
$xtag =~ s/\s+\*\*.*$//; # Remove stuff like ** INVALID ** and ** FUNKY **
$xtag =~ tr/_/\./ if ( $opt_u );
$xtag =~ s/[\/]/$opt_s/g;
+ $xtag =~ s/\[//g;
system('git-tag', '-f', $xtag, $cid) == 0
or die "Cannot create tag $xtag: $!\n";
@@ -945,7 +952,7 @@ while (<CVS>) {
} elsif (/^-+$/) { # end of unknown-line processing
$state = 1;
} elsif ($state != 11) { # ignore stuff when skipping
- print "* UNKNOWN LINE * $_\n";
+ print STDERR "* UNKNOWN LINE * $_\n";
}
}
commit() if $branch and $state != 11;
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index ecded3b9c..b0a805c68 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -21,6 +21,7 @@ use bytes;
use Fcntl;
use File::Temp qw/tempdir tempfile/;
+use File::Path qw/rmtree/;
use File::Basename;
use Getopt::Long qw(:config require_order no_ignore_case);
@@ -73,8 +74,8 @@ my $methods = {
'status' => \&req_status,
'admin' => \&req_CATCHALL,
'history' => \&req_CATCHALL,
- 'watchers' => \&req_CATCHALL,
- 'editors' => \&req_CATCHALL,
+ 'watchers' => \&req_EMPTY,
+ 'editors' => \&req_EMPTY,
'annotate' => \&req_annotate,
'Global_option' => \&req_Globaloption,
#'annotate' => \&req_CATCHALL,
@@ -86,10 +87,21 @@ my $methods = {
# $state holds all the bits of information the clients sends us that could
# potentially be useful when it comes to actually _doing_ something.
my $state = { prependdir => '' };
+
+# Work is for managing temporary working directory
+my $work =
+ {
+ state => undef, # undef, 1 (empty), 2 (with stuff)
+ workDir => undef,
+ index => undef,
+ emptyDir => undef,
+ tmpDir => undef
+ };
+
$log->info("--------------- STARTING -----------------");
my $usage =
- "Usage: git-cvsserver [options] [pserver|server] [<directory> ...]\n".
+ "Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
" --base-path <path> : Prepend to requested CVSROOT\n".
" --strict-paths : Don't allow recursing into subdirectories\n".
" --export-all : Don't check for gitcvs.enabled in config\n".
@@ -189,6 +201,9 @@ while (<STDIN>)
$log->debug("Processing time : user=" . (times)[0] . " system=" . (times)[1]);
$log->info("--------------- FINISH -----------------");
+chdir '/';
+exit 0;
+
# Magic catchall method.
# This is the method that will handle all commands we haven't yet
# implemented. It simply sends a warning to the log file indicating a
@@ -199,6 +214,11 @@ sub req_CATCHALL
$log->warn("Unhandled command : req_$cmd : $data");
}
+# This method invariably succeeds with an empty response.
+sub req_EMPTY
+{
+ print "ok\n";
+}
# Root pathname \n
# Response expected: no. Tell the server which CVSROOT to use. Note that
@@ -482,7 +502,7 @@ sub req_add
print $state->{CVSROOT} . "/$state->{module}/$filename\n";
# this is an "entries" line
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
$log->debug("/$filepart/1.$meta->{revision}//$kopts/");
print "/$filepart/1.$meta->{revision}//$kopts/\n";
# permissions
@@ -513,9 +533,26 @@ sub req_add
print "Checked-in $dirpart\n";
print "$filename\n";
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path($filename,"file",
+ $state->{entries}{$filename}{modified_filename});
print "/$filepart/0//$kopts/\n";
+ my $requestedKopts = $state->{opt}{k};
+ if(defined($requestedKopts))
+ {
+ $requestedKopts = "-k$requestedKopts";
+ }
+ else
+ {
+ $requestedKopts = "";
+ }
+ if( $kopts ne $requestedKopts )
+ {
+ $log->warn("Ignoring requested -k='$requestedKopts'"
+ . " for '$filename'; detected -k='$kopts' instead");
+ #TODO: Also have option to send warning to user?
+ }
+
$addcount++;
}
@@ -595,7 +632,7 @@ sub req_remove
print "Checked-in $dirpart\n";
print "$filename\n";
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
print "/$filepart/-1.$wrev//$kopts/\n";
$rmcount++;
@@ -764,7 +801,20 @@ sub req_co
argsplit("co");
+ # Provide list of modules, if -c was used.
+ if (exists $state->{opt}{c}) {
+ my $showref = `git show-ref --heads`;
+ for my $line (split '\n', $showref) {
+ if ( $line =~ m% refs/heads/(.*)$% ) {
+ print "M $1\t$1\n";
+ }
+ }
+ print "ok\n";
+ return 1;
+ }
+
my $module = $state->{args}[0];
+ $state->{module} = $module;
my $checkout_path = $module;
# use the user specified directory if we're given it
@@ -842,6 +892,7 @@ sub req_co
# Don't want to check out deleted files
next if ( $git->{filehash} eq "deleted" );
+ my $fullName = $git->{name};
( $git->{name}, $git->{dir} ) = filenamesplit($git->{name});
if (length($git->{dir}) && $git->{dir} ne './'
@@ -872,7 +923,7 @@ sub req_co
print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n";
# this is an "entries" line
- my $kopts = kopts_from_path($git->{name});
+ my $kopts = kopts_from_path($fullName,"sha1",$git->{filehash});
print "/$git->{name}/1.$git->{revision}//$kopts/\n";
# permissions
print "u=$git->{mode},g=$git->{mode},o=$git->{mode}\n";
@@ -908,21 +959,15 @@ sub req_update
# projects (heads in this case) to checkout.
#
if ($state->{module} eq '') {
- my $heads_dir = $state->{CVSROOT} . '/refs/heads';
- if (!opendir HEADS, $heads_dir) {
- print "E [server aborted]: Failed to open directory, "
- . "$heads_dir: $!\nerror\n";
- return 0;
- }
+ my $showref = `git show-ref --heads`;
print "E cvs update: Updating .\n";
- while (my $head = readdir(HEADS)) {
- if (-f $state->{CVSROOT} . '/refs/heads/' . $head) {
- print "E cvs update: New directory `$head'\n";
- }
- }
- closedir HEADS;
- print "ok\n";
- return 1;
+ for my $line (split '\n', $showref) {
+ if ( $line =~ m% refs/heads/(.*)$% ) {
+ print "E cvs update: New directory `$1'\n";
+ }
+ }
+ print "ok\n";
+ return 1;
}
@@ -958,6 +1003,17 @@ sub req_update
$meta = $updater->getmeta($filename);
}
+ # If -p was given, "print" the contents of the requested revision.
+ if ( exists ( $state->{opt}{p} ) ) {
+ if ( defined ( $meta->{revision} ) ) {
+ $log->info("Printing '$filename' revision " . $meta->{revision});
+
+ transmitfile($meta->{filehash}, { print => 1 });
+ }
+
+ next;
+ }
+
if ( ! defined $meta )
{
$meta = {
@@ -1070,7 +1126,7 @@ sub req_update
print $state->{CVSROOT} . "/$state->{module}/$filename\n";
# this is an "entries" line
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
$log->debug("/$filepart/1.$meta->{revision}//$kopts/");
print "/$filepart/1.$meta->{revision}//$kopts/\n";
@@ -1085,25 +1141,27 @@ sub req_update
$log->info("Updating '$filename'");
my ( $filepart, $dirpart ) = filenamesplit($meta->{name},1);
- my $dir = tempdir( DIR => $TEMP_DIR, CLEANUP => 1 ) . "/";
+ my $mergeDir = setupTmpDir();
- chdir $dir;
my $file_local = $filepart . ".mine";
+ my $mergedFile = "$mergeDir/$file_local";
system("ln","-s",$state->{entries}{$filename}{modified_filename}, $file_local);
my $file_old = $filepart . "." . $oldmeta->{revision};
- transmitfile($oldmeta->{filehash}, $file_old);
+ transmitfile($oldmeta->{filehash}, { targetfile => $file_old });
my $file_new = $filepart . "." . $meta->{revision};
- transmitfile($meta->{filehash}, $file_new);
+ transmitfile($meta->{filehash}, { targetfile => $file_new });
# we need to merge with the local changes ( M=successful merge, C=conflict merge )
$log->info("Merging $file_local, $file_old, $file_new");
print "M Merging differences between 1.$oldmeta->{revision} and 1.$meta->{revision} into $filename\n";
- $log->debug("Temporary directory for merge is $dir");
+ $log->debug("Temporary directory for merge is $mergeDir");
my $return = system("git", "merge-file", $file_local, $file_old, $file_new);
$return >>= 8;
+ cleanupTmpDir();
+
if ( $return == 0 )
{
$log->info("Merged successfully");
@@ -1116,7 +1174,8 @@ sub req_update
print "Merged $dirpart\n";
$log->debug($state->{CVSROOT} . "/$state->{module}/$filename");
print $state->{CVSROOT} . "/$state->{module}/$filename\n";
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path("$dirpart/$filepart",
+ "file",$mergedFile);
$log->debug("/$filepart/1.$meta->{revision}//$kopts/");
print "/$filepart/1.$meta->{revision}//$kopts/\n";
}
@@ -1132,7 +1191,8 @@ sub req_update
{
print "Merged $dirpart\n";
print $state->{CVSROOT} . "/$state->{module}/$filename\n";
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path("$dirpart/$filepart",
+ "file",$mergedFile);
print "/$filepart/1.$meta->{revision}/+/$kopts/\n";
}
}
@@ -1152,13 +1212,11 @@ sub req_update
# transmit file, format is single integer on a line by itself (file
# size) followed by the file contents
# TODO : we should copy files in blocks
- my $data = `cat $file_local`;
+ my $data = `cat $mergedFile`;
$log->debug("File size : " . length($data));
print length($data) . "\n";
print $data;
}
-
- chdir "/";
}
}
@@ -1179,6 +1237,7 @@ sub req_ci
if ( $state->{method} eq 'pserver')
{
print "error 1 pserver access cannot commit\n";
+ cleanupWorkTree();
exit;
}
@@ -1186,6 +1245,7 @@ sub req_ci
{
$log->warn("file 'index' already exists in the git repository");
print "error 1 Index already exists in git repo\n";
+ cleanupWorkTree();
exit;
}
@@ -1193,31 +1253,20 @@ sub req_ci
my $updater = GITCVS::updater->new($state->{CVSROOT}, $state->{module}, $log);
$updater->update();
- my $tmpdir = tempdir ( DIR => $TEMP_DIR );
- my ( undef, $file_index ) = tempfile ( DIR => $TEMP_DIR, OPEN => 0 );
- $log->info("Lockless commit start, basing commit on '$tmpdir', index file is '$file_index'");
-
- $ENV{GIT_DIR} = $state->{CVSROOT} . "/";
- $ENV{GIT_WORK_TREE} = ".";
- $ENV{GIT_INDEX_FILE} = $file_index;
-
# Remember where the head was at the beginning.
my $parenthash = `git show-ref -s refs/heads/$state->{module}`;
chomp $parenthash;
if ($parenthash !~ /^[0-9a-f]{40}$/) {
print "error 1 pserver cannot find the current HEAD of module";
+ cleanupWorkTree();
exit;
}
- chdir $tmpdir;
+ setupWorkTree($parenthash);
- # populate the temporary index
- system("git-read-tree", $parenthash);
- unless ($? == 0)
- {
- die "Error running git-read-tree $state->{module} $file_index $!";
- }
- $log->info("Created index '$file_index' for head $state->{module} - exit status $?");
+ $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;
@@ -1255,7 +1304,7 @@ sub req_ci
{
# fail everything if an up to date check fails
print "error 1 Up to date check failed for $filename\n";
- chdir "/";
+ cleanupWorkTree();
exit;
}
@@ -1297,7 +1346,7 @@ sub req_ci
{
print "E No files to commit\n";
print "ok\n";
- chdir "/";
+ cleanupWorkTree();
return;
}
@@ -1320,7 +1369,7 @@ sub req_ci
{
$log->warn("Commit failed (Invalid commit hash)");
print "error 1 Commit failed (unknown reason)\n";
- chdir "/";
+ cleanupWorkTree();
exit;
}
@@ -1332,7 +1381,7 @@ sub req_ci
{
$log->warn("Commit failed (update hook declined to update ref)");
print "error 1 Commit failed (update hook declined)\n";
- chdir "/";
+ cleanupWorkTree();
exit;
}
}
@@ -1342,6 +1391,7 @@ sub req_ci
"refs/heads/$state->{module}", $commithash, $parenthash)) {
$log->warn("update-ref for $state->{module} failed.");
print "error 1 Cannot commit -- update first\n";
+ cleanupWorkTree();
exit;
}
@@ -1393,12 +1443,12 @@ sub req_ci
}
print "Checked-in $dirpart\n";
print "$filename\n";
- my $kopts = kopts_from_path($filepart);
+ my $kopts = kopts_from_path($filename,"sha1",$meta->{filehash});
print "/$filepart/1.$meta->{revision}//$kopts/\n";
}
}
- chdir "/";
+ cleanupWorkTree();
print "ok\n";
}
@@ -1423,6 +1473,8 @@ sub req_status
{
$filename = filecleanup($filename);
+ next if exists($state->{opt}{l}) && index($filename, '/', length($state->{prependdir})) >= 0;
+
my $meta = $updater->getmeta($filename);
my $oldmeta = $meta;
@@ -1466,8 +1518,10 @@ sub req_status
$status ||= "Unknown";
+ my ($filepart) = filenamesplit($filename);
+
print "M ===================================================================\n";
- print "M File: $filename\tStatus: $status\n";
+ print "M File: $filepart\tStatus: $status\n";
if ( defined($state->{entries}{$filename}{revision}) )
{
print "M Working revision:\t" . $state->{entries}{$filename}{revision} . "\n";
@@ -1541,14 +1595,14 @@ sub req_diff
print "E File $filename at revision 1.$revision1 doesn't exist\n";
next;
}
- transmitfile($meta1->{filehash}, $file1);
+ 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}, $file1);
+ transmitfile($meta1->{filehash}, { targetfile => $file1 });
}
# if we have a second -r switch, use it too
@@ -1563,7 +1617,7 @@ sub req_diff
next;
}
- transmitfile($meta2->{filehash}, $file2);
+ transmitfile($meta2->{filehash}, { targetfile => $file2 });
}
# otherwise we just use the working copy
else
@@ -1576,7 +1630,7 @@ sub req_diff
{
( undef, $file2 ) = tempfile( DIR => $TEMP_DIR, OPEN => 0 );
$meta2 = $updater->getmeta($filename, $wrev);
- transmitfile($meta2->{filehash}, $file2);
+ transmitfile($meta2->{filehash}, { targetfile => $file2 });
}
# We need to have retrieved something useful
@@ -1708,8 +1762,7 @@ sub req_log
print "M revision 1.$revision->{revision}\n";
# reformat the date for log output
$revision->{modified} = sprintf('%04d/%02d/%02d %s', $3, $DATE_LIST->{$2}, $1, $4 ) if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and defined($DATE_LIST->{$2}) );
- $revision->{author} =~ s/\s+.*//;
- $revision->{author} =~ s/^(.{8}).*/$1/;
+ $revision->{author} = cvs_author($revision->{author});
print "M date: $revision->{modified}; author: $revision->{author}; state: " . ( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) . "; lines: +2 -3\n";
my $commitmessage = $updater->commitmessage($revision->{commithash});
$commitmessage =~ s/^/M /mg;
@@ -1738,15 +1791,9 @@ sub req_annotate
argsfromdir($updater);
# we'll need a temporary checkout dir
- my $tmpdir = tempdir ( DIR => $TEMP_DIR );
- my ( undef, $file_index ) = tempfile ( DIR => $TEMP_DIR, OPEN => 0 );
- $log->info("Temp checkoutdir creation successful, basing annotate session work on '$tmpdir', index file is '$file_index'");
-
- $ENV{GIT_DIR} = $state->{CVSROOT} . "/";
- $ENV{GIT_WORK_TREE} = ".";
- $ENV{GIT_INDEX_FILE} = $file_index;
+ setupWorkTree();
- chdir $tmpdir;
+ $log->info("Temp checkoutdir creation successful, basing annotate session work on '$work->{workDir}', index file is '$ENV{GIT_INDEX_FILE}'");
# foreach file specified on the command line ...
foreach my $filename ( @{$state->{args}} )
@@ -1770,10 +1817,10 @@ sub req_annotate
system("git-read-tree", $lastseenin);
unless ($? == 0)
{
- print "E error running git-read-tree $lastseenin $file_index $!\n";
+ print "E error running git-read-tree $lastseenin $ENV{GIT_INDEX_FILE} $!\n";
return;
}
- $log->info("Created index '$file_index' with commit $lastseenin - exit status $?");
+ $log->info("Created index '$ENV{GIT_INDEX_FILE}' with commit $lastseenin - exit status $?");
# do a checkout of the file
system('git-checkout-index', '-f', '-u', $filename);
@@ -1789,7 +1836,7 @@ sub req_annotate
# git-jsannotate telling us about commits we are hiding
# from the client.
- my $a_hints = "$tmpdir/.annotate_hints";
+ my $a_hints = "$work->{workDir}/.annotate_hints";
if (!open(ANNOTATEHINTS, '>', $a_hints)) {
print "E failed to open '$a_hints' for writing: $!\n";
return;
@@ -1824,8 +1871,7 @@ sub req_annotate
unless ( defined ( $metadata->{$commithash} ) )
{
$metadata->{$commithash} = $updater->getmeta($filename, $commithash);
- $metadata->{$commithash}{author} =~ s/\s+.*//;
- $metadata->{$commithash}{author} =~ s/^(.{8}).*/$1/;
+ $metadata->{$commithash}{author} = cvs_author($metadata->{$commithash}{author});
$metadata->{$commithash}{modified} = sprintf("%02d-%s-%02d", $1, $2, $3) if ( $metadata->{$commithash}{modified} =~ /^(\d+)\s(\w+)\s\d\d(\d\d)/ );
}
printf("M 1.%-5d (%-8s %10s): %s\n",
@@ -1844,7 +1890,7 @@ sub req_annotate
}
# done; get out of the tempdir
- chdir "/";
+ cleanupWorkTree();
print "ok\n";
@@ -2005,14 +2051,17 @@ sub revparse
return undef;
}
-# This method takes a file hash and does a CVS "file transfer" which transmits the
-# size of the file, and then the file contents.
-# If a second argument $targetfile is given, the file is instead written out to
-# a file by the name of $targetfile
+# This method takes a file hash and does a CVS "file transfer". Its
+# exact behaviour depends on a second, optional hash table argument:
+# - If $options->{targetfile}, dump the contents to that file;
+# - If $options->{print}, use M/MT to transmit the contents one line
+# at a time;
+# - Otherwise, transmit the size of the file, followed by the file
+# contents.
sub transmitfile
{
my $filehash = shift;
- my $targetfile = shift;
+ my $options = shift;
if ( defined ( $filehash ) and $filehash eq "deleted" )
{
@@ -2034,11 +2083,20 @@ sub transmitfile
if ( open my $fh, '-|', "git-cat-file", "blob", $filehash )
{
- if ( defined ( $targetfile ) )
+ if ( defined ( $options->{targetfile} ) )
{
+ my $targetfile = $options->{targetfile};
open NEWFILE, ">", $targetfile or die("Couldn't open '$targetfile' for writing : $!");
print NEWFILE $_ while ( <$fh> );
close NEWFILE or die("Failed to write '$targetfile': $!");
+ } elsif ( defined ( $options->{print} ) && $options->{print} ) {
+ while ( <$fh> ) {
+ if( /\n\z/ ) {
+ print 'M ', $_;
+ } else {
+ print 'MT text ', $_, "\n";
+ }
+ }
} else {
print "$size\n";
print while ( <$fh> );
@@ -2085,28 +2143,400 @@ sub filecleanup
return $filename;
}
+sub validateGitDir
+{
+ if( !defined($state->{CVSROOT}) )
+ {
+ print "error 1 CVSROOT not specified\n";
+ cleanupWorkTree();
+ exit;
+ }
+ if( $ENV{GIT_DIR} ne ($state->{CVSROOT} . '/') )
+ {
+ print "error 1 Internally inconsistent CVSROOT\n";
+ cleanupWorkTree();
+ exit;
+ }
+}
+
+# Setup working directory in a work tree with the requested version
+# loaded in the index.
+sub setupWorkTree
+{
+ my ($ver) = @_;
+
+ validateGitDir();
+
+ if( ( defined($work->{state}) && $work->{state} != 1 ) ||
+ defined($work->{tmpDir}) )
+ {
+ $log->warn("Bad work tree state management");
+ print "error 1 Internal setup multiple work trees without cleanup\n";
+ cleanupWorkTree();
+ exit;
+ }
+
+ $work->{workDir} = tempdir ( DIR => $TEMP_DIR );
+
+ if( !defined($work->{index}) )
+ {
+ (undef, $work->{index}) = tempfile ( DIR => $TEMP_DIR, OPEN => 0 );
+ }
+
+ chdir $work->{workDir} or
+ die "Unable to chdir to $work->{workDir}\n";
+
+ $log->info("Setting up GIT_WORK_TREE as '.' in '$work->{workDir}', index file is '$work->{index}'");
+
+ $ENV{GIT_WORK_TREE} = ".";
+ $ENV{GIT_INDEX_FILE} = $work->{index};
+ $work->{state} = 2;
+
+ if($ver)
+ {
+ system("git","read-tree",$ver);
+ unless ($? == 0)
+ {
+ $log->warn("Error running git-read-tree");
+ die "Error running git-read-tree $ver in $work->{workDir} $!\n";
+ }
+ }
+ # else # req_annotate reads tree for each file
+}
+
+# Ensure current directory is in some kind of working directory,
+# with a recent version loaded in the index.
+sub ensureWorkTree
+{
+ if( defined($work->{tmpDir}) )
+ {
+ $log->warn("Bad work tree state management [ensureWorkTree()]");
+ print "error 1 Internal setup multiple dirs without cleanup\n";
+ cleanupWorkTree();
+ exit;
+ }
+ if( $work->{state} )
+ {
+ return;
+ }
+
+ validateGitDir();
+
+ if( !defined($work->{emptyDir}) )
+ {
+ $work->{emptyDir} = tempdir ( DIR => $TEMP_DIR, OPEN => 0);
+ }
+ chdir $work->{emptyDir} or
+ die "Unable to chdir to $work->{emptyDir}\n";
+
+ my $ver = `git show-ref -s refs/heads/$state->{module}`;
+ chomp $ver;
+ if ($ver !~ /^[0-9a-f]{40}$/)
+ {
+ $log->warn("Error from git show-ref -s refs/head$state->{module}");
+ print "error 1 cannot find the current HEAD of module";
+ cleanupWorkTree();
+ exit;
+ }
+
+ if( !defined($work->{index}) )
+ {
+ (undef, $work->{index}) = tempfile ( DIR => $TEMP_DIR, OPEN => 0 );
+ }
+
+ $ENV{GIT_WORK_TREE} = ".";
+ $ENV{GIT_INDEX_FILE} = $work->{index};
+ $work->{state} = 1;
+
+ system("git","read-tree",$ver);
+ unless ($? == 0)
+ {
+ die "Error running git-read-tree $ver $!\n";
+ }
+}
+
+# Cleanup working directory that is not needed any longer.
+sub cleanupWorkTree
+{
+ if( ! $work->{state} )
+ {
+ return;
+ }
+
+ chdir "/" or die "Unable to chdir '/'\n";
+
+ if( defined($work->{workDir}) )
+ {
+ rmtree( $work->{workDir} );
+ undef $work->{workDir};
+ }
+ undef $work->{state};
+}
+
+# Setup a temporary directory (not a working tree), typically for
+# merging dirty state as in req_update.
+sub setupTmpDir
+{
+ $work->{tmpDir} = tempdir ( DIR => $TEMP_DIR );
+ chdir $work->{tmpDir} or die "Unable to chdir $work->{tmpDir}\n";
+
+ return $work->{tmpDir};
+}
+
+# Clean up a previously setupTmpDir. Restore previous work tree if
+# appropriate.
+sub cleanupTmpDir
+{
+ if ( !defined($work->{tmpDir}) )
+ {
+ $log->warn("cleanup tmpdir that has not been setup");
+ die "Cleanup tmpDir that has not been setup\n";
+ }
+ if( defined($work->{state}) )
+ {
+ if( $work->{state} == 1 )
+ {
+ chdir $work->{emptyDir} or
+ die "Unable to chdir to $work->{emptyDir}\n";
+ }
+ elsif( $work->{state} == 2 )
+ {
+ chdir $work->{workDir} or
+ die "Unable to chdir to $work->{emptyDir}\n";
+ }
+ else
+ {
+ $log->warn("Inconsistent work dir state");
+ die "Inconsistent work dir state\n";
+ }
+ }
+ else
+ {
+ chdir "/" or die "Unable to chdir '/'\n";
+ }
+}
+
# Given a path, this function returns a string containing the kopts
# that should go into that path's Entries line. For example, a binary
# file should get -kb.
sub kopts_from_path
{
- my ($path) = @_;
+ my ($path, $srcType, $name) = @_;
- # Once it exists, the git attributes system should be used to look up
- # what attributes apply to this path.
+ if ( defined ( $cfg->{gitcvs}{usecrlfattr} ) and
+ $cfg->{gitcvs}{usecrlfattr} =~ /\s*(1|true|yes)\s*$/i )
+ {
+ my ($val) = check_attr( "crlf", $path );
+ if ( $val eq "set" )
+ {
+ return "";
+ }
+ elsif ( $val eq "unset" )
+ {
+ return "-kb"
+ }
+ else
+ {
+ $log->info("Unrecognized check_attr crlf $path : $val");
+ }
+ }
- # Until then, take the setting from the config file
- unless ( defined ( $cfg->{gitcvs}{allbinary} ) and $cfg->{gitcvs}{allbinary} =~ /^\s*(1|true|yes)\s*$/i )
+ if ( defined ( $cfg->{gitcvs}{allbinary} ) )
{
- # Return "" to give no special treatment to any path
- return "";
- } else {
- # Alternatively, to have all files treated as if they are binary (which
- # is more like git itself), always return the "-kb" option
- return "-kb";
+ if( ($cfg->{gitcvs}{allbinary} =~ /^\s*(1|true|yes)\s*$/i) )
+ {
+ return "-kb";
+ }
+ elsif( ($cfg->{gitcvs}{allbinary} =~ /^\s*guess\s*$/i) )
+ {
+ if( $srcType eq "sha1Or-k" &&
+ !defined($name) )
+ {
+ my ($ret)=$state->{entries}{$path}{options};
+ if( !defined($ret) )
+ {
+ $ret=$state->{opt}{k};
+ if(defined($ret))
+ {
+ $ret="-k$ret";
+ }
+ else
+ {
+ $ret="";
+ }
+ }
+ if( ! ($ret=~/^(|-kb|-kkv|-kkvl|-kk|-ko|-kv)$/) )
+ {
+ print "E Bad -k option\n";
+ $log->warn("Bad -k option: $ret");
+ die "Error: Bad -k option: $ret\n";
+ }
+
+ return $ret;
+ }
+ else
+ {
+ if( is_binary($srcType,$name) )
+ {
+ $log->debug("... as binary");
+ return "-kb";
+ }
+ else
+ {
+ $log->debug("... as text");
+ }
+ }
+ }
+ }
+ # Return "" to give no special treatment to any path
+ return "";
+}
+
+sub check_attr
+{
+ my ($attr,$path) = @_;
+ ensureWorkTree();
+ if ( open my $fh, '-|', "git", "check-attr", $attr, "--", $path )
+ {
+ my $val = <$fh>;
+ close $fh;
+ $val =~ s/.*: ([^:\r\n]*)\s*$/$1/;
+ return $val;
+ }
+ else
+ {
+ return undef;
}
}
+# This should have the same heuristics as convert.c:is_binary() and related.
+# Note that the bare CR test is done by callers in convert.c.
+sub is_binary
+{
+ my ($srcType,$name) = @_;
+ $log->debug("is_binary($srcType,$name)");
+
+ # Minimize amount of interpreted code run in the inner per-character
+ # loop for large files, by totalling each character value and
+ # then analyzing the totals.
+ my @counts;
+ my $i;
+ for($i=0;$i<256;$i++)
+ {
+ $counts[$i]=0;
+ }
+
+ my $fh = open_blob_or_die($srcType,$name);
+ my $line;
+ while( defined($line=<$fh>) )
+ {
+ # Any '\0' and bare CR are considered binary.
+ if( $line =~ /\0|(\r[^\n])/ )
+ {
+ close($fh);
+ return 1;
+ }
+
+ # Count up each character in the line:
+ my $len=length($line);
+ for($i=0;$i<$len;$i++)
+ {
+ $counts[ord(substr($line,$i,1))]++;
+ }
+ }
+ close $fh;
+
+ # Don't count CR and LF as either printable/nonprintable
+ $counts[ord("\n")]=0;
+ $counts[ord("\r")]=0;
+
+ # Categorize individual character count into printable and nonprintable:
+ my $printable=0;
+ my $nonprintable=0;
+ for($i=0;$i<256;$i++)
+ {
+ if( $i < 32 &&
+ $i != ord("\b") &&
+ $i != ord("\t") &&
+ $i != 033 && # ESC
+ $i != 014 ) # FF
+ {
+ $nonprintable+=$counts[$i];
+ }
+ elsif( $i==127 ) # DEL
+ {
+ $nonprintable+=$counts[$i];
+ }
+ else
+ {
+ $printable+=$counts[$i];
+ }
+ }
+
+ return ($printable >> 7) < $nonprintable;
+}
+
+# Returns open file handle. Possible invocations:
+# - open_blob_or_die("file",$filename);
+# - open_blob_or_die("sha1",$filehash);
+sub open_blob_or_die
+{
+ my ($srcType,$name) = @_;
+ my ($fh);
+ if( $srcType eq "file" )
+ {
+ if( !open $fh,"<",$name )
+ {
+ $log->warn("Unable to open file $name: $!");
+ die "Unable to open file $name: $!\n";
+ }
+ }
+ elsif( $srcType eq "sha1" || $srcType eq "sha1Or-k" )
+ {
+ unless ( defined ( $name ) and $name =~ /^[a-zA-Z0-9]{40}$/ )
+ {
+ $log->warn("Need filehash");
+ die "Need filehash\n";
+ }
+
+ my $type = `git cat-file -t $name`;
+ chomp $type;
+
+ unless ( defined ( $type ) and $type eq "blob" )
+ {
+ $log->warn("Invalid type '$type' for '$name'");
+ die ( "Invalid type '$type' (expected 'blob')" )
+ }
+
+ my $size = `git cat-file -s $name`;
+ chomp $size;
+
+ $log->debug("open_blob_or_die($name) size=$size, type=$type");
+
+ unless( open $fh, '-|', "git", "cat-file", "blob", $name )
+ {
+ $log->warn("Unable to open sha1 $name");
+ die "Unable to open sha1 $name\n";
+ }
+ }
+ else
+ {
+ $log->warn("Unknown type of blob source: $srcType");
+ die "Unknown type of blob source: $srcType\n";
+ }
+ return $fh;
+}
+
+# Generate a CVS author name from Git author information, by taking
+# the first eight characters of the user part of the email address.
+sub cvs_author
+{
+ my $author_line = shift;
+ (my $author) = $author_line =~ /<([^>@]{1,8})/;
+
+ $author;
+}
+
package GITCVS::log;
####
@@ -2311,6 +2741,14 @@ sub new
bless $self, $class;
+ $self->{valid_tables} = {'revision' => 1,
+ 'revision_ix1' => 1,
+ 'revision_ix2' => 1,
+ 'head' => 1,
+ 'head_ix1' => 1,
+ 'properties' => 1,
+ 'commitmsgs' => 1};
+
$self->{module} = $module;
$self->{git_path} = $config . "/";
@@ -2326,6 +2764,8 @@ sub new
$cfg->{gitcvs}{dbuser} || "";
$self->{dbpass} = $cfg->{gitcvs}{$state->{method}}{dbpass} ||
$cfg->{gitcvs}{dbpass} || "";
+ $self->{dbtablenameprefix} = $cfg->{gitcvs}{$state->{method}}{dbtablenameprefix} ||
+ $cfg->{gitcvs}{dbtablenameprefix} || "";
my %mapping = ( m => $module,
a => $state->{method},
u => getlogin || getpwuid($<) || $<,
@@ -2334,6 +2774,8 @@ sub new
);
$self->{dbname} =~ s/%([mauGg])/$mapping{$1}/eg;
$self->{dbuser} =~ s/%([mauGg])/$mapping{$1}/eg;
+ $self->{dbtablenameprefix} =~ s/%([mauGg])/$mapping{$1}/eg;
+ $self->{dbtablenameprefix} = mangle_tablename($self->{dbtablenameprefix});
die "Invalid char ':' in dbdriver" if $self->{dbdriver} =~ /:/;
die "Invalid char ';' in dbname" if $self->{dbname} =~ /;/;
@@ -2349,10 +2791,13 @@ sub new
}
# Construct the revision table if required
- unless ( $self->{tables}{revision} )
+ unless ( $self->{tables}{$self->tablename("revision")} )
{
+ my $tablename = $self->tablename("revision");
+ my $ix1name = $self->tablename("revision_ix1");
+ my $ix2name = $self->tablename("revision_ix2");
$self->{dbh}->do("
- CREATE TABLE revision (
+ CREATE TABLE $tablename (
name TEXT NOT NULL,
revision INTEGER NOT NULL,
filehash TEXT NOT NULL,
@@ -2363,20 +2808,22 @@ sub new
)
");
$self->{dbh}->do("
- CREATE INDEX revision_ix1
- ON revision (name,revision)
+ CREATE INDEX $ix1name
+ ON $tablename (name,revision)
");
$self->{dbh}->do("
- CREATE INDEX revision_ix2
- ON revision (name,commithash)
+ CREATE INDEX $ix2name
+ ON $tablename (name,commithash)
");
}
# Construct the head table if required
- unless ( $self->{tables}{head} )
+ unless ( $self->{tables}{$self->tablename("head")} )
{
+ my $tablename = $self->tablename("head");
+ my $ix1name = $self->tablename("head_ix1");
$self->{dbh}->do("
- CREATE TABLE head (
+ CREATE TABLE $tablename (
name TEXT NOT NULL,
revision INTEGER NOT NULL,
filehash TEXT NOT NULL,
@@ -2387,16 +2834,17 @@ sub new
)
");
$self->{dbh}->do("
- CREATE INDEX head_ix1
- ON head (name)
+ CREATE INDEX $ix1name
+ ON $tablename (name)
");
}
# Construct the properties table if required
- unless ( $self->{tables}{properties} )
+ unless ( $self->{tables}{$self->tablename("properties")} )
{
+ my $tablename = $self->tablename("properties");
$self->{dbh}->do("
- CREATE TABLE properties (
+ CREATE TABLE $tablename (
key TEXT NOT NULL PRIMARY KEY,
value TEXT
)
@@ -2404,10 +2852,11 @@ sub new
}
# Construct the commitmsgs table if required
- unless ( $self->{tables}{commitmsgs} )
+ unless ( $self->{tables}{$self->tablename("commitmsgs")} )
{
+ my $tablename = $self->tablename("commitmsgs");
$self->{dbh}->do("
- CREATE TABLE commitmsgs (
+ CREATE TABLE $tablename (
key TEXT NOT NULL PRIMARY KEY,
value TEXT
)
@@ -2417,6 +2866,21 @@ sub new
return $self;
}
+=head2 tablename
+
+=cut
+sub tablename
+{
+ my $self = shift;
+ my $name = shift;
+
+ if (exists $self->{valid_tables}{$name}) {
+ return $self->{dbtablenameprefix} . $name;
+ } else {
+ return undef;
+ }
+}
+
=head2 update
=cut
@@ -2543,13 +3007,20 @@ sub update
if ($parent eq $lastpicked) {
next;
}
- my $base = safe_pipe_capture('git-merge-base',
+ my $base = eval {
+ safe_pipe_capture('git-merge-base',
$lastpicked, $parent);
+ };
+ # The two branches may not be related at all,
+ # in which case merge base simply fails to find
+ # any, but that's Ok.
+ next if ($@);
+
chomp $base;
if ($base) {
my @merged;
# print "want to log between $base $parent \n";
- open(GITLOG, '-|', 'git-log', "$base..$parent")
+ open(GITLOG, '-|', 'git-log', '--pretty=medium', "$base..$parent")
or die "Cannot call git-log: $!";
my $mergedhash;
while (<GITLOG>) {
@@ -2626,7 +3097,7 @@ sub update
};
$self->insert_rev($name, $head->{$name}{revision}, $hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
}
- elsif ( $change eq "M" )
+ elsif ( $change eq "M" || $change eq "T" )
{
#$log->debug("MODIFIED $name");
$head->{$name} = {
@@ -2775,8 +3246,9 @@ sub insert_rev
my $modified = shift;
my $author = shift;
my $mode = shift;
+ my $tablename = $self->tablename("revision");
- my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
+ my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO $tablename (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
$insert_rev->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
}
@@ -2785,16 +3257,18 @@ sub insert_mergelog
my $self = shift;
my $key = shift;
my $value = shift;
+ my $tablename = $self->tablename("commitmsgs");
- my $insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO commitmsgs (key, value) VALUES (?,?)",{},1);
+ my $insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO $tablename (key, value) VALUES (?,?)",{},1);
$insert_mergelog->execute($key, $value);
}
sub delete_head
{
my $self = shift;
+ my $tablename = $self->tablename("head");
- my $delete_head = $self->{dbh}->prepare_cached("DELETE FROM head",{},1);
+ my $delete_head = $self->{dbh}->prepare_cached("DELETE FROM $tablename",{},1);
$delete_head->execute();
}
@@ -2808,8 +3282,9 @@ sub insert_head
my $modified = shift;
my $author = shift;
my $mode = shift;
+ my $tablename = $self->tablename("head");
- my $insert_head = $self->{dbh}->prepare_cached("INSERT INTO head (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
+ my $insert_head = $self->{dbh}->prepare_cached("INSERT INTO $tablename (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
$insert_head->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
}
@@ -2817,8 +3292,9 @@ sub _headrev
{
my $self = shift;
my $filename = shift;
+ my $tablename = $self->tablename("head");
- my $db_query = $self->{dbh}->prepare_cached("SELECT filehash, revision, mode FROM head WHERE name=?",{},1);
+ my $db_query = $self->{dbh}->prepare_cached("SELECT filehash, revision, mode FROM $tablename WHERE name=?",{},1);
$db_query->execute($filename);
my ( $hash, $revision, $mode ) = $db_query->fetchrow_array;
@@ -2829,8 +3305,9 @@ sub _get_prop
{
my $self = shift;
my $key = shift;
+ my $tablename = $self->tablename("properties");
- my $db_query = $self->{dbh}->prepare_cached("SELECT value FROM properties WHERE key=?",{},1);
+ my $db_query = $self->{dbh}->prepare_cached("SELECT value FROM $tablename WHERE key=?",{},1);
$db_query->execute($key);
my ( $value ) = $db_query->fetchrow_array;
@@ -2842,13 +3319,14 @@ sub _set_prop
my $self = shift;
my $key = shift;
my $value = shift;
+ my $tablename = $self->tablename("properties");
- my $db_query = $self->{dbh}->prepare_cached("UPDATE properties SET value=? WHERE key=?",{},1);
+ my $db_query = $self->{dbh}->prepare_cached("UPDATE $tablename SET value=? WHERE key=?",{},1);
$db_query->execute($value, $key);
unless ( $db_query->rows )
{
- $db_query = $self->{dbh}->prepare_cached("INSERT INTO properties (key, value) VALUES (?,?)",{},1);
+ $db_query = $self->{dbh}->prepare_cached("INSERT INTO $tablename (key, value) VALUES (?,?)",{},1);
$db_query->execute($key, $value);
}
@@ -2862,10 +3340,11 @@ sub _set_prop
sub gethead
{
my $self = shift;
+ my $tablename = $self->tablename("head");
return $self->{gethead_cache} if ( defined ( $self->{gethead_cache} ) );
- my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM head ORDER BY name ASC",{},1);
+ my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, mode, revision, modified, commithash, author FROM $tablename ORDER BY name ASC",{},1);
$db_query->execute();
my $tree = [];
@@ -2887,8 +3366,9 @@ sub getlog
{
my $self = shift;
my $filename = shift;
+ my $tablename = $self->tablename("revision");
- my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, author, mode, revision, modified, commithash FROM revision WHERE name=? ORDER BY revision DESC",{},1);
+ my $db_query = $self->{dbh}->prepare_cached("SELECT name, filehash, author, mode, revision, modified, commithash FROM $tablename WHERE name=? ORDER BY revision DESC",{},1);
$db_query->execute($filename);
my $tree = [];
@@ -2912,19 +3392,21 @@ sub getmeta
my $self = shift;
my $filename = shift;
my $revision = shift;
+ my $tablename_rev = $self->tablename("revision");
+ my $tablename_head = $self->tablename("head");
my $db_query;
if ( defined($revision) and $revision =~ /^\d+$/ )
{
- $db_query = $self->{dbh}->prepare_cached("SELECT * FROM revision WHERE name=? AND revision=?",{},1);
+ $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_rev WHERE name=? AND revision=?",{},1);
$db_query->execute($filename, $revision);
}
elsif ( defined($revision) and $revision =~ /^[a-zA-Z0-9]{40}$/ )
{
- $db_query = $self->{dbh}->prepare_cached("SELECT * FROM revision WHERE name=? AND commithash=?",{},1);
+ $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 head WHERE name=?",{},1);
+ $db_query = $self->{dbh}->prepare_cached("SELECT * FROM $tablename_head WHERE name=?",{},1);
$db_query->execute($filename);
}
@@ -2940,11 +3422,12 @@ sub commitmessage
{
my $self = shift;
my $commithash = shift;
+ my $tablename = $self->tablename("commitmsgs");
die("Need commithash") unless ( defined($commithash) and $commithash =~ /^[a-zA-Z0-9]{40}$/ );
my $db_query;
- $db_query = $self->{dbh}->prepare_cached("SELECT value FROM commitmsgs WHERE key=?",{},1);
+ $db_query = $self->{dbh}->prepare_cached("SELECT value FROM $tablename WHERE key=?",{},1);
$db_query->execute($commithash);
my ( $message ) = $db_query->fetchrow_array;
@@ -2972,9 +3455,10 @@ sub gethistory
{
my $self = shift;
my $filename = shift;
+ my $tablename = $self->tablename("revision");
my $db_query;
- $db_query = $self->{dbh}->prepare_cached("SELECT revision, filehash, commithash FROM revision WHERE name=? ORDER BY revision DESC",{},1);
+ $db_query = $self->{dbh}->prepare_cached("SELECT revision, filehash, commithash FROM $tablename WHERE name=? ORDER BY revision DESC",{},1);
$db_query->execute($filename);
return $db_query->fetchall_arrayref;
@@ -2994,9 +3478,10 @@ sub gethistorydense
{
my $self = shift;
my $filename = shift;
+ my $tablename = $self->tablename("revision");
my $db_query;
- $db_query = $self->{dbh}->prepare_cached("SELECT revision, filehash, commithash FROM revision WHERE name=? AND filehash!='deleted' ORDER BY revision DESC",{},1);
+ $db_query = $self->{dbh}->prepare_cached("SELECT revision, filehash, commithash FROM $tablename WHERE name=? AND filehash!='deleted' ORDER BY revision DESC",{},1);
$db_query->execute($filename);
return $db_query->fetchall_arrayref;
@@ -3054,4 +3539,19 @@ sub mangle_dirname {
return $dirname;
}
+=head2 mangle_tablename
+
+create a string from a that is suitable to use as part of an SQL table
+name, mainly by converting all chars except \w to _
+
+=cut
+sub mangle_tablename {
+ my $tablename = shift;
+ return unless defined $tablename;
+
+ $tablename =~ s/[^\w_]/_/g;
+
+ return $tablename;
+}
+
1;
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ebf05ca60..a324cf059 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -58,8 +58,8 @@ eval "$functions"
# "author" or "committer
set_ident () {
- lid="$(echo "$1" | tr "A-Z" "a-z")"
- uid="$(echo "$1" | tr "a-z" "A-Z")"
+ lid="$(echo "$1" | tr "[A-Z]" "[a-z]")"
+ uid="$(echo "$1" | tr "[a-z]" "[A-Z]")"
pick_id_script='
/^'$lid' /{
s/'\''/'\''\\'\'\''/g
@@ -97,9 +97,11 @@ USAGE="[--env-filter <command>] [--tree-filter <command>] \
OPTIONS_SPEC=
. git-sh-setup
-git diff-files --quiet &&
+if [ "$(is_bare_repository)" = false ]; then
+ git diff-files --quiet &&
git diff-index --cached --quiet HEAD -- ||
die "Cannot rewrite branch(es) with a dirty working directory."
+fi
tempdir=.git-rewrite
filter_env=
@@ -114,7 +116,6 @@ orig_namespace=refs/original/
force=
while :
do
- test $# = 0 && usage
case "$1" in
--)
shift
@@ -189,6 +190,9 @@ cd "$tempdir/t" &&
workdir="$(pwd)" ||
die ""
+# Remove tempdir on exit
+trap 'cd ../..; rm -rf "$tempdir"' 0
+
# Make sure refs/original is empty
git for-each-ref > "$tempdir"/backup-refs
while read sha1 type name
@@ -210,7 +214,7 @@ GIT_WORK_TREE=.
export GIT_DIR GIT_WORK_TREE
# The refs should be updated if their heads were rewritten
-git rev-parse --no-flags --revs-only --symbolic-full-name "$@" |
+git rev-parse --no-flags --revs-only --symbolic-full-name --default HEAD "$@" |
sed -e '/^^/d' >"$tempdir"/heads
test -s "$tempdir"/heads ||
@@ -232,7 +236,7 @@ case "$filter_subdir" in
;;
*)
git rev-list --reverse --topo-order --default HEAD \
- --parents --full-history "$@" -- "$filter_subdir"
+ --parents "$@" -- "$filter_subdir"
esac > ../revs || die "Could not get the commits"
commits=$(wc -l <../revs | tr -d " ")
@@ -250,7 +254,16 @@ while read commit parents; do
git read-tree -i -m $commit
;;
*)
- git read-tree -i -m $commit:"$filter_subdir"
+ # The commit may not have the subdirectory at all
+ err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
+ if ! git rev-parse --verify $commit:"$filter_subdir" 2>/dev/null
+ then
+ rm -f "$GIT_INDEX_FILE"
+ else
+ echo >&2 "$err"
+ false
+ fi
+ }
esac || die "Could not initialize the index"
GIT_COMMIT=$commit
@@ -270,14 +283,15 @@ while read commit parents; do
die "Could not checkout the index"
# files that $commit removed are now still in the working tree;
# remove them, else they would be added again
- git ls-files -z --others | xargs -0 rm -f
+ git clean -d -q -f -x
eval "$filter_tree" < /dev/null ||
die "tree filter failed: $filter_tree"
- git diff-index -r $commit | cut -f 2- | tr '\012' '\000' | \
- xargs -0 git update-index --add --replace --remove
- git ls-files -z --others | \
- xargs -0 git update-index --add --replace --remove
+ (
+ git diff-index -r --name-only $commit
+ git ls-files --others
+ ) |
+ git update-index --add --replace --remove --stdin
fi
eval "$filter_index" < /dev/null ||
@@ -297,7 +311,7 @@ while read commit parents; do
sed -e '1,/^$/d' <../commit | \
eval "$filter_msg" > ../message ||
die "msg filter failed: $filter_msg"
- sh -c "$filter_commit" "git commit-tree" \
+ @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
$(git write-tree) $parentstr < ../message > ../map/$commit
done <../revs
@@ -347,9 +361,17 @@ do
;;
$_x40)
echo "Ref '$ref' was rewritten"
- git update-ref -m "filter-branch: rewrite" \
- "$ref" $rewritten $sha1 ||
- die "Could not rewrite $ref"
+ if ! git update-ref -m "filter-branch: rewrite" \
+ "$ref" $rewritten $sha1 2>/dev/null; then
+ if test $(git cat-file -t "$ref") = tag; then
+ if test -z "$filter_tag_name"; then
+ warn "WARNING: You said to rewrite tagged commits, but not the corresponding tag."
+ warn "WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag."
+ fi
+ else
+ die "Could not rewrite $ref"
+ fi
+ fi
;;
*)
# NEEDSWORK: possibly add -Werror, making this an error
@@ -394,8 +416,22 @@ if [ "$filter_tag_name" ]; then
echo "$ref -> $new_ref ($sha1 -> $new_sha1)"
if [ "$type" = "tag" ]; then
- # Warn that we are not rewriting the tag object itself.
- warn "unreferencing tag object $sha1t"
+ new_sha1=$(git cat-file tag "$ref" |
+ sed -n \
+ -e "1,/^$/{
+ s/^object .*/object $new_sha1/
+ s/^type .*/type commit/
+ s/^tag .*/tag $new_ref/
+ }" \
+ -e '/^-----BEGIN PGP SIGNATURE-----/q' \
+ -e 'p' |
+ git mktag) ||
+ die "Could not create new tag object for $ref"
+ if git cat-file tag "$ref" | \
+ grep '^-----BEGIN PGP SIGNATURE-----' >/dev/null 2>&1
+ then
+ warn "gpg signature stripped from tag object $sha1t"
+ fi
fi
git update-ref "refs/tags/$new_ref" "$new_sha1" ||
@@ -406,12 +442,22 @@ fi
cd ../..
rm -rf "$tempdir"
-unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
-test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
-test -z "$ORIG_GIT_WORK_TREE" || GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
- export GIT_WORK_TREE
-test -z "$ORIG_GIT_INDEX_FILE" || GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
- export GIT_INDEX_FILE
-git read-tree -u -m HEAD
+trap - 0
+
+if [ "$(is_bare_repository)" = false ]; then
+ unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
+ test -z "$ORIG_GIT_DIR" || {
+ GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
+ }
+ test -z "$ORIG_GIT_WORK_TREE" || {
+ GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
+ export GIT_WORK_TREE
+ }
+ test -z "$ORIG_GIT_INDEX_FILE" || {
+ GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
+ export GIT_INDEX_FILE
+ }
+ git read-tree -u -m HEAD
+fi
exit $ret
diff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN
index cfe46a857..4e709ebe7 100755
--- a/git-gui/GIT-VERSION-GEN
+++ b/git-gui/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=0.9.GITGUI
+DEF_VER=0.11.GITGUI
LF='
'
diff --git a/git-gui/Makefile b/git-gui/Makefile
index 1baf4b086..55765c8a3 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -13,6 +13,7 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
SCRIPT_SH = git-gui.sh
GITGUI_MAIN := git-gui
@@ -33,8 +34,12 @@ ifndef gitexecdir
endif
ifndef sharedir
+ifeq (git-core,$(notdir $(gitexecdir)))
+ sharedir := $(dir $(patsubst %/,%,$(dir $(gitexecdir))))share
+else
sharedir := $(dir $(gitexecdir))share
endif
+endif
ifndef INSTALL
INSTALL = install
@@ -67,7 +72,7 @@ ifndef V
QUIET_GEN = $(QUIET)echo ' ' GEN '$@' &&
QUIET_INDEX = $(QUIET)echo ' ' INDEX $(dir $@) &&
QUIET_MSGFMT0 = $(QUIET)printf ' MSGFMT %12s ' $@ && v=`
- QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages//g'
+ QUIET_MSGFMT1 = 2>&1` && echo "$$v" | sed -e 's/fuzzy translations/fuzzy/' | sed -e 's/ messages*//g'
QUIET_2DEVNULL = 2>/dev/null
INSTALL_D0 = dir=
@@ -91,9 +96,20 @@ ifndef V
REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_RF) "$$dst"
endif
-TCL_PATH ?= tclsh
TCLTK_PATH ?= wish
-TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
+ifeq (./,$(dir $(TCLTK_PATH)))
+ TCL_PATH ?= $(subst wish,tclsh,$(TCLTK_PATH))
+else
+ TCL_PATH ?= $(dir $(TCLTK_PATH))$(notdir $(subst wish,tclsh,$(TCLTK_PATH)))
+endif
+
+ifeq ($(uname_S),Darwin)
+ TKFRAMEWORK = /Library/Frameworks/Tk.framework/Resources/Wish.app
+ ifeq ($(shell expr "$(uname_R)" : '9\.'),2)
+ TKFRAMEWORK = /System/Library/Frameworks/Tk.framework/Resources/Wish\ Shell.app
+ endif
+ TKEXECUTABLE = $(shell basename "$(TKFRAMEWORK)" .app)
+endif
ifeq ($(findstring $(MAKEFLAGS),s),s)
QUIET_GEN =
@@ -119,7 +135,17 @@ GITGUI_MACOSXAPP :=
ifeq ($(uname_O),Cygwin)
GITGUI_SCRIPT := `cygpath --windows --absolute "$(GITGUI_SCRIPT)"`
- gg_libdir_sed_in := $(shell cygpath --windows --absolute "$(gg_libdir)")
+
+ # Is this a Cygwin Tcl/Tk binary? If so it knows how to do
+ # POSIX path translation just like cygpath does and we must
+ # keep libdir in POSIX format so Cygwin packages of git-gui
+ # work no matter where the user installs them.
+ #
+ ifeq ($(shell echo 'puts [file normalize /]' | '$(TCL_PATH_SQ)'),$(shell cygpath --mixed --absolute /))
+ gg_libdir_sed_in := $(gg_libdir)
+ else
+ gg_libdir_sed_in := $(shell cygpath --windows --absolute "$(gg_libdir)")
+ endif
else
ifeq ($(exedir),$(gg_libdir))
GITGUI_RELATIVE := 1
@@ -134,6 +160,7 @@ endif
ifneq (,$(findstring MINGW,$(uname_S)))
NO_MSGFMT=1
GITGUI_WINDOWS_WRAPPER := YesPlease
+ GITGUI_RELATIVE := 1
endif
ifdef GITGUI_MACOSXAPP
@@ -147,7 +174,7 @@ git-gui: GIT-VERSION-FILE GIT-GUI-VARS
echo then >>$@+ && \
echo ' 'echo \'git-gui version '$(GITGUI_VERSION)'\' >>$@+ && \
echo else >>$@+ && \
- echo ' 'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/Wish'\' \
+ echo ' 'exec \''$(libdir_SQ)/Git Gui.app/Contents/MacOS/$(subst \,,$(TKEXECUTABLE))'\' \
'"$$0" "$$@"' >>$@+ && \
echo fi >>$@+ && \
chmod +x $@+ && \
@@ -157,14 +184,15 @@ Git\ Gui.app: GIT-VERSION-FILE GIT-GUI-VARS \
macosx/Info.plist \
macosx/git-gui.icns \
macosx/AppMain.tcl \
- $(TKFRAMEWORK)/Contents/MacOS/Wish
+ $(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)
$(QUIET_GEN)rm -rf '$@' '$@'+ && \
mkdir -p '$@'+/Contents/MacOS && \
mkdir -p '$@'+/Contents/Resources/Scripts && \
- cp '$(subst ','\'',$(TKFRAMEWORK))/Contents/MacOS/Wish' \
+ cp '$(subst ','\'',$(subst \,,$(TKFRAMEWORK)/Contents/MacOS/$(TKEXECUTABLE)))' \
'$@'+/Contents/MacOS && \
cp macosx/git-gui.icns '$@'+/Contents/Resources && \
sed -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
+ -e 's/@@GITGUI_TKEXECUTABLE@@/$(TKEXECUTABLE)/g' \
macosx/Info.plist \
>'$@'+/Contents/Info.plist && \
sed -e 's|@@gitexecdir@@|$(gitexecdir_SQ)|' \
@@ -198,6 +226,9 @@ ifdef NO_MSGFMT
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
else
MSGFMT ?= msgfmt
+ ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
+ MSGFMT := $(TCL_PATH) po/po2msg.sh
+ endif
endif
msgsdir = $(gg_libdir)/msgs
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index fcb2ab2fb..ad65aaad5 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -52,7 +52,11 @@ catch {rename send {}} ; # What an evil concept...
set oguilib {@@GITGUI_LIBDIR@@}
set oguirel {@@GITGUI_RELATIVE@@}
if {$oguirel eq {1}} {
- set oguilib [file dirname [file dirname [file normalize $argv0]]]
+ set oguilib [file dirname [file normalize $argv0]]
+ if {[file tail $oguilib] eq {git-core}} {
+ set oguilib [file dirname $oguilib]
+ }
+ set oguilib [file dirname $oguilib]
set oguilib [file join $oguilib share git-gui lib]
set oguimsg [file join $oguilib msgs]
} elseif {[string match @@* $oguirel]} {
@@ -122,6 +126,14 @@ set _reponame {}
set _iscygwin {}
set _search_path {}
+set _trace [lsearch -exact $argv --trace]
+if {$_trace >= 0} {
+ set argv [lreplace $argv $_trace $_trace]
+ set _trace 1
+} else {
+ set _trace 0
+}
+
proc appname {} {
global _appname
return $_appname
@@ -245,6 +257,21 @@ proc get_config {name} {
##
## handy utils
+proc _trace_exec {cmd} {
+ if {!$::_trace} return
+ set d {}
+ foreach v $cmd {
+ if {$d ne {}} {
+ append d { }
+ }
+ if {[regexp {[ \t\r\n'"$?*]} $v]} {
+ set v [sq $v]
+ }
+ append d $v
+ }
+ puts stderr $d
+}
+
proc _git_cmd {name} {
global _git_cmd_path
@@ -294,7 +321,7 @@ proc _git_cmd {name} {
return $v
}
-proc _which {what} {
+proc _which {what args} {
global env _search_exe _search_path
if {$_search_path eq {}} {
@@ -317,8 +344,14 @@ proc _which {what} {
}
}
+ if {[is_Windows] && [lsearch -exact $args -script] >= 0} {
+ set suffix {}
+ } else {
+ set suffix $_search_exe
+ }
+
foreach p $_search_path {
- set p [file join $p $what$_search_exe]
+ set p [file join $p $what$suffix]
if {[file exists $p]} {
return [file normalize $p]
}
@@ -339,7 +372,7 @@ proc _lappend_nice {cmd_var} {
}
proc git {args} {
- set opt [list exec]
+ set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -359,12 +392,18 @@ proc git {args} {
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
- return [eval $opt $cmdp $args]
+ _trace_exec [concat $opt $cmdp $args]
+ set result [eval exec $opt $cmdp $args]
+ if {$::_trace} {
+ puts stderr "< $result"
+ }
+ return $result
}
proc _open_stdout_stderr {cmd} {
+ _trace_exec $cmd
if {[catch {
- set fd [open $cmd r]
+ set fd [open [concat [list | ] $cmd] r]
} err]} {
if { [lindex $cmd end] eq {2>@1}
&& $err eq {can not find channel named "1"}
@@ -375,6 +414,7 @@ proc _open_stdout_stderr {cmd} {
# to try to start it a second time.
#
set fd [open [concat \
+ [list | ] \
[lrange $cmd 0 end-1] \
[list |& cat] \
] r]
@@ -387,7 +427,7 @@ proc _open_stdout_stderr {cmd} {
}
proc git_read {args} {
- set opt [list |]
+ set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -415,7 +455,7 @@ proc git_read {args} {
}
proc git_write {args} {
- set opt [list |]
+ set opt [list]
while {1} {
switch -- [lindex $args 0] {
@@ -435,7 +475,50 @@ proc git_write {args} {
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
- return [open [concat $opt $cmdp $args] w]
+ _trace_exec [concat $opt $cmdp $args]
+ return [open [concat [list | ] $opt $cmdp $args] w]
+}
+
+proc githook_read {hook_name args} {
+ set pchook [gitdir hooks $hook_name]
+ lappend args 2>@1
+
+ # On Windows [file executable] might lie so we need to ask
+ # the shell if the hook is executable. Yes that's annoying.
+ #
+ if {[is_Windows]} {
+ upvar #0 _sh interp
+ if {![info exists interp]} {
+ set interp [_which sh]
+ }
+ if {$interp eq {}} {
+ error "hook execution requires sh (not in PATH)"
+ }
+
+ set scr {if test -x "$1";then exec "$@";fi}
+ set sh_c [list $interp -c $scr $interp $pchook]
+ return [_open_stdout_stderr [concat $sh_c $args]]
+ }
+
+ if {[file executable $pchook]} {
+ return [_open_stdout_stderr [concat [list $pchook] $args]]
+ }
+
+ return {}
+}
+
+proc kill_file_process {fd} {
+ set process [pid $fd]
+
+ catch {
+ if {[is_Windows]} {
+ # Use a Cygwin-specific flag to allow killing
+ # native Windows processes
+ exec kill -f $process
+ } else {
+ exec kill $process
+ }
+ }
}
proc sq {value} {
@@ -573,6 +656,7 @@ proc apply_config {} {
}
}
+set default_config(branch.autosetupmerge) true
set default_config(merge.diffstat) true
set default_config(merge.summary) false
set default_config(merge.verbosity) 2
@@ -582,8 +666,12 @@ set default_config(user.email) {}
set default_config(gui.matchtrackingbranch) false
set default_config(gui.pruneduringfetch) false
set default_config(gui.trustmtime) false
+set default_config(gui.fastcopyblame) false
+set default_config(gui.copyblamethreshold) 40
set default_config(gui.diffcontext) 5
+set default_config(gui.commitmsgwidth) 75
set default_config(gui.newbranchtemplate) {}
+set default_config(gui.spellingdictionary) {}
set default_config(gui.fontui) [font configure font_ui]
set default_config(gui.fontdiff) [font configure font_diff]
set font_descs {
@@ -634,7 +722,7 @@ if {![regsub {^git version } $_git_version {} _git_version]} {
}
set _real_git_version $_git_version
-regsub -- {-dirty$} $_git_version {} _git_version
+regsub -- {[\-\.]dirty$} $_git_version {} _git_version
regsub {\.[0-9]+\.g[0-9a-f]+$} $_git_version {} _git_version
regsub {\.rc[0-9]+$} $_git_version {} _git_version
regsub {\.GIT$} $_git_version {} _git_version
@@ -1065,27 +1153,18 @@ proc rescan {after {honor_trustmtime 1}} {
}
if {[is_Cygwin]} {
- set is_git_info_link {}
set is_git_info_exclude {}
proc have_info_exclude {} {
- global is_git_info_link is_git_info_exclude
+ global is_git_info_exclude
- if {$is_git_info_link eq {}} {
- set is_git_info_link [file isfile [gitdir info.lnk]]
- }
-
- if {$is_git_info_link} {
- if {$is_git_info_exclude eq {}} {
- if {[catch {exec test -f [gitdir info exclude]}]} {
- set is_git_info_exclude 0
- } else {
- set is_git_info_exclude 1
- }
+ if {$is_git_info_exclude eq {}} {
+ if {[catch {exec test -f [gitdir info exclude]}]} {
+ set is_git_info_exclude 0
+ } else {
+ set is_git_info_exclude 1
}
- return $is_git_info_exclude
- } else {
- return [file readable [gitdir info exclude]]
}
+ return $is_git_info_exclude
}
} else {
proc have_info_exclude {} {
@@ -1617,10 +1696,10 @@ proc do_gitk {revs} {
# -- Always start gitk through whatever we were loaded with. This
# lets us bypass using shell process on Windows systems.
#
- set exe [file join [file dirname $::_git] gitk]
+ set exe [_which gitk -script]
set cmd [list [info nameofexecutable] $exe]
- if {! [file exists $exe]} {
- error_popup [mc "Unable to start gitk:\n\n%s does not exist" $exe]
+ if {$exe eq {}} {
+ error_popup [mc "Couldn't find gitk in PATH"]
} else {
global env
@@ -1655,6 +1734,7 @@ set is_quitting 0
proc do_quit {} {
global ui_comm is_quitting repo_config commit_type
global GITGUI_BCK_exists GITGUI_BCK_i
+ global ui_comm_spell
if {$is_quitting} return
set is_quitting 1
@@ -1682,6 +1762,12 @@ proc do_quit {} {
}
}
+ # -- Cancel our spellchecker if its running.
+ #
+ if {[info exists ui_comm_spell]} {
+ $ui_comm_spell stop
+ }
+
# -- Remove our editor backup, its not needed.
#
after cancel $GITGUI_BCK_i
@@ -1714,6 +1800,11 @@ proc do_commit {} {
commit_tree
}
+proc next_diff {} {
+ global next_diff_p next_diff_w next_diff_i
+ show_diff $next_diff_p $next_diff_w $next_diff_i
+}
+
proc toggle_or_diff {w x y} {
global file_states file_lists current_diff_path ui_index ui_workdir
global last_clicked selected_paths
@@ -1732,12 +1823,34 @@ proc toggle_or_diff {w x y} {
$ui_index tag remove in_sel 0.0 end
$ui_workdir tag remove in_sel 0.0 end
- if {$col == 0} {
- if {$current_diff_path eq $path} {
+ if {$col == 0 && $y > 1} {
+ set i [expr {$lno-1}]
+ set ll [expr {[llength $file_lists($w)]-1}]
+
+ if {$i == $ll && $i == 0} {
set after {reshow_diff;}
} else {
- set after {}
+ global next_diff_p next_diff_w next_diff_i
+
+ set next_diff_w $w
+
+ if {$i < $ll} {
+ set i [expr {$i + 1}]
+ set next_diff_i $i
+ } else {
+ set next_diff_i $i
+ set i [expr {$i - 1}]
+ }
+
+ set next_diff_p [lindex $file_lists($w) $i]
+
+ if {$next_diff_p ne {} && $current_diff_path ne {}} {
+ set after {next_diff;}
+ } else {
+ set after {}
+ }
}
+
if {$w eq $ui_index} {
update_indexinfo \
"Unstaging [short_path $path] from commit" \
@@ -1809,6 +1922,22 @@ proc add_range_to_selection {w x y} {
$w tag add in_sel $begin.0 [expr {$end + 1}].0
}
+proc show_more_context {} {
+ global repo_config
+ if {$repo_config(gui.diffcontext) < 99} {
+ incr repo_config(gui.diffcontext)
+ reshow_diff
+ }
+}
+
+proc show_less_context {} {
+ global repo_config
+ if {$repo_config(gui.diffcontext) >= 1} {
+ incr repo_config(gui.diffcontext) -1
+ reshow_diff
+ }
+}
+
######################################################################
##
## ui construction
@@ -1892,9 +2021,13 @@ if {[is_enabled multicommit]} {
}
}
-.mbar.repository add command -label [mc Quit] \
- -command do_quit \
- -accelerator $M1T-Q
+if {[is_MacOSX]} {
+ proc ::tk::mac::Quit {args} { do_quit }
+} else {
+ .mbar.repository add command -label [mc Quit] \
+ -command do_quit \
+ -accelerator $M1T-Q
+}
# -- Edit Menu
#
@@ -2009,6 +2142,16 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
.mbar.commit add separator
+ .mbar.commit add command -label [mc "Show Less Context"] \
+ -command show_less_context \
+ -accelerator $M1T-\-
+
+ .mbar.commit add command -label [mc "Show More Context"] \
+ -command show_more_context \
+ -accelerator $M1T-=
+
+ .mbar.commit add separator
+
.mbar.commit add command -label [mc "Sign Off"] \
-command do_signoff \
-accelerator $M1T-S
@@ -2052,7 +2195,7 @@ if {[is_enabled transport]} {
if {[is_MacOSX]} {
# -- Apple Menu (Mac OS X only)
#
- .mbar add cascade -label [mc Apple] -menu .mbar.apple
+ .mbar add cascade -label Apple -menu .mbar.apple
menu .mbar.apple
.mbar.apple add command -label [mc "About %s" [appname]] \
@@ -2253,8 +2396,9 @@ pack .vpane -anchor n -side top -fill both -expand 1
#
frame .vpane.files.index -height 100 -width 200
label .vpane.files.index.title -text [mc "Staged Changes (Will Commit)"] \
- -background lightgreen
-text $ui_index -background white -borderwidth 0 \
+ -background lightgreen -foreground black
+text $ui_index -background white -foreground black \
+ -borderwidth 0 \
-width 20 -height 10 \
-wrap none \
-cursor $cursor_ptr \
@@ -2272,8 +2416,9 @@ pack $ui_index -side left -fill both -expand 1
#
frame .vpane.files.workdir -height 100 -width 200
label .vpane.files.workdir.title -text [mc "Unstaged Changes"] \
- -background lightsalmon
-text $ui_workdir -background white -borderwidth 0 \
+ -background lightsalmon -foreground black
+text $ui_workdir -background white -foreground black \
+ -borderwidth 0 \
-width 20 -height 10 \
-wrap none \
-cursor $cursor_ptr \
@@ -2380,12 +2525,13 @@ pack $ui_coml -side left -fill x
pack .vpane.lower.commarea.buffer.header.amend -side right
pack .vpane.lower.commarea.buffer.header.new -side right
-text $ui_comm -background white -borderwidth 1 \
+text $ui_comm -background white -foreground black \
+ -borderwidth 1 \
-undo true \
-maxundo 20 \
-autoseparators true \
-relief sunken \
- -width 75 -height 9 -wrap none \
+ -width $repo_config(gui.commitmsgwidth) -height 9 -wrap none \
-font font_diff \
-yscrollcommand {.vpane.lower.commarea.buffer.sby set}
scrollbar .vpane.lower.commarea.buffer.sby \
@@ -2426,7 +2572,7 @@ $ctxm add separator
$ctxm add command \
-label [mc "Sign Off"] \
-command do_signoff
-bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
+set ui_comm_ctxm $ctxm
# -- Diff Header
#
@@ -2457,15 +2603,18 @@ trace add variable current_diff_path write trace_current_diff_path
frame .vpane.lower.diff.header -background gold
label .vpane.lower.diff.header.status \
-background gold \
+ -foreground black \
-width $max_status_desc \
-anchor w \
-justify left
label .vpane.lower.diff.header.file \
-background gold \
+ -foreground black \
-anchor w \
-justify left
label .vpane.lower.diff.header.path \
-background gold \
+ -foreground black \
-anchor w \
-justify left
pack .vpane.lower.diff.header.status -side left
@@ -2489,7 +2638,8 @@ bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
#
frame .vpane.lower.diff.body
set ui_diff .vpane.lower.diff.body.t
-text $ui_diff -background white -borderwidth 0 \
+text $ui_diff -background white -foreground black \
+ -borderwidth 0 \
-width 80 -height 15 -wrap none \
-font font_diff \
-xscrollcommand {.vpane.lower.diff.body.sbx set} \
@@ -2546,20 +2696,19 @@ $ctxm add command \
-command {apply_hunk $cursorX $cursorY}
set ui_diff_applyhunk [$ctxm index last]
lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
+$ctxm add command \
+ -label [mc "Apply/Reverse Line"] \
+ -command {apply_line $cursorX $cursorY; do_rescan}
+set ui_diff_applyline [$ctxm index last]
+lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
$ctxm add separator
$ctxm add command \
-label [mc "Show Less Context"] \
- -command {if {$repo_config(gui.diffcontext) >= 1} {
- incr repo_config(gui.diffcontext) -1
- reshow_diff
- }}
+ -command show_less_context
lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
$ctxm add command \
-label [mc "Show More Context"] \
- -command {if {$repo_config(gui.diffcontext) < 99} {
- incr repo_config(gui.diffcontext)
- reshow_diff
- }}
+ -command show_more_context
lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
$ctxm add separator
$ctxm add command \
@@ -2600,8 +2749,10 @@ proc popup_diff_menu {ctxm x y X Y} {
set ::cursorY $y
if {$::ui_index eq $::current_diff_side} {
set l [mc "Unstage Hunk From Commit"]
+ set t [mc "Unstage Line From Commit"]
} else {
set l [mc "Stage Hunk For Commit"]
+ set t [mc "Stage Line For Commit"]
}
if {$::is_3way_diff
|| $current_diff_path eq {}
@@ -2612,6 +2763,7 @@ proc popup_diff_menu {ctxm x y X Y} {
set s normal
}
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
+ $ctxm entryconf $::ui_diff_applyline -state $s -label $t
tk_popup $ctxm $X $Y
}
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]
@@ -2651,6 +2803,11 @@ bind $ui_comm <$M1B-Key-v> {tk_textPaste %W; %W see insert; break}
bind $ui_comm <$M1B-Key-V> {tk_textPaste %W; %W see insert; break}
bind $ui_comm <$M1B-Key-a> {%W tag add sel 0.0 end;break}
bind $ui_comm <$M1B-Key-A> {%W tag add sel 0.0 end;break}
+bind $ui_comm <$M1B-Key-minus> {show_less_context;break}
+bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break}
+bind $ui_comm <$M1B-Key-equal> {show_more_context;break}
+bind $ui_comm <$M1B-Key-plus> {show_more_context;break}
+bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break}
bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break}
bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
@@ -2694,6 +2851,11 @@ bind . <$M1B-Key-t> do_add_selection
bind . <$M1B-Key-T> do_add_selection
bind . <$M1B-Key-i> do_add_all
bind . <$M1B-Key-I> do_add_all
+bind . <$M1B-Key-minus> {show_less_context;break}
+bind . <$M1B-Key-KP_Subtract> {show_less_context;break}
+bind . <$M1B-Key-equal> {show_more_context;break}
+bind . <$M1B-Key-plus> {show_more_context;break}
+bind . <$M1B-Key-KP_Add> {show_more_context;break}
bind . <$M1B-Key-Return> do_commit
foreach i [list $ui_index $ui_workdir] {
bind $i <Button-1> "toggle_or_diff $i %x %y; break"
@@ -2773,6 +2935,7 @@ if {[is_enabled transport]} {
populate_fetch_menu
set n [expr {[.mbar.remote index end] - $n}]
if {$n > 0} {
+ if {[.mbar.remote type 0] eq "tearoff"} { incr n }
.mbar.remote insert $n separator
}
unset n
@@ -2829,6 +2992,30 @@ if {[winfo exists $ui_comm]} {
}
backup_commit_buffer
+
+ # -- If the user has aspell available we can drive it
+ # in pipe mode to spellcheck the commit message.
+ #
+ set spell_cmd [list |]
+ set spell_dict [get_config gui.spellingdictionary]
+ lappend spell_cmd aspell
+ if {$spell_dict ne {}} {
+ lappend spell_cmd --master=$spell_dict
+ }
+ lappend spell_cmd --mode=none
+ lappend spell_cmd --encoding=utf-8
+ lappend spell_cmd pipe
+ if {$spell_dict eq {none}
+ || [catch {set spell_fd [open $spell_cmd r+]} spell_err]} {
+ bind_button3 $ui_comm [list tk_popup $ui_comm_ctxm %X %Y]
+ } else {
+ set ui_comm_spell [spellcheck::init \
+ $spell_fd \
+ $ui_comm \
+ $ui_comm_ctxm \
+ ]
+ }
+ unset -nocomplain spell_cmd spell_fd spell_err spell_dict
}
lock_index begin-read
diff --git a/git-gui/lib/about.tcl b/git-gui/lib/about.tcl
index 719fc547b..241ab892c 100644
--- a/git-gui/lib/about.tcl
+++ b/git-gui/lib/about.tcl
@@ -4,6 +4,7 @@
proc do_about {} {
global appvers copyright oguilib
global tcl_patchLevel tk_patchLevel
+ global ui_comm_spell
set w .about_dialog
toplevel $w
@@ -40,6 +41,11 @@ proc do_about {} {
append v "Tcl version $tcl_patchLevel"
append v ", Tk version $tk_patchLevel"
}
+ if {[info exists ui_comm_spell]
+ && [$ui_comm_spell version] ne {}} {
+ append v "\n"
+ append v [$ui_comm_spell version]
+ }
set d {}
append d "git wrapper: $::_git\n"
diff --git a/git-gui/lib/blame.tcl b/git-gui/lib/blame.tcl
index 00ecf2133..b6e42cbc8 100644
--- a/git-gui/lib/blame.tcl
+++ b/git-gui/lib/blame.tcl
@@ -33,13 +33,6 @@ variable group_colors {
#ececec
}
-# Switches for original location detection
-#
-variable original_options [list -C -C]
-if {[git-version >= 1.5.3]} {
- lappend original_options -w ; # ignore indentation changes
-}
-
# Current blame data; cleared/reset on each load
#
field commit ; # input commit to blame
@@ -80,6 +73,7 @@ constructor new {i_commit i_path} {
label $w.header.commit_l \
-text [mc "Commit:"] \
-background gold \
+ -foreground black \
-anchor w \
-justify left
set w_back $w.header.commit_b
@@ -89,6 +83,7 @@ constructor new {i_commit i_path} {
-relief flat \
-state disabled \
-background gold \
+ -foreground black \
-activebackground gold
bind $w_back <Button-1> "
if {\[$w_back cget -state\] eq {normal}} {
@@ -98,16 +93,19 @@ constructor new {i_commit i_path} {
label $w.header.commit \
-textvariable @commit \
-background gold \
+ -foreground black \
-anchor w \
-justify left
label $w.header.path_l \
-text [mc "File:"] \
-background gold \
+ -foreground black \
-anchor w \
-justify left
set w_path $w.header.path
label $w_path \
-background gold \
+ -foreground black \
-anchor w \
-justify left
pack $w.header.commit_l -side left
@@ -135,7 +133,9 @@ constructor new {i_commit i_path} {
-takefocus 0 \
-highlightthickness 0 \
-padx 0 -pady 0 \
- -background white -borderwidth 0 \
+ -background white \
+ -foreground black \
+ -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
@@ -148,7 +148,9 @@ constructor new {i_commit i_path} {
-takefocus 0 \
-highlightthickness 0 \
-padx 0 -pady 0 \
- -background white -borderwidth 0 \
+ -background white \
+ -foreground black \
+ -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
@@ -166,7 +168,9 @@ constructor new {i_commit i_path} {
-takefocus 0 \
-highlightthickness 0 \
-padx 0 -pady 0 \
- -background white -borderwidth 0 \
+ -background white \
+ -foreground black \
+ -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
@@ -184,7 +188,9 @@ constructor new {i_commit i_path} {
-takefocus 0 \
-highlightthickness 0 \
-padx 0 -pady 0 \
- -background white -borderwidth 0 \
+ -background white \
+ -foreground black \
+ -borderwidth 0 \
-state disabled \
-wrap none \
-height 40 \
@@ -213,7 +219,9 @@ constructor new {i_commit i_path} {
set w_cviewer $w.file_pane.cm.t
text $w_cviewer \
- -background white -borderwidth 0 \
+ -background white \
+ -foreground black \
+ -borderwidth 0 \
-state disabled \
-wrap none \
-height 10 \
@@ -248,6 +256,9 @@ constructor new {i_commit i_path} {
$w.ctxm add command \
-label [mc "Copy Commit"] \
-command [cb _copycommit]
+ $w.ctxm add command \
+ -label [mc "Do Full Copy Detection"] \
+ -command [cb _fullcopyblame]
foreach i $w_columns {
for {set g 0} {$g < [llength $group_colors]} {incr g} {
@@ -318,19 +329,27 @@ constructor new {i_commit i_path} {
bind $w.file_pane <Configure> \
"if {{$w.file_pane} eq {%W}} {[cb _resize %h]}"
+ wm protocol $top WM_DELETE_WINDOW "destroy $top"
+ bind $top <Destroy> [cb _kill]
+
_load $this {}
}
+method _kill {} {
+ if {$current_fd ne {}} {
+ kill_file_process $current_fd
+ catch {close $current_fd}
+ set current_fd {}
+ }
+}
+
method _load {jump} {
variable group_colors
_hide_tooltip $this
if {$total_lines != 0 || $current_fd ne {}} {
- if {$current_fd ne {}} {
- catch {close $current_fd}
- set current_fd {}
- }
+ _kill $this
foreach i $w_columns {
$i conf -state normal
@@ -496,7 +515,6 @@ method _exec_blame {cur_w cur_d options cur_s} {
method _read_blame {fd cur_w cur_d} {
upvar #0 $cur_d line_data
variable group_colors
- variable original_options
if {$fd ne $current_fd} {
catch {close $fd}
@@ -669,6 +687,18 @@ method _read_blame {fd cur_w cur_d} {
if {[eof $fd]} {
close $fd
if {$cur_w eq $w_asim} {
+ # Switches for original location detection
+ set threshold [get_config gui.copyblamethreshold]
+ set original_options [list "-C$threshold"]
+
+ if {![is_config_true gui.fastcopyblame]} {
+ # thorough copy search; insert before the threshold
+ set original_options [linsert $original_options 0 -C]
+ }
+ if {[git-version >= 1.5.3]} {
+ lappend original_options -w ; # ignore indentation changes
+ }
+
_exec_blame $this $w_amov @amov_data \
$original_options \
[mc "Loading original location annotations..."]
@@ -681,6 +711,72 @@ method _read_blame {fd cur_w cur_d} {
}
} ifdeleted { catch {close $fd} }
+method _find_commit_bound {data_list start_idx delta} {
+ upvar #0 $data_list line_data
+ set pos $start_idx
+ set limit [expr {[llength $line_data] - 1}]
+ set base_commit [lindex $line_data $pos 0]
+
+ while {$pos > 0 && $pos < $limit} {
+ set new_pos [expr {$pos + $delta}]
+ if {[lindex $line_data $new_pos 0] ne $base_commit} {
+ return $pos
+ }
+
+ set pos $new_pos
+ }
+
+ return $pos
+}
+
+method _fullcopyblame {} {
+ if {$current_fd ne {}} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [mc "Busy"] \
+ -message [mc "Annotation process is already running."]
+
+ return
+ }
+
+ # Switches for original location detection
+ set threshold [get_config gui.copyblamethreshold]
+ set original_options [list -C -C "-C$threshold"]
+
+ if {[git-version >= 1.5.3]} {
+ lappend original_options -w ; # ignore indentation changes
+ }
+
+ # Find the line range
+ set pos @$::cursorX,$::cursorY
+ set lno [lindex [split [$::cursorW index $pos] .] 0]
+ set min_amov_lno [_find_commit_bound $this @amov_data $lno -1]
+ set max_amov_lno [_find_commit_bound $this @amov_data $lno 1]
+ set min_asim_lno [_find_commit_bound $this @asim_data $lno -1]
+ set max_asim_lno [_find_commit_bound $this @asim_data $lno 1]
+
+ if {$min_asim_lno < $min_amov_lno} {
+ set min_amov_lno $min_asim_lno
+ }
+
+ if {$max_asim_lno > $max_amov_lno} {
+ set max_amov_lno $max_asim_lno
+ }
+
+ lappend original_options -L "$min_amov_lno,$max_amov_lno"
+
+ # Clear lines
+ for {set i $min_amov_lno} {$i <= $max_amov_lno} {incr i} {
+ lset amov_data $i [list ]
+ }
+
+ # Start the back-end process
+ _exec_blame $this $w_amov @amov_data \
+ $original_options \
+ [mc "Running thorough copy detection..."]
+}
+
method _click {cur_w pos} {
set lno [lindex [split [$cur_w index $pos] .] 0]
_showcommit $this $cur_w $lno
diff --git a/git-gui/lib/branch_create.tcl b/git-gui/lib/branch_create.tcl
index 53dfb4ce6..3817771b9 100644
--- a/git-gui/lib/branch_create.tcl
+++ b/git-gui/lib/branch_create.tcl
@@ -183,6 +183,9 @@ method _create {} {
if {$spec ne {} && $opt_fetch} {
$co enable_fetch $spec
}
+ if {$spec ne {}} {
+ $co remote_source $spec
+ }
if {[$co run]} {
destroy $w
diff --git a/git-gui/lib/branch_delete.tcl b/git-gui/lib/branch_delete.tcl
index 86c4f7337..ef1930b49 100644
--- a/git-gui/lib/branch_delete.tcl
+++ b/git-gui/lib/branch_delete.tcl
@@ -127,7 +127,7 @@ method _delete {} {
foreach i $to_delete {
set b [lindex $i 0]
set o [lindex $i 1]
- if {[catch {git update-ref -d "refs/heads/$b" $o} err]} {
+ if {[catch {git branch -D $b} err]} {
append failed " - $b: $err\n"
}
}
diff --git a/git-gui/lib/browser.tcl b/git-gui/lib/browser.tcl
index 53d5a6281..ab470d126 100644
--- a/git-gui/lib/browser.tcl
+++ b/git-gui/lib/browser.tcl
@@ -39,7 +39,8 @@ constructor new {commit {path {}}} {
frame $w.list
set w_list $w.list.l
- text $w_list -background white -borderwidth 0 \
+ text $w_list -background white -foreground black \
+ -borderwidth 0 \
-cursor $cursor_ptr \
-state disabled \
-wrap none \
diff --git a/git-gui/lib/checkout_op.tcl b/git-gui/lib/checkout_op.tcl
index f24396692..caca88831 100644
--- a/git-gui/lib/checkout_op.tcl
+++ b/git-gui/lib/checkout_op.tcl
@@ -16,6 +16,7 @@ field merge_base {}; # merge base if we have another ref involved
field fetch_spec {}; # refetch tracking branch if used?
field checkout 1; # actually checkout the branch?
field create 0; # create the branch if it doesn't exist?
+field remote_source {}; # same as fetch_spec, to setup tracking
field reset_ok 0; # did the user agree to reset?
field fetch_ok 0; # did the fetch succeed?
@@ -44,6 +45,10 @@ method enable_fetch {spec} {
set fetch_spec $spec
}
+method remote_source {spec} {
+ set remote_source $spec
+}
+
method enable_checkout {co} {
set checkout $co
}
@@ -145,7 +150,7 @@ method _finish_fetch {ok} {
}
method _update_ref {} {
- global null_sha1 current_branch
+ global null_sha1 current_branch repo_config
set ref $new_ref
set new $new_hash
@@ -172,6 +177,23 @@ method _update_ref {} {
set reflog_msg "branch: Created from $new_expr"
set cur $null_sha1
+
+ if {($repo_config(branch.autosetupmerge) eq {true}
+ || $repo_config(branch.autosetupmerge) eq {always})
+ && $remote_source ne {}
+ && "refs/heads/$newbranch" eq $ref} {
+
+ set c_remote [lindex $remote_source 1]
+ set c_merge [lindex $remote_source 2]
+ if {[catch {
+ git config branch.$newbranch.remote $c_remote
+ git config branch.$newbranch.merge $c_merge
+ } err]} {
+ _error $this [strcat \
+ [mc "Failed to configure simplified git-pull for '%s'." $newbranch] \
+ "\n\n$err"]
+ }
+ }
} elseif {$create && $merge_type eq {none}} {
# We were told to create it, but not do a merge.
# Bad. Name shouldn't have existed.
@@ -280,7 +302,7 @@ The rescan will be automatically started now.
} elseif {[is_config_true gui.trustmtime]} {
_readtree $this
} else {
- ui_status {Refreshing file status...}
+ ui_status [mc "Refreshing file status..."]
set fd [git_read update-index \
-q \
--unmerged \
@@ -320,7 +342,7 @@ method _readtree {} {
set readtree_d {}
$::main_status start \
[mc "Updating working directory to '%s'..." [_name $this]] \
- {files checked out}
+ [mc "files checked out"]
set fd [git_read --stderr read-tree \
-m \
@@ -447,7 +469,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
} else {
repository_state commit_type HEAD MERGE_HEAD
set PARENT $HEAD
- ui_status "Checked out '$name'."
+ ui_status [mc "Checked out '%s'." $name]
}
delete_this
}
diff --git a/git-gui/lib/choose_font.tcl b/git-gui/lib/choose_font.tcl
index 0c4051b37..56443b042 100644
--- a/git-gui/lib/choose_font.tcl
+++ b/git-gui/lib/choose_font.tcl
@@ -55,6 +55,7 @@ constructor pick {path title a_family a_size} {
set w_family $w.inner.family.v
text $w_family \
-background white \
+ -foreground black \
-borderwidth 1 \
-relief sunken \
-cursor $::cursor_ptr \
@@ -92,6 +93,7 @@ constructor pick {path title a_family a_size} {
set w_example $w.example.t
text $w_example \
-background white \
+ -foreground black \
-borderwidth 1 \
-relief sunken \
-height 3 \
diff --git a/git-gui/lib/choose_repository.tcl b/git-gui/lib/choose_repository.tcl
index 86faf24cc..318078615 100644
--- a/git-gui/lib/choose_repository.tcl
+++ b/git-gui/lib/choose_repository.tcl
@@ -11,6 +11,7 @@ field w_quit ; # Quit button
field o_cons ; # Console object (if active)
field w_types ; # List of type buttons in clone
field w_recentlist ; # Listbox containing recent repositories
+field w_localpath ; # Entry widget bound to local_path
field done 0 ; # Finished picking the repository?
field local_path {} ; # Where this repository is locally
@@ -37,7 +38,7 @@ constructor pick {} {
menu $m_repo
if {[is_MacOSX]} {
- $w.mbar add cascade -label [mc Apple] -menu .mbar.apple
+ $w.mbar add cascade -label Apple -menu .mbar.apple
menu $w.mbar.apple
$w.mbar.apple add command \
-label [mc "About %s" [appname]] \
@@ -385,10 +386,9 @@ method _do_new {} {
button $w_body.where.b \
-text [mc "Browse"] \
-command [cb _new_local_path]
+ set w_localpath $w_body.where.t
- pack $w_body.where.b -side right
- pack $w_body.where.l -side left
- pack $w_body.where.t -fill x
+ grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x
trace add variable @local_path write [cb _write_local_path]
@@ -416,6 +416,7 @@ method _new_local_path {} {
return
}
set local_path $p
+ $w_localpath icursor end
}
method _do_new2 {} {
@@ -481,6 +482,7 @@ method _do_clone {} {
-text [mc "Browse"] \
-command [cb _new_local_path]
grid $args.where_l $args.where_t $args.where_b -sticky ew
+ set w_localpath $args.where_t
label $args.type_l -text [mc "Clone Type:"]
frame $args.type_f
@@ -983,9 +985,7 @@ method _do_open {} {
-text [mc "Browse"] \
-command [cb _open_local_path]
- pack $w_body.where.b -side right
- pack $w_body.where.l -side left
- pack $w_body.where.t -fill x
+ grid $w_body.where.l $w_body.where.t $w_body.where.b -sticky ew
pack $w_body.where -fill x
trace add variable @local_path write [cb _write_local_path]
diff --git a/git-gui/lib/choose_rev.tcl b/git-gui/lib/choose_rev.tcl
index a063c5bc4..c8821c146 100644
--- a/git-gui/lib/choose_rev.tcl
+++ b/git-gui/lib/choose_rev.tcl
@@ -451,7 +451,8 @@ method _sb_set {sb orient first last} {
focus $old_focus
}
}
- $sb set $first $last
+
+ catch {$sb set $first $last}
}
method _show_tooltip {pos} {
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index 1c0586c40..40a710355 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -192,45 +192,52 @@ A good commit message has the following format:
return
}
- # -- Run the pre-commit hook.
+ # -- Build the message file.
#
- set pchook [gitdir hooks pre-commit]
+ set msg_p [gitdir GITGUI_EDITMSG]
+ set msg_wt [open $msg_p w]
+ fconfigure $msg_wt -translation lf
+ if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
+ set enc utf-8
+ }
+ set use_enc [tcl_encoding $enc]
+ if {$use_enc ne {}} {
+ fconfigure $msg_wt -encoding $use_enc
+ } else {
+ puts stderr [mc "warning: Tcl does not support encoding '%s'." $enc]
+ fconfigure $msg_wt -encoding utf-8
+ }
+ puts $msg_wt $msg
+ close $msg_wt
- # On Cygwin [file executable] might lie so we need to ask
- # the shell if the hook is executable. Yes that's annoying.
+ # -- Run the pre-commit hook.
#
- if {[is_Cygwin] && [file isfile $pchook]} {
- set pchook [list sh -c [concat \
- "if test -x \"$pchook\";" \
- "then exec \"$pchook\" 2>&1;" \
- "fi"]]
- } elseif {[file executable $pchook]} {
- set pchook [list $pchook |& cat]
- } else {
- commit_writetree $curHEAD $msg
+ set fd_ph [githook_read pre-commit]
+ if {$fd_ph eq {}} {
+ commit_commitmsg $curHEAD $msg_p
return
}
- ui_status {Calling pre-commit hook...}
+ ui_status [mc "Calling pre-commit hook..."]
set pch_error {}
- set fd_ph [open "| $pchook" r]
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
fileevent $fd_ph readable \
- [list commit_prehook_wait $fd_ph $curHEAD $msg]
+ [list commit_prehook_wait $fd_ph $curHEAD $msg_p]
}
-proc commit_prehook_wait {fd_ph curHEAD msg} {
+proc commit_prehook_wait {fd_ph curHEAD msg_p} {
global pch_error
append pch_error [read $fd_ph]
fconfigure $fd_ph -blocking 1
if {[eof $fd_ph]} {
if {[catch {close $fd_ph}]} {
- ui_status {Commit declined by pre-commit hook.}
+ catch {file delete $msg_p}
+ ui_status [mc "Commit declined by pre-commit hook."]
hook_failed_popup pre-commit $pch_error
unlock_index
} else {
- commit_writetree $curHEAD $msg
+ commit_commitmsg $curHEAD $msg_p
}
set pch_error {}
return
@@ -238,14 +245,52 @@ proc commit_prehook_wait {fd_ph curHEAD msg} {
fconfigure $fd_ph -blocking 0
}
-proc commit_writetree {curHEAD msg} {
- ui_status {Committing changes...}
+proc commit_commitmsg {curHEAD msg_p} {
+ global pch_error
+
+ # -- Run the commit-msg hook.
+ #
+ set fd_ph [githook_read commit-msg $msg_p]
+ if {$fd_ph eq {}} {
+ commit_writetree $curHEAD $msg_p
+ return
+ }
+
+ ui_status [mc "Calling commit-msg hook..."]
+ set pch_error {}
+ fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+ fileevent $fd_ph readable \
+ [list commit_commitmsg_wait $fd_ph $curHEAD $msg_p]
+}
+
+proc commit_commitmsg_wait {fd_ph curHEAD msg_p} {
+ global pch_error
+
+ append pch_error [read $fd_ph]
+ fconfigure $fd_ph -blocking 1
+ if {[eof $fd_ph]} {
+ if {[catch {close $fd_ph}]} {
+ catch {file delete $msg_p}
+ ui_status [mc "Commit declined by commit-msg hook."]
+ hook_failed_popup commit-msg $pch_error
+ unlock_index
+ } else {
+ commit_writetree $curHEAD $msg_p
+ }
+ set pch_error {}
+ return
+ }
+ fconfigure $fd_ph -blocking 0
+}
+
+proc commit_writetree {curHEAD msg_p} {
+ ui_status [mc "Committing changes..."]
set fd_wt [git_read write-tree]
fileevent $fd_wt readable \
- [list commit_committree $fd_wt $curHEAD $msg]
+ [list commit_committree $fd_wt $curHEAD $msg_p]
}
-proc commit_committree {fd_wt curHEAD msg} {
+proc commit_committree {fd_wt curHEAD msg_p} {
global HEAD PARENT MERGE_HEAD commit_type
global current_branch
global ui_comm selected_commit_type
@@ -254,8 +299,9 @@ proc commit_committree {fd_wt curHEAD msg} {
gets $fd_wt tree_id
if {[catch {close $fd_wt} err]} {
+ catch {file delete $msg_p}
error_popup [strcat [mc "write-tree failed:"] "\n\n$err"]
- ui_status {Commit failed.}
+ ui_status [mc "Commit failed."]
unlock_index
return
}
@@ -276,6 +322,7 @@ proc commit_committree {fd_wt curHEAD msg} {
}
if {$tree_id eq $old_tree} {
+ catch {file delete $msg_p}
info_popup [mc "No changes to commit.
No files were modified by this commit and it was not a merge commit.
@@ -288,24 +335,6 @@ A rescan will be automatically started now.
}
}
- # -- Build the message.
- #
- set msg_p [gitdir COMMIT_EDITMSG]
- set msg_wt [open $msg_p w]
- fconfigure $msg_wt -translation lf
- if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
- set enc utf-8
- }
- set use_enc [tcl_encoding $enc]
- if {$use_enc ne {}} {
- fconfigure $msg_wt -encoding $use_enc
- } else {
- puts stderr [mc "warning: Tcl does not support encoding '%s'." $enc]
- fconfigure $msg_wt -encoding utf-8
- }
- puts $msg_wt $msg
- close $msg_wt
-
# -- Create the commit.
#
set cmd [list commit-tree $tree_id]
@@ -314,8 +343,9 @@ A rescan will be automatically started now.
}
lappend cmd <$msg_p
if {[catch {set cmt_id [eval git $cmd]} err]} {
+ catch {file delete $msg_p}
error_popup [strcat [mc "commit-tree failed:"] "\n\n$err"]
- ui_status {Commit failed.}
+ ui_status [mc "Commit failed."]
unlock_index
return
}
@@ -326,18 +356,16 @@ A rescan will be automatically started now.
if {$commit_type ne {normal}} {
append reflogm " ($commit_type)"
}
- set i [string first "\n" $msg]
- if {$i >= 0} {
- set subject [string range $msg 0 [expr {$i - 1}]]
- } else {
- set subject $msg
- }
+ set msg_fd [open $msg_p r]
+ gets $msg_fd subject
+ close $msg_fd
append reflogm {: } $subject
if {[catch {
git update-ref -m $reflogm HEAD $cmt_id $curHEAD
} err]} {
+ catch {file delete $msg_p}
error_popup [strcat [mc "update-ref failed:"] "\n\n$err"]
- ui_status {Commit failed.}
+ ui_status [mc "Commit failed."]
unlock_index
return
}
@@ -363,17 +391,13 @@ A rescan will be automatically started now.
# -- Run the post-commit hook.
#
- set pchook [gitdir hooks post-commit]
- if {[is_Cygwin] && [file isfile $pchook]} {
- set pchook [list sh -c [concat \
- "if test -x \"$pchook\";" \
- "then exec \"$pchook\";" \
- "fi"]]
- } elseif {![file executable $pchook]} {
- set pchook {}
- }
- if {$pchook ne {}} {
- catch {exec $pchook &}
+ set fd_ph [githook_read post-commit]
+ if {$fd_ph ne {}} {
+ upvar #0 pch_error$cmt_id pc_err
+ set pc_err {}
+ fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+ fileevent $fd_ph readable \
+ [list commit_postcommit_wait $fd_ph $cmt_id]
}
$ui_comm delete 0.0 end
@@ -429,3 +453,18 @@ A rescan will be automatically started now.
reshow_diff
ui_status [mc "Created commit %s: %s" [string range $cmt_id 0 7] $subject]
}
+
+proc commit_postcommit_wait {fd_ph cmt_id} {
+ upvar #0 pch_error$cmt_id pch_error
+
+ append pch_error [read $fd_ph]
+ fconfigure $fd_ph -blocking 1
+ if {[eof $fd_ph]} {
+ if {[catch {close $fd_ph}]} {
+ hook_failed_popup post-commit $pch_error 0
+ }
+ unset pch_error
+ return
+ }
+ fconfigure $fd_ph -blocking 0
+}
diff --git a/git-gui/lib/console.tcl b/git-gui/lib/console.tcl
index 5597188d8..c112464ec 100644
--- a/git-gui/lib/console.tcl
+++ b/git-gui/lib/console.tcl
@@ -46,7 +46,9 @@ method _init {} {
-justify left \
-font font_uibold
text $w_t \
- -background white -borderwidth 1 \
+ -background white \
+ -foreground black \
+ -borderwidth 1 \
-relief sunken \
-width 80 -height 10 \
-wrap none \
@@ -180,7 +182,8 @@ method done {ok} {
if {$ok} {
if {[winfo exists $w.m.s]} {
bind $w.m.s <Destroy> [list delete_this $this]
- $w.m.s conf -background green -text [mc "Success"]
+ $w.m.s conf -background green -foreground black \
+ -text [mc "Success"]
if {$is_toplevel} {
$w.ok conf -state normal
focus $w.ok
@@ -193,7 +196,8 @@ method done {ok} {
_init $this
}
bind $w.m.s <Destroy> [list delete_this $this]
- $w.m.s conf -background red -text [mc "Error: Command Failed"]
+ $w.m.s conf -background red -foreground black \
+ -text [mc "Error: Command Failed"]
if {$is_toplevel} {
$w.ok conf -state normal
focus $w.ok
diff --git a/git-gui/lib/database.tcl b/git-gui/lib/database.tcl
index d66aa3fe3..a18ac8b43 100644
--- a/git-gui/lib/database.tcl
+++ b/git-gui/lib/database.tcl
@@ -102,8 +102,8 @@ proc hint_gc {} {
*]]
if {$objects_current >= $object_limit} {
- set objects_current [expr {$objects_current * 256}]
- set object_limit [expr {$object_limit * 256}]
+ set objects_current [expr {$objects_current * 250}]
+ set object_limit [expr {$object_limit * 250}]
if {[ask_popup \
[mc "This repository currently has approximately %i loose objects.
diff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl
index d04f6dbde..52b79e4a1 100644
--- a/git-gui/lib/diff.tcl
+++ b/git-gui/lib/diff.tcl
@@ -19,6 +19,7 @@ proc clear_diff {} {
proc reshow_diff {} {
global file_states file_lists
global current_diff_path current_diff_side
+ global ui_diff
set p $current_diff_path
if {$p eq {}} {
@@ -28,7 +29,8 @@ proc reshow_diff {} {
|| [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
clear_diff
} else {
- show_diff $p $current_diff_side
+ set save_pos [lindex [$ui_diff yview] 0]
+ show_diff $p $current_diff_side {} $save_pos
}
}
@@ -52,7 +54,7 @@ A rescan will be automatically started to find other files which may have the sa
rescan ui_ready 0
}
-proc show_diff {path w {lno {}}} {
+proc show_diff {path w {lno {}} {scroll_pos {}}} {
global file_states file_lists
global is_3way_diff diff_active repo_config
global ui_diff ui_index ui_workdir
@@ -151,6 +153,10 @@ proc show_diff {path w {lno {}}} {
$ui_diff conf -state disabled
set diff_active 0
unlock_index
+ if {$scroll_pos ne {}} {
+ update
+ $ui_diff yview moveto $scroll_pos
+ }
ui_ready
return
}
@@ -190,10 +196,10 @@ proc show_diff {path w {lno {}}} {
-blocking 0 \
-encoding binary \
-translation binary
- fileevent $fd readable [list read_diff $fd]
+ fileevent $fd readable [list read_diff $fd $scroll_pos]
}
-proc read_diff {fd} {
+proc read_diff {fd scroll_pos} {
global ui_diff diff_active
global is_3way_diff current_diff_header
@@ -282,6 +288,10 @@ proc read_diff {fd} {
close $fd
set diff_active 0
unlock_index
+ if {$scroll_pos ne {}} {
+ update
+ $ui_diff yview moveto $scroll_pos
+ }
ui_ready
if {[$ui_diff index end] eq {2.0}} {
@@ -362,3 +372,148 @@ proc apply_hunk {x y} {
set current_diff_path $current_diff_path
}
}
+
+proc apply_line {x y} {
+ global current_diff_path current_diff_header current_diff_side
+ global ui_diff ui_index file_states
+
+ if {$current_diff_path eq {} || $current_diff_header eq {}} return
+ if {![lock_index apply_hunk]} return
+
+ set apply_cmd {apply --cached --whitespace=nowarn}
+ set mi [lindex $file_states($current_diff_path) 0]
+ if {$current_diff_side eq $ui_index} {
+ set failed_msg [mc "Failed to unstage selected line."]
+ set to_context {+}
+ lappend apply_cmd --reverse
+ if {[string index $mi 0] ne {M}} {
+ unlock_index
+ return
+ }
+ } else {
+ set failed_msg [mc "Failed to stage selected line."]
+ set to_context {-}
+ if {[string index $mi 1] ne {M}} {
+ unlock_index
+ return
+ }
+ }
+
+ set the_l [$ui_diff index @$x,$y]
+
+ # operate only on change lines
+ set c1 [$ui_diff get "$the_l linestart"]
+ if {$c1 ne {+} && $c1 ne {-}} {
+ unlock_index
+ return
+ }
+ set sign $c1
+
+ set i_l [$ui_diff search -backwards -regexp ^@@ $the_l 0.0]
+ if {$i_l eq {}} {
+ unlock_index
+ return
+ }
+ # $i_l is now at the beginning of a line
+
+ # pick start line number from hunk header
+ set hh [$ui_diff get $i_l "$i_l + 1 lines"]
+ set hh [lindex [split $hh ,] 0]
+ set hln [lindex [split $hh -] 1]
+
+ # There is a special situation to take care of. Consider this hunk:
+ #
+ # @@ -10,4 +10,4 @@
+ # context before
+ # -old 1
+ # -old 2
+ # +new 1
+ # +new 2
+ # context after
+ #
+ # We used to keep the context lines in the order they appear in the
+ # hunk. But then it is not possible to correctly stage only
+ # "-old 1" and "+new 1" - it would result in this staged text:
+ #
+ # context before
+ # old 2
+ # new 1
+ # context after
+ #
+ # (By symmetry it is not possible to *un*stage "old 2" and "new 2".)
+ #
+ # We resolve the problem by introducing an asymmetry, namely, when
+ # a "+" line is *staged*, it is moved in front of the context lines
+ # that are generated from the "-" lines that are immediately before
+ # the "+" block. That is, we construct this patch:
+ #
+ # @@ -10,4 +10,5 @@
+ # context before
+ # +new 1
+ # old 1
+ # old 2
+ # context after
+ #
+ # But we do *not* treat "-" lines that are *un*staged in a special
+ # way.
+ #
+ # With this asymmetry it is possible to stage the change
+ # "old 1" -> "new 1" directly, and to stage the change
+ # "old 2" -> "new 2" by first staging the entire hunk and
+ # then unstaging the change "old 1" -> "new 1".
+
+ # This is non-empty if and only if we are _staging_ changes;
+ # then it accumulates the consecutive "-" lines (after converting
+ # them to context lines) in order to be moved after the "+" change
+ # line.
+ set pre_context {}
+
+ set n 0
+ set i_l [$ui_diff index "$i_l + 1 lines"]
+ set patch {}
+ while {[$ui_diff compare $i_l < "end - 1 chars"] &&
+ [$ui_diff get $i_l "$i_l + 2 chars"] ne {@@}} {
+ set next_l [$ui_diff index "$i_l + 1 lines"]
+ set c1 [$ui_diff get $i_l]
+ if {[$ui_diff compare $i_l <= $the_l] &&
+ [$ui_diff compare $the_l < $next_l]} {
+ # the line to stage/unstage
+ set ln [$ui_diff get $i_l $next_l]
+ if {$c1 eq {-}} {
+ set n [expr $n+1]
+ set patch "$patch$pre_context$ln"
+ } else {
+ set patch "$patch$ln$pre_context"
+ }
+ set pre_context {}
+ } elseif {$c1 ne {-} && $c1 ne {+}} {
+ # context line
+ set ln [$ui_diff get $i_l $next_l]
+ set patch "$patch$pre_context$ln"
+ set n [expr $n+1]
+ set pre_context {}
+ } elseif {$c1 eq $to_context} {
+ # turn change line into context line
+ set ln [$ui_diff get "$i_l + 1 chars" $next_l]
+ if {$c1 eq {-}} {
+ set pre_context "$pre_context $ln"
+ } else {
+ set patch "$patch $ln"
+ }
+ set n [expr $n+1]
+ }
+ set i_l $next_l
+ }
+ set patch "@@ -$hln,$n +$hln,[eval expr $n $sign 1] @@\n$patch"
+
+ if {[catch {
+ set p [eval git_write $apply_cmd]
+ fconfigure $p -translation binary -encoding binary
+ puts -nonewline $p $current_diff_header
+ puts -nonewline $p $patch
+ close $p} err]} {
+ error_popup [append $failed_msg "\n\n$err"]
+ }
+
+ unlock_index
+}
diff --git a/git-gui/lib/error.tcl b/git-gui/lib/error.tcl
index 13565b7ab..75650157e 100644
--- a/git-gui/lib/error.tcl
+++ b/git-gui/lib/error.tcl
@@ -1,6 +1,14 @@
# git-gui branch (create/delete) support
# Copyright (C) 2006, 2007 Shawn Pearce
+proc _error_parent {} {
+ set p [grab current .]
+ if {$p eq {}} {
+ return .
+ }
+ return $p
+}
+
proc error_popup {msg} {
set title [appname]
if {[reponame] ne {}} {
@@ -11,8 +19,8 @@ proc error_popup {msg} {
-type ok \
-title [append "$title: " [mc "error"]] \
-message $msg]
- if {[winfo ismapped .]} {
- lappend cmd -parent .
+ if {[winfo ismapped [_error_parent]]} {
+ lappend cmd -parent [_error_parent]
}
eval $cmd
}
@@ -27,19 +35,19 @@ proc warn_popup {msg} {
-type ok \
-title [append "$title: " [mc "warning"]] \
-message $msg]
- if {[winfo ismapped .]} {
- lappend cmd -parent .
+ if {[winfo ismapped [_error_parent]]} {
+ lappend cmd -parent [_error_parent]
}
eval $cmd
}
-proc info_popup {msg {parent .}} {
+proc info_popup {msg} {
set title [appname]
if {[reponame] ne {}} {
append title " ([reponame])"
}
tk_messageBox \
- -parent $parent \
+ -parent [_error_parent] \
-icon info \
-type ok \
-title $title \
@@ -56,13 +64,13 @@ proc ask_popup {msg} {
-type yesno \
-title $title \
-message $msg]
- if {[winfo ismapped .]} {
- lappend cmd -parent .
+ if {[winfo ismapped [_error_parent]]} {
+ lappend cmd -parent [_error_parent]
}
eval $cmd
}
-proc hook_failed_popup {hook msg} {
+proc hook_failed_popup {hook msg {is_fatal 1}} {
set w .hookfail
toplevel $w
@@ -72,19 +80,23 @@ proc hook_failed_popup {hook msg} {
-justify left \
-font font_uibold
text $w.m.t \
- -background white -borderwidth 1 \
+ -background white \
+ -foreground black \
+ -borderwidth 1 \
-relief sunken \
-width 80 -height 10 \
-font font_diff \
-yscrollcommand [list $w.m.sby set]
- label $w.m.l2 \
- -text [mc "You must correct the above errors before committing."] \
- -anchor w \
- -justify left \
- -font font_uibold
scrollbar $w.m.sby -command [list $w.m.t yview]
pack $w.m.l1 -side top -fill x
- pack $w.m.l2 -side bottom -fill x
+ if {$is_fatal} {
+ label $w.m.l2 \
+ -text [mc "You must correct the above errors before committing."] \
+ -anchor w \
+ -justify left \
+ -font font_uibold
+ pack $w.m.l2 -side bottom -fill x
+ }
pack $w.m.sby -side right -fill y
pack $w.m.t -side left -fill both -expand 1
pack $w.m -side top -fill both -expand 1 -padx 5 -pady 10
@@ -99,6 +111,6 @@ proc hook_failed_popup {hook msg} {
bind $w <Visibility> "grab $w; focus $w"
bind $w <Key-Return> "destroy $w"
- wm title $w [append "[appname] ([reponame]): " [mc "error"]]
+ wm title $w [strcat "[appname] ([reponame]): " [mc "error"]]
tkwait window $w
}
diff --git a/git-gui/lib/index.tcl b/git-gui/lib/index.tcl
index 30a244cc1..3c1fce747 100644
--- a/git-gui/lib/index.tcl
+++ b/git-gui/lib/index.tcl
@@ -310,7 +310,7 @@ proc add_helper {txt paths} {
update_index \
$txt \
$pathList \
- [concat $after {ui_status {Ready to commit.}}]
+ [concat $after {ui_status [mc "Ready to commit."]}]
}
}
diff --git a/git-gui/lib/merge.tcl b/git-gui/lib/merge.tcl
index 63e14279c..5c01875b0 100644
--- a/git-gui/lib/merge.tcl
+++ b/git-gui/lib/merge.tcl
@@ -116,8 +116,7 @@ method _start {} {
lappend cmd HEAD
lappend cmd $name
- set msg [mc "Merging %s and %s" $current_branch $stitle]
- ui_status "$msg..."
+ ui_status [mc "Merging %s and %s..." $current_branch $stitle]
set cons [console::new [mc "Merge"] "merge $stitle"]
console::exec $cons $cmd [cb _finish $cons]
@@ -236,7 +235,7 @@ Continue with resetting the current changes?"]
set fd [git_read --stderr read-tree --reset -u -v HEAD]
fconfigure $fd -blocking 0 -translation binary
fileevent $fd readable [namespace code [list _reset_wait $fd]]
- $::main_status start [mc "Aborting"] {files reset}
+ $::main_status start [mc "Aborting"] [mc "files reset"]
} else {
unlock_index
}
@@ -258,6 +257,7 @@ proc _reset_wait {fd} {
catch {file delete [gitdir MERGE_HEAD]}
catch {file delete [gitdir rr-cache MERGE_RR]}
+ catch {file delete [gitdir MERGE_RR]}
catch {file delete [gitdir SQUASH_MSG]}
catch {file delete [gitdir MERGE_MSG]}
catch {file delete [gitdir GITGUI_MSG]}
diff --git a/git-gui/lib/option.tcl b/git-gui/lib/option.tcl
index f812e5e89..ffb3f00ff 100644
--- a/git-gui/lib/option.tcl
+++ b/git-gui/lib/option.tcl
@@ -5,6 +5,7 @@ proc save_config {} {
global default_config font_descs
global repo_config global_config
global repo_config_new global_config_new
+ global ui_comm_spell
foreach option $font_descs {
set name [lindex $option 0]
@@ -52,11 +53,23 @@ proc save_config {} {
set repo_config($name) $value
}
}
+
+ if {[info exists repo_config(gui.spellingdictionary)]} {
+ set value $repo_config(gui.spellingdictionary)
+ if {$value eq {none}} {
+ if {[info exists ui_comm_spell]} {
+ $ui_comm_spell stop
+ }
+ } elseif {[info exists ui_comm_spell]} {
+ $ui_comm_spell lang $value
+ }
+ }
}
proc do_options {} {
global repo_config global_config font_descs
global repo_config_new global_config_new
+ global ui_comm_spell
array unset repo_config_new
array unset global_config_new
@@ -110,7 +123,10 @@ proc do_options {} {
{b gui.trustmtime {mc "Trust File Modification Timestamps"}}
{b gui.pruneduringfetch {mc "Prune Tracking Branches During Fetch"}}
{b gui.matchtrackingbranch {mc "Match Tracking Branches"}}
+ {b gui.fastcopyblame {mc "Blame Copy Only On Changed Files"}}
+ {i-20..200 gui.copyblamethreshold {mc "Minimum Letters To Blame Copy On"}}
{i-0..99 gui.diffcontext {mc "Number of Diff Context Lines"}}
+ {i-0..99 gui.commitmsgwidth {mc "Commit Message Text Width"}}
{t gui.newbranchtemplate {mc "New Branch Name Template"}}
} {
set type [lindex $option 0]
@@ -159,6 +175,32 @@ proc do_options {} {
}
}
+ set all_dicts [linsert \
+ [spellcheck::available_langs] \
+ 0 \
+ none]
+ incr optid
+ foreach f {repo global} {
+ if {![info exists ${f}_config_new(gui.spellingdictionary)]} {
+ if {[info exists ui_comm_spell]} {
+ set value [$ui_comm_spell lang]
+ } else {
+ set value none
+ }
+ set ${f}_config_new(gui.spellingdictionary) $value
+ }
+
+ frame $w.$f.$optid
+ label $w.$f.$optid.l -text [mc "Spelling Dictionary:"]
+ eval tk_optionMenu $w.$f.$optid.v \
+ ${f}_config_new(gui.spellingdictionary) \
+ $all_dicts
+ pack $w.$f.$optid.l -side left -anchor w -fill x
+ pack $w.$f.$optid.v -side right -anchor e -padx 5
+ pack $w.$f.$optid -side top -anchor w -fill x
+ }
+ unset all_dicts
+
set all_fonts [lsort [font families]]
foreach option $font_descs {
set name [lindex $option 0]
diff --git a/git-gui/lib/spellcheck.tcl b/git-gui/lib/spellcheck.tcl
new file mode 100644
index 000000000..78f344f08
--- /dev/null
+++ b/git-gui/lib/spellcheck.tcl
@@ -0,0 +1,414 @@
+# git-gui spellchecking support through ispell/aspell
+# Copyright (C) 2008 Shawn Pearce
+
+class spellcheck {
+
+field s_fd {} ; # pipe to ispell/aspell
+field s_version {} ; # ispell/aspell version string
+field s_lang {} ; # current language code
+field s_prog aspell; # are we actually old ispell?
+field s_failed 0 ; # is $s_prog bogus and not working?
+
+field w_text ; # text widget we are spelling
+field w_menu ; # context menu for the widget
+field s_menuidx 0 ; # last index of insertion into $w_menu
+
+field s_i {} ; # timer registration for _run callbacks
+field s_clear 0 ; # did we erase mispelled tags yet?
+field s_seen [list] ; # lines last seen from $w_text in _run
+field s_checked [list] ; # lines already checked
+field s_pending [list] ; # [$line $data] sent to ispell/aspell
+field s_suggest ; # array, list of suggestions, keyed by misspelling
+
+constructor init {pipe_fd ui_text ui_menu} {
+ set w_text $ui_text
+ set w_menu $ui_menu
+ array unset s_suggest
+
+ bind_button3 $w_text [cb _popup_suggest %X %Y @%x,%y]
+ _connect $this $pipe_fd
+ return $this
+}
+
+method _connect {pipe_fd} {
+ fconfigure $pipe_fd \
+ -encoding utf-8 \
+ -eofchar {} \
+ -translation lf
+
+ if {[gets $pipe_fd s_version] <= 0} {
+ if {[catch {close $pipe_fd} err]} {
+
+ # Eh? Is this actually ispell choking on aspell options?
+ #
+ if {$s_prog eq {aspell}
+ && [regexp -nocase {^Usage: } $err]
+ && ![catch {
+ set pipe_fd [open [list | $s_prog -v] r]
+ gets $pipe_fd s_version
+ close $pipe_fd
+ }]
+ && $s_version ne {}} {
+ if {{@(#) } eq [string range $s_version 0 4]} {
+ set s_version [string range $s_version 5 end]
+ }
+ set s_failed 1
+ error_popup [strcat \
+ [mc "Unsupported spell checker"] \
+ ":\n\n$s_version"]
+ set s_version {}
+ return
+ }
+
+ regsub -nocase {^Error: } $err {} err
+ if {$s_fd eq {}} {
+ error_popup [strcat [mc "Spell checking is unavailable"] ":\n\n$err"]
+ } else {
+ error_popup [strcat \
+ [mc "Invalid spell checking configuration"] \
+ ":\n\n$err\n\n" \
+ [mc "Reverting dictionary to %s." $s_lang]]
+ }
+ } else {
+ error_popup [mc "Spell checker silently failed on startup"]
+ }
+ return
+ }
+
+ if {{@(#) } ne [string range $s_version 0 4]} {
+ catch {close $pipe_fd}
+ error_popup [strcat [mc "Unrecognized spell checker"] ":\n\n$s_version"]
+ return
+ }
+ set s_version [string range $s_version 5 end]
+ regexp \
+ {International Ispell Version .* \(but really (Aspell .*?)\)$} \
+ $s_version _junk s_version
+ regexp {^Aspell (\d)+\.(\d+)} $s_version _junk major minor
+
+ puts $pipe_fd ! ; # enable terse mode
+
+ # fetch the language
+ if {$major > 0 || ($major == 0 && $minor >= 60)} {
+ puts $pipe_fd {$$cr master}
+ flush $pipe_fd
+ gets $pipe_fd s_lang
+ regexp {[/\\]([^/\\]+)\.[^\.]+$} $s_lang _ s_lang
+ } else {
+ set s_lang {}
+ }
+
+ if {$::default_config(gui.spellingdictionary) eq {}
+ && [get_config gui.spellingdictionary] eq {}} {
+ set ::default_config(gui.spellingdictionary) $s_lang
+ }
+
+ if {$s_fd ne {}} {
+ catch {close $s_fd}
+ }
+ set s_fd $pipe_fd
+
+ fconfigure $s_fd -blocking 0
+ fileevent $s_fd readable [cb _read]
+
+ $w_text tag conf misspelled \
+ -foreground red \
+ -underline 1
+
+ array unset s_suggest
+ set s_seen [list]
+ set s_checked [list]
+ set s_pending [list]
+ _run $this
+}
+
+method lang {{n {}}} {
+ if {$n ne {} && $s_lang ne $n && !$s_failed} {
+ set spell_cmd [list |]
+ lappend spell_cmd aspell
+ lappend spell_cmd --master=$n
+ lappend spell_cmd --mode=none
+ lappend spell_cmd --encoding=UTF-8
+ lappend spell_cmd pipe
+ _connect $this [open $spell_cmd r+]
+ }
+ return $s_lang
+}
+
+method version {} {
+ if {$s_version ne {}} {
+ return "$s_version, $s_lang"
+ }
+ return {}
+}
+
+method stop {} {
+ while {$s_menuidx > 0} {
+ $w_menu delete 0
+ incr s_menuidx -1
+ }
+ $w_text tag delete misspelled
+
+ catch {close $s_fd}
+ catch {after cancel $s_i}
+ set s_fd {}
+ set s_i {}
+ set s_lang {}
+}
+
+method _popup_suggest {X Y pos} {
+ while {$s_menuidx > 0} {
+ $w_menu delete 0
+ incr s_menuidx -1
+ }
+
+ set b_loc [$w_text index "$pos wordstart"]
+ set e_loc [_wordend $this $b_loc]
+ set orig [$w_text get $b_loc $e_loc]
+ set tags [$w_text tag names $b_loc]
+
+ if {[lsearch -exact $tags misspelled] >= 0} {
+ if {[info exists s_suggest($orig)]} {
+ set cnt 0
+ foreach s $s_suggest($orig) {
+ if {$cnt < 5} {
+ $w_menu insert $s_menuidx command \
+ -label $s \
+ -command [cb _replace $b_loc $e_loc $s]
+ incr s_menuidx
+ incr cnt
+ } else {
+ break
+ }
+ }
+ } else {
+ $w_menu insert $s_menuidx command \
+ -label [mc "No Suggestions"] \
+ -state disabled
+ incr s_menuidx
+ }
+ $w_menu insert $s_menuidx separator
+ incr s_menuidx
+ }
+
+ $w_text mark set saved-insert insert
+ tk_popup $w_menu $X $Y
+}
+
+method _replace {b_loc e_loc word} {
+ $w_text configure -autoseparators 0
+ $w_text edit separator
+
+ $w_text delete $b_loc $e_loc
+ $w_text insert $b_loc $word
+
+ $w_text edit separator
+ $w_text configure -autoseparators 1
+ $w_text mark set insert saved-insert
+}
+
+method _restart_timer {} {
+ set s_i [after 300 [cb _run]]
+}
+
+proc _match_length {max_line arr_name} {
+ upvar $arr_name a
+
+ if {[llength $a] > $max_line} {
+ set a [lrange $a 0 $max_line]
+ }
+ while {[llength $a] <= $max_line} {
+ lappend a {}
+ }
+}
+
+method _wordend {pos} {
+ set pos [$w_text index "$pos wordend"]
+ set tags [$w_text tag names $pos]
+ while {[lsearch -exact $tags misspelled] >= 0} {
+ set pos [$w_text index "$pos +1c"]
+ set tags [$w_text tag names $pos]
+ }
+ return $pos
+}
+
+method _run {} {
+ set cur_pos [$w_text index {insert -1c}]
+ set cur_line [lindex [split $cur_pos .] 0]
+ set max_line [lindex [split [$w_text index end] .] 0]
+ _match_length $max_line s_seen
+ _match_length $max_line s_checked
+
+ # Nothing in the message buffer? Nothing to spellcheck.
+ #
+ if {$cur_line == 1
+ && $max_line == 2
+ && [$w_text get 1.0 end] eq "\n"} {
+ array unset s_suggest
+ _restart_timer $this
+ return
+ }
+
+ set active 0
+ for {set n 1} {$n <= $max_line} {incr n} {
+ set s [$w_text get "$n.0" "$n.end"]
+
+ # Don't spellcheck the current line unless we are at
+ # a word boundary. The user might be typing on it.
+ #
+ if {$n == $cur_line
+ && ![regexp {^\W$} [$w_text get $cur_pos insert]]} {
+
+ # If the current word is mispelled remove the tag
+ # but force a spellcheck later.
+ #
+ set tags [$w_text tag names $cur_pos]
+ if {[lsearch -exact $tags misspelled] >= 0} {
+ $w_text tag remove misspelled \
+ "$cur_pos wordstart" \
+ [_wordend $this $cur_pos]
+ lset s_seen $n $s
+ lset s_checked $n {}
+ }
+
+ continue
+ }
+
+ if {[lindex $s_seen $n] eq $s
+ && [lindex $s_checked $n] ne $s} {
+ # Don't send empty lines to Aspell it doesn't check them.
+ #
+ if {$s eq {}} {
+ lset s_checked $n $s
+ continue
+ }
+
+ # Don't send typical s-b-o lines as the emails are
+ # almost always misspelled according to Aspell.
+ #
+ if {[regexp -nocase {^[a-z-]+-by:.*<.*@.*>$} $s]} {
+ $w_text tag remove misspelled "$n.0" "$n.end"
+ lset s_checked $n $s
+ continue
+ }
+
+ puts $s_fd ^$s
+ lappend s_pending [list $n $s]
+ set active 1
+ } else {
+ # Delay until another idle loop to make sure we don't
+ # spellcheck lines the user is actively changing.
+ #
+ lset s_seen $n $s
+ }
+ }
+
+ if {$active} {
+ set s_clear 1
+ flush $s_fd
+ } else {
+ _restart_timer $this
+ }
+}
+
+method _read {} {
+ while {[gets $s_fd line] >= 0} {
+ set lineno [lindex $s_pending 0 0]
+
+ if {$s_clear} {
+ $w_text tag remove misspelled "$lineno.0" "$lineno.end"
+ set s_clear 0
+ }
+
+ if {$line eq {}} {
+ lset s_checked $lineno [lindex $s_pending 0 1]
+ set s_pending [lrange $s_pending 1 end]
+ set s_clear 1
+ continue
+ }
+
+ set sugg [list]
+ switch -- [string range $line 0 1] {
+ {& } {
+ set line [split [string range $line 2 end] :]
+ set info [split [lindex $line 0] { }]
+ set orig [lindex $info 0]
+ set offs [lindex $info 2]
+ foreach s [split [lindex $line 1] ,] {
+ lappend sugg [string range $s 1 end]
+ }
+ }
+ {# } {
+ set info [split [string range $line 2 end] { }]
+ set orig [lindex $info 0]
+ set offs [lindex $info 1]
+ }
+ default {
+ puts stderr "<spell> $line"
+ continue
+ }
+ }
+
+ incr offs -1
+ set b_loc "$lineno.$offs"
+ set e_loc [$w_text index "$lineno.$offs wordend"]
+ set curr [$w_text get $b_loc $e_loc]
+
+ # At least for English curr = "bob", orig = "bob's"
+ # so Tk didn't include the 's but Aspell did. We
+ # try to round out the word.
+ #
+ while {$curr ne $orig
+ && [string equal -length [string length $curr] $curr $orig]} {
+ set n_loc [$w_text index "$e_loc +1c"]
+ set n_curr [$w_text get $b_loc $n_loc]
+ if {$n_curr eq $curr} {
+ break
+ }
+ set curr $n_curr
+ set e_loc $n_loc
+ }
+
+ if {$curr eq $orig} {
+ $w_text tag add misspelled $b_loc $e_loc
+ if {[llength $sugg] > 0} {
+ set s_suggest($orig) $sugg
+ } else {
+ unset -nocomplain s_suggest($orig)
+ }
+ } else {
+ unset -nocomplain s_suggest($orig)
+ }
+ }
+
+ fconfigure $s_fd -block 1
+ if {[eof $s_fd]} {
+ if {![catch {close $s_fd} err]} {
+ set err [mc "Unexpected EOF from spell checker"]
+ }
+ catch {after cancel $s_i}
+ $w_text tag remove misspelled 1.0 end
+ error_popup [strcat [mc "Spell Checker Failed"] "\n\n" $err]
+ return
+ }
+ fconfigure $s_fd -block 0
+
+ if {[llength $s_pending] == 0} {
+ _restart_timer $this
+ }
+}
+
+proc available_langs {} {
+ set langs [list]
+ catch {
+ set fd [open [list | aspell dump dicts] r]
+ while {[gets $fd line] >= 0} {
+ if {$line eq {}} continue
+ lappend langs $line
+ }
+ close $fd
+ }
+ return $langs
+}
+
+}
diff --git a/git-gui/macosx/AppMain.tcl b/git-gui/macosx/AppMain.tcl
index 41ca08e2b..ddbe6334a 100644
--- a/git-gui/macosx/AppMain.tcl
+++ b/git-gui/macosx/AppMain.tcl
@@ -7,7 +7,7 @@ if {[string first -psn [lindex $argv 0]] == 0} {
}
if {[file tail [lindex $argv 0]] eq {gitk}} {
- set argv0 [file join $gitexecdir gitk]
+ set argv0 [lindex $argv 0]
set AppMain_source $argv0
} else {
set argv0 [file join $gitexecdir [file tail [lindex $argv 0]]]
diff --git a/git-gui/macosx/Info.plist b/git-gui/macosx/Info.plist
index 99913ec57..b3bf15fa1 100644
--- a/git-gui/macosx/Info.plist
+++ b/git-gui/macosx/Info.plist
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
- <string>Wish</string>
+ <string>@@GITGUI_TKEXECUTABLE@@</string>
<key>CFBundleGetInfoString</key>
<string>Git Gui @@GITGUI_VERSION@@ © 2006-2007 Shawn Pearce, et. al.</string>
<key>CFBundleIconFile</key>
diff --git a/git-gui/po/README b/git-gui/po/README
index 9d8b7364f..595bbf5de 100644
--- a/git-gui/po/README
+++ b/git-gui/po/README
@@ -101,7 +101,7 @@ matching msgid lines. A few tips:
"printf()"-like functions. Make sure "%s", "%d", and "%%" in your
translated messages match the original.
- When you have to change the order of words, you can add "<number>\$"
+ When you have to change the order of words, you can add "<number>$"
between '%' and the conversion ('s', 'd', etc.) to say "<number>-th
parameter to the format string is used at this point". For example,
if the original message is like this:
@@ -111,12 +111,17 @@ matching msgid lines. A few tips:
and if for whatever reason your translation needs to say weight first
and then length, you can say something like:
- "WEIGHT IS %2\$d, LENGTH IS %1\$d"
+ "WEIGHT IS %2$d, LENGTH IS %1$d"
- The reason you need a backslash before dollar sign is because
- this is a double quoted string in Tcl language, and without
- it the letter introduces a variable interpolation, which you
- do not want here.
+ A format specification with a '*' (asterisk) refers to *two* arguments
+ instead of one, hence the succeeding argument number is two higher
+ instead of one. So, a message like this
+
+ "%s ... %*i of %*i %s (%3i%%)"
+
+ is equivalent to
+
+ "%1$s ... %2$*i of %4$*i %6$s (%7$3i%%)"
- A long message can be split across multiple lines by ending the
string with a double quote, and starting another string on the next
@@ -178,18 +183,6 @@ step.
$ msgmerge -U po/af.po po/git-gui.pot
-[NEEDSWORK: who is responsible for updating po/git-gui.pot file by
-running xgettext? IIRC, Christian recommended against running it
-nilly-willy because it can become a source of unnecessary merge
-conflicts. Perhaps we should mention something like "
-
-The po/git-gui.pot file is updated by the internationalization
-coordinator from time to time. You _could_ update it yourself, but
-translators are discouraged from doing so because we would want all
-language teams to be working off of the same version of git-gui.pot.
-
-" here?]
-
This updates po/af.po (again, replace "af" with your language
code) so that it contains msgid lines (i.e. the original) that
your translation did not have before. There are a few things to
@@ -207,3 +200,53 @@ watch out for:
- New messages added to the software will have msgstr lines with empty
strings. You would need to translate them.
+
+The po/git-gui.pot file is updated by the internationalization
+coordinator from time to time. You _could_ update it yourself, but
+translators are discouraged from doing so because we would want all
+language teams to be working off of the same version of git-gui.pot.
+
+****************************************************************
+
+This section is a note to the internationalization coordinator, and
+translators do not have to worry about it too much.
+
+The message template file po/git-gui.pot needs to be kept up to date
+relative to the software the translations apply to, and it is the
+responsibility of the internationalization coordinator.
+
+When updating po/git-gui.pot file, however, _never_ run "msgmerge -U
+po/xx.po" for individual language translations, unless you are absolutely
+sure that there is no outstanding work on translation for language xx.
+Doing so will create unnecessary merge conflicts and force needless
+re-translation on translators. The translator however may not have access
+to the msgmerge tool, in which case the coordinator may run it for the
+translator as a service.
+
+But mistakes do happen. Suppose a translation was based on an older
+version X, the POT file was updated at version Y and then msgmerge was run
+at version Z for the language, and the translator sent in a patch based on
+version X:
+
+ ? translated
+ /
+ ---X---Y---Z (master)
+
+The coordinator could recover from such a mistake by first applying the
+patch to X, replace the translated file in Z, and then running msgmerge
+again based on the updated POT file and commit the result. The sequence
+would look like this:
+
+ $ git checkout X
+ $ git am -s xx.patch
+ $ git checkout master
+ $ git checkout HEAD@{1} po/xx.po
+ $ msgmerge -U po/xx.po po/git-gui.pot
+ $ git commit -c HEAD@{1} po/xx.po
+
+State in the message that the translated messages are based on a slightly
+older version, and msgmerge was run to incorporate changes to message
+templates from the updated POT file. The result needs to be further
+translated, but at least the messages that were updated by the patch that
+were not changed by the POT update will survive the process and do not
+need to be re-translated.
diff --git a/git-gui/po/de.po b/git-gui/po/de.po
index 2dfe07e06..fa43947ad 100644
--- a/git-gui/po/de.po
+++ b/git-gui/po/de.po
@@ -7,41 +7,41 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2008-01-15 20:33+0100\n"
+"POT-Creation-Date: 2008-08-02 08:58+0200\n"
+"PO-Revision-Date: 2008-08-02 09:09+0200\n"
"Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:634 git-gui.sh:648 git-gui.sh:661 git-gui.sh:744
+#: git-gui.sh:763
msgid "git-gui: fatal error"
msgstr "git-gui: Programmfehler"
-#: git-gui.sh:565
+#: git-gui.sh:593
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Ungültige Zeichensatz-Angabe in %s:"
-#: git-gui.sh:590
+#: git-gui.sh:620
msgid "Main Font"
msgstr "Programmschriftart"
-#: git-gui.sh:591
+#: git-gui.sh:621
msgid "Diff/Console Font"
msgstr "Vergleich-Schriftart"
-#: git-gui.sh:605
+#: git-gui.sh:635
msgid "Cannot find git in PATH."
msgstr "Git kann im PATH nicht gefunden werden."
-#: git-gui.sh:632
+#: git-gui.sh:662
msgid "Cannot parse Git version string:"
msgstr "Git Versionsangabe kann nicht erkannt werden:"
-#: git-gui.sh:650
+#: git-gui.sh:680
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -60,380 +60,383 @@ msgstr ""
"\n"
"Soll angenommen werden, »%s« sei Version 1.5.0?\n"
-#: git-gui.sh:888
+#: git-gui.sh:918
msgid "Git directory not found:"
msgstr "Git-Verzeichnis nicht gefunden:"
-#: git-gui.sh:895
+#: git-gui.sh:925
msgid "Cannot move to top of working directory:"
msgstr ""
"Es konnte nicht in das oberste Verzeichnis der Arbeitskopie gewechselt "
"werden:"
-#: git-gui.sh:902
+#: git-gui.sh:932
msgid "Cannot use funny .git directory:"
msgstr "Unerwartete Struktur des .git Verzeichnis:"
-#: git-gui.sh:907
+#: git-gui.sh:937
msgid "No working directory"
msgstr "Kein Arbeitsverzeichnis"
-#: git-gui.sh:1054
+#: git-gui.sh:1084 lib/checkout_op.tcl:283
msgid "Refreshing file status..."
msgstr "Dateistatus aktualisieren..."
-#: git-gui.sh:1119
+#: git-gui.sh:1149
msgid "Scanning for modified files ..."
msgstr "Nach geänderten Dateien suchen..."
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1324 lib/browser.tcl:246
msgid "Ready."
msgstr "Bereit."
-#: git-gui.sh:1560
+#: git-gui.sh:1590
msgid "Unmodified"
msgstr "Unverändert"
-#: git-gui.sh:1562
+#: git-gui.sh:1592
msgid "Modified, not staged"
msgstr "Verändert, nicht bereitgestellt"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1593 git-gui.sh:1598
msgid "Staged for commit"
msgstr "Bereitgestellt zum Eintragen"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1594 git-gui.sh:1599
msgid "Portions staged for commit"
msgstr "Teilweise bereitgestellt zum Eintragen"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1595 git-gui.sh:1600
msgid "Staged for commit, missing"
msgstr "Bereitgestellt zum Eintragen, fehlend"
-#: git-gui.sh:1567
+#: git-gui.sh:1597
msgid "Untracked, not staged"
msgstr "Nicht unter Versionskontrolle, nicht bereitgestellt"
-#: git-gui.sh:1572
+#: git-gui.sh:1602
msgid "Missing"
msgstr "Fehlend"
-#: git-gui.sh:1573
+#: git-gui.sh:1603
msgid "Staged for removal"
msgstr "Bereitgestellt zum Löschen"
-#: git-gui.sh:1574
+#: git-gui.sh:1604
msgid "Staged for removal, still present"
msgstr "Bereitgestellt zum Löschen, trotzdem vorhanden"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1606 git-gui.sh:1607 git-gui.sh:1608 git-gui.sh:1609
msgid "Requires merge resolution"
msgstr "Konfliktauflösung nötig"
-#: git-gui.sh:1614
+#: git-gui.sh:1644
msgid "Starting gitk... please wait..."
msgstr "Gitk wird gestartet... bitte warten."
-#: git-gui.sh:1623
-#, tcl-format
-msgid ""
-"Unable to start gitk:\n"
-"\n"
-"%s does not exist"
-msgstr ""
-"Gitk kann nicht gestartet werden:\n"
-"\n"
-"%s existiert nicht"
+#: git-gui.sh:1698
+msgid "Couldn't find gitk in PATH"
+msgstr "Gitk kann im PATH nicht gefunden werden."
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1948 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Projektarchiv"
-#: git-gui.sh:1824
+#: git-gui.sh:1861
msgid "Edit"
msgstr "Bearbeiten"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1863 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Zweig"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1866 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "Version"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1869 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Zusammenführen"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1870 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Andere Archive"
-#: git-gui.sh:1842
+#: git-gui.sh:1879
msgid "Browse Current Branch's Files"
msgstr "Aktuellen Zweig durchblättern"
-#: git-gui.sh:1846
+#: git-gui.sh:1883
msgid "Browse Branch Files..."
msgstr "Einen Zweig durchblättern..."
-#: git-gui.sh:1851
+#: git-gui.sh:1888
msgid "Visualize Current Branch's History"
msgstr "Aktuellen Zweig darstellen"
-#: git-gui.sh:1855
+#: git-gui.sh:1892
msgid "Visualize All Branch History"
msgstr "Alle Zweige darstellen"
-#: git-gui.sh:1862
+#: git-gui.sh:1899
#, tcl-format
msgid "Browse %s's Files"
msgstr "Zweig »%s« durchblättern"
-#: git-gui.sh:1864
+#: git-gui.sh:1901
#, tcl-format
msgid "Visualize %s's History"
msgstr "Historie von »%s« darstellen"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1906 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "Datenbankstatistik"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1909 lib/database.tcl:34
msgid "Compress Database"
msgstr "Datenbank komprimieren"
-#: git-gui.sh:1875
+#: git-gui.sh:1912
msgid "Verify Database"
msgstr "Datenbank überprüfen"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:1919 git-gui.sh:1923 git-gui.sh:1927 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Desktop-Icon erstellen"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:1932 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Beenden"
-#: git-gui.sh:1902
+#: git-gui.sh:1939
msgid "Undo"
msgstr "Rückgängig"
-#: git-gui.sh:1905
+#: git-gui.sh:1942
msgid "Redo"
msgstr "Wiederholen"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:1946 git-gui.sh:2443
msgid "Cut"
msgstr "Ausschneiden"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:1949 git-gui.sh:2446 git-gui.sh:2520 git-gui.sh:2614
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Kopieren"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:1952 git-gui.sh:2449
msgid "Paste"
msgstr "Einfügen"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:1955 git-gui.sh:2452 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Löschen"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:1959 git-gui.sh:2456 git-gui.sh:2618 lib/console.tcl:71
msgid "Select All"
msgstr "Alle auswählen"
-#: git-gui.sh:1931
+#: git-gui.sh:1968
msgid "Create..."
msgstr "Erstellen..."
-#: git-gui.sh:1937
+#: git-gui.sh:1974
msgid "Checkout..."
msgstr "Umstellen..."
-#: git-gui.sh:1943
+#: git-gui.sh:1980
msgid "Rename..."
msgstr "Umbenennen..."
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:1985 git-gui.sh:2085
msgid "Delete..."
msgstr "Löschen..."
-#: git-gui.sh:1953
+#: git-gui.sh:1990
msgid "Reset..."
msgstr "Zurücksetzen..."
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2002 git-gui.sh:2389
msgid "New Commit"
msgstr "Neue Version"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2010 git-gui.sh:2396
msgid "Amend Last Commit"
msgstr "Letzte nachbessern"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2019 git-gui.sh:2356 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Neu laden"
-#: git-gui.sh:1988
+#: git-gui.sh:2025
msgid "Stage To Commit"
msgstr "Zum Eintragen bereitstellen"
-#: git-gui.sh:1994
+#: git-gui.sh:2031
msgid "Stage Changed Files To Commit"
msgstr "Geänderte Dateien bereitstellen"
-#: git-gui.sh:2000
+#: git-gui.sh:2037
msgid "Unstage From Commit"
msgstr "Aus der Bereitstellung herausnehmen"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2042 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Änderungen verwerfen"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2141 git-gui.sh:2702
+msgid "Show Less Context"
+msgstr "Weniger Zeilen anzeigen"
+
+#: git-gui.sh:2145 git-gui.sh:2706
+msgid "Show More Context"
+msgstr "Mehr Zeilen anzeigen"
+
+#: git-gui.sh:2151 git-gui.sh:2470 git-gui.sh:2569
msgid "Sign Off"
msgstr "Abzeichnen"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2053 git-gui.sh:2372
msgid "Commit@@verb"
msgstr "Eintragen"
-#: git-gui.sh:2027
+#: git-gui.sh:2064
msgid "Local Merge..."
msgstr "Lokales Zusammenführen..."
-#: git-gui.sh:2032
+#: git-gui.sh:2069
msgid "Abort Merge..."
msgstr "Zusammenführen abbrechen..."
-#: git-gui.sh:2044
+#: git-gui.sh:2081
msgid "Push..."
msgstr "Versenden..."
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
-msgid "Apple"
-msgstr "Apple"
-
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2197 git-gui.sh:2219 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "Ãœber %s"
-#: git-gui.sh:2062
+#: git-gui.sh:2099
msgid "Preferences..."
msgstr "Einstellungen..."
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2107 git-gui.sh:2639
msgid "Options..."
msgstr "Optionen..."
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2113 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Hilfe"
-#: git-gui.sh:2117
+#: git-gui.sh:2154
msgid "Online Documentation"
msgstr "Online-Dokumentation"
-#: git-gui.sh:2201
+#: git-gui.sh:2238
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr "Fehler: Verzeichnis »%s« kann nicht gelesen werden: Datei oder Verzeichnis nicht gefunden"
+msgstr ""
+"Fehler: Verzeichnis »%s« kann nicht gelesen werden: Datei oder Verzeichnis "
+"nicht gefunden"
-#: git-gui.sh:2234
+#: git-gui.sh:2271
msgid "Current Branch:"
msgstr "Aktueller Zweig:"
-#: git-gui.sh:2255
+#: git-gui.sh:2292
msgid "Staged Changes (Will Commit)"
msgstr "Bereitstellung (zum Eintragen)"
-#: git-gui.sh:2274
+#: git-gui.sh:2312
msgid "Unstaged Changes"
msgstr "Nicht bereitgestellte Änderungen"
-#: git-gui.sh:2323
+#: git-gui.sh:2362
msgid "Stage Changed"
msgstr "Alles bereitstellen"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2378 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Versenden"
-#: git-gui.sh:2369
+#: git-gui.sh:2408
msgid "Initial Commit Message:"
msgstr "Erste Versionsbeschreibung:"
-#: git-gui.sh:2370
+#: git-gui.sh:2409
msgid "Amended Commit Message:"
-msgstr "Nachgebesserte Versionsbeschreibung:"
+msgstr "Nachgebesserte Beschreibung:"
-#: git-gui.sh:2371
+#: git-gui.sh:2410
msgid "Amended Initial Commit Message:"
-msgstr "Nachgebesserte erste Versionsbeschreibung:"
+msgstr "Nachgebesserte erste Beschreibung:"
-#: git-gui.sh:2372
+#: git-gui.sh:2411
msgid "Amended Merge Commit Message:"
-msgstr "Nachgebesserte Zusammenführungs-Versionsbeschreibung:"
+msgstr "Nachgebesserte Zusammenführungs-Beschreibung:"
-#: git-gui.sh:2373
+#: git-gui.sh:2412
msgid "Merge Commit Message:"
-msgstr "Zusammenführungs-Versionsbeschreibung:"
+msgstr "Zusammenführungs-Beschreibung:"
-#: git-gui.sh:2374
+#: git-gui.sh:2413
msgid "Commit Message:"
msgstr "Versionsbeschreibung:"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2459 git-gui.sh:2622 lib/console.tcl:73
msgid "Copy All"
msgstr "Alle kopieren"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2483 lib/blame.tcl:107
msgid "File:"
msgstr "Datei:"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Aktualisieren"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2589
msgid "Apply/Reverse Hunk"
msgstr "Kontext anwenden/umkehren"
-#: git-gui.sh:2572
+#: git-gui.sh:2696
+msgid "Apply/Reverse Line"
+msgstr "Zeile anwenden/umkehren"
+
+#: git-gui.sh:2711
+msgid "Refresh"
+msgstr "Aktualisieren"
+
+#: git-gui.sh:2631
msgid "Decrease Font Size"
msgstr "Schriftgröße verkleinern"
-#: git-gui.sh:2576
+#: git-gui.sh:2635
msgid "Increase Font Size"
msgstr "Schriftgröße vergrößern"
-#: git-gui.sh:2581
-msgid "Show Less Context"
-msgstr "Weniger Zeilen anzeigen"
-
-#: git-gui.sh:2588
-msgid "Show More Context"
-msgstr "Mehr Zeilen anzeigen"
-
-#: git-gui.sh:2602
+#: git-gui.sh:2646
msgid "Unstage Hunk From Commit"
msgstr "Kontext aus Bereitstellung herausnehmen"
-#: git-gui.sh:2604
+#: git-gui.sh:2748
+msgid "Unstage Line From Commit"
+msgstr "Zeile aus der Bereitstellung herausnehmen"
+
+#: git-gui.sh:2750
msgid "Stage Hunk For Commit"
msgstr "Kontext zur Bereitstellung hinzufügen"
-#: git-gui.sh:2623
+#: git-gui.sh:2751
+msgid "Stage Line For Commit"
+msgstr "Zeile zur Bereitstellung hinzufügen"
+
+#: git-gui.sh:2771
msgid "Initializing..."
msgstr "Initialisieren..."
-#: git-gui.sh:2718
+#: git-gui.sh:2762
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -449,7 +452,7 @@ msgstr ""
"von %s an Git weitergegeben werden:\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2792
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -459,7 +462,7 @@ msgstr ""
"Dies ist ein bekanntes Problem der Tcl-Version, die\n"
"in Cygwin mitgeliefert wird."
-#: git-gui.sh:2753
+#: git-gui.sh:2797
#, tcl-format
msgid ""
"\n"
@@ -475,7 +478,7 @@ msgstr ""
"gewünschten Werte für die Einstellung user.name und \n"
"user.email in Ihre Datei ~/.gitconfig einfügen.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - eine grafische Oberfläche für Git."
@@ -487,79 +490,95 @@ msgstr "Datei-Browser"
msgid "Commit:"
msgstr "Version:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:264
msgid "Copy Commit"
msgstr "Version kopieren"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:260
+msgid "Do Full Copy Detection"
+msgstr "Volle Kopie-Erkennung"
+
+#: lib/blame.tcl:388
#, tcl-format
msgid "Reading %s..."
msgstr "%s lesen..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:488
msgid "Loading copy/move tracking annotations..."
msgstr "Annotierungen für Kopieren/Verschieben werden geladen..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:508
msgid "lines annotated"
msgstr "Zeilen annotiert"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:689
msgid "Loading original location annotations..."
msgstr "Annotierungen für ursprünglichen Ort werden geladen..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:692
msgid "Annotation complete."
msgstr "Annotierung vollständig."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:737
+msgid "Busy"
+msgstr "Verarbeitung läuft"
+
+#: lib/blame.tcl:738
+msgid "Annotation process is already running."
+msgstr "Annotierung läuft bereits."
+
+#: lib/blame.tcl:777
+msgid "Running thorough copy detection..."
+msgstr "Intensive Kopie-Erkennung läuft..."
+
+#: lib/blame.tcl:827
msgid "Loading annotation..."
msgstr "Annotierung laden..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:802
msgid "Author:"
msgstr "Autor:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:806
msgid "Committer:"
msgstr "Eintragender:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:811
msgid "Original File:"
msgstr "Ursprüngliche Datei:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:925
msgid "Originally By:"
msgstr "Ursprünglich von:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:931
msgid "In File:"
msgstr "In Datei:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:936
msgid "Copied Or Moved Here By:"
msgstr "Kopiert oder verschoben durch:"
#: lib/branch_checkout.tcl:14 lib/branch_checkout.tcl:19
msgid "Checkout Branch"
-msgstr "Zweig umstellen"
+msgstr "Auf Zweig umstellen"
#: lib/branch_checkout.tcl:23
msgid "Checkout"
msgstr "Umstellen"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Abbrechen"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "Version"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:242
msgid "Options"
msgstr "Optionen"
@@ -579,7 +598,7 @@ msgstr "Zweig erstellen"
msgid "Create New Branch"
msgstr "Neuen Zweig erstellen"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Erstellen"
@@ -651,7 +670,7 @@ msgstr "Lokale Zweige"
#: lib/branch_delete.tcl:52
msgid "Delete Only If Merged Into"
-msgstr "Nur löschen, wenn darin zusammengeführt"
+msgstr "Nur löschen, wenn zusammengeführt nach"
#: lib/branch_delete.tcl:54
msgid "Always (Do not perform merge test.)"
@@ -719,22 +738,22 @@ msgstr "Starten..."
msgid "File Browser"
msgstr "Datei-Browser"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "%s laden..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Nach oben]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "Dateien des Zweigs durchblättern"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:474 lib/choose_repository.tcl:484
+#: lib/choose_repository.tcl:987
msgid "Browse"
msgstr "Blättern"
@@ -748,7 +767,7 @@ msgstr "Änderungen »%s« von »%s« anfordern"
msgid "fatal: Cannot resolve %s"
msgstr "Fehler: »%s« kann nicht als Zweig oder Version erkannt werden"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:140 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Schließen"
@@ -757,7 +776,12 @@ msgstr "Schließen"
msgid "Branch '%s' does not exist."
msgstr "Zweig »%s« existiert nicht."
-#: lib/checkout_op.tcl:206
+#: lib/checkout_op.tcl:193
+#, tcl-format
+msgid "Failed to configure simplified git-pull for '%s'."
+msgstr "Fehler beim Einrichten der vereinfachten git-pull für »%s«."
+
+#: lib/checkout_op.tcl:228
#, tcl-format
msgid ""
"Branch '%s' already exists.\n"
@@ -805,11 +829,15 @@ msgstr ""
msgid "Updating working directory to '%s'..."
msgstr "Arbeitskopie umstellen auf »%s«..."
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr "Dateien aktualisiert"
+
#: lib/checkout_op.tcl:353
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
msgstr ""
-"Zweig umstellen von »%s« abgebrochen (Zusammenführen der Dateien ist "
+"Auf Zweig »%s« umstellen abgebrochen (Zusammenführen der Dateien ist "
"notwendig)."
#: lib/checkout_op.tcl:354
@@ -833,7 +861,7 @@ msgstr ""
"Wenn Sie auf einem Zweig arbeiten möchten, erstellen Sie bitte jetzt einen "
"Zweig mit der Auswahl »Abgetrennte Arbeitskopie-Version«."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:446 lib/checkout_op.tcl:450
#, tcl-format
msgid "Checked out '%s'."
msgstr "Umgestellt auf »%s«."
@@ -854,7 +882,7 @@ msgstr ""
msgid "Reset '%s'?"
msgstr "»%s« zurücksetzen?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:510 lib/merge.tcl:163
msgid "Visualize"
msgstr "Darstellen"
@@ -884,15 +912,15 @@ msgstr "Auswählen"
msgid "Font Family"
msgstr "Schriftfamilie"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Schriftgröße"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Schriftbeispiel"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -900,225 +928,231 @@ msgstr ""
"Dies ist ein Beispieltext.\n"
"Wenn Ihnen dieser Text gefällt, sollten Sie diese Schriftart wählen."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git Gui"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Neues Projektarchiv"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Neu..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:460
msgid "Clone Existing Repository"
msgstr "Projektarchiv klonen"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Klonen..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:976
msgid "Open Existing Repository"
msgstr "Projektarchiv öffnen"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Öffnen..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Zuletzt benutzte Projektarchive"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Zuletzt benutztes Projektarchiv öffnen:"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "Projektarchiv »%s« existiert bereits."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "Projektarchiv »%s« konnte nicht erstellt werden:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:478
msgid "Directory:"
msgstr "Verzeichnis:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:412 lib/choose_repository.tcl:537
+#: lib/choose_repository.tcl:1011
msgid "Git Repository"
msgstr "Git Projektarchiv"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:437
#, tcl-format
msgid "Directory %s already exists."
msgstr "Verzeichnis »%s« existiert bereits."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:441
#, tcl-format
msgid "File %s already exists."
msgstr "Datei »%s« existiert bereits."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:455
msgid "Clone"
msgstr "Klonen"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:468
msgid "URL:"
msgstr "URL:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:489
msgid "Clone Type:"
msgstr "Art des Klonens:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:495
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Standard (schnell, teilweise redundant, Hardlinks)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:501
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "Alles kopieren (langsamer, volle Redundanz)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:507
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Verknüpft (schnell, nicht empfohlen, kein Backup)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:543 lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:736 lib/choose_repository.tcl:806
+#: lib/choose_repository.tcl:1017 lib/choose_repository.tcl:1025
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "Kein Git-Projektarchiv in »%s« gefunden."
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:579
msgid "Standard only available for local repository."
msgstr "Standard ist nur für lokale Projektarchive verfügbar."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:583
msgid "Shared only available for local repository."
msgstr "Verknüpft ist nur für lokale Projektarchive verfügbar."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:604
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "Projektarchiv »%s« existiert bereits."
+
+#: lib/choose_repository.tcl:615
msgid "Failed to configure origin"
msgstr "Der Ursprungsort konnte nicht eingerichtet werden"
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:627
msgid "Counting objects"
msgstr "Objekte werden gezählt"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:628
msgid "buckets"
msgstr "Buckets"
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:652
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Kopien von Objekten/Info/Alternates konnten nicht erstellt werden: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:688
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Von »%s« konnte nichts geklont werden."
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:690 lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:916
msgid "The 'master' branch has not been initialized."
msgstr "Der »master«-Zweig wurde noch nicht initialisiert."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:703
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "Hardlinks nicht verfügbar. Stattdessen wird kopiert."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:715
#, tcl-format
msgid "Cloning from %s"
msgstr "Kopieren von »%s«"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:746
msgid "Copying objects"
msgstr "Objektdatenbank kopieren"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:747
msgid "KiB"
msgstr "KB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:771
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Objekt kann nicht kopiert werden: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:781
msgid "Linking objects"
msgstr "Objekte verlinken"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:782
msgid "objects"
msgstr "Objekte"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:790
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Für Objekt konnte kein Hardlink erstellt werden: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:845
msgid "Cannot fetch branches and objects. See console output for details."
-msgstr "Zweige und Objekte konnten nicht angefordert werden. Kontrollieren Sie die Ausgaben auf der Konsole für weitere Angaben."
+msgstr ""
+"Zweige und Objekte konnten nicht angefordert werden. Kontrollieren Sie die "
+"Ausgaben auf der Konsole für weitere Angaben."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:856
msgid "Cannot fetch tags. See console output for details."
-msgstr "Markierungen konnten nicht angefordert werden. Kontrollieren Sie die Ausgaben auf der Konsole für weitere Angaben."
+msgstr ""
+"Markierungen konnten nicht angefordert werden. Kontrollieren Sie die "
+"Ausgaben auf der Konsole für weitere Angaben."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:880
msgid "Cannot determine HEAD. See console output for details."
-msgstr "Die Zweigspitze (HEAD) konnte nicht gefunden werden. Kontrollieren Sie die Ausgaben auf der Konsole für weitere Angaben."
+msgstr ""
+"Die Zweigspitze (HEAD) konnte nicht gefunden werden. Kontrollieren Sie die "
+"Ausgaben auf der Konsole für weitere Angaben."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:889
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Verzeichnis »%s« kann nicht aufgeräumt werden."
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:895
msgid "Clone failed."
msgstr "Klonen fehlgeschlagen."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:902
msgid "No default branch obtained."
msgstr "Kein voreingestellter Zweig gefunden."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:913
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "»%s« wurde nicht als Version gefunden."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:925
msgid "Creating working directory"
msgstr "Arbeitskopie erstellen"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:926 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "Dateien"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:955
msgid "Initial file checkout failed."
msgstr "Erstellen der Arbeitskopie fehlgeschlagen."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:971
msgid "Open"
msgstr "Öffnen"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:981
msgid "Repository:"
msgstr "Projektarchiv:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1031
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Projektarchiv »%s« konnte nicht geöffnet werden."
@@ -1139,7 +1173,7 @@ msgstr "Lokaler Zweig"
msgid "Tracking Branch"
msgstr "Ãœbernahmezweig"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Markierung"
@@ -1156,11 +1190,11 @@ msgstr "Keine Version ausgewählt."
msgid "Revision expression is empty."
msgstr "Versions-Ausdruck ist leer."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Aktualisiert"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "URL"
@@ -1273,16 +1307,47 @@ msgstr ""
"\n"
"- Rest: Eine ausführliche Beschreibung, warum diese Änderung hilfreich ist.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "Warning: Tcl/Tk unterstützt die Zeichencodierung »%s« nicht."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "Aufrufen der Vor-Eintragen-Kontrolle..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "Eintragen abgelehnt durch Vor-Eintragen-Kontrolle (»pre-commit hook«)."
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "Aufrufen der Versionsbeschreibungs-Kontrolle..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr ""
+"Eintragen abgelehnt durch Versionsbeschreibungs-Kontrolle (»commit-message "
+"hook«)."
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Änderungen eintragen..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "write-tree fehlgeschlagen:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Eintragen fehlgeschlagen."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "Version »%s« scheint beschädigt zu sein"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1297,37 +1362,32 @@ msgstr ""
"\n"
"Das Arbeitsverzeichnis wird daher jetzt neu geladen.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "Keine Änderungen, die eingetragen werden können."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "Warning: Tcl/Tk unterstützt die Zeichencodierung »%s« nicht."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "commit-tree fehlgeschlagen:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "update-ref fehlgeschlagen:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Version %s übertragen: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Verarbeitung. Bitte warten..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "Erfolgreich"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Fehler: Kommando fehlgeschlagen"
@@ -1353,7 +1413,7 @@ msgstr "Festplattenplatz von komprimierten Objekten"
#: lib/database.tcl:48
msgid "Packed objects waiting for pruning"
-msgstr "Komprimierte Objekte, die zum Entfernen vorgesehen sind"
+msgstr "Komprimierte Objekte, die zum Aufräumen vorgesehen sind"
#: lib/database.tcl:49
msgid "Garbage files"
@@ -1438,23 +1498,32 @@ msgstr "* Binärdatei (Inhalt wird nicht angezeigt)"
msgid "Error loading diff:"
msgstr "Fehler beim Laden des Vergleichs:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:303
msgid "Failed to unstage selected hunk."
-msgstr "Fehler beim Herausnehmen des gewählten Kontexts aus der Bereitstellung."
+msgstr ""
+"Fehler beim Herausnehmen des gewählten Kontexts aus der Bereitstellung."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:310
msgid "Failed to stage selected hunk."
msgstr "Fehler beim Bereitstellen des gewählten Kontexts."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/diff.tcl:386
+msgid "Failed to unstage selected line."
+msgstr "Fehler beim Herausnehmen der gewählten Zeile aus der Bereitstellung."
+
+#: lib/diff.tcl:394
+msgid "Failed to stage selected line."
+msgstr "Fehler beim Bereitstellen der gewählten Zeile."
+
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "Fehler"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "Warnung"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr ""
"Sie müssen die obigen Fehler zuerst beheben, bevor Sie eintragen können."
@@ -1471,7 +1540,10 @@ msgstr "Fehler in Bereitstellung"
msgid ""
"Updating the Git index failed. A rescan will be automatically started to "
"resynchronize git-gui."
-msgstr "Das Aktualisieren der Git-Bereitstellung ist fehlgeschlagen. Eine allgemeine Git-Aktualisierung wird jetzt gestartet, um git-gui wieder mit git zu synchronisieren."
+msgstr ""
+"Das Aktualisieren der Git-Bereitstellung ist fehlgeschlagen. Eine allgemeine "
+"Git-Aktualisierung wird jetzt gestartet, um git-gui wieder mit git zu "
+"synchronisieren."
#: lib/index.tcl:27
msgid "Continue"
@@ -1486,6 +1558,10 @@ msgstr "Bereitstellung freigeben"
msgid "Unstaging %s from commit"
msgstr "Datei »%s« aus der Bereitstellung herausnehmen"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Bereit zum Eintragen."
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1501,11 +1577,12 @@ msgstr "Änderungen in Datei »%s« verwerfen?"
msgid "Revert changes in these %i files?"
msgstr "Änderungen in den gewählten %i Dateien verwerfen?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
-msgstr "Alle nicht bereitgestellten Änderungen werden beim Verwerfen verloren gehen."
+msgstr ""
+"Alle nicht bereitgestellten Änderungen werden beim Verwerfen verloren gehen."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Nichts tun"
@@ -1577,27 +1654,27 @@ msgstr "%s von %s"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "Zusammenführen von %s und %s"
+msgid "Merging %s and %s..."
+msgstr "Zusammenführen von %s und %s..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "Zusammenführen erfolgreich abgeschlossen."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "Zusammenführen fehlgeschlagen. Konfliktauflösung ist notwendig."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
-msgstr "Zusammenführen in %s"
+msgstr "Zusammenführen in »%s«"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "Zusammenzuführende Version"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1607,7 +1684,7 @@ msgstr ""
"\n"
"Sie müssen die Nachbesserung der Version abschließen.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1622,7 +1699,7 @@ msgstr ""
"\n"
"Zusammenführen jetzt abbrechen?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1637,103 +1714,123 @@ msgstr ""
"\n"
"Änderungen jetzt zurücksetzen?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "Abbruch"
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "Dateien zurückgesetzt"
+
+#: lib/merge.tcl:265
msgid "Abort failed."
msgstr "Abbruch fehlgeschlagen."
-#: lib/merge.tcl:268
+#: lib/merge.tcl:267
msgid "Abort completed. Ready."
msgstr "Abbruch durchgeführt. Bereit."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "Voreinstellungen wiederherstellen"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Speichern"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "Projektarchiv %s"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Global (Alle Projektarchive)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Benutzername"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "E-Mail-Adresse"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "Zusammenführungs-Versionen zusammenfassen"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Ausführlichkeit der Zusammenführen-Meldungen"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Vergleichsstatistik nach Zusammenführen anzeigen"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "Auf Dateiänderungsdatum verlassen"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
-msgstr "Übernahmezweige entfernen während Anforderung"
+msgstr "Übernahmezweige aufräumen während Anforderung"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "Passend zu Ãœbernahmezweig"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
+msgid "Blame Copy Only On Changed Files"
+msgstr "Kopie-Annotieren nur bei geänderten Dateien"
+
+#: lib/option.tcl:127
+msgid "Minimum Letters To Blame Copy On"
+msgstr "Mindestzahl Zeichen für Kopie-Annotieren"
+
+#: lib/option.tcl:128
msgid "Number of Diff Context Lines"
msgstr "Anzahl der Kontextzeilen beim Vergleich"
-#: lib/option.tcl:114
+#: lib/option.tcl:127
+msgid "Commit Message Text Width"
+msgstr "Textbreite der Versionsbeschreibung"
+
+#: lib/option.tcl:128
msgid "New Branch Name Template"
msgstr "Namensvorschlag für neue Zweige"
-#: lib/option.tcl:176
+#: lib/option.tcl:192
+msgid "Spelling Dictionary:"
+msgstr "Wörterbuch Rechtschreibprüfung:"
+
+#: lib/option.tcl:216
msgid "Change Font"
msgstr "Schriftart ändern"
-#: lib/option.tcl:180
+#: lib/option.tcl:220
#, tcl-format
msgid "Choose %s"
msgstr "%s wählen"
-#: lib/option.tcl:186
+#: lib/option.tcl:226
msgid "pt."
msgstr "pt."
-#: lib/option.tcl:200
+#: lib/option.tcl:240
msgid "Preferences"
msgstr "Einstellungen"
-#: lib/option.tcl:235
+#: lib/option.tcl:275
msgid "Failed to completely save options:"
msgstr "Optionen konnten nicht gespeichert werden:"
#: lib/remote_branch_delete.tcl:29 lib/remote_branch_delete.tcl:34
msgid "Delete Remote Branch"
-msgstr "Zweig aus anderem Projektarchiv löschen"
+msgstr "Zweig in anderem Projektarchiv löschen"
#: lib/remote_branch_delete.tcl:47
msgid "From Repository"
-msgstr "Von Projektarchiv"
+msgstr "In Projektarchiv"
#: lib/remote_branch_delete.tcl:50 lib/transport.tcl:123
msgid "Remote:"
@@ -1741,7 +1838,7 @@ msgstr "Anderes Archiv:"
#: lib/remote_branch_delete.tcl:66 lib/transport.tcl:138
msgid "Arbitrary URL:"
-msgstr "Kommunikation mit URL:"
+msgstr "Archiv-URL:"
#: lib/remote_branch_delete.tcl:84
msgid "Branches"
@@ -1749,11 +1846,11 @@ msgstr "Zweige"
#: lib/remote_branch_delete.tcl:109
msgid "Delete Only If"
-msgstr "Löschen, falls"
+msgstr "Nur löschen, wenn"
#: lib/remote_branch_delete.tcl:111
msgid "Merged Into:"
-msgstr "Zusammenführen mit:"
+msgstr "Zusammengeführt mit:"
#: lib/remote_branch_delete.tcl:119
msgid "Always (Do not perform merge checks)"
@@ -1815,7 +1912,7 @@ msgstr "»%s« laden..."
#: lib/remote.tcl:165
msgid "Prune from"
-msgstr "Entfernen von"
+msgstr "Aufräumen von"
#: lib/remote.tcl:170
msgid "Fetch from"
@@ -1833,6 +1930,43 @@ msgstr "Fehler beim Schreiben der Verknüpfung:"
msgid "Cannot write icon:"
msgstr "Fehler beim Erstellen des Icons:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "Rechtschreibprüfungsprogramm nicht unterstützt"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "Rechtschreibprüfung nicht verfügbar"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "Unbenutzbare Konfiguration der Rechtschreibprüfung"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Wörterbuch auf %s zurückgesetzt."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "Rechtschreibprüfungsprogramm mit Fehler abgebrochen"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "Unbekanntes Rechtschreibprüfungsprogramm"
+
+#: lib/spellcheck.tcl:180
+msgid "No Suggestions"
+msgstr "Keine Vorschläge"
+
+#: lib/spellcheck.tcl:381
+msgid "Unexpected EOF from spell checker"
+msgstr "Unerwartetes EOF vom Rechtschreibprüfungsprogramm"
+
+#: lib/spellcheck.tcl:385
+msgid "Spell Checker Failed"
+msgstr "Rechtschreibprüfung fehlgeschlagen"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
@@ -1851,12 +1985,12 @@ msgstr "Neue Änderungen von »%s« holen"
#: lib/transport.tcl:18
#, tcl-format
msgid "remote prune %s"
-msgstr "Entfernen von »%s« aus anderem Archiv"
+msgstr "Aufräumen von »%s«"
#: lib/transport.tcl:19
#, tcl-format
msgid "Pruning tracking branches deleted from %s"
-msgstr "Übernahmezweige entfernen, die in »%s« gelöscht wurden"
+msgstr "Übernahmezweige aufräumen und entfernen, die in »%s« gelöscht wurden"
#: lib/transport.tcl:25 lib/transport.tcl:71
#, tcl-format
@@ -1879,7 +2013,7 @@ msgstr "Zweige versenden"
#: lib/transport.tcl:103
msgid "Source Branches"
-msgstr "Herkunftszweige"
+msgstr "Lokale Zweige"
#: lib/transport.tcl:120
msgid "Destination Repository"
diff --git a/git-gui/po/fr.po b/git-gui/po/fr.po
index d389bdaca..89b6d51ea 100644
--- a/git-gui/po/fr.po
+++ b/git-gui/po/fr.po
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: fr\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2008-01-14 21:08+0100\n"
+"POT-Creation-Date: 2008-03-14 07:18+0100\n"
+"PO-Revision-Date: 2008-04-04 22:05+0200\n"
"Last-Translator: Christian Couder <chriscool@tuxfamily.org>\n"
"Language-Team: French\n"
"MIME-Version: 1.0\n"
@@ -18,33 +18,33 @@ msgstr ""
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:634 git-gui.sh:648 git-gui.sh:661 git-gui.sh:744
+#: git-gui.sh:763
msgid "git-gui: fatal error"
msgstr "git-gui: erreur fatale"
-#: git-gui.sh:565
+#: git-gui.sh:593
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Invalide fonte spécifiée dans %s :"
-#: git-gui.sh:590
+#: git-gui.sh:620
msgid "Main Font"
msgstr "Fonte principale"
-#: git-gui.sh:591
+#: git-gui.sh:621
msgid "Diff/Console Font"
msgstr "Fonte diff/console"
-#: git-gui.sh:605
+#: git-gui.sh:635
msgid "Cannot find git in PATH."
msgstr "Impossible de trouver git dans PATH."
-#: git-gui.sh:632
+#: git-gui.sh:662
msgid "Cannot parse Git version string:"
msgstr "Impossible de parser la version de Git :"
-#: git-gui.sh:650
+#: git-gui.sh:680
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -63,79 +63,79 @@ msgstr ""
"\n"
"Peut'on considérer que '%s' est en version 1.5.0 ?\n"
-#: git-gui.sh:888
+#: git-gui.sh:918
msgid "Git directory not found:"
msgstr "Impossible de trouver le répertoire de Git :"
-#: git-gui.sh:895
+#: git-gui.sh:925
msgid "Cannot move to top of working directory:"
msgstr "Impossible d'aller à la racine du répertoire de travail :"
-#: git-gui.sh:902
+#: git-gui.sh:932
msgid "Cannot use funny .git directory:"
msgstr "Impossible d'utiliser un drôle de répertoire git :"
-#: git-gui.sh:907
+#: git-gui.sh:937
msgid "No working directory"
msgstr "Pas de répertoire de travail"
-#: git-gui.sh:1054
+#: git-gui.sh:1084 lib/checkout_op.tcl:283
msgid "Refreshing file status..."
msgstr "Rafraichissement du status des fichiers..."
-#: git-gui.sh:1119
+#: git-gui.sh:1149
msgid "Scanning for modified files ..."
msgstr "Recherche de fichiers modifiés..."
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1324 lib/browser.tcl:246
msgid "Ready."
msgstr "Prêt."
-#: git-gui.sh:1560
+#: git-gui.sh:1590
msgid "Unmodified"
msgstr "Non modifié"
-#: git-gui.sh:1562
+#: git-gui.sh:1592
msgid "Modified, not staged"
msgstr "Modifié, non pré-commité"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1593 git-gui.sh:1598
msgid "Staged for commit"
msgstr "Pré-commité"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1594 git-gui.sh:1599
msgid "Portions staged for commit"
msgstr "En partie pré-commité"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1595 git-gui.sh:1600
msgid "Staged for commit, missing"
msgstr "Pré-commité, manquant"
-#: git-gui.sh:1567
+#: git-gui.sh:1597
msgid "Untracked, not staged"
msgstr "Non suivi, non pré-commité"
-#: git-gui.sh:1572
+#: git-gui.sh:1602
msgid "Missing"
msgstr "Manquant"
-#: git-gui.sh:1573
+#: git-gui.sh:1603
msgid "Staged for removal"
msgstr "Pré-commité pour suppression"
-#: git-gui.sh:1574
+#: git-gui.sh:1604
msgid "Staged for removal, still present"
msgstr "Pré-commité pour suppression, toujours présent"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1606 git-gui.sh:1607 git-gui.sh:1608 git-gui.sh:1609
msgid "Requires merge resolution"
msgstr "Nécessite la résolution d'une fusion"
-#: git-gui.sh:1614
+#: git-gui.sh:1644
msgid "Starting gitk... please wait..."
msgstr "Lancement de gitk... merci de patienter..."
-#: git-gui.sh:1623
+#: git-gui.sh:1653
#, tcl-format
msgid ""
"Unable to start gitk:\n"
@@ -146,295 +146,295 @@ msgstr ""
"\n"
"%s inexistant"
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1860 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Référentiel"
-#: git-gui.sh:1824
+#: git-gui.sh:1861
msgid "Edit"
msgstr "Editer"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1863 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Branche"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1866 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "Commit"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1869 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Fusionner"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1870 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Référentiel distant"
-#: git-gui.sh:1842
+#: git-gui.sh:1879
msgid "Browse Current Branch's Files"
msgstr "Visionner fichiers dans branche courante"
-#: git-gui.sh:1846
+#: git-gui.sh:1883
msgid "Browse Branch Files..."
msgstr "Visionner fichiers de branche"
-#: git-gui.sh:1851
+#: git-gui.sh:1888
msgid "Visualize Current Branch's History"
msgstr "Visualiser historique branche courante"
-#: git-gui.sh:1855
+#: git-gui.sh:1892
msgid "Visualize All Branch History"
msgstr "Visualiser historique toutes branches"
-#: git-gui.sh:1862
+#: git-gui.sh:1899
#, tcl-format
msgid "Browse %s's Files"
msgstr "Visionner fichiers de %s"
-#: git-gui.sh:1864
+#: git-gui.sh:1901
#, tcl-format
msgid "Visualize %s's History"
msgstr "Visualiser historique de %s"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1906 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "Statistiques base de donnée"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1909 lib/database.tcl:34
msgid "Compress Database"
msgstr "Comprimer base de donnée"
-#: git-gui.sh:1875
+#: git-gui.sh:1912
msgid "Verify Database"
msgstr "Vérifier base de donnée"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:1919 git-gui.sh:1923 git-gui.sh:1927 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Créer icône sur bureau"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:1932 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Quitter"
-#: git-gui.sh:1902
+#: git-gui.sh:1939
msgid "Undo"
msgstr "Défaire"
-#: git-gui.sh:1905
+#: git-gui.sh:1942
msgid "Redo"
msgstr "Refaire"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:1946 git-gui.sh:2443
msgid "Cut"
msgstr "Couper"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:1949 git-gui.sh:2446 git-gui.sh:2520 git-gui.sh:2614
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Copier"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:1952 git-gui.sh:2449
msgid "Paste"
msgstr "Coller"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:1955 git-gui.sh:2452 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Supprimer"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:1959 git-gui.sh:2456 git-gui.sh:2618 lib/console.tcl:71
msgid "Select All"
msgstr "Tout sélectionner"
-#: git-gui.sh:1931
+#: git-gui.sh:1968
msgid "Create..."
msgstr "Créer..."
-#: git-gui.sh:1937
+#: git-gui.sh:1974
msgid "Checkout..."
msgstr "Emprunter... "
-#: git-gui.sh:1943
+#: git-gui.sh:1980
msgid "Rename..."
msgstr "Renommer..."
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:1985 git-gui.sh:2085
msgid "Delete..."
msgstr "Supprimer..."
-#: git-gui.sh:1953
+#: git-gui.sh:1990
msgid "Reset..."
msgstr "Réinitialiser..."
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2002 git-gui.sh:2389
msgid "New Commit"
msgstr "Nouveau commit"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2010 git-gui.sh:2396
msgid "Amend Last Commit"
msgstr "Corriger dernier commit"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2019 git-gui.sh:2356 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Resynchroniser"
-#: git-gui.sh:1988
+#: git-gui.sh:2025
msgid "Stage To Commit"
msgstr "Commiter un pré-commit"
-#: git-gui.sh:1994
+#: git-gui.sh:2031
msgid "Stage Changed Files To Commit"
msgstr "Commiter fichiers modifiés dans pré-commit"
-#: git-gui.sh:2000
+#: git-gui.sh:2037
msgid "Unstage From Commit"
msgstr "Commit vers pré-commit"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2042 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Inverser modification"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2049 git-gui.sh:2368 git-gui.sh:2467
msgid "Sign Off"
msgstr "Se désinscrire"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2053 git-gui.sh:2372
msgid "Commit@@verb"
msgstr "Commiter"
-#: git-gui.sh:2027
+#: git-gui.sh:2064
msgid "Local Merge..."
msgstr "Fusion locale..."
-#: git-gui.sh:2032
+#: git-gui.sh:2069
msgid "Abort Merge..."
msgstr "Abandonner fusion..."
-#: git-gui.sh:2044
+#: git-gui.sh:2081
msgid "Push..."
msgstr "Pousser..."
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
+#: git-gui.sh:2092 lib/choose_repository.tcl:41
msgid "Apple"
msgstr "Pomme"
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2095 git-gui.sh:2117 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "A propos de %s"
-#: git-gui.sh:2062
+#: git-gui.sh:2099
msgid "Preferences..."
msgstr "Préférences..."
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2107 git-gui.sh:2639
msgid "Options..."
msgstr "Options..."
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2113 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Aide"
-#: git-gui.sh:2117
+#: git-gui.sh:2154
msgid "Online Documentation"
msgstr "Documentation en ligne"
-#: git-gui.sh:2201
+#: git-gui.sh:2238
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr "fatale : pas d'infos sur le chemin %s : Fichier ou répertoire inexistant"
+msgstr "erreur fatale : pas d'infos sur le chemin %s : Fichier ou répertoire inexistant"
-#: git-gui.sh:2234
+#: git-gui.sh:2271
msgid "Current Branch:"
msgstr "Branche courante :"
-#: git-gui.sh:2255
+#: git-gui.sh:2292
msgid "Staged Changes (Will Commit)"
msgstr "Modifications pré-commitées"
-#: git-gui.sh:2274
+#: git-gui.sh:2312
msgid "Unstaged Changes"
msgstr "Modifications non pré-commitées"
-#: git-gui.sh:2323
+#: git-gui.sh:2362
msgid "Stage Changed"
msgstr "Pré-commit modifié"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2378 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Pousser"
-#: git-gui.sh:2369
+#: git-gui.sh:2408
msgid "Initial Commit Message:"
msgstr "Message de commit initial :"
-#: git-gui.sh:2370
+#: git-gui.sh:2409
msgid "Amended Commit Message:"
msgstr "Message de commit corrigé :"
-#: git-gui.sh:2371
+#: git-gui.sh:2410
msgid "Amended Initial Commit Message:"
msgstr "Message de commit initial corrigé :"
-#: git-gui.sh:2372
+#: git-gui.sh:2411
msgid "Amended Merge Commit Message:"
msgstr "Message de commit de fusion corrigé :"
-#: git-gui.sh:2373
+#: git-gui.sh:2412
msgid "Merge Commit Message:"
msgstr "Message de commit de fusion :"
-#: git-gui.sh:2374
+#: git-gui.sh:2413
msgid "Commit Message:"
msgstr "Message de commit :"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2459 git-gui.sh:2622 lib/console.tcl:73
msgid "Copy All"
msgstr "Copier tout"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2483 lib/blame.tcl:107
msgid "File:"
msgstr "Fichier :"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Rafraichir"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2589
msgid "Apply/Reverse Hunk"
msgstr "Appliquer/Inverser section"
-#: git-gui.sh:2572
-msgid "Decrease Font Size"
-msgstr "Réduire fonte"
-
-#: git-gui.sh:2576
-msgid "Increase Font Size"
-msgstr "Agrandir fonte"
-
-#: git-gui.sh:2581
+#: git-gui.sh:2595
msgid "Show Less Context"
msgstr "Montrer moins de contexte"
-#: git-gui.sh:2588
+#: git-gui.sh:2602
msgid "Show More Context"
msgstr "Montrer plus de contexte"
-#: git-gui.sh:2602
+#: git-gui.sh:2610
+msgid "Refresh"
+msgstr "Rafraichir"
+
+#: git-gui.sh:2631
+msgid "Decrease Font Size"
+msgstr "Réduire fonte"
+
+#: git-gui.sh:2635
+msgid "Increase Font Size"
+msgstr "Agrandir fonte"
+
+#: git-gui.sh:2646
msgid "Unstage Hunk From Commit"
msgstr "Enlever section pré-commitée"
-#: git-gui.sh:2604
+#: git-gui.sh:2648
msgid "Stage Hunk For Commit"
msgstr "Pré-commiter section"
-#: git-gui.sh:2623
+#: git-gui.sh:2667
msgid "Initializing..."
msgstr "Initialisation..."
-#: git-gui.sh:2718
+#: git-gui.sh:2762
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -451,7 +451,7 @@ msgstr ""
"sous-processus de Git lancés par %s\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2792
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -461,7 +461,7 @@ msgstr ""
"Ceci est du à un problème connu avec\n"
"le binaire Tcl distribué par Cygwin."
-#: git-gui.sh:2753
+#: git-gui.sh:2797
#, tcl-format
msgid ""
"\n"
@@ -478,7 +478,7 @@ msgstr ""
"de l'utilisateur) et 'user.email' (addresse email\n"
"de l'utilisateur) dans votre fichier '~/.gitconfig'.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - une interface graphique utilisateur pour Git"
@@ -490,56 +490,56 @@ msgstr "Visionneur de fichier"
msgid "Commit:"
msgstr "Commit :"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:264
msgid "Copy Commit"
msgstr "Copier commit"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:384
#, tcl-format
msgid "Reading %s..."
msgstr "Lecture de %s..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:488
msgid "Loading copy/move tracking annotations..."
msgstr "Chargement des annotations de suivi des copies/déplacements..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:508
msgid "lines annotated"
msgstr "lignes annotées"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:689
msgid "Loading original location annotations..."
msgstr "Chargement des annotations d'emplacement original"
-#: lib/blame.tcl:677
+#: lib/blame.tcl:692
msgid "Annotation complete."
msgstr "Annotation terminée."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:746
msgid "Loading annotation..."
msgstr "Chargement des annotations..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:802
msgid "Author:"
msgstr "Auteur :"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:806
msgid "Committer:"
msgstr "Commiteur :"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:811
msgid "Original File:"
msgstr "Fichier original :"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:925
msgid "Originally By:"
msgstr "A l'origine par :"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:931
msgid "In File:"
msgstr "Dans le fichier :"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:936
msgid "Copied Or Moved Here By:"
msgstr "Copié ou déplacé ici par :"
@@ -552,17 +552,17 @@ msgid "Checkout"
msgstr "Emprunter"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Annuler"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "Révision"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:242
msgid "Options"
msgstr "Options"
@@ -582,7 +582,7 @@ msgstr "Créer branche"
msgid "Create New Branch"
msgstr "Créer nouvelle branche"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Créer"
@@ -722,22 +722,22 @@ msgstr "Lancement..."
msgid "File Browser"
msgstr "Visionneur de fichier"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "Chargement de %s..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Jusqu'au parent]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "Visionner fichiers de branches"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:474 lib/choose_repository.tcl:484
+#: lib/choose_repository.tcl:987
msgid "Browse"
msgstr "Visionner"
@@ -749,9 +749,9 @@ msgstr "Récupération de %s à partir de %s"
#: lib/checkout_op.tcl:127
#, tcl-format
msgid "fatal: Cannot resolve %s"
-msgstr "Erreur fatale : Impossible de résoudre %s"
+msgstr "erreur fatale : Impossible de résoudre %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:140 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Fermer"
@@ -807,6 +807,10 @@ msgstr ""
msgid "Updating working directory to '%s'..."
msgstr "Mise à jour du répertoire courant avec '%s'..."
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr "fichiers empruntés"
+
#: lib/checkout_op.tcl:353
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
@@ -830,9 +834,10 @@ msgid ""
msgstr ""
"Vous n'êtes plus ur une branche locale.\n"
"\n"
-"Si vous vouliez être sur une branche, créez en une maintenant en partant de 'Cet emprunt détaché'."
+"Si vous vouliez être sur une branche, créez en une maintenant en partant de "
+"'Cet emprunt détaché'."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:446 lib/checkout_op.tcl:450
#, tcl-format
msgid "Checked out '%s'."
msgstr "'%s' emprunté."
@@ -851,7 +856,7 @@ msgstr "Récupérer les commits perdus ne sera peut être pas facile."
msgid "Reset '%s'?"
msgstr "Réinitialiser '%s' ?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:510 lib/merge.tcl:163
msgid "Visualize"
msgstr "Visualiser"
@@ -867,7 +872,9 @@ msgid ""
msgstr ""
"Le changement de la branche courante a échoué.\n"
"\n"
-"Le répertoire courant n'est que partiellement modifié. Les fichiers ont été mis à jour avec succès, mais la mise à jour d'un fichier interne à Git a échouée.\n"
+"Le répertoire courant n'est que partiellement modifié. Les fichiers ont été "
+"mis à jour avec succès, mais la mise à jour d'un fichier interne à Git a "
+"échouée.\n"
"\n"
"Cela n'aurait pas du se produire. %s va abandonner et se terminer."
@@ -879,15 +886,15 @@ msgstr "Sélectionner"
msgid "Font Family"
msgstr "Famille de fonte"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Taille de fonte"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Exemple de fonte"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -895,225 +902,229 @@ msgstr ""
"C'est un texte d'exemple.\n"
"Si vous aimez ce texte, vous pouvez choisir cette fonte."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git Gui"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Créer nouveau référentiel"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Nouveau..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:460
msgid "Clone Existing Repository"
msgstr "Cloner référentiel existant"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Cloner..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:976
msgid "Open Existing Repository"
msgstr "Ouvrir référentiel existant"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Ouvrir..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Référentiels récents"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Ouvrir référentiel récent :"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "L'emplacement %s existe déjà."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "La création du référentiel %s a échouée :"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:478
msgid "Directory:"
msgstr "Répertoire :"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:412 lib/choose_repository.tcl:537
+#: lib/choose_repository.tcl:1011
msgid "Git Repository"
msgstr "Référentiel Git"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:437
#, tcl-format
msgid "Directory %s already exists."
msgstr "Le répertoire %s existe déjà."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:441
#, tcl-format
msgid "File %s already exists."
msgstr "Le fichier %s existe déjà."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:455
msgid "Clone"
msgstr "Cloner"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:468
msgid "URL:"
msgstr "URL :"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:489
msgid "Clone Type:"
msgstr "Type de clonage :"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:495
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Standard (rapide, semi-redondant, liens durs)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:501
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "Copy complète (plus lent, sauvegarde redondante)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:507
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Partagé (le plus rapide, non recommandé, pas de sauvegarde)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:543 lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:736 lib/choose_repository.tcl:806
+#: lib/choose_repository.tcl:1017 lib/choose_repository.tcl:1025
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "'%s' n'est pas un référentiel Git."
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:579
msgid "Standard only available for local repository."
msgstr "Standard n'est disponible que pour un référentiel local."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:583
msgid "Shared only available for local repository."
msgstr "Partagé n'est disponible que pour un référentiel local."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:604
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "L'emplacement %s existe déjà."
+
+#: lib/choose_repository.tcl:615
msgid "Failed to configure origin"
msgstr "La configuration de l'origine a échouée."
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:627
msgid "Counting objects"
msgstr "Comptage des objets"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:628
msgid "buckets"
msgstr "paniers"
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:652
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Impossible de copier 'objects/info/alternates' : %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:688
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Il n'y a rien à cloner depuis %s."
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:690 lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:916
msgid "The 'master' branch has not been initialized."
msgstr "Cette branche 'master' n'a pas été initialisée."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:703
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "Les liens durs ne sont pas disponibles. On se résoud à copier."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:715
#, tcl-format
msgid "Cloning from %s"
msgstr "Clonage depuis %s"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:746
msgid "Copying objects"
msgstr "Copie des objets"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:747
msgid "KiB"
msgstr "KiB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:771
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Impossible de copier l'objet : %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:781
msgid "Linking objects"
msgstr "Liaison des objets"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:782
msgid "objects"
msgstr "objets"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:790
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Impossible créer un lien dur pour l'objet : %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:845
msgid "Cannot fetch branches and objects. See console output for details."
-msgstr "Impossible de récupérer les branches et objets. Voir la sortie console pour plus de détails."
+msgstr ""
+"Impossible de récupérer les branches et objets. Voir la sortie console pour "
+"plus de détails."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:856
msgid "Cannot fetch tags. See console output for details."
-msgstr "Impossible de récupérer les marques. Voir la sortie console pour plus de détails."
+msgstr ""
+"Impossible de récupérer les marques. Voir la sortie console pour plus de "
+"détails."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:880
msgid "Cannot determine HEAD. See console output for details."
msgstr "Impossible de déterminer HEAD. Voir la sortie console pour plus de détails."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:889
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Impossible de nettoyer %s"
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:895
msgid "Clone failed."
msgstr "Le clonage a échoué."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:902
msgid "No default branch obtained."
msgstr "Aucune branche par défaut n'a été obtenue."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:913
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "Impossible de résoudre %s comme commit."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:925
msgid "Creating working directory"
msgstr "Création du répertoire de travail"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:926 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "fichiers"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:955
msgid "Initial file checkout failed."
msgstr "L'emprunt initial de fichier a échoué."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:971
msgid "Open"
msgstr "Ouvrir"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:981
msgid "Repository:"
msgstr "Référentiel :"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1031
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Impossible d'ouvrir le référentiel %s :"
@@ -1134,7 +1145,7 @@ msgstr "Branche locale"
msgid "Tracking Branch"
msgstr "Suivi de branche"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Marque"
@@ -1151,11 +1162,11 @@ msgstr "Pas de révision selectionnée."
msgid "Revision expression is empty."
msgstr "L'expression de révision est vide."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Misa à jour"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "URL"
@@ -1168,7 +1179,8 @@ msgid ""
msgstr ""
"Il n'y a rien à corriger.\n"
"\n"
-"Vous allez créer le commit initial. Il n'y a pas de commit avant celui-ci à corriger.\n"
+"Vous allez créer le commit initial. Il n'y a pas de commit avant celui-ci à "
+"corriger.\n"
#: lib/commit.tcl:18
msgid ""
@@ -1180,7 +1192,9 @@ msgid ""
msgstr ""
"Impossible de corriger pendant une fusion.\n"
"\n"
-"Vous êtes actuellement au milieu d'une fusion qui n'a pas été completement terminée. Vous ne pouvez pas corriger le commit précédant sauf si vous abandonnez la fusion courante.\n"
+"Vous êtes actuellement au milieu d'une fusion qui n'a pas été completement "
+"terminée. Vous ne pouvez pas corriger le commit précédant sauf si vous "
+"abandonnez la fusion courante.\n"
#: lib/commit.tcl:49
msgid "Error loading commit data for amend:"
@@ -1203,9 +1217,12 @@ msgid ""
"\n"
"The rescan will be automatically started now.\n"
msgstr ""
-"L'état lors de la dernière synchronisation ne correspond plus à l'état du référentiel.\n"
+"L'état lors de la dernière synchronisation ne correspond plus à l'état du "
+"référentiel.\n"
"\n"
-"Un autre programme Git a modifié ce référentiel depuis la dernière synchronisation. Une resynshronisation doit être effectuée avant de pouvoir créer un nouveau commit.\n"
+"Un autre programme Git a modifié ce référentiel depuis la dernière "
+"synchronisation. Une resynshronisation doit être effectuée avant de pouvoir "
+"créer un nouveau commit.\n"
"\n"
"Cela va être fait tout de suite automatiquement.\n"
@@ -1219,7 +1236,8 @@ msgid ""
msgstr ""
"Des fichiers non fusionnés ne peuvent être commités.\n"
"\n"
-"Le fichier %s a des conflicts de fusion. Vous devez les résoudre et pré-commiter le fichier avant de pouvoir commiter.\n"
+"Le fichier %s a des conflicts de fusion. Vous devez les résoudre et pré-"
+"commiter le fichier avant de pouvoir commiter.\n"
#: lib/commit.tcl:162
#, tcl-format
@@ -1260,16 +1278,45 @@ msgstr ""
"- Deuxième ligne : rien.\n"
"- Lignes suivantes : Décrire pourquoi ces modifications sont bonnes.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "attention : Tcl ne supporte pas l'encodage '%s'."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "Appel du programme externe d'avant commit..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "Commit refusé par le programme externe d'avant commit."
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "Appel du programme externe de message de commit..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "Commit refusé par le programme externe de message de commit."
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Commit des modifications..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "write-tree a échoué :"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Le commit a échoué."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "Le commit %s semble être corrompu"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1279,41 +1326,37 @@ msgid ""
msgstr ""
"Pas de modification à commiter.\n"
"\n"
-"Aucun fichier n'a été modifié par ce commit et il ne s'agit pas d'un commit de fusion.\n"
+"Aucun fichier n'a été modifié par ce commit et il ne s'agit pas d'un commit "
+"de fusion.\n"
"\n"
"Une resynchronisation va être lancée tout de suite automatiquement.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "Pas de modifications à commiter."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "attention : Tcl ne supporte pas l'encodage '%s'."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "commit-tree a échoué :"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "update-ref a échoué"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Commit créé %s : %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Travail en cours... merci de patienter..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "Succès"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Erreur : échec de la commande"
@@ -1345,7 +1388,7 @@ msgstr "Objets empaquetés attendant d'être supprimés"
msgid "Garbage files"
msgstr "Fichiers poubelle"
-#: lib/database.tcl:72ets
+#: lib/database.tcl:72
msgid "Compressing the object database"
msgstr "Compression de la base des objets"
@@ -1363,9 +1406,12 @@ msgid ""
"\n"
"Compress the database now?"
msgstr ""
-"Ce référentiel comprend actuellement environ %i objets ayant leur fichier particulier.\n"
+"Ce référentiel comprend actuellement environ %i objets ayant leur fichier "
+"particulier.\n"
"\n"
-"Pour conserver une performance optimale, il est fortement recommandé de comprimer la base quand plus de %i objets ayant leur fichier particulier existent.\n"
+"Pour conserver une performance optimale, il est fortement recommandé de "
+"comprimer la base quand plus de %i objets ayant leur fichier particulier "
+"existent.\n"
"\n"
"Comprimer la base maintenant ?"
@@ -1391,9 +1437,11 @@ msgstr ""
"\n"
"%s ne comporte aucune modification.\n"
"\n"
-"La date de modification de ce fichier a été mise à jour par une autre application, mais le contenu du fichier n'a pas changé.\n"
+"La date de modification de ce fichier a été mise à jour par une autre "
+"application, mais le contenu du fichier n'a pas changé.\n"
"\n"
-"Une resynchronisation va être lancée automatiquement pour trouver d'autres fichiers qui pourraient se trouver dans le même état."
+"Une resynchronisation va être lancée automatiquement pour trouver d'autres "
+"fichiers qui pourraient se trouver dans le même état."
#: lib/diff.tcl:81
#, tcl-format
@@ -1421,23 +1469,23 @@ msgstr "* Fichier binaire (pas d'apperçu du contenu)."
msgid "Error loading diff:"
msgstr "Erreur lors du chargement des différences :"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:303
msgid "Failed to unstage selected hunk."
msgstr "La suppression dans le pré-commit de la section sélectionnée a échouée."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:310
msgid "Failed to stage selected hunk."
msgstr "Le pré-commit de la section sélectionnée a échoué."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "erreur"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "attention"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr "Vous devez corriger les erreurs suivantes avant de pouvoir commiter."
@@ -1468,6 +1516,10 @@ msgstr "Dévérouiller le pré-commit"
msgid "Unstaging %s from commit"
msgstr "Supprimer %s du commit"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Prêt à être commité."
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1483,11 +1535,13 @@ msgstr "Inverser les modifications dans le fichier %s ? "
msgid "Revert changes in these %i files?"
msgstr "Inverser les modifications dans ces %i fichiers ?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
-msgstr "Toutes les modifications non pré-commitées seront définitivement perdues lors de l'inversion."
+msgstr ""
+"Toutes les modifications non pré-commitées seront définitivement perdues "
+"lors de l'inversion."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Ne rien faire"
@@ -1499,7 +1553,8 @@ msgid ""
msgstr ""
"Impossible de fucionner pendant une correction.\n"
"\n"
-"Vous devez finir de corriger ce commit avant de lancer une quelconque fusion.\n"
+"Vous devez finir de corriger ce commit avant de lancer une quelconque "
+"fusion.\n"
#: lib/merge.tcl:27
msgid ""
@@ -1510,9 +1565,12 @@ msgid ""
"\n"
"The rescan will be automatically started now.\n"
msgstr ""
-"L'état lors de la dernière synchronisation ne correspond plus à l'état du référentiel.\n"
+"L'état lors de la dernière synchronisation ne correspond plus à l'état du "
+"référentiel.\n"
"\n"
-"Un autre programme Git a modifié ce référentiel depuis la dernière synchronisation. Une resynchronisation doit être effectuée avant de pouvoir fusionner de nouveau.\n"
+"Un autre programme Git a modifié ce référentiel depuis la dernière "
+"synchronisation. Une resynchronisation doit être effectuée avant de pouvoir "
+"fusionner de nouveau.\n"
"\n"
"Cela va être fait tout de suite automatiquement\n"
@@ -1530,7 +1588,9 @@ msgstr ""
"\n"
"Le fichier %s a des conflicts de fusion.\n"
"\n"
-"Vous devez les résoudre, puis pré-commiter le fichier, et enfin commiter pour terminer la fusion courante. Seulementà ce moment là, il sera possible d'effectuer une nouvelle fusion.\n"
+"Vous devez les résoudre, puis pré-commiter le fichier, et enfin commiter "
+"pour terminer la fusion courante. Seulementà ce moment là, il sera possible "
+"d'effectuer une nouvelle fusion.\n"
#: lib/merge.tcl:54
#, tcl-format
@@ -1546,7 +1606,9 @@ msgstr ""
"\n"
"Le fichier %s est modifié.\n"
"\n"
-"Vous devriez terminer le commit courant avant de lancer une fusion. En faisait comme cela, vous éviterez de devoir éventuellement abandonner une fusion ayant échouée.\n"
+"Vous devriez terminer le commit courant avant de lancer une fusion. En "
+"faisait comme cela, vous éviterez de devoir éventuellement abandonner une "
+"fusion ayant échouée.\n"
#: lib/merge.tcl:106
#, tcl-format
@@ -1555,27 +1617,27 @@ msgstr "%s de %s"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "Fusion de %s et %s"
+msgid "Merging %s and %s..."
+msgstr "Fusion de %s et %s..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "La fusion s'est faite avec succès."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "La fusion a echouée. Il est nécessaire de résoudre les conflicts."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "Fusion dans %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "Révision à fusionner"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1585,7 +1647,7 @@ msgstr ""
"\n"
"Vous devez finir de corriger ce commit.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1595,11 +1657,12 @@ msgid ""
msgstr ""
"Abandonner la fusion ?\n"
"\n"
-"Abandonner la fusion courante entrainera la perte de TOUTES les modifications non commitées.\n"
+"Abandonner la fusion courante entrainera la perte de TOUTES les "
+"modifications non commitées.\n"
"\n"
"Abandonner quand même la fusion courante ?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1609,97 +1672,110 @@ msgid ""
msgstr ""
"Réinitialiser les modifications ?\n"
"\n"
-"Réinitialiser les modifications va faire perdre TOUTES les modifications non commitées.\n"
+"Réinitialiser les modifications va faire perdre TOUTES les modifications non "
+"commitées.\n"
"\n"
"Réinitialiser quand même les modifications courantes ?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "Abandon"
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "fichiers réinitialisés"
+
+#: lib/merge.tcl:265
msgid "Abort failed."
msgstr "L'abandon a échoué."
-#: lib/merge.tcl:268
+#: lib/merge.tcl:267
msgid "Abort completed. Ready."
msgstr "Abandon teminé. Prêt."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "Remettre les valeurs par défaut"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Sauvegarder"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "Référentiel de %s"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Globales (tous les référentiels)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Nom d'utilisateur"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "Adresse email"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "Résumer les commits de fusion"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Fusion bavarde"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Montrer statistiques de diff après fusion"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "Faire confiance aux dates de modification de fichiers "
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr "Nettoyer les branches de suivi pendant la récupération"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "Faire correspondre les branches de suivi"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
msgid "Number of Diff Context Lines"
msgstr "Nombre de lignes de contexte dans les diffs"
-#: lib/option.tcl:114
+#: lib/option.tcl:127
+msgid "Commit Message Text Width"
+msgstr "Largeur du texte de message de commit"
+
+#: lib/option.tcl:128
msgid "New Branch Name Template"
msgstr "Nouveau modèle de nom de branche"
-#: lib/option.tcl:176
+#: lib/option.tcl:192
+msgid "Spelling Dictionary:"
+msgstr "Dictionnaire d'orthographe :"
+
+#: lib/option.tcl:216
msgid "Change Font"
msgstr "Modifier les fontes"
-#: lib/option.tcl:180
+#: lib/option.tcl:220
#, tcl-format
msgid "Choose %s"
msgstr "Choisir %s"
-#: lib/option.tcl:186
+#: lib/option.tcl:226
msgid "pt."
msgstr "pt."
-#: lib/option.tcl:200
+#: lib/option.tcl:240
msgid "Preferences"
msgstr "Préférences"
-#: lib/option.tcl:235
+#: lib/option.tcl:275
msgid "Failed to completely save options:"
msgstr "La sauvegarde complète des options a échouée :"
@@ -1755,7 +1831,9 @@ msgstr ""
msgid ""
"One or more of the merge tests failed because you have not fetched the "
"necessary commits. Try fetching from %s first."
-msgstr "Une ou plusieurs des tests de fusion ont échoués parce que vous n'avez pas récupéré les commits nécessaires. Essayez de récupéré à partir de %s d'abord."
+msgstr ""
+"Une ou plusieurs des tests de fusion ont échoués parce que vous n'avez pas "
+"récupéré les commits nécessaires. Essayez de récupéré à partir de %s d'abord."
#: lib/remote_branch_delete.tcl:207
msgid "Please select one or more branches to delete."
@@ -1805,6 +1883,43 @@ msgstr "Impossible d'écrire le raccourcis :"
msgid "Cannot write icon:"
msgstr "Impossible d'écrire l'icône :"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "Vérificateur d'orthographe non supporté"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "La vérification d'orthographe n'est pas disponible"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "Configuration de vérification d'orthographe invalide"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Réinitialisation du dictionnaire à %s."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "La vérification d'orthographe a échouée silentieusement au démarrage"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "Vérificateur d'orthographe non reconnu"
+
+#: lib/spellcheck.tcl:180
+msgid "No Suggestions"
+msgstr "Aucune suggestion"
+
+#: lib/spellcheck.tcl:381
+msgid "Unexpected EOF from spell checker"
+msgstr "Fin de fichier innatendue envoyée par le vérificateur d'orthographe"
+
+#: lib/spellcheck.tcl:385
+msgid "Spell Checker Failed"
+msgstr "Le vérificateur d'orthographe a échoué"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
@@ -1863,7 +1978,9 @@ msgstr "Transférer options"
#: lib/transport.tcl:160
msgid "Force overwrite existing branch (may discard changes)"
-msgstr "Forcer l'écrasement d'une branche existante (peut supprimer des modifications)"
+msgstr ""
+"Forcer l'écrasement d'une branche existante (peut supprimer des "
+"modifications)"
#: lib/transport.tcl:164
msgid "Use thin pack (for slow network connections)"
diff --git a/git-gui/po/git-gui.pot b/git-gui/po/git-gui.pot
index dfa48ae26..e295000e7 100644
--- a/git-gui/po/git-gui.pot
+++ b/git-gui/po/git-gui.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
+"POT-Creation-Date: 2008-08-02 14:45-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,33 +16,33 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:688 git-gui.sh:702 git-gui.sh:715 git-gui.sh:798
+#: git-gui.sh:817
msgid "git-gui: fatal error"
msgstr ""
-#: git-gui.sh:565
+#: git-gui.sh:644
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr ""
-#: git-gui.sh:590
+#: git-gui.sh:674
msgid "Main Font"
msgstr ""
-#: git-gui.sh:591
+#: git-gui.sh:675
msgid "Diff/Console Font"
msgstr ""
-#: git-gui.sh:605
+#: git-gui.sh:689
msgid "Cannot find git in PATH."
msgstr ""
-#: git-gui.sh:632
+#: git-gui.sh:716
msgid "Cannot parse Git version string:"
msgstr ""
-#: git-gui.sh:650
+#: git-gui.sh:734
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -54,375 +54,379 @@ msgid ""
"Assume '%s' is version 1.5.0?\n"
msgstr ""
-#: git-gui.sh:888
+#: git-gui.sh:972
msgid "Git directory not found:"
msgstr ""
-#: git-gui.sh:895
+#: git-gui.sh:979
msgid "Cannot move to top of working directory:"
msgstr ""
-#: git-gui.sh:902
+#: git-gui.sh:986
msgid "Cannot use funny .git directory:"
msgstr ""
-#: git-gui.sh:907
+#: git-gui.sh:991
msgid "No working directory"
msgstr ""
-#: git-gui.sh:1054
+#: git-gui.sh:1138 lib/checkout_op.tcl:305
msgid "Refreshing file status..."
msgstr ""
-#: git-gui.sh:1119
+#: git-gui.sh:1194
msgid "Scanning for modified files ..."
msgstr ""
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1369 lib/browser.tcl:246
msgid "Ready."
msgstr ""
-#: git-gui.sh:1560
+#: git-gui.sh:1635
msgid "Unmodified"
msgstr ""
-#: git-gui.sh:1562
+#: git-gui.sh:1637
msgid "Modified, not staged"
msgstr ""
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1638 git-gui.sh:1643
msgid "Staged for commit"
msgstr ""
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1639 git-gui.sh:1644
msgid "Portions staged for commit"
msgstr ""
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1640 git-gui.sh:1645
msgid "Staged for commit, missing"
msgstr ""
-#: git-gui.sh:1567
+#: git-gui.sh:1642
msgid "Untracked, not staged"
msgstr ""
-#: git-gui.sh:1572
+#: git-gui.sh:1647
msgid "Missing"
msgstr ""
-#: git-gui.sh:1573
+#: git-gui.sh:1648
msgid "Staged for removal"
msgstr ""
-#: git-gui.sh:1574
+#: git-gui.sh:1649
msgid "Staged for removal, still present"
msgstr ""
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1651 git-gui.sh:1652 git-gui.sh:1653 git-gui.sh:1654
msgid "Requires merge resolution"
msgstr ""
-#: git-gui.sh:1614
+#: git-gui.sh:1689
msgid "Starting gitk... please wait..."
msgstr ""
-#: git-gui.sh:1623
-#, tcl-format
-msgid ""
-"Unable to start gitk:\n"
-"\n"
-"%s does not exist"
+#: git-gui.sh:1698
+msgid "Couldn't find gitk in PATH"
msgstr ""
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1948 lib/choose_repository.tcl:36
msgid "Repository"
msgstr ""
-#: git-gui.sh:1824
+#: git-gui.sh:1949
msgid "Edit"
msgstr ""
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1951 lib/choose_rev.tcl:561
msgid "Branch"
msgstr ""
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1954 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr ""
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1957 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr ""
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1958 lib/choose_rev.tcl:557
msgid "Remote"
msgstr ""
-#: git-gui.sh:1842
+#: git-gui.sh:1967
msgid "Browse Current Branch's Files"
msgstr ""
-#: git-gui.sh:1846
+#: git-gui.sh:1971
msgid "Browse Branch Files..."
msgstr ""
-#: git-gui.sh:1851
+#: git-gui.sh:1976
msgid "Visualize Current Branch's History"
msgstr ""
-#: git-gui.sh:1855
+#: git-gui.sh:1980
msgid "Visualize All Branch History"
msgstr ""
-#: git-gui.sh:1862
+#: git-gui.sh:1987
#, tcl-format
msgid "Browse %s's Files"
msgstr ""
-#: git-gui.sh:1864
+#: git-gui.sh:1989
#, tcl-format
msgid "Visualize %s's History"
msgstr ""
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1994 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr ""
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1997 lib/database.tcl:34
msgid "Compress Database"
msgstr ""
-#: git-gui.sh:1875
+#: git-gui.sh:2000
msgid "Verify Database"
msgstr ""
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:2007 git-gui.sh:2011 git-gui.sh:2015 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr ""
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:2023 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr ""
-#: git-gui.sh:1902
+#: git-gui.sh:2031
msgid "Undo"
msgstr ""
-#: git-gui.sh:1905
+#: git-gui.sh:2034
msgid "Redo"
msgstr ""
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:2038 git-gui.sh:2545
msgid "Cut"
msgstr ""
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:2041 git-gui.sh:2548 git-gui.sh:2622 git-gui.sh:2715
+#: lib/console.tcl:69
msgid "Copy"
msgstr ""
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:2044 git-gui.sh:2551
msgid "Paste"
msgstr ""
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:2047 git-gui.sh:2554 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr ""
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:2051 git-gui.sh:2558 git-gui.sh:2719 lib/console.tcl:71
msgid "Select All"
msgstr ""
-#: git-gui.sh:1931
+#: git-gui.sh:2060
msgid "Create..."
msgstr ""
-#: git-gui.sh:1937
+#: git-gui.sh:2066
msgid "Checkout..."
msgstr ""
-#: git-gui.sh:1943
+#: git-gui.sh:2072
msgid "Rename..."
msgstr ""
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:2077 git-gui.sh:2187
msgid "Delete..."
msgstr ""
-#: git-gui.sh:1953
+#: git-gui.sh:2082
msgid "Reset..."
msgstr ""
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2094 git-gui.sh:2491
msgid "New Commit"
msgstr ""
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2102 git-gui.sh:2498
msgid "Amend Last Commit"
msgstr ""
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2111 git-gui.sh:2458 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr ""
-#: git-gui.sh:1988
+#: git-gui.sh:2117
msgid "Stage To Commit"
msgstr ""
-#: git-gui.sh:1994
+#: git-gui.sh:2123
msgid "Stage Changed Files To Commit"
msgstr ""
-#: git-gui.sh:2000
+#: git-gui.sh:2129
msgid "Unstage From Commit"
msgstr ""
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2134 lib/index.tcl:395
msgid "Revert Changes"
msgstr ""
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2141 git-gui.sh:2702
+msgid "Show Less Context"
+msgstr ""
+
+#: git-gui.sh:2145 git-gui.sh:2706
+msgid "Show More Context"
+msgstr ""
+
+#: git-gui.sh:2151 git-gui.sh:2470 git-gui.sh:2569
msgid "Sign Off"
msgstr ""
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2155 git-gui.sh:2474
msgid "Commit@@verb"
msgstr ""
-#: git-gui.sh:2027
+#: git-gui.sh:2166
msgid "Local Merge..."
msgstr ""
-#: git-gui.sh:2032
+#: git-gui.sh:2171
msgid "Abort Merge..."
msgstr ""
-#: git-gui.sh:2044
+#: git-gui.sh:2183
msgid "Push..."
msgstr ""
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
-msgid "Apple"
-msgstr ""
-
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2197 git-gui.sh:2219 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr ""
-#: git-gui.sh:2062
+#: git-gui.sh:2201
msgid "Preferences..."
msgstr ""
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2209 git-gui.sh:2740
msgid "Options..."
msgstr ""
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2215 lib/choose_repository.tcl:47
msgid "Help"
msgstr ""
-#: git-gui.sh:2117
+#: git-gui.sh:2256
msgid "Online Documentation"
msgstr ""
-#: git-gui.sh:2201
+#: git-gui.sh:2340
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
msgstr ""
-#: git-gui.sh:2234
+#: git-gui.sh:2373
msgid "Current Branch:"
msgstr ""
-#: git-gui.sh:2255
+#: git-gui.sh:2394
msgid "Staged Changes (Will Commit)"
msgstr ""
-#: git-gui.sh:2274
+#: git-gui.sh:2414
msgid "Unstaged Changes"
msgstr ""
-#: git-gui.sh:2323
+#: git-gui.sh:2464
msgid "Stage Changed"
msgstr ""
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2480 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr ""
-#: git-gui.sh:2369
+#: git-gui.sh:2510
msgid "Initial Commit Message:"
msgstr ""
-#: git-gui.sh:2370
+#: git-gui.sh:2511
msgid "Amended Commit Message:"
msgstr ""
-#: git-gui.sh:2371
+#: git-gui.sh:2512
msgid "Amended Initial Commit Message:"
msgstr ""
-#: git-gui.sh:2372
+#: git-gui.sh:2513
msgid "Amended Merge Commit Message:"
msgstr ""
-#: git-gui.sh:2373
+#: git-gui.sh:2514
msgid "Merge Commit Message:"
msgstr ""
-#: git-gui.sh:2374
+#: git-gui.sh:2515
msgid "Commit Message:"
msgstr ""
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2561 git-gui.sh:2723 lib/console.tcl:73
msgid "Copy All"
msgstr ""
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2585 lib/blame.tcl:100
msgid "File:"
msgstr ""
-#: git-gui.sh:2545
-msgid "Refresh"
+#: git-gui.sh:2691
+msgid "Apply/Reverse Hunk"
msgstr ""
-#: git-gui.sh:2566
-msgid "Apply/Reverse Hunk"
+#: git-gui.sh:2696
+msgid "Apply/Reverse Line"
msgstr ""
-#: git-gui.sh:2572
+#: git-gui.sh:2711
+msgid "Refresh"
+msgstr ""
+
+#: git-gui.sh:2732
msgid "Decrease Font Size"
msgstr ""
-#: git-gui.sh:2576
+#: git-gui.sh:2736
msgid "Increase Font Size"
msgstr ""
-#: git-gui.sh:2581
-msgid "Show Less Context"
+#: git-gui.sh:2747
+msgid "Unstage Hunk From Commit"
msgstr ""
-#: git-gui.sh:2588
-msgid "Show More Context"
+#: git-gui.sh:2748
+msgid "Unstage Line From Commit"
msgstr ""
-#: git-gui.sh:2602
-msgid "Unstage Hunk From Commit"
+#: git-gui.sh:2750
+msgid "Stage Hunk For Commit"
msgstr ""
-#: git-gui.sh:2604
-msgid "Stage Hunk For Commit"
+#: git-gui.sh:2751
+msgid "Stage Line For Commit"
msgstr ""
-#: git-gui.sh:2623
+#: git-gui.sh:2771
msgid "Initializing..."
msgstr ""
-#: git-gui.sh:2718
+#: git-gui.sh:2876
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -433,14 +437,14 @@ msgid ""
"\n"
msgstr ""
-#: git-gui.sh:2748
+#: git-gui.sh:2906
msgid ""
"\n"
"This is due to a known issue with the\n"
"Tcl binary distributed by Cygwin."
msgstr ""
-#: git-gui.sh:2753
+#: git-gui.sh:2911
#, tcl-format
msgid ""
"\n"
@@ -451,68 +455,84 @@ msgid ""
"~/.gitconfig file.\n"
msgstr ""
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr ""
-#: lib/blame.tcl:77
+#: lib/blame.tcl:70
msgid "File Viewer"
msgstr ""
-#: lib/blame.tcl:81
+#: lib/blame.tcl:74
msgid "Commit:"
msgstr ""
-#: lib/blame.tcl:249
+#: lib/blame.tcl:257
msgid "Copy Commit"
msgstr ""
-#: lib/blame.tcl:369
+#: lib/blame.tcl:260
+msgid "Do Full Copy Detection"
+msgstr ""
+
+#: lib/blame.tcl:388
#, tcl-format
msgid "Reading %s..."
msgstr ""
-#: lib/blame.tcl:473
+#: lib/blame.tcl:492
msgid "Loading copy/move tracking annotations..."
msgstr ""
-#: lib/blame.tcl:493
+#: lib/blame.tcl:512
msgid "lines annotated"
msgstr ""
-#: lib/blame.tcl:674
+#: lib/blame.tcl:704
msgid "Loading original location annotations..."
msgstr ""
-#: lib/blame.tcl:677
+#: lib/blame.tcl:707
msgid "Annotation complete."
msgstr ""
-#: lib/blame.tcl:731
+#: lib/blame.tcl:737
+msgid "Busy"
+msgstr ""
+
+#: lib/blame.tcl:738
+msgid "Annotation process is already running."
+msgstr ""
+
+#: lib/blame.tcl:777
+msgid "Running thorough copy detection..."
+msgstr ""
+
+#: lib/blame.tcl:827
msgid "Loading annotation..."
msgstr ""
-#: lib/blame.tcl:787
+#: lib/blame.tcl:883
msgid "Author:"
msgstr ""
-#: lib/blame.tcl:791
+#: lib/blame.tcl:887
msgid "Committer:"
msgstr ""
-#: lib/blame.tcl:796
+#: lib/blame.tcl:892
msgid "Original File:"
msgstr ""
-#: lib/blame.tcl:910
+#: lib/blame.tcl:1006
msgid "Originally By:"
msgstr ""
-#: lib/blame.tcl:916
+#: lib/blame.tcl:1012
msgid "In File:"
msgstr ""
-#: lib/blame.tcl:921
+#: lib/blame.tcl:1017
msgid "Copied Or Moved Here By:"
msgstr ""
@@ -525,17 +545,17 @@ msgid "Checkout"
msgstr ""
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:544 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr ""
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr ""
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:244
msgid "Options"
msgstr ""
@@ -555,7 +575,7 @@ msgstr ""
msgid "Create New Branch"
msgstr ""
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr ""
@@ -587,7 +607,7 @@ msgstr ""
msgid "Fast Forward Only"
msgstr ""
-#: lib/branch_create.tcl:85 lib/checkout_op.tcl:514
+#: lib/branch_create.tcl:85 lib/checkout_op.tcl:536
msgid "Reset"
msgstr ""
@@ -672,7 +692,7 @@ msgstr ""
msgid "Please select a branch to rename."
msgstr ""
-#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:179
+#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:201
#, tcl-format
msgid "Branch '%s' already exists."
msgstr ""
@@ -690,45 +710,50 @@ msgstr ""
msgid "File Browser"
msgstr ""
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr ""
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr ""
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr ""
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:472 lib/choose_repository.tcl:482
+#: lib/choose_repository.tcl:985
msgid "Browse"
msgstr ""
-#: lib/checkout_op.tcl:79
+#: lib/checkout_op.tcl:84
#, tcl-format
msgid "Fetching %s from %s"
msgstr ""
-#: lib/checkout_op.tcl:127
+#: lib/checkout_op.tcl:132
#, tcl-format
msgid "fatal: Cannot resolve %s"
msgstr ""
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:145 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr ""
-#: lib/checkout_op.tcl:169
+#: lib/checkout_op.tcl:174
#, tcl-format
msgid "Branch '%s' does not exist."
msgstr ""
-#: lib/checkout_op.tcl:206
+#: lib/checkout_op.tcl:193
+#, tcl-format
+msgid "Failed to configure simplified git-pull for '%s'."
+msgstr ""
+
+#: lib/checkout_op.tcl:228
#, tcl-format
msgid ""
"Branch '%s' already exists.\n"
@@ -737,21 +762,21 @@ msgid ""
"A merge is required."
msgstr ""
-#: lib/checkout_op.tcl:220
+#: lib/checkout_op.tcl:242
#, tcl-format
msgid "Merge strategy '%s' not supported."
msgstr ""
-#: lib/checkout_op.tcl:239
+#: lib/checkout_op.tcl:261
#, tcl-format
msgid "Failed to update '%s'."
msgstr ""
-#: lib/checkout_op.tcl:251
+#: lib/checkout_op.tcl:273
msgid "Staging area (index) is already locked."
msgstr ""
-#: lib/checkout_op.tcl:266
+#: lib/checkout_op.tcl:288
msgid ""
"Last scanned state does not match repository state.\n"
"\n"
@@ -761,26 +786,30 @@ msgid ""
"The rescan will be automatically started now.\n"
msgstr ""
-#: lib/checkout_op.tcl:322
+#: lib/checkout_op.tcl:344
#, tcl-format
msgid "Updating working directory to '%s'..."
msgstr ""
-#: lib/checkout_op.tcl:353
+#: lib/checkout_op.tcl:345
+msgid "files checked out"
+msgstr ""
+
+#: lib/checkout_op.tcl:375
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
msgstr ""
-#: lib/checkout_op.tcl:354
+#: lib/checkout_op.tcl:376
msgid "File level merge required."
msgstr ""
-#: lib/checkout_op.tcl:358
+#: lib/checkout_op.tcl:380
#, tcl-format
msgid "Staying on branch '%s'."
msgstr ""
-#: lib/checkout_op.tcl:429
+#: lib/checkout_op.tcl:451
msgid ""
"You are no longer on a local branch.\n"
"\n"
@@ -788,30 +817,30 @@ msgid ""
"Checkout'."
msgstr ""
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:468 lib/checkout_op.tcl:472
#, tcl-format
msgid "Checked out '%s'."
msgstr ""
-#: lib/checkout_op.tcl:478
+#: lib/checkout_op.tcl:500
#, tcl-format
msgid "Resetting '%s' to '%s' will lose the following commits:"
msgstr ""
-#: lib/checkout_op.tcl:500
+#: lib/checkout_op.tcl:522
msgid "Recovering lost commits may not be easy."
msgstr ""
-#: lib/checkout_op.tcl:505
+#: lib/checkout_op.tcl:527
#, tcl-format
msgid "Reset '%s'?"
msgstr ""
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:532 lib/merge.tcl:163
msgid "Visualize"
msgstr ""
-#: lib/checkout_op.tcl:578
+#: lib/checkout_op.tcl:600
#, tcl-format
msgid ""
"Failed to set current branch.\n"
@@ -830,239 +859,239 @@ msgstr ""
msgid "Font Family"
msgstr ""
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr ""
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr ""
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
msgstr ""
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr ""
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr ""
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr ""
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:458
msgid "Clone Existing Repository"
msgstr ""
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr ""
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:974
msgid "Open Existing Repository"
msgstr ""
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr ""
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr ""
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr ""
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr ""
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr ""
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:476
msgid "Directory:"
msgstr ""
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:410 lib/choose_repository.tcl:535
+#: lib/choose_repository.tcl:1007
msgid "Git Repository"
msgstr ""
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:435
#, tcl-format
msgid "Directory %s already exists."
msgstr ""
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:439
#, tcl-format
msgid "File %s already exists."
msgstr ""
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:453
msgid "Clone"
msgstr ""
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:466
msgid "URL:"
msgstr ""
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:487
msgid "Clone Type:"
msgstr ""
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:493
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr ""
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:499
msgid "Full Copy (Slower, Redundant Backup)"
msgstr ""
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:505
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr ""
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:541 lib/choose_repository.tcl:588
+#: lib/choose_repository.tcl:734 lib/choose_repository.tcl:804
+#: lib/choose_repository.tcl:1013 lib/choose_repository.tcl:1021
#, tcl-format
msgid "Not a Git repository: %s"
msgstr ""
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:577
msgid "Standard only available for local repository."
msgstr ""
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:581
msgid "Shared only available for local repository."
msgstr ""
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:602
+#, tcl-format
+msgid "Location %s already exists."
+msgstr ""
+
+#: lib/choose_repository.tcl:613
msgid "Failed to configure origin"
msgstr ""
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:625
msgid "Counting objects"
msgstr ""
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:626
msgid "buckets"
msgstr ""
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:650
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr ""
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:686
#, tcl-format
msgid "Nothing to clone from %s."
msgstr ""
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:688 lib/choose_repository.tcl:902
+#: lib/choose_repository.tcl:914
msgid "The 'master' branch has not been initialized."
msgstr ""
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:701
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr ""
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:713
#, tcl-format
msgid "Cloning from %s"
msgstr ""
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:744
msgid "Copying objects"
msgstr ""
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:745
msgid "KiB"
msgstr ""
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:769
#, tcl-format
msgid "Unable to copy object: %s"
msgstr ""
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:779
msgid "Linking objects"
msgstr ""
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:780
msgid "objects"
msgstr ""
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:788
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr ""
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:843
msgid "Cannot fetch branches and objects. See console output for details."
msgstr ""
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:854
msgid "Cannot fetch tags. See console output for details."
msgstr ""
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:878
msgid "Cannot determine HEAD. See console output for details."
msgstr ""
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:887
#, tcl-format
msgid "Unable to cleanup %s"
msgstr ""
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:893
msgid "Clone failed."
msgstr ""
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:900
msgid "No default branch obtained."
msgstr ""
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:911
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr ""
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:923
msgid "Creating working directory"
msgstr ""
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:924 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr ""
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:953
msgid "Initial file checkout failed."
msgstr ""
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:969
msgid "Open"
msgstr ""
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:979
msgid "Repository:"
msgstr ""
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1027
#, tcl-format
msgid "Failed to open repository %s:"
msgstr ""
@@ -1083,7 +1112,7 @@ msgstr ""
msgid "Tracking Branch"
msgstr ""
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr ""
@@ -1100,11 +1129,11 @@ msgstr ""
msgid "Revision expression is empty."
msgstr ""
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr ""
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr ""
@@ -1182,16 +1211,45 @@ msgid ""
"- Remaining lines: Describe why this change is good.\n"
msgstr ""
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr ""
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr ""
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr ""
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr ""
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr ""
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr ""
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr ""
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr ""
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr ""
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1200,37 +1258,32 @@ msgid ""
"A rescan will be automatically started now.\n"
msgstr ""
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr ""
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr ""
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr ""
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr ""
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr ""
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr ""
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr ""
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr ""
@@ -1286,7 +1339,7 @@ msgstr ""
msgid "Invalid date from Git: %s"
msgstr ""
-#: lib/diff.tcl:42
+#: lib/diff.tcl:44
#, tcl-format
msgid ""
"No differences detected.\n"
@@ -1300,49 +1353,57 @@ msgid ""
"the same state."
msgstr ""
-#: lib/diff.tcl:81
+#: lib/diff.tcl:83
#, tcl-format
msgid "Loading diff of %s..."
msgstr ""
-#: lib/diff.tcl:114 lib/diff.tcl:184
+#: lib/diff.tcl:116 lib/diff.tcl:190
#, tcl-format
msgid "Unable to display %s"
msgstr ""
-#: lib/diff.tcl:115
+#: lib/diff.tcl:117
msgid "Error loading file:"
msgstr ""
-#: lib/diff.tcl:122
+#: lib/diff.tcl:124
msgid "Git Repository (subproject)"
msgstr ""
-#: lib/diff.tcl:134
+#: lib/diff.tcl:136
msgid "* Binary file (not showing content)."
msgstr ""
-#: lib/diff.tcl:185
+#: lib/diff.tcl:191
msgid "Error loading diff:"
msgstr ""
-#: lib/diff.tcl:302
+#: lib/diff.tcl:313
msgid "Failed to unstage selected hunk."
msgstr ""
-#: lib/diff.tcl:309
+#: lib/diff.tcl:320
msgid "Failed to stage selected hunk."
msgstr ""
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/diff.tcl:386
+msgid "Failed to unstage selected line."
+msgstr ""
+
+#: lib/diff.tcl:394
+msgid "Failed to stage selected line."
+msgstr ""
+
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr ""
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr ""
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr ""
@@ -1373,6 +1434,10 @@ msgstr ""
msgid "Unstaging %s from commit"
msgstr ""
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr ""
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1388,11 +1453,11 @@ msgstr ""
msgid "Revert changes in these %i files?"
msgstr ""
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
msgstr ""
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr ""
@@ -1442,34 +1507,34 @@ msgstr ""
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
+msgid "Merging %s and %s..."
msgstr ""
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr ""
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr ""
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr ""
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr ""
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
"You must finish amending this commit.\n"
msgstr ""
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1478,7 +1543,7 @@ msgid ""
"Continue with aborting the current merge?"
msgstr ""
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1487,10 +1552,14 @@ msgid ""
"Continue with resetting the current changes?"
msgstr ""
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr ""
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr ""
+
#: lib/merge.tcl:266
msgid "Abort failed."
msgstr ""
@@ -1499,84 +1568,112 @@ msgstr ""
msgid "Abort completed. Ready."
msgstr ""
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr ""
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr ""
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr ""
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr ""
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr ""
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr ""
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr ""
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr ""
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr ""
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr ""
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr ""
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr ""
-#: lib/option.tcl:113
+#: lib/option.tcl:126
+msgid "Blame Copy Only On Changed Files"
+msgstr ""
+
+#: lib/option.tcl:127
+msgid "Minimum Letters To Blame Copy On"
+msgstr ""
+
+#: lib/option.tcl:128
msgid "Number of Diff Context Lines"
msgstr ""
-#: lib/option.tcl:114
+#: lib/option.tcl:129
+msgid "Commit Message Text Width"
+msgstr ""
+
+#: lib/option.tcl:130
msgid "New Branch Name Template"
msgstr ""
-#: lib/option.tcl:176
+#: lib/option.tcl:194
+msgid "Spelling Dictionary:"
+msgstr ""
+
+#: lib/option.tcl:218
msgid "Change Font"
msgstr ""
-#: lib/option.tcl:180
+#: lib/option.tcl:222
#, tcl-format
msgid "Choose %s"
msgstr ""
-#: lib/option.tcl:186
+#: lib/option.tcl:228
msgid "pt."
msgstr ""
-#: lib/option.tcl:200
+#: lib/option.tcl:242
msgid "Preferences"
msgstr ""
-#: lib/option.tcl:235
+#: lib/option.tcl:277
msgid "Failed to completely save options:"
msgstr ""
+#: lib/remote.tcl:165
+msgid "Prune from"
+msgstr ""
+
+#: lib/remote.tcl:170
+msgid "Fetch from"
+msgstr ""
+
+#: lib/remote.tcl:213
+msgid "Push to"
+msgstr ""
+
#: lib/remote_branch_delete.tcl:29 lib/remote_branch_delete.tcl:34
msgid "Delete Remote Branch"
msgstr ""
@@ -1653,24 +1750,49 @@ msgstr ""
msgid "Scanning %s..."
msgstr ""
-#: lib/remote.tcl:165
-msgid "Prune from"
+#: lib/shortcut.tcl:20 lib/shortcut.tcl:61
+msgid "Cannot write shortcut:"
msgstr ""
-#: lib/remote.tcl:170
-msgid "Fetch from"
+#: lib/shortcut.tcl:136
+msgid "Cannot write icon:"
msgstr ""
-#: lib/remote.tcl:213
-msgid "Push to"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
msgstr ""
-#: lib/shortcut.tcl:20 lib/shortcut.tcl:61
-msgid "Cannot write shortcut:"
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
msgstr ""
-#: lib/shortcut.tcl:136
-msgid "Cannot write icon:"
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr ""
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr ""
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr ""
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr ""
+
+#: lib/spellcheck.tcl:186
+msgid "No Suggestions"
+msgstr ""
+
+#: lib/spellcheck.tcl:387
+msgid "Unexpected EOF from spell checker"
+msgstr ""
+
+#: lib/spellcheck.tcl:391
+msgid "Spell Checker Failed"
msgstr ""
#: lib/status_bar.tcl:83
diff --git a/git-gui/po/glossary/de.po b/git-gui/po/glossary/de.po
index 0b33c572b..35764d1d2 100644
--- a/git-gui/po/glossary/de.po
+++ b/git-gui/po/glossary/de.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui glossary\n"
"POT-Creation-Date: 2008-01-07 21:20+0100\n"
-"PO-Revision-Date: 2008-01-15 20:32+0100\n"
+"PO-Revision-Date: 2008-02-16 21:48+0100\n"
"Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
"Language-Team: German \n"
"MIME-Version: 1.0\n"
@@ -114,7 +114,7 @@ msgstr "Beschreibung (Meldung?, Nachricht?; Source Safe: Kommentar)"
#. "Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in 'remotes/<name>'."
msgid "prune"
-msgstr "entfernen"
+msgstr "aufräumen (entfernen?)"
#. "Pulling a branch means to fetch it and merge it."
msgid "pull"
diff --git a/git-gui/po/glossary/fr.po b/git-gui/po/glossary/fr.po
index bb2feaf13..27c006abb 100644
--- a/git-gui/po/glossary/fr.po
+++ b/git-gui/po/glossary/fr.po
@@ -34,7 +34,7 @@ msgstr "branche"
#. ""
msgid "branch [verb]"
-msgstr "créer une branche"
+msgstr "créer une branche"
#. ""
msgid "checkout [noun]"
@@ -58,7 +58,7 @@ msgstr "commiter"
#. ""
msgid "diff [noun]"
-msgstr "différence"
+msgstr "différence"
#. ""
msgid "diff [verb]"
@@ -70,11 +70,11 @@ msgstr "fusion par avance rapide"
#. "Fetching a branch means to get the branch's head from a remote repository, to find out which objects are missing from the local object database, and to get them, too."
msgid "fetch"
-msgstr "récupérer"
+msgstr "récupérer"
#. "A collection of files. The index is a stored version of your working tree."
msgid "index (in git-gui: staging area)"
-msgstr "pré-commit"
+msgstr "pré-commit"
#. "A successful merge results in the creation of a new commit representing the result of the merge."
msgid "merge [noun]"
@@ -106,15 +106,15 @@ msgstr "refaire"
#. "An other repository ('remote'). One might have a set of remotes whose branches one tracks."
msgid "remote"
-msgstr "référentiel distant"
+msgstr "référentiel distant"
#. "A collection of refs (?) together with an object database containing all objects which are reachable from the refs... (oops, you've lost me here. Again, please an explanation for mere mortals?)"
msgid "repository"
-msgstr "référentiel"
+msgstr "référentiel"
#. ""
msgid "reset"
-msgstr "réinitialiser"
+msgstr "réinitialiser"
#. ""
msgid "revert"
@@ -122,7 +122,7 @@ msgstr "inverser"
#. "A particular state of files and directories which was stored in the object database."
msgid "revision"
-msgstr "révision"
+msgstr "révision"
#. ""
msgid "sign off"
@@ -130,11 +130,11 @@ msgstr "signer"
#. ""
msgid "staging area"
-msgstr "pré-commit"
+msgstr "pré-commit"
#. ""
msgid "status"
-msgstr "état"
+msgstr "état"
#. "A ref pointing to a tag or commit object"
msgid "tag [noun]"
@@ -150,15 +150,15 @@ msgstr "branche de suivi"
#. ""
msgid "undo"
-msgstr "défaire"
+msgstr "défaire"
#. ""
msgid "update"
-msgstr "mise à jour"
+msgstr "mise à jour"
#. ""
msgid "verify"
-msgstr "vérifier"
+msgstr "vérifier"
#. "The tree of actual checked out files."
msgid "working copy, working tree"
diff --git a/git-gui/po/hu.po b/git-gui/po/hu.po
index 627c05eb9..28760ed97 100644
--- a/git-gui/po/hu.po
+++ b/git-gui/po/hu.po
@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui-i 18n\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2007-12-04 01:15+0100\n"
+"POT-Creation-Date: 2008-03-14 07:18+0100\n"
+"PO-Revision-Date: 2008-03-14 17:24+0100\n"
"Last-Translator: Miklos Vajna <vmiklos@frugalware.org>\n"
"Language-Team: Hungarian\n"
"MIME-Version: 1.0\n"
@@ -16,33 +16,33 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:634 git-gui.sh:648 git-gui.sh:661 git-gui.sh:744
+#: git-gui.sh:763
msgid "git-gui: fatal error"
msgstr "git-gui: végzetes hiba"
-#: git-gui.sh:565
+#: git-gui.sh:593
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Érvénytelen font lett megadva itt: %s:"
-#: git-gui.sh:590
+#: git-gui.sh:620
msgid "Main Font"
msgstr "Fő betűtípus"
-#: git-gui.sh:591
+#: git-gui.sh:621
msgid "Diff/Console Font"
msgstr "Diff/konzol betűtípus"
-#: git-gui.sh:605
+#: git-gui.sh:635
msgid "Cannot find git in PATH."
msgstr "A git nem található a PATH-ban."
-#: git-gui.sh:632
+#: git-gui.sh:662
msgid "Cannot parse Git version string:"
msgstr "Nem értelmezhető a Git verzió sztring:"
-#: git-gui.sh:650
+#: git-gui.sh:680
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -61,79 +61,79 @@ msgstr ""
"\n"
"Feltételezhetjük, hogy a(z) '%s' verziója legalább 1.5.0?\n"
-#: git-gui.sh:888
+#: git-gui.sh:918
msgid "Git directory not found:"
msgstr "A Git könyvtár nem található:"
-#: git-gui.sh:895
+#: git-gui.sh:925
msgid "Cannot move to top of working directory:"
msgstr "Nem lehet a munkakönyvtár tetejére lépni:"
-#: git-gui.sh:902
+#: git-gui.sh:932
msgid "Cannot use funny .git directory:"
msgstr "Nem használható vicces .git könyvtár:"
-#: git-gui.sh:907
+#: git-gui.sh:937
msgid "No working directory"
msgstr "Nincs munkakönyvtár"
-#: git-gui.sh:1054
+#: git-gui.sh:1084 lib/checkout_op.tcl:283
msgid "Refreshing file status..."
msgstr "A fájlok státuszának frissítése..."
-#: git-gui.sh:1119
+#: git-gui.sh:1149
msgid "Scanning for modified files ..."
msgstr "Módosított fájlok keresése ..."
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1324 lib/browser.tcl:246
msgid "Ready."
msgstr "Kész."
-#: git-gui.sh:1560
+#: git-gui.sh:1590
msgid "Unmodified"
msgstr "Nem módosított"
-#: git-gui.sh:1562
+#: git-gui.sh:1592
msgid "Modified, not staged"
msgstr "Módosított, de nem kiválasztott"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1593 git-gui.sh:1598
msgid "Staged for commit"
msgstr "Kiválasztva commitolásra"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1594 git-gui.sh:1599
msgid "Portions staged for commit"
msgstr "Részek kiválasztva commitolásra"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1595 git-gui.sh:1600
msgid "Staged for commit, missing"
msgstr "Kiválasztva commitolásra, hiányzó"
-#: git-gui.sh:1567
+#: git-gui.sh:1597
msgid "Untracked, not staged"
msgstr "Nem követett, nem kiválasztott"
-#: git-gui.sh:1572
+#: git-gui.sh:1602
msgid "Missing"
msgstr "Hiányzó"
-#: git-gui.sh:1573
+#: git-gui.sh:1603
msgid "Staged for removal"
msgstr "Kiválasztva eltávolításra"
-#: git-gui.sh:1574
+#: git-gui.sh:1604
msgid "Staged for removal, still present"
msgstr "Kiválasztva eltávolításra, jelenleg is elérhető"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1606 git-gui.sh:1607 git-gui.sh:1608 git-gui.sh:1609
msgid "Requires merge resolution"
msgstr "Merge feloldás szükséges"
-#: git-gui.sh:1614
+#: git-gui.sh:1644
msgid "Starting gitk... please wait..."
msgstr "A gitk indítása... várjunk..."
-#: git-gui.sh:1623
+#: git-gui.sh:1653
#, tcl-format
msgid ""
"Unable to start gitk:\n"
@@ -144,295 +144,296 @@ msgstr ""
"\n"
"A(z) %s nem létezik"
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1860 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Repó"
-#: git-gui.sh:1824
+#: git-gui.sh:1861
msgid "Edit"
msgstr "Szerkesztés"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1863 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Branch"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1866 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "Commit@@főnév"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1869 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Merge"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1870 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Távoli"
-#: git-gui.sh:1842
+#: git-gui.sh:1879
msgid "Browse Current Branch's Files"
msgstr "A jelenlegi branch fájljainak böngészése"
-#: git-gui.sh:1846
+#: git-gui.sh:1883
msgid "Browse Branch Files..."
msgstr "A branch fájljainak böngészése..."
-#: git-gui.sh:1851
+#: git-gui.sh:1888
msgid "Visualize Current Branch's History"
msgstr "A jelenlegi branch történetének vizualizálása"
-#: git-gui.sh:1855
+#: git-gui.sh:1892
msgid "Visualize All Branch History"
msgstr "Az összes branch történetének vizualizálása"
-#: git-gui.sh:1862
+#: git-gui.sh:1899
#, tcl-format
msgid "Browse %s's Files"
msgstr "A(z) %s branch fájljainak böngészése"
-#: git-gui.sh:1864
+#: git-gui.sh:1901
#, tcl-format
msgid "Visualize %s's History"
msgstr "A(z) %s branch történetének vizualizálása"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1906 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "Adatbázis statisztikák"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1909 lib/database.tcl:34
msgid "Compress Database"
msgstr "Adatbázis tömörítése"
-#: git-gui.sh:1875
+#: git-gui.sh:1912
msgid "Verify Database"
msgstr "Adatbázis ellenőrzése"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:1919 git-gui.sh:1923 git-gui.sh:1927 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Asztal ikon létrehozása"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:1932 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Kilépés"
-#: git-gui.sh:1902
+#: git-gui.sh:1939
msgid "Undo"
msgstr "Visszavonás"
-#: git-gui.sh:1905
+#: git-gui.sh:1942
msgid "Redo"
msgstr "Mégis"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:1946 git-gui.sh:2443
msgid "Cut"
msgstr "Kivágás"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:1949 git-gui.sh:2446 git-gui.sh:2520 git-gui.sh:2614
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Másolás"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:1952 git-gui.sh:2449
msgid "Paste"
msgstr "Beillesztés"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:1955 git-gui.sh:2452 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Törlés"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:1959 git-gui.sh:2456 git-gui.sh:2618 lib/console.tcl:71
msgid "Select All"
msgstr "Mindent kiválaszt"
-#: git-gui.sh:1931
+#: git-gui.sh:1968
msgid "Create..."
msgstr "Létrehozás..."
-#: git-gui.sh:1937
+#: git-gui.sh:1974
msgid "Checkout..."
msgstr "Checkout..."
-#: git-gui.sh:1943
+#: git-gui.sh:1980
msgid "Rename..."
msgstr "Ãtnevezés..."
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:1985 git-gui.sh:2085
msgid "Delete..."
msgstr "Törlés..."
-#: git-gui.sh:1953
+#: git-gui.sh:1990
msgid "Reset..."
msgstr "Visszaállítás..."
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2002 git-gui.sh:2389
msgid "New Commit"
msgstr "Új commit"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2010 git-gui.sh:2396
msgid "Amend Last Commit"
msgstr "Utolsó commit javítása"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2019 git-gui.sh:2356 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Keresés újra"
-#: git-gui.sh:1988
+#: git-gui.sh:2025
msgid "Stage To Commit"
msgstr "Kiválasztás commitolásra"
-#: git-gui.sh:1994
+#: git-gui.sh:2031
msgid "Stage Changed Files To Commit"
msgstr "Módosított fájlok kiválasztása commitolásra"
-#: git-gui.sh:2000
+#: git-gui.sh:2037
msgid "Unstage From Commit"
msgstr "Commitba való kiválasztás visszavonása"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2042 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Változtatások visszaállítása"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2049 git-gui.sh:2368 git-gui.sh:2467
msgid "Sign Off"
msgstr "Aláír"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2053 git-gui.sh:2372
msgid "Commit@@verb"
msgstr "Commit@@ige"
-#: git-gui.sh:2027
+#: git-gui.sh:2064
msgid "Local Merge..."
msgstr "Helyi merge..."
-#: git-gui.sh:2032
+#: git-gui.sh:2069
msgid "Abort Merge..."
msgstr "Merge megszakítása..."
-#: git-gui.sh:2044
+#: git-gui.sh:2081
msgid "Push..."
msgstr "Push..."
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
+#: git-gui.sh:2092 lib/choose_repository.tcl:41
msgid "Apple"
msgstr "Apple"
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2095 git-gui.sh:2117 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "Névjegy: %s"
-#: git-gui.sh:2062
+#: git-gui.sh:2099
msgid "Preferences..."
msgstr "Beállítások..."
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2107 git-gui.sh:2639
msgid "Options..."
msgstr "Opciók..."
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2113 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Segítség"
-#: git-gui.sh:2117
+#: git-gui.sh:2154
msgid "Online Documentation"
msgstr "Online dokumentáció"
-#: git-gui.sh:2201
+#: git-gui.sh:2238
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr "végzetes hiba: nem érhető el a(z) %s útvonal: Nincs ilyen fájl vagy könyvtár"
+msgstr ""
+"végzetes hiba: nem érhető el a(z) %s útvonal: Nincs ilyen fájl vagy könyvtár"
-#: git-gui.sh:2234
+#: git-gui.sh:2271
msgid "Current Branch:"
msgstr "Jelenlegi branch:"
-#: git-gui.sh:2255
+#: git-gui.sh:2292
msgid "Staged Changes (Will Commit)"
msgstr "Kiválasztott változtatások (commitolva lesz)"
-#: git-gui.sh:2274
+#: git-gui.sh:2312
msgid "Unstaged Changes"
msgstr "Kiválasztatlan változtatások"
-#: git-gui.sh:2323
+#: git-gui.sh:2362
msgid "Stage Changed"
msgstr "Változtatások kiválasztása"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2378 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Push"
-#: git-gui.sh:2369
+#: git-gui.sh:2408
msgid "Initial Commit Message:"
msgstr "Kezdeti commit üzenet:"
-#: git-gui.sh:2370
+#: git-gui.sh:2409
msgid "Amended Commit Message:"
msgstr "Javító commit üzenet:"
-#: git-gui.sh:2371
+#: git-gui.sh:2410
msgid "Amended Initial Commit Message:"
msgstr "Kezdeti javító commit üzenet:"
-#: git-gui.sh:2372
+#: git-gui.sh:2411
msgid "Amended Merge Commit Message:"
msgstr "Javító merge commit üzenet:"
-#: git-gui.sh:2373
+#: git-gui.sh:2412
msgid "Merge Commit Message:"
msgstr "Merge commit üzenet:"
-#: git-gui.sh:2374
+#: git-gui.sh:2413
msgid "Commit Message:"
msgstr "Commit üzenet:"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2459 git-gui.sh:2622 lib/console.tcl:73
msgid "Copy All"
msgstr "Összes másolása"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2483 lib/blame.tcl:107
msgid "File:"
msgstr "Fájl:"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Frissítés"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2589
msgid "Apply/Reverse Hunk"
msgstr "Hunk alkalmazása/visszaállítása"
-#: git-gui.sh:2572
-msgid "Decrease Font Size"
-msgstr "Font méret csökkentése"
-
-#: git-gui.sh:2576
-msgid "Increase Font Size"
-msgstr "Fönt méret növelése"
-
-#: git-gui.sh:2581
+#: git-gui.sh:2595
msgid "Show Less Context"
msgstr "Kevesebb környezet mutatása"
-#: git-gui.sh:2588
+#: git-gui.sh:2602
msgid "Show More Context"
msgstr "Több környezet mutatása"
-#: git-gui.sh:2602
+#: git-gui.sh:2610
+msgid "Refresh"
+msgstr "Frissítés"
+
+#: git-gui.sh:2631
+msgid "Decrease Font Size"
+msgstr "Font méret csökkentése"
+
+#: git-gui.sh:2635
+msgid "Increase Font Size"
+msgstr "Fönt méret növelése"
+
+#: git-gui.sh:2646
msgid "Unstage Hunk From Commit"
msgstr "Hunk törlése commitból"
-#: git-gui.sh:2604
+#: git-gui.sh:2648
msgid "Stage Hunk For Commit"
msgstr "Hunk kiválasztása commitba"
-#: git-gui.sh:2623
+#: git-gui.sh:2667
msgid "Initializing..."
msgstr "Inicializálás..."
-#: git-gui.sh:2718
+#: git-gui.sh:2762
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -449,7 +450,7 @@ msgstr ""
"indított folyamatok által:\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2792
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -459,7 +460,7 @@ msgstr ""
"Ez a Cygwin által terjesztett Tcl binárisban\n"
"lévő ismert hiba miatt van."
-#: git-gui.sh:2753
+#: git-gui.sh:2797
#, tcl-format
msgid ""
"\n"
@@ -476,7 +477,7 @@ msgstr ""
"elhelyezése a személyes\n"
"~/.gitconfig fájlba.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - egy grafikus felület a Githez."
@@ -488,56 +489,56 @@ msgstr "Fájl néző"
msgid "Commit:"
msgstr "Commit:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:264
msgid "Copy Commit"
msgstr "Commit másolása"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:384
#, tcl-format
msgid "Reading %s..."
msgstr "A(z) %s olvasása..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:488
msgid "Loading copy/move tracking annotations..."
msgstr "A másolást/átnevezést követő annotációk betöltése..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:508
msgid "lines annotated"
msgstr "sor annotálva"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:689
msgid "Loading original location annotations..."
msgstr "Az eredeti hely annotációk betöltése..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:692
msgid "Annotation complete."
msgstr "Az annotáció kész."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:746
msgid "Loading annotation..."
msgstr "Az annotáció betöltése..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:802
msgid "Author:"
msgstr "Szerző:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:806
msgid "Committer:"
msgstr "Commiter:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:811
msgid "Original File:"
msgstr "Eredeti fájl:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:925
msgid "Originally By:"
msgstr "Eredeti szerző:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:931
msgid "In File:"
msgstr "Ebben a fájlban:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:936
msgid "Copied Or Moved Here By:"
msgstr "Ide másolta vagy helyezte:"
@@ -550,17 +551,17 @@ msgid "Checkout"
msgstr "Checkout"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Mégsem"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "Revízió"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:242
msgid "Options"
msgstr "Opciók"
@@ -580,7 +581,7 @@ msgstr "Branch létrehozása"
msgid "Create New Branch"
msgstr "Új branch létrehozása"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Létrehozás"
@@ -720,22 +721,22 @@ msgstr "Indítás..."
msgid "File Browser"
msgstr "Fájl böngésző"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "A(z) %s betöltése..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Fel a szülőhöz]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "A branch fájljainak böngészése"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:474 lib/choose_repository.tcl:484
+#: lib/choose_repository.tcl:987
msgid "Browse"
msgstr "Böngészés"
@@ -749,7 +750,7 @@ msgstr "A(z) %s letöltése innen: %s"
msgid "fatal: Cannot resolve %s"
msgstr "végzetes: Nem lehet feloldani a következőt: %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:140 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Bezárás"
@@ -807,6 +808,10 @@ msgstr ""
msgid "Updating working directory to '%s'..."
msgstr "A munkkönyvtár frissiítése a következőre: '%s'..."
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr "fájl frissítve"
+
#: lib/checkout_op.tcl:353
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
@@ -833,7 +838,7 @@ msgstr ""
"Ha egy branchen szeretnénk lenni, hozzunk létre egyet az 'Ez a leválasztott "
"checkout'-ból."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:446 lib/checkout_op.tcl:450
#, tcl-format
msgid "Checked out '%s'."
msgstr "'%s' kifejtve."
@@ -853,7 +858,7 @@ msgstr "Az elveszett commitok helyreállítása nem biztos, hogy egyszerű."
msgid "Reset '%s'?"
msgstr "Visszaállítjuk a következőt: '%s'?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:510 lib/merge.tcl:163
msgid "Visualize"
msgstr "Vizualizálás"
@@ -882,15 +887,15 @@ msgstr "Kiválaszt"
msgid "Font Family"
msgstr "Font család"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Font méret"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Font példa"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -898,225 +903,227 @@ msgstr ""
"Ez egy példa szöveg.\n"
"Ha ez megfelel, ez lehet a betűtípus."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git Gui"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Új repó létrehozása"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Új..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:460
msgid "Clone Existing Repository"
msgstr "Létező repó másolása"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Másolás..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:976
msgid "Open Existing Repository"
msgstr "Létező könyvtár megnyitása"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Meggyitás..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Legutóbbi repók"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Legutóbbi repók megnyitása:"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "A(z) '%s' hely már létezik."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "Nem sikerült letrehozni a(z) %s repót:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:478
msgid "Directory:"
msgstr "Könyvtár:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:412 lib/choose_repository.tcl:537
+#: lib/choose_repository.tcl:1011
msgid "Git Repository"
msgstr "Git repó"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:437
#, tcl-format
msgid "Directory %s already exists."
msgstr "A(z) '%s' könyvtár már létezik."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:441
#, tcl-format
msgid "File %s already exists."
msgstr "A(z) '%s' fájl már létezik."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:455
msgid "Clone"
msgstr "Bezárás"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:468
msgid "URL:"
msgstr "URL:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:489
msgid "Clone Type:"
msgstr "Másolás típusa:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:495
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Ãltalános (Gyors, félig-redundáns, hardlinkek)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:501
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "Teljes másolás (Lassabb, redundáns biztonsági mentés)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:507
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Megosztott (Leggyorsabb, nem ajánlott, nincs mentés)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:543 lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:736 lib/choose_repository.tcl:806
+#: lib/choose_repository.tcl:1017 lib/choose_repository.tcl:1025
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "Nem Git repó: %s"
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:579
msgid "Standard only available for local repository."
msgstr "A standard csak helyi repókra érhető el."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:583
msgid "Shared only available for local repository."
msgstr "A megosztott csak helyi repókra érhető el."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:604
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "A(z) '%s' hely már létezik."
+
+#: lib/choose_repository.tcl:615
msgid "Failed to configure origin"
msgstr "Nem sikerült beállítani az origint"
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:627
msgid "Counting objects"
msgstr "Objektumok számolása"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:628
msgid "buckets"
msgstr "vödrök"
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:652
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Nem sikerült másolni az objects/info/alternates-t: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:688
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Semmi másolni való nincs innen: %s"
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:690 lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:916
msgid "The 'master' branch has not been initialized."
msgstr "A 'master' branch nincs inicializálva."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:703
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "Nem érhetőek el hardlinkek. Másolás használata."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:715
#, tcl-format
msgid "Cloning from %s"
msgstr "Másolás innen: %s"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:746
msgid "Copying objects"
msgstr "Objektumok másolása"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:747
msgid "KiB"
msgstr "KiB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:771
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Nem sikerült másolni az objektumot: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:781
msgid "Linking objects"
msgstr "Objektumok összefűzése"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:782
msgid "objects"
msgstr "objektum"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:790
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Nem sikerült hardlinkelni az objektumot: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:845
msgid "Cannot fetch branches and objects. See console output for details."
-msgstr "Nem sikerült letölteni a branch-eket és az objektumokat. Bővebben a konzolos kimenetben."
+msgstr ""
+"Nem sikerült letölteni a branch-eket és az objektumokat. Bővebben a "
+"konzolos kimenetben."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:856
msgid "Cannot fetch tags. See console output for details."
msgstr "Nem sikerült letölteni a tageket. Bővebben a konzolos kimenetben."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:880
msgid "Cannot determine HEAD. See console output for details."
msgstr "Nem sikerült megállapítani a HEAD-et. Bővebben a konzolos kimenetben."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:889
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Nem sikerült tiszítani: %s."
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:895
msgid "Clone failed."
msgstr "A másolás nem sikerült."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:902
msgid "No default branch obtained."
msgstr "Nincs alapértelmezett branch."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:913
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "Nem sikerült felöldani a(z) %s objektumot commitként."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:925
msgid "Creating working directory"
msgstr "Munkakönyvtár létrehozása"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:926 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "fájl"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:955
msgid "Initial file checkout failed."
msgstr "A kezdeti fájl-kibontás sikertelen."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:971
msgid "Open"
msgstr "Megnyitás"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:981
msgid "Repository:"
msgstr "Repó:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1031
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Nem sikerült megnyitni a(z) %s repót:"
@@ -1137,7 +1144,7 @@ msgstr "Helyi branch"
msgid "Tracking Branch"
msgstr "Követő branch"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Tag"
@@ -1154,11 +1161,11 @@ msgstr "Nincs kiválasztva revízió."
msgid "Revision expression is empty."
msgstr "A revízió kifejezés üres."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Frissítve"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "URL"
@@ -1268,16 +1275,45 @@ msgstr ""
"- Második sor: Üres\n"
"- A többi sor: Leírja, hogy miért jó ez a változtatás.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "figyelmeztetés: a Tcl nem támogatja a(z) '%s' kódolást."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "A pre-commit hurok meghívása..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "A commitot megakadályozta a pre-commit hurok. "
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "A commit-msg hurok meghívása..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "A commiot megakadályozta a commit-msg hurok."
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "A változtatások commitolása..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "a write-tree sikertelen:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "A commit nem sikerült."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "A(z) %s commit sérültnek tűnik"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1291,37 +1327,32 @@ msgstr ""
"\n"
"Az újrakeresés most automatikusan el fog indulni.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "Nincs commitolandó változtatás."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "figyelmeztetés: a Tcl nem támogatja a(z) '%s' kódolást."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "a commit-tree sikertelen:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "az update-ref sikertelen:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Létrejött a %s commit: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Munka folyamatban.. Várjunk..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "Siker"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Hiba: a parancs sikertelen"
@@ -1431,23 +1462,23 @@ msgstr "* Bináris fájl (tartalom elrejtése)."
msgid "Error loading diff:"
msgstr "Hiba a diff betöltése közben:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:303
msgid "Failed to unstage selected hunk."
msgstr "Nem visszavonni a hunk kiválasztását."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:310
msgid "Failed to stage selected hunk."
msgstr "Nem sikerült kiválasztani a hunkot."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "hiba"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "figyelmeztetés"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr "Ki kell javítanunk a fenti hibákat commit előtt."
@@ -1464,8 +1495,8 @@ msgid ""
"Updating the Git index failed. A rescan will be automatically started to "
"resynchronize git-gui."
msgstr ""
-"A Git index frissítése sikertelen volt. Egy újraolvasás automatikusan elindult, hogy "
-"a git-gui újra szinkonban legyen."
+"A Git index frissítése sikertelen volt. Egy újraolvasás automatikusan "
+"elindult, hogy a git-gui újra szinkonban legyen."
#: lib/index.tcl:27
msgid "Continue"
@@ -1480,6 +1511,10 @@ msgstr "Index zárolásának feloldása"
msgid "Unstaging %s from commit"
msgstr "A(z) %s commitba való kiválasztásának visszavonása"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Commitolásra kész."
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1495,13 +1530,13 @@ msgstr "Visszaállítja a változtatásokat a(z) %s fájlban?"
msgid "Revert changes in these %i files?"
msgstr "Visszaállítja a változtatásokat ebben e %i fájlban?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
msgstr ""
"Minden nem kiválasztott változtatás el fog veszni ezáltal a visszaállítás "
"által."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Ne csináljunk semmit"
@@ -1574,27 +1609,27 @@ msgstr "%s / %s"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "A(z) %s és a(z) %s merge-ölése"
+msgid "Merging %s and %s..."
+msgstr "A(z) %s és a(z) %s merge-ölése..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "A merge sikeresen befejeződött."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "A merge sikertelen. Fel kell oldanunk az ütközéseket."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "Merge-ölés a következőbe: %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "Merge-ölni szándékozott revízió"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1604,7 +1639,7 @@ msgstr ""
"\n"
"Be kell fejeznünk ennek a commitnak a javítását.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1619,7 +1654,7 @@ msgstr ""
"\n"
"Folytatjuk a jelenlegi merge megszakítását?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1634,93 +1669,105 @@ msgstr ""
"\n"
"Folytatjuk a jelenlegi módosítások visszavonását?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "Félbeszakítás"
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "fájl visszaállítva"
+
+#: lib/merge.tcl:265
msgid "Abort failed."
msgstr "A félbeszakítás nem sikerült."
-#: lib/merge.tcl:268
+#: lib/merge.tcl:267
msgid "Abort completed. Ready."
msgstr "A megkeszakítás befejeződött. Kész."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "Alapértelmezés visszaállítása"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Mentés"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "%s Repó"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Globális (minden repó)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Felhasználónév"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "Email cím"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "A merge commitok összegzése"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Merge beszédesség"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Diffstat mutatása merge után"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "A fájl módosítási dátumok megbízhatóak"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr "A követő branchek eltávolítása letöltés alatt"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "A követő branchek egyeztetése"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
msgid "Number of Diff Context Lines"
msgstr "A diff környezeti sorok száma"
-#: lib/option.tcl:114
+#: lib/option.tcl:127
+msgid "Commit Message Text Width"
+msgstr "Commit üzenet szövegének szélessége"
+
+#: lib/option.tcl:128
msgid "New Branch Name Template"
msgstr "Új branch név sablon"
-#: lib/option.tcl:176
+#: lib/option.tcl:192
+msgid "Spelling Dictionary:"
+msgstr "Helyesírás-ellenőrző szótár:"
+
+#: lib/option.tcl:216
msgid "Change Font"
msgstr "Betűtípus megváltoztatása"
-#: lib/option.tcl:180
+#: lib/option.tcl:220
#, tcl-format
msgid "Choose %s"
msgstr "%s választása"
-#: lib/option.tcl:186
+#: lib/option.tcl:226
msgid "pt."
msgstr "pt."
-#: lib/option.tcl:200
+#: lib/option.tcl:240
msgid "Preferences"
msgstr "Beállítások"
-#: lib/option.tcl:235
+#: lib/option.tcl:275
msgid "Failed to completely save options:"
msgstr "Nem sikerült teljesen elmenteni a beállításokat:"
@@ -1767,8 +1814,7 @@ msgid ""
"\n"
" - %s"
msgstr ""
-"A következő branchek nem teljesen lettek merge-ölve ebbe: %s:"
-"\n"
+"A következő branchek nem teljesen lettek merge-ölve ebbe: %s:\n"
" - %s"
#: lib/remote_branch_delete.tcl:189
@@ -1829,6 +1875,43 @@ msgstr "Nem sikerült írni a gyorsbillentyűt:"
msgid "Cannot write icon:"
msgstr "Nem sikerült írni az ikont:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "Nem támogatott helyesírás-ellenőrző"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "A helyesírás-ellenőrzés nem elérhető"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "Érvénytelen a helyesírás-ellenőrző beállítása"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Szótár visszaállítása a következőre: %s."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "A helyesírás-ellenőrő indítása sikertelen"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "Ismeretlen helyesírás-ellenőrző"
+
+#: lib/spellcheck.tcl:180
+msgid "No Suggestions"
+msgstr "Nincs javaslat"
+
+#: lib/spellcheck.tcl:381
+msgid "Unexpected EOF from spell checker"
+msgstr "Nem várt EOF a helyesírás-ellenőrzőtől"
+
+#: lib/spellcheck.tcl:385
+msgid "Spell Checker Failed"
+msgstr "A helyesírás-ellenőrzés sikertelen"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
@@ -1887,7 +1970,9 @@ msgstr "Ãtviteli opciók"
#: lib/transport.tcl:160
msgid "Force overwrite existing branch (may discard changes)"
-msgstr "Létező branch felülírásának erőltetése (lehet, hogy el fog dobni változtatásokat)"
+msgstr ""
+"Létező branch felülírásának erőltetése (lehet, hogy el fog dobni "
+"változtatásokat)"
#: lib/transport.tcl:164
msgid "Use thin pack (for slow network connections)"
@@ -1897,6 +1982,9 @@ msgstr "Vékony csomagok használata (lassú hálózati kapcsolatok számára)"
msgid "Include tags"
msgstr "Tageket is"
+#~ msgid "Not connected to aspell"
+#~ msgstr "Nincs kapcsolat az aspellhez"
+
#~ msgid "Cannot find the git directory:"
#~ msgstr "Nem található a git könyvtár:"
diff --git a/git-gui/po/it.po b/git-gui/po/it.po
index 33a839917..3db4fb68c 100644
--- a/git-gui/po/it.po
+++ b/git-gui/po/it.po
@@ -3,47 +3,47 @@
# This file is distributed under the same license as the git-gui package.
# Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>, 2007
# Michele Ballabio <barra_cuda@katamail.com>, 2007.
-#
-#
+#
+#
msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-09 11:18+0100\n"
-"PO-Revision-Date: 2007-11-01 21:05+0100\n"
+"POT-Creation-Date: 2008-08-02 14:45-0700\n"
+"PO-Revision-Date: 2008-08-03 16:04+0200\n"
"Last-Translator: Michele Ballabio <barra_cuda@katamail.com>\n"
"Language-Team: Italian <tp@lists.linux.it>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:688 git-gui.sh:702 git-gui.sh:715 git-gui.sh:798
+#: git-gui.sh:817
msgid "git-gui: fatal error"
msgstr "git-gui: errore grave"
-#: git-gui.sh:565
+#: git-gui.sh:644
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Caratteri non validi specificati in %s:"
-#: git-gui.sh:590
+#: git-gui.sh:674
msgid "Main Font"
msgstr "Caratteri principali"
-#: git-gui.sh:591
+#: git-gui.sh:675
msgid "Diff/Console Font"
msgstr "Caratteri per confronti e terminale"
-#: git-gui.sh:605
+#: git-gui.sh:689
msgid "Cannot find git in PATH."
msgstr "Impossibile trovare git nel PATH"
-#: git-gui.sh:632
+#: git-gui.sh:716
msgid "Cannot parse Git version string:"
msgstr "Impossibile determinare la versione di Git:"
-#: git-gui.sh:650
+#: git-gui.sh:734
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -62,380 +62,381 @@ msgstr ""
"\n"
"Assumere che '%s' sia alla versione 1.5.0?\n"
-#: git-gui.sh:888
+#: git-gui.sh:972
msgid "Git directory not found:"
msgstr "Non trovo la directory di git: "
-#: git-gui.sh:895
+#: git-gui.sh:979
msgid "Cannot move to top of working directory:"
msgstr "Impossibile spostarsi sulla directory principale del progetto:"
-#: git-gui.sh:902
+#: git-gui.sh:986
msgid "Cannot use funny .git directory:"
msgstr "Impossibile usare una .git directory strana:"
-#: git-gui.sh:907
+#: git-gui.sh:991
msgid "No working directory"
msgstr "Nessuna directory di lavoro"
-#: git-gui.sh:1054
+#: git-gui.sh:1138 lib/checkout_op.tcl:305
msgid "Refreshing file status..."
msgstr "Controllo dello stato dei file in corso..."
-#: git-gui.sh:1119
+#: git-gui.sh:1194
msgid "Scanning for modified files ..."
msgstr "Ricerca di file modificati in corso..."
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1369 lib/browser.tcl:246
msgid "Ready."
msgstr "Pronto."
-#: git-gui.sh:1560
+#: git-gui.sh:1635
msgid "Unmodified"
msgstr "Non modificato"
-#: git-gui.sh:1562
+#: git-gui.sh:1637
msgid "Modified, not staged"
msgstr "Modificato, non preparato per una nuova revisione"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1638 git-gui.sh:1643
msgid "Staged for commit"
msgstr "Preparato per una nuova revisione"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1639 git-gui.sh:1644
msgid "Portions staged for commit"
msgstr "Parti preparate per una nuova revisione"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1640 git-gui.sh:1645
msgid "Staged for commit, missing"
msgstr "Preparato per una nuova revisione, mancante"
-#: git-gui.sh:1567
+#: git-gui.sh:1642
msgid "Untracked, not staged"
msgstr "Non tracciato, non preparato per una nuova revisione"
-#: git-gui.sh:1572
+#: git-gui.sh:1647
msgid "Missing"
msgstr "Mancante"
-#: git-gui.sh:1573
+#: git-gui.sh:1648
msgid "Staged for removal"
msgstr "Preparato per la rimozione"
-#: git-gui.sh:1574
+#: git-gui.sh:1649
msgid "Staged for removal, still present"
msgstr "Preparato alla rimozione, ancora presente"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1651 git-gui.sh:1652 git-gui.sh:1653 git-gui.sh:1654
msgid "Requires merge resolution"
msgstr "Richiede risoluzione dei conflitti"
-#: git-gui.sh:1614
+#: git-gui.sh:1689
msgid "Starting gitk... please wait..."
msgstr "Avvio di gitk... attendere..."
-#: git-gui.sh:1623
-#, tcl-format
-msgid ""
-"Unable to start gitk:\n"
-"\n"
-"%s does not exist"
-msgstr ""
-"Impossibile avviare gitk:\n"
-"\n"
-"%s non esiste"
+#: git-gui.sh:1698
+msgid "Couldn't find gitk in PATH"
+msgstr "Impossibile trovare gitk nel PATH"
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1948 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Archivio"
-#: git-gui.sh:1824
+#: git-gui.sh:1949
msgid "Edit"
msgstr "Modifica"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1951 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Ramo"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1954 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "Revisione"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1957 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Fusione (Merge)"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1958 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Remoto"
-#: git-gui.sh:1842
+#: git-gui.sh:1967
msgid "Browse Current Branch's Files"
msgstr "Esplora i file del ramo attuale"
-#: git-gui.sh:1846
+#: git-gui.sh:1971
msgid "Browse Branch Files..."
msgstr "Esplora i file del ramo..."
-#: git-gui.sh:1851
+#: git-gui.sh:1976
msgid "Visualize Current Branch's History"
msgstr "Visualizza la cronologia del ramo attuale"
-#: git-gui.sh:1855
+#: git-gui.sh:1980
msgid "Visualize All Branch History"
msgstr "Visualizza la cronologia di tutti i rami"
-#: git-gui.sh:1862
+#: git-gui.sh:1987
#, tcl-format
msgid "Browse %s's Files"
msgstr "Esplora i file di %s"
-#: git-gui.sh:1864
+#: git-gui.sh:1989
#, tcl-format
msgid "Visualize %s's History"
msgstr "Visualizza la cronologia di %s"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1994 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "Statistiche dell'archivio"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1997 lib/database.tcl:34
msgid "Compress Database"
msgstr "Comprimi l'archivio"
-#: git-gui.sh:1875
+#: git-gui.sh:2000
msgid "Verify Database"
msgstr "Verifica l'archivio"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:2007 git-gui.sh:2011 git-gui.sh:2015 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Crea icona desktop"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:2023 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Esci"
-#: git-gui.sh:1902
+#: git-gui.sh:2031
msgid "Undo"
msgstr "Annulla"
-#: git-gui.sh:1905
+#: git-gui.sh:2034
msgid "Redo"
msgstr "Ripeti"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:2038 git-gui.sh:2545
msgid "Cut"
msgstr "Taglia"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:2041 git-gui.sh:2548 git-gui.sh:2622 git-gui.sh:2715
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Copia"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:2044 git-gui.sh:2551
msgid "Paste"
msgstr "Incolla"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:2047 git-gui.sh:2554 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Elimina"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:2051 git-gui.sh:2558 git-gui.sh:2719 lib/console.tcl:71
msgid "Select All"
msgstr "Seleziona tutto"
-#: git-gui.sh:1931
+#: git-gui.sh:2060
msgid "Create..."
msgstr "Crea..."
-#: git-gui.sh:1937
+#: git-gui.sh:2066
msgid "Checkout..."
msgstr "Attiva..."
-#: git-gui.sh:1943
+#: git-gui.sh:2072
msgid "Rename..."
msgstr "Rinomina"
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:2077 git-gui.sh:2187
msgid "Delete..."
msgstr "Elimina..."
-#: git-gui.sh:1953
+#: git-gui.sh:2082
msgid "Reset..."
msgstr "Ripristina..."
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2094 git-gui.sh:2491
msgid "New Commit"
msgstr "Nuova revisione"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2102 git-gui.sh:2498
msgid "Amend Last Commit"
msgstr "Correggi l'ultima revisione"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2111 git-gui.sh:2458 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Analizza nuovamente"
-#: git-gui.sh:1988
+#: git-gui.sh:2117
msgid "Stage To Commit"
msgstr "Prepara per una nuova revisione"
-#: git-gui.sh:1994
+#: git-gui.sh:2123
msgid "Stage Changed Files To Commit"
msgstr "Prepara i file modificati per una nuova revisione"
-#: git-gui.sh:2000
+#: git-gui.sh:2129
msgid "Unstage From Commit"
msgstr "Annulla preparazione"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2134 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Annulla modifiche"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2141 git-gui.sh:2702
+msgid "Show Less Context"
+msgstr "Mostra meno contesto"
+
+#: git-gui.sh:2145 git-gui.sh:2706
+msgid "Show More Context"
+msgstr "Mostra più contesto"
+
+#: git-gui.sh:2151 git-gui.sh:2470 git-gui.sh:2569
msgid "Sign Off"
msgstr "Sign Off"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2155 git-gui.sh:2474
msgid "Commit@@verb"
msgstr "Nuova revisione"
-#: git-gui.sh:2027
+#: git-gui.sh:2166
msgid "Local Merge..."
msgstr "Fusione locale..."
-#: git-gui.sh:2032
+#: git-gui.sh:2171
msgid "Abort Merge..."
msgstr "Interrompi fusione..."
-#: git-gui.sh:2044
+#: git-gui.sh:2183
msgid "Push..."
msgstr "Propaga..."
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
-msgid "Apple"
-msgstr "Apple"
-
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2197 git-gui.sh:2219 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "Informazioni su %s"
-#: git-gui.sh:2062
+#: git-gui.sh:2201
msgid "Preferences..."
msgstr "Preferenze..."
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2209 git-gui.sh:2740
msgid "Options..."
msgstr "Opzioni..."
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2215 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Aiuto"
-#: git-gui.sh:2117
+#: git-gui.sh:2256
msgid "Online Documentation"
msgstr "Documentazione sul web"
-#: git-gui.sh:2201
+#: git-gui.sh:2340
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
msgstr ""
"errore grave: impossibile effettuare lo stat del path %s: file o directory "
"non trovata"
-#: git-gui.sh:2234
+#: git-gui.sh:2373
msgid "Current Branch:"
msgstr "Ramo attuale:"
-#: git-gui.sh:2255
+#: git-gui.sh:2394
msgid "Staged Changes (Will Commit)"
msgstr "Modifiche preparate (saranno nella nuova revisione)"
-#: git-gui.sh:2274
+#: git-gui.sh:2414
msgid "Unstaged Changes"
msgstr "Modifiche non preparate"
-#: git-gui.sh:2323
+#: git-gui.sh:2464
msgid "Stage Changed"
msgstr "Prepara modificati"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2480 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Propaga (Push)"
-#: git-gui.sh:2369
+#: git-gui.sh:2510
msgid "Initial Commit Message:"
msgstr "Messaggio di revisione iniziale:"
-#: git-gui.sh:2370
+#: git-gui.sh:2511
msgid "Amended Commit Message:"
msgstr "Messaggio di revisione corretto:"
-#: git-gui.sh:2371
+#: git-gui.sh:2512
msgid "Amended Initial Commit Message:"
msgstr "Messaggio iniziale di revisione corretto:"
-#: git-gui.sh:2372
+#: git-gui.sh:2513
msgid "Amended Merge Commit Message:"
msgstr "Messaggio di fusione corretto:"
-#: git-gui.sh:2373
+#: git-gui.sh:2514
msgid "Merge Commit Message:"
msgstr "Messaggio di fusione:"
-#: git-gui.sh:2374
+#: git-gui.sh:2515
msgid "Commit Message:"
msgstr "Messaggio di revisione:"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2561 git-gui.sh:2723 lib/console.tcl:73
msgid "Copy All"
msgstr "Copia tutto"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2585 lib/blame.tcl:100
msgid "File:"
msgstr "File:"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Rinfresca"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2691
msgid "Apply/Reverse Hunk"
msgstr "Applica/Inverti sezione"
-#: git-gui.sh:2572
+#: git-gui.sh:2696
+msgid "Apply/Reverse Line"
+msgstr "Applica/Inverti riga"
+
+#: git-gui.sh:2711
+msgid "Refresh"
+msgstr "Rinfresca"
+
+#: git-gui.sh:2732
msgid "Decrease Font Size"
msgstr "Diminuisci dimensione caratteri"
-#: git-gui.sh:2576
+#: git-gui.sh:2736
msgid "Increase Font Size"
msgstr "Aumenta dimensione caratteri"
-#: git-gui.sh:2581
-msgid "Show Less Context"
-msgstr "Mostra meno contesto"
-
-#: git-gui.sh:2588
-msgid "Show More Context"
-msgstr "Mostra più contesto"
-
-#: git-gui.sh:2602
+#: git-gui.sh:2747
msgid "Unstage Hunk From Commit"
-msgstr "Sezione non preparata per una nuova revisione"
+msgstr "Annulla preparazione della sezione per una nuova revisione"
-#: git-gui.sh:2604
+#: git-gui.sh:2748
+msgid "Unstage Line From Commit"
+msgstr "Annulla preparazione della linea per una nuova revisione"
+
+#: git-gui.sh:2750
msgid "Stage Hunk For Commit"
msgstr "Prepara sezione per una nuova revisione"
-#: git-gui.sh:2623
+#: git-gui.sh:2751
+msgid "Stage Line For Commit"
+msgstr "Prepara linea per una nuova revisione"
+
+#: git-gui.sh:2771
msgid "Initializing..."
msgstr "Inizializzazione..."
-#: git-gui.sh:2718
+#: git-gui.sh:2876
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -452,7 +453,7 @@ msgstr ""
"da %s:\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2906
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -462,7 +463,7 @@ msgstr ""
"Ciò è dovuto a un problema conosciuto\n"
"causato dall'eseguibile Tcl distribuito da Cygwin."
-#: git-gui.sh:2753
+#: git-gui.sh:2911
#, tcl-format
msgid ""
"\n"
@@ -478,68 +479,84 @@ msgstr ""
"consiste nell'assegnare valori alle variabili di configurazione\n"
"user.name e user.email nel tuo file ~/.gitconfig personale.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - un'interfaccia grafica per Git."
-#: lib/blame.tcl:77
+#: lib/blame.tcl:70
msgid "File Viewer"
msgstr "Mostra file"
-#: lib/blame.tcl:81
+#: lib/blame.tcl:74
msgid "Commit:"
msgstr "Revisione:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:257
msgid "Copy Commit"
msgstr "Copia revisione"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:260
+msgid "Do Full Copy Detection"
+msgstr "Ricerca accurata delle copie"
+
+#: lib/blame.tcl:388
#, tcl-format
msgid "Reading %s..."
msgstr "Lettura di %s..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:492
msgid "Loading copy/move tracking annotations..."
msgstr "Caricamento annotazioni per copie/spostamenti..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:512
msgid "lines annotated"
msgstr "linee annotate"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:704
msgid "Loading original location annotations..."
msgstr "Caricamento annotazioni per posizione originaria..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:707
msgid "Annotation complete."
msgstr "Annotazione completata."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:737
+msgid "Busy"
+msgstr "Occupato"
+
+#: lib/blame.tcl:738
+msgid "Annotation process is already running."
+msgstr "Il processo di annotazione è già in corso."
+
+#: lib/blame.tcl:777
+msgid "Running thorough copy detection..."
+msgstr "Ricerca accurata delle copie in corso..."
+
+#: lib/blame.tcl:827
msgid "Loading annotation..."
msgstr "Caricamento annotazioni..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:883
msgid "Author:"
msgstr "Autore:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:887
msgid "Committer:"
msgstr "Revisione creata da:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:892
msgid "Original File:"
msgstr "File originario:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:1006
msgid "Originally By:"
msgstr "In origine da:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:1012
msgid "In File:"
msgstr "Nel file:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:1017
msgid "Copied Or Moved Here By:"
msgstr "Copiato o spostato qui da:"
@@ -552,17 +569,17 @@ msgid "Checkout"
msgstr "Attiva"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:544 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Annulla"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "Revisione"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:244
msgid "Options"
msgstr "Opzioni"
@@ -582,7 +599,7 @@ msgstr "Crea ramo"
msgid "Create New Branch"
msgstr "Crea nuovo ramo"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Crea"
@@ -614,7 +631,7 @@ msgstr "No"
msgid "Fast Forward Only"
msgstr "Solo fast forward"
-#: lib/branch_create.tcl:85 lib/checkout_op.tcl:514
+#: lib/branch_create.tcl:85 lib/checkout_op.tcl:536
msgid "Reset"
msgstr "Ripristina"
@@ -705,7 +722,7 @@ msgstr "Nuovo Nome:"
msgid "Please select a branch to rename."
msgstr "Scegliere un ramo da rinominare."
-#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:179
+#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:201
#, tcl-format
msgid "Branch '%s' already exists."
msgstr "Il ramo '%s' esiste già."
@@ -723,45 +740,50 @@ msgstr "Avvio in corso..."
msgid "File Browser"
msgstr "File browser"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "Caricamento %s..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Directory superiore]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "Esplora i file del ramo"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:472 lib/choose_repository.tcl:482
+#: lib/choose_repository.tcl:985
msgid "Browse"
-msgstr "Sfoglia"
+msgstr "Esplora"
-#: lib/checkout_op.tcl:79
+#: lib/checkout_op.tcl:84
#, tcl-format
msgid "Fetching %s from %s"
msgstr "Recupero %s da %s"
-#: lib/checkout_op.tcl:127
+#: lib/checkout_op.tcl:132
#, tcl-format
msgid "fatal: Cannot resolve %s"
msgstr "errore grave: impossibile risolvere %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:145 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Chiudi"
-#: lib/checkout_op.tcl:169
+#: lib/checkout_op.tcl:174
#, tcl-format
msgid "Branch '%s' does not exist."
msgstr "Il ramo '%s' non esiste."
-#: lib/checkout_op.tcl:206
+#: lib/checkout_op.tcl:193
+#, tcl-format
+msgid "Failed to configure simplified git-pull for '%s'."
+msgstr "Impossibile configurare git-pull semplificato per '%s'."
+
+#: lib/checkout_op.tcl:228
#, tcl-format
msgid ""
"Branch '%s' already exists.\n"
@@ -774,22 +796,22 @@ msgstr ""
"Non può effettuare un 'fast-forward' a %s.\n"
"E' necessaria una fusione."
-#: lib/checkout_op.tcl:220
+#: lib/checkout_op.tcl:242
#, tcl-format
msgid "Merge strategy '%s' not supported."
msgstr "La strategia di fusione '%s' non è supportata."
-#: lib/checkout_op.tcl:239
+#: lib/checkout_op.tcl:261
#, tcl-format
msgid "Failed to update '%s'."
msgstr "Impossibile aggiornare '%s'."
-#: lib/checkout_op.tcl:251
+#: lib/checkout_op.tcl:273
msgid "Staging area (index) is already locked."
msgstr ""
"L'area di preparazione per una nuova revisione (indice) è già bloccata."
-#: lib/checkout_op.tcl:266
+#: lib/checkout_op.tcl:288
msgid ""
"Last scanned state does not match repository state.\n"
"\n"
@@ -806,26 +828,30 @@ msgstr ""
"\n"
"La nuova analisi comincerà ora.\n"
-#: lib/checkout_op.tcl:322
+#: lib/checkout_op.tcl:344
#, tcl-format
msgid "Updating working directory to '%s'..."
msgstr "Aggiornamento della directory di lavoro a '%s' in corso..."
-#: lib/checkout_op.tcl:353
+#: lib/checkout_op.tcl:345
+msgid "files checked out"
+msgstr "file presenti nella directory di lavoro"
+
+#: lib/checkout_op.tcl:375
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
msgstr "Attivazione di '%s' fallita (richiesta una fusione a livello file)."
-#: lib/checkout_op.tcl:354
+#: lib/checkout_op.tcl:376
msgid "File level merge required."
msgstr "E' richiesta una fusione a livello file."
-#: lib/checkout_op.tcl:358
+#: lib/checkout_op.tcl:380
#, tcl-format
msgid "Staying on branch '%s'."
msgstr "Si rimarrà sul ramo '%s'."
-#: lib/checkout_op.tcl:429
+#: lib/checkout_op.tcl:451
msgid ""
"You are no longer on a local branch.\n"
"\n"
@@ -837,31 +863,31 @@ msgstr ""
"Se si vuole rimanere su un ramo, crearne uno ora a partire da 'Questa "
"revisione attiva staccata'."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:468 lib/checkout_op.tcl:472
#, tcl-format
msgid "Checked out '%s'."
msgstr "Attivazione di '%s' completata."
-#: lib/checkout_op.tcl:478
+#: lib/checkout_op.tcl:500
#, tcl-format
msgid "Resetting '%s' to '%s' will lose the following commits:"
msgstr ""
"Ripristinare '%s' a '%s' comporterà la perdita delle seguenti revisioni:"
-#: lib/checkout_op.tcl:500
+#: lib/checkout_op.tcl:522
msgid "Recovering lost commits may not be easy."
msgstr "Ricomporre le revisioni perdute potrebbe non essere semplice."
-#: lib/checkout_op.tcl:505
+#: lib/checkout_op.tcl:527
#, tcl-format
msgid "Reset '%s'?"
msgstr "Ripristinare '%s'?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:532 lib/merge.tcl:163
msgid "Visualize"
msgstr "Visualizza"
-#: lib/checkout_op.tcl:578
+#: lib/checkout_op.tcl:600
#, tcl-format
msgid ""
"Failed to set current branch.\n"
@@ -887,246 +913,246 @@ msgstr "Seleziona"
msgid "Font Family"
msgstr "Famiglia di caratteri"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Dimensione caratteri"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Esempio caratteri"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
msgstr ""
"Questo è un testo d'esempio.\n"
-"Se ti piace questo testo, può essere il carattere giusto."
+"Se ti piace questo testo, scegli questo carattere."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git Gui"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Crea nuovo archivio"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Nuovo..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:458
msgid "Clone Existing Repository"
msgstr "Clona archivio esistente"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Clona..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:974
msgid "Open Existing Repository"
msgstr "Apri archivio esistente"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Apri..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Archivi recenti"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Apri archivio recente:"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "La posizione %s esiste già."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "Impossibile creare l'archivio %s:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:476
msgid "Directory:"
msgstr "Directory:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:410 lib/choose_repository.tcl:535
+#: lib/choose_repository.tcl:1007
msgid "Git Repository"
msgstr "Archivio Git"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:435
#, tcl-format
msgid "Directory %s already exists."
msgstr "La directory %s esiste già."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:439
#, tcl-format
msgid "File %s already exists."
msgstr "Il file %s esiste già."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:453
msgid "Clone"
msgstr "Clona"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:466
msgid "URL:"
msgstr "URL:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:487
msgid "Clone Type:"
msgstr "Tipo di clone:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:493
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Standard (veloce, semi-ridondante, con hardlink)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:499
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "Copia completa (più lento, backup ridondante)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:505
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Shared (il più veloce, non raccomandato, nessun backup)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:541 lib/choose_repository.tcl:588
+#: lib/choose_repository.tcl:734 lib/choose_repository.tcl:804
+#: lib/choose_repository.tcl:1013 lib/choose_repository.tcl:1021
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "%s non è un archivio Git."
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:577
msgid "Standard only available for local repository."
msgstr "Standard è disponibile solo per archivi locali."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:581
msgid "Shared only available for local repository."
msgstr "Shared è disponibile solo per archivi locali."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:602
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "Il file/directory %s esiste già."
+
+#: lib/choose_repository.tcl:613
msgid "Failed to configure origin"
msgstr "Impossibile configurare origin"
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:625
msgid "Counting objects"
msgstr "Calcolo oggetti"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:626
msgid "buckets"
msgstr ""
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:650
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Impossibile copiare oggetti/info/alternate: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:686
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Niente da clonare da %s."
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:688 lib/choose_repository.tcl:902
+#: lib/choose_repository.tcl:914
msgid "The 'master' branch has not been initialized."
msgstr "Il ramo 'master' non è stato inizializzato."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:701
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "Impossibile utilizzare gli hardlink. Si ricorrerà alla copia."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:713
#, tcl-format
msgid "Cloning from %s"
msgstr "Clonazione da %s"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:744
msgid "Copying objects"
msgstr "Copia degli oggetti"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:745
msgid "KiB"
msgstr "KiB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:769
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Impossibile copiare oggetto: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:779
msgid "Linking objects"
msgstr "Collegamento oggetti"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:780
msgid "objects"
msgstr "oggetti"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:788
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Hardlink impossibile sull'oggetto: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:843
msgid "Cannot fetch branches and objects. See console output for details."
msgstr ""
"Impossibile recuperare rami e oggetti. Controllare i dettagli forniti dalla "
"console."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:854
msgid "Cannot fetch tags. See console output for details."
msgstr ""
"Impossibile recuperare le etichette. Controllare i dettagli forniti dalla "
"console."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:878
msgid "Cannot determine HEAD. See console output for details."
msgstr ""
"Impossibile determinare HEAD. Controllare i dettagli forniti dalla console."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:887
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Impossibile ripulire %s"
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:893
msgid "Clone failed."
msgstr "Clonazione non riuscita."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:900
msgid "No default branch obtained."
msgstr "Non è stato trovato un ramo predefinito."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:911
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "Impossibile risolvere %s come una revisione."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:923
msgid "Creating working directory"
msgstr "Creazione directory di lavoro"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:924 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "file"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:953
msgid "Initial file checkout failed."
msgstr "Attivazione iniziale non riuscita."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:969
msgid "Open"
msgstr "Apri"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:979
msgid "Repository:"
msgstr "Archivio:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1027
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Impossibile accedere all'archivio %s:"
@@ -1147,7 +1173,7 @@ msgstr "Ramo locale"
msgid "Tracking Branch"
msgstr "Duplicato locale di ramo remoto"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Etichetta"
@@ -1164,11 +1190,11 @@ msgstr "Nessuna revisione selezionata."
msgid "Revision expression is empty."
msgstr "L'espressione di revisione è vuota."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Aggiornato"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "URL"
@@ -1268,7 +1294,7 @@ msgid ""
"\n"
"A good commit message has the following format:\n"
"\n"
-"- First line: Describe in one sentance what you did.\n"
+"- First line: Describe in one sentence what you did.\n"
"- Second line: Blank\n"
"- Remaining lines: Describe why this change is good.\n"
msgstr ""
@@ -1280,16 +1306,45 @@ msgstr ""
"- Seconda linea: vuota.\n"
"- Terza linea: spiega a cosa serve la tua modifica.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "attenzione: Tcl non supporta la codifica '%s'."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "Avvio pre-commit hook..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "Revisione rifiutata dal pre-commit hook."
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "Avvio commit-msg hook..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "Revisione rifiutata dal commit-msg hook."
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Archiviazione modifiche..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "write-tree non riuscito:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Impossibile creare una nuova revisione."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "La revisione %s sembra essere danneggiata"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1303,37 +1358,32 @@ msgstr ""
"\n"
"Si procederà subito ad una nuova analisi.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "Nessuna modifica per la nuova revisione."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "attenzione: Tcl non supporta la codifica '%s'."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "commit-tree non riuscito:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "update-ref non riuscito:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Creata revisione %s: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Elaborazione in corso... attendere..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "Successo"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Errore: comando non riuscito"
@@ -1395,7 +1445,7 @@ msgstr ""
msgid "Invalid date from Git: %s"
msgstr "Git ha restituito una data non valida: %s"
-#: lib/diff.tcl:42
+#: lib/diff.tcl:44
#, tcl-format
msgid ""
"No differences detected.\n"
@@ -1418,49 +1468,57 @@ msgstr ""
"Si procederà automaticamente ad una nuova analisi per trovare altri file che "
"potrebbero avere lo stesso stato."
-#: lib/diff.tcl:81
+#: lib/diff.tcl:83
#, tcl-format
msgid "Loading diff of %s..."
msgstr "Caricamento delle differenze di %s..."
-#: lib/diff.tcl:114 lib/diff.tcl:184
+#: lib/diff.tcl:116 lib/diff.tcl:190
#, tcl-format
msgid "Unable to display %s"
msgstr "Impossibile visualizzare %s"
-#: lib/diff.tcl:115
+#: lib/diff.tcl:117
msgid "Error loading file:"
msgstr "Errore nel caricamento del file:"
-#: lib/diff.tcl:122
+#: lib/diff.tcl:124
msgid "Git Repository (subproject)"
msgstr "Archivio Git (sottoprogetto)"
-#: lib/diff.tcl:134
+#: lib/diff.tcl:136
msgid "* Binary file (not showing content)."
msgstr "* File binario (il contenuto non sarà mostrato)."
-#: lib/diff.tcl:185
+#: lib/diff.tcl:191
msgid "Error loading diff:"
msgstr "Errore nel caricamento delle differenze:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:313
msgid "Failed to unstage selected hunk."
msgstr "Impossibile rimuovere la sezione scelta dalla nuova revisione."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:320
msgid "Failed to stage selected hunk."
msgstr "Impossibile preparare la sezione scelta per una nuova revisione."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/diff.tcl:386
+msgid "Failed to unstage selected line."
+msgstr "Impossibile rimuovere la riga scelta dalla nuova revisione."
+
+#: lib/diff.tcl:394
+msgid "Failed to stage selected line."
+msgstr "Impossibile preparare la riga scelta per una nuova revisione."
+
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "errore"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "attenzione"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr ""
"Bisogna correggere gli errori suddetti prima di creare una nuova revisione."
@@ -1494,6 +1552,10 @@ msgstr "Sblocca l'accesso all'indice"
msgid "Unstaging %s from commit"
msgstr "%s non farà parte della prossima revisione"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Pronto per creare una nuova revisione."
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1509,13 +1571,13 @@ msgstr "Annullare le modifiche nel file %s?"
msgid "Revert changes in these %i files?"
msgstr "Annullare le modifiche in questi %i file?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
msgstr ""
"Tutte le modifiche non preparate per una nuova revisione saranno perse per "
"sempre."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Non fare niente"
@@ -1589,27 +1651,27 @@ msgstr "%s di %s"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "Fusione di %s e %s in corso"
+msgid "Merging %s and %s..."
+msgstr "Fusione di %s e %s in corso..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "Fusione completata con successo."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "Fusione non riuscita. Bisogna risolvere i conflitti."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "Fusione in %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "Revisione da fondere"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1619,7 +1681,7 @@ msgstr ""
"\n"
"Bisogna finire di correggere questa revisione.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1634,7 +1696,7 @@ msgstr ""
"\n"
"Continuare con l'interruzione della fusione attuale?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1649,9 +1711,13 @@ msgstr ""
"\n"
"Continuare con l'annullamento delle modifiche attuali?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
-msgstr "Interruzione in corso"
+msgstr "Interruzione"
+
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "ripristino file"
#: lib/merge.tcl:266
msgid "Abort failed."
@@ -1661,82 +1727,98 @@ msgstr "Interruzione non riuscita."
msgid "Abort completed. Ready."
msgstr "Interruzione completata. Pronto."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "Ripristina valori predefiniti"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Salva"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "Archivio di %s"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Tutti gli archivi"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Nome utente"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "Indirizzo Email"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "Riepilogo nelle revisioni di fusione"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Prolissità della fusione"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Mostra statistiche delle differenze dopo la fusione"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "Fidati delle date di modifica dei file"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr ""
"Effettua potatura dei duplicati locali di rami remoti durante il recupero"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "Appaia duplicati locali di rami remoti"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
+msgid "Blame Copy Only On Changed Files"
+msgstr "Ricerca copie solo nei file modificati"
+
+#: lib/option.tcl:127
+msgid "Minimum Letters To Blame Copy On"
+msgstr "Numero minimo di lettere che attivano la ricerca delle copie"
+
+#: lib/option.tcl:128
msgid "Number of Diff Context Lines"
msgstr "Numero di linee di contesto nelle differenze"
-#: lib/option.tcl:114
+#: lib/option.tcl:129
+msgid "Commit Message Text Width"
+msgstr "Larghezza del messaggio di revisione"
+
+#: lib/option.tcl:130
msgid "New Branch Name Template"
msgstr "Modello per il nome di un nuovo ramo"
-#: lib/option.tcl:176
+#: lib/option.tcl:194
+msgid "Spelling Dictionary:"
+msgstr "Lingua dizionario:"
+
+#: lib/option.tcl:218
msgid "Change Font"
msgstr "Cambia caratteri"
-#: lib/option.tcl:180
+#: lib/option.tcl:222
#, tcl-format
msgid "Choose %s"
msgstr "Scegli %s"
-#: lib/option.tcl:186
+#: lib/option.tcl:228
msgid "pt."
msgstr "pt."
-#: lib/option.tcl:200
+#: lib/option.tcl:242
msgid "Preferences"
msgstr "Preferenze"
-#: lib/option.tcl:235
+#: lib/option.tcl:277
msgid "Failed to completely save options:"
msgstr "Impossibile salvare completamente le opzioni:"
@@ -1844,6 +1926,43 @@ msgstr "Impossibile scrivere shortcut:"
msgid "Cannot write icon:"
msgstr "Impossibile scrivere icona:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "Correttore ortografico non supportato"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "Correzione ortografica indisponibile"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "La configurazione del correttore ortografico non è valida"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Il dizionario è stato reimpostato su %s."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "Il correttore ortografico ha riportato un errore all'avvio"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "Correttore ortografico non riconosciuto"
+
+#: lib/spellcheck.tcl:186
+msgid "No Suggestions"
+msgstr "Nessun suggerimento"
+
+#: lib/spellcheck.tcl:387
+msgid "Unexpected EOF from spell checker"
+msgstr "Il correttore ortografico ha mandato un EOF inaspettato"
+
+#: lib/spellcheck.tcl:391
+msgid "Spell Checker Failed"
+msgstr "Errore nel correttore ortografico"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
diff --git a/git-gui/po/ja.po b/git-gui/po/ja.po
index e2cf5bdc0..5db44a4ad 100644
--- a/git-gui/po/ja.po
+++ b/git-gui/po/ja.po
@@ -8,41 +8,41 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2007-12-05 06:12+0900\n"
-"Last-Translator: ã—らã„ã— ãªãªã“ <nanako3@bluebottle.com>\n"
+"POT-Creation-Date: 2008-08-02 14:45-0700\n"
+"PO-Revision-Date: 2008-08-03 17:00+0900\n"
+"Last-Translator: ã—らã„ã— ãªãªã“ <nanako3@lavabit.com>\n"
"Language-Team: Japanese\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:688 git-gui.sh:702 git-gui.sh:715 git-gui.sh:798
+#: git-gui.sh:817
msgid "git-gui: fatal error"
msgstr "git-gui: 致命的ãªã‚¨ãƒ©ãƒ¼"
-#: git-gui.sh:565
+#: git-gui.sh:644
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "%s ã«ç„¡åŠ¹ãªãƒ•ã‚©ãƒ³ãƒˆãŒæŒ‡å®šã•ã‚Œã¦ã„ã¾ã™:"
-#: git-gui.sh:590
+#: git-gui.sh:674
msgid "Main Font"
msgstr "主フォント"
-#: git-gui.sh:591
+#: git-gui.sh:675
msgid "Diff/Console Font"
msgstr "diff/コンソール・フォント"
-#: git-gui.sh:605
+#: git-gui.sh:689
msgid "Cannot find git in PATH."
msgstr "PATH 中㫠git ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“"
-#: git-gui.sh:632
+#: git-gui.sh:716
msgid "Cannot parse Git version string:"
msgstr "Git ãƒãƒ¼ã‚¸ãƒ§ãƒ³åãŒç†è§£ã§ãã¾ã›ã‚“:"
-#: git-gui.sh:650
+#: git-gui.sh:734
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -61,380 +61,381 @@ msgstr ""
"\n"
"'%s' ã¯ãƒãƒ¼ã‚¸ãƒ§ãƒ³ 1.5.0 ã¨æ€ã£ã¦è‰¯ã„ã§ã™ã‹ï¼Ÿ\n"
-#: git-gui.sh:888
+#: git-gui.sh:972
msgid "Git directory not found:"
msgstr "Git ディレクトリãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“:"
-#: git-gui.sh:895
+#: git-gui.sh:979
msgid "Cannot move to top of working directory:"
msgstr "作業ディレクトリã®æœ€ä¸Šä½ã«ç§»å‹•ã§ãã¾ã›ã‚“"
-#: git-gui.sh:902
+#: git-gui.sh:986
msgid "Cannot use funny .git directory:"
msgstr "変㪠.git ディレクトリã¯ä½¿ãˆã¾ã›ã‚“"
-#: git-gui.sh:907
+#: git-gui.sh:991
msgid "No working directory"
msgstr "作業ディレクトリãŒã‚ã‚Šã¾ã›ã‚“"
-#: git-gui.sh:1054
+#: git-gui.sh:1138 lib/checkout_op.tcl:305
msgid "Refreshing file status..."
msgstr "ファイル状態を更新ã—ã¦ã„ã¾ã™â€¦"
-#: git-gui.sh:1119
+#: git-gui.sh:1194
msgid "Scanning for modified files ..."
msgstr "変更ã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«ã‚’スキャンã—ã¦ã„ã¾ã™â€¦"
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1369 lib/browser.tcl:246
msgid "Ready."
msgstr "準備完了"
-#: git-gui.sh:1560
+#: git-gui.sh:1635
msgid "Unmodified"
msgstr "変更無ã—"
-#: git-gui.sh:1562
+#: git-gui.sh:1637
msgid "Modified, not staged"
msgstr "変更ã‚ã‚Šã€ã‚³ãƒŸãƒƒãƒˆæœªäºˆå®š"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1638 git-gui.sh:1643
msgid "Staged for commit"
msgstr "コミット予定済"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1639 git-gui.sh:1644
msgid "Portions staged for commit"
msgstr "部分的ã«ã‚³ãƒŸãƒƒãƒˆäºˆå®šæ¸ˆ"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1640 git-gui.sh:1645
msgid "Staged for commit, missing"
msgstr "コミット予定済ã€ãƒ•ã‚¡ã‚¤ãƒ«ç„¡ã—"
-#: git-gui.sh:1567
+#: git-gui.sh:1642
msgid "Untracked, not staged"
msgstr "管ç†å¤–ã€ã‚³ãƒŸãƒƒãƒˆæœªäºˆå®š"
-#: git-gui.sh:1572
+#: git-gui.sh:1647
msgid "Missing"
msgstr "ファイル無ã—"
-#: git-gui.sh:1573
+#: git-gui.sh:1648
msgid "Staged for removal"
msgstr "削除予定済"
-#: git-gui.sh:1574
+#: git-gui.sh:1649
msgid "Staged for removal, still present"
msgstr "削除予定済ã€ãƒ•ã‚¡ã‚¤ãƒ«æœªå‰Šé™¤"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1651 git-gui.sh:1652 git-gui.sh:1653 git-gui.sh:1654
msgid "Requires merge resolution"
msgstr "è¦ãƒžãƒ¼ã‚¸è§£æ±º"
-#: git-gui.sh:1614
+#: git-gui.sh:1689
msgid "Starting gitk... please wait..."
msgstr "gitk を起動中…ãŠå¾…ã¡ä¸‹ã•ã„…"
-#: git-gui.sh:1623
-#, tcl-format
-msgid ""
-"Unable to start gitk:\n"
-"\n"
-"%s does not exist"
-msgstr ""
-"gitk ã‚’èµ·å‹•ã§ãã¾ã›ã‚“:\n"
-"\n"
-"%s ãŒã‚ã‚Šã¾ã›ã‚“"
+#: git-gui.sh:1698
+msgid "Couldn't find gitk in PATH"
+msgstr "PATH 中㫠gitk ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“"
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1948 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "リãƒã‚¸ãƒˆãƒª"
-#: git-gui.sh:1824
+#: git-gui.sh:1949
msgid "Edit"
msgstr "編集"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1951 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "ブランãƒ"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1954 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "コミット"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1957 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "マージ"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1958 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "リモート"
-#: git-gui.sh:1842
+#: git-gui.sh:1967
msgid "Browse Current Branch's Files"
msgstr "ç¾åœ¨ã®ãƒ–ランãƒã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’見る"
-#: git-gui.sh:1846
+#: git-gui.sh:1971
msgid "Browse Branch Files..."
msgstr "ブランãƒã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’見る…"
-#: git-gui.sh:1851
+#: git-gui.sh:1976
msgid "Visualize Current Branch's History"
msgstr "ç¾åœ¨ã®ãƒ–ランãƒã®å±¥æ­´ã‚’見る"
-#: git-gui.sh:1855
+#: git-gui.sh:1980
msgid "Visualize All Branch History"
msgstr "å…¨ã¦ã®ãƒ–ランãƒã®å±¥æ­´ã‚’見る"
-#: git-gui.sh:1862
+#: git-gui.sh:1987
#, tcl-format
msgid "Browse %s's Files"
msgstr "ブランム%s ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’見る"
-#: git-gui.sh:1864
+#: git-gui.sh:1989
#, tcl-format
msgid "Visualize %s's History"
msgstr "ブランム%s ã®å±¥æ­´ã‚’見る"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1994 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "データベース統計"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1997 lib/database.tcl:34
msgid "Compress Database"
msgstr "データベース圧縮"
-#: git-gui.sh:1875
+#: git-gui.sh:2000
msgid "Verify Database"
msgstr "データベース検証"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:2007 git-gui.sh:2011 git-gui.sh:2015 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "デスクトップ・アイコンを作る"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:2023 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "終了"
-#: git-gui.sh:1902
+#: git-gui.sh:2031
msgid "Undo"
msgstr "å…ƒã«æˆ»ã™"
-#: git-gui.sh:1905
+#: git-gui.sh:2034
msgid "Redo"
msgstr "ã‚„ã‚Šç›´ã—"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:2038 git-gui.sh:2545
msgid "Cut"
msgstr "切りå–ã‚Š"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:2041 git-gui.sh:2548 git-gui.sh:2622 git-gui.sh:2715
+#: lib/console.tcl:69
msgid "Copy"
msgstr "コピー"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:2044 git-gui.sh:2551
msgid "Paste"
msgstr "貼り付ã‘"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:2047 git-gui.sh:2554 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "削除"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:2051 git-gui.sh:2558 git-gui.sh:2719 lib/console.tcl:71
msgid "Select All"
msgstr "å…¨ã¦é¸æŠž"
-#: git-gui.sh:1931
+#: git-gui.sh:2060
msgid "Create..."
msgstr "作æˆâ€¦"
-#: git-gui.sh:1937
+#: git-gui.sh:2066
msgid "Checkout..."
msgstr "ãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆ"
-#: git-gui.sh:1943
+#: git-gui.sh:2072
msgid "Rename..."
msgstr "åå‰å¤‰æ›´â€¦"
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:2077 git-gui.sh:2187
msgid "Delete..."
msgstr "削除…"
-#: git-gui.sh:1953
+#: git-gui.sh:2082
msgid "Reset..."
msgstr "リセット…"
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2094 git-gui.sh:2491
msgid "New Commit"
msgstr "æ–°è¦ã‚³ãƒŸãƒƒãƒˆ"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2102 git-gui.sh:2498
msgid "Amend Last Commit"
msgstr "最新コミットを訂正"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2111 git-gui.sh:2458 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "å†ã‚¹ã‚­ãƒ£ãƒ³"
-#: git-gui.sh:1988
+#: git-gui.sh:2117
msgid "Stage To Commit"
msgstr "コミット予定ã™ã‚‹"
-#: git-gui.sh:1994
+#: git-gui.sh:2123
msgid "Stage Changed Files To Commit"
msgstr "変更ã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«ã‚’コミット予定"
-#: git-gui.sh:2000
+#: git-gui.sh:2129
msgid "Unstage From Commit"
msgstr "コミットã‹ã‚‰é™ã‚ã™"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2134 lib/index.tcl:395
msgid "Revert Changes"
msgstr "変更を元ã«æˆ»ã™"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2141 git-gui.sh:2702
+msgid "Show Less Context"
+msgstr "文脈を少ãªã"
+
+#: git-gui.sh:2145 git-gui.sh:2706
+msgid "Show More Context"
+msgstr "文脈を多ã"
+
+#: git-gui.sh:2151 git-gui.sh:2470 git-gui.sh:2569
msgid "Sign Off"
msgstr "ç½²å"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2155 git-gui.sh:2474
msgid "Commit@@verb"
msgstr "コミット"
-#: git-gui.sh:2027
+#: git-gui.sh:2166
msgid "Local Merge..."
msgstr "ローカル・マージ…"
-#: git-gui.sh:2032
+#: git-gui.sh:2171
msgid "Abort Merge..."
msgstr "マージ中止…"
-#: git-gui.sh:2044
+#: git-gui.sh:2183
msgid "Push..."
msgstr "プッシュ…"
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
-msgid "Apple"
-msgstr "ã‚Šã‚“ã”"
-
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2197 git-gui.sh:2219 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "%s ã«ã¤ã„ã¦"
-#: git-gui.sh:2062
+#: git-gui.sh:2201
msgid "Preferences..."
msgstr "設定…"
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2209 git-gui.sh:2740
msgid "Options..."
msgstr "オプション…"
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2215 lib/choose_repository.tcl:47
msgid "Help"
msgstr "ヘルプ"
-#: git-gui.sh:2117
+#: git-gui.sh:2256
msgid "Online Documentation"
msgstr "オンライン・ドキュメント"
-#: git-gui.sh:2201
+#: git-gui.sh:2340
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
msgstr ""
"致命的: パス %s ㌠stat ã§ãã¾ã›ã‚“。ãã®ã‚ˆã†ãªãƒ•ã‚¡ã‚¤ãƒ«ã‚„ディレクトリã¯ã‚ã‚Šã¾"
"ã›ã‚“"
-#: git-gui.sh:2234
+#: git-gui.sh:2373
msgid "Current Branch:"
msgstr "ç¾åœ¨ã®ãƒ–ランãƒ"
-#: git-gui.sh:2255
+#: git-gui.sh:2394
msgid "Staged Changes (Will Commit)"
msgstr "ステージングã•ã‚ŒãŸï¼ˆã‚³ãƒŸãƒƒãƒˆäºˆå®šæ¸ˆã®ï¼‰å¤‰æ›´"
-#: git-gui.sh:2274
+#: git-gui.sh:2414
msgid "Unstaged Changes"
msgstr "コミット予定ã«å…¥ã£ã¦ã„ãªã„変更"
-#: git-gui.sh:2323
+#: git-gui.sh:2464
msgid "Stage Changed"
msgstr "変更をコミット予定ã«å…¥ã‚Œã‚‹"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2480 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "プッシュ"
-#: git-gui.sh:2369
+#: git-gui.sh:2510
msgid "Initial Commit Message:"
msgstr "最åˆã®ã‚³ãƒŸãƒƒãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:"
-#: git-gui.sh:2370
+#: git-gui.sh:2511
msgid "Amended Commit Message:"
msgstr "訂正ã—ãŸã‚³ãƒŸãƒƒãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:"
-#: git-gui.sh:2371
+#: git-gui.sh:2512
msgid "Amended Initial Commit Message:"
msgstr "訂正ã—ãŸæœ€åˆã®ã‚³ãƒŸãƒƒãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:"
-#: git-gui.sh:2372
+#: git-gui.sh:2513
msgid "Amended Merge Commit Message:"
msgstr "訂正ã—ãŸãƒžãƒ¼ã‚¸ã‚³ãƒŸãƒƒãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸:"
-#: git-gui.sh:2373
+#: git-gui.sh:2514
msgid "Merge Commit Message:"
msgstr "マージコミットメッセージ:"
-#: git-gui.sh:2374
+#: git-gui.sh:2515
msgid "Commit Message:"
msgstr "コミットメッセージ:"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2561 git-gui.sh:2723 lib/console.tcl:73
msgid "Copy All"
msgstr "å…¨ã¦ã‚³ãƒ”ー"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2585 lib/blame.tcl:100
msgid "File:"
msgstr "ファイル:"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "å†èª­ã¿è¾¼ã¿"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2691
msgid "Apply/Reverse Hunk"
msgstr "パッãƒã‚’é©ç”¨/å–り消ã™"
-#: git-gui.sh:2572
+#: git-gui.sh:2696
+msgid "Apply/Reverse Line"
+msgstr "パッãƒè¡Œã‚’é©ç”¨/å–り消ã™"
+
+#: git-gui.sh:2711
+msgid "Refresh"
+msgstr "å†èª­ã¿è¾¼ã¿"
+
+#: git-gui.sh:2732
msgid "Decrease Font Size"
msgstr "フォントをå°ã•ã"
-#: git-gui.sh:2576
+#: git-gui.sh:2736
msgid "Increase Font Size"
msgstr "フォントを大ãã"
-#: git-gui.sh:2581
-msgid "Show Less Context"
-msgstr "文脈を少ãªã"
-
-#: git-gui.sh:2588
-msgid "Show More Context"
-msgstr "文脈を多ã"
-
-#: git-gui.sh:2602
+#: git-gui.sh:2747
msgid "Unstage Hunk From Commit"
msgstr "パッãƒã‚’コミット予定ã‹ã‚‰å¤–ã™"
-#: git-gui.sh:2604
+#: git-gui.sh:2748
+msgid "Unstage Line From Commit"
+msgstr "コミット予定ã‹ã‚‰è¡Œã‚’外ã™"
+
+#: git-gui.sh:2750
msgid "Stage Hunk For Commit"
msgstr "パッãƒã‚’コミット予定ã«åŠ ãˆã‚‹"
-#: git-gui.sh:2623
+#: git-gui.sh:2751
+msgid "Stage Line For Commit"
+msgstr "パッãƒè¡Œã‚’コミット予定ã«åŠ ãˆã‚‹"
+
+#: git-gui.sh:2771
msgid "Initializing..."
msgstr "åˆæœŸåŒ–ã—ã¦ã„ã¾ã™â€¦"
-#: git-gui.sh:2718
+#: git-gui.sh:2876
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -449,7 +450,7 @@ msgstr ""
"以下ã®ç’°å¢ƒå¤‰æ•°ã¯ %s ãŒèµ·å‹•ã™ã‚‹ Git サブプロセスã«ã‚ˆã£ã¦ç„¡è¦–ã•ã‚Œã‚‹ã§ã—ょã†:\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2906
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -459,7 +460,7 @@ msgstr ""
"ã“れ㯠Cygwin ã§é…布ã•ã‚Œã¦ã„ã‚‹ Tcl ãƒã‚¤ãƒŠãƒªã«\n"
"é–¢ã—ã¦ã®æ—¢çŸ¥ã®å•é¡Œã«ã‚ˆã‚Šã¾ã™"
-#: git-gui.sh:2753
+#: git-gui.sh:2911
#, tcl-format
msgid ""
"\n"
@@ -474,68 +475,84 @@ msgstr ""
"個人的㪠~/.gitconfig ファイル内㧠user.name 㨠user.email ã®å€¤ã‚’設定\n"
"ã™ã‚‹ã®ãŒã€%s ã®è‰¯ã„代用ã¨ãªã‚Šã¾ã™\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "Git ã®ã‚°ãƒ©ãƒ•ã‚£ã‚«ãƒ«UI git-gui"
-#: lib/blame.tcl:77
+#: lib/blame.tcl:70
msgid "File Viewer"
msgstr "ファイルピューワ"
-#: lib/blame.tcl:81
+#: lib/blame.tcl:74
msgid "Commit:"
msgstr "コミット:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:257
msgid "Copy Commit"
msgstr "コミットをコピー"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:260
+msgid "Do Full Copy Detection"
+msgstr "コピー検知"
+
+#: lib/blame.tcl:388
#, tcl-format
msgid "Reading %s..."
msgstr "%s を読んã§ã„ã¾ã™â€¦"
-#: lib/blame.tcl:473
+#: lib/blame.tcl:492
msgid "Loading copy/move tracking annotations..."
msgstr "コピー・移動追跡データを読んã§ã„ã¾ã™â€¦"
-#: lib/blame.tcl:493
+#: lib/blame.tcl:512
msgid "lines annotated"
msgstr "行を注釈ã—ã¾ã—ãŸ"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:704
msgid "Loading original location annotations..."
msgstr "å…ƒä½ç½®è¡Œã®æ³¨é‡ˆãƒ‡ãƒ¼ã‚¿ã‚’読んã§ã„ã¾ã™â€¦"
-#: lib/blame.tcl:677
+#: lib/blame.tcl:707
msgid "Annotation complete."
msgstr "注釈完了ã—ã¾ã—ãŸ"
-#: lib/blame.tcl:731
+#: lib/blame.tcl:737
+msgid "Busy"
+msgstr "実行中"
+
+#: lib/blame.tcl:738
+msgid "Annotation process is already running."
+msgstr "ã™ã§ã« blame プロセスを実行中ã§ã™ã€‚"
+
+#: lib/blame.tcl:777
+msgid "Running thorough copy detection..."
+msgstr "コピー検知を実行中…"
+
+#: lib/blame.tcl:827
msgid "Loading annotation..."
msgstr "注釈を読ã¿è¾¼ã‚“ã§ã„ã¾ã™â€¦"
-#: lib/blame.tcl:787
+#: lib/blame.tcl:883
msgid "Author:"
msgstr "作者:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:887
msgid "Committer:"
msgstr "コミット者:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:892
msgid "Original File:"
msgstr "元ファイル"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:1006
msgid "Originally By:"
msgstr "原作者:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:1012
msgid "In File:"
msgstr "ファイル:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:1017
msgid "Copied Or Moved Here By:"
msgstr "複写・移動者:"
@@ -548,17 +565,17 @@ msgid "Checkout"
msgstr "ãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆ"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:544 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "中止"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "リビジョン"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:244
msgid "Options"
msgstr "オプション"
@@ -578,7 +595,7 @@ msgstr "ブランãƒã‚’作æˆ"
msgid "Create New Branch"
msgstr "ブランãƒã‚’æ–°è¦ä½œæˆ"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "作æˆ"
@@ -610,7 +627,7 @@ msgstr "ã„ã„ãˆ"
msgid "Fast Forward Only"
msgstr "æ—©é€ã‚Šã®ã¿"
-#: lib/branch_create.tcl:85 lib/checkout_op.tcl:514
+#: lib/branch_create.tcl:85 lib/checkout_op.tcl:536
msgid "Reset"
msgstr "リセット"
@@ -700,7 +717,7 @@ msgstr "æ–°ã—ã„åå‰:"
msgid "Please select a branch to rename."
msgstr "åå‰ã‚’変更ã™ã‚‹ãƒ–ランãƒã‚’é¸ã‚“ã§ä¸‹ã•ã„。"
-#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:179
+#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:201
#, tcl-format
msgid "Branch '%s' already exists."
msgstr "'%s'ã¨ã„ã†ãƒ–ランãƒã¯æ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚"
@@ -718,45 +735,50 @@ msgstr "起動中…"
msgid "File Browser"
msgstr "ファイル・ブラウザ"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "%s をロード中…"
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[上ä½ãƒ•ã‚©ãƒ«ãƒ€ã¸]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "ç¾åœ¨ã®ãƒ–ランãƒã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’見る"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:472 lib/choose_repository.tcl:482
+#: lib/choose_repository.tcl:985
msgid "Browse"
msgstr "ブラウズ"
-#: lib/checkout_op.tcl:79
+#: lib/checkout_op.tcl:84
#, tcl-format
msgid "Fetching %s from %s"
msgstr "%s ã‹ã‚‰ %s をフェッãƒã—ã¦ã„ã¾ã™"
-#: lib/checkout_op.tcl:127
+#: lib/checkout_op.tcl:132
#, tcl-format
msgid "fatal: Cannot resolve %s"
msgstr "致命的エラー: %s を解決ã§ãã¾ã›ã‚“"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:145 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "é–‰ã˜ã‚‹"
-#: lib/checkout_op.tcl:169
+#: lib/checkout_op.tcl:174
#, tcl-format
msgid "Branch '%s' does not exist."
msgstr "ブランãƒ'%s'ã¯å­˜åœ¨ã—ã¾ã›ã‚“。"
-#: lib/checkout_op.tcl:206
+#: lib/checkout_op.tcl:193
+#, tcl-format
+msgid "Failed to configure simplified git-pull for '%s'."
+msgstr "'%s' ã«ç°¡æ˜“ git-pull を設定ã§ãã¾ã›ã‚“ã§ã—ãŸ"
+
+#: lib/checkout_op.tcl:228
#, tcl-format
msgid ""
"Branch '%s' already exists.\n"
@@ -769,21 +791,21 @@ msgstr ""
"%s ã«æ—©é€ã‚Šã§ãã¾ã›ã‚“。\n"
"マージãŒå¿…è¦ã§ã™ã€‚"
-#: lib/checkout_op.tcl:220
+#: lib/checkout_op.tcl:242
#, tcl-format
msgid "Merge strategy '%s' not supported."
msgstr "'%s' マージ戦略ã¯ã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã›ã‚“。"
-#: lib/checkout_op.tcl:239
+#: lib/checkout_op.tcl:261
#, tcl-format
msgid "Failed to update '%s'."
msgstr "'%s' ã®æ›´æ–°ã«å¤±æ•—ã—ã¾ã—ãŸã€‚"
-#: lib/checkout_op.tcl:251
+#: lib/checkout_op.tcl:273
msgid "Staging area (index) is already locked."
msgstr "インデックスã¯æ—¢ã«ãƒ­ãƒƒã‚¯ã•ã‚Œã¦ã„ã¾ã™ã€‚"
-#: lib/checkout_op.tcl:266
+#: lib/checkout_op.tcl:288
msgid ""
"Last scanned state does not match repository state.\n"
"\n"
@@ -799,26 +821,30 @@ msgstr ""
"\n"
"自動的ã«å†ã‚¹ã‚­ãƒ£ãƒ³ã‚’開始ã—ã¾ã™ã€‚\n"
-#: lib/checkout_op.tcl:322
+#: lib/checkout_op.tcl:344
#, tcl-format
msgid "Updating working directory to '%s'..."
msgstr "作業ディレクトリを '%s' ã«æ›´æ–°ã—ã¦ã„ã¾ã™â€¦"
-#: lib/checkout_op.tcl:353
+#: lib/checkout_op.tcl:345
+msgid "files checked out"
+msgstr "ãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«"
+
+#: lib/checkout_op.tcl:375
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
msgstr "'%s' ã®ãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆã‚’中止ã—ã¾ã—ãŸï¼ˆãƒ•ã‚¡ã‚¤ãƒ«æ¯Žã®ãƒžãƒ¼ã‚¸ãŒå¿…è¦ã§ã™ï¼‰ã€‚"
-#: lib/checkout_op.tcl:354
+#: lib/checkout_op.tcl:376
msgid "File level merge required."
msgstr "ファイル毎ã®ãƒžãƒ¼ã‚¸ãŒå¿…è¦ã§ã™ã€‚"
-#: lib/checkout_op.tcl:358
+#: lib/checkout_op.tcl:380
#, tcl-format
msgid "Staying on branch '%s'."
msgstr "ブランム'%s' ã«æ»žã¾ã‚Šã¾ã™ã€‚"
-#: lib/checkout_op.tcl:429
+#: lib/checkout_op.tcl:451
msgid ""
"You are no longer on a local branch.\n"
"\n"
@@ -830,30 +856,30 @@ msgstr ""
"ブランãƒä¸Šã«æ»žã¾ã‚ŠãŸã„ã¨ãã¯ã€ã“ã®ã€Œåˆ†é›¢ã•ã‚ŒãŸãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆã€ã‹ã‚‰æ–°è¦ãƒ–ラン"
"ãƒã‚’開始ã—ã¦ãã ã•ã„。"
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:468 lib/checkout_op.tcl:472
#, tcl-format
msgid "Checked out '%s'."
msgstr "'%s' ã‚’ãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆã—ã¾ã—ãŸ"
-#: lib/checkout_op.tcl:478
+#: lib/checkout_op.tcl:500
#, tcl-format
msgid "Resetting '%s' to '%s' will lose the following commits:"
msgstr "'%s' ã‚’ '%s' ã«ãƒªã‚»ãƒƒãƒˆã™ã‚‹ã¨ã€ä»¥ä¸‹ã®ã‚³ãƒŸãƒƒãƒˆãŒå¤±ãªã‚ã‚Œã¾ã™:"
-#: lib/checkout_op.tcl:500
+#: lib/checkout_op.tcl:522
msgid "Recovering lost commits may not be easy."
msgstr "失ãªã‚ã‚ŒãŸã‚³ãƒŸãƒƒãƒˆã‚’回復ã™ã‚‹ã®ã¯ç°¡å˜ã§ã¯ã‚ã‚Šã¾ã›ã‚“。"
-#: lib/checkout_op.tcl:505
+#: lib/checkout_op.tcl:527
#, tcl-format
msgid "Reset '%s'?"
msgstr "'%s' をリセットã—ã¾ã™ã‹ï¼Ÿ"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:532 lib/merge.tcl:163
msgid "Visualize"
msgstr "å¯è¦–化"
-#: lib/checkout_op.tcl:578
+#: lib/checkout_op.tcl:600
#, tcl-format
msgid ""
"Failed to set current branch.\n"
@@ -877,15 +903,15 @@ msgstr "é¸æŠž"
msgid "Font Family"
msgstr "フォント・ファミリー"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "フォントã®å¤§ãã•"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "フォント・サンプル"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -893,225 +919,225 @@ msgstr ""
"ã“ã‚Œã¯ã‚µãƒ³ãƒ—ル文ã§ã™ã€‚\n"
"ã“ã®ãƒ•ã‚©ãƒ³ãƒˆãŒæ°—ã«å…¥ã‚Œã°ãŠä½¿ã„ã«ãªã‚Œã¾ã™ã€‚"
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git GUI"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "æ–°ã—ã„リãƒã‚¸ãƒˆãƒªã‚’作る"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "æ–°è¦â€¦"
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:458
msgid "Clone Existing Repository"
msgstr "既存リãƒã‚¸ãƒˆãƒªã‚’複製ã™ã‚‹"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "複製…"
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:974
msgid "Open Existing Repository"
msgstr "既存リãƒã‚¸ãƒˆãƒªã‚’é–‹ã"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "é–‹ã…"
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "最近使ã£ãŸãƒªãƒã‚¸ãƒˆãƒª"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "最近使ã£ãŸãƒªãƒã‚¸ãƒˆãƒªã‚’é–‹ã"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "'%s' ã¯æ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚"
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "リãƒã‚¸ãƒˆãƒª %s を作製ã§ãã¾ã›ã‚“:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:476
msgid "Directory:"
msgstr "ディレクトリ:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:410 lib/choose_repository.tcl:535
+#: lib/choose_repository.tcl:1007
msgid "Git Repository"
msgstr "GIT リãƒã‚¸ãƒˆãƒª"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:435
#, tcl-format
msgid "Directory %s already exists."
msgstr "ディレクトリ '%s' ã¯æ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚"
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:439
#, tcl-format
msgid "File %s already exists."
msgstr "ファイル '%s' ã¯æ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚"
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:453
msgid "Clone"
msgstr "複製"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:466
msgid "URL:"
msgstr "URL:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:487
msgid "Clone Type:"
msgstr "複製方å¼:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:493
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "標準(高速・中冗長度・ãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:499
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "全複写(低速・冗長ãƒãƒƒã‚¯ã‚¢ãƒƒãƒ—)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:505
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "共有(最高速・éžæŽ¨å¥¨ãƒ»ãƒãƒƒã‚¯ã‚¢ãƒƒãƒ—ç„¡ã—)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:541 lib/choose_repository.tcl:588
+#: lib/choose_repository.tcl:734 lib/choose_repository.tcl:804
+#: lib/choose_repository.tcl:1013 lib/choose_repository.tcl:1021
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "Git リãƒã‚¸ãƒˆãƒªã§ã¯ã‚ã‚Šã¾ã›ã‚“: %s"
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:577
msgid "Standard only available for local repository."
msgstr "標準方å¼ã¯åŒä¸€è¨ˆç®—機上ã®ãƒªãƒã‚¸ãƒˆãƒªã«ã®ã¿ä½¿ãˆã¾ã™ã€‚"
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:581
msgid "Shared only available for local repository."
msgstr "共有方å¼ã¯åŒä¸€è¨ˆç®—機上ã®ãƒªãƒã‚¸ãƒˆãƒªã«ã®ã¿ä½¿ãˆã¾ã™ã€‚"
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:602
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "'%s' ã¯æ—¢ã«å­˜åœ¨ã—ã¾ã™ã€‚"
+
+#: lib/choose_repository.tcl:613
msgid "Failed to configure origin"
msgstr "origin を設定ã§ãã¾ã›ã‚“ã§ã—ãŸ"
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:625
msgid "Counting objects"
msgstr "オブジェクトを数ãˆã¦ã„ã¾ã™"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:626
msgid "buckets"
msgstr "ãƒã‚±ãƒ„"
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:650
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "objects/info/alternates を複写ã§ãã¾ã›ã‚“: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:686
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "%s ã‹ã‚‰è¤‡è£½ã™ã‚‹å†…容ã¯ã‚ã‚Šã¾ã›ã‚“"
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:688 lib/choose_repository.tcl:902
+#: lib/choose_repository.tcl:914
msgid "The 'master' branch has not been initialized."
msgstr "'master' ブランãƒãŒåˆæœŸåŒ–ã•ã‚Œã¦ã„ã¾ã›ã‚“"
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:701
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "ãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯ãŒä½œã‚Œãªã„ã®ã§ã€ã‚³ãƒ”ーã—ã¾ã™"
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:713
#, tcl-format
msgid "Cloning from %s"
msgstr "%s ã‹ã‚‰è¤‡è£½ã—ã¦ã„ã¾ã™"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:744
msgid "Copying objects"
msgstr "オブジェクトを複写ã—ã¦ã„ã¾ã™"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:745
msgid "KiB"
msgstr "KiB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:769
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "オブジェクトを複写ã§ãã¾ã›ã‚“: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:779
msgid "Linking objects"
msgstr "オブジェクトを連çµã—ã¦ã„ã¾ã™"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:780
msgid "objects"
msgstr "オブジェクト"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:788
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "オブジェクトをãƒãƒ¼ãƒ‰ãƒªãƒ³ã‚¯ã§ãã¾ã›ã‚“: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:843
msgid "Cannot fetch branches and objects. See console output for details."
msgstr "ブランãƒã‚„オブジェクトをå–å¾—ã§ãã¾ã›ã‚“。コンソール出力を見ã¦ä¸‹ã•ã„"
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:854
msgid "Cannot fetch tags. See console output for details."
msgstr "ã‚¿ã‚°ã‚’å–å¾—ã§ãã¾ã›ã‚“。コンソール出力を見ã¦ä¸‹ã•ã„"
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:878
msgid "Cannot determine HEAD. See console output for details."
msgstr "HEAD を確定ã§ãã¾ã›ã‚“。コンソール出力を見ã¦ä¸‹ã•ã„"
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:887
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "%s を掃除ã§ãã¾ã›ã‚“"
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:893
msgid "Clone failed."
msgstr "複写ã«å¤±æ•—ã—ã¾ã—ãŸã€‚"
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:900
msgid "No default branch obtained."
msgstr "デフォールト・ブランãƒãŒå–å¾—ã•ã‚Œã¾ã›ã‚“ã§ã—ãŸ"
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:911
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "%s をコミットã¨ã—ã¦è§£é‡ˆã§ãã¾ã›ã‚“"
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:923
msgid "Creating working directory"
msgstr "作業ディレクトリを作æˆã—ã¦ã„ã¾ã™"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:924 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "ファイル"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:953
msgid "Initial file checkout failed."
msgstr "åˆæœŸãƒã‚§ãƒƒã‚¯ã‚¢ã‚¦ãƒˆã«å¤±æ•—ã—ã¾ã—ãŸ"
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:969
msgid "Open"
msgstr "é–‹ã"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:979
msgid "Repository:"
msgstr "リãƒã‚¸ãƒˆãƒª:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1027
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "リãƒã‚¸ãƒˆãƒª %s ã‚’é–‹ã‘ã¾ã›ã‚“:"
@@ -1132,7 +1158,7 @@ msgstr "ローカル・ブランãƒ"
msgid "Tracking Branch"
msgstr "トラッキング・ブランãƒ"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "ã‚¿ã‚°"
@@ -1149,11 +1175,11 @@ msgstr "リビジョンãŒæœªé¸æŠžã§ã™ã€‚"
msgid "Revision expression is empty."
msgstr "リビジョンå¼ãŒç©ºã§ã™ã€‚"
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "æ›´æ–°ã—ã¾ã—ãŸ"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "URL"
@@ -1262,16 +1288,45 @@ msgstr ""
"- 第2行: 空白\n"
"- 残りã®è¡Œ: ãªãœã€ã“ã®å¤‰æ›´ãŒè‰¯ã„変更ã‹ã€ã®èª¬æ˜Žã€‚\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "警告: Tcl ã¯ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚° '%s' をサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã›ã‚“"
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "コミットå‰ãƒ•ãƒƒã‚¯ã‚’実行中・・・"
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "コミットå‰ãƒ•ãƒƒã‚¯ãŒã‚³ãƒŸãƒƒãƒˆã‚’æ‹’å¦ã—ã¾ã—ãŸ"
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "コミット・メッセージ・フックを実行中・・・"
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "コミット・メッセージ・フックãŒã‚³ãƒŸãƒƒãƒˆã‚’æ‹’å¦ã—ã¾ã—ãŸ"
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "変更点をコミット中・・・"
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "write-tree ãŒå¤±æ•—ã—ã¾ã—ãŸ:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "コミットã«å¤±æ•—ã—ã¾ã—ãŸã€‚"
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "コミット %s ã¯å£Šã‚Œã¦ã„ã¾ã™"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1285,37 +1340,32 @@ msgstr ""
"\n"
"自動的ã«å†ã‚¹ã‚­ãƒ£ãƒ³ã‚’開始ã—ã¾ã™ã€‚\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "コミットã™ã‚‹å¤‰æ›´ãŒã‚ã‚Šã¾ã›ã‚“。"
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "警告: Tcl ã¯ã‚¨ãƒ³ã‚³ãƒ¼ãƒ‡ã‚£ãƒ³ã‚° '%s' をサãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã›ã‚“"
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "commit-tree ãŒå¤±æ•—ã—ã¾ã—ãŸ:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "update-ref ãŒå¤±æ•—ã—ã¾ã—ãŸ:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "コミット %s を作æˆã—ã¾ã—ãŸ: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "実行中…ãŠå¾…ã¡ä¸‹ã•ã„…"
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "æˆåŠŸ"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "エラー: コマンドãŒå¤±æ•—ã—ã¾ã—ãŸ"
@@ -1377,7 +1427,7 @@ msgstr ""
msgid "Invalid date from Git: %s"
msgstr "Git ã‹ã‚‰å‡ºãŸç„¡åŠ¹ãªæ—¥ä»˜: %s"
-#: lib/diff.tcl:42
+#: lib/diff.tcl:44
#, tcl-format
msgid ""
"No differences detected.\n"
@@ -1399,49 +1449,57 @@ msgstr ""
"\n"
"åŒæ§˜ãªçŠ¶æ…‹ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’探ã™ãŸã‚ã«ã€è‡ªå‹•çš„ã«å†ã‚¹ã‚­ãƒ£ãƒ³ã‚’開始ã—ã¾ã™ã€‚"
-#: lib/diff.tcl:81
+#: lib/diff.tcl:83
#, tcl-format
msgid "Loading diff of %s..."
msgstr "%s ã®å¤‰æ›´ç‚¹ã‚’ロード中…"
-#: lib/diff.tcl:114 lib/diff.tcl:184
+#: lib/diff.tcl:116 lib/diff.tcl:190
#, tcl-format
msgid "Unable to display %s"
msgstr "%s を表示ã§ãã¾ã›ã‚“"
-#: lib/diff.tcl:115
+#: lib/diff.tcl:117
msgid "Error loading file:"
msgstr "ファイルを読む際ã®ã‚¨ãƒ©ãƒ¼ã§ã™:"
-#: lib/diff.tcl:122
+#: lib/diff.tcl:124
msgid "Git Repository (subproject)"
msgstr "Git リãƒã‚¸ãƒˆãƒª(サブプロジェクト)"
-#: lib/diff.tcl:134
+#: lib/diff.tcl:136
msgid "* Binary file (not showing content)."
msgstr "* ãƒã‚¤ãƒŠãƒªãƒ•ã‚¡ã‚¤ãƒ«(内容ã¯è¡¨ç¤ºã—ã¾ã›ã‚“)"
-#: lib/diff.tcl:185
+#: lib/diff.tcl:191
msgid "Error loading diff:"
msgstr "diff を読む際ã®ã‚¨ãƒ©ãƒ¼ã§ã™:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:313
msgid "Failed to unstage selected hunk."
msgstr "é¸æŠžã•ã‚ŒãŸãƒ‘ッãƒã‚’コミット予定ã‹ã‚‰å¤–ã›ã¾ã›ã‚“。"
-#: lib/diff.tcl:309
+#: lib/diff.tcl:320
msgid "Failed to stage selected hunk."
msgstr "é¸æŠžã•ã‚ŒãŸãƒ‘ッãƒã‚’コミット予定ã«åŠ ãˆã‚‰ã‚Œã¾ã›ã‚“。"
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/diff.tcl:386
+msgid "Failed to unstage selected line."
+msgstr "é¸æŠžã•ã‚ŒãŸãƒ‘ッãƒè¡Œã‚’コミット予定ã‹ã‚‰å¤–ã›ã¾ã›ã‚“。"
+
+#: lib/diff.tcl:394
+msgid "Failed to stage selected line."
+msgstr "é¸æŠžã•ã‚ŒãŸãƒ‘ッãƒè¡Œã‚’コミット予定ã«åŠ ãˆã‚‰ã‚Œã¾ã›ã‚“。"
+
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "エラー"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "警告"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr "コミットã™ã‚‹å‰ã«ã€ä»¥ä¸Šã®ã‚¨ãƒ©ãƒ¼ã‚’修正ã—ã¦ä¸‹ã•ã„"
@@ -1457,7 +1515,9 @@ msgstr "索引エラー"
msgid ""
"Updating the Git index failed. A rescan will be automatically started to "
"resynchronize git-gui."
-msgstr "GIT インデックスã®æ›´æ–°ãŒå¤±æ•—ã—ã¾ã—ãŸã€‚git-gui ã¨åŒæœŸã‚’ã¨ã‚‹ãŸã‚ã«å†ã‚¹ã‚­ãƒ£ãƒ³ã—ã¾ã™ã€‚"
+msgstr ""
+"GIT インデックスã®æ›´æ–°ãŒå¤±æ•—ã—ã¾ã—ãŸã€‚git-gui ã¨åŒæœŸã‚’ã¨ã‚‹ãŸã‚ã«å†ã‚¹ã‚­ãƒ£ãƒ³ã—"
+"ã¾ã™ã€‚"
#: lib/index.tcl:27
msgid "Continue"
@@ -1472,6 +1532,10 @@ msgstr "インデックスã®ãƒ­ãƒƒã‚¯è§£é™¤"
msgid "Unstaging %s from commit"
msgstr "コミットã‹ã‚‰ '%s' ã‚’é™ã‚ã™"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "コミット準備完了"
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1487,11 +1551,11 @@ msgstr "ファイル %s ã«ã—ãŸå¤‰æ›´ã‚’å…ƒã«æˆ»ã—ã¾ã™ã‹ï¼Ÿ"
msgid "Revert changes in these %i files?"
msgstr "ã“れら %i 個ã®ãƒ•ã‚¡ã‚¤ãƒ«ã«ã—ãŸå¤‰æ›´ã‚’å…ƒã«æˆ»ã—ã¾ã™ã‹ï¼Ÿ"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
msgstr "変更を元ã«æˆ»ã™ã¨ã‚³ãƒŸãƒƒãƒˆäºˆå®šã—ã¦ã„ãªã„変更ã¯å…¨ã¦å¤±ã‚ã‚Œã¾ã™ã€‚"
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "何もã—ãªã„"
@@ -1562,27 +1626,27 @@ msgstr "%s ã® %s ブランãƒ"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "%s 㨠%s をマージã—ã¾ã™"
+msgid "Merging %s and %s..."
+msgstr "%s 㨠%s をマージ中・・・"
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "マージãŒå®Œäº†ã—ã¾ã—ãŸ"
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "マージãŒå¤±æ•—ã—ã¾ã—ãŸã€‚è¡çªã®è§£æ±ºãŒå¿…è¦ã§ã™ã€‚"
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "%s ã«ãƒžãƒ¼ã‚¸"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "マージã™ã‚‹ãƒªãƒ“ジョン"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1592,7 +1656,7 @@ msgstr ""
"\n"
"ã¾ãšä»Šã®ã‚³ãƒŸãƒƒãƒˆè¨‚正を完了ã•ã›ã¦ä¸‹ã•ã„。\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1606,7 +1670,7 @@ msgstr ""
"\n"
"マージを中断ã—ã¦ã‚ˆã‚ã—ã„ã§ã™ã‹ï¼Ÿ"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1620,10 +1684,14 @@ msgstr ""
"\n"
"リセットã—ã¦ã‚ˆã‚ã—ã„ã§ã™ã‹ï¼Ÿ"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "中断ã—ã¦ã„ã¾ã™"
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "リセットã—ãŸãƒ•ã‚¡ã‚¤ãƒ«"
+
#: lib/merge.tcl:266
msgid "Abort failed."
msgstr "中断ã«å¤±æ•—ã—ã¾ã—ãŸã€‚"
@@ -1632,84 +1700,112 @@ msgstr "中断ã«å¤±æ•—ã—ã¾ã—ãŸã€‚"
msgid "Abort completed. Ready."
msgstr "中断完了。"
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "既定値ã«æˆ»ã™"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "ä¿å­˜"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "%s リãƒã‚¸ãƒˆãƒª"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "大域(全ã¦ã®ãƒªãƒã‚¸ãƒˆãƒªï¼‰"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "ユーザå"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "é›»å­ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "マージコミットã®è¦ç´„"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "マージã®å†—長度"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "マージ後㫠diffstat を表示"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "ファイル変更時刻を信頼ã™ã‚‹"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr "フェッãƒä¸­ã«ãƒˆãƒ©ãƒƒã‚­ãƒ³ã‚°ãƒ–ランãƒã‚’刈る"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "トラッキングブランãƒã‚’åˆã‚ã›ã‚‹"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
+msgid "Blame Copy Only On Changed Files"
+msgstr "変更ã•ã‚ŒãŸãƒ•ã‚¡ã‚¤ãƒ«ã®ã¿ã‚³ãƒ”ー検知を行ãªã†"
+
+#: lib/option.tcl:127
+msgid "Minimum Letters To Blame Copy On"
+msgstr "コピーを検知ã™ã‚‹æœ€å°‘文字数"
+
+#: lib/option.tcl:128
msgid "Number of Diff Context Lines"
msgstr "diff ã®æ–‡è„ˆè¡Œæ•°"
-#: lib/option.tcl:114
+#: lib/option.tcl:129
+msgid "Commit Message Text Width"
+msgstr "コミットメッセージã®ãƒ†ã‚­ã‚¹ãƒˆå¹…"
+
+#: lib/option.tcl:130
msgid "New Branch Name Template"
msgstr "æ–°ã—ã„ブランãƒåã®ãƒ†ãƒ³ãƒ—レート"
-#: lib/option.tcl:176
+#: lib/option.tcl:194
+msgid "Spelling Dictionary:"
+msgstr "スペルãƒã‚§ãƒƒã‚¯è¾žæ›¸"
+
+#: lib/option.tcl:218
msgid "Change Font"
msgstr "フォントを変更"
-#: lib/option.tcl:180
+#: lib/option.tcl:222
#, tcl-format
msgid "Choose %s"
msgstr "%s ã‚’é¸æŠž"
-#: lib/option.tcl:186
+#: lib/option.tcl:228
msgid "pt."
msgstr "ãƒã‚¤ãƒ³ãƒˆ"
-#: lib/option.tcl:200
+#: lib/option.tcl:242
msgid "Preferences"
msgstr "設定"
-#: lib/option.tcl:235
+#: lib/option.tcl:277
msgid "Failed to completely save options:"
msgstr "完全ã«ã‚ªãƒ—ションをä¿å­˜ã§ãã¾ã›ã‚“:"
+#: lib/remote.tcl:165
+msgid "Prune from"
+msgstr "ã‹ã‚‰åˆˆè¾¼ã‚€â€¦"
+
+#: lib/remote.tcl:170
+msgid "Fetch from"
+msgstr "å–å¾—å…ƒ"
+
+#: lib/remote.tcl:213
+msgid "Push to"
+msgstr "プッシュ先"
+
#: lib/remote_branch_delete.tcl:29 lib/remote_branch_delete.tcl:34
msgid "Delete Remote Branch"
msgstr "リモート・ブランãƒã‚’削除"
@@ -1794,18 +1890,6 @@ msgstr "リãƒã‚¸ãƒˆãƒªãŒé¸æŠžã•ã‚Œã¦ã„ã¾ã›ã‚“。"
msgid "Scanning %s..."
msgstr "%s をスキャンã—ã¦ã„ã¾ã™â€¦"
-#: lib/remote.tcl:165
-msgid "Prune from"
-msgstr "ã‹ã‚‰åˆˆè¾¼ã‚€â€¦"
-
-#: lib/remote.tcl:170
-msgid "Fetch from"
-msgstr "å–å¾—å…ƒ"
-
-#: lib/remote.tcl:213
-msgid "Push to"
-msgstr "プッシュ先"
-
#: lib/shortcut.tcl:20 lib/shortcut.tcl:61
msgid "Cannot write shortcut:"
msgstr "ショートカットãŒæ›¸ã‘ã¾ã›ã‚“:"
@@ -1814,6 +1898,43 @@ msgstr "ショートカットãŒæ›¸ã‘ã¾ã›ã‚“:"
msgid "Cannot write icon:"
msgstr "アイコンãŒæ›¸ã‘ã¾ã›ã‚“:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "サãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ãªã„スペルãƒã‚§ãƒƒã‚«ãƒ¼ã§ã™"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "スペルãƒã‚§ãƒƒã‚¯æ©Ÿèƒ½ã¯ä½¿ãˆã¾ã›ã‚“"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "スペルãƒã‚§ãƒƒã‚¯ã®è¨­å®šãŒä¸æ­£ã§ã™"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "辞書を %s ã«å·»ã戻ã—ã¾ã™"
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "スペルãƒã‚§ãƒƒã‚«ãƒ¼ã®èµ·å‹•ã«å¤±æ•—ã—ã¾ã—ãŸ"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "スペルãƒã‚§ãƒƒã‚«ãƒ¼ãŒåˆ¤åˆ¥ã§ãã¾ã›ã‚“"
+
+#: lib/spellcheck.tcl:186
+msgid "No Suggestions"
+msgstr "æ案ãªã—"
+
+#: lib/spellcheck.tcl:387
+msgid "Unexpected EOF from spell checker"
+msgstr "スペルãƒã‚§ãƒƒã‚«ãƒ¼ãŒäºˆæƒ³å¤–ã® EOF ã‚’è¿”ã—ã¾ã—ãŸ"
+
+#: lib/spellcheck.tcl:391
+msgid "Spell Checker Failed"
+msgstr "スペルãƒã‚§ãƒƒã‚¯å¤±æ•—"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
diff --git a/git-gui/po/po2msg.sh b/git-gui/po/po2msg.sh
index c63248e37..b7c4bf3fd 100644
--- a/git-gui/po/po2msg.sh
+++ b/git-gui/po/po2msg.sh
@@ -127,7 +127,26 @@ foreach file $files {
}
if {$show_statistics} {
- puts [concat "$translated_count translated messages, " \
- "$fuzzy_count fuzzy ones, " \
- "$not_translated_count untranslated ones."]
+ set str ""
+
+ append str "$translated_count translated message"
+ if {$translated_count != 1} {
+ append str s
+ }
+
+ if {$fuzzy_count > 1} {
+ append str ", $fuzzy_count fuzzy translation"
+ if {$fuzzy_count != 1} {
+ append str s
+ }
+ }
+ if {$not_translated_count > 0} {
+ append str ", $not_translated_count untranslated message"
+ if {$not_translated_count != 1} {
+ append str s
+ }
+ }
+
+ append str .
+ puts $str
}
diff --git a/git-gui/po/ru.po b/git-gui/po/ru.po
index 6727a832e..db55b3e0a 100644
--- a/git-gui/po/ru.po
+++ b/git-gui/po/ru.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-10-31 21:23+0100\n"
+"POT-Creation-Date: 2008-03-14 07:18+0100\n"
"PO-Revision-Date: 2007-10-22 22:30-0200\n"
"Last-Translator: Alex Riesen <raa.lkml@gmail.com>\n"
"Language-Team: Russian Translation <git@vger.kernel.org>\n"
@@ -15,33 +15,33 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: git-gui.sh:41 git-gui.sh:597 git-gui.sh:611 git-gui.sh:624 git-gui.sh:707
-#: git-gui.sh:726
+#: git-gui.sh:41 git-gui.sh:634 git-gui.sh:648 git-gui.sh:661 git-gui.sh:744
+#: git-gui.sh:763
msgid "git-gui: fatal error"
msgstr "git-gui: критичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°"
-#: git-gui.sh:558
+#: git-gui.sh:593
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Ð’ %s уÑтановлен неверный шрифт:"
-#: git-gui.sh:583
+#: git-gui.sh:620
msgid "Main Font"
msgstr "Шрифт интерфейÑа"
-#: git-gui.sh:584
+#: git-gui.sh:621
msgid "Diff/Console Font"
msgstr "Шрифт конÑоли и изменений (diff)"
-#: git-gui.sh:598
+#: git-gui.sh:635
msgid "Cannot find git in PATH."
msgstr "git не найден в PATH."
-#: git-gui.sh:625
+#: git-gui.sh:662
msgid "Cannot parse Git version string:"
msgstr "Ðевозможно раÑпознать Ñтроку верÑии Git: "
-#: git-gui.sh:643
+#: git-gui.sh:680
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -59,79 +59,79 @@ msgstr ""
"\n"
"ПринÑÑ‚ÑŒ '%s' как верÑию 1.5.0?\n"
-#: git-gui.sh:881
+#: git-gui.sh:918
msgid "Git directory not found:"
msgstr "Каталог Git не найден:"
-#: git-gui.sh:888
+#: git-gui.sh:925
msgid "Cannot move to top of working directory:"
msgstr "Ðевозможно перейти к корню рабочего каталога репозиториÑ: "
-#: git-gui.sh:895
+#: git-gui.sh:932
msgid "Cannot use funny .git directory:"
msgstr "Каталог.git иÑпорчен: "
-#: git-gui.sh:900
+#: git-gui.sh:937
msgid "No working directory"
msgstr "ОтÑутÑтвует рабочий каталог"
-#: git-gui.sh:1047
+#: git-gui.sh:1084 lib/checkout_op.tcl:283
msgid "Refreshing file status..."
msgstr "Обновление информации о ÑоÑтоÑнии файлов..."
-#: git-gui.sh:1112
+#: git-gui.sh:1149
msgid "Scanning for modified files ..."
msgstr "ПоиÑк измененных файлов..."
-#: git-gui.sh:1287 lib/browser.tcl:245
+#: git-gui.sh:1324 lib/browser.tcl:246
msgid "Ready."
msgstr "Готово."
-#: git-gui.sh:1553
+#: git-gui.sh:1590
msgid "Unmodified"
msgstr "Ðе изменено"
-#: git-gui.sh:1555
+#: git-gui.sh:1592
msgid "Modified, not staged"
msgstr "Изменено, не подготовлено"
-#: git-gui.sh:1556 git-gui.sh:1561
+#: git-gui.sh:1593 git-gui.sh:1598
msgid "Staged for commit"
msgstr "Подготовлено Ð´Ð»Ñ ÑохранениÑ"
-#: git-gui.sh:1557 git-gui.sh:1562
+#: git-gui.sh:1594 git-gui.sh:1599
msgid "Portions staged for commit"
msgstr "ЧаÑти, подготовленные Ð´Ð»Ñ ÑохранениÑ"
-#: git-gui.sh:1558 git-gui.sh:1563
+#: git-gui.sh:1595 git-gui.sh:1600
msgid "Staged for commit, missing"
msgstr "Подготовлено Ð´Ð»Ñ ÑохранениÑ, отÑутÑтвует"
-#: git-gui.sh:1560
+#: git-gui.sh:1597
msgid "Untracked, not staged"
msgstr "Ðе отÑлеживаетÑÑ, не подготовлено"
-#: git-gui.sh:1565
+#: git-gui.sh:1602
msgid "Missing"
msgstr "ОтÑутÑтвует"
-#: git-gui.sh:1566
+#: git-gui.sh:1603
msgid "Staged for removal"
msgstr "Подготовлено Ð´Ð»Ñ ÑƒÐ´Ð°Ð»ÐµÐ½Ð¸Ñ"
-#: git-gui.sh:1567
+#: git-gui.sh:1604
msgid "Staged for removal, still present"
msgstr "Подготовлено Ð´Ð»Ñ ÑƒÐ´Ð°Ð»ÐµÐ½Ð¸Ñ, еще не удалено"
-#: git-gui.sh:1569 git-gui.sh:1570 git-gui.sh:1571 git-gui.sh:1572
+#: git-gui.sh:1606 git-gui.sh:1607 git-gui.sh:1608 git-gui.sh:1609
msgid "Requires merge resolution"
msgstr "ТребуетÑÑ Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ðµ конфликта при объединении"
-#: git-gui.sh:1607
+#: git-gui.sh:1644
msgid "Starting gitk... please wait..."
msgstr "ЗапуÑкаетÑÑ gitk... пожалуйÑта, ждите..."
-#: git-gui.sh:1616
+#: git-gui.sh:1653
#, tcl-format
msgid ""
"Unable to start gitk:\n"
@@ -142,295 +142,295 @@ msgstr ""
"\n"
"%s не ÑущеÑтвует"
-#: git-gui.sh:1816 lib/choose_repository.tcl:35
+#: git-gui.sh:1860 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Репозиторий"
-#: git-gui.sh:1817
+#: git-gui.sh:1861
msgid "Edit"
msgstr "Редактировать"
-#: git-gui.sh:1819 lib/choose_rev.tcl:560
+#: git-gui.sh:1863 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Ветвь"
-#: git-gui.sh:1822 lib/choose_rev.tcl:547
+#: git-gui.sh:1866 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "СоÑтоÑние"
-#: git-gui.sh:1825 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1869 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Объединить"
-#: git-gui.sh:1826 lib/choose_rev.tcl:556
+#: git-gui.sh:1870 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Внешние репозитории"
-#: git-gui.sh:1835
+#: git-gui.sh:1879
msgid "Browse Current Branch's Files"
msgstr "ПроÑмотреть файлы текущей ветви"
-#: git-gui.sh:1839
+#: git-gui.sh:1883
msgid "Browse Branch Files..."
msgstr "Показать файлы ветви..."
-#: git-gui.sh:1844
+#: git-gui.sh:1888
msgid "Visualize Current Branch's History"
msgstr "ИÑÑ‚Ð¾Ñ€Ð¸Ñ Ñ‚ÐµÐºÑƒÑ‰ÐµÐ¹ ветви наглÑдно"
-#: git-gui.sh:1848
+#: git-gui.sh:1892
msgid "Visualize All Branch History"
msgstr "ИÑÑ‚Ð¾Ñ€Ð¸Ñ Ð²Ñех ветвей наглÑдно"
-#: git-gui.sh:1855
+#: git-gui.sh:1899
#, tcl-format
msgid "Browse %s's Files"
msgstr "Показать файлы ветви %s"
-#: git-gui.sh:1857
+#: git-gui.sh:1901
#, tcl-format
msgid "Visualize %s's History"
msgstr "ИÑÑ‚Ð¾Ñ€Ð¸Ñ Ð²ÐµÑ‚Ð²Ð¸ %s наглÑдно"
-#: git-gui.sh:1862 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1906 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "СтатиÑтика базы данных"
-#: git-gui.sh:1865 lib/database.tcl:34
+#: git-gui.sh:1909 lib/database.tcl:34
msgid "Compress Database"
msgstr "Сжать базу данных"
-#: git-gui.sh:1868
+#: git-gui.sh:1912
msgid "Verify Database"
msgstr "Проверить базу данных"
-#: git-gui.sh:1875 git-gui.sh:1879 git-gui.sh:1883 lib/shortcut.tcl:7
+#: git-gui.sh:1919 git-gui.sh:1923 git-gui.sh:1927 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Создать Ñрлык на рабочем Ñтоле"
-#: git-gui.sh:1888 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:1932 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Выход"
-#: git-gui.sh:1895
+#: git-gui.sh:1939
msgid "Undo"
msgstr "Отменить"
-#: git-gui.sh:1898
+#: git-gui.sh:1942
msgid "Redo"
msgstr "Повторить"
-#: git-gui.sh:1902 git-gui.sh:2395
+#: git-gui.sh:1946 git-gui.sh:2443
msgid "Cut"
msgstr "Вырезать"
-#: git-gui.sh:1905 git-gui.sh:2398 git-gui.sh:2469 git-gui.sh:2541
-#: lib/console.tcl:67
+#: git-gui.sh:1949 git-gui.sh:2446 git-gui.sh:2520 git-gui.sh:2614
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Копировать"
-#: git-gui.sh:1908 git-gui.sh:2401
+#: git-gui.sh:1952 git-gui.sh:2449
msgid "Paste"
msgstr "Ð’Ñтавить"
-#: git-gui.sh:1911 git-gui.sh:2404 lib/branch_delete.tcl:26
+#: git-gui.sh:1955 git-gui.sh:2452 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Удалить"
-#: git-gui.sh:1915 git-gui.sh:2408 git-gui.sh:2545 lib/console.tcl:69
+#: git-gui.sh:1959 git-gui.sh:2456 git-gui.sh:2618 lib/console.tcl:71
msgid "Select All"
msgstr "Выделить вÑе"
-#: git-gui.sh:1924
+#: git-gui.sh:1968
msgid "Create..."
msgstr "Создать..."
-#: git-gui.sh:1930
+#: git-gui.sh:1974
msgid "Checkout..."
msgstr "Перейти..."
-#: git-gui.sh:1936
+#: git-gui.sh:1980
msgid "Rename..."
msgstr "Переименовать..."
-#: git-gui.sh:1941 git-gui.sh:2040
+#: git-gui.sh:1985 git-gui.sh:2085
msgid "Delete..."
msgstr "Удалить..."
-#: git-gui.sh:1946
+#: git-gui.sh:1990
msgid "Reset..."
msgstr "СброÑить..."
-#: git-gui.sh:1958 git-gui.sh:2342
+#: git-gui.sh:2002 git-gui.sh:2389
msgid "New Commit"
msgstr "Ðовое ÑоÑтоÑние"
-#: git-gui.sh:1966 git-gui.sh:2349
+#: git-gui.sh:2010 git-gui.sh:2396
msgid "Amend Last Commit"
msgstr "ИÑправить поÑледнее ÑоÑтоÑние"
-#: git-gui.sh:1975 git-gui.sh:2309 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2019 git-gui.sh:2356 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Перечитать"
-#: git-gui.sh:1981
+#: git-gui.sh:2025
msgid "Stage To Commit"
msgstr "Подготовить Ð´Ð»Ñ ÑохранениÑ"
-#: git-gui.sh:1986
+#: git-gui.sh:2031
msgid "Stage Changed Files To Commit"
msgstr "Подготовить измененные файлы Ð´Ð»Ñ ÑохранениÑ"
-#: git-gui.sh:1992
+#: git-gui.sh:2037
msgid "Unstage From Commit"
msgstr "Убрать из подготовленного"
-#: git-gui.sh:1997 lib/index.tcl:393
+#: git-gui.sh:2042 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Отменить изменениÑ"
-#: git-gui.sh:2004 git-gui.sh:2321 git-gui.sh:2419
+#: git-gui.sh:2049 git-gui.sh:2368 git-gui.sh:2467
msgid "Sign Off"
msgstr "ПодпиÑать"
-#: git-gui.sh:2008 git-gui.sh:2325
+#: git-gui.sh:2053 git-gui.sh:2372
msgid "Commit@@verb"
msgstr "Сохранить"
-#: git-gui.sh:2019
+#: git-gui.sh:2064
msgid "Local Merge..."
msgstr "Локальное объединение..."
-#: git-gui.sh:2024
+#: git-gui.sh:2069
msgid "Abort Merge..."
msgstr "Прервать объединение..."
-#: git-gui.sh:2036
+#: git-gui.sh:2081
msgid "Push..."
msgstr "Отправить..."
-#: git-gui.sh:2047 lib/choose_repository.tcl:40
+#: git-gui.sh:2092 lib/choose_repository.tcl:41
msgid "Apple"
msgstr ""
-#: git-gui.sh:2050 git-gui.sh:2072 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2095 git-gui.sh:2117 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "О %s"
-#: git-gui.sh:2054
+#: git-gui.sh:2099
msgid "Preferences..."
msgstr "ÐаÑтройки..."
-#: git-gui.sh:2062 git-gui.sh:2587
+#: git-gui.sh:2107 git-gui.sh:2639
msgid "Options..."
msgstr "ÐаÑтройки..."
-#: git-gui.sh:2068 lib/choose_repository.tcl:46
+#: git-gui.sh:2113 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Помощь"
-#: git-gui.sh:2109
+#: git-gui.sh:2154
msgid "Online Documentation"
msgstr "Ð”Ð¾ÐºÑƒÐ¼ÐµÐ½Ñ‚Ð°Ñ†Ð¸Ñ Ð² интернете"
-#: git-gui.sh:2193
+#: git-gui.sh:2238
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
msgstr "критичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°: %s: нет такого файла или каталога"
-#: git-gui.sh:2226
+#: git-gui.sh:2271
msgid "Current Branch:"
msgstr "Ð¢ÐµÐºÑƒÑ‰Ð°Ñ Ð²ÐµÑ‚Ð²ÑŒ:"
-#: git-gui.sh:2247
+#: git-gui.sh:2292
msgid "Staged Changes (Will Commit)"
msgstr "Подготовлено (будет Ñохранено)"
-#: git-gui.sh:2266
+#: git-gui.sh:2312
msgid "Unstaged Changes"
msgstr "Изменено (не будет Ñохранено)"
-#: git-gui.sh:2315
+#: git-gui.sh:2362
msgid "Stage Changed"
msgstr "Подготовить вÑе"
-#: git-gui.sh:2331 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2378 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Отправить"
-#: git-gui.sh:2361
+#: git-gui.sh:2408
msgid "Initial Commit Message:"
msgstr "Комментарий к первому ÑоÑтоÑнию:"
-#: git-gui.sh:2362
+#: git-gui.sh:2409
msgid "Amended Commit Message:"
msgstr "Комментарий к иÑправленному ÑоÑтоÑнию:"
-#: git-gui.sh:2363
+#: git-gui.sh:2410
msgid "Amended Initial Commit Message:"
msgstr "Комментарий к иÑправленному первоначальному ÑоÑтоÑнию:"
-#: git-gui.sh:2364
+#: git-gui.sh:2411
msgid "Amended Merge Commit Message:"
msgstr "Комментарий к иÑправленному объединению:"
-#: git-gui.sh:2365
+#: git-gui.sh:2412
msgid "Merge Commit Message:"
msgstr "Комментарий к объединению:"
-#: git-gui.sh:2366
+#: git-gui.sh:2413
msgid "Commit Message:"
msgstr "Комментарий к ÑоÑтоÑнию:"
-#: git-gui.sh:2411 git-gui.sh:2549 lib/console.tcl:71
+#: git-gui.sh:2459 git-gui.sh:2622 lib/console.tcl:73
msgid "Copy All"
msgstr "Копировать вÑе"
-#: git-gui.sh:2435 lib/blame.tcl:104
+#: git-gui.sh:2483 lib/blame.tcl:107
msgid "File:"
msgstr "Файл:"
-#: git-gui.sh:2537
-msgid "Refresh"
-msgstr "Обновить"
-
-#: git-gui.sh:2558
+#: git-gui.sh:2589
msgid "Apply/Reverse Hunk"
msgstr "Применить/Убрать изменение"
-#: git-gui.sh:2564
-msgid "Decrease Font Size"
-msgstr "Уменьшить размер шрифта"
-
-#: git-gui.sh:2568
-msgid "Increase Font Size"
-msgstr "Увеличить размер шрифта"
-
-#: git-gui.sh:2573
+#: git-gui.sh:2595
msgid "Show Less Context"
msgstr "Меньше контекÑта"
-#: git-gui.sh:2580
+#: git-gui.sh:2602
msgid "Show More Context"
msgstr "Больше контекÑта"
-#: git-gui.sh:2594
+#: git-gui.sh:2610
+msgid "Refresh"
+msgstr "Обновить"
+
+#: git-gui.sh:2631
+msgid "Decrease Font Size"
+msgstr "Уменьшить размер шрифта"
+
+#: git-gui.sh:2635
+msgid "Increase Font Size"
+msgstr "Увеличить размер шрифта"
+
+#: git-gui.sh:2646
msgid "Unstage Hunk From Commit"
msgstr "Ðе ÑохранÑÑ‚ÑŒ чаÑÑ‚ÑŒ"
-#: git-gui.sh:2596
+#: git-gui.sh:2648
msgid "Stage Hunk For Commit"
msgstr "Подготовить чаÑÑ‚ÑŒ Ð´Ð»Ñ ÑохранениÑ"
-#: git-gui.sh:2615
+#: git-gui.sh:2667
msgid "Initializing..."
msgstr "ИнициализациÑ..."
-#: git-gui.sh:2706
+#: git-gui.sh:2762
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -447,7 +447,7 @@ msgstr ""
"запущенными из %s\n"
"\n"
-#: git-gui.sh:2736
+#: git-gui.sh:2792
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -457,7 +457,7 @@ msgstr ""
"Это извеÑÑ‚Ð½Ð°Ñ Ð¿Ñ€Ð¾Ð±Ð»ÐµÐ¼Ð° Ñ Tcl,\n"
"раÑпроÑтранÑемым Cygwin."
-#: git-gui.sh:2741
+#: git-gui.sh:2797
#, tcl-format
msgid ""
"\n"
@@ -474,7 +474,7 @@ msgstr ""
"user.email в Вашем перÑональном\n"
"файле ~/.gitconfig.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - графичеÑкий пользовательÑкий Ð¸Ð½Ñ‚ÐµÑ€Ñ„ÐµÐ¹Ñ Ðº Git."
@@ -486,56 +486,56 @@ msgstr "ПроÑмотр файла"
msgid "Commit:"
msgstr "Сохраненное ÑоÑтоÑние:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:264
msgid "Copy Commit"
msgstr "Скопировать SHA-1"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:384
#, tcl-format
msgid "Reading %s..."
msgstr "Чтение %s..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:488
msgid "Loading copy/move tracking annotations..."
msgstr "Загрузка аннотации копирований/переименований..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:508
msgid "lines annotated"
msgstr "Ñтрок прокомментировано"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:689
msgid "Loading original location annotations..."
msgstr "Загрузка аннотаций первоначального Ð¿Ð¾Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð¾Ð±ÑŠÐµÐºÑ‚Ð°..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:692
msgid "Annotation complete."
msgstr "ÐÐ½Ð½Ð¾Ñ‚Ð°Ñ†Ð¸Ñ Ð·Ð°Ð²ÐµÑ€ÑˆÐµÐ½Ð°."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:746
msgid "Loading annotation..."
msgstr "Загрузка аннотации..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:802
msgid "Author:"
msgstr "Ðвтор:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:806
msgid "Committer:"
msgstr "Сохранил:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:811
msgid "Original File:"
msgstr "ИÑходный файл:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:925
msgid "Originally By:"
msgstr "ИÑточник:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:931
msgid "In File:"
msgstr "Файл:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:936
msgid "Copied Or Moved Here By:"
msgstr "Скопировано/перемещено в:"
@@ -548,17 +548,17 @@ msgid "Checkout"
msgstr "Перейти"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Отменить"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "ВерÑиÑ"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:242
msgid "Options"
msgstr "ÐаÑтройки"
@@ -578,7 +578,7 @@ msgstr "Создание ветви"
msgid "Create New Branch"
msgstr "Создать новую ветвь"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Создать"
@@ -718,22 +718,22 @@ msgstr "ЗапуÑк..."
msgid "File Browser"
msgstr "ПроÑмотр ÑпиÑка файлов"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "Загрузка %s..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Ðа уровень выше]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "Показать файлы ветви"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:474 lib/choose_repository.tcl:484
+#: lib/choose_repository.tcl:987
msgid "Browse"
msgstr "Показать"
@@ -747,7 +747,7 @@ msgstr "Получение %s из %s "
msgid "fatal: Cannot resolve %s"
msgstr "критичеÑÐºÐ°Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ°: невозможно разрешить %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:140 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Закрыть"
@@ -804,6 +804,10 @@ msgstr ""
msgid "Updating working directory to '%s'..."
msgstr "Обновление рабочего каталога из '%s'..."
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
+msgstr "файлы извлечены"
+
#: lib/checkout_op.tcl:353
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
@@ -830,7 +834,7 @@ msgstr ""
"ЕÑли вы хотите Ñнова вернутьÑÑ Ðº какой-нибудь ветви, Ñоздайте ее ÑейчаÑ, "
"Ð½Ð°Ñ‡Ð¸Ð½Ð°Ñ Ñ 'Текущего отÑоединенного ÑоÑтоÑниÑ'."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:446 lib/checkout_op.tcl:450
#, tcl-format
msgid "Checked out '%s'."
msgstr "Ветвь '%s' Ñделана текущей."
@@ -849,7 +853,7 @@ msgstr "ВоÑÑтановить потерÑнные Ñохраненные ÑÐ
msgid "Reset '%s'?"
msgstr "СброÑить '%s'?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:510 lib/merge.tcl:163
msgid "Visualize"
msgstr "ÐаглÑдно"
@@ -878,15 +882,15 @@ msgstr "Выбрать"
msgid "Font Family"
msgstr "Шрифт"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Размер шрифта"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Пример текÑта"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -894,226 +898,226 @@ msgstr ""
"Это пример текÑта.\n"
"ЕÑли Вам нравитÑÑ Ñтот текÑÑ‚, Ñто может быть Ваш шрифт."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr ""
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Создать новый репозиторий"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Ðовый..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:460
msgid "Clone Existing Repository"
msgstr "Склонировать ÑущеÑтвующий репозиторий"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Склонировать..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:976
msgid "Open Existing Repository"
msgstr "Выбрать ÑущеÑтвующий репозиторий"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Открыть..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Ðедавние репозитории"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Открыть поÑледний репозиторий"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "Путь '%s' уже ÑущеÑтвует."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "Ðе удалоÑÑŒ Ñоздать репозиторий %s:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:478
msgid "Directory:"
msgstr "Каталог:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:412 lib/choose_repository.tcl:537
+#: lib/choose_repository.tcl:1011
msgid "Git Repository"
msgstr "Репозиторий"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:437
#, tcl-format
msgid "Directory %s already exists."
msgstr "Каталог '%s' уже ÑущеÑтвует."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:441
#, tcl-format
msgid "File %s already exists."
msgstr "Файл '%s' уже ÑущеÑтвует."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:455
msgid "Clone"
msgstr "Склонировать"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:468
msgid "URL:"
msgstr "СÑылка:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:489
msgid "Clone Type:"
msgstr "Тип клона:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:495
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Стандартный (БыÑтрый, полуизбыточный, \"жеÑткие\" ÑÑылки)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:501
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "ÐŸÐ¾Ð»Ð½Ð°Ñ ÐºÐ¾Ð¿Ð¸Ñ (Медленный, Ñоздает резервную копию)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:507
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Общий (Самый быÑтрый, не рекомендуетÑÑ, без резервной копии)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:543 lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:736 lib/choose_repository.tcl:806
+#: lib/choose_repository.tcl:1017 lib/choose_repository.tcl:1025
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "Каталог не ÑвлÑетÑÑ Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸ÐµÐ¼: %s"
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:579
msgid "Standard only available for local repository."
msgstr "Стандартный клон возможен только Ð´Ð»Ñ Ð»Ð¾ÐºÐ°Ð»ÑŒÐ½Ð¾Ð³Ð¾ репозиториÑ."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:583
msgid "Shared only available for local repository."
msgstr "Общий клон возможен только Ð´Ð»Ñ Ð»Ð¾ÐºÐ°Ð»ÑŒÐ½Ð¾Ð³Ð¾ репозиториÑ."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:604
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "Путь '%s' уже ÑущеÑтвует."
+
+#: lib/choose_repository.tcl:615
msgid "Failed to configure origin"
msgstr "Ðе могу Ñконфигурировать иÑходный репозиторий."
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:627
msgid "Counting objects"
msgstr "Считаю объекты"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:628
msgid "buckets"
msgstr ""
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:652
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Ðе могу Ñкопировать objects/info/alternates: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:688
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Ðечего клонировать Ñ %s."
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:690 lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:916
msgid "The 'master' branch has not been initialized."
msgstr "Ðе инициализирована ветвь 'master'."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:703
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "\"ЖеÑткие ÑÑылки\" не доÑтупны. Буду иÑпользовать копирование."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:715
#, tcl-format
msgid "Cloning from %s"
msgstr "Клонирование %s"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:746
msgid "Copying objects"
msgstr "Копирование objects"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:747
msgid "KiB"
msgstr "КБ"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:771
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Ðе могу Ñкопировать объект: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:781
msgid "Linking objects"
msgstr "Создание ÑÑылок на objects"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:782
msgid "objects"
msgstr "объекты"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:790
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Ðе могу \"жеÑтко ÑвÑзать\" объект: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:845
msgid "Cannot fetch branches and objects. See console output for details."
msgstr ""
"Ðе могу получить ветви и объекты. Ð”Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð½Ð° конÑоли."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:856
msgid "Cannot fetch tags. See console output for details."
msgstr "Ðе могу получить метки. Ð”Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð½Ð° конÑоли."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:880
msgid "Cannot determine HEAD. See console output for details."
msgstr "Ðе могу определить HEAD. Ð”Ð¾Ð¿Ð¾Ð»Ð½Ð¸Ñ‚ÐµÐ»ÑŒÐ½Ð°Ñ Ð¸Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð½Ð° конÑоли."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:889
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Ðе могу очиÑтить %s"
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:895
msgid "Clone failed."
msgstr "Клонирование не удалоÑÑŒ."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:902
msgid "No default branch obtained."
msgstr "Ðе было получено ветви по умолчанию."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:913
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "Ðе могу раÑпознать %s как ÑоÑтоÑние."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:925
msgid "Creating working directory"
msgstr "Создаю рабочий каталог"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:926 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "файлов"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:955
msgid "Initial file checkout failed."
msgstr "Ðе удалоÑÑŒ получить начальное ÑоÑтоÑние файлов репозиториÑ."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:971
msgid "Open"
msgstr "Открыть"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:981
msgid "Repository:"
msgstr "Репозиторий:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1031
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Ðе удалоÑÑŒ открыть репозиторий %s:"
@@ -1134,7 +1138,7 @@ msgstr "Ð›Ð¾ÐºÐ°Ð»ÑŒÐ½Ð°Ñ Ð²ÐµÑ‚Ð²ÑŒ:"
msgid "Tracking Branch"
msgstr "Ветвь ÑлежениÑ"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Таг"
@@ -1151,11 +1155,11 @@ msgstr "ВерÑÐ¸Ñ Ð½Ðµ указана."
msgid "Revision expression is empty."
msgstr "ПуÑтое выражение Ð´Ð»Ñ Ð¾Ð¿Ñ€ÐµÐ´ÐµÐ»ÐµÐ½Ð¸Ñ Ð²ÐµÑ€Ñии."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Обновлено"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "СÑылка"
@@ -1251,7 +1255,7 @@ msgid ""
"\n"
"A good commit message has the following format:\n"
"\n"
-"- First line: Describe in one sentance what you did.\n"
+"- First line: Describe in one sentence what you did.\n"
"- Second line: Blank\n"
"- Remaining lines: Describe why this change is good.\n"
msgstr ""
@@ -1263,16 +1267,45 @@ msgstr ""
"- Ð²Ñ‚Ð¾Ñ€Ð°Ñ Ñтрока пуÑтаÑ\n"
"- оÑтавшиеÑÑ Ñтроки: опишите, что дают ваши изменениÑ.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "предупреждение: Tcl не поддерживает кодировку '%s'."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "Вызов программы поддержки Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ pre-commit..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "Сохранение прервано программой поддержки Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ pre-commit"
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "Вызов программы поддержки Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ commit-msg..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "Сохранение прервано программой поддержки Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ commit-msg"
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Сохранение изменений..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "Программа write-tree завершилаÑÑŒ Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ¾Ð¹:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Сохранить ÑоÑтоÑние не удалоÑÑŒ."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "СоÑтоÑние %s выглÑдит поврежденным"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1286,37 +1319,32 @@ msgstr ""
"\n"
"Ð¡ÐµÐ¹Ñ‡Ð°Ñ Ð°Ð²Ñ‚Ð¾Ð¼Ð°Ñ‚Ð¸Ñ‡ÐµÑки запуÑтитÑÑ Ð¿ÐµÑ€ÐµÑ‡Ð¸Ñ‚Ñ‹Ð²Ð°Ð½Ð¸Ðµ репозиториÑ.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "ОтуÑтвуют Ð¸Ð·Ð¼ÐµÐ½Ð¸Ñ Ð´Ð»Ñ ÑохранениÑ."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "предупреждение: Tcl не поддерживает кодировку '%s'."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "Программа commit-tree завершилаÑÑŒ Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ¾Ð¹:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "Программа update-ref завершилаÑÑŒ Ñ Ð¾ÑˆÐ¸Ð±ÐºÐ¾Ð¹:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Создано ÑоÑтоÑние %s: %s "
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Ð’ процеÑÑе... пожалуйÑта, ждите..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "ПроцеÑÑ ÑƒÑпешно завершен"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Ошибка: не удалоÑÑŒ выполнить команду"
@@ -1426,23 +1454,23 @@ msgstr "* Двоичный файл (Ñодержимое не показано)
msgid "Error loading diff:"
msgstr "Ошибка загрузки diff:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:303
msgid "Failed to unstage selected hunk."
msgstr "Ðе удалоÑÑŒ иÑключить выбранную чаÑÑ‚ÑŒ."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:310
msgid "Failed to stage selected hunk."
msgstr "Ðе удалоÑÑŒ подготовить к Ñохранению выбранную чаÑÑ‚ÑŒ."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "ошибка"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "предупреждение"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr "Прежде чем Ñохранить, иÑправьте вышеуказанные ошибки."
@@ -1459,8 +1487,8 @@ msgid ""
"Updating the Git index failed. A rescan will be automatically started to "
"resynchronize git-gui."
msgstr ""
-"Ðе удалоÑÑŒ обновить Ð¸Ð½Ð´ÐµÐºÑ Git. СоÑтоÑние Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ Ð±ÑƒÐ´ÐµÑ‚"
-"перечитано автоматичеÑки."
+"Ðе удалоÑÑŒ обновить Ð¸Ð½Ð´ÐµÐºÑ Git. СоÑтоÑние Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ Ð±ÑƒÐ´ÐµÑ‚Ð¿ÐµÑ€ÐµÑ‡Ð¸Ñ‚Ð°Ð½Ð¾ "
+"автоматичеÑки."
#: lib/index.tcl:27
msgid "Continue"
@@ -1475,6 +1503,10 @@ msgstr "Разблокировать индекÑ"
msgid "Unstaging %s from commit"
msgstr "Удаление %s из подготовленного"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Подготовлено Ð´Ð»Ñ ÑохранениÑ"
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1490,13 +1522,13 @@ msgstr "Отменить Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð² файле %s?"
msgid "Revert changes in these %i files?"
msgstr "Отменить Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð² %i файле(-ах)?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
msgstr ""
"Любые изменениÑ, не подготовленные к Ñохранению, будут потерÑны при данной "
"операции."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Ðичего не делать"
@@ -1567,28 +1599,27 @@ msgid "%s of %s"
msgstr "%s из %s"
#: lib/merge.tcl:119
-#, tcl-format
-msgid "Merging %s and %s"
-msgstr "Объединение %s и %s"
+msgid "Merging %s and %s..."
+msgstr "Объединение %s и %s..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "Объединение уÑпешно завершено."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "Ðе удалоÑÑŒ завершить объединение. ТребуетÑÑ Ñ€Ð°Ð·Ñ€ÐµÑˆÐµÐ½Ð¸Ðµ конфликта."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "Объединить Ñ %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "ВерÑÐ¸Ñ Ð´Ð»Ñ Ð¾Ð±ÑŠÐµÐ´Ð¸Ð½ÐµÐ½Ð¸Ñ"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1598,7 +1629,7 @@ msgstr ""
"\n"
"Завершите текущее иÑправление Ñохраненного ÑоÑтоÑниÑ.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1612,7 +1643,7 @@ msgstr ""
"\n"
"Продолжить?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1626,94 +1657,106 @@ msgstr ""
"\n"
"Продолжить?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "Прерываю"
-#: lib/merge.tcl:266
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð² файлах отменены"
+
+#: lib/merge.tcl:265
msgid "Abort failed."
msgstr "Прервать не удалоÑÑŒ."
-#: lib/merge.tcl:268
+#: lib/merge.tcl:267
msgid "Abort completed. Ready."
msgstr "Прервано."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "ВоÑÑтановить наÑтройки по умолчанию"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Сохранить"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "Ð´Ð»Ñ Ñ€ÐµÐ¿Ð¾Ð·Ð¸Ñ‚Ð¾Ñ€Ð¸Ñ %s"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Общие (Ð´Ð»Ñ Ð²Ñех репозиториев)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Ð˜Ð¼Ñ Ð¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ñ‚ÐµÐ»Ñ"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
-msgstr "ÐÐ´ÐµÑ Ñлектронной почты"
+msgstr "ÐÐ´Ñ€ÐµÑ Ñлектронной почты"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "Суммарный комментарий при объединении"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Уровень детальноÑти Ñообщений при объединении"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Показать отчет об изменениÑÑ… поÑле объединениÑ"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "ДоверÑÑ‚ÑŒ времени модификации файла"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr "ЧиÑтка ветвей ÑÐ»ÐµÐ¶ÐµÐ½Ð¸Ñ Ð¿Ñ€Ð¸ получении изменений"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "Ð˜Ð¼Ñ Ð½Ð¾Ð²Ð¾Ð¹ ветви взÑÑ‚ÑŒ из имен ветвей ÑлежениÑ"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
msgid "Number of Diff Context Lines"
msgstr "ЧиÑло Ñтрок в контекÑте diff"
-#: lib/option.tcl:114
+#: lib/option.tcl:127
+msgid "Commit Message Text Width"
+msgstr "Ширина ÐºÐ¾Ð¼Ð¼ÐµÐ½Ñ‚Ð°Ñ€Ð¸Ñ Ðº ÑоÑтоÑнию:"
+
+#: lib/option.tcl:128
msgid "New Branch Name Template"
msgstr "Шаблон Ð´Ð»Ñ Ð¸Ð¼ÐµÐ½Ð¸ новой ветви"
-#: lib/option.tcl:176
+#: lib/option.tcl:192
+msgid "Spelling Dictionary:"
+msgstr "Словарь Ð´Ð»Ñ Ð¿Ñ€Ð¾Ð²ÐµÑ€ÐºÐ¸ правопиÑаниÑ:"
+
+#: lib/option.tcl:216
msgid "Change Font"
msgstr "Изменить шрифт"
-#: lib/option.tcl:180
+#: lib/option.tcl:220
#, tcl-format
msgid "Choose %s"
msgstr "Выберите %s"
# carbon copy
-#: lib/option.tcl:186
+#: lib/option.tcl:226
msgid "pt."
msgstr ""
-#: lib/option.tcl:200
+#: lib/option.tcl:240
msgid "Preferences"
msgstr "ÐаÑтройки"
-#: lib/option.tcl:235
+#: lib/option.tcl:275
msgid "Failed to completely save options:"
msgstr "Ðе удалоÑÑŒ полноÑтью Ñохранить наÑтройки:"
@@ -1820,6 +1863,43 @@ msgstr "Ðевозможно запиÑать ÑÑылку:"
msgid "Cannot write icon:"
msgstr "Ðевозможно запиÑать значок:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "ÐÐµÐ¿Ð¾Ð´Ð´ÐµÑ€Ð¶Ð¸Ð²Ð°ÐµÐ¼Ð°Ñ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ð° проверки правопиÑаниÑ"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "Проверка правопиÑÐ°Ð½Ð¸Ñ Ð½Ðµ доÑтупна"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "ÐÐµÐ¿Ñ€Ð°Ð²Ð¸Ð»ÑŒÐ½Ð°Ñ ÐºÐ¾Ð½Ñ„Ð¸Ð³ÑƒÑ€Ð°Ñ†Ð¸Ñ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ñ‹ проверки правопиÑаниÑ"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Словарь вернут к %s."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "Программа проверки правопиÑÐ°Ð½Ð¸Ñ Ð½Ðµ Ñмогла запуÑтитÑÑ"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "ÐераÑÐ¿Ð¾Ð·Ð½Ð°Ð½Ð°Ñ Ð¿Ñ€Ð¾Ð³Ñ€Ð°Ð¼Ð¼Ð° проверки правопиÑаниÑ"
+
+#: lib/spellcheck.tcl:180
+msgid "No Suggestions"
+msgstr "ИÑправлений не найдено"
+
+#: lib/spellcheck.tcl:381
+msgid "Unexpected EOF from spell checker"
+msgstr "Программа проверки правопиÑÐ°Ð½Ð¸Ñ Ð¿Ñ€ÐµÑ€Ð²Ð°Ð»Ð° передачу данных"
+
+#: lib/spellcheck.tcl:385
+msgid "Spell Checker Failed"
+msgstr "Ошибка проверки правопиÑаниÑ"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
diff --git a/git-gui/po/sv.po b/git-gui/po/sv.po
index cd3f40b4a..0196ba8ce 100644
--- a/git-gui/po/sv.po
+++ b/git-gui/po/sv.po
@@ -3,46 +3,46 @@
# This file is distributed under the same license as the git-gui package.
#
# Peter Karlsson <peter@softwolves.pp.se>, 2007-2008.
+# Mikael Magnusson <mikachu@gmail.com>, 2008.
msgid ""
msgstr ""
"Project-Id-Version: sv\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-11-24 10:36+0100\n"
-"PO-Revision-Date: 2008-01-12 09:27+0100\n"
-"Last-Translator: Peter Karlsson <peter@softwolves.pp.se>\n"
-"Language-Team: Swedish <sv@li.org>\n"
+"POT-Creation-Date: 2008-08-03 01:34+0200\n"
+"PO-Revision-Date: 2008-08-03 01:45+0200\n"
+"Last-Translator: Mikael Magnusson <mikachu@gmail.com>\n"
+"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"X-Generator: KBabel 1.11.4\n"
-#: git-gui.sh:41 git-gui.sh:604 git-gui.sh:618 git-gui.sh:631 git-gui.sh:714
-#: git-gui.sh:733
+#: git-gui.sh:41 git-gui.sh:688 git-gui.sh:702 git-gui.sh:715 git-gui.sh:798
+#: git-gui.sh:817
msgid "git-gui: fatal error"
msgstr "git-gui: ödesdigert fel"
-#: git-gui.sh:565
+#: git-gui.sh:644
#, tcl-format
msgid "Invalid font specified in %s:"
msgstr "Ogiltigt teckensnitt angivet i %s:"
-#: git-gui.sh:590
+#: git-gui.sh:674
msgid "Main Font"
msgstr "Huvudteckensnitt"
-#: git-gui.sh:591
+#: git-gui.sh:675
msgid "Diff/Console Font"
msgstr "Diff/konsolteckensnitt"
-#: git-gui.sh:605
+#: git-gui.sh:689
msgid "Cannot find git in PATH."
msgstr "Hittar inte git i PATH."
-#: git-gui.sh:632
+#: git-gui.sh:716
msgid "Cannot parse Git version string:"
msgstr "Kan inte tolka versionssträng från Git:"
-#: git-gui.sh:650
+#: git-gui.sh:734
#, tcl-format
msgid ""
"Git version cannot be determined.\n"
@@ -61,378 +61,380 @@ msgstr ""
"\n"
"Anta att \"%s\" är version 1.5.0?\n"
-#: git-gui.sh:888
+#: git-gui.sh:972
msgid "Git directory not found:"
msgstr "Git-katalogen hittades inte:"
-#: git-gui.sh:895
+#: git-gui.sh:979
msgid "Cannot move to top of working directory:"
msgstr "Kan inte gå till början på arbetskatalogen:"
-#: git-gui.sh:902
+#: git-gui.sh:986
msgid "Cannot use funny .git directory:"
msgstr "Kan inte använda underlig .git-katalog:"
-#: git-gui.sh:907
+#: git-gui.sh:991
msgid "No working directory"
msgstr "Ingen arbetskatalog"
-#: git-gui.sh:1054
+#: git-gui.sh:1138 lib/checkout_op.tcl:305
msgid "Refreshing file status..."
msgstr "Uppdaterar filstatus..."
-#: git-gui.sh:1119
+#: git-gui.sh:1194
msgid "Scanning for modified files ..."
msgstr "Söker efter ändrade filer..."
-#: git-gui.sh:1294 lib/browser.tcl:245
+#: git-gui.sh:1369 lib/browser.tcl:246
msgid "Ready."
msgstr "Klar."
-#: git-gui.sh:1560
+#: git-gui.sh:1635
msgid "Unmodified"
msgstr "Oförändrade"
-#: git-gui.sh:1562
+#: git-gui.sh:1637
msgid "Modified, not staged"
msgstr "Förändrade, ej köade"
-#: git-gui.sh:1563 git-gui.sh:1568
+#: git-gui.sh:1638 git-gui.sh:1643
msgid "Staged for commit"
msgstr "Köade för incheckning"
-#: git-gui.sh:1564 git-gui.sh:1569
+#: git-gui.sh:1639 git-gui.sh:1644
msgid "Portions staged for commit"
msgstr "Delar köade för incheckning"
-#: git-gui.sh:1565 git-gui.sh:1570
+#: git-gui.sh:1640 git-gui.sh:1645
msgid "Staged for commit, missing"
msgstr "Köade för incheckning, saknade"
-#: git-gui.sh:1567
+#: git-gui.sh:1642
msgid "Untracked, not staged"
msgstr "Ej spårade, ej köade"
-#: git-gui.sh:1572
+#: git-gui.sh:1647
msgid "Missing"
msgstr "Saknade"
-#: git-gui.sh:1573
+#: git-gui.sh:1648
msgid "Staged for removal"
msgstr "Köade för borttagning"
-#: git-gui.sh:1574
+#: git-gui.sh:1649
msgid "Staged for removal, still present"
msgstr "Köade för borttagning, fortfarande närvarande"
-#: git-gui.sh:1576 git-gui.sh:1577 git-gui.sh:1578 git-gui.sh:1579
+#: git-gui.sh:1651 git-gui.sh:1652 git-gui.sh:1653 git-gui.sh:1654
msgid "Requires merge resolution"
msgstr "Kräver konflikthantering efter sammanslagning"
-#: git-gui.sh:1614
+#: git-gui.sh:1689
msgid "Starting gitk... please wait..."
msgstr "Startar gitk... vänta..."
-#: git-gui.sh:1623
-#, tcl-format
-msgid ""
-"Unable to start gitk:\n"
-"\n"
-"%s does not exist"
-msgstr ""
-"Kan inte starta gitk:\n"
-"\n"
-"%s finns inte"
+#: git-gui.sh:1698
+msgid "Couldn't find gitk in PATH"
+msgstr "Hittar inte gitk i PATH."
-#: git-gui.sh:1823 lib/choose_repository.tcl:35
+#: git-gui.sh:1948 lib/choose_repository.tcl:36
msgid "Repository"
msgstr "Arkiv"
-#: git-gui.sh:1824
+#: git-gui.sh:1949
msgid "Edit"
msgstr "Redigera"
-#: git-gui.sh:1826 lib/choose_rev.tcl:560
+#: git-gui.sh:1951 lib/choose_rev.tcl:561
msgid "Branch"
msgstr "Gren"
-#: git-gui.sh:1829 lib/choose_rev.tcl:547
+#: git-gui.sh:1954 lib/choose_rev.tcl:548
msgid "Commit@@noun"
msgstr "Incheckning"
-#: git-gui.sh:1832 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1957 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
msgstr "Slå ihop"
-#: git-gui.sh:1833 lib/choose_rev.tcl:556
+#: git-gui.sh:1958 lib/choose_rev.tcl:557
msgid "Remote"
msgstr "Fjärr"
-#: git-gui.sh:1842
+#: git-gui.sh:1967
msgid "Browse Current Branch's Files"
msgstr "Bläddra i grenens filer"
-#: git-gui.sh:1846
+#: git-gui.sh:1971
msgid "Browse Branch Files..."
msgstr "Bläddra filer på gren..."
-#: git-gui.sh:1851
+#: git-gui.sh:1976
msgid "Visualize Current Branch's History"
msgstr "Visualisera grenens historik"
-#: git-gui.sh:1855
+#: git-gui.sh:1980
msgid "Visualize All Branch History"
msgstr "Visualisera alla grenars historik"
-#: git-gui.sh:1862
+#: git-gui.sh:1987
#, tcl-format
msgid "Browse %s's Files"
msgstr "Bläddra i filer för %s"
-#: git-gui.sh:1864
+#: git-gui.sh:1989
#, tcl-format
msgid "Visualize %s's History"
msgstr "Visualisera historik för %s"
-#: git-gui.sh:1869 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1994 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
msgstr "Databasstatistik"
-#: git-gui.sh:1872 lib/database.tcl:34
+#: git-gui.sh:1997 lib/database.tcl:34
msgid "Compress Database"
msgstr "Komprimera databas"
-#: git-gui.sh:1875
+#: git-gui.sh:2000
msgid "Verify Database"
msgstr "Verifiera databas"
-#: git-gui.sh:1882 git-gui.sh:1886 git-gui.sh:1890 lib/shortcut.tcl:7
+#: git-gui.sh:2007 git-gui.sh:2011 git-gui.sh:2015 lib/shortcut.tcl:7
#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "Skapa skrivbordsikon"
-#: git-gui.sh:1895 lib/choose_repository.tcl:176 lib/choose_repository.tcl:184
+#: git-gui.sh:2023 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "Avsluta"
-#: git-gui.sh:1902
+#: git-gui.sh:2031
msgid "Undo"
msgstr "Ã…ngra"
-#: git-gui.sh:1905
+#: git-gui.sh:2034
msgid "Redo"
msgstr "Gör om"
-#: git-gui.sh:1909 git-gui.sh:2403
+#: git-gui.sh:2038 git-gui.sh:2545
msgid "Cut"
msgstr "Klipp ut"
-#: git-gui.sh:1912 git-gui.sh:2406 git-gui.sh:2477 git-gui.sh:2549
-#: lib/console.tcl:67
+#: git-gui.sh:2041 git-gui.sh:2548 git-gui.sh:2622 git-gui.sh:2715
+#: lib/console.tcl:69
msgid "Copy"
msgstr "Kopiera"
-#: git-gui.sh:1915 git-gui.sh:2409
+#: git-gui.sh:2044 git-gui.sh:2551
msgid "Paste"
msgstr "Klistra in"
-#: git-gui.sh:1918 git-gui.sh:2412 lib/branch_delete.tcl:26
+#: git-gui.sh:2047 git-gui.sh:2554 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "Ta bort"
-#: git-gui.sh:1922 git-gui.sh:2416 git-gui.sh:2553 lib/console.tcl:69
+#: git-gui.sh:2051 git-gui.sh:2558 git-gui.sh:2719 lib/console.tcl:71
msgid "Select All"
msgstr "Markera alla"
-#: git-gui.sh:1931
+#: git-gui.sh:2060
msgid "Create..."
msgstr "Skapa..."
-#: git-gui.sh:1937
+#: git-gui.sh:2066
msgid "Checkout..."
msgstr "Checka ut..."
-#: git-gui.sh:1943
+#: git-gui.sh:2072
msgid "Rename..."
msgstr "Byt namn..."
-#: git-gui.sh:1948 git-gui.sh:2048
+#: git-gui.sh:2077 git-gui.sh:2187
msgid "Delete..."
msgstr "Ta bort..."
-#: git-gui.sh:1953
+#: git-gui.sh:2082
msgid "Reset..."
msgstr "Återställ..."
-#: git-gui.sh:1965 git-gui.sh:2350
+#: git-gui.sh:2094 git-gui.sh:2491
msgid "New Commit"
msgstr "Ny incheckning"
-#: git-gui.sh:1973 git-gui.sh:2357
+#: git-gui.sh:2102 git-gui.sh:2498
msgid "Amend Last Commit"
msgstr "Lägg till föregående incheckning"
-#: git-gui.sh:1982 git-gui.sh:2317 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2111 git-gui.sh:2458 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "Sök på nytt"
-#: git-gui.sh:1988
+#: git-gui.sh:2117
msgid "Stage To Commit"
msgstr "Köa för incheckning"
-#: git-gui.sh:1994
+#: git-gui.sh:2123
msgid "Stage Changed Files To Commit"
msgstr "Köa ändrade filer för incheckning"
-#: git-gui.sh:2000
+#: git-gui.sh:2129
msgid "Unstage From Commit"
msgstr "Ta bort från incheckningskö"
-#: git-gui.sh:2005 lib/index.tcl:393
+#: git-gui.sh:2134 lib/index.tcl:395
msgid "Revert Changes"
msgstr "Återställ ändringar"
-#: git-gui.sh:2012 git-gui.sh:2329 git-gui.sh:2427
+#: git-gui.sh:2141 git-gui.sh:2702
+msgid "Show Less Context"
+msgstr "Visa mindre sammanhang"
+
+#: git-gui.sh:2145 git-gui.sh:2706
+msgid "Show More Context"
+msgstr "Visa mer sammanhang"
+
+#: git-gui.sh:2151 git-gui.sh:2470 git-gui.sh:2569
msgid "Sign Off"
msgstr "Skriv under"
-#: git-gui.sh:2016 git-gui.sh:2333
+#: git-gui.sh:2155 git-gui.sh:2474
msgid "Commit@@verb"
msgstr "Checka in"
-#: git-gui.sh:2027
+#: git-gui.sh:2166
msgid "Local Merge..."
msgstr "Lokal sammanslagning..."
-#: git-gui.sh:2032
+#: git-gui.sh:2171
msgid "Abort Merge..."
msgstr "Avbryt sammanslagning..."
-#: git-gui.sh:2044
+#: git-gui.sh:2183
msgid "Push..."
msgstr "Sänd..."
-#: git-gui.sh:2055 lib/choose_repository.tcl:40
-msgid "Apple"
-msgstr "Äpple"
-
-#: git-gui.sh:2058 git-gui.sh:2080 lib/about.tcl:13
-#: lib/choose_repository.tcl:43 lib/choose_repository.tcl:49
+#: git-gui.sh:2197 git-gui.sh:2219 lib/about.tcl:14
+#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
msgstr "Om %s"
-#: git-gui.sh:2062
+#: git-gui.sh:2201
msgid "Preferences..."
msgstr "Inställningar..."
-#: git-gui.sh:2070 git-gui.sh:2595
+#: git-gui.sh:2209 git-gui.sh:2740
msgid "Options..."
msgstr "Alternativ..."
-#: git-gui.sh:2076 lib/choose_repository.tcl:46
+#: git-gui.sh:2215 lib/choose_repository.tcl:47
msgid "Help"
msgstr "Hjälp"
-#: git-gui.sh:2117
+#: git-gui.sh:2256
msgid "Online Documentation"
msgstr "Webbdokumentation"
-#: git-gui.sh:2201
+#: git-gui.sh:2340
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr "ödesdigert: kunde inte ta status på sökvägen %s: Fil eller katalog saknas"
+msgstr ""
+"ödesdigert: kunde inte ta status på sökvägen %s: Fil eller katalog saknas"
-#: git-gui.sh:2234
+#: git-gui.sh:2373
msgid "Current Branch:"
msgstr "Aktuell gren:"
-#: git-gui.sh:2255
+#: git-gui.sh:2394
msgid "Staged Changes (Will Commit)"
msgstr "Köade ändringar (kommer att checkas in)"
-#: git-gui.sh:2274
+#: git-gui.sh:2414
msgid "Unstaged Changes"
msgstr "Oköade ändringar"
-#: git-gui.sh:2323
+#: git-gui.sh:2464
msgid "Stage Changed"
msgstr "Köa ändrade"
-#: git-gui.sh:2339 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2480 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "Sänd"
-#: git-gui.sh:2369
+#: git-gui.sh:2510
msgid "Initial Commit Message:"
msgstr "Inledande incheckningsmeddelande:"
-#: git-gui.sh:2370
+#: git-gui.sh:2511
msgid "Amended Commit Message:"
msgstr "Utökat incheckningsmeddelande:"
-#: git-gui.sh:2371
+#: git-gui.sh:2512
msgid "Amended Initial Commit Message:"
msgstr "Utökat inledande incheckningsmeddelande:"
-#: git-gui.sh:2372
+#: git-gui.sh:2513
msgid "Amended Merge Commit Message:"
msgstr "Utökat incheckningsmeddelande för sammanslagning:"
-#: git-gui.sh:2373
+#: git-gui.sh:2514
msgid "Merge Commit Message:"
msgstr "Incheckningsmeddelande för sammanslagning:"
-#: git-gui.sh:2374
+#: git-gui.sh:2515
msgid "Commit Message:"
msgstr "Incheckningsmeddelande:"
-#: git-gui.sh:2419 git-gui.sh:2557 lib/console.tcl:71
+#: git-gui.sh:2561 git-gui.sh:2723 lib/console.tcl:73
msgid "Copy All"
msgstr "Kopiera alla"
-#: git-gui.sh:2443 lib/blame.tcl:104
+#: git-gui.sh:2585 lib/blame.tcl:100
msgid "File:"
msgstr "Fil:"
-#: git-gui.sh:2545
-msgid "Refresh"
-msgstr "Uppdatera"
-
-#: git-gui.sh:2566
+#: git-gui.sh:2691
msgid "Apply/Reverse Hunk"
msgstr "Använd/återställ del"
-#: git-gui.sh:2572
+#: git-gui.sh:2696
+msgid "Apply/Reverse Line"
+msgstr "Använd/återställ rad"
+
+#: git-gui.sh:2711
+msgid "Refresh"
+msgstr "Uppdatera"
+
+#: git-gui.sh:2732
msgid "Decrease Font Size"
msgstr "Minska teckensnittsstorlek"
-#: git-gui.sh:2576
+#: git-gui.sh:2736
msgid "Increase Font Size"
msgstr "Öka teckensnittsstorlek"
-#: git-gui.sh:2581
-msgid "Show Less Context"
-msgstr "Visa mindre sammanhang"
-
-#: git-gui.sh:2588
-msgid "Show More Context"
-msgstr "Visa mer sammanhang"
-
-#: git-gui.sh:2602
+#: git-gui.sh:2747
msgid "Unstage Hunk From Commit"
msgstr "Ta bort del ur incheckningskö"
-#: git-gui.sh:2604
+#: git-gui.sh:2748
+msgid "Unstage Line From Commit"
+msgstr "Ta bort rad ur incheckningskö"
+
+#: git-gui.sh:2750
msgid "Stage Hunk For Commit"
msgstr "Ställ del i incheckningskö"
-#: git-gui.sh:2623
+#: git-gui.sh:2751
+msgid "Stage Line For Commit"
+msgstr "Ställ rad i incheckningskö"
+
+#: git-gui.sh:2771
msgid "Initializing..."
msgstr "Initierar..."
-#: git-gui.sh:2718
+#: git-gui.sh:2876
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -449,7 +451,7 @@ msgstr ""
"av %s:\n"
"\n"
-#: git-gui.sh:2748
+#: git-gui.sh:2906
msgid ""
"\n"
"This is due to a known issue with the\n"
@@ -459,7 +461,7 @@ msgstr ""
"Detta beror på ett känt problem med\n"
"Tcl-binären som följer med Cygwin."
-#: git-gui.sh:2753
+#: git-gui.sh:2911
#, tcl-format
msgid ""
"\n"
@@ -476,68 +478,84 @@ msgstr ""
"user.name och user.email i din personliga\n"
"~/.gitconfig-fil.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
msgstr "git-gui - ett grafiskt användargränssnitt för Git."
-#: lib/blame.tcl:77
+#: lib/blame.tcl:70
msgid "File Viewer"
msgstr "Filvisare"
-#: lib/blame.tcl:81
+#: lib/blame.tcl:74
msgid "Commit:"
msgstr "Incheckning:"
-#: lib/blame.tcl:249
+#: lib/blame.tcl:257
msgid "Copy Commit"
msgstr "Kopiera incheckning"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:260
+msgid "Do Full Copy Detection"
+msgstr "Gör full kopieringsigenkänning"
+
+#: lib/blame.tcl:388
#, tcl-format
msgid "Reading %s..."
msgstr "Läser %s..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:492
msgid "Loading copy/move tracking annotations..."
msgstr "Läser annoteringar för kopiering/flyttning..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:512
msgid "lines annotated"
msgstr "rader annoterade"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:704
msgid "Loading original location annotations..."
msgstr "Läser in annotering av originalplacering..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:707
msgid "Annotation complete."
msgstr "Annotering fullbordad."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:737
+msgid "Busy"
+msgstr "Upptagen"
+
+#: lib/blame.tcl:738
+msgid "Annotation process is already running."
+msgstr "Annoteringsprocess körs redan."
+
+#: lib/blame.tcl:777
+msgid "Running thorough copy detection..."
+msgstr "Kör grundlig kopieringsigenkänning..."
+
+#: lib/blame.tcl:827
msgid "Loading annotation..."
msgstr "Läser in annotering..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:883
msgid "Author:"
msgstr "Författare:"
-#: lib/blame.tcl:791
+#: lib/blame.tcl:887
msgid "Committer:"
msgstr "Incheckare:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:892
msgid "Original File:"
msgstr "Ursprunglig fil:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:1006
msgid "Originally By:"
msgstr "Ursprungligen av:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:1012
msgid "In File:"
msgstr "I filen:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:1017
msgid "Copied Or Moved Here By:"
msgstr "Kopierad eller flyttad hit av:"
@@ -550,17 +568,17 @@ msgid "Checkout"
msgstr "Checka ut"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:544 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
msgstr "Avbryt"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
msgstr "Revision"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:244
msgid "Options"
msgstr "Alternativ"
@@ -580,7 +598,7 @@ msgstr "Skapa gren"
msgid "Create New Branch"
msgstr "Skapa ny gren"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:375
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
msgstr "Skapa"
@@ -612,7 +630,7 @@ msgstr "Nej"
msgid "Fast Forward Only"
msgstr "Endast snabbspolning"
-#: lib/branch_create.tcl:85 lib/checkout_op.tcl:514
+#: lib/branch_create.tcl:85 lib/checkout_op.tcl:536
msgid "Reset"
msgstr "Återställ"
@@ -702,7 +720,7 @@ msgstr "Nytt namn:"
msgid "Please select a branch to rename."
msgstr "Välj en gren att byta namn på."
-#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:179
+#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:201
#, tcl-format
msgid "Branch '%s' already exists."
msgstr "Grenen \"%s\" finns redan."
@@ -720,45 +738,50 @@ msgstr "Startar..."
msgid "File Browser"
msgstr "Filbläddrare"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
msgstr "Läser %s..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
msgstr "[Upp till förälder]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
msgstr "Bläddra filer på grenen"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:391
-#: lib/choose_repository.tcl:482 lib/choose_repository.tcl:492
-#: lib/choose_repository.tcl:989
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:472 lib/choose_repository.tcl:482
+#: lib/choose_repository.tcl:985
msgid "Browse"
msgstr "Bläddra"
-#: lib/checkout_op.tcl:79
+#: lib/checkout_op.tcl:84
#, tcl-format
msgid "Fetching %s from %s"
msgstr "Hämtar %s från %s"
-#: lib/checkout_op.tcl:127
+#: lib/checkout_op.tcl:132
#, tcl-format
msgid "fatal: Cannot resolve %s"
msgstr "ödesdigert: Kunde inte slå upp %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:145 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
msgstr "Stäng"
-#: lib/checkout_op.tcl:169
+#: lib/checkout_op.tcl:174
#, tcl-format
msgid "Branch '%s' does not exist."
msgstr "Grenen \"%s\" finns inte."
-#: lib/checkout_op.tcl:206
+#: lib/checkout_op.tcl:193
+#, tcl-format
+msgid "Failed to configure simplified git-pull for '%s'."
+msgstr "Kunde inte konfigurera förenklad git-pull för '%s'."
+
+#: lib/checkout_op.tcl:228
#, tcl-format
msgid ""
"Branch '%s' already exists.\n"
@@ -771,21 +794,21 @@ msgstr ""
"Den kan inte snabbspolas till %s.\n"
"En sammanslagning krävs."
-#: lib/checkout_op.tcl:220
+#: lib/checkout_op.tcl:242
#, tcl-format
msgid "Merge strategy '%s' not supported."
msgstr "Sammanslagningsstrategin \"%s\" stöds inte."
-#: lib/checkout_op.tcl:239
+#: lib/checkout_op.tcl:261
#, tcl-format
msgid "Failed to update '%s'."
msgstr "Misslyckades med att uppdatera \"%s\"."
-#: lib/checkout_op.tcl:251
+#: lib/checkout_op.tcl:273
msgid "Staging area (index) is already locked."
msgstr "Köområdet (index) är redan låst."
-#: lib/checkout_op.tcl:266
+#: lib/checkout_op.tcl:288
msgid ""
"Last scanned state does not match repository state.\n"
"\n"
@@ -796,31 +819,35 @@ msgid ""
msgstr ""
"Det senaste inlästa tillståndet motsvarar inte tillståndet i arkivet.\n"
"\n"
-"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du "
-"måste utföra en ny sökning innan den aktuella grenen kan ändras.\n"
+"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du måste "
+"utföra en ny sökning innan den aktuella grenen kan ändras.\n"
"\n"
"Sökningen kommer att startas automatiskt nu.\n"
-#: lib/checkout_op.tcl:322
+#: lib/checkout_op.tcl:344
#, tcl-format
msgid "Updating working directory to '%s'..."
msgstr "Uppdaterar arbetskatalogen till \"%s\"..."
-#: lib/checkout_op.tcl:353
+#: lib/checkout_op.tcl:345
+msgid "files checked out"
+msgstr "filer utcheckade"
+
+#: lib/checkout_op.tcl:375
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
msgstr "Avbryter utcheckning av \"%s\" (sammanslagning på filnivå krävs)."
-#: lib/checkout_op.tcl:354
+#: lib/checkout_op.tcl:376
msgid "File level merge required."
msgstr "Sammanslagning på filnivå krävs."
-#: lib/checkout_op.tcl:358
+#: lib/checkout_op.tcl:380
#, tcl-format
msgid "Staying on branch '%s'."
msgstr "Stannar på grenen \"%s\"."
-#: lib/checkout_op.tcl:429
+#: lib/checkout_op.tcl:451
msgid ""
"You are no longer on a local branch.\n"
"\n"
@@ -829,33 +856,34 @@ msgid ""
msgstr ""
"Du är inte längre på en lokal gren.\n"
"\n"
-"Om du ville vara på en gren skapar du en nu, baserad på \"Denna "
-"frånkopplade utcheckning\"."
+"Om du ville vara på en gren skapar du en nu, baserad på \"Denna frånkopplade "
+"utcheckning\"."
-#: lib/checkout_op.tcl:446
+#: lib/checkout_op.tcl:468 lib/checkout_op.tcl:472
#, tcl-format
msgid "Checked out '%s'."
msgstr "Checkade ut \"%s\"."
-#: lib/checkout_op.tcl:478
+#: lib/checkout_op.tcl:500
#, tcl-format
msgid "Resetting '%s' to '%s' will lose the following commits:"
-msgstr "Om du återställer \"%s\" till \"%s\" får följande incheckningar förlorade:"
+msgstr ""
+"Om du återställer \"%s\" till \"%s\" går följande incheckningar förlorade:"
-#: lib/checkout_op.tcl:500
+#: lib/checkout_op.tcl:522
msgid "Recovering lost commits may not be easy."
msgstr "Det kanske inte är så enkelt att återskapa förlorade incheckningar."
-#: lib/checkout_op.tcl:505
+#: lib/checkout_op.tcl:527
#, tcl-format
msgid "Reset '%s'?"
msgstr "Återställa \"%s\"?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:532 lib/merge.tcl:163
msgid "Visualize"
msgstr "Visualisera"
-#: lib/checkout_op.tcl:578
+#: lib/checkout_op.tcl:600
#, tcl-format
msgid ""
"Failed to set current branch.\n"
@@ -867,8 +895,8 @@ msgid ""
msgstr ""
"Kunde inte ställa in aktuell gren.\n"
"\n"
-"Arbetskatalogen har bara växlats delvis. Vi uppdaterade filerna "
-"utan problem, men kunde inte uppdatera en intern fil i Git.\n"
+"Arbetskatalogen har bara växlats delvis. Vi uppdaterade filerna utan "
+"problem, men kunde inte uppdatera en intern fil i Git.\n"
"\n"
"Detta skulle inte ha hänt. %s kommer nu stängas och ge upp."
@@ -880,15 +908,15 @@ msgstr "Välj"
msgid "Font Family"
msgstr "Teckensnittsfamilj"
-#: lib/choose_font.tcl:73
+#: lib/choose_font.tcl:74
msgid "Font Size"
msgstr "Storlek"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
msgstr "Exempel"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
@@ -896,225 +924,225 @@ msgstr ""
"Detta är en exempeltext.\n"
"Om du tycker om den här texten kan den vara ditt teckensnitt."
-#: lib/choose_repository.tcl:27
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
msgstr "Git Gui"
-#: lib/choose_repository.tcl:80 lib/choose_repository.tcl:380
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
msgstr "Skapa nytt arkiv"
-#: lib/choose_repository.tcl:86
+#: lib/choose_repository.tcl:87
msgid "New..."
msgstr "Nytt..."
-#: lib/choose_repository.tcl:93 lib/choose_repository.tcl:468
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:458
msgid "Clone Existing Repository"
msgstr "Klona befintligt arkiv"
-#: lib/choose_repository.tcl:99
+#: lib/choose_repository.tcl:100
msgid "Clone..."
msgstr "Klona..."
-#: lib/choose_repository.tcl:106 lib/choose_repository.tcl:978
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:974
msgid "Open Existing Repository"
msgstr "Öppna befintligt arkiv"
-#: lib/choose_repository.tcl:112
+#: lib/choose_repository.tcl:113
msgid "Open..."
msgstr "Öppna..."
-#: lib/choose_repository.tcl:125
+#: lib/choose_repository.tcl:126
msgid "Recent Repositories"
msgstr "Senaste arkiven"
-#: lib/choose_repository.tcl:131
+#: lib/choose_repository.tcl:132
msgid "Open Recent Repository:"
msgstr "Öppna tidigare arkiv:"
-#: lib/choose_repository.tcl:294
-#, tcl-format
-msgid "Location %s already exists."
-msgstr "Platsen %s finns redan."
-
-#: lib/choose_repository.tcl:300 lib/choose_repository.tcl:307
-#: lib/choose_repository.tcl:314
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
msgstr "Kunde inte skapa arkivet %s:"
-#: lib/choose_repository.tcl:385 lib/choose_repository.tcl:486
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:476
msgid "Directory:"
msgstr "Katalog:"
-#: lib/choose_repository.tcl:415 lib/choose_repository.tcl:544
-#: lib/choose_repository.tcl:1013
+#: lib/choose_repository.tcl:410 lib/choose_repository.tcl:535
+#: lib/choose_repository.tcl:1007
msgid "Git Repository"
msgstr "Gitarkiv"
-#: lib/choose_repository.tcl:430 lib/choose_repository.tcl:437
+#: lib/choose_repository.tcl:435
#, tcl-format
msgid "Directory %s already exists."
msgstr "Katalogen %s finns redan."
-#: lib/choose_repository.tcl:442
+#: lib/choose_repository.tcl:439
#, tcl-format
msgid "File %s already exists."
msgstr "Filen %s finns redan."
-#: lib/choose_repository.tcl:463
+#: lib/choose_repository.tcl:453
msgid "Clone"
msgstr "Klona"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:466
msgid "URL:"
msgstr "Webbadress:"
-#: lib/choose_repository.tcl:496
+#: lib/choose_repository.tcl:487
msgid "Clone Type:"
msgstr "Typ av klon:"
-#: lib/choose_repository.tcl:502
+#: lib/choose_repository.tcl:493
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
msgstr "Standard (snabb, semiredundant, hårda länkar)"
-#: lib/choose_repository.tcl:508
+#: lib/choose_repository.tcl:499
msgid "Full Copy (Slower, Redundant Backup)"
msgstr "Full kopia (långsammare, redundant säkerhetskopia)"
-#: lib/choose_repository.tcl:514
+#: lib/choose_repository.tcl:505
msgid "Shared (Fastest, Not Recommended, No Backup)"
msgstr "Delad (snabbast, rekommenderas ej, ingen säkerhetskopia)"
-#: lib/choose_repository.tcl:550 lib/choose_repository.tcl:597
-#: lib/choose_repository.tcl:738 lib/choose_repository.tcl:808
-#: lib/choose_repository.tcl:1019 lib/choose_repository.tcl:1027
+#: lib/choose_repository.tcl:541 lib/choose_repository.tcl:588
+#: lib/choose_repository.tcl:734 lib/choose_repository.tcl:804
+#: lib/choose_repository.tcl:1013 lib/choose_repository.tcl:1021
#, tcl-format
msgid "Not a Git repository: %s"
msgstr "Inte ett Gitarkiv: %s"
-#: lib/choose_repository.tcl:586
+#: lib/choose_repository.tcl:577
msgid "Standard only available for local repository."
msgstr "Standard är endast tillgängligt för lokala arkiv."
-#: lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:581
msgid "Shared only available for local repository."
msgstr "Delat är endast tillgängligt för lokala arkiv."
-#: lib/choose_repository.tcl:617
+#: lib/choose_repository.tcl:602
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "Platsen %s finns redan."
+
+#: lib/choose_repository.tcl:613
msgid "Failed to configure origin"
msgstr "Kunde inte konfigurera ursprung"
-#: lib/choose_repository.tcl:629
+#: lib/choose_repository.tcl:625
msgid "Counting objects"
msgstr "Räknar objekt"
-#: lib/choose_repository.tcl:630
+#: lib/choose_repository.tcl:626
msgid "buckets"
msgstr "hinkar"
-#: lib/choose_repository.tcl:654
+#: lib/choose_repository.tcl:650
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
msgstr "Kunde inte kopiera objekt/info/alternativ: %s"
-#: lib/choose_repository.tcl:690
+#: lib/choose_repository.tcl:686
#, tcl-format
msgid "Nothing to clone from %s."
msgstr "Ingenting att klona från %s."
-#: lib/choose_repository.tcl:692 lib/choose_repository.tcl:906
-#: lib/choose_repository.tcl:918
+#: lib/choose_repository.tcl:688 lib/choose_repository.tcl:902
+#: lib/choose_repository.tcl:914
msgid "The 'master' branch has not been initialized."
msgstr "Grenen \"master\" har inte initierats."
-#: lib/choose_repository.tcl:705
+#: lib/choose_repository.tcl:701
msgid "Hardlinks are unavailable. Falling back to copying."
msgstr "Hårda länkar är inte tillgängliga. Faller tillbaka på kopiering."
-#: lib/choose_repository.tcl:717
+#: lib/choose_repository.tcl:713
#, tcl-format
msgid "Cloning from %s"
msgstr "Klonar från %s"
-#: lib/choose_repository.tcl:748
+#: lib/choose_repository.tcl:744
msgid "Copying objects"
msgstr "Kopierar objekt"
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:745
msgid "KiB"
msgstr "KiB"
-#: lib/choose_repository.tcl:773
+#: lib/choose_repository.tcl:769
#, tcl-format
msgid "Unable to copy object: %s"
msgstr "Kunde inte kopiera objekt: %s"
-#: lib/choose_repository.tcl:783
+#: lib/choose_repository.tcl:779
msgid "Linking objects"
msgstr "Länkar objekt"
-#: lib/choose_repository.tcl:784
+#: lib/choose_repository.tcl:780
msgid "objects"
msgstr "objekt"
-#: lib/choose_repository.tcl:792
+#: lib/choose_repository.tcl:788
#, tcl-format
msgid "Unable to hardlink object: %s"
msgstr "Kunde inte hårdlänka objekt: %s"
-#: lib/choose_repository.tcl:847
+#: lib/choose_repository.tcl:843
msgid "Cannot fetch branches and objects. See console output for details."
msgstr "Kunde inte hämta grenar och objekt. Se konsolutdata för detaljer."
-#: lib/choose_repository.tcl:858
+#: lib/choose_repository.tcl:854
msgid "Cannot fetch tags. See console output for details."
msgstr "Kunde inte hämta taggar. Se konsolutdata för detaljer."
-#: lib/choose_repository.tcl:882
+#: lib/choose_repository.tcl:878
msgid "Cannot determine HEAD. See console output for details."
msgstr "Kunde inte avgöra HEAD. Se konsolutdata för detaljer."
-#: lib/choose_repository.tcl:891
+#: lib/choose_repository.tcl:887
#, tcl-format
msgid "Unable to cleanup %s"
msgstr "Kunde inte städa upp %s"
-#: lib/choose_repository.tcl:897
+#: lib/choose_repository.tcl:893
msgid "Clone failed."
msgstr "Kloning misslyckades."
-#: lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:900
msgid "No default branch obtained."
msgstr "Hämtade ingen standardgren."
-#: lib/choose_repository.tcl:915
+#: lib/choose_repository.tcl:911
#, tcl-format
msgid "Cannot resolve %s as a commit."
msgstr "Kunde inte slå upp %s till någon incheckning."
-#: lib/choose_repository.tcl:927
+#: lib/choose_repository.tcl:923
msgid "Creating working directory"
msgstr "Skapar arbetskatalog"
-#: lib/choose_repository.tcl:928 lib/index.tcl:65 lib/index.tcl:127
+#: lib/choose_repository.tcl:924 lib/index.tcl:65 lib/index.tcl:127
#: lib/index.tcl:193
msgid "files"
msgstr "filer"
-#: lib/choose_repository.tcl:957
+#: lib/choose_repository.tcl:953
msgid "Initial file checkout failed."
msgstr "Inledande filutcheckning misslyckades."
-#: lib/choose_repository.tcl:973
+#: lib/choose_repository.tcl:969
msgid "Open"
msgstr "Öppna"
-#: lib/choose_repository.tcl:983
+#: lib/choose_repository.tcl:979
msgid "Repository:"
msgstr "Arkiv:"
-#: lib/choose_repository.tcl:1033
+#: lib/choose_repository.tcl:1027
#, tcl-format
msgid "Failed to open repository %s:"
msgstr "Kunde inte öppna arkivet %s:"
@@ -1135,7 +1163,7 @@ msgstr "Lokal gren"
msgid "Tracking Branch"
msgstr "Spårande gren"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
msgstr "Tagg"
@@ -1152,11 +1180,11 @@ msgstr "Ingen revision vald."
msgid "Revision expression is empty."
msgstr "Revisionsuttrycket är tomt."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
msgstr "Uppdaterad"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
msgstr "Webbadress"
@@ -1182,9 +1210,9 @@ msgid ""
msgstr ""
"Kan inte utöka vid sammanslagning.\n"
"\n"
-"Du är i mitten av en sammanslagning som inte är fullbordad. Du kan "
-"inte utöka tidigare incheckningar om du inte först avbryter den "
-"pågående sammanslagningen.\n"
+"Du är i mitten av en sammanslagning som inte är fullbordad. Du kan inte "
+"utöka tidigare incheckningar om du inte först avbryter den pågående "
+"sammanslagningen.\n"
#: lib/commit.tcl:49
msgid "Error loading commit data for amend:"
@@ -1209,8 +1237,8 @@ msgid ""
msgstr ""
"Det senaste inlästa tillståndet motsvarar inte tillståndet i arkivet.\n"
"\n"
-"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du "
-"måste utföra en ny sökning innan du kan göra en ny incheckning.\n"
+"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du måste "
+"utföra en ny sökning innan du kan göra en ny incheckning.\n"
"\n"
"Sökningen kommer att startas automatiskt nu.\n"
@@ -1266,16 +1294,45 @@ msgstr ""
"- Andra raden: Tom\n"
"- Följande rader: Beskriv varför det här är en bra ändring.\n"
-#: lib/commit.tcl:257
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "varning: Tcl stöder inte teckenkodningen \"%s\"."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr "Anropar krok före incheckning..."
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr "Incheckningen avvisades av krok före incheckning."
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr "Anropar krok för incheckningsmeddelande..."
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
+msgstr "Incheckning avvisad av krok för incheckningsmeddelande."
+
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr "Checkar in ändringar..."
+
+#: lib/commit.tcl:303
msgid "write-tree failed:"
msgstr "write-tree misslyckades:"
-#: lib/commit.tcl:275
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+msgid "Commit failed."
+msgstr "Incheckningen misslyckades."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
msgstr "Incheckningen %s verkar vara trasig"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1289,37 +1346,32 @@ msgstr ""
"\n"
"En sökning kommer att startas automatiskt nu.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
msgstr "Inga ändringar att checka in."
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr "varning: Tcl stöder inte teckenkodningen \"%s\"."
-
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
msgstr "commit-tree misslyckades:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
msgstr "update-ref misslyckades:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
msgstr "Skapade incheckningen %s: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
msgstr "Arbetar... vänta..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
msgstr "Lyckades"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
msgstr "Fel: Kommando misslyckades"
@@ -1381,7 +1433,7 @@ msgstr ""
msgid "Invalid date from Git: %s"
msgstr "Ogiltigt datum från Git: %s"
-#: lib/diff.tcl:42
+#: lib/diff.tcl:44
#, tcl-format
msgid ""
"No differences detected.\n"
@@ -1398,55 +1450,63 @@ msgstr ""
"\n"
"%s innehåller inga ändringar.\n"
"\n"
-"Modifieringsdatum för filen uppdaterades av ett annat program, men innehållet "
-"i filen har inte ändrats.\n"
+"Modifieringsdatum för filen uppdaterades av ett annat program, men "
+"innehållet i filen har inte ändrats.\n"
"\n"
"En sökning kommer automatiskt att startas för att hitta andra filer som kan "
"vara i samma tillstånd."
-#: lib/diff.tcl:81
+#: lib/diff.tcl:83
#, tcl-format
msgid "Loading diff of %s..."
msgstr "Läser differens för %s..."
-#: lib/diff.tcl:114 lib/diff.tcl:184
+#: lib/diff.tcl:116 lib/diff.tcl:190
#, tcl-format
msgid "Unable to display %s"
msgstr "Kan inte visa %s"
-#: lib/diff.tcl:115
+#: lib/diff.tcl:117
msgid "Error loading file:"
msgstr "Fel vid läsning av fil:"
-#: lib/diff.tcl:122
+#: lib/diff.tcl:124
msgid "Git Repository (subproject)"
msgstr "Gitarkiv (underprojekt)"
-#: lib/diff.tcl:134
+#: lib/diff.tcl:136
msgid "* Binary file (not showing content)."
msgstr "* Binärfil (visar inte innehållet)."
-#: lib/diff.tcl:185
+#: lib/diff.tcl:191
msgid "Error loading diff:"
msgstr "Fel vid inläsning av differens:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:313
msgid "Failed to unstage selected hunk."
msgstr "Kunde inte ta bort den valda delen från kön."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:320
msgid "Failed to stage selected hunk."
msgstr "Kunde inte lägga till den valda delen till kön."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/diff.tcl:386
+msgid "Failed to unstage selected line."
+msgstr "Kunde inte ta bort den valda raden från kön."
+
+#: lib/diff.tcl:394
+msgid "Failed to stage selected line."
+msgstr "Kunde inte lägga till den valda raden till kön."
+
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
msgstr "fel"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
msgstr "varning"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
msgstr "Du måste rätta till felen ovan innan du checkar in."
@@ -1479,6 +1539,10 @@ msgstr "LÃ¥s upp index"
msgid "Unstaging %s from commit"
msgstr "Tar bort %s för incheckningskön"
+#: lib/index.tcl:313
+msgid "Ready to commit."
+msgstr "Redo att checka in."
+
#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
@@ -1494,11 +1558,12 @@ msgstr "Återställ ändringarna i filen %s?"
msgid "Revert changes in these %i files?"
msgstr "Återställ ändringarna i dessa %i filer?"
-#: lib/index.tcl:389
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
-msgstr "Alla oköade ändringar kommer permanent gå förlorade vid återställningen."
+msgstr ""
+"Alla oköade ändringar kommer permanent gå förlorade vid återställningen."
-#: lib/index.tcl:392
+#: lib/index.tcl:394
msgid "Do Nothing"
msgstr "Gör ingenting"
@@ -1510,7 +1575,7 @@ msgid ""
msgstr ""
"Kan inte slå ihop vid utökning.\n"
"\n"
-"Du måste föra färdig utökningen av incheckningen innan du påbörjar någon "
+"Du måste göra färdig utökningen av incheckningen innan du påbörjar någon "
"slags sammanslagning.\n"
#: lib/merge.tcl:27
@@ -1524,8 +1589,8 @@ msgid ""
msgstr ""
"Det senaste inlästa tillståndet motsvarar inte tillståndet i arkivet.\n"
"\n"
-"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du "
-"måste utföra en ny sökning innan du kan utföra en sammanslagning.\n"
+"Ett annat Git-program har ändrat arkivet sedan senaste avsökningen. Du måste "
+"utföra en ny sökning innan du kan utföra en sammanslagning.\n"
"\n"
"Sökningen kommer att startas automatiskt nu.\n"
@@ -1571,27 +1636,27 @@ msgstr "%s av %s"
#: lib/merge.tcl:119
#, tcl-format
-msgid "Merging %s and %s"
-msgstr "Slår ihop %s och %s"
+msgid "Merging %s and %s..."
+msgstr "Slår ihop %s och %s..."
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
msgstr "Sammanslagningen avslutades framgångsrikt."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
msgstr "Sammanslagningen misslyckades. Du måste lösa konflikterna."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
msgstr "Slå ihop i %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
msgstr "Revisioner att slå ihop"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
@@ -1601,7 +1666,7 @@ msgstr ""
"\n"
"Du måste göra dig färdig med att utöka incheckningen.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1611,12 +1676,12 @@ msgid ""
msgstr ""
"Avbryt sammanslagning?\n"
"\n"
-"Om du avbryter sammanslagningen kommer *ALLA* ej incheckade ändringar att "
-"gå förlorade.\n"
+"Om du avbryter sammanslagningen kommer *ALLA* ej incheckade ändringar att gå "
+"förlorade.\n"
"\n"
"GÃ¥ vidare med att avbryta den aktuella sammanslagningen?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1626,15 +1691,19 @@ msgid ""
msgstr ""
"Återställ ändringar?\n"
"\n"
-"Om du återställer ändringarna kommer *ALLA* ej incheckade ändringar att "
-"gå förlorade.\n"
+"Om du återställer ändringarna kommer *ALLA* ej incheckade ändringar att gå "
+"förlorade.\n"
"\n"
"Gå vidare med att återställa de aktuella ändringarna?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
msgstr "Avbryter"
+#: lib/merge.tcl:238
+msgid "files reset"
+msgstr "filer återställda"
+
#: lib/merge.tcl:266
msgid "Abort failed."
msgstr "Misslyckades avbryta."
@@ -1643,81 +1712,97 @@ msgstr "Misslyckades avbryta."
msgid "Abort completed. Ready."
msgstr "Avbrytning fullbordad. Redo."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
msgstr "Återställ standardvärden"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
msgstr "Spara"
-#: lib/option.tcl:96
+#: lib/option.tcl:109
#, tcl-format
msgid "%s Repository"
msgstr "Arkivet %s"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
msgstr "Globalt (alla arkiv)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
msgstr "Användarnamn"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
msgstr "E-postadress"
-#: lib/option.tcl:106
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
msgstr "Summera sammanslagningsincheckningar"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
msgstr "Pratsamhet för sammanslagningar"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
msgstr "Visa diffstatistik efter sammanslagning"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
msgstr "Lita på filändringstidsstämplar"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
msgstr "Städa spårade grenar vid hämtning"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
msgstr "Matcha spårade grenar"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
+msgid "Blame Copy Only On Changed Files"
+msgstr "Klandra kopiering bara i ändrade filer"
+
+#: lib/option.tcl:127
+msgid "Minimum Letters To Blame Copy On"
+msgstr "Minsta antal tecken att klandra kopiering för"
+
+#: lib/option.tcl:128
msgid "Number of Diff Context Lines"
msgstr "Antal rader sammanhang i differenser"
-#: lib/option.tcl:114
+#: lib/option.tcl:129
+msgid "Commit Message Text Width"
+msgstr "Textbredd för incheckningsmeddelande"
+
+#: lib/option.tcl:130
msgid "New Branch Name Template"
msgstr "Mall för namn på nya grenar"
-#: lib/option.tcl:176
+#: lib/option.tcl:194
+msgid "Spelling Dictionary:"
+msgstr "Stavningsordlista:"
+
+#: lib/option.tcl:218
msgid "Change Font"
msgstr "Byt teckensnitt"
-#: lib/option.tcl:180
+#: lib/option.tcl:222
#, tcl-format
msgid "Choose %s"
msgstr "Välj %s"
-#: lib/option.tcl:186
+#: lib/option.tcl:228
msgid "pt."
msgstr "p."
-#: lib/option.tcl:200
+#: lib/option.tcl:242
msgid "Preferences"
msgstr "Inställningar"
-#: lib/option.tcl:235
+#: lib/option.tcl:277
msgid "Failed to completely save options:"
msgstr "Misslyckades med att helt spara alternativ:"
@@ -1774,8 +1859,8 @@ msgid ""
"One or more of the merge tests failed because you have not fetched the "
"necessary commits. Try fetching from %s first."
msgstr ""
-"En eller flera av sammanslagningstesterna misslyckades eftersom du inte "
-"har hämtat de nödvändiga incheckningarna. Försök hämta från %s först."
+"En eller flera av sammanslagningstesterna misslyckades eftersom du inte har "
+"hämtat de nödvändiga incheckningarna. Försök hämta från %s först."
#: lib/remote_branch_delete.tcl:207
msgid "Please select one or more branches to delete."
@@ -1787,7 +1872,7 @@ msgid ""
"\n"
"Delete the selected branches?"
msgstr ""
-"Det kan vara svårt att återställa grenar.\n"
+"Det kan vara svårt att återställa borttagna grenar.\n"
"\n"
"Ta bort de valda grenarna?"
@@ -1825,6 +1910,43 @@ msgstr "Kan inte skriva genväg:"
msgid "Cannot write icon:"
msgstr "Kan inte skriva ikon:"
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
+msgstr "Stavningskontrollprogrammet stöds inte"
+
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
+msgstr "Stavningskontroll är ej tillgänglig"
+
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr "Ogiltig inställning för stavningskontroll"
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr "Återställer ordlistan till %s."
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr "Stavningskontroll misslyckades tyst vid start"
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr "Stavningskontrollprogrammet känns inte igen"
+
+#: lib/spellcheck.tcl:186
+msgid "No Suggestions"
+msgstr "Inga förslag"
+
+#: lib/spellcheck.tcl:387
+msgid "Unexpected EOF from spell checker"
+msgstr "Oväntat filslut från stavningskontroll"
+
+#: lib/spellcheck.tcl:391
+msgid "Spell Checker Failed"
+msgstr "Stavningskontroll misslyckades"
+
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
@@ -1893,3 +2015,17 @@ msgstr "Använd tunt paket (för långsamma nätverksanslutningar)"
msgid "Include tags"
msgstr "Ta med taggar"
+#~ msgid ""
+#~ "Unable to start gitk:\n"
+#~ "\n"
+#~ "%s does not exist"
+#~ msgstr ""
+#~ "Kan inte starta gitk:\n"
+#~ "\n"
+#~ "%s finns inte"
+
+#~ msgid "Apple"
+#~ msgstr "Äpple"
+
+#~ msgid "Not connected to aspell"
+#~ msgstr "Inte ansluten till aspell"
diff --git a/git-gui/po/zh_cn.po b/git-gui/po/zh_cn.po
index 621c9479b..d2c686667 100644
--- a/git-gui/po/zh_cn.po
+++ b/git-gui/po/zh_cn.po
@@ -3,14 +3,31 @@
# This file is distributed under the same license as the git-gui package.
# Xudong Guan <xudong.guan@gmail.com>, 2007.
#
+# Please use the following translation throughout the file for consistence:
+#
+# repository 版本库
+# commit æ交
+# revision 版本
+# branch 分支
+# tag 标签
+# annotation 标注
+# merge åˆå¹¶
+# fast forward 快速åˆå¹¶(??)
+# stage 缓存 (译自 index/cache)
+# amend 修正
+# reset å¤ä½
+#
+# 2008-01-06 Eric Miao <eric.y.miao@gmail.com>
+# FIXME: checkout 的标准翻译
+#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-10-10 04:04-0400\n"
+"POT-Creation-Date: 2008-03-14 07:18+0100\n"
"PO-Revision-Date: 2007-07-21 01:23-0700\n"
-"Last-Translator: Xudong Guan <xudong.guan@gmail.com>\n"
+"Last-Translator: Eric Miao <eric.y.miao@gmail.com>\n"
"Language-Team: Chinese\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -19,28 +36,28 @@ msgstr ""
#: git-gui.sh:41 git-gui.sh:634 git-gui.sh:648 git-gui.sh:661 git-gui.sh:744
#: git-gui.sh:763
msgid "git-gui: fatal error"
-msgstr ""
+msgstr "git-gui: 致命错误"
-#: git-gui.sh:595
+#: git-gui.sh:593
#, tcl-format
msgid "Invalid font specified in %s:"
-msgstr ""
+msgstr "%s 中指定的字体无效:"
#: git-gui.sh:620
msgid "Main Font"
-msgstr ""
+msgstr "主è¦å­—体"
#: git-gui.sh:621
msgid "Diff/Console Font"
-msgstr ""
+msgstr "Diff/控制终端字体"
#: git-gui.sh:635
msgid "Cannot find git in PATH."
-msgstr ""
+msgstr "PATH 中没有找到 git"
#: git-gui.sh:662
msgid "Cannot parse Git version string:"
-msgstr ""
+msgstr "æ— æ³•è§£æž Git 的版本信æ¯:"
#: git-gui.sh:680
#, tcl-format
@@ -53,388 +70,386 @@ msgid ""
"\n"
"Assume '%s' is version 1.5.0?\n"
msgstr ""
+"无法确定 Git 的版本.\n"
+"\n"
+"%s 声明其版本为 '%s'.\n"
+"\n"
+"而 %s éœ€è¦ 1.5.0 或这以åŽçš„ Git 版本.\n"
+"\n"
+"是å¦å‡å®š '%s' 为版本 1.5.0?\n"
-#: git-gui.sh:853
+#: git-gui.sh:918
msgid "Git directory not found:"
-msgstr ""
+msgstr "Git 目录无法找到:"
-#: git-gui.sh:860
+#: git-gui.sh:925
msgid "Cannot move to top of working directory:"
-msgstr ""
+msgstr "无法移动到工作根目录:"
-#: git-gui.sh:867
+#: git-gui.sh:932
msgid "Cannot use funny .git directory:"
-msgstr ""
+msgstr "无法使用 .git 目录:"
-#: git-gui.sh:872
+#: git-gui.sh:937
msgid "No working directory"
-msgstr ""
+msgstr "没有工作目录"
-#: git-gui.sh:1019
+#: git-gui.sh:1084 lib/checkout_op.tcl:283
msgid "Refreshing file status..."
-msgstr ""
+msgstr "更新文件状æ€..."
-#: git-gui.sh:1084
+#: git-gui.sh:1149
msgid "Scanning for modified files ..."
-msgstr ""
+msgstr "扫æ修改过的文件 ..."
-#: git-gui.sh:1259 lib/browser.tcl:245
-#, fuzzy
+#: git-gui.sh:1324 lib/browser.tcl:246
msgid "Ready."
-msgstr "é‡åš"
+msgstr "就绪"
-#: git-gui.sh:1525
+#: git-gui.sh:1590
msgid "Unmodified"
-msgstr ""
+msgstr "未修改"
-#: git-gui.sh:1527
+#: git-gui.sh:1592
msgid "Modified, not staged"
-msgstr ""
+msgstr "修改但未缓存"
-#: git-gui.sh:1528 git-gui.sh:1533
-#, fuzzy
+#: git-gui.sh:1593 git-gui.sh:1598
msgid "Staged for commit"
-msgstr "从本次æ交移除"
+msgstr "缓存为æ交"
-#: git-gui.sh:1529 git-gui.sh:1534
-#, fuzzy
+#: git-gui.sh:1594 git-gui.sh:1599
msgid "Portions staged for commit"
-msgstr "从本次æ交移除"
+msgstr "部分缓存为æ交"
-#: git-gui.sh:1530 git-gui.sh:1535
+#: git-gui.sh:1595 git-gui.sh:1600
msgid "Staged for commit, missing"
-msgstr ""
+msgstr "缓存为æ交, ä¸å­˜åœ¨"
-#: git-gui.sh:1532
+#: git-gui.sh:1597
msgid "Untracked, not staged"
-msgstr ""
+msgstr "未跟踪, 未缓存"
-#: git-gui.sh:1537
+#: git-gui.sh:1602
msgid "Missing"
-msgstr ""
+msgstr "ä¸å­˜åœ¨"
-#: git-gui.sh:1538
+#: git-gui.sh:1603
msgid "Staged for removal"
-msgstr ""
+msgstr "缓存为删除"
-#: git-gui.sh:1539
+#: git-gui.sh:1604
msgid "Staged for removal, still present"
-msgstr ""
+msgstr "缓存为删除, 但ä»å­˜åœ¨"
-#: git-gui.sh:1541 git-gui.sh:1542 git-gui.sh:1543 git-gui.sh:1544
+#: git-gui.sh:1606 git-gui.sh:1607 git-gui.sh:1608 git-gui.sh:1609
msgid "Requires merge resolution"
-msgstr ""
+msgstr "需è¦è§£å†³åˆå¹¶å†²çª"
-#: git-gui.sh:1579
+#: git-gui.sh:1644
msgid "Starting gitk... please wait..."
-msgstr ""
+msgstr "å¯åŠ¨ gitk... 请等待..."
-#: git-gui.sh:1588
+#: git-gui.sh:1653
#, tcl-format
msgid ""
"Unable to start gitk:\n"
"\n"
"%s does not exist"
msgstr ""
+"无法å¯åŠ¨ gitk:\n"
+"\n"
+"%s ä¸å­˜åœ¨"
-#: git-gui.sh:1788 lib/choose_repository.tcl:32
+#: git-gui.sh:1860 lib/choose_repository.tcl:36
msgid "Repository"
-msgstr "版本树"
+msgstr "版本库(repository)"
-#: git-gui.sh:1789
+#: git-gui.sh:1861
msgid "Edit"
msgstr "编辑"
-#: git-gui.sh:1791 lib/choose_rev.tcl:560
+#: git-gui.sh:1863 lib/choose_rev.tcl:561
msgid "Branch"
-msgstr "分支"
+msgstr "分支(branch)"
-#: git-gui.sh:1794 lib/choose_rev.tcl:547
-#, fuzzy
+#: git-gui.sh:1866 lib/choose_rev.tcl:548
msgid "Commit@@noun"
-msgstr "æ交"
+msgstr "æ交(commit)"
-#: git-gui.sh:1797 lib/merge.tcl:121 lib/merge.tcl:150 lib/merge.tcl:168
+#: git-gui.sh:1869 lib/merge.tcl:120 lib/merge.tcl:149 lib/merge.tcl:167
msgid "Merge"
-msgstr "åˆå¹¶"
+msgstr "åˆå¹¶(merge)"
-#: git-gui.sh:1798 lib/choose_rev.tcl:556
-#, fuzzy
+#: git-gui.sh:1870 lib/choose_rev.tcl:557
msgid "Remote"
-msgstr "改å..."
+msgstr "远端(remote)"
-#: git-gui.sh:1807
+#: git-gui.sh:1879
msgid "Browse Current Branch's Files"
-msgstr "æµè§ˆå½“å‰åˆ†æ”¯æ–‡ä»¶"
+msgstr "æµè§ˆå½“å‰åˆ†æ”¯ä¸Šçš„文件"
-#: git-gui.sh:1811
-#, fuzzy
+#: git-gui.sh:1883
msgid "Browse Branch Files..."
-msgstr "æµè§ˆå½“å‰åˆ†æ”¯æ–‡ä»¶"
+msgstr "æµè§ˆåˆ†æ”¯ä¸Šçš„文件..."
-#: git-gui.sh:1816
+#: git-gui.sh:1888
msgid "Visualize Current Branch's History"
-msgstr "调用gitk显示当å‰åˆ†æ”¯"
+msgstr "图示当å‰åˆ†æ”¯çš„历å²"
-#: git-gui.sh:1820
+#: git-gui.sh:1892
msgid "Visualize All Branch History"
-msgstr "调用gitk显示所有分支"
+msgstr "图示所有分支的历å²"
-#: git-gui.sh:1827
-#, fuzzy, tcl-format
+#: git-gui.sh:1899
+#, tcl-format
msgid "Browse %s's Files"
-msgstr "æµè§ˆå½“å‰åˆ†æ”¯æ–‡ä»¶"
+msgstr "æµè§ˆ %s 上的文件"
-#: git-gui.sh:1829
-#, fuzzy, tcl-format
+#: git-gui.sh:1901
+#, tcl-format
msgid "Visualize %s's History"
-msgstr "调用gitk显示所有分支"
+msgstr "图示 %s 分支的历å²"
-#: git-gui.sh:1834 lib/database.tcl:27 lib/database.tcl:67
+#: git-gui.sh:1906 lib/database.tcl:27 lib/database.tcl:67
msgid "Database Statistics"
-msgstr "æ•°æ®åº“统计数æ®"
+msgstr "æ•°æ®åº“统计信æ¯"
-#: git-gui.sh:1837 lib/database.tcl:34
+#: git-gui.sh:1909 lib/database.tcl:34
msgid "Compress Database"
msgstr "压缩数æ®åº“"
-#: git-gui.sh:1840
+#: git-gui.sh:1912
msgid "Verify Database"
msgstr "验è¯æ•°æ®åº“"
-#: git-gui.sh:1847 git-gui.sh:1851 git-gui.sh:1855 lib/shortcut.tcl:9
-#: lib/shortcut.tcl:45 lib/shortcut.tcl:84
+#: git-gui.sh:1919 git-gui.sh:1923 git-gui.sh:1927 lib/shortcut.tcl:7
+#: lib/shortcut.tcl:39 lib/shortcut.tcl:71
msgid "Create Desktop Icon"
msgstr "创建桌é¢å›¾æ ‡"
-#: git-gui.sh:1860 lib/choose_repository.tcl:36 lib/choose_repository.tcl:95
+#: git-gui.sh:1932 lib/choose_repository.tcl:177 lib/choose_repository.tcl:185
msgid "Quit"
msgstr "退出"
-#: git-gui.sh:1867
+#: git-gui.sh:1939
msgid "Undo"
msgstr "撤销"
-#: git-gui.sh:1870
+#: git-gui.sh:1942
msgid "Redo"
msgstr "é‡åš"
-#: git-gui.sh:1874 git-gui.sh:2366
+#: git-gui.sh:1946 git-gui.sh:2443
msgid "Cut"
msgstr "剪切"
-#: git-gui.sh:1877 git-gui.sh:2369 git-gui.sh:2440 git-gui.sh:2512
-#: lib/console.tcl:67
+#: git-gui.sh:1949 git-gui.sh:2446 git-gui.sh:2520 git-gui.sh:2614
+#: lib/console.tcl:69
msgid "Copy"
msgstr "å¤åˆ¶"
-#: git-gui.sh:1880 git-gui.sh:2372
+#: git-gui.sh:1952 git-gui.sh:2449
msgid "Paste"
msgstr "粘贴"
-#: git-gui.sh:1883 git-gui.sh:2375 lib/branch_delete.tcl:26
+#: git-gui.sh:1955 git-gui.sh:2452 lib/branch_delete.tcl:26
#: lib/remote_branch_delete.tcl:38
msgid "Delete"
msgstr "删除"
-#: git-gui.sh:1887 git-gui.sh:2379 git-gui.sh:2516 lib/console.tcl:69
+#: git-gui.sh:1959 git-gui.sh:2456 git-gui.sh:2618 lib/console.tcl:71
msgid "Select All"
msgstr "全选"
-#: git-gui.sh:1896
+#: git-gui.sh:1968
msgid "Create..."
msgstr "新建..."
-#: git-gui.sh:1902
+#: git-gui.sh:1974
msgid "Checkout..."
-msgstr "切æ¢..."
+msgstr "Checkout..."
-#: git-gui.sh:1908
+#: git-gui.sh:1980
msgid "Rename..."
-msgstr "改å..."
+msgstr "æ›´å..."
-#: git-gui.sh:1913 git-gui.sh:2012
+#: git-gui.sh:1985 git-gui.sh:2085
msgid "Delete..."
msgstr "删除..."
-#: git-gui.sh:1918
+#: git-gui.sh:1990
msgid "Reset..."
-msgstr "é‡ç½®æ‰€æœ‰ä¿®åŠ¨..."
+msgstr "å¤ä½(Reset)..."
-#: git-gui.sh:1930 git-gui.sh:2313
+#: git-gui.sh:2002 git-gui.sh:2389
msgid "New Commit"
-msgstr "æ–°æ交"
+msgstr "新建æ交"
-#: git-gui.sh:1938 git-gui.sh:2320
+#: git-gui.sh:2010 git-gui.sh:2396
msgid "Amend Last Commit"
-msgstr "修订上次æ交"
+msgstr "修正上次æ交"
-#: git-gui.sh:1947 git-gui.sh:2280 lib/remote_branch_delete.tcl:99
+#: git-gui.sh:2019 git-gui.sh:2356 lib/remote_branch_delete.tcl:99
msgid "Rescan"
msgstr "é‡æ–°æ‰«æ"
-#: git-gui.sh:1953
-#, fuzzy
+#: git-gui.sh:2025
msgid "Stage To Commit"
-msgstr "从本次æ交移除"
+msgstr "缓存为æ交"
-#: git-gui.sh:1958
-#, fuzzy
+#: git-gui.sh:2031
msgid "Stage Changed Files To Commit"
-msgstr "将被æ交的修改"
+msgstr "缓存修改的文件为æ交"
-#: git-gui.sh:1964
+#: git-gui.sh:2037
msgid "Unstage From Commit"
-msgstr "从本次æ交移除"
+msgstr "从本次æ交撤除"
-#: git-gui.sh:1969 lib/index.tcl:352
+#: git-gui.sh:2042 lib/index.tcl:395
msgid "Revert Changes"
-msgstr "æ¢å¤ä¿®æ”¹"
+msgstr "撤销修改"
-#: git-gui.sh:1976 git-gui.sh:2292 git-gui.sh:2390
+#: git-gui.sh:2049 git-gui.sh:2368 git-gui.sh:2467
msgid "Sign Off"
-msgstr "ç­¾å"
+msgstr "ç­¾å(Sign Off)"
-#: git-gui.sh:1980 git-gui.sh:2296
-#, fuzzy
+#: git-gui.sh:2053 git-gui.sh:2372
msgid "Commit@@verb"
msgstr "æ交"
-#: git-gui.sh:1991
+#: git-gui.sh:2064
msgid "Local Merge..."
msgstr "本地åˆå¹¶..."
-#: git-gui.sh:1996
+#: git-gui.sh:2069
msgid "Abort Merge..."
-msgstr "å–消åˆå¹¶..."
+msgstr "中止åˆå¹¶..."
-#: git-gui.sh:2008
+#: git-gui.sh:2081
msgid "Push..."
msgstr "上传..."
-#: git-gui.sh:2019 lib/choose_repository.tcl:41
+#: git-gui.sh:2092 lib/choose_repository.tcl:41
msgid "Apple"
msgstr "苹果"
-#: git-gui.sh:2022 git-gui.sh:2044 lib/about.tcl:13
+#: git-gui.sh:2095 git-gui.sh:2117 lib/about.tcl:14
#: lib/choose_repository.tcl:44 lib/choose_repository.tcl:50
#, tcl-format
msgid "About %s"
-msgstr "关于%s"
+msgstr "关于 %s"
-#: git-gui.sh:2026
+#: git-gui.sh:2099
msgid "Preferences..."
-msgstr ""
+msgstr "首选项..."
-#: git-gui.sh:2034 git-gui.sh:2558
+#: git-gui.sh:2107 git-gui.sh:2639
msgid "Options..."
msgstr "选项..."
-#: git-gui.sh:2040 lib/choose_repository.tcl:47
+#: git-gui.sh:2113 lib/choose_repository.tcl:47
msgid "Help"
msgstr "帮助"
-#: git-gui.sh:2081
+#: git-gui.sh:2154
msgid "Online Documentation"
msgstr "在线文档"
-#: git-gui.sh:2165
+#: git-gui.sh:2238
#, tcl-format
msgid "fatal: cannot stat path %s: No such file or directory"
-msgstr ""
+msgstr "致命错误: 无法获å–路径 %s çš„ä¿¡æ¯: 该文件或目录ä¸å­˜åœ¨"
-#: git-gui.sh:2198
+#: git-gui.sh:2271
msgid "Current Branch:"
msgstr "当å‰åˆ†æ”¯:"
-#: git-gui.sh:2219
-#, fuzzy
+#: git-gui.sh:2292
msgid "Staged Changes (Will Commit)"
-msgstr "将被æ交的修改"
+msgstr "已缓存的改动 (将被æ交)"
-#: git-gui.sh:2239
+#: git-gui.sh:2312
msgid "Unstaged Changes"
-msgstr ""
+msgstr "未缓存的改动"
-#: git-gui.sh:2286
+#: git-gui.sh:2362
msgid "Stage Changed"
-msgstr ""
+msgstr "缓存改动"
-#: git-gui.sh:2302 lib/transport.tcl:93 lib/transport.tcl:182
+#: git-gui.sh:2378 lib/transport.tcl:93 lib/transport.tcl:182
msgid "Push"
msgstr "上传"
-#: git-gui.sh:2332
+#: git-gui.sh:2408
msgid "Initial Commit Message:"
-msgstr "åˆå§‹æ交æè¿°:"
+msgstr "åˆå§‹çš„æ交æè¿°:"
-#: git-gui.sh:2333
+#: git-gui.sh:2409
msgid "Amended Commit Message:"
-msgstr "修订æ交æè¿°:"
+msgstr "修正的æ交æè¿°:"
-#: git-gui.sh:2334
+#: git-gui.sh:2410
msgid "Amended Initial Commit Message:"
-msgstr "修订åˆå§‹æ交æè¿°:"
+msgstr "修正的åˆå§‹æ交æè¿°:"
-#: git-gui.sh:2335
+#: git-gui.sh:2411
msgid "Amended Merge Commit Message:"
-msgstr "修订åˆå¹¶æ交æè¿°:"
+msgstr "修正的åˆå¹¶æ交æè¿°:"
-#: git-gui.sh:2336
+#: git-gui.sh:2412
msgid "Merge Commit Message:"
msgstr "åˆå¹¶æ交æè¿°:"
-#: git-gui.sh:2337
+#: git-gui.sh:2413
msgid "Commit Message:"
msgstr "æ交æè¿°:"
-#: git-gui.sh:2382 git-gui.sh:2520 lib/console.tcl:71
+#: git-gui.sh:2459 git-gui.sh:2622 lib/console.tcl:73
msgid "Copy All"
msgstr "全部å¤åˆ¶"
-#: git-gui.sh:2406 lib/blame.tcl:104
+#: git-gui.sh:2483 lib/blame.tcl:107
msgid "File:"
-msgstr ""
-
-#: git-gui.sh:2508
-msgid "Refresh"
-msgstr "刷新"
+msgstr "文件:"
-#: git-gui.sh:2529
+#: git-gui.sh:2589
msgid "Apply/Reverse Hunk"
msgstr "应用/撤消此修改å—"
-#: git-gui.sh:2535
+#: git-gui.sh:2595
+msgid "Show Less Context"
+msgstr "显示更少上下文"
+
+#: git-gui.sh:2602
+msgid "Show More Context"
+msgstr "显示更多上下文"
+
+#: git-gui.sh:2610
+msgid "Refresh"
+msgstr "刷新"
+
+#: git-gui.sh:2631
msgid "Decrease Font Size"
msgstr "缩å°å­—体"
-#: git-gui.sh:2539
+#: git-gui.sh:2635
msgid "Increase Font Size"
msgstr "放大字体"
-#: git-gui.sh:2544
-msgid "Show Less Context"
-msgstr "显示更多diff上下文"
-
-#: git-gui.sh:2551
-msgid "Show More Context"
-msgstr "显示更少diff上下文"
-
-#: git-gui.sh:2565
-#, fuzzy
+#: git-gui.sh:2646
msgid "Unstage Hunk From Commit"
-msgstr "从本次æ交移除"
+msgstr "从æ交中撤除修改å—"
-#: git-gui.sh:2567
-#, fuzzy
+#: git-gui.sh:2648
msgid "Stage Hunk For Commit"
-msgstr "从本次æ交移除"
+msgstr "缓存修改å—为æ交"
-#: git-gui.sh:2586
+#: git-gui.sh:2667
msgid "Initializing..."
-msgstr ""
+msgstr "åˆå§‹åŒ–..."
-#: git-gui.sh:2677
+#: git-gui.sh:2762
#, tcl-format
msgid ""
"Possible environment issues exist.\n"
@@ -444,15 +459,22 @@ msgid ""
"by %s:\n"
"\n"
msgstr ""
+"å¯èƒ½å­˜åœ¨çŽ¯å¢ƒå˜é‡çš„问题.\n"
+"\n"
+"ç”± %s 执行的 Git å­è¿›ç¨‹å¯èƒ½å¿½ç•¥ä¸‹åˆ—环境å˜é‡:\n"
+"\n"
-#: git-gui.sh:2707
+#: git-gui.sh:2792
msgid ""
"\n"
"This is due to a known issue with the\n"
"Tcl binary distributed by Cygwin."
msgstr ""
+"\n"
+"这是由 Cygwin å‘布的 Tcl 代ç ä¸­ä¸€ä¸ª\n"
+"已知问题所引起."
-#: git-gui.sh:2712
+#: git-gui.sh:2797
#, tcl-format
msgid ""
"\n"
@@ -462,206 +484,197 @@ msgid ""
"user.email settings into your personal\n"
"~/.gitconfig file.\n"
msgstr ""
+"\n"
+"\n"
+"%s 的一个很好的替代方案是将 user.name 以åŠ\n"
+"user.email 设置放在你的个人 ~/.gitconfig 文件中.\n"
-#: lib/about.tcl:25
+#: lib/about.tcl:26
msgid "git-gui - a graphical user interface for Git."
-msgstr ""
+msgstr "git-gui - Git 的图形化用户界é¢"
#: lib/blame.tcl:77
msgid "File Viewer"
-msgstr ""
+msgstr "文件查看器"
#: lib/blame.tcl:81
-#, fuzzy
msgid "Commit:"
-msgstr "æ交"
+msgstr "æ交:"
-#: lib/blame.tcl:249
-#, fuzzy
+#: lib/blame.tcl:264
msgid "Copy Commit"
-msgstr "æ交"
+msgstr "å¤åˆ¶æ交"
-#: lib/blame.tcl:369
+#: lib/blame.tcl:384
#, tcl-format
msgid "Reading %s..."
-msgstr ""
+msgstr "è¯»å– %s..."
-#: lib/blame.tcl:473
+#: lib/blame.tcl:488
msgid "Loading copy/move tracking annotations..."
-msgstr ""
+msgstr "装载å¤åˆ¶/移动跟踪标注..."
-#: lib/blame.tcl:493
+#: lib/blame.tcl:508
msgid "lines annotated"
-msgstr ""
+msgstr "标注行"
-#: lib/blame.tcl:674
+#: lib/blame.tcl:689
msgid "Loading original location annotations..."
-msgstr ""
+msgstr "装载原始ä½ç½®æ ‡æ³¨..."
-#: lib/blame.tcl:677
+#: lib/blame.tcl:692
msgid "Annotation complete."
-msgstr ""
+msgstr "标注完æˆ."
-#: lib/blame.tcl:731
+#: lib/blame.tcl:746
msgid "Loading annotation..."
-msgstr ""
+msgstr "è£è¼‰æ ‡æ³¨..."
-#: lib/blame.tcl:787
+#: lib/blame.tcl:802
msgid "Author:"
-msgstr ""
+msgstr "作者:"
-#: lib/blame.tcl:791
-#, fuzzy
+#: lib/blame.tcl:806
msgid "Committer:"
-msgstr "æ交"
+msgstr "æ交者:"
-#: lib/blame.tcl:796
+#: lib/blame.tcl:811
msgid "Original File:"
-msgstr ""
+msgstr "原始文件:"
-#: lib/blame.tcl:910
+#: lib/blame.tcl:925
msgid "Originally By:"
-msgstr ""
+msgstr "最åˆç”±:"
-#: lib/blame.tcl:916
+#: lib/blame.tcl:931
msgid "In File:"
-msgstr ""
+msgstr "在文件:"
-#: lib/blame.tcl:921
+#: lib/blame.tcl:936
msgid "Copied Or Moved Here By:"
-msgstr ""
+msgstr "ç”±å¤åˆ¶æˆ–移动至此:"
#: lib/branch_checkout.tcl:14 lib/branch_checkout.tcl:19
-#, fuzzy
msgid "Checkout Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "Checkout 分支"
#: lib/branch_checkout.tcl:23
-#, fuzzy
msgid "Checkout"
-msgstr "切æ¢..."
+msgstr "Checkout"
#: lib/branch_checkout.tcl:27 lib/branch_create.tcl:35
-#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:281
-#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:172
-#: lib/option.tcl:90 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
+#: lib/branch_delete.tcl:32 lib/branch_rename.tcl:30 lib/browser.tcl:282
+#: lib/checkout_op.tcl:522 lib/choose_font.tcl:43 lib/merge.tcl:171
+#: lib/option.tcl:103 lib/remote_branch_delete.tcl:42 lib/transport.tcl:97
msgid "Cancel"
-msgstr ""
+msgstr "å–消"
-#: lib/branch_checkout.tcl:32 lib/browser.tcl:286
+#: lib/branch_checkout.tcl:32 lib/browser.tcl:287
msgid "Revision"
-msgstr ""
+msgstr "版本"
-#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:202
-#, fuzzy
+#: lib/branch_checkout.tcl:36 lib/branch_create.tcl:69 lib/option.tcl:242
msgid "Options"
msgstr "选项..."
#: lib/branch_checkout.tcl:39 lib/branch_create.tcl:92
msgid "Fetch Tracking Branch"
-msgstr ""
+msgstr "获å–跟踪分支"
#: lib/branch_checkout.tcl:44
msgid "Detach From Local Branch"
-msgstr ""
+msgstr "从本地分支脱离"
#: lib/branch_create.tcl:22
-#, fuzzy
msgid "Create Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "创建分支"
#: lib/branch_create.tcl:27
-#, fuzzy
msgid "Create New Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "新建分支"
-#: lib/branch_create.tcl:31 lib/choose_repository.tcl:199
-#, fuzzy
+#: lib/branch_create.tcl:31 lib/choose_repository.tcl:371
msgid "Create"
-msgstr "新建..."
+msgstr "新建"
#: lib/branch_create.tcl:40
-#, fuzzy
msgid "Branch Name"
-msgstr "分支"
+msgstr "分支å"
#: lib/branch_create.tcl:43
msgid "Name:"
-msgstr ""
+msgstr "åå­—:"
#: lib/branch_create.tcl:58
msgid "Match Tracking Branch Name"
-msgstr ""
+msgstr "匹é…跟踪分支åå­—"
#: lib/branch_create.tcl:66
msgid "Starting Revision"
-msgstr ""
+msgstr "起始版本"
#: lib/branch_create.tcl:72
msgid "Update Existing Branch:"
-msgstr ""
+msgstr "更新已有分支:"
#: lib/branch_create.tcl:75
msgid "No"
-msgstr ""
+msgstr "å·ç "
#: lib/branch_create.tcl:80
msgid "Fast Forward Only"
-msgstr ""
+msgstr "仅快速åˆå¹¶"
#: lib/branch_create.tcl:85 lib/checkout_op.tcl:514
-#, fuzzy
msgid "Reset"
-msgstr "é‡ç½®æ‰€æœ‰ä¿®åŠ¨..."
+msgstr "å¤ä½"
#: lib/branch_create.tcl:97
msgid "Checkout After Creation"
-msgstr ""
+msgstr "在创建åŽCheckout"
#: lib/branch_create.tcl:131
msgid "Please select a tracking branch."
-msgstr ""
+msgstr "请选择æŸä¸ªè·Ÿè¸ªåˆ†æ”¯."
#: lib/branch_create.tcl:140
#, tcl-format
msgid "Tracking branch %s is not a branch in the remote repository."
-msgstr ""
+msgstr "跟踪分支 %s 并ä¸æ˜¯è¿œç«¯ç‰ˆæœ¬åº“中的一个分支"
#: lib/branch_create.tcl:153 lib/branch_rename.tcl:86
msgid "Please supply a branch name."
-msgstr ""
+msgstr "请æ供分支åå­—."
#: lib/branch_create.tcl:164 lib/branch_rename.tcl:106
#, tcl-format
msgid "'%s' is not an acceptable branch name."
-msgstr ""
+msgstr "'%s'ä¸æ˜¯ä¸€ä¸ªå¯æŽ¥å—的分支å."
#: lib/branch_delete.tcl:15
-#, fuzzy
msgid "Delete Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "删除分支"
#: lib/branch_delete.tcl:20
msgid "Delete Local Branch"
-msgstr ""
+msgstr "删除本地分支"
#: lib/branch_delete.tcl:37
-#, fuzzy
msgid "Local Branches"
-msgstr "分支"
+msgstr "本地分支"
#: lib/branch_delete.tcl:52
msgid "Delete Only If Merged Into"
-msgstr ""
+msgstr "仅在åˆå¹¶åŽåˆ é™¤"
#: lib/branch_delete.tcl:54
msgid "Always (Do not perform merge test.)"
-msgstr ""
+msgstr "总是åˆå¹¶ (ä¸ä½œåˆå¹¶æµ‹è¯•.)"
#: lib/branch_delete.tcl:103
#, tcl-format
msgid "The following branches are not completely merged into %s:"
-msgstr ""
+msgstr "下列分支没有完全被åˆå¹¶åˆ° %s:"
#: lib/branch_delete.tcl:115
msgid ""
@@ -669,6 +682,9 @@ msgid ""
"\n"
" Delete the selected branches?"
msgstr ""
+"æ¢å¤è¢«åˆ é™¤çš„分支éžå¸¸å›°éš¾.\n"
+"\n"
+"是å¦è¦åˆ é™¤æ‰€é€‰åˆ†æ”¯?"
#: lib/branch_delete.tcl:141
#, tcl-format
@@ -676,86 +692,84 @@ msgid ""
"Failed to delete branches:\n"
"%s"
msgstr ""
+"无法删除分支:\n"
+"%s"
#: lib/branch_rename.tcl:14 lib/branch_rename.tcl:22
-#, fuzzy
msgid "Rename Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "更改分支å:"
#: lib/branch_rename.tcl:26
-#, fuzzy
msgid "Rename"
-msgstr "改å..."
+msgstr "æ›´å..."
#: lib/branch_rename.tcl:36
-#, fuzzy
msgid "Branch:"
-msgstr "分支"
+msgstr "分支:"
#: lib/branch_rename.tcl:39
msgid "New Name:"
-msgstr ""
+msgstr "æ–°åå­—:"
#: lib/branch_rename.tcl:75
msgid "Please select a branch to rename."
-msgstr ""
+msgstr "请选择分支更å."
#: lib/branch_rename.tcl:96 lib/checkout_op.tcl:179
#, tcl-format
msgid "Branch '%s' already exists."
-msgstr ""
+msgstr "分支 '%s' å·²ç»å­˜åœ¨."
#: lib/branch_rename.tcl:117
#, tcl-format
msgid "Failed to rename '%s'."
-msgstr ""
+msgstr "无法更å '%s'."
#: lib/browser.tcl:17
msgid "Starting..."
-msgstr ""
+msgstr "开始..."
#: lib/browser.tcl:26
msgid "File Browser"
-msgstr ""
+msgstr "文件æµè§ˆå™¨"
-#: lib/browser.tcl:125 lib/browser.tcl:142
+#: lib/browser.tcl:126 lib/browser.tcl:143
#, tcl-format
msgid "Loading %s..."
-msgstr ""
+msgstr "装载 %s..."
-#: lib/browser.tcl:186
+#: lib/browser.tcl:187
msgid "[Up To Parent]"
-msgstr ""
+msgstr "[上层目录]"
-#: lib/browser.tcl:266 lib/browser.tcl:272
-#, fuzzy
+#: lib/browser.tcl:267 lib/browser.tcl:273
msgid "Browse Branch Files"
-msgstr "æµè§ˆå½“å‰åˆ†æ”¯æ–‡ä»¶"
+msgstr "æµè§ˆåˆ†æ”¯æ–‡ä»¶"
-#: lib/browser.tcl:277 lib/choose_repository.tcl:215
-#: lib/choose_repository.tcl:305 lib/choose_repository.tcl:315
-#: lib/choose_repository.tcl:811
+#: lib/browser.tcl:278 lib/choose_repository.tcl:387
+#: lib/choose_repository.tcl:474 lib/choose_repository.tcl:484
+#: lib/choose_repository.tcl:987
msgid "Browse"
-msgstr ""
+msgstr "æµè§ˆ"
#: lib/checkout_op.tcl:79
#, tcl-format
msgid "Fetching %s from %s"
-msgstr ""
+msgstr "èŽ·å– %s 自 %s"
#: lib/checkout_op.tcl:127
#, tcl-format
msgid "fatal: Cannot resolve %s"
-msgstr ""
+msgstr "致命错误: 无法解决 %s"
-#: lib/checkout_op.tcl:140 lib/console.tcl:79 lib/database.tcl:31
+#: lib/checkout_op.tcl:140 lib/console.tcl:81 lib/database.tcl:31
msgid "Close"
-msgstr ""
+msgstr "关闭"
#: lib/checkout_op.tcl:169
#, tcl-format
msgid "Branch '%s' does not exist."
-msgstr ""
+msgstr "分支 '%s' 并ä¸å­˜åœ¨."
#: lib/checkout_op.tcl:206
#, tcl-format
@@ -765,20 +779,24 @@ msgid ""
"It cannot fast-forward to %s.\n"
"A merge is required."
msgstr ""
+"分支 '%s' å·²ç»å­˜åœ¨.\n"
+"\n"
+"无法快速åˆå¹¶åˆ° %s.\n"
+"需è¦æ™®é€šåˆå¹¶."
#: lib/checkout_op.tcl:220
#, tcl-format
msgid "Merge strategy '%s' not supported."
-msgstr ""
+msgstr "åˆå¹¶ç­–ç•¥ '%s' ä¸æ”¯æŒ."
#: lib/checkout_op.tcl:239
#, tcl-format
msgid "Failed to update '%s'."
-msgstr ""
+msgstr "无法更新 '%s'."
#: lib/checkout_op.tcl:251
msgid "Staging area (index) is already locked."
-msgstr ""
+msgstr "缓存区域 (index) 已被é”定."
#: lib/checkout_op.tcl:266
msgid ""
@@ -789,25 +807,35 @@ msgid ""
"\n"
"The rescan will be automatically started now.\n"
msgstr ""
+"最åŽä¸€æ¬¡æ‰«æ的状æ€å’Œå½“å‰ç‰ˆæœ¬åº“状æ€ä¸ç¬¦.\n"
+"\n"
+"å¦ä¸€ Git 程åºè‡ªä¸Šæ¬¡æ‰«æåŽä¿®æ”¹äº†æœ¬ç‰ˆæœ¬åº“. 在修改当å‰åˆ†æ”¯ä¹‹å‰éœ€è¦é‡æ–°åšä¸€æ¬¡æ‰«"
+"æ.\n"
+"\n"
+"é‡æ–°æ‰«æ将自动开始.\n"
#: lib/checkout_op.tcl:322
#, tcl-format
msgid "Updating working directory to '%s'..."
+msgstr "更新工作目录到 '%s'..."
+
+#: lib/checkout_op.tcl:323
+msgid "files checked out"
msgstr ""
#: lib/checkout_op.tcl:353
#, tcl-format
msgid "Aborted checkout of '%s' (file level merging is required)."
-msgstr ""
+msgstr "中止 '%s' çš„ checkout æ“作 (需è¦åšæ–‡ä»¶çº§åˆå¹¶)."
#: lib/checkout_op.tcl:354
msgid "File level merge required."
-msgstr ""
+msgstr "需è¦æ–‡ä»¶çº§åˆå¹¶."
#: lib/checkout_op.tcl:358
#, tcl-format
msgid "Staying on branch '%s'."
-msgstr ""
+msgstr "åœç•™åœ¨åˆ†æ”¯ '%s'."
#: lib/checkout_op.tcl:429
msgid ""
@@ -816,29 +844,32 @@ msgid ""
"If you wanted to be on a branch, create one now starting from 'This Detached "
"Checkout'."
msgstr ""
+"ä½ ä¸åœ¨æŸä¸ªæœ¬åœ°åˆ†æ”¯ä¸Š.\n"
+"\n"
+"如果你想ä½äºŽæŸåˆ†æ”¯ä¸Š, 从当å‰è„±èŠ‚çš„Checkout中创建一个新分支."
-#: lib/checkout_op.tcl:446
-#, fuzzy, tcl-format
+#: lib/checkout_op.tcl:446 lib/checkout_op.tcl:450
+#, tcl-format
msgid "Checked out '%s'."
-msgstr "切æ¢..."
+msgstr "'%s' 已被 checkout"
#: lib/checkout_op.tcl:478
#, tcl-format
msgid "Resetting '%s' to '%s' will lose the following commits:"
-msgstr ""
+msgstr "å¤ä½ '%s' 到 '%s' 将导致下列æ交的丢失:"
#: lib/checkout_op.tcl:500
msgid "Recovering lost commits may not be easy."
-msgstr ""
+msgstr "æ¢å¤ä¸¢å¤±çš„æ交是比较困难的."
#: lib/checkout_op.tcl:505
#, tcl-format
msgid "Reset '%s'?"
-msgstr ""
+msgstr "å¤ä½ '%s'?"
-#: lib/checkout_op.tcl:510 lib/merge.tcl:164
+#: lib/checkout_op.tcl:510 lib/merge.tcl:163
msgid "Visualize"
-msgstr ""
+msgstr "图示"
#: lib/checkout_op.tcl:578
#, tcl-format
@@ -850,286 +881,301 @@ msgid ""
"\n"
"This should not have occurred. %s will now close and give up."
msgstr ""
+"无法设定当å‰åˆ†æ”¯.\n"
+"\n"
+"当å‰å·¥ä½œç›®å½•ä»…有部分被切æ¢å‡º, 我们已æˆåŠŸçš„更新了您的文件但是无法更新æŸä¸ªå†…部"
+"的Git文件.\n"
+"\n"
+"这本ä¸è¯¥å‘生, %s 将关闭并放弃."
#: lib/choose_font.tcl:39
-#, fuzzy
msgid "Select"
-msgstr "全选"
+msgstr "选择"
#: lib/choose_font.tcl:53
msgid "Font Family"
-msgstr ""
+msgstr "字体æ—"
-#: lib/choose_font.tcl:73
-#, fuzzy
+#: lib/choose_font.tcl:74
msgid "Font Size"
-msgstr "缩å°å­—体"
+msgstr "字体大å°"
-#: lib/choose_font.tcl:90
+#: lib/choose_font.tcl:91
msgid "Font Example"
-msgstr ""
+msgstr "字体样例"
-#: lib/choose_font.tcl:101
+#: lib/choose_font.tcl:103
msgid ""
"This is example text.\n"
"If you like this text, it can be your font."
msgstr ""
+"这是样例文本.\n"
+"如果你喜欢, ä½ å¯ä»¥è®¾ç½®è¯¥å­—体."
-#: lib/choose_repository.tcl:25
+#: lib/choose_repository.tcl:28
msgid "Git Gui"
-msgstr ""
+msgstr "Git Gui"
-#: lib/choose_repository.tcl:69 lib/choose_repository.tcl:204
-#, fuzzy
+#: lib/choose_repository.tcl:81 lib/choose_repository.tcl:376
msgid "Create New Repository"
-msgstr "版本树"
+msgstr "创建新的版本库"
-#: lib/choose_repository.tcl:74 lib/choose_repository.tcl:291
-#, fuzzy
+#: lib/choose_repository.tcl:87
+msgid "New..."
+msgstr "新建..."
+
+#: lib/choose_repository.tcl:94 lib/choose_repository.tcl:460
msgid "Clone Existing Repository"
-msgstr "版本树"
+msgstr "克隆已有版本库"
-#: lib/choose_repository.tcl:79 lib/choose_repository.tcl:800
-#, fuzzy
+#: lib/choose_repository.tcl:100
+msgid "Clone..."
+msgstr "克隆..."
+
+#: lib/choose_repository.tcl:107 lib/choose_repository.tcl:976
msgid "Open Existing Repository"
-msgstr "版本树"
+msgstr "打开已有版本库"
-#: lib/choose_repository.tcl:91
-msgid "Next >"
-msgstr ""
+#: lib/choose_repository.tcl:113
+msgid "Open..."
+msgstr "打开..."
-#: lib/choose_repository.tcl:152
-#, tcl-format
-msgid "Location %s already exists."
-msgstr ""
+#: lib/choose_repository.tcl:126
+msgid "Recent Repositories"
+msgstr "最近版本库"
-#: lib/choose_repository.tcl:158 lib/choose_repository.tcl:165
-#: lib/choose_repository.tcl:172
+#: lib/choose_repository.tcl:132
+msgid "Open Recent Repository:"
+msgstr "打开最近版本库"
+
+#: lib/choose_repository.tcl:296 lib/choose_repository.tcl:303
+#: lib/choose_repository.tcl:310
#, tcl-format
msgid "Failed to create repository %s:"
-msgstr ""
+msgstr "无法创建版本库 %s:"
-#: lib/choose_repository.tcl:209 lib/choose_repository.tcl:309
+#: lib/choose_repository.tcl:381 lib/choose_repository.tcl:478
msgid "Directory:"
-msgstr ""
+msgstr "目录:"
-#: lib/choose_repository.tcl:238 lib/choose_repository.tcl:363
-#: lib/choose_repository.tcl:834
-#, fuzzy
+#: lib/choose_repository.tcl:412 lib/choose_repository.tcl:537
+#: lib/choose_repository.tcl:1011
msgid "Git Repository"
-msgstr "版本树"
+msgstr "Git 版本库"
-#: lib/choose_repository.tcl:253 lib/choose_repository.tcl:260
+#: lib/choose_repository.tcl:437
#, tcl-format
msgid "Directory %s already exists."
-msgstr ""
+msgstr "目录 %s å·²ç»å­˜åœ¨."
-#: lib/choose_repository.tcl:265
+#: lib/choose_repository.tcl:441
#, tcl-format
msgid "File %s already exists."
-msgstr ""
+msgstr "文件 %s å·²ç»å­˜åœ¨."
-#: lib/choose_repository.tcl:286
+#: lib/choose_repository.tcl:455
msgid "Clone"
-msgstr ""
+msgstr "克隆"
-#: lib/choose_repository.tcl:299
+#: lib/choose_repository.tcl:468
msgid "URL:"
-msgstr ""
+msgstr "URL:"
-#: lib/choose_repository.tcl:319
+#: lib/choose_repository.tcl:489
msgid "Clone Type:"
-msgstr ""
+msgstr "克隆类型:"
-#: lib/choose_repository.tcl:325
+#: lib/choose_repository.tcl:495
msgid "Standard (Fast, Semi-Redundant, Hardlinks)"
-msgstr ""
+msgstr "æ ‡å‡†æ–¹å¼ (快速, 部分备份, 作硬连接)"
-#: lib/choose_repository.tcl:331
+#: lib/choose_repository.tcl:501
msgid "Full Copy (Slower, Redundant Backup)"
-msgstr ""
+msgstr "全部å¤åˆ¶ (较慢, åšå¤‡ä»½)"
-#: lib/choose_repository.tcl:337
+#: lib/choose_repository.tcl:507
msgid "Shared (Fastest, Not Recommended, No Backup)"
-msgstr ""
+msgstr "å…±äº«æ–¹å¼ (最快, ä¸æŽ¨è, ä¸åšå¤‡ä»½)"
-#: lib/choose_repository.tcl:369 lib/choose_repository.tcl:418
-#: lib/choose_repository.tcl:560 lib/choose_repository.tcl:630
-#: lib/choose_repository.tcl:840 lib/choose_repository.tcl:848
+#: lib/choose_repository.tcl:543 lib/choose_repository.tcl:590
+#: lib/choose_repository.tcl:736 lib/choose_repository.tcl:806
+#: lib/choose_repository.tcl:1017 lib/choose_repository.tcl:1025
#, tcl-format
msgid "Not a Git repository: %s"
-msgstr ""
+msgstr "ä¸æ˜¯ä¸€ä¸ª Git 版本库: %s"
-#: lib/choose_repository.tcl:405
+#: lib/choose_repository.tcl:579
msgid "Standard only available for local repository."
-msgstr ""
+msgstr "标准方å¼ä»…当是本地版本库时有效."
-#: lib/choose_repository.tcl:409
+#: lib/choose_repository.tcl:583
msgid "Shared only available for local repository."
-msgstr ""
+msgstr "共享方å¼ä»…当是本地版本库时有效."
-#: lib/choose_repository.tcl:439
+#: lib/choose_repository.tcl:604
+#, tcl-format
+msgid "Location %s already exists."
+msgstr "ä½ç½® %s å·²ç»å­˜åœ¨."
+
+#: lib/choose_repository.tcl:615
msgid "Failed to configure origin"
-msgstr ""
+msgstr "无法é…ç½® origin"
-#: lib/choose_repository.tcl:451
+#: lib/choose_repository.tcl:627
msgid "Counting objects"
-msgstr ""
+msgstr "清点对象"
-#: lib/choose_repository.tcl:452
+#: lib/choose_repository.tcl:628
+#, fuzzy
msgid "buckets"
-msgstr ""
+msgstr "水桶??"
-#: lib/choose_repository.tcl:476
+#: lib/choose_repository.tcl:652
#, tcl-format
msgid "Unable to copy objects/info/alternates: %s"
-msgstr ""
+msgstr "无法å¤åˆ¶ objects/info/alternates: %s"
-#: lib/choose_repository.tcl:512
+#: lib/choose_repository.tcl:688
#, tcl-format
msgid "Nothing to clone from %s."
-msgstr ""
+msgstr "没有东西å¯ä»Ž %s 克隆."
-#: lib/choose_repository.tcl:514 lib/choose_repository.tcl:728
-#: lib/choose_repository.tcl:740
+#: lib/choose_repository.tcl:690 lib/choose_repository.tcl:904
+#: lib/choose_repository.tcl:916
msgid "The 'master' branch has not been initialized."
-msgstr ""
+msgstr "'master'分支尚未åˆå§‹åŒ–."
-#: lib/choose_repository.tcl:527
+#: lib/choose_repository.tcl:703
msgid "Hardlinks are unavailable. Falling back to copying."
-msgstr ""
+msgstr "硬连接ä¸å¯ç”¨. 使用å¤åˆ¶."
-#: lib/choose_repository.tcl:539
+#: lib/choose_repository.tcl:715
#, tcl-format
msgid "Cloning from %s"
-msgstr ""
+msgstr "从 %s 克隆"
-#: lib/choose_repository.tcl:570
-#, fuzzy
+#: lib/choose_repository.tcl:746
msgid "Copying objects"
-msgstr "压缩数æ®åº“"
+msgstr "å¤åˆ¶ objects"
-#: lib/choose_repository.tcl:571
+#: lib/choose_repository.tcl:747
msgid "KiB"
-msgstr ""
+msgstr "KiB"
-#: lib/choose_repository.tcl:595
+#: lib/choose_repository.tcl:771
#, tcl-format
msgid "Unable to copy object: %s"
-msgstr ""
+msgstr "无法å¤åˆ¶ object: %s"
-#: lib/choose_repository.tcl:605
+#: lib/choose_repository.tcl:781
msgid "Linking objects"
-msgstr ""
+msgstr "链接 objects"
-#: lib/choose_repository.tcl:606
+#: lib/choose_repository.tcl:782
msgid "objects"
-msgstr ""
+msgstr "objects"
-#: lib/choose_repository.tcl:614
+#: lib/choose_repository.tcl:790
#, tcl-format
msgid "Unable to hardlink object: %s"
-msgstr ""
+msgstr "无法硬链接 object: %s"
-#: lib/choose_repository.tcl:669
+#: lib/choose_repository.tcl:845
msgid "Cannot fetch branches and objects. See console output for details."
-msgstr ""
+msgstr "无法获å–分支和对象. 请查看控制终端的输出."
-#: lib/choose_repository.tcl:680
+#: lib/choose_repository.tcl:856
msgid "Cannot fetch tags. See console output for details."
-msgstr ""
+msgstr "无法获å–标签. 请查看控制终端的输出."
-#: lib/choose_repository.tcl:704
+#: lib/choose_repository.tcl:880
msgid "Cannot determine HEAD. See console output for details."
-msgstr ""
+msgstr "无法确定 HEAD. 请查看控制终端的输出."
-#: lib/choose_repository.tcl:713
+#: lib/choose_repository.tcl:889
#, tcl-format
msgid "Unable to cleanup %s"
-msgstr ""
+msgstr "æ— æ³•æ¸…ç† %s"
-#: lib/choose_repository.tcl:719
+#: lib/choose_repository.tcl:895
msgid "Clone failed."
-msgstr ""
+msgstr "克隆失败."
-#: lib/choose_repository.tcl:726
+#: lib/choose_repository.tcl:902
msgid "No default branch obtained."
-msgstr ""
+msgstr "没有获å–缺çœåˆ†æ”¯"
-#: lib/choose_repository.tcl:737
+#: lib/choose_repository.tcl:913
#, tcl-format
msgid "Cannot resolve %s as a commit."
-msgstr ""
+msgstr "æ— æ³•è§£æž %s 为æ交."
-#: lib/choose_repository.tcl:749
+#: lib/choose_repository.tcl:925
msgid "Creating working directory"
-msgstr ""
+msgstr "创建工作目录"
-#: lib/choose_repository.tcl:750 lib/index.tcl:15 lib/index.tcl:80
-#: lib/index.tcl:149
+#: lib/choose_repository.tcl:926 lib/index.tcl:65 lib/index.tcl:127
+#: lib/index.tcl:193
msgid "files"
-msgstr ""
+msgstr "文件"
-#: lib/choose_repository.tcl:779
+#: lib/choose_repository.tcl:955
msgid "Initial file checkout failed."
-msgstr ""
+msgstr "åˆå§‹çš„文件checkout失败"
-#: lib/choose_repository.tcl:795
+#: lib/choose_repository.tcl:971
msgid "Open"
-msgstr ""
+msgstr "打开"
-#: lib/choose_repository.tcl:805
-#, fuzzy
+#: lib/choose_repository.tcl:981
msgid "Repository:"
-msgstr "版本树"
+msgstr "版本库"
-#: lib/choose_repository.tcl:854
+#: lib/choose_repository.tcl:1031
#, tcl-format
msgid "Failed to open repository %s:"
-msgstr ""
+msgstr "无法打开版本库 %s:"
#: lib/choose_rev.tcl:53
msgid "This Detached Checkout"
-msgstr ""
+msgstr "该脱节的Checkout"
#: lib/choose_rev.tcl:60
msgid "Revision Expression:"
-msgstr ""
+msgstr "版本表达å¼:"
#: lib/choose_rev.tcl:74
-#, fuzzy
msgid "Local Branch"
-msgstr "分支"
+msgstr "本地分支"
#: lib/choose_rev.tcl:79
-#, fuzzy
msgid "Tracking Branch"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "跟踪分支:"
-#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:537
+#: lib/choose_rev.tcl:84 lib/choose_rev.tcl:538
msgid "Tag"
-msgstr ""
+msgstr "标签"
#: lib/choose_rev.tcl:317
#, tcl-format
msgid "Invalid revision: %s"
-msgstr ""
+msgstr "无效版本: %s"
#: lib/choose_rev.tcl:338
msgid "No revision selected."
-msgstr ""
+msgstr "没有选择版本."
#: lib/choose_rev.tcl:346
msgid "Revision expression is empty."
-msgstr ""
+msgstr "版本表达å¼ä¸ºç©º."
-#: lib/choose_rev.tcl:530
+#: lib/choose_rev.tcl:531
msgid "Updated"
-msgstr ""
+msgstr "已更新"
-#: lib/choose_rev.tcl:558
+#: lib/choose_rev.tcl:559
msgid "URL"
-msgstr ""
+msgstr "URL"
#: lib/commit.tcl:9
msgid ""
@@ -1138,6 +1184,9 @@ msgid ""
"You are about to create the initial commit. There is no commit before this "
"to amend.\n"
msgstr ""
+"没有改动需è¦ä¿®æ­£.\n"
+"\n"
+"你正在创建最åˆçš„æ交. 在此之å‰æ²¡æœ‰æ交å¯ä»¥ä¿®æ­£.\n"
#: lib/commit.tcl:18
msgid ""
@@ -1147,18 +1196,22 @@ msgid ""
"completed. You cannot amend the prior commit unless you first abort the "
"current merge activity.\n"
msgstr ""
+"在åˆå¹¶æ—¶æ— æ³•ä¿®æ­£.\n"
+"\n"
+"你当å‰æ­£åœ¨ä¸€æ¬¡å°šæœªå®Œæˆçš„åˆå¹¶æ“作过程中. 除éžä¸­æ­¢å½“å‰åˆå¹¶æ´»åŠ¨,\n"
+"å¦åˆ™æ— æ³•ä¿®æ­£ä¹‹å‰çš„æ交.\n"
#: lib/commit.tcl:49
msgid "Error loading commit data for amend:"
-msgstr ""
+msgstr "为修正装载æ交数æ®å‡ºé”™:"
#: lib/commit.tcl:76
msgid "Unable to obtain your identity:"
-msgstr ""
+msgstr "无法获知你的身份:"
#: lib/commit.tcl:81
msgid "Invalid GIT_COMMITTER_IDENT:"
-msgstr ""
+msgstr "无效的 GIT_COMMITTER_IDENT"
#: lib/commit.tcl:133
msgid ""
@@ -1169,6 +1222,12 @@ msgid ""
"\n"
"The rescan will be automatically started now.\n"
msgstr ""
+"最åŽä¸€æ¬¡æ‰«æ的状æ€å’Œå½“å‰ç‰ˆæœ¬åº“状æ€ä¸ç¬¦.\n"
+"\n"
+"å¦ä¸€ Git 程åºè‡ªä¸Šæ¬¡æ‰«æåŽä¿®æ”¹äº†æœ¬ç‰ˆæœ¬åº“. 在修改当å‰åˆ†æ”¯ä¹‹å‰éœ€è¦é‡æ–°åšä¸€æ¬¡æ‰«"
+"æ.\n"
+"\n"
+"é‡æ–°æ‰«æ将自动开始.\n"
#: lib/commit.tcl:154
#, tcl-format
@@ -1178,6 +1237,9 @@ msgid ""
"File %s has merge conflicts. You must resolve them and stage the file "
"before committing.\n"
msgstr ""
+"尚未åˆå¹¶çš„文件没有办法æ交.\n"
+"\n"
+"文件 %s 有åˆå¹¶å†²çª, 你必须解决这些冲çªå¹¶ç¼“存该文件作æ交.\n"
#: lib/commit.tcl:162
#, tcl-format
@@ -1186,6 +1248,9 @@ msgid ""
"\n"
"File %s cannot be committed by this program.\n"
msgstr ""
+"æ£€æµ‹åˆ°æœªçŸ¥æ–‡ä»¶çŠ¶æ€ %s.\n"
+"\n"
+"文件 %s 无法由该程åºæ交.\n"
#: lib/commit.tcl:170
msgid ""
@@ -1193,6 +1258,9 @@ msgid ""
"\n"
"You must stage at least 1 file before you can commit.\n"
msgstr ""
+"没有需è¦æ交的å˜åŠ¨.\n"
+"\n"
+"æ交å‰ä½ å¿…须首先缓存至少一个文件.\n"
#: lib/commit.tcl:183
msgid ""
@@ -1200,21 +1268,58 @@ msgid ""
"\n"
"A good commit message has the following format:\n"
"\n"
-"- First line: Describe in one sentance what you did.\n"
+"- First line: Describe in one sentence what you did.\n"
"- Second line: Blank\n"
"- Remaining lines: Describe why this change is good.\n"
msgstr ""
+"请æ供一æ¡æ交信æ¯.\n"
+"\n"
+"一æ¡å¥½çš„æ交信æ¯æœ‰ä¸‹åˆ—æ ¼å¼:\n"
+"\n"
+"- 第一行: 一å¥è¯æ¦‚括你åšçš„修改.\n"
+"- 第二行: 空行\n"
+"- 剩余行: 请æ述为什么你åšçš„这些改动是好的.\n"
-#: lib/commit.tcl:257
-msgid "write-tree failed:"
+#: lib/commit.tcl:207
+#, tcl-format
+msgid "warning: Tcl does not support encoding '%s'."
+msgstr "警告: Tcl ä¸æ”¯æŒç¼–ç æ–¹å¼ '%s'."
+
+#: lib/commit.tcl:221
+msgid "Calling pre-commit hook..."
+msgstr ""
+
+#: lib/commit.tcl:236
+msgid "Commit declined by pre-commit hook."
+msgstr ""
+
+#: lib/commit.tcl:259
+msgid "Calling commit-msg hook..."
+msgstr ""
+
+#: lib/commit.tcl:274
+msgid "Commit declined by commit-msg hook."
msgstr ""
-#: lib/commit.tcl:275
+#: lib/commit.tcl:287
+msgid "Committing changes..."
+msgstr ""
+
+#: lib/commit.tcl:303
+msgid "write-tree failed:"
+msgstr "write-tree 失败:"
+
+#: lib/commit.tcl:304 lib/commit.tcl:348 lib/commit.tcl:368
+#, fuzzy
+msgid "Commit failed."
+msgstr "克隆失败."
+
+#: lib/commit.tcl:321
#, tcl-format
msgid "Commit %s appears to be corrupt"
-msgstr ""
+msgstr "æ交 %s 似乎已æŸå"
-#: lib/commit.tcl:279
+#: lib/commit.tcl:326
msgid ""
"No changes to commit.\n"
"\n"
@@ -1222,77 +1327,76 @@ msgid ""
"\n"
"A rescan will be automatically started now.\n"
msgstr ""
+"没有改动æ交.\n"
+"\n"
+"该æ交没有改动任何文件也ä¸æ˜¯ä¸€ä¸ªåˆå¹¶æ交.\n"
+"\n"
+"é‡æ–°æ‰«æ将自动开始.\n"
-#: lib/commit.tcl:286
+#: lib/commit.tcl:333
msgid "No changes to commit."
-msgstr ""
-
-#: lib/commit.tcl:303
-#, tcl-format
-msgid "warning: Tcl does not support encoding '%s'."
-msgstr ""
+msgstr "没有改动è¦æ交."
-#: lib/commit.tcl:317
+#: lib/commit.tcl:347
msgid "commit-tree failed:"
-msgstr ""
+msgstr "commit-tree 失败:"
-#: lib/commit.tcl:339
+#: lib/commit.tcl:367
msgid "update-ref failed:"
-msgstr ""
+msgstr "update-ref 失败:"
-#: lib/commit.tcl:430
+#: lib/commit.tcl:454
#, tcl-format
msgid "Created commit %s: %s"
-msgstr ""
+msgstr "创建了 commit %s: %s"
-#: lib/console.tcl:57
+#: lib/console.tcl:59
msgid "Working... please wait..."
-msgstr ""
+msgstr "工作中... 请等待..."
-#: lib/console.tcl:183
+#: lib/console.tcl:186
msgid "Success"
-msgstr ""
+msgstr "æˆåŠŸ"
-#: lib/console.tcl:196
+#: lib/console.tcl:200
msgid "Error: Command Failed"
-msgstr ""
+msgstr "错误: 命令失败"
#: lib/database.tcl:43
msgid "Number of loose objects"
-msgstr ""
+msgstr "æ¾æ•£å¯¹è±¡çš„æ•°é‡"
#: lib/database.tcl:44
msgid "Disk space used by loose objects"
-msgstr ""
+msgstr "æ¾æ•£å¯¹è±¡æ‰€ä½¿ç”¨çš„ç£ç›˜ç©ºé—´"
#: lib/database.tcl:45
msgid "Number of packed objects"
-msgstr ""
+msgstr "压缩对象数é‡"
#: lib/database.tcl:46
msgid "Number of packs"
-msgstr ""
+msgstr "压缩包数é‡"
#: lib/database.tcl:47
msgid "Disk space used by packed objects"
-msgstr ""
+msgstr "压缩对象所使用的ç£ç›˜ç©ºé—´"
#: lib/database.tcl:48
msgid "Packed objects waiting for pruning"
-msgstr ""
+msgstr "压缩对象等待清ç†"
#: lib/database.tcl:49
msgid "Garbage files"
-msgstr ""
+msgstr "垃圾文件"
#: lib/database.tcl:72
-#, fuzzy
msgid "Compressing the object database"
-msgstr "压缩数æ®åº“"
+msgstr "压缩对象数æ®åº“"
#: lib/database.tcl:83
msgid "Verifying the object database with fsck-objects"
-msgstr ""
+msgstr "使用 fsck-objects 验è¯å¯¹è±¡æ•°æ®åº“"
#: lib/database.tcl:108
#, tcl-format
@@ -1304,11 +1408,16 @@ msgid ""
"\n"
"Compress the database now?"
msgstr ""
+"该版本库当å‰çº¦æœ‰ %i 个æ¾æ•£å¯¹è±¡.\n"
+"\n"
+"为达到较优的性能,强烈建议你在æ¾æ•£å¯¹è±¡å¤šäºŽ %i 时压缩数æ®åº“.\n"
+"\n"
+"现在就压缩数æ®åº“么?"
#: lib/date.tcl:25
#, tcl-format
msgid "Invalid date from Git: %s"
-msgstr ""
+msgstr "无效的日期: %s"
#: lib/diff.tcl:42
#, tcl-format
@@ -1323,80 +1432,112 @@ msgid ""
"A rescan will be automatically started to find other files which may have "
"the same state."
msgstr ""
+"未检测到改动.\n"
+"\n"
+"该文件的修改日期被å¦ä¸€ä¸ªç¨‹åºæ‰€æ›´æ–°, 但其内容并没有å˜åŒ–.\n"
+"\n"
+"对于类似情况的其他文件的é‡æ–°æ‰«æ将自动开始."
#: lib/diff.tcl:81
-#, tcl-format
+#, fuzzy, tcl-format
msgid "Loading diff of %s..."
-msgstr ""
+msgstr "装载 %s 的 diff ..."
#: lib/diff.tcl:114 lib/diff.tcl:184
#, tcl-format
msgid "Unable to display %s"
-msgstr ""
+msgstr "无法显示 %s"
#: lib/diff.tcl:115
msgid "Error loading file:"
-msgstr ""
+msgstr "装载文件出错:"
#: lib/diff.tcl:122
msgid "Git Repository (subproject)"
-msgstr ""
+msgstr "Git 版本库 (å­é¡¹ç›®)"
#: lib/diff.tcl:134
msgid "* Binary file (not showing content)."
-msgstr ""
+msgstr "* 二进制文件 (ä¸æ˜¾ç¤ºå†…容)."
#: lib/diff.tcl:185
msgid "Error loading diff:"
-msgstr ""
+msgstr "装载 diff 错误:"
-#: lib/diff.tcl:302
+#: lib/diff.tcl:303
msgid "Failed to unstage selected hunk."
-msgstr ""
+msgstr "无法将选择的代ç æ®µä»Žç¼“存中删除."
-#: lib/diff.tcl:309
+#: lib/diff.tcl:310
msgid "Failed to stage selected hunk."
-msgstr ""
+msgstr "无法缓存所选代ç æ®µ."
-#: lib/error.tcl:12 lib/error.tcl:102
+#: lib/error.tcl:20 lib/error.tcl:114
msgid "error"
-msgstr ""
+msgstr "错误"
-#: lib/error.tcl:28
+#: lib/error.tcl:36
msgid "warning"
-msgstr ""
+msgstr "警告"
-#: lib/error.tcl:81
+#: lib/error.tcl:94
msgid "You must correct the above errors before committing."
-msgstr ""
+msgstr "你必须在æ交å‰ä¿®æ­£ä¸Šè¿°é”™è¯¯."
-#: lib/index.tcl:241
-#, fuzzy, tcl-format
+#: lib/index.tcl:6
+msgid "Unable to unlock the index."
+msgstr "无法解é”缓存 (index)"
+
+#: lib/index.tcl:15
+msgid "Index Error"
+msgstr "缓存(Index)错误"
+
+#: lib/index.tcl:21
+msgid ""
+"Updating the Git index failed. A rescan will be automatically started to "
+"resynchronize git-gui."
+msgstr "æ›´æ–° Git 缓存(Index)失败, é‡æ–°æ‰«æ将自动开始以é‡æ–°åŒæ­¥ git-gui."
+
+#: lib/index.tcl:27
+msgid "Continue"
+msgstr "继续"
+
+#: lib/index.tcl:31
+msgid "Unlock Index"
+msgstr "è§£é” Index"
+
+#: lib/index.tcl:282
+#, tcl-format
msgid "Unstaging %s from commit"
-msgstr "从本次æ交移除"
+msgstr "从æ交缓存中删除 %s"
-#: lib/index.tcl:285
+#: lib/index.tcl:313
+#, fuzzy
+msgid "Ready to commit."
+msgstr "缓存为æ交"
+
+#: lib/index.tcl:326
#, tcl-format
msgid "Adding %s"
-msgstr ""
+msgstr "添加 %s"
-#: lib/index.tcl:340
-#, fuzzy, tcl-format
+#: lib/index.tcl:381
+#, tcl-format
msgid "Revert changes in file %s?"
-msgstr "æ¢å¤ä¿®æ”¹"
+msgstr "撤销文件 %s 中的改动?"
-#: lib/index.tcl:342
+#: lib/index.tcl:383
#, tcl-format
msgid "Revert changes in these %i files?"
-msgstr ""
+msgstr "撤销这些 (%i个) 文件的改动?"
-#: lib/index.tcl:348
+#: lib/index.tcl:391
msgid "Any unstaged changes will be permanently lost by the revert."
-msgstr ""
+msgstr "任何未缓存的改动将在这次撤销中永久丢失."
-#: lib/index.tcl:351
+#: lib/index.tcl:394
msgid "Do Nothing"
-msgstr ""
+msgstr "ä¸åšæ“作"
#: lib/merge.tcl:13
msgid ""
@@ -1404,6 +1545,9 @@ msgid ""
"\n"
"You must finish amending this commit before starting any type of merge.\n"
msgstr ""
+"修正时无法åšåˆå¹¶.\n"
+"\n"
+"你必须完æˆå¯¹è¯¥æ交的修正æ‰èƒ½ç»§ç»­ä»»ä½•ç±»åž‹çš„åˆå¹¶æ“作.\n"
#: lib/merge.tcl:27
msgid ""
@@ -1414,6 +1558,12 @@ msgid ""
"\n"
"The rescan will be automatically started now.\n"
msgstr ""
+"最åŽä¸€æ¬¡æ‰«æ的状æ€å’Œå½“å‰ç‰ˆæœ¬åº“状æ€ä¸ç¬¦.\n"
+"\n"
+"å¦ä¸€ Git 程åºè‡ªä¸Šæ¬¡æ‰«æåŽä¿®æ”¹äº†æœ¬ç‰ˆæœ¬åº“. 在修改当å‰åˆ†æ”¯ä¹‹å‰éœ€è¦é‡æ–°åšä¸€æ¬¡æ‰«"
+"æ.\n"
+"\n"
+"é‡æ–°æ‰«æ将自动开始.\n"
#: lib/merge.tcl:44
#, tcl-format
@@ -1425,6 +1575,12 @@ msgid ""
"You must resolve them, stage the file, and commit to complete the current "
"merge. Only then can you begin another merge.\n"
msgstr ""
+"你正处在一个有冲çªçš„åˆå¹¶æ“作中.\n"
+"\n"
+"文件 %s 有åˆå¹¶å†²çª.\n"
+"\n"
+"你必须解决这些冲çª, 缓存该文件, 并æ交æ¥å®Œæˆå½“å‰çš„åˆå¹¶.仅当这样åŽæ‰èƒ½å¼€å§‹ä¸‹ä¸€"
+"个åˆå¹¶æ“作.\n"
#: lib/merge.tcl:54
#, tcl-format
@@ -1436,6 +1592,12 @@ msgid ""
"You should complete the current commit before starting a merge. Doing so "
"will help you abort a failed merge, should the need arise.\n"
msgstr ""
+"你正处在一个改动当中.\n"
+"\n"
+"文件 %s 已被修改.\n"
+"\n"
+"你必须完æˆå½“å‰çš„æ交åŽæ‰èƒ½å¼€å§‹åˆå¹¶. 如果需è¦, 这么åšå°†æœ‰åŠ©äºŽä¸­æ­¢ä¸€æ¬¡å¤±è´¥çš„åˆ"
+"并.\n"
#: lib/merge.tcl:106
#, tcl-format
@@ -1443,35 +1605,38 @@ msgid "%s of %s"
msgstr ""
#: lib/merge.tcl:119
-#, tcl-format
-msgid "Merging %s and %s"
-msgstr ""
+#, fuzzy, tcl-format
+msgid "Merging %s and %s..."
+msgstr "åˆå¹¶ %s å’Œ %s"
-#: lib/merge.tcl:131
+#: lib/merge.tcl:130
msgid "Merge completed successfully."
-msgstr ""
+msgstr "åˆå¹¶æˆåŠŸå®Œæˆ."
-#: lib/merge.tcl:133
+#: lib/merge.tcl:132
msgid "Merge failed. Conflict resolution is required."
-msgstr ""
+msgstr "åˆå¹¶å¤±è´¥. 需è¦è§£å†³å†²çª."
-#: lib/merge.tcl:158
+#: lib/merge.tcl:157
#, tcl-format
msgid "Merge Into %s"
-msgstr ""
+msgstr "åˆå¹¶åˆ° %s"
-#: lib/merge.tcl:177
+#: lib/merge.tcl:176
msgid "Revision To Merge"
-msgstr ""
+msgstr "è¦åˆå¹¶çš„版本"
-#: lib/merge.tcl:212
+#: lib/merge.tcl:211
msgid ""
"Cannot abort while amending.\n"
"\n"
"You must finish amending this commit.\n"
msgstr ""
+"修正æ“作中无法中止.\n"
+"\n"
+"你必须先完æˆæœ¬æ¬¡ä¿®æ­£æ“作.\n"
-#: lib/merge.tcl:222
+#: lib/merge.tcl:221
msgid ""
"Abort merge?\n"
"\n"
@@ -1479,8 +1644,13 @@ msgid ""
"\n"
"Continue with aborting the current merge?"
msgstr ""
+"中止åˆå¹¶?\n"
+"\n"
+"中止当å‰çš„åˆå¹¶æ“作将导致 *所有* 尚未æ交的改动丢失.\n"
+"\n"
+"是å¦è¦ç»§ç»­ä¸­æ­¢å½“å‰çš„åˆå¹¶æ“作?"
-#: lib/merge.tcl:228
+#: lib/merge.tcl:227
msgid ""
"Reset changes?\n"
"\n"
@@ -1488,150 +1658,151 @@ msgid ""
"\n"
"Continue with resetting the current changes?"
msgstr ""
+"是å¦å¤ä½å½“å‰æ”¹åŠ¨?\n"
+"\n"
+"å¤ä½å½“å‰çš„改动将导致 *所有* 未æ交的改动丢失.\n"
+"\n"
+"是å¦è¦ç»§ç»­å¤ä½å½“å‰çš„改动?"
-#: lib/merge.tcl:239
+#: lib/merge.tcl:238
msgid "Aborting"
-msgstr ""
+msgstr "中止"
+
+#: lib/merge.tcl:238
+#, fuzzy
+msgid "files reset"
+msgstr "文件"
-#: lib/merge.tcl:266
+#: lib/merge.tcl:265
msgid "Abort failed."
-msgstr ""
+msgstr "中止失败"
-#: lib/merge.tcl:268
+#: lib/merge.tcl:267
msgid "Abort completed. Ready."
-msgstr ""
+msgstr "中止完æˆ. 就绪."
-#: lib/option.tcl:82
+#: lib/option.tcl:95
msgid "Restore Defaults"
-msgstr ""
+msgstr "æ¢å¤é»˜è®¤å€¼"
-#: lib/option.tcl:86
+#: lib/option.tcl:99
msgid "Save"
-msgstr ""
+msgstr "ä¿å­˜"
-#: lib/option.tcl:96
-#, fuzzy, tcl-format
+#: lib/option.tcl:109
+#, tcl-format
msgid "%s Repository"
-msgstr "版本树"
+msgstr "%s 版本库"
-#: lib/option.tcl:97
+#: lib/option.tcl:110
msgid "Global (All Repositories)"
-msgstr ""
+msgstr "全局 (所有版本库)"
-#: lib/option.tcl:103
+#: lib/option.tcl:116
msgid "User Name"
-msgstr ""
+msgstr "用户å"
-#: lib/option.tcl:104
+#: lib/option.tcl:117
msgid "Email Address"
-msgstr ""
+msgstr "Email 地å€"
-#: lib/option.tcl:106
-#, fuzzy
+#: lib/option.tcl:119
msgid "Summarize Merge Commits"
-msgstr "修订åˆå¹¶æ交æè¿°:"
+msgstr "概述åˆå¹¶æ交:"
-#: lib/option.tcl:107
+#: lib/option.tcl:120
msgid "Merge Verbosity"
-msgstr ""
+msgstr "åˆå¹¶å†—余度"
-#: lib/option.tcl:108
+#: lib/option.tcl:121
msgid "Show Diffstat After Merge"
-msgstr ""
+msgstr "在åˆå¹¶åŽæ˜¾ç¤º Diffstat"
-#: lib/option.tcl:110
+#: lib/option.tcl:123
msgid "Trust File Modification Timestamps"
-msgstr ""
+msgstr "相信文件的改动时间"
-#: lib/option.tcl:111
+#: lib/option.tcl:124
msgid "Prune Tracking Branches During Fetch"
-msgstr ""
+msgstr "获å–时清除跟踪分支"
-#: lib/option.tcl:112
+#: lib/option.tcl:125
msgid "Match Tracking Branches"
-msgstr ""
+msgstr "匹é…跟踪分支"
-#: lib/option.tcl:113
+#: lib/option.tcl:126
msgid "Number of Diff Context Lines"
-msgstr ""
+msgstr "Diff 上下文行数"
+
+#: lib/option.tcl:127
+#, fuzzy
+msgid "Commit Message Text Width"
+msgstr "æ交æè¿°:"
-#: lib/option.tcl:114
+#: lib/option.tcl:128
msgid "New Branch Name Template"
+msgstr "新建分支命å模æ¿"
+
+#: lib/option.tcl:192
+msgid "Spelling Dictionary:"
msgstr ""
-#: lib/option.tcl:176
+#: lib/option.tcl:216
msgid "Change Font"
-msgstr ""
+msgstr "更改字体"
-#: lib/option.tcl:180
+#: lib/option.tcl:220
#, tcl-format
msgid "Choose %s"
-msgstr ""
+msgstr "选择 %s"
-#: lib/option.tcl:186
+#: lib/option.tcl:226
msgid "pt."
-msgstr ""
+msgstr "磅"
-#: lib/option.tcl:200
+#: lib/option.tcl:240
msgid "Preferences"
-msgstr ""
+msgstr "首选项"
-#: lib/option.tcl:235
+#: lib/option.tcl:275
msgid "Failed to completely save options:"
-msgstr ""
-
-#: lib/remote.tcl:165
-msgid "Prune from"
-msgstr ""
-
-#: lib/remote.tcl:170
-#, fuzzy
-msgid "Fetch from"
-msgstr "导入"
-
-#: lib/remote.tcl:213
-#, fuzzy
-msgid "Push to"
-msgstr "上传"
+msgstr "无法完全ä¿å­˜é€‰é¡¹:"
#: lib/remote_branch_delete.tcl:29 lib/remote_branch_delete.tcl:34
msgid "Delete Remote Branch"
-msgstr ""
+msgstr "删除远端分支"
#: lib/remote_branch_delete.tcl:47
-#, fuzzy
msgid "From Repository"
-msgstr "版本树"
+msgstr "从版本库"
#: lib/remote_branch_delete.tcl:50 lib/transport.tcl:123
msgid "Remote:"
-msgstr ""
+msgstr "Remote:"
#: lib/remote_branch_delete.tcl:66 lib/transport.tcl:138
msgid "Arbitrary URL:"
-msgstr ""
+msgstr "ä»»æ„ URL:"
#: lib/remote_branch_delete.tcl:84
-#, fuzzy
msgid "Branches"
msgstr "分支"
#: lib/remote_branch_delete.tcl:109
-#, fuzzy
msgid "Delete Only If"
-msgstr "删除"
+msgstr "删除仅当"
#: lib/remote_branch_delete.tcl:111
msgid "Merged Into:"
-msgstr ""
+msgstr "åˆå¹¶åˆ°"
#: lib/remote_branch_delete.tcl:119
msgid "Always (Do not perform merge checks)"
-msgstr ""
+msgstr "总是åˆå¹¶ (ä¸ä½œåˆå¹¶æ£€æŸ¥)"
#: lib/remote_branch_delete.tcl:152
msgid "A branch is required for 'Merged Into'."
-msgstr ""
+msgstr "'åˆå¹¶åˆ°' 需è¦æŒ‡å®šæŸä¸ªåˆ†æ”¯"
#: lib/remote_branch_delete.tcl:184
#, tcl-format
@@ -1640,6 +1811,9 @@ msgid ""
"\n"
" - %s"
msgstr ""
+"下列分支没有被全部åˆå¹¶åˆ° %s 中:\n"
+"\n"
+" - %s"
#: lib/remote_branch_delete.tcl:189
#, tcl-format
@@ -1647,10 +1821,11 @@ msgid ""
"One or more of the merge tests failed because you have not fetched the "
"necessary commits. Try fetching from %s first."
msgstr ""
+"由于没有获å–到必è¦çš„æ交,一个或多个åˆå¹¶æµ‹è¯•å¤±è´¥ã€‚请å°è¯•ä»Ž %s 处先获å–。"
#: lib/remote_branch_delete.tcl:207
msgid "Please select one or more branches to delete."
-msgstr ""
+msgstr "请选择æŸä¸ªæˆ–多个分支æ¥åˆ é™¤"
#: lib/remote_branch_delete.tcl:216
msgid ""
@@ -1658,112 +1833,145 @@ msgid ""
"\n"
"Delete the selected branches?"
msgstr ""
+"æ¢å¤è¢«åˆ é™¤çš„分支éžå¸¸å›°éš¾.\n"
+"\n"
+"是å¦è¦åˆ é™¤æ‰€é€‰åˆ†æ”¯?"
#: lib/remote_branch_delete.tcl:226
#, tcl-format
msgid "Deleting branches from %s"
-msgstr ""
+msgstr "从 %s 中删除分支"
#: lib/remote_branch_delete.tcl:286
msgid "No repository selected."
-msgstr ""
+msgstr "没有选择版本库"
#: lib/remote_branch_delete.tcl:291
#, tcl-format
msgid "Scanning %s..."
+msgstr "正在扫æ %s..."
+
+#: lib/remote.tcl:165
+msgid "Prune from"
+msgstr "从..清除(prune)"
+
+#: lib/remote.tcl:170
+msgid "Fetch from"
+msgstr "从..获å–(fetch)"
+
+#: lib/remote.tcl:213
+msgid "Push to"
+msgstr "上传到(push)"
+
+#: lib/shortcut.tcl:20 lib/shortcut.tcl:61
+msgid "Cannot write shortcut:"
+msgstr "无法修改快æ·æ–¹å¼:"
+
+#: lib/shortcut.tcl:136
+msgid "Cannot write icon:"
+msgstr "无法修改图标:"
+
+#: lib/spellcheck.tcl:57
+msgid "Unsupported spell checker"
msgstr ""
-#: lib/shortcut.tcl:26 lib/shortcut.tcl:74
-msgid "Cannot write script:"
+#: lib/spellcheck.tcl:65
+msgid "Spell checking is unavailable"
msgstr ""
-#: lib/shortcut.tcl:149
-msgid "Cannot write icon:"
+#: lib/spellcheck.tcl:68
+msgid "Invalid spell checking configuration"
+msgstr ""
+
+#: lib/spellcheck.tcl:70
+#, tcl-format
+msgid "Reverting dictionary to %s."
+msgstr ""
+
+#: lib/spellcheck.tcl:73
+msgid "Spell checker silently failed on startup"
+msgstr ""
+
+#: lib/spellcheck.tcl:80
+msgid "Unrecognized spell checker"
+msgstr ""
+
+#: lib/spellcheck.tcl:180
+msgid "No Suggestions"
+msgstr ""
+
+#: lib/spellcheck.tcl:381
+msgid "Unexpected EOF from spell checker"
+msgstr ""
+
+#: lib/spellcheck.tcl:385
+msgid "Spell Checker Failed"
msgstr ""
#: lib/status_bar.tcl:83
#, tcl-format
msgid "%s ... %*i of %*i %s (%3i%%)"
-msgstr ""
+msgstr "%s ... %*i of %*i %s (%3i%%)"
#: lib/transport.tcl:6
-#, fuzzy, tcl-format
+#, tcl-format
msgid "fetch %s"
-msgstr "导入"
+msgstr "获å–(fetch)"
#: lib/transport.tcl:7
#, tcl-format
msgid "Fetching new changes from %s"
-msgstr ""
+msgstr "从 %s 处获å–新的改动"
#: lib/transport.tcl:18
#, tcl-format
msgid "remote prune %s"
-msgstr ""
+msgstr "清除远端 %s"
#: lib/transport.tcl:19
#, tcl-format
msgid "Pruning tracking branches deleted from %s"
-msgstr ""
+msgstr "清除"
#: lib/transport.tcl:25 lib/transport.tcl:71
#, tcl-format
msgid "push %s"
-msgstr ""
+msgstr "上传 %s"
#: lib/transport.tcl:26
#, tcl-format
msgid "Pushing changes to %s"
-msgstr ""
+msgstr "上传改动到 %s"
#: lib/transport.tcl:72
#, tcl-format
msgid "Pushing %s %s to %s"
-msgstr ""
+msgstr "上传 %s %s 到 %s"
#: lib/transport.tcl:89
-#, fuzzy
msgid "Push Branches"
-msgstr "分支"
+msgstr "上传分支"
#: lib/transport.tcl:103
-#, fuzzy
msgid "Source Branches"
-msgstr "当å‰åˆ†æ”¯:"
+msgstr "æºç«¯åˆ†æ”¯:"
#: lib/transport.tcl:120
-#, fuzzy
msgid "Destination Repository"
-msgstr "版本树"
+msgstr "目标版本库"
#: lib/transport.tcl:158
msgid "Transfer Options"
-msgstr ""
+msgstr "传输选项"
#: lib/transport.tcl:160
msgid "Force overwrite existing branch (may discard changes)"
-msgstr ""
+msgstr "强制覆盖已有的分支 (å¯èƒ½ä¼šä¸¢å¤±æ”¹åŠ¨)"
#: lib/transport.tcl:164
msgid "Use thin pack (for slow network connections)"
-msgstr ""
+msgstr "使用 thin pack (适用于低速网络连接)"
#: lib/transport.tcl:168
msgid "Include tags"
-msgstr ""
-
-#~ msgid "Add To Commit"
-#~ msgstr "添加到本次æ交"
-
-#~ msgid "Add Existing To Commit"
-#~ msgstr "添加默认修改文件"
-
-#~ msgid "Unstaged Changes (Will Not Be Committed)"
-#~ msgstr "ä¸è¢«æ交的修改"
-
-#~ msgid "Add Existing"
-#~ msgstr "添加默认修改文件"
-
-#, fuzzy
-#~ msgid "Push to %s..."
-#~ msgstr "上传..."
+msgstr "包å«æ ‡ç­¾"
diff --git a/git-gui/windows/git-gui.sh b/git-gui/windows/git-gui.sh
index 98f32c0a0..53c3a9468 100644
--- a/git-gui/windows/git-gui.sh
+++ b/git-gui/windows/git-gui.sh
@@ -8,9 +8,12 @@ if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
incr argc -2
}
-set gitguidir [file dirname [info script]]
-regsub -all ";" $gitguidir "\\;" gitguidir
-set env(PATH) "$gitguidir;$env(PATH)"
-unset gitguidir
+set bindir [file dirname \
+ [file dirname \
+ [file dirname [info script]]]]
+set bindir [file join $bindir bin]
+regsub -all ";" $bindir "\\;" bindir
+set env(PATH) "$bindir;$env(PATH)"
+unset bindir
source [file join [file dirname [info script]] git-gui.tcl]
diff --git a/git-instaweb.sh b/git-instaweb.sh
index ad0723ccc..0843372b5 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -6,7 +6,7 @@
PERL='@@PERL@@'
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
-git-instaweb [options] (--start | --stop | --restart)
+git instaweb [options] (--start | --stop | --restart)
--
l,local only bind on 127.0.0.1
p,port= the port to bind to
@@ -22,12 +22,10 @@ restart restart the web server
. git-sh-setup
fqgitdir="$GIT_DIR"
-local="`git config --bool --get instaweb.local`"
-httpd="`git config --get instaweb.httpd`"
-browser="`git config --get instaweb.browser`"
-test -z "$browser" && browser="`git config --get web.browser`"
-port=`git config --get instaweb.port`
-module_path="`git config --get instaweb.modulepath`"
+local="$(git config --bool --get instaweb.local)"
+httpd="$(git config --get instaweb.httpd)"
+port=$(git config --get instaweb.port)
+module_path="$(git config --get instaweb.modulepath)"
conf="$GIT_DIR/gitweb/httpd.conf"
@@ -36,17 +34,24 @@ conf="$GIT_DIR/gitweb/httpd.conf"
# if installed, it doesn't need further configuration (module_path)
test -z "$httpd" && httpd='lighttpd -f'
-# probably the most popular browser among gitweb users
-test -z "$browser" && browser='firefox'
-
# any untaken local port will do...
test -z "$port" && port=1234
-start_httpd () {
- httpd_only="`echo $httpd | cut -f1 -d' '`"
+resolve_full_httpd () {
+ case "$httpd" in
+ *apache2*|*lighttpd*)
+ # ensure that the apache2/lighttpd command ends with "-f"
+ if ! echo "$httpd" | grep -- '-f *$' >/dev/null 2>&1
+ then
+ httpd="$httpd -f"
+ fi
+ ;;
+ esac
+
+ httpd_only="$(echo $httpd | cut -f1 -d' ')"
if case "$httpd_only" in /*) : ;; *) which $httpd_only >/dev/null;; esac
then
- $httpd "$fqgitdir/gitweb/httpd.conf"
+ full_httpd=$httpd
else
# many httpds are installed in /usr/sbin or /usr/local/sbin
# these days and those are not in most users $PATHs
@@ -56,16 +61,23 @@ start_httpd () {
do
if test -x "$i/$httpd_only"
then
- # don't quote $httpd, there can be
- # arguments to it (-f)
- $i/$httpd "$fqgitdir/gitweb/httpd.conf"
+ full_httpd=$i/$httpd
return
fi
done
- echo "$httpd_only not found. Install $httpd_only or use" \
- "--httpd to specify another http daemon."
+
+ echo >&2 "$httpd_only not found. Install $httpd_only or use" \
+ "--httpd to specify another httpd daemon."
exit 1
fi
+}
+
+start_httpd () {
+ # here $httpd should have a meaningful value
+ resolve_full_httpd
+
+ # don't quote $full_httpd, there can be arguments to it (-f)
+ $full_httpd "$fqgitdir/gitweb/httpd.conf"
if test $? != 0; then
echo "Could not execute http daemon $httpd."
exit 1
@@ -73,7 +85,7 @@ start_httpd () {
}
stop_httpd () {
- test -f "$fqgitdir/pid" && kill `cat "$fqgitdir/pid"`
+ test -f "$fqgitdir/pid" && kill $(cat "$fqgitdir/pid")
}
while test $# != 0
@@ -121,7 +133,7 @@ do
done
mkdir -p "$GIT_DIR/gitweb/tmp"
-GIT_EXEC_PATH="`git --exec-path`"
+GIT_EXEC_PATH="$(git --exec-path)"
GIT_DIR="$fqgitdir"
export GIT_EXEC_PATH GIT_DIR
@@ -220,7 +232,8 @@ PerlPassEnv GIT_EXEC_DIR
EOF
else
# plain-old CGI
- list_mods=`echo "$httpd" | sed "s/-f$/-l/"`
+ resolve_full_httpd
+ list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
$list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
cat >> "$conf" <<EOF
@@ -276,4 +289,9 @@ esac
start_httpd
url=http://127.0.0.1:$port
-test -n "$browser" && "$browser" $url || echo $url
+
+if test -n "$browser"; then
+ git web--browse -b "$browser" $url || echo $url
+else
+ git web--browse -c "instaweb.browser" $url || echo $url
+fi
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 9ee3f8045..e1eb96326 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -48,10 +48,11 @@ case "${1:-.}${2:-.}${3:-.}" in
;;
"..$3")
echo "Adding $4"
- test -f "$4" || {
+ if test -f "$4"
+ then
echo "ERROR: untracked $4 is overwritten by the merge."
exit 1
- }
+ fi
git update-index --add --cacheinfo "$7" "$3" "$4" &&
exec git checkout-index -u -f -- "$4"
;;
diff --git a/git-merge-stupid.sh b/git-merge-stupid.sh
deleted file mode 100755
index f612d4729..000000000
--- a/git-merge-stupid.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2005 Linus Torvalds
-#
-# Resolve two trees, 'stupid merge'.
-
-# The first parameters up to -- are merge bases; the rest are heads.
-bases= head= remotes= sep_seen=
-for arg
-do
- case ",$sep_seen,$head,$arg," in
- *,--,)
- sep_seen=yes
- ;;
- ,yes,,*)
- head=$arg
- ;;
- ,yes,*)
- remotes="$remotes$arg "
- ;;
- *)
- bases="$bases$arg "
- ;;
- esac
-done
-
-# Give up if we are given two or more remotes -- not handling octopus.
-case "$remotes" in
-?*' '?*)
- exit 2 ;;
-esac
-
-# Find an optimum merge base if there are more than one candidates.
-case "$bases" in
-?*' '?*)
- echo "Trying to find the optimum merge base."
- G=.tmp-index$$
- best=
- best_cnt=-1
- for c in $bases
- do
- rm -f $G
- GIT_INDEX_FILE=$G git read-tree -m $c $head $remotes \
- 2>/dev/null || continue
- # Count the paths that are unmerged.
- cnt=`GIT_INDEX_FILE=$G git ls-files --unmerged | wc -l`
- if test $best_cnt -le 0 -o $cnt -le $best_cnt
- then
- best=$c
- best_cnt=$cnt
- if test "$best_cnt" -eq 0
- then
- # Cannot do any better than all trivial merge.
- break
- fi
- fi
- done
- rm -f $G
- common="$best"
- ;;
-*)
- common="$bases"
- ;;
-esac
-
-git update-index --refresh 2>/dev/null
-git read-tree -u -m $common $head $remotes || exit 2
-echo "Trying simple merge."
-if result_tree=$(git write-tree 2>/dev/null)
-then
- exit 0
-else
- echo "Simple merge failed, trying Automatic merge."
- if git-merge-index -o git-merge-one-file -a
- then
- exit 0
- else
- exit 1
- fi
-fi
diff --git a/git-mergetool.sh b/git-mergetool.sh
index cbbb70795..94187c306 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -34,7 +34,7 @@ base_present () {
cleanup_temp_files () {
if test "$1" = --save-backup ; then
- mv -- "$BACKUP" "$path.orig"
+ mv -- "$BACKUP" "$MERGED.orig"
rm -f -- "$LOCAL" "$REMOTE" "$BASE"
else
rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP"
@@ -67,14 +67,14 @@ resolve_symlink_merge () {
read ans
case "$ans" in
[lL]*)
- git checkout-index -f --stage=2 -- "$path"
- git add -- "$path"
+ git checkout-index -f --stage=2 -- "$MERGED"
+ git add -- "$MERGED"
cleanup_temp_files --save-backup
return
;;
[rR]*)
- git checkout-index -f --stage=3 -- "$path"
- git add -- "$path"
+ git checkout-index -f --stage=3 -- "$MERGED"
+ git add -- "$MERGED"
cleanup_temp_files --save-backup
return
;;
@@ -95,12 +95,12 @@ resolve_deleted_merge () {
read ans
case "$ans" in
[mMcC]*)
- git add -- "$path"
+ git add -- "$MERGED"
cleanup_temp_files --save-backup
return
;;
[dD]*)
- git rm -- "$path" > /dev/null
+ git rm -- "$MERGED" > /dev/null
cleanup_temp_files
return
;;
@@ -112,11 +112,11 @@ resolve_deleted_merge () {
}
check_unchanged () {
- if test "$path" -nt "$BACKUP" ; then
+ if test "$MERGED" -nt "$BACKUP" ; then
status=0;
else
while true; do
- echo "$path seems unchanged."
+ echo "$MERGED seems unchanged."
printf "Was the merge successful? [y/n] "
read answer < /dev/tty
case "$answer" in
@@ -127,50 +127,38 @@ check_unchanged () {
fi
}
-save_backup () {
- if test "$status" -eq 0; then
- mv -- "$BACKUP" "$path.orig"
- fi
-}
-
-remove_backup () {
- if test "$status" -eq 0; then
- rm "$BACKUP"
- fi
-}
-
merge_file () {
- path="$1"
+ MERGED="$1"
- f=`git ls-files -u -- "$path"`
+ f=`git ls-files -u -- "$MERGED"`
if test -z "$f" ; then
- if test ! -f "$path" ; then
- echo "$path: file not found"
+ if test ! -f "$MERGED" ; then
+ echo "$MERGED: file not found"
else
- echo "$path: file does not need merging"
+ echo "$MERGED: file does not need merging"
fi
exit 1
fi
- ext="$$$(expr "$path" : '.*\(\.[^/]*\)$')"
- BACKUP="$path.BACKUP.$ext"
- LOCAL="$path.LOCAL.$ext"
- REMOTE="$path.REMOTE.$ext"
- BASE="$path.BASE.$ext"
+ ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
+ BACKUP="./$MERGED.BACKUP.$ext"
+ LOCAL="./$MERGED.LOCAL.$ext"
+ REMOTE="./$MERGED.REMOTE.$ext"
+ BASE="./$MERGED.BASE.$ext"
- mv -- "$path" "$BACKUP"
- cp -- "$BACKUP" "$path"
+ mv -- "$MERGED" "$BACKUP"
+ cp -- "$BACKUP" "$MERGED"
- base_mode=`git ls-files -u -- "$path" | awk '{if ($3==1) print $1;}'`
- local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
- remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
+ base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
+ local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
+ remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
- base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null
- local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null
- remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null
+ base_present && git cat-file blob ":1:$prefix$MERGED" >"$BASE" 2>/dev/null
+ local_present && git cat-file blob ":2:$prefix$MERGED" >"$LOCAL" 2>/dev/null
+ remote_present && git cat-file blob ":3:$prefix$MERGED" >"$REMOTE" 2>/dev/null
if test -z "$local_mode" -o -z "$remote_mode"; then
- echo "Deleted merge conflict for '$path':"
+ echo "Deleted merge conflict for '$MERGED':"
describe_file "$local_mode" "local" "$LOCAL"
describe_file "$remote_mode" "remote" "$REMOTE"
resolve_deleted_merge
@@ -178,14 +166,14 @@ merge_file () {
fi
if is_symlink "$local_mode" || is_symlink "$remote_mode"; then
- echo "Symbolic link merge conflict for '$path':"
+ echo "Symbolic link merge conflict for '$MERGED':"
describe_file "$local_mode" "local" "$LOCAL"
describe_file "$remote_mode" "remote" "$REMOTE"
resolve_symlink_merge
return
fi
- echo "Normal merge conflict for '$path':"
+ echo "Normal merge conflict for '$MERGED':"
describe_file "$local_mode" "local" "$LOCAL"
describe_file "$remote_mode" "remote" "$REMOTE"
printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
@@ -194,36 +182,32 @@ merge_file () {
case "$merge_tool" in
kdiff3)
if base_present ; then
- ("$merge_tool_path" --auto --L1 "$path (Base)" --L2 "$path (Local)" --L3 "$path (Remote)" \
- -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+ ("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \
+ -o "$MERGED" "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
else
- ("$merge_tool_path" --auto --L1 "$path (Local)" --L2 "$path (Remote)" \
- -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
+ ("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \
+ -o "$MERGED" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
fi
status=$?
- remove_backup
;;
tkdiff)
if base_present ; then
- "$merge_tool_path" -a "$BASE" -o "$path" -- "$LOCAL" "$REMOTE"
+ "$merge_tool_path" -a "$BASE" -o "$MERGED" "$LOCAL" "$REMOTE"
else
- "$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
+ "$merge_tool_path" -o "$MERGED" "$LOCAL" "$REMOTE"
fi
status=$?
- save_backup
;;
meld|vimdiff)
touch "$BACKUP"
- "$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
+ "$merge_tool_path" "$LOCAL" "$MERGED" "$REMOTE"
check_unchanged
- save_backup
;;
gvimdiff)
- touch "$BACKUP"
- "$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE"
- check_unchanged
- save_backup
- ;;
+ touch "$BACKUP"
+ "$merge_tool_path" -f "$LOCAL" "$MERGED" "$REMOTE"
+ check_unchanged
+ ;;
xxdiff)
touch "$BACKUP"
if base_present ; then
@@ -231,53 +215,68 @@ merge_file () {
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$path" -- "$LOCAL" "$BASE" "$REMOTE"
+ --merged-file "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
else
"$merge_tool_path" -X --show-merged-pane \
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
-R 'Accel.Search: "Ctrl+F"' \
-R 'Accel.SearchForward: "Ctrl-G"' \
- --merged-file "$path" -- "$LOCAL" "$REMOTE"
+ --merged-file "$MERGED" "$LOCAL" "$REMOTE"
fi
check_unchanged
- save_backup
;;
opendiff)
touch "$BACKUP"
if base_present; then
- "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$path" | cat
+ "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" | cat
else
- "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
+ "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED" | cat
fi
check_unchanged
- save_backup
;;
ecmerge)
touch "$BACKUP"
if base_present; then
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$path"
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --default --mode=merge3 --to="$MERGED"
else
- "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
+ "$merge_tool_path" "$LOCAL" "$REMOTE" --default --mode=merge2 --to="$MERGED"
fi
check_unchanged
- save_backup
;;
emerge)
if base_present ; then
- "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")"
+ "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
else
- "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
+ "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
fi
status=$?
- save_backup
+ ;;
+ *)
+ if test -n "$merge_tool_cmd"; then
+ if test "$merge_tool_trust_exit_code" = "false"; then
+ touch "$BACKUP"
+ ( eval $merge_tool_cmd )
+ check_unchanged
+ else
+ ( eval $merge_tool_cmd )
+ status=$?
+ fi
+ fi
;;
esac
if test "$status" -ne 0; then
- echo "merge of $path failed" 1>&2
- mv -- "$BACKUP" "$path"
+ echo "merge of $MERGED failed" 1>&2
+ mv -- "$BACKUP" "$MERGED"
exit 1
fi
- git add -- "$path"
+
+ if test "$merge_keep_backup" = "true"; then
+ mv -- "$BACKUP" "$MERGED.orig"
+ else
+ rm -- "$BACKUP"
+ fi
+
+ git add -- "$MERGED"
cleanup_temp_files
}
@@ -309,12 +308,20 @@ do
shift
done
+valid_custom_tool()
+{
+ merge_tool_cmd="$(git config mergetool.$1.cmd)"
+ test -n "$merge_tool_cmd"
+}
+
valid_tool() {
case "$1" in
kdiff3 | tkdiff | xxdiff | meld | opendiff | emerge | vimdiff | gvimdiff | ecmerge)
;; # happy
*)
- return 1
+ if ! valid_custom_tool "$1"; then
+ return 1
+ fi
;;
esac
}
@@ -380,10 +387,16 @@ else
init_merge_tool_path "$merge_tool"
- if ! type "$merge_tool_path" > /dev/null 2>&1; then
+ merge_keep_backup="$(git config --bool merge.keepBackup || echo true)"
+
+ if test -z "$merge_tool_cmd" && ! type "$merge_tool_path" > /dev/null 2>&1; then
echo "The merge tool $merge_tool is not available as '$merge_tool_path'"
exit 1
fi
+
+ if ! test -z "$merge_tool_cmd"; then
+ merge_tool_trust_exit_code="$(git config --bool mergetool.$merge_tool.trustExitCode || echo false)"
+ fi
fi
diff --git a/git-pull.sh b/git-pull.sh
index fa97b0f35..75c36100a 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -4,7 +4,7 @@
#
# Fetch one or more remote refs and merge it/them into the current HEAD.
-USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
+USAGE='[-n | --no-stat] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...'
LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
@@ -16,19 +16,19 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
-strategy_args= no_summary= no_commit= squash= no_ff=
+strategy_args= no_stat= no_commit= squash= no_ff= log_arg=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
rebase=$(git config --bool branch.$curr_branch_short.rebase)
while :
do
case "$1" in
- -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
- --no-summa|--no-summar|--no-summary)
- no_summary=-n ;;
- --summary)
- no_summary=$1
- ;;
+ -n|--no-stat|--no-summary)
+ no_stat=-n ;;
+ --stat|--summary)
+ no_stat=$1 ;;
+ --log|--no-log)
+ log_arg=$1 ;;
--no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit)
no_commit=--no-commit ;;
--c|--co|--com|--comm|--commi|--commit)
@@ -106,8 +106,22 @@ error_on_no_merge_candidates () {
exit 1
}
+test true = "$rebase" && {
+ git update-index --ignore-submodules --refresh &&
+ git diff-files --ignore-submodules --quiet &&
+ git diff-index --ignore-submodules --cached --quiet HEAD -- ||
+ die "refusing to pull with rebase: your working tree is not up-to-date"
+
+ . git-parse-remote &&
+ origin="$1"
+ test -z "$origin" && origin=$(get_default_remote)
+ reflist="$(get_remote_refs_for_fetch "$@" 2>/dev/null |
+ sed "s|refs/heads/\(.*\):|\1|")" &&
+ oldremoteref="$(git rev-parse --verify \
+ "refs/remotes/$origin/$reflist" 2>/dev/null)"
+}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git-fetch --update-head-ok "$@" || exit 1
+git fetch --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -163,7 +177,9 @@ then
exit
fi
-merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
-test true = "$rebase" && exec git-rebase $merge_head
-exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \
+merge_name=$(git fmt-merge-msg $log_arg <"$GIT_DIR/FETCH_HEAD") || exit
+test true = "$rebase" &&
+ exec git-rebase $strategy_args --onto $merge_head \
+ ${oldremoteref:-$merge_head}
+exec git-merge $no_stat $no_commit $squash $no_ff $log_arg $strategy_args \
"$merge_name" HEAD $merge_head
diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 233e5eae1..cebaee1cc 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -1,7 +1,7 @@
#!/bin/sh
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
-git-quiltimport [options]
+git quiltimport [options]
--
n,dry-run dry run
author= author name and email address for patches without any
@@ -53,7 +53,7 @@ if ! [ -d "$QUILT_PATCHES" ] ; then
fi
# Temporary directories
-tmp_dir=.dotest
+tmp_dir="$GIT_DIR"/rebase-apply
tmp_msg="$tmp_dir/msg"
tmp_patch="$tmp_dir/patch"
tmp_info="$tmp_dir/info"
@@ -63,7 +63,23 @@ tmp_info="$tmp_dir/info"
commit=$(git rev-parse HEAD)
mkdir $tmp_dir || exit 2
-for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
+while read patch_name level garbage
+do
+ case "$patch_name" in ''|'#'*) continue;; esac
+ case "$level" in
+ -p*) ;;
+ ''|'#'*)
+ level=;;
+ *)
+ echo "unable to parse patch level, ignoring it."
+ level=;;
+ esac
+ case "$garbage" in
+ ''|'#'*);;
+ *)
+ echo "trailing garbage found in series file: $garbage"
+ exit 1;;
+ esac
if ! [ -f "$QUILT_PATCHES/$patch_name" ] ; then
echo "$patch_name doesn't exist. Skipping."
continue
@@ -113,10 +129,10 @@ for patch_name in $(grep -v '^#' < "$QUILT_PATCHES/series" ); do
fi
if [ -z "$dry_run" ] ; then
- git apply --index -C1 "$tmp_patch" &&
+ git apply --index -C1 ${level:+"$level"} "$tmp_patch" &&
tree=$(git write-tree) &&
commit=$( (echo "$SUBJECT"; echo; cat "$tmp_msg") | git commit-tree $tree -p $commit) &&
git update-ref -m "quiltimport: $patch_name" HEAD $commit || exit 4
fi
-done
+done <"$QUILT_PATCHES/series"
rm -rf $tmp_dir || exit 5
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 402ff3782..929d681c4 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -10,14 +10,28 @@
# The original idea comes from Eric W. Biederman, in
# http://article.gmane.org/gmane.comp.version-control.git/22407
-USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]
- [--onto <branch>] <upstream> [<branch>])'
+OPTIONS_KEEPDASHDASH=
+OPTIONS_SPEC="\
+git-rebase [-i] [options] [--] <upstream> [<branch>]
+git-rebase [-i] (--continue | --abort | --skip)
+--
+ Available options are
+v,verbose display a diffstat of what changed upstream
+onto= rebase onto given branch instead of upstream
+p,preserve-merges try to recreate merges instead of ignoring them
+s,strategy= use the given merge strategy
+m,merge always used (no-op)
+i,interactive always used (no-op)
+ Actions:
+continue continue rebasing process
+abort abort rebasing process and restore original branch
+skip skip current patch and continue rebasing process
+"
-OPTIONS_SPEC=
. git-sh-setup
require_work_tree
-DOTEST="$GIT_DIR/.dotest-merge"
+DOTEST="$GIT_DIR/rebase-merge"
TODO="$DOTEST"/git-rebase-todo
DONE="$DOTEST"/done
MSG="$DOTEST"/message
@@ -25,10 +39,8 @@ SQUASH_MSG="$DOTEST"/message-squash
REWRITTEN="$DOTEST"/rewritten
PRESERVE_MERGES=
STRATEGY=
+ONTO=
VERBOSE=
-test -d "$REWRITTEN" && PRESERVE_MERGES=t
-test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
-test -f "$DOTEST"/verbose && VERBOSE=t
GIT_CHERRY_PICK_HELP=" After resolving the conflicts,
mark the corrected paths with 'git add <paths>', and
@@ -56,9 +68,9 @@ output () {
require_clean_work_tree () {
# test if working tree is dirty
git rev-parse --verify HEAD > /dev/null &&
- git update-index --refresh &&
- git diff-files --quiet &&
- git diff-index --cached --quiet HEAD -- ||
+ git update-index --ignore-submodules --refresh &&
+ git diff-files --quiet --ignore-submodules &&
+ git diff-index --cached --quiet HEAD --ignore-submodules -- ||
die "Working tree is dirty"
}
@@ -78,8 +90,8 @@ mark_action_done () {
sed -e 1q < "$TODO" >> "$DONE"
sed -e 1d < "$TODO" >> "$TODO".new
mv -f "$TODO".new "$TODO"
- count=$(($(grep -ve '^$' -e '^#' < "$DONE" | wc -l)))
- total=$(($count+$(grep -ve '^$' -e '^#' < "$TODO" | wc -l)))
+ count=$(grep -c '^[^#]' < "$DONE")
+ total=$(($count+$(grep -c '^[^#]' < "$TODO")))
if test "$last_count" != "$count"
then
last_count=$count
@@ -110,7 +122,7 @@ die_abort () {
}
has_action () {
- grep -vqe '^$' -e '^#' "$1"
+ grep '^[^#]' "$1" >/dev/null
}
pick_one () {
@@ -133,7 +145,16 @@ pick_one () {
}
pick_one_preserving_merges () {
- case "$1" in -n) sha1=$2 ;; *) sha1=$1 ;; esac
+ fast_forward=t
+ case "$1" in
+ -n)
+ fast_forward=f
+ sha1=$2
+ ;;
+ *)
+ sha1=$1
+ ;;
+ esac
sha1=$(git rev-parse $sha1)
if test -f "$DOTEST"/current-commit
@@ -144,15 +165,14 @@ pick_one_preserving_merges () {
die "Cannot write current commit's replacement sha1"
fi
+ echo $sha1 > "$DOTEST"/current-commit
+
# rewrite parents; if none were rewritten, we can fast-forward.
- fast_forward=t
- preserve=t
new_parents=
for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -f2-)
do
if test -f "$REWRITTEN"/$p
then
- preserve=f
new_p=$(cat "$REWRITTEN"/$p)
test $p != $new_p && fast_forward=f
case "$new_parents" in
@@ -162,12 +182,15 @@ pick_one_preserving_merges () {
new_parents="$new_parents $new_p"
;;
esac
+ else
+ new_parents="$new_parents $p"
fi
done
case $fast_forward in
t)
output warn "Fast forward to $sha1"
- test $preserve = f || echo $sha1 > "$REWRITTEN"/$sha1
+ output git reset --hard $sha1 ||
+ die "Cannot fast forward to $sha1"
;;
f)
test "a$1" = a-n && die "Refusing to squash a merge: $sha1"
@@ -177,7 +200,6 @@ pick_one_preserving_merges () {
output git checkout $first_parent 2> /dev/null ||
die "Cannot move HEAD to $first_parent"
- echo $sha1 > "$DOTEST"/current-commit
case "$new_parents" in
' '*' '*)
# redo merge
@@ -218,7 +240,7 @@ nth_string () {
make_squash_message () {
if test -f "$SQUASH_MSG"; then
COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
- < "$SQUASH_MSG" | tail -n 1)+1))
+ < "$SQUASH_MSG" | sed -ne '$p')+1))
echo "# This is a combination of $COUNT commits."
sed -e 1d -e '2,/^./{
/^$/d
@@ -263,11 +285,15 @@ do_next () {
die_with_patch $sha1 "Could not apply $sha1... $rest"
make_patch $sha1
: > "$DOTEST"/amend
- warn
+ warn "Stopped at $sha1... $rest"
warn "You can amend the commit now, with"
warn
warn " git commit --amend"
warn
+ warn "Once you are satisfied with your changes, run"
+ warn
+ warn " git rebase --continue"
+ warn
exit 0
;;
squash|s)
@@ -362,10 +388,27 @@ do_rest () {
done
}
+# check if no other options are set
+is_standalone () {
+ test $# -eq 2 -a "$2" = '--' &&
+ test -z "$ONTO" &&
+ test -z "$PRESERVE_MERGES" &&
+ test -z "$STRATEGY" &&
+ test -z "$VERBOSE"
+}
+
+get_saved_options () {
+ test -d "$REWRITTEN" && PRESERVE_MERGES=t
+ test -f "$DOTEST"/strategy && STRATEGY="$(cat "$DOTEST"/strategy)"
+ test -f "$DOTEST"/verbose && VERBOSE=t
+}
+
while test $# != 0
do
case "$1" in
--continue)
+ is_standalone "$@" || usage
+ get_saved_options
comment_for_reflog continue
test -d "$DOTEST" || die "No interactive rebase running"
@@ -373,11 +416,12 @@ do
# Sanity check
git rev-parse --verify HEAD >/dev/null ||
die "Cannot read HEAD"
- git update-index --refresh && git diff-files --quiet ||
+ git update-index --ignore-submodules --refresh &&
+ git diff-files --quiet --ignore-submodules ||
die "Working tree is dirty"
# do we have anything to commit?
- if git diff-index --cached --quiet HEAD --
+ if git diff-index --cached --quiet --ignore-submodules HEAD --
then
: Nothing to commit -- skip this
else
@@ -397,6 +441,8 @@ do
do_rest
;;
--abort)
+ is_standalone "$@" || usage
+ get_saved_options
comment_for_reflog abort
git rerere clear
@@ -414,6 +460,8 @@ do
exit
;;
--skip)
+ is_standalone "$@" || usage
+ get_saved_options
comment_for_reflog skip
git rerere clear
@@ -421,7 +469,7 @@ do
output git reset --hard && do_rest
;;
- -s|--strategy)
+ -s)
case "$#,$1" in
*,*=*)
STRATEGY="-s "$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
@@ -432,25 +480,26 @@ do
shift ;;
esac
;;
- --merge)
+ -m)
# we use merge anyway
;;
- -C*)
- die "Interactive rebase uses merge, so $1 does not make sense"
- ;;
- -v|--verbose)
+ -v)
VERBOSE=t
;;
- -p|--preserve-merges)
+ -p)
PRESERVE_MERGES=t
;;
- -i|--interactive)
+ -i)
# yeah, we know
;;
- ''|-h)
- usage
+ --onto)
+ shift
+ ONTO=$(git rev-parse --verify "$1") ||
+ die "Does not point to a valid commit: $1"
;;
- *)
+ --)
+ shift
+ test $# -eq 1 -o $# -eq 2 || usage
test -d "$DOTEST" &&
die "Interactive rebase already started"
@@ -459,17 +508,11 @@ do
comment_for_reflog start
- ONTO=
- case "$1" in
- --onto)
- ONTO=$(git rev-parse --verify "$2") ||
- die "Does not point to a valid commit: $2"
- shift; shift
- ;;
- esac
-
require_clean_work_tree
+ UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
+ test -z "$ONTO" && ONTO=$UPSTREAM
+
if test ! -z "$2"
then
output git show-ref --verify --quiet "refs/heads/$2" ||
@@ -479,12 +522,8 @@ do
fi
HEAD=$(git rev-parse --verify HEAD) || die "No HEAD?"
- UPSTREAM=$(git rev-parse --verify "$1") || die "Invalid base"
-
mkdir "$DOTEST" || die "Could not create temporary $DOTEST"
- test -z "$ONTO" && ONTO=$UPSTREAM
-
: > "$DOTEST"/interactive || die "Could not mark as interactive"
git symbolic-ref HEAD > "$DOTEST"/head-name 2> /dev/null ||
echo "detached HEAD" > "$DOTEST"/head-name
@@ -526,9 +565,9 @@ do
# Rebase $SHORTUPSTREAM..$SHORTHEAD onto $SHORTONTO
#
# Commands:
-# pick = use commit
-# edit = use commit, but stop for amending
-# squash = use commit, but meld into previous commit
+# p, pick = use commit
+# e, edit = use commit, but stop for amending
+# s, squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
@@ -545,6 +584,7 @@ EOF
has_action "$TODO" ||
die_abort "Nothing to do"
+ git update-ref ORIG_HEAD $HEAD
output git checkout $ONTO && do_rest
;;
esac
diff --git a/git-rebase.sh b/git-rebase.sh
index bdcea0ed7..528b604cd 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -14,12 +14,11 @@ It is possible that a merge failure will prevent this process from being
completely automatic. You will have to resolve any such merge failure
and run git rebase --continue. Another option is to bypass the commit
that caused the merge failure with git rebase --skip. To restore the
-original <branch> and remove the .dotest working files, use the command
-git rebase --abort instead.
+original <branch> and remove the .git/rebase-apply working files, use the
+command git rebase --abort instead.
Note that if <branch> is not specified on the command line, the
-currently checked out branch is used. You must be in the top
-directory of your project to start (or continue) a rebase.
+currently checked out branch is used.
Example: git-rebase master~1 topic
@@ -43,7 +42,7 @@ To restore the original branch and stop rebasing run \"git rebase --abort\".
unset newbase
strategy=recursive
do_merge=
-dotest=$GIT_DIR/.dotest-merge
+dotest="$GIT_DIR"/rebase-merge
prec=4
verbose=
git_am_opt=
@@ -61,9 +60,9 @@ continue_merge () {
fi
cmt=`cat "$dotest/current"`
- if ! git diff-index --quiet HEAD --
+ if ! git diff-index --quiet --ignore-submodules HEAD --
then
- if ! git-commit -C "$cmt"
+ if ! git commit --no-verify -C "$cmt"
then
echo "Commit failed, please do not call \"git commit\""
echo "directly, but instead do one of the following: "
@@ -145,13 +144,27 @@ is_interactive () {
done && test -n "$1"
}
+test -f "$GIT_DIR"/rebase-apply/applying &&
+ die 'It looks like git-am is in progress. Cannot rebase.'
+
is_interactive "$@" && exec git-rebase--interactive "$@"
+if test $# -eq 0
+then
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
+ test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
+ die 'A rebase is in progress, try --continue, --skip or --abort.'
+ die "No arguments given and $GIT_DIR/rebase-apply already exists."
+fi
+
while test $# != 0
do
case "$1" in
--continue)
- git diff-files --quiet || {
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ die "No rebase in progress?"
+
+ git diff-files --quiet --ignore-submodules || {
echo "You must edit all merge conflicts and then"
echo "mark them as resolved using git add"
exit 1
@@ -171,14 +184,17 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat .dotest/head-name) &&
- onto=$(cat .dotest/onto) &&
- orig_head=$(cat .dotest/orig-head) &&
+ head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
+ onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
+ orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
--skip)
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ die "No rebase in progress?"
+
git reset --hard HEAD || exit $?
if test -d "$dotest"
then
@@ -196,28 +212,27 @@ do
finish_rb_merge
exit
fi
- head_name=$(cat .dotest/head-name) &&
- onto=$(cat .dotest/onto) &&
- orig_head=$(cat .dotest/orig-head) &&
+ head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
+ onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
+ orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
exit
;;
--abort)
+ test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply ||
+ die "No rebase in progress?"
+
git rerere clear
if test -d "$dotest"
then
move_to_original_branch
- rm -r "$dotest"
- elif test -d .dotest
- then
- dotest=.dotest
- move_to_original_branch
- rm -r .dotest
else
- die "No rebase in progress?"
+ dotest="$GIT_DIR"/rebase-apply
+ move_to_original_branch
fi
- git reset --hard ORIG_HEAD
+ git reset --hard $(cat "$dotest/orig-head")
+ rm -r "$dotest"
exit
;;
--onto)
@@ -261,31 +276,33 @@ do
shift
done
-# Make sure we do not have .dotest
+# Make sure we do not have $GIT_DIR/rebase-apply
if test -z "$do_merge"
then
- if mkdir .dotest
+ if mkdir "$GIT_DIR"/rebase-apply 2>/dev/null
then
- rmdir .dotest
+ rmdir "$GIT_DIR"/rebase-apply
else
echo >&2 '
-It seems that I cannot create a .dotest directory, and I wonder if you
-are in the middle of patch application or another rebase. If that is not
-the case, please rm -fr .dotest and run me again. I am stopping in case
-you still have something valuable there.'
+It seems that I cannot create a rebase-apply directory, and
+I wonder if you are in the middle of patch application or another
+rebase. If that is not the case, please
+ rm -fr '"$GIT_DIR"'/rebase-apply
+and run me again. I am stopping in case you still have something
+valuable there.'
exit 1
fi
else
if test -d "$dotest"
then
- die "previous dotest directory $dotest still exists." \
- 'try git-rebase < --continue | --abort >'
+ die "previous rebase directory $dotest still exists." \
+ 'Try git rebase (--continue | --abort | --skip)'
fi
fi
# The tree must be really really clean.
-git update-index --refresh || exit
-diff=$(git diff-index --cached --name-status -r HEAD --)
+git update-index --ignore-submodules --refresh || exit
+diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
case "$diff" in
?*) echo "cannot rebase: your index is not up-to-date"
echo "$diff"
@@ -311,22 +328,42 @@ then
}
fi
-# If the branch to rebase is given, first switch to it.
+# If the branch to rebase is given, that is the branch we will rebase
+# $branch_name -- branch being rebased, or HEAD (already detached)
+# $orig_head -- commit object name of tip of the branch before rebasing
+# $head_name -- refs/heads/<that-branch> or "detached HEAD"
+switch_to=
case "$#" in
2)
+ # Is it "rebase other $branchname" or "rebase other $commit"?
branch_name="$2"
- git-checkout "$2" || usage
+ switch_to="$2"
+
+ if git show-ref --verify --quiet -- "refs/heads/$2" &&
+ branch=$(git rev-parse --verify "refs/heads/$2" 2>/dev/null)
+ then
+ head_name="refs/heads/$2"
+ elif branch=$(git rev-parse --verify "$2" 2>/dev/null)
+ then
+ head_name="detached HEAD"
+ else
+ usage
+ fi
;;
*)
+ # Do not need to switch branches, we are already on it.
if branch_name=`git symbolic-ref -q HEAD`
then
+ head_name=$branch_name
branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
else
+ head_name="detached HEAD"
branch_name=HEAD ;# detached
fi
+ branch=$(git rev-parse --verify "${branch_name}^0") || exit
;;
esac
-branch=$(git rev-parse --verify "${branch_name}^0") || exit
+orig_head=$branch
# Now we are rebasing commits $upstream..$branch on top of $onto
@@ -335,8 +372,10 @@ branch=$(git rev-parse --verify "${branch_name}^0") || exit
mb=$(git merge-base "$onto" "$branch")
if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
# linear history?
- ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null
+ ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null
then
+ # Lazily switch to the target branch if needed...
+ test -z "$switch_to" || git checkout "$switch_to"
echo >&2 "Current branch $branch_name is up to date."
exit 0
fi
@@ -348,22 +387,10 @@ then
GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
fi
-# move to a detached HEAD
-orig_head=$(git rev-parse HEAD^0)
-head_name=$(git symbolic-ref HEAD 2> /dev/null)
-case "$head_name" in
-'')
- head_name="detached HEAD"
- ;;
-*)
- git checkout "$orig_head" > /dev/null 2>&1 ||
- die "could not detach HEAD"
- ;;
-esac
-
-# Rewind the head to "$onto"; this saves our current head in ORIG_HEAD.
+# Detach HEAD and reset the tree
echo "First, rewinding head to replay your work on top of it..."
-git-reset --hard "$onto"
+git checkout -q "$onto^0" || die "could not detach HEAD"
+git update-ref ORIG_HEAD $branch
# If the $onto is a proper descendant of the tip of the branch, then
# we just fast forwarded.
@@ -376,14 +403,15 @@ fi
if test -z "$do_merge"
then
- git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
- git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" &&
+ git format-patch -k --stdout --full-index --ignore-if-in-upstream \
+ "$upstream..$orig_head" |
+ git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
move_to_original_branch
ret=$?
- test 0 != $ret -a -d .dotest &&
- echo $head_name > .dotest/head-name &&
- echo $onto > .dotest/onto &&
- echo $orig_head > .dotest/orig-head
+ test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
+ echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
+ echo $onto > "$GIT_DIR"/rebase-apply/onto &&
+ echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head
exit $ret
fi
@@ -399,7 +427,7 @@ echo "$orig_head" > "$dotest/orig-head"
echo "$head_name" > "$dotest/head-name"
msgnum=0
-for cmt in `git rev-list --reverse --no-merges "$upstream"..ORIG_HEAD`
+for cmt in `git rev-list --reverse --no-merges "$upstream..$orig_head"`
do
msgnum=$(($msgnum + 1))
echo "$cmt" > "$dotest/cmt.$msgnum"
diff --git a/git-relink.perl b/git-relink.perl
index f6b4f6a2f..937c69a74 100755
--- a/git-relink.perl
+++ b/git-relink.perl
@@ -40,7 +40,7 @@ my $master_dir = pop @dirs;
opendir(D,$master_dir . "objects/")
or die "Failed to open $master_dir/objects/ : $!";
-my @hashdirs = grep !/^\.{1,2}$/, readdir(D);
+my @hashdirs = grep { ($_ eq 'pack') || /^[0-9a-f]{2}$/ } readdir(D);
foreach my $repo (@dirs) {
$linked = 0;
@@ -163,7 +163,7 @@ sub link_two_files($$) {
sub usage() {
- print("Usage: $0 [--safe] <dir> [<dir> ...] <master_dir> \n");
+ print("Usage: git relink [--safe] <dir> [<dir> ...] <master_dir> \n");
print("All directories should contain a .git/objects/ subdirectory.\n");
print("Options\n");
print("\t--safe\t" .
diff --git a/git-repack.sh b/git-repack.sh
index e18eb3f5d..683960b04 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -5,12 +5,13 @@
OPTIONS_KEEPDASHDASH=
OPTIONS_SPEC="\
-git-repack [options]
+git repack [options]
--
a pack everything in a single pack
-A same as -a, and keep unreachable objects too
+A same as -a, and turn unreachable objects loose
d remove redundant packs, and run git-prune-packed
f pass --no-reuse-delta to git-pack-objects
+n do not run git-update-server-info
q,quiet be quiet
l pass --local to git-pack-objects
Packing constraints
@@ -22,7 +23,7 @@ max-pack-size= maximum size of each packfile
SUBDIRECTORY_OK='Yes'
. git-sh-setup
-no_update_info= all_into_one= remove_redundant= keep_unreachable=
+no_update_info= all_into_one= remove_redundant= unpack_unreachable=
local= quiet= no_reuse= extra=
while test $# != 0
do
@@ -30,7 +31,7 @@ do
-n) no_update_info=t ;;
-a) all_into_one=t ;;
-A) all_into_one=t
- keep_unreachable=--keep-unreachable ;;
+ unpack_unreachable=--unpack-unreachable ;;
-d) remove_redundant=t ;;
-q) quiet=-q ;;
-f) no_reuse=--no-reuse-object ;;
@@ -43,11 +44,7 @@ do
shift
done
-# Later we will default repack.UseDeltaBaseOffset to true
-default_dbo=false
-
-case "`git config --bool repack.usedeltabaseoffset ||
- echo $default_dbo`" in
+case "`git config --bool repack.usedeltabaseoffset || echo true`" in
true)
extra="$extra --delta-base-offset" ;;
esac
@@ -78,9 +75,9 @@ case ",$all_into_one," in
if test -z "$args"
then
args='--unpacked --incremental'
- elif test -n "$keep_unreachable"
+ elif test -n "$unpack_unreachable"
then
- args="$args $keep_unreachable"
+ args="$args $unpack_unreachable"
fi
;;
esac
@@ -124,7 +121,6 @@ then
# We know $existing are all redundant.
if [ -n "$existing" ]
then
- sync
( cd "$PACKDIR" &&
for e in $existing
do
diff --git a/git-request-pull.sh b/git-request-pull.sh
index 068f5e0fc..073a314c8 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -26,7 +26,7 @@ merge_base=`git merge-base $baserev $headrev` ||
die "fatal: No commits in common between $base and $head"
url=$(get_remote_url "$url")
-branch=$(git peek-remote "$url" \
+branch=$(git ls-remote "$url" \
| sed -n -e "/^$headrev refs.heads./{
s/^.* refs.heads.//
p
diff --git a/git-send-email.perl b/git-send-email.perl
index 6c72952fc..d2fd89907 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -24,8 +24,6 @@ use Data::Dumper;
use Term::ANSIColor;
use Git;
-$SIG{INT} = sub { print color("reset"), "\n"; exit };
-
package FakeTerm;
sub new {
my ($class, $reason) = @_;
@@ -40,7 +38,7 @@ package main;
sub usage {
print <<EOT;
-git-send-email [options] <file | directory>...
+git send-email [options] <file | directory>...
Options:
--from Specify the "From:" line of the email to be sent.
@@ -86,7 +84,16 @@ Options:
--smtp-pass The password for SMTP-AUTH.
- --smtp-ssl If set, connects to the SMTP server using SSL.
+ --smtp-encryption Specify 'tls' for STARTTLS encryption, or 'ssl' for SSL.
+ Any other value disables the feature.
+
+ --smtp-ssl Synonym for '--smtp-encryption=ssl'. Deprecated.
+
+ --suppress-cc Suppress the specified category of auto-CC. The category
+ can be one of 'author' for the patch author, 'self' to
+ avoid copying yourself, 'sob' for Signed-off-by lines,
+ 'cccmd' for the output of the cccmd, or 'all' to suppress
+ all of these.
--suppress-from Suppress sending emails to yourself. Defaults to off.
@@ -157,16 +164,19 @@ my $compose_filename = ".msg.$$";
# Variables we fill in automatically, or via prompting:
my (@to,@cc,@initial_cc,@bcclist,@xh,
- $initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);
+ $initial_reply_to,$initial_subject,@files,$author,$sender,$smtp_authpass,$compose,$time);
my $envelope_sender;
# Example reply to:
#$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
-my $repo = Git->repository();
+my $repo = eval { Git->repository() };
+my @repo = $repo ? ($repo) : ();
my $term = eval {
- new Term::ReadLine 'git-send-email';
+ $ENV{"GIT_SEND_EMAIL_NOTTY"}
+ ? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
+ : new Term::ReadLine 'git-send-email';
};
if ($@) {
$term = new FakeTerm "$@: going non-interactive";
@@ -177,16 +187,16 @@ my ($quiet, $dry_run) = (0, 0);
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
-my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
+my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_encryption);
my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
my ($no_validate);
+my (@suppress_cc);
my %config_bool_settings = (
"thread" => [\$thread, 1],
"chainreplyto" => [\$chain_reply_to, 1],
- "suppressfrom" => [\$suppress_from, 0],
- "signedoffcc" => [\$signed_off_cc, 1],
- "smtpssl" => [\$smtp_ssl, 0],
+ "suppressfrom" => [\$suppress_from, undef],
+ "signedoffcc" => [\$signed_off_cc, undef],
);
my %config_settings = (
@@ -195,12 +205,38 @@ my %config_settings = (
"smtpuser" => \$smtp_authuser,
"smtppass" => \$smtp_authpass,
"to" => \@to,
+ "cc" => \@initial_cc,
"cccmd" => \$cc_cmd,
"aliasfiletype" => \$aliasfiletype,
"bcc" => \@bcclist,
"aliasesfile" => \@alias_files,
+ "suppresscc" => \@suppress_cc,
+ "envelopesender" => \$envelope_sender,
);
+# Handle Uncouth Termination
+sub signal_handler {
+
+ # Make text normal
+ print color("reset"), "\n";
+
+ # SMTP password masked
+ system "stty echo";
+
+ # tmp files from --compose
+ if (-e $compose_filename) {
+ print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
+ }
+ if (-e ($compose_filename . ".final")) {
+ print "'$compose_filename.final' contains the composed email.\n"
+ }
+
+ exit;
+};
+
+$SIG{TERM} = \&signal_handler;
+$SIG{INT} = \&signal_handler;
+
# Begin by accumulating all the variables (defined above), that we will end up
# needing, first, from the command line:
@@ -214,13 +250,15 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"smtp-server=s" => \$smtp_server,
"smtp-server-port=s" => \$smtp_server_port,
"smtp-user=s" => \$smtp_authuser,
- "smtp-pass=s" => \$smtp_authpass,
- "smtp-ssl!" => \$smtp_ssl,
+ "smtp-pass:s" => \$smtp_authpass,
+ "smtp-ssl" => sub { $smtp_encryption = 'ssl' },
+ "smtp-encryption=s" => \$smtp_encryption,
"identity=s" => \$identity,
"compose" => \$compose,
"quiet" => \$quiet,
"cc-cmd=s" => \$cc_cmd,
"suppress-from!" => \$suppress_from,
+ "suppress-cc=s" => \@suppress_cc,
"signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
"dry-run" => \$dry_run,
"envelope-sender=s" => \$envelope_sender,
@@ -239,25 +277,34 @@ sub read_config {
foreach my $setting (keys %config_bool_settings) {
my $target = $config_bool_settings{$setting}->[0];
- $$target = $repo->config_bool("$prefix.$setting") unless (defined $$target);
+ $$target = Git::config_bool(@repo, "$prefix.$setting") unless (defined $$target);
}
foreach my $setting (keys %config_settings) {
my $target = $config_settings{$setting};
if (ref($target) eq "ARRAY") {
unless (@$target) {
- my @values = $repo->config("$prefix.$setting");
+ my @values = Git::config(@repo, "$prefix.$setting");
@$target = @values if (@values && defined $values[0]);
}
}
else {
- $$target = $repo->config("$prefix.$setting") unless (defined $$target);
+ $$target = Git::config(@repo, "$prefix.$setting") unless (defined $$target);
+ }
+ }
+
+ if (!defined $smtp_encryption) {
+ my $enc = Git::config(@repo, "$prefix.smtpencryption");
+ if (defined $enc) {
+ $smtp_encryption = $enc;
+ } elsif (Git::config_bool(@repo, "$prefix.smtpssl")) {
+ $smtp_encryption = 'ssl';
}
}
}
# read configuration from [sendemail "$identity"], fall back on [sendemail]
-$identity = $repo->config("sendemail.identity") unless (defined $identity);
+$identity = Git::config(@repo, "sendemail.identity") unless (defined $identity);
read_config("sendemail.$identity") if (defined $identity);
read_config("sendemail");
@@ -266,8 +313,41 @@ foreach my $setting (values %config_bool_settings) {
${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
}
-my ($repoauthor) = $repo->ident_person('author');
-my ($repocommitter) = $repo->ident_person('committer');
+# 'default' encryption is none -- this only prevents a warning
+$smtp_encryption = '' unless (defined $smtp_encryption);
+
+# Set CC suppressions
+my(%suppress_cc);
+if (@suppress_cc) {
+ foreach my $entry (@suppress_cc) {
+ die "Unknown --suppress-cc field: '$entry'\n"
+ unless $entry =~ /^(all|cccmd|cc|author|self|sob)$/;
+ $suppress_cc{$entry} = 1;
+ }
+}
+
+if ($suppress_cc{'all'}) {
+ foreach my $entry (qw (ccmd cc author self sob)) {
+ $suppress_cc{$entry} = 1;
+ }
+ delete $suppress_cc{'all'};
+}
+
+# If explicit old-style ones are specified, they trump --suppress-cc.
+$suppress_cc{'self'} = $suppress_from if defined $suppress_from;
+$suppress_cc{'sob'} = !$signed_off_cc if defined $signed_off_cc;
+
+# Debugging, print out the suppressions.
+if (0) {
+ print "suppressions:\n";
+ foreach my $entry (keys %suppress_cc) {
+ printf " %-5s -> $suppress_cc{$entry}\n", $entry;
+ }
+}
+
+my ($repoauthor, $repocommitter);
+($repoauthor) = Git::ident_person(@repo, 'author');
+($repocommitter) = Git::ident_person(@repo, 'committer');
# Verify the user input
@@ -328,7 +408,7 @@ for my $f (@ARGV) {
push @files, grep { -f $_ } map { +$f . "/" . $_ }
sort readdir(DH);
- } elsif (-f $f) {
+ } elsif (-f $f or -p $f) {
push @files, $f;
} else {
@@ -338,8 +418,10 @@ for my $f (@ARGV) {
if (!$no_validate) {
foreach my $f (@files) {
- my $error = validate_patch($f);
- $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+ unless (-p $f) {
+ my $error = validate_patch($f);
+ $error and die "fatal: $f: $error\nwarning: no patches were sent\n";
+ }
}
}
@@ -354,10 +436,13 @@ if (@files) {
my $prompting = 0;
if (!defined $sender) {
- $sender = $repoauthor || $repocommitter;
- do {
+ $sender = $repoauthor || $repocommitter || '';
+
+ while (1) {
$_ = $term->readline("Who should the emails appear to be from? [$sender] ");
- } while (!defined $_);
+ last if defined $_;
+ print "\n";
+ }
$sender = $_ if ($_);
print "Emails will be sent from: ", $sender, "\n";
@@ -365,12 +450,16 @@ if (!defined $sender) {
}
if (!@to) {
- do {
- $_ = $term->readline("Who should the emails be sent to? ",
- "");
- } while (!defined $_);
+
+
+ while (1) {
+ $_ = $term->readline("Who should the emails be sent to? ", "");
+ last if defined $_;
+ print "\n";
+ }
+
my $to = $_;
- push @to, split /,/, $to;
+ push @to, split /,\s*/, $to;
$prompting++;
}
@@ -390,25 +479,29 @@ sub expand_aliases {
@bcclist = expand_aliases(@bcclist);
if (!defined $initial_subject && $compose) {
- do {
- $_ = $term->readline("What subject should the initial email start with? ",
- $initial_subject);
- } while (!defined $_);
+ while (1) {
+ $_ = $term->readline("What subject should the initial email start with? ", $initial_subject);
+ last if defined $_;
+ print "\n";
+ }
+
$initial_subject = $_;
$prompting++;
}
if ($thread && !defined $initial_reply_to && $prompting) {
- do {
- $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ",
- $initial_reply_to);
- } while (!defined $_);
+ while (1) {
+ $_= $term->readline("Message-ID to be used as In-Reply-To for the first email? ", $initial_reply_to);
+ last if defined $_;
+ print "\n";
+ }
$initial_reply_to = $_;
}
-if (defined $initial_reply_to && $_ ne "") {
- $initial_reply_to =~ s/^\s*<?/</;
- $initial_reply_to =~ s/>?\s*$/>/;
+if (defined $initial_reply_to) {
+ $initial_reply_to =~ s/^\s*<?//;
+ $initial_reply_to =~ s/>?\s*$//;
+ $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
}
if (!defined $smtp_server) {
@@ -437,8 +530,8 @@ GIT: for the patch you are writing.
EOT
close(C);
- my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
- system('sh', '-c', '$0 $@', $editor, $compose_filename);
+ my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+ system('sh', '-c', $editor.' "$@"', $editor, $compose_filename);
open(C2,">",$compose_filename . ".final")
or die "Failed to open $compose_filename.final : " . $!;
@@ -446,23 +539,47 @@ EOT
open(C,"<",$compose_filename)
or die "Failed to open $compose_filename : " . $!;
+ my $need_8bit_cte = file_has_nonascii($compose_filename);
+ my $in_body = 0;
while(<C>) {
next if m/^GIT: /;
+ if (!$in_body && /^\n$/) {
+ $in_body = 1;
+ if ($need_8bit_cte) {
+ print C2 "MIME-Version: 1.0\n",
+ "Content-Type: text/plain; ",
+ "charset=utf-8\n",
+ "Content-Transfer-Encoding: 8bit\n";
+ }
+ }
+ if (!$in_body && /^MIME-Version:/i) {
+ $need_8bit_cte = 0;
+ }
+ if (!$in_body && /^Subject: ?(.*)/i) {
+ my $subject = $1;
+ $_ = "Subject: " .
+ ($subject =~ /[^[:ascii:]]/ ?
+ quote_rfc2047($subject) :
+ $subject) .
+ "\n";
+ }
print C2 $_;
}
close(C);
close(C2);
- do {
+ while (1) {
$_ = $term->readline("Send this email? (y|n) ");
- } while (!defined $_);
+ last if defined $_;
+ print "\n";
+ }
if (uc substr($_,0,1) ne 'Y') {
cleanup_compose_files();
exit(0);
}
- @files = ($compose_filename . ".final");
+ @files = ($compose_filename . ".final", @files);
}
# Variables we set as part of the loop over files
@@ -536,6 +653,14 @@ sub unquote_rfc2047 {
return wantarray ? ($_, $encoding) : $_;
}
+sub quote_rfc2047 {
+ local $_ = shift;
+ my $encoding = shift || 'utf-8';
+ s/([^-a-zA-Z0-9!*+\/])/sprintf("=%02X", ord($1))/eg;
+ s/(.*)/=\?$encoding\?q\?$1\?=/;
+ return $_;
+}
+
# use the simplest quoting being able to handle the recipient
sub sanitize_address
{
@@ -553,13 +678,12 @@ sub sanitize_address
# rfc2047 is needed if a non-ascii char is included
if ($recipient_name =~ /[^[:ascii:]]/) {
- $recipient_name =~ s/([^-a-zA-Z0-9!*+\/])/sprintf("=%02X", ord($1))/eg;
- $recipient_name =~ s/(.*)/=\?utf-8\?q\?$1\?=/;
+ $recipient_name = quote_rfc2047($recipient_name);
}
# double quotes are needed if specials or CTLs are included
elsif ($recipient_name =~ /[][()<>@,;:\\".\000-\037\177]/) {
- $recipient_name =~ s/(["\\\r])/\\$1/;
+ $recipient_name =~ s/(["\\\r])/\\$1/g;
$recipient_name = "\"$recipient_name\"";
}
@@ -631,7 +755,7 @@ X-Mailer: git-send-email $gitversion
die "The required SMTP server is not properly defined."
}
- if ($smtp_ssl) {
+ if ($smtp_encryption eq 'ssl') {
$smtp_server_port ||= 465; # ssmtp
require Net::SMTP::SSL;
$smtp ||= Net::SMTP::SSL->new($smtp_server, Port => $smtp_server_port);
@@ -641,15 +765,47 @@ X-Mailer: git-send-email $gitversion
$smtp ||= Net::SMTP->new((defined $smtp_server_port)
? "$smtp_server:$smtp_server_port"
: $smtp_server);
+ if ($smtp_encryption eq 'tls') {
+ require Net::SMTP::SSL;
+ $smtp->command('STARTTLS');
+ $smtp->response();
+ if ($smtp->code == 220) {
+ $smtp = Net::SMTP::SSL->start_SSL($smtp)
+ or die "STARTTLS failed! ".$smtp->message;
+ $smtp_encryption = '';
+ # Send EHLO again to receive fresh
+ # supported commands
+ $smtp->hello();
+ } else {
+ die "Server does not support STARTTLS! ".$smtp->message;
+ }
+ }
}
if (!$smtp) {
die "Unable to initialize SMTP properly. Is there something wrong with your config?";
}
- if ((defined $smtp_authuser) && (defined $smtp_authpass)) {
+ if (defined $smtp_authuser) {
+
+ if (!defined $smtp_authpass) {
+
+ system "stty -echo";
+
+ do {
+ print "Password: ";
+ $_ = <STDIN>;
+ print "\n";
+ } while (!defined $_);
+
+ chomp($smtp_authpass = $_);
+
+ system "stty echo";
+ }
+
$auth ||= $smtp->auth( $smtp_authuser, $smtp_authpass ) or die $smtp->message;
}
+
$smtp->mail( $raw_from ) or die $smtp->message;
$smtp->to( @recipients ) or die $smtp->message;
$smtp->data or die $smtp->message;
@@ -711,11 +867,14 @@ foreach my $t (@files) {
} elsif (/^(Cc|From):\s+(.*)$/) {
if (unquote_rfc2047($2) eq $sender) {
- next if ($suppress_from);
+ next if ($suppress_cc{'self'});
}
elsif ($1 eq 'From') {
($author, $author_encoding)
= unquote_rfc2047($2);
+ next if ($suppress_cc{'author'});
+ } else {
+ next if ($suppress_cc{'cc'});
}
printf("(mbox) Adding cc: %s from line '%s'\n",
$2, $_) unless $quiet;
@@ -723,7 +882,7 @@ foreach my $t (@files) {
}
elsif (/^Content-type:/i) {
$has_content_type = 1;
- if (/charset="?[^ "]+/) {
+ if (/charset="?([^ "]+)/) {
$body_encoding = $1;
}
push @xh, $_;
@@ -742,7 +901,7 @@ foreach my $t (@files) {
# line 2 = subject
# So let's support that, too.
$input_format = 'lots';
- if (@cc == 0) {
+ if (@cc == 0 && !$suppress_cc{'cc'}) {
printf("(non-mbox) Adding cc: %s from line '%s'\n",
$_, $_) unless $quiet;
@@ -759,10 +918,12 @@ foreach my $t (@files) {
}
} else {
$message .= $_;
- if (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {
+ if (/^(Signed-off-by|Cc): (.*)$/i) {
+ next if ($suppress_cc{'sob'});
+ chomp;
my $c = $2;
chomp $c;
- next if ($c eq $sender and $suppress_from);
+ next if ($c eq $sender and $suppress_cc{'self'});
push @cc, $c;
printf("(sob) Adding cc: %s from line '%s'\n",
$c, $_) unless $quiet;
@@ -771,7 +932,7 @@ foreach my $t (@files) {
}
close F;
- if (defined $cc_cmd) {
+ if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
open(F, "$cc_cmd $t |")
or die "(cc-cmd) Could not execute '$cc_cmd'";
while(<F>) {
@@ -860,3 +1021,13 @@ sub validate_patch {
}
return undef;
}
+
+sub file_has_nonascii {
+ my $fn = shift;
+ open(my $fh, '<', $fn)
+ or die "unable to open $fn: $!\n";
+ while (my $line = <$fh>) {
+ return 1 if $line =~ /[^[:ascii:]]/;
+ }
+ return 0;
+}
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index aae14090b..dbdf209ec 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -32,15 +32,16 @@ if test -n "$OPTIONS_SPEC"; then
echo exit $?
)"
else
+ dashless=$(basename "$0" | sed -e 's/-/ /')
usage() {
- die "Usage: $0 $USAGE"
+ die "Usage: $dashless $USAGE"
}
if [ -z "$LONG_USAGE" ]
then
- LONG_USAGE="Usage: $0 $USAGE"
+ LONG_USAGE="Usage: $dashless $USAGE"
else
- LONG_USAGE="Usage: $0 $USAGE
+ LONG_USAGE="Usage: $dashless $USAGE
$LONG_USAGE"
fi
@@ -119,7 +120,7 @@ get_author_ident_from_commit () {
}
'
encoding=$(git config i18n.commitencoding || echo UTF-8)
- git show -s --pretty=raw --encoding="$encoding" "$1" |
+ git show -s --pretty=raw --encoding="$encoding" "$1" -- |
LANG=C LC_ALL=C sed -ne "$pick_author_script"
}
@@ -127,20 +128,14 @@ get_author_ident_from_commit () {
# if we require to be in a git repository.
if test -z "$NONGIT_OK"
then
+ GIT_DIR=$(git rev-parse --git-dir) || exit
if [ -z "$SUBDIRECTORY_OK" ]
then
- : ${GIT_DIR=.git}
test -z "$(git rev-parse --show-cdup)" || {
exit=$?
echo >&2 "You need to run this command from the toplevel of the working tree."
exit $exit
}
- else
- GIT_DIR=$(git rev-parse --git-dir) || {
- exit=$?
- echo >&2 "Failed to find a valid git directory."
- exit $exit
- }
fi
test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
echo >&2 "Unable to determine absolute path of git directory"
@@ -148,3 +143,16 @@ then
}
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
fi
+
+# Fix some commands on Windows
+case $(uname -s) in
+*MINGW*)
+ # Windows has its own (incompatible) sort and find
+ sort () {
+ /usr/bin/sort "$@"
+ }
+ find () {
+ /usr/bin/find "$@"
+ }
+ ;;
+esac
diff --git a/git-stash.sh b/git-stash.sh
index b00f88816..e15c12abc 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -1,7 +1,13 @@
#!/bin/sh
# Copyright (c) 2007, Nanako Shiraishi
-USAGE='[ | save | list | show | apply | clear | create ]'
+dashless=$(basename "$0" | sed -e 's/-/ /')
+USAGE="list [<options>]
+ or: $dashless (show | drop | pop ) [<stash>]
+ or: $dashless apply [--index] [<stash>]
+ or: $dashless branch <branchname> [<stash>]
+ or: $dashless [save [--keep-index] [<message>]]
+ or: $dashless clear"
SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
@@ -15,8 +21,8 @@ trap 'rm -f "$TMP-*"' 0
ref_stash=refs/stash
no_changes () {
- git diff-index --quiet --cached HEAD -- &&
- git diff-files --quiet
+ git diff-index --quiet --cached HEAD --ignore-submodules -- &&
+ git diff-files --quiet --ignore-submodules
}
clear_stash () {
@@ -86,7 +92,14 @@ create_stash () {
}
save_stash () {
- stash_msg="$1"
+ keep_index=
+ case "$1" in
+ --keep-index)
+ keep_index=t
+ shift
+ esac
+
+ stash_msg="$*"
if no_changes
then
@@ -104,6 +117,13 @@ save_stash () {
git update-ref -m "$stash_msg" $ref_stash $w_commit ||
die "Cannot save the current status"
printf 'Saved working directory and index state "%s"\n' "$stash_msg"
+
+ git reset --hard
+
+ if test -n "$keep_index" && test -n $i_tree
+ then
+ git read-tree --reset -u $i_tree
+ fi
}
have_stash () {
@@ -130,7 +150,7 @@ show_stash () {
}
apply_stash () {
- git diff-files --quiet ||
+ git diff-files --quiet --ignore-submodules ||
die 'Cannot restore on top of a dirty state'
unstash_index=
@@ -153,7 +173,8 @@ apply_stash () {
die "$*: no valid stashed state found"
unstashed_index_tree=
- if test -n "$unstash_index" && test "$b_tree" != "$i_tree"
+ if test -n "$unstash_index" && test "$b_tree" != "$i_tree" &&
+ test "$c_tree" != "$i_tree"
then
git diff-tree --binary $s^2^..$s^2 | git apply --cached
test $? -ne 0 &&
@@ -196,6 +217,45 @@ apply_stash () {
fi
}
+drop_stash () {
+ have_stash || die 'No stash entries to drop'
+
+ if test $# = 0
+ then
+ set x "$ref_stash@{0}"
+ shift
+ fi
+ # Verify supplied argument looks like a stash entry
+ s=$(git rev-parse --revs-only --no-flags "$@") &&
+ git rev-parse --verify "$s:" > /dev/null 2>&1 &&
+ git rev-parse --verify "$s^1:" > /dev/null 2>&1 &&
+ git rev-parse --verify "$s^2:" > /dev/null 2>&1 ||
+ die "$*: not a valid stashed state"
+
+ git reflog delete --updateref --rewrite "$@" &&
+ echo "Dropped $* ($s)" || die "$*: Could not drop stash entry"
+
+ # clear_stash if we just dropped the last stash entry
+ git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
+}
+
+apply_to_branch () {
+ have_stash || die 'Nothing to apply'
+
+ test -n "$1" || die 'No branch name specified'
+ branch=$1
+
+ if test -z "$2"
+ then
+ set x "$ref_stash@{0}"
+ fi
+ stash=$2
+
+ git-checkout -b $branch $stash^ &&
+ apply_stash --index $stash &&
+ drop_stash $stash
+}
+
# Main command set
case "$1" in
list)
@@ -213,7 +273,7 @@ show)
;;
save)
shift
- save_stash "$*" && git-reset --hard
+ save_stash "$@"
;;
apply)
shift
@@ -230,12 +290,27 @@ create)
fi
create_stash "$*" && echo "$w_commit"
;;
+drop)
+ shift
+ drop_stash "$@"
+ ;;
+pop)
+ shift
+ if apply_stash "$@"
+ then
+ test -z "$unstash_index" || shift
+ drop_stash "$@"
+ fi
+ ;;
+branch)
+ shift
+ apply_to_branch "$@"
+ ;;
*)
if test $# -eq 0
then
save_stash &&
- echo '(To restore them type "git stash apply")' &&
- git-reset --hard
+ echo '(To restore them type "git stash apply")'
else
usage
fi
diff --git a/git-submodule.sh b/git-submodule.sh
index ad9fe628f..b40f876a2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -4,16 +4,15 @@
#
# Copyright (c) 2007 Lars Hjemli
-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update] [--] [<path>...]'
+USAGE="[--quiet] [--cached] \
+[add <repo> [-b branch] <path>]|[status|init|update [-i|--init]|summary [-n|--summary-limit <n>] [<commit>]] \
+[--] [<path>...]"
OPTIONS_SPEC=
. git-sh-setup
require_work_tree
-add=
+command=
branch=
-init=
-update=
-status=
quiet=
cached=
@@ -28,26 +27,14 @@ say()
fi
}
-# NEEDSWORK: identical function exists in get_repo_base in clone.sh
-get_repo_base() {
- (
- cd "`/bin/pwd`" &&
- cd "$1" || cd "$1.git" &&
- {
- cd .git
- pwd
- }
- ) 2>/dev/null
-}
-
# Resolve relative url by appending to parent's url
resolve_relative_url ()
{
branch="$(git symbolic-ref HEAD 2>/dev/null)"
remote="$(git config branch.${branch#refs/heads/}.remote)"
remote="${remote:-origin}"
- remoteurl="$(git config remote.$remote.url)" ||
- die "remote ($remote) does not have a url in .git/config"
+ remoteurl=$(git config "remote.$remote.url") ||
+ die "remote ($remote) does not have a url defined in .git/config"
url="$1"
while test -n "$url"
do
@@ -74,9 +61,8 @@ resolve_relative_url ()
module_name()
{
# Do we have "submodule.<something>.path = $1" defined in .gitmodules file?
- re=$(printf '%s' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
- name=$( GIT_CONFIG=.gitmodules \
- git config --get-regexp '^submodule\..*\.path$' |
+ re=$(printf '%s\n' "$1" | sed -e 's/[].[^$\\*]/\\&/g')
+ name=$( git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
sed -n -e 's|^submodule\.\(.*\)\.path '"$re"'$|\1|p' )
test -z "$name" &&
die "No submodule mapping found in .gitmodules for path '$path'"
@@ -86,9 +72,9 @@ module_name()
#
# Clone a submodule
#
-# Prior to calling, modules_update checks that a possibly existing
+# Prior to calling, cmd_update checks that a possibly existing
# path is not a git repository.
-# Likewise, module_add checks that path does not exist at all,
+# Likewise, cmd_add checks that path does not exist at all,
# since it is the location of a new submodule.
#
module_clone()
@@ -117,54 +103,97 @@ module_clone()
#
# Add a new submodule to the working tree, .gitmodules and the index
#
-# $@ = repo [path]
+# $@ = repo path
#
# optional branch is stored in global branch variable
#
-module_add()
+cmd_add()
{
+ # parse $args after "submodule ... add".
+ while test $# -ne 0
+ do
+ case "$1" in
+ -b | --branch)
+ case "$2" in '') usage ;; esac
+ branch=$2
+ shift
+ ;;
+ -q|--quiet)
+ quiet=1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
repo=$1
path=$2
- if test -z "$repo"; then
+ if test -z "$repo" -o -z "$path"; then
usage
fi
+ # assure repo is absolute or relative to parent
case "$repo" in
./*|../*)
# dereference source url relative to parent's url
- realrepo="$(resolve_relative_url $repo)" ;;
- *)
- # Turn the source into an absolute path if
- # it is local
- if base=$(get_repo_base "$repo"); then
- repo="$base"
- fi
+ realrepo=$(resolve_relative_url "$repo") || exit
+ ;;
+ *:*|/*)
+ # absolute url
realrepo=$repo
;;
+ *)
+ die "repo URL: '$repo' must be absolute or begin with ./|../"
+ ;;
esac
- # Guess path from repo if not specified or strip trailing slashes
- if test -z "$path"; then
- path=$(echo "$repo" | sed -e 's|/*$||' -e 's|:*/*\.git$||' -e 's|.*[/:]||g')
- else
- path=$(echo "$path" | sed -e 's|/*$||')
- fi
-
- test -e "$path" &&
- die "'$path' already exists"
+ # strip trailing slashes from path
+ path=$(echo "$path" | sed -e 's|/*$||')
git ls-files --error-unmatch "$path" > /dev/null 2>&1 &&
die "'$path' already exists in the index"
- module_clone "$path" "$realrepo" || exit
- (unset GIT_DIR; cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
- die "Unable to checkout submodule '$path'"
+ # perhaps the path exists and is already a git repo, else clone it
+ if test -e "$path"
+ then
+ if test -d "$path"/.git -o -f "$path"/.git
+ then
+ echo "Adding existing repo at '$path' to the index"
+ else
+ die "'$path' already exists and is not a valid git repo"
+ fi
+
+ case "$repo" in
+ ./*|../*)
+ url=$(resolve_relative_url "$repo") || exit
+ ;;
+ *)
+ url="$repo"
+ ;;
+ esac
+ git config submodule."$path".url "$url"
+ else
+
+ module_clone "$path" "$realrepo" || exit
+ (unset GIT_DIR; cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) ||
+ die "Unable to checkout submodule '$path'"
+ fi
+
git add "$path" ||
die "Failed to add submodule '$path'"
- GIT_CONFIG=.gitmodules git config submodule."$path".path "$path" &&
- GIT_CONFIG=.gitmodules git config submodule."$path".url "$repo" &&
+ git config -f .gitmodules submodule."$path".path "$path" &&
+ git config -f .gitmodules submodule."$path".url "$repo" &&
git add .gitmodules ||
die "Failed to register submodule '$path'"
}
@@ -174,9 +203,30 @@ module_add()
#
# $@ = requested paths (default to all)
#
-modules_init()
+cmd_init()
{
- git ls-files --stage -- "$@" | grep -e '^160000 ' |
+ # parse $args after "submodule ... init".
+ while test $# -ne 0
+ do
+ case "$1" in
+ -q|--quiet)
+ quiet=1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ git ls-files --stage -- "$@" | grep '^160000 ' |
while read mode sha1 stage path
do
# Skip already registered paths
@@ -184,14 +234,14 @@ modules_init()
url=$(git config submodule."$name".url)
test -z "$url" || continue
- url=$(GIT_CONFIG=.gitmodules git config submodule."$name".url)
+ url=$(git config -f .gitmodules submodule."$name".url)
test -z "$url" &&
die "No url found for submodule path '$path' in .gitmodules"
# Possibly a url relative to parent
case "$url" in
./*|../*)
- url="$(resolve_relative_url "$url")"
+ url=$(resolve_relative_url "$url") || exit
;;
esac
@@ -207,9 +257,34 @@ modules_init()
#
# $@ = requested paths (default to all)
#
-modules_update()
+cmd_update()
{
- git ls-files --stage -- "$@" | grep -e '^160000 ' |
+ # parse $args after "submodule ... update".
+ while test $# -ne 0
+ do
+ case "$1" in
+ -q|--quiet)
+ shift
+ quiet=1
+ ;;
+ -i|--init)
+ shift
+ cmd_init "$@" || return
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
+ git ls-files --stage -- "$@" | grep '^160000 ' |
while read mode sha1 stage path
do
name=$(module_name "$path") || exit
@@ -220,10 +295,11 @@ modules_update()
# path have been specified
test "$#" != "0" &&
say "Submodule path '$path' not initialized"
+ say "Maybe you want to use 'update --init'?"
continue
fi
- if ! test -d "$path"/.git
+ if ! test -d "$path"/.git -o -f "$path"/.git
then
module_clone "$path" "$url" || exit
subsha1=
@@ -250,12 +326,193 @@ set_name_rev () {
cd "$1" && {
git describe "$2" 2>/dev/null ||
git describe --tags "$2" 2>/dev/null ||
- git describe --contains --tags "$2"
+ git describe --contains "$2" 2>/dev/null ||
+ git describe --all --always "$2"
}
) )
test -z "$revname" || revname=" ($revname)"
}
+#
+# Show commit summary for submodules in index or working tree
+#
+# If '--cached' is given, show summary between index and given commit,
+# or between working tree and given commit
+#
+# $@ = [commit (default 'HEAD'),] requested paths (default all)
+#
+cmd_summary() {
+ summary_limit=-1
+ for_status=
+ # parse $args after "submodule ... summary".
+ while test $# -ne 0
+ do
+ case "$1" in
+ --cached)
+ cached="$1"
+ ;;
+ --for-status)
+ for_status="$1"
+ ;;
+ -n|--summary-limit)
+ if summary_limit=$(($2 + 0)) 2>/dev/null && test "$summary_limit" = "$2"
+ then
+ :
+ else
+ usage
+ fi
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ test $summary_limit = 0 && return
+
+ if rev=$(git rev-parse --verify "$1^0" 2>/dev/null)
+ then
+ head=$rev
+ shift
+ else
+ head=HEAD
+ fi
+
+ cd_to_toplevel
+ # Get modified modules cared by user
+ modules=$(git diff-index $cached --raw $head -- "$@" |
+ grep -e '^:160000' -e '^:[0-7]* 160000' |
+ while read mod_src mod_dst sha1_src sha1_dst status name
+ do
+ # Always show modules deleted or type-changed (blob<->module)
+ test $status = D -o $status = T && echo "$name" && continue
+ # Also show added or modified modules which are checked out
+ GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
+ echo "$name"
+ done
+ )
+
+ test -z "$modules" && return
+
+ git diff-index $cached --raw $head -- $modules |
+ grep -e '^:160000' -e '^:[0-7]* 160000' |
+ cut -c2- |
+ while read mod_src mod_dst sha1_src sha1_dst status name
+ do
+ if test -z "$cached" &&
+ test $sha1_dst = 0000000000000000000000000000000000000000
+ then
+ case "$mod_dst" in
+ 160000)
+ sha1_dst=$(GIT_DIR="$name/.git" git rev-parse HEAD)
+ ;;
+ 100644 | 100755 | 120000)
+ sha1_dst=$(git hash-object $name)
+ ;;
+ 000000)
+ ;; # removed
+ *)
+ # unexpected type
+ echo >&2 "unexpected mode $mod_dst"
+ continue ;;
+ esac
+ fi
+ missing_src=
+ missing_dst=
+
+ test $mod_src = 160000 &&
+ ! GIT_DIR="$name/.git" git-rev-parse --verify $sha1_src^0 >/dev/null 2>&1 &&
+ missing_src=t
+
+ test $mod_dst = 160000 &&
+ ! GIT_DIR="$name/.git" git-rev-parse --verify $sha1_dst^0 >/dev/null 2>&1 &&
+ missing_dst=t
+
+ total_commits=
+ case "$missing_src,$missing_dst" in
+ t,)
+ errmsg=" Warn: $name doesn't contain commit $sha1_src"
+ ;;
+ ,t)
+ errmsg=" Warn: $name doesn't contain commit $sha1_dst"
+ ;;
+ t,t)
+ errmsg=" Warn: $name doesn't contain commits $sha1_src and $sha1_dst"
+ ;;
+ *)
+ errmsg=
+ total_commits=$(
+ if test $mod_src = 160000 -a $mod_dst = 160000
+ then
+ range="$sha1_src...$sha1_dst"
+ elif test $mod_src = 160000
+ then
+ range=$sha1_src
+ else
+ range=$sha1_dst
+ fi
+ GIT_DIR="$name/.git" \
+ git log --pretty=oneline --first-parent $range | wc -l
+ )
+ total_commits=" ($(($total_commits + 0)))"
+ ;;
+ esac
+
+ sha1_abbr_src=$(echo $sha1_src | cut -c1-7)
+ sha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)
+ if test $status = T
+ then
+ if test $mod_dst = 160000
+ then
+ echo "* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:"
+ else
+ echo "* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:"
+ fi
+ else
+ echo "* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:"
+ fi
+ if test -n "$errmsg"
+ then
+ # Don't give error msg for modification whose dst is not submodule
+ # i.e. deleted or changed to blob
+ test $mod_dst = 160000 && echo "$errmsg"
+ else
+ if test $mod_src = 160000 -a $mod_dst = 160000
+ then
+ limit=
+ test $summary_limit -gt 0 && limit="-$summary_limit"
+ GIT_DIR="$name/.git" \
+ git log $limit --pretty='format: %m %s' \
+ --first-parent $sha1_src...$sha1_dst
+ elif test $mod_dst = 160000
+ then
+ GIT_DIR="$name/.git" \
+ git log --pretty='format: > %s' -1 $sha1_dst
+ else
+ GIT_DIR="$name/.git" \
+ git log --pretty='format: < %s' -1 $sha1_src
+ fi
+ echo
+ fi
+ echo
+ done |
+ if test -n "$for_status"; then
+ echo "# Modified submodules:"
+ echo "#"
+ sed -e 's|^|# |' -e 's|^# $|#|'
+ else
+ cat
+ fi
+}
#
# List all submodules, prefixed with:
# - submodule not initialized
@@ -266,14 +523,38 @@ set_name_rev () {
#
# $@ = requested paths (default to all)
#
-modules_list()
+cmd_status()
{
- git ls-files --stage -- "$@" | grep -e '^160000 ' |
+ # parse $args after "submodule ... status".
+ while test $# -ne 0
+ do
+ case "$1" in
+ -q|--quiet)
+ quiet=1
+ ;;
+ --cached)
+ cached=1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ -*)
+ usage
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+ done
+
+ git ls-files --stage -- "$@" | grep '^160000 ' |
while read mode sha1 stage path
do
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
- if test -z "url" || ! test -d "$path"/.git
+ if test -z "$url" || ! test -d "$path"/.git -o -f "$path"/.git
then
say "-$sha1 $path"
continue;
@@ -293,20 +574,17 @@ modules_list()
done
}
-while test $# != 0
+# This loop parses the command line arguments to find the
+# subcommand name to dispatch. Parsing of the subcommand specific
+# options are primarily done by the subcommand implementations.
+# Subcommand specific options such as --branch and --cached are
+# parsed here as well, for backward compatibility.
+
+while test $# != 0 && test -z "$command"
do
case "$1" in
- add)
- add=1
- ;;
- init)
- init=1
- ;;
- update)
- update=1
- ;;
- status)
- status=1
+ add | init | update | status | summary)
+ command=$1
;;
-q|--quiet)
quiet=1
@@ -320,7 +598,7 @@ do
branch="$2"; shift
;;
--cached)
- cached=1
+ cached="$1"
;;
--)
break
@@ -335,30 +613,19 @@ do
shift
done
-case "$add,$branch" in
-1,*)
- ;;
-,)
- ;;
-,*)
+# No command word defaults to "status"
+test -n "$command" || command=status
+
+# "-b branch" is accepted only by "add"
+if test -n "$branch" && test "$command" != add
+then
usage
- ;;
-esac
+fi
-case "$add,$init,$update,$status,$cached" in
-1,,,,)
- module_add "$@"
- ;;
-,1,,,)
- modules_init "$@"
- ;;
-,,1,,)
- modules_update "$@"
- ;;
-,,,*,*)
- modules_list "$@"
- ;;
-*)
+# "--cached" is accepted only by "status" and "summary"
+if test -n "$cached" && test "$command" != status -a "$command" != summary
+then
usage
- ;;
-esac
+fi
+
+"cmd_$command" "$@"
diff --git a/git-svn.perl b/git-svn.perl
index 9f2b587b2..099fd02b3 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4,7 +4,7 @@
use warnings;
use strict;
use vars qw/ $AUTHOR $VERSION
- $sha1 $sha1_short $_revision
+ $sha1 $sha1_short $_revision $_repository
$_q $_authors %users/;
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
$VERSION = '@@GIT_VERSION@@';
@@ -65,7 +65,8 @@ my ($_stdin, $_help, $_edit,
$_template, $_shared,
$_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local,
- $_prefix, $_no_checkout, $_url, $_verbose);
+ $_prefix, $_no_checkout, $_url, $_verbose,
+ $_git_format, $_commit_url);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -82,6 +83,7 @@ my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'repack-flags|repack-args|repack-opts=s' =>
\$Git::SVN::_repack_flags,
'use-log-author' => \$Git::SVN::_use_log_author,
+ 'add-author-from' => \$Git::SVN::_add_author_from,
%remote_opts );
my ($_trunk, $_tags, $_branches, $_stdlayout);
@@ -125,6 +127,8 @@ my %cmd = (
'verbose|v' => \$_verbose,
'dry-run|n' => \$_dry_run,
'fetch-all|all' => \$_fetch_all,
+ 'commit-url=s' => \$_commit_url,
+ 'revision|r=i' => \$_revision,
'no-rebase' => \$_no_rebase,
%cmt_opts, %fc_opts } ],
'set-tree' => [ \&cmd_set_tree,
@@ -167,7 +171,8 @@ my %cmd = (
'color' => \$Git::SVN::Log::color,
'pager=s' => \$Git::SVN::Log::pager
} ],
- 'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish",
+ 'find-rev' => [ \&cmd_find_rev,
+ "Translate between SVN revision numbers and tree-ish",
{} ],
'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
{ 'merge|m|M' => \$_merge,
@@ -175,6 +180,7 @@ my %cmd = (
'strategy|s=s' => \$_strategy,
'local|l' => \$_local,
'fetch-all|all' => \$_fetch_all,
+ 'dry-run|n' => \$_dry_run,
%fc_opts } ],
'commit-diff' => [ \&cmd_commit_diff,
'Commit a diff between two trees',
@@ -186,6 +192,9 @@ my %cmd = (
"Show info about the latest SVN revision
on the current branch",
{ 'url' => \$_url, } ],
+ 'blame' => [ \&Git::SVN::Log::cmd_blame,
+ "Show what revision and author last modified each line of a file",
+ { 'git-format' => \$_git_format } ],
);
my $cmd;
@@ -217,12 +226,15 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
}
$ENV{GIT_DIR} = $git_dir;
}
+ $_repository = Git->repository(Repository => $ENV{GIT_DIR});
}
my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
read_repo_config(\%opts);
-Getopt::Long::Configure('pass_through') if ($cmd && $cmd eq 'log');
+if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
+ Getopt::Long::Configure('pass_through');
+}
my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,
'minimize-connections' => \$Git::SVN::Migration::_minimize,
'id|i=s' => \$Git::SVN::default_ref_id,
@@ -254,7 +266,7 @@ sub usage {
my $fd = $exit ? \*STDERR : \*STDOUT;
print $fd <<"";
git-svn - bidirectional operations between a single Subversion tree and git
-Usage: $0 <command> [options] [arguments]\n
+Usage: git svn <command> [options] [arguments]\n
print $fd "Available commands:\n" unless $cmd;
@@ -298,6 +310,7 @@ sub do_git_init_db {
}
}
command_noisy(@init_db);
+ $_repository = Git->repository(Repository => ".git");
}
my $set;
my $pfx = "svn-remote.$Git::SVN::default_repo_id";
@@ -314,6 +327,7 @@ sub init_subdir {
mkpath([$repo_path]) unless -d $repo_path;
chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
$ENV{GIT_DIR} = '.git';
+ $_repository = Git->repository(Repository => $ENV{GIT_DIR});
}
sub cmd_clone {
@@ -407,12 +421,15 @@ sub cmd_dcommit {
$head ||= 'HEAD';
my @refs;
my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
- print "Committing to $url ...\n";
+ $url = $_commit_url if defined $_commit_url;
+ my $last_rev = $_revision if defined $_revision;
+ if ($url) {
+ print "Committing to $url ...\n";
+ }
unless ($gs) {
die "Unable to determine upstream SVN information from ",
- "$head history\n";
+ "$head history.\nPerhaps the repository is empty.";
}
- my $last_rev;
my ($linear_refs, $parents) = linearize_history($gs, \@refs);
if ($_no_rebase && scalar(@$linear_refs) > 1) {
warn "Attempting to commit more than one change while ",
@@ -435,7 +452,7 @@ sub cmd_dcommit {
my $cmt_rev;
my %ed_opts = ( r => $last_rev,
log => get_commit_entry($d)->{log},
- ra => Git::SVN::Ra->new($gs->full_url),
+ ra => Git::SVN::Ra->new($url),
config => SVN::Core::config_get_config(
$Git::SVN::Ra::config_dir
),
@@ -519,19 +536,20 @@ sub cmd_dcommit {
}
sub cmd_find_rev {
- my $revision_or_hash = shift;
+ my $revision_or_hash = shift or die "SVN or git revision required ",
+ "as a command-line argument\n";
my $result;
if ($revision_or_hash =~ /^r\d+$/) {
my $head = shift;
$head ||= 'HEAD';
my @refs;
- my (undef, undef, undef, $gs) = working_head_info($head, \@refs);
+ my (undef, undef, $uuid, $gs) = working_head_info($head, \@refs);
unless ($gs) {
die "Unable to determine upstream SVN information from ",
"$head history\n";
}
my $desired_revision = substr($revision_or_hash, 1);
- $result = $gs->rev_map_get($desired_revision);
+ $result = $gs->rev_map_get($desired_revision, $uuid);
} else {
my (undef, $rev, undef) = cmt_metadata($revision_or_hash);
$result = $rev;
@@ -546,6 +564,11 @@ sub cmd_rebase {
die "Unable to determine upstream SVN information from ",
"working tree history\n";
}
+ if ($_dry_run) {
+ print "Remote Branch: " . $gs->refname . "\n";
+ print "SVN URL: " . $url . "\n";
+ return;
+ }
if (command(qw/diff-index HEAD --/)) {
print STDERR "Cannot rebase with uncommited changes:\n";
command_noisy('status');
@@ -608,7 +631,7 @@ sub cmd_create_ignore {
print GITIGNORE "$s\n";
close(GITIGNORE)
or fatal("Failed to close `$ignore': $!");
- command_noisy('add', $ignore);
+ command_noisy('add', '-f', $ignore);
});
}
@@ -626,6 +649,8 @@ sub canonicalize_path {
$path =~ s#/[^/]+/\.\.##g;
$path =~ s#/$##g;
$path =~ s#^\./## if $dot_slash_added;
+ $path =~ s#^/##;
+ $path =~ s#^\.$##;
return $path;
}
@@ -734,7 +759,7 @@ sub cmd_commit_diff {
my $usage = "Usage: $0 commit-diff -r<revision> ".
"<tree-ish> <tree-ish> [<URL>]";
fatal($usage) if (!defined $ta || !defined $tb);
- my $svn_path;
+ my $svn_path = '';
if (!defined $url) {
my $gs = eval { Git::SVN->new };
if (!$gs) {
@@ -758,7 +783,6 @@ sub cmd_commit_diff {
$_message ||= get_commit_entry($tb)->{log};
}
my $ra ||= Git::SVN::Ra->new($url);
- $svn_path ||= $ra->{svn_path};
my $r = $_revision;
if ($r eq 'HEAD') {
$r = $ra->get_latest_revnum;
@@ -778,8 +802,8 @@ sub cmd_commit_diff {
}
sub cmd_info {
- my $path = canonicalize_path(shift or ".");
- unless (scalar(@_) == 0) {
+ my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
+ if (exists $_[1]) {
die "Too many arguments specified\n";
}
@@ -795,6 +819,10 @@ sub cmd_info {
die "Unable to determine upstream SVN information from ",
"working tree history\n";
}
+
+ # canonicalize_path() will return "" to make libsvn 1.5.x happy,
+ $path = "." if $path eq "";
+
my $full_url = $url . ($path eq "." ? "" : "/$path");
if ($_url) {
@@ -954,15 +982,18 @@ sub complete_url_ls_init {
"wanted to set to: $gs->{url}\n";
}
command_oneline('config', $k, $gs->{url}) unless $orig_url;
- my $remote_path = "$ra->{svn_path}/$repo_path/*";
+ my $remote_path = "$ra->{svn_path}/$repo_path";
$remote_path =~ s#/+#/#g;
$remote_path =~ s#^/##g;
+ $remote_path .= "/*" if $remote_path !~ /\*/;
my ($n) = ($switch =~ /^--(\w+)/);
if (length $pfx && $pfx !~ m#/$#) {
die "--prefix='$pfx' must have a trailing slash '/'\n";
}
- command_noisy('config', "svn-remote.$gs->{repo_id}.$n",
- "$remote_path:refs/remotes/$pfx*");
+ command_noisy('config',
+ "svn-remote.$gs->{repo_id}.$n",
+ "$remote_path:refs/remotes/$pfx*" .
+ ('/*' x (($remote_path =~ tr/*/*/) - 1)) );
}
sub verify_ref {
@@ -1004,17 +1035,30 @@ sub get_commit_entry {
my ($msg_fh, $ctx) = command_output_pipe('cat-file',
$type, $treeish);
my $in_msg = 0;
+ my $author;
+ my $saw_from = 0;
+ my $msgbuf = "";
while (<$msg_fh>) {
if (!$in_msg) {
$in_msg = 1 if (/^\s*$/);
+ $author = $1 if (/^author (.*>)/);
} elsif (/^git-svn-id: /) {
# skip this for now, we regenerate the
# correct one on re-fetch anyways
# TODO: set *:merge properties or like...
} else {
- print $log_fh $_ or croak $!;
+ if (/^From:/ || /^Signed-off-by:/) {
+ $saw_from = 1;
+ }
+ $msgbuf .= $_;
}
}
+ $msgbuf =~ s/\s+$//s;
+ if ($Git::SVN::_add_author_from && defined($author)
+ && !$saw_from) {
+ $msgbuf .= "\n\nFrom: $author";
+ }
+ print $log_fh $msgbuf or croak $!;
command_close_pipe($msg_fh, $ctx);
}
close $log_fh or croak $!;
@@ -1115,7 +1159,7 @@ sub cmt_metadata {
sub working_head_info {
my ($head, $refs) = @_;
- my @args = ('log', '--no-color', '--first-parent');
+ my @args = ('log', '--no-color', '--first-parent', '--pretty=medium');
my ($fh, $ctx) = command_output_pipe(@args, $head);
my $hash;
my %max;
@@ -1130,7 +1174,7 @@ sub working_head_info {
if (defined $url && defined $rev) {
next if $max{$url} and $max{$url} < $rev;
if (my $gs = Git::SVN->find_by_url($url)) {
- my $c = $gs->rev_map_get($rev);
+ my $c = $gs->rev_map_get($rev, $uuid);
if ($c && $c eq $hash) {
close $fh; # break the pipe
return ($url, $rev, $uuid, $gs);
@@ -1194,7 +1238,7 @@ sub linearize_history {
sub find_file_type_and_diff_status {
my ($path) = @_;
- return ('dir', '') if $path eq '.';
+ return ('dir', '') if $path eq '';
my $diff_output =
command_oneline(qw(diff --cached --name-status --), $path) || "";
@@ -1221,7 +1265,7 @@ sub md5sum {
my $arg = shift;
my $ref = ref $arg;
my $md5 = Digest::MD5->new();
- if ($ref eq 'GLOB' || $ref eq 'IO::File') {
+ if ($ref eq 'GLOB' || $ref eq 'IO::File' || $ref eq 'File::Temp') {
$md5->addfile($arg) or croak $!;
} elsif ($ref eq 'SCALAR') {
$md5->add($$arg) or croak $!;
@@ -1241,13 +1285,14 @@ use constant rev_map_fmt => 'NH40';
use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
$_repack $_repack_flags $_use_svm_props $_head
$_use_svnsync_props $no_reuse_existing $_minimize_url
- $_use_log_author/;
+ $_use_log_author $_add_author_from/;
use Carp qw/croak/;
use File::Path qw/mkpath/;
use File::Copy qw/copy/;
use IPC::Open3;
-my $_repack_nr;
+my ($_gc_nr, $_gc_period);
+
# properties that we do not log:
my %SKIP_PROP;
BEGIN {
@@ -1283,6 +1328,7 @@ BEGIN {
}
}
+
my (%LOCKFILES, %INDEX_FILES);
END {
unlink keys %LOCKFILES if %LOCKFILES;
@@ -1383,11 +1429,21 @@ sub fetch_all {
sub read_all_remotes {
my $r = {};
+ my $use_svm_props = eval { command_oneline(qw/config --bool
+ svn.useSvmProps/) };
+ $use_svm_props = $use_svm_props eq 'true' if $use_svm_props;
foreach (grep { s/^svn-remote\.// } command(qw/config -l/)) {
- if (m!^(.+)\.fetch=\s*(.*)\s*:\s*refs/remotes/(.+)\s*$!) {
- my ($remote, $local_ref, $remote_ref) = ($1, $2, $3);
+ if (m!^(.+)\.fetch=\s*(.*)\s*:\s*(.+)\s*$!) {
+ my ($remote, $local_ref, $_remote_ref) = ($1, $2, $3);
+ die("svn-remote.$remote: remote ref '$_remote_ref' "
+ . "must start with 'refs/remotes/'\n")
+ unless $_remote_ref =~ m{^refs/remotes/(.+)};
+ my $remote_ref = $1;
$local_ref =~ s{^/}{};
$r->{$remote}->{fetch}->{$local_ref} = $remote_ref;
+ $r->{$remote}->{svm} = {} if $use_svm_props;
+ } elsif (m!^(.+)\.usesvmprops=\s*(.*)\s*$!) {
+ $r->{$1}->{svm} = {};
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
$r->{$1}->{url} = $2;
} elsif (m!^(.+)\.(branches|tags)=
@@ -1404,14 +1460,30 @@ sub read_all_remotes {
}
}
}
+
+ map {
+ if (defined $r->{$_}->{svm}) {
+ my $svm;
+ eval {
+ my $section = "svn-remote.$_";
+ $svm = {
+ source => tmp_config('--get',
+ "$section.svm-source"),
+ replace => tmp_config('--get',
+ "$section.svm-replace"),
+ }
+ };
+ $r->{$_}->{svm} = $svm;
+ }
+ } keys %$r;
+
$r;
}
sub init_vars {
- if (defined $_repack) {
- $_repack = 1000 if ($_repack <= 0);
- $_repack_nr = $_repack;
- $_repack_flags ||= '-d';
+ $_gc_nr = $_gc_period = 1000;
+ if (defined $_repack || defined $_repack_flags) {
+ warn "Repack options are obsolete; they have no effect.\n";
}
}
@@ -1432,13 +1504,6 @@ sub verify_remotes_sanity {
}
}
-# we allow more chars than remotes2config.sh...
-sub sanitize_remote_name {
- my ($name) = @_;
- $name =~ tr{A-Za-z0-9:,/+-}{.}c;
- $name;
-}
-
sub find_existing_remote {
my ($url, $remotes) = @_;
return undef if $no_reuse_existing;
@@ -1537,9 +1602,22 @@ sub find_by_url { # repos_root and, path are optional
$remotes->{$repo_id}->{$_});
}
my $p = $path;
+ my $rwr = rewrite_root({repo_id => $repo_id});
+ my $svm = $remotes->{$repo_id}->{svm}
+ if defined $remotes->{$repo_id}->{svm};
unless (defined $p) {
$p = $full_url;
- $p =~ s#^\Q$u\E(?:/|$)## or next;
+ my $z = $u;
+ my $prefix = '';
+ if ($rwr) {
+ $z = $rwr;
+ } elsif (defined $svm) {
+ $z = $svm->{source};
+ $prefix = $svm->{replace};
+ $prefix =~ s#^\Q$u\E(?:/|$)##;
+ $prefix =~ s#/$##;
+ }
+ $p =~ s#^\Q$z\E(?:/|$)#$prefix# or next;
}
foreach my $f (keys %$fetch) {
next if $f ne $p;
@@ -1890,7 +1968,7 @@ sub prop_walk {
foreach (sort keys %$dirent) {
next if $dirent->{$_}->{kind} != $SVN::Node::dir;
- $self->prop_walk($path . '/' . $_, $rev, $sub);
+ $self->prop_walk($self->{path} . $p . $_, $rev, $sub);
}
}
@@ -2098,6 +2176,10 @@ sub restore_commit_header_env {
}
}
+sub gc {
+ command_noisy('gc', '--auto');
+};
+
sub do_git_commit {
my ($self, $log_entry) = @_;
my $lr = $self->last_rev;
@@ -2151,12 +2233,9 @@ sub do_git_commit {
0, $self->svm_uuid);
}
print " = $commit ($self->{ref_id})\n";
- if (defined $_repack && (--$_repack_nr == 0)) {
- $_repack_nr = $_repack;
- # repack doesn't use any arguments with spaces in them, does it?
- print "Running git repack $_repack_flags ...\n";
- command_noisy('repack', split(/\s+/, $_repack_flags));
- print "Done repacking\n";
+ if (--$_gc_nr == 0) {
+ $_gc_nr = $_gc_period;
+ gc();
}
return $commit;
}
@@ -2228,7 +2307,13 @@ sub find_parent_branch {
# just grow a tail if we're not unique enough :x
$ref_id .= '-' while find_ref($ref_id);
print STDERR "Initializing parent: $ref_id\n";
- $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
+ my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
+ if ($u =~ s#^\Q$url\E(/|$)##) {
+ $p = $u;
+ $u = $url;
+ $repo_id = $self->{repo_id};
+ }
+ $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
}
my ($r0, $parent) = $gs->find_rev_before($r, 1);
if (!defined $r0 || !defined $parent) {
@@ -2358,8 +2443,7 @@ sub check_author {
my ($author) = @_;
if (!defined $author || length $author == 0) {
$author = '(no author)';
- }
- if (defined $::_authors && ! defined $::users{$author}) {
+ } elsif (defined $::_authors && ! defined $::users{$author}) {
die "Author: $author not defined in $::_authors file\n";
}
$author;
@@ -2410,13 +2494,15 @@ sub make_log_entry {
$name_field = $1;
}
if (!defined $name_field) {
- #
+ if (!defined $email) {
+ $email = $name;
+ }
} elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
($name, $email) = ($1, $2);
} elsif ($name_field =~ /(.*)@/) {
($name, $email) = ($1, $name_field);
} else {
- ($name, $email) = ($name_field, 'unknown');
+ ($name, $email) = ($name_field, $name_field);
}
}
if (defined $headrev && $self->use_svm_props) {
@@ -2502,6 +2588,7 @@ sub rebuild_from_rev_db {
my ($self, $path) = @_;
my $r = -1;
open my $fh, '<', $path or croak "open: $!";
+ binmode $fh or croak "binmode: $!";
while (<$fh>) {
length($_) == 41 or croak "inconsistent size in ($_) != 41";
chomp($_);
@@ -2533,8 +2620,8 @@ sub rebuild {
my ($log, $ctx) =
command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,
$self->refname, '--');
- my $full_url = $self->full_url;
- remove_username($full_url);
+ my $metadata_url = $self->metadata_url;
+ remove_username($metadata_url);
my $svn_uuid = $self->ra_uuid;
my $c;
while (<$log>) {
@@ -2552,7 +2639,7 @@ sub rebuild {
# if we merged or otherwise started elsewhere, this is
# how we break out of it
if (($uuid ne $svn_uuid) ||
- ($full_url && $url && ($url ne $full_url))) {
+ ($metadata_url && $url && ($url ne $metadata_url))) {
next;
}
@@ -2599,6 +2686,7 @@ sub rebuild {
sub _rev_map_set {
my ($fh, $rev, $commit) = @_;
+ binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size";
@@ -2702,6 +2790,7 @@ sub rev_map_max {
my $map_path = $self->map_path;
stat $map_path or return $want_commit ? (0, undef) : 0;
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+ binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size";
@@ -2734,6 +2823,7 @@ sub rev_map_get {
return undef unless -e $map_path;
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+ binmode $fh or croak "binmode: $!";
my $size = (stat($fh))[7];
($size % 24) == 0 or croak "inconsistent size: $size";
@@ -2806,7 +2896,7 @@ sub _new {
unless (defined $ref_id && length $ref_id) {
$_[2] = $ref_id = $Git::SVN::default_ref_id;
}
- $_[1] = $repo_id = sanitize_remote_name($repo_id);
+ $_[1] = $repo_id;
my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
$_[3] = $path = '' unless (defined $path);
mkpath(["$ENV{GIT_DIR}/svn"]);
@@ -2993,6 +3083,7 @@ use vars qw/@ISA/;
use strict;
use warnings;
use Carp qw/croak/;
+use File::Temp qw/tempfile/;
use IO::File qw//;
# file baton members: path, mode_a, mode_b, pool, fh, blob, base
@@ -3140,22 +3231,15 @@ sub change_file_prop {
sub apply_textdelta {
my ($self, $fb, $exp) = @_;
- my $fh = IO::File->new_tmpfile;
- $fh->autoflush(1);
+ my $fh = Git::temp_acquire('svn_delta');
# $fh gets auto-closed() by SVN::TxDelta::apply(),
# (but $base does not,) so dup() it for reading in close_file
open my $dup, '<&', $fh or croak $!;
- my $base = IO::File->new_tmpfile;
- $base->autoflush(1);
+ my $base = Git::temp_acquire('git_blob');
if ($fb->{blob}) {
- defined (my $pid = fork) or croak $!;
- if (!$pid) {
- open STDOUT, '>&', $base or croak $!;
- print STDOUT 'link ' if ($fb->{mode_a} == 120000);
- exec qw/git-cat-file blob/, $fb->{blob} or croak $!;
- }
- waitpid $pid, 0;
- croak $? if $?;
+ print $base 'link ' if ($fb->{mode_a} == 120000);
+ my $size = $::_repository->cat_blob($fb->{blob}, $base);
+ die "Failed to read object $fb->{blob}" if ($size < 0);
if (defined $exp) {
seek $base, 0, 0 or croak $!;
@@ -3166,9 +3250,9 @@ sub apply_textdelta {
}
}
seek $base, 0, 0 or croak $!;
- $fb->{fh} = $dup;
+ $fb->{fh} = $fh;
$fb->{base} = $base;
- [ SVN::TxDelta::apply($base, $fh, undef, $fb->{path}, $fb->{pool}) ];
+ [ SVN::TxDelta::apply($base, $dup, undef, $fb->{path}, $fb->{pool}) ];
}
sub close_file {
@@ -3184,28 +3268,36 @@ sub close_file {
"expected: $exp\n got: $got\n";
}
}
- sysseek($fh, 0, 0) or croak $!;
if ($fb->{mode_b} == 120000) {
- eval {
- sysread($fh, my $buf, 5) == 5 or croak $!;
- $buf eq 'link ' or die "$path has mode 120000",
- " but is not a link";
- };
- if ($@) {
- warn "$@\n";
- sysseek($fh, 0, 0) or croak $!;
+ sysseek($fh, 0, 0) or croak $!;
+ sysread($fh, my $buf, 5) == 5 or croak $!;
+
+ unless ($buf eq 'link ') {
+ warn "$path has mode 120000",
+ " but is not a link\n";
+ } else {
+ my $tmp_fh = Git::temp_acquire('svn_hash');
+ my $res;
+ while ($res = sysread($fh, my $str, 1024)) {
+ my $out = syswrite($tmp_fh, $str, $res);
+ defined($out) && $out == $res
+ or croak("write ",
+ $tmp_fh->filename,
+ ": $!\n");
+ }
+ defined $res or croak $!;
+
+ ($fh, $tmp_fh) = ($tmp_fh, $fh);
+ Git::temp_release($tmp_fh, 1);
}
}
- defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
- if (!$pid) {
- open STDIN, '<&', $fh or croak $!;
- exec qw/git-hash-object -w --stdin/ or croak $!;
- }
- chomp($hash = do { local $/; <$out> });
- close $out or croak $!;
- close $fh or croak $!;
+
+ $hash = $::_repository->hash_and_insert_object(
+ $fh->filename);
$hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
- close $fb->{base} or croak $!;
+
+ Git::temp_release($fb->{base}, 1);
+ Git::temp_release($fh, 1);
} else {
$hash = $fb->{blob} or die "no blob information\n";
}
@@ -3264,6 +3356,7 @@ sub new {
$self->{rm} = { };
$self->{path_prefix} = length $self->{svn_path} ?
"$self->{svn_path}/" : '';
+ $self->{config} = $opts->{config};
return $self;
}
@@ -3452,6 +3545,57 @@ sub ensure_path {
return $bat->{$c};
}
+# Subroutine to convert a globbing pattern to a regular expression.
+# From perl cookbook.
+sub glob2pat {
+ my $globstr = shift;
+ my %patmap = ('*' => '.*', '?' => '.', '[' => '[', ']' => ']');
+ $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge;
+ return '^' . $globstr . '$';
+}
+
+sub check_autoprop {
+ my ($self, $pattern, $properties, $file, $fbat) = @_;
+ # Convert the globbing pattern to a regular expression.
+ my $regex = glob2pat($pattern);
+ # Check if the pattern matches the file name.
+ if($file =~ m/($regex)/) {
+ # Parse the list of properties to set.
+ my @props = split(/;/, $properties);
+ foreach my $prop (@props) {
+ # Parse 'name=value' syntax and set the property.
+ if ($prop =~ /([^=]+)=(.*)/) {
+ my ($n,$v) = ($1,$2);
+ for ($n, $v) {
+ s/^\s+//; s/\s+$//;
+ }
+ $self->change_file_prop($fbat, $n, $v);
+ }
+ }
+ }
+}
+
+sub apply_autoprops {
+ my ($self, $file, $fbat) = @_;
+ my $conf_t = ${$self->{config}}{'config'};
+ no warnings 'once';
+ # Check [miscellany]/enable-auto-props in svn configuration.
+ if (SVN::_Core::svn_config_get_bool(
+ $conf_t,
+ $SVN::_Core::SVN_CONFIG_SECTION_MISCELLANY,
+ $SVN::_Core::SVN_CONFIG_OPTION_ENABLE_AUTO_PROPS,
+ 0)) {
+ # Auto-props are enabled. Enumerate them to look for matches.
+ my $callback = sub {
+ $self->check_autoprop($_[0], $_[1], $file, $fbat);
+ };
+ SVN::_Core::svn_config_enumerate(
+ $conf_t,
+ $SVN::_Core::SVN_CONFIG_SECTION_AUTO_PROPS,
+ $callback);
+ }
+}
+
sub A {
my ($self, $m) = @_;
my ($dir, $file) = split_path($m->{file_b});
@@ -3459,6 +3603,7 @@ sub A {
my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat,
undef, -1);
print "\tA\t$m->{file_b}\n" unless $::_q;
+ $self->apply_autoprops($file, $fbat);
$self->chg_file($fbat, $m);
$self->close_file($fbat,undef,$self->{pool});
}
@@ -3522,20 +3667,15 @@ sub chg_file {
} elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
$self->change_file_prop($fbat,'svn:executable',undef);
}
- my $fh = IO::File->new_tmpfile or croak $!;
+ my $fh = Git::temp_acquire('git_blob');
if ($m->{mode_b} =~ /^120/) {
print $fh 'link ' or croak $!;
$self->change_file_prop($fbat,'svn:special','*');
} elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
$self->change_file_prop($fbat,'svn:special',undef);
}
- defined(my $pid = fork) or croak $!;
- if (!$pid) {
- open STDOUT, '>&', $fh or croak $!;
- exec qw/git-cat-file blob/, $m->{sha1_b} or croak $!;
- }
- waitpid $pid, 0;
- croak $? if $?;
+ my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
+ croak "Failed to read object $m->{sha1_b}" if ($size < 0);
$fh->flush == 0 or croak $!;
seek $fh, 0, 0 or croak $!;
@@ -3546,9 +3686,8 @@ sub chg_file {
my $atd = $self->apply_textdelta($fbat, undef, $pool);
my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);
die "Checksum mismatch\nexpected: $exp\ngot: $got\n" if ($got ne $exp);
+ Git::temp_release($fh, 1);
$pool->clear;
-
- close $fh or croak $!;
}
sub D {
@@ -3634,6 +3773,7 @@ sub _auth_providers () {
SVN::Client::get_ssl_client_cert_file_provider(),
SVN::Client::get_ssl_client_cert_prompt_provider(
\&Git::SVN::Prompt::ssl_client_cert, 2),
+ SVN::Client::get_ssl_client_cert_pw_file_provider(),
SVN::Client::get_ssl_client_cert_pw_prompt_provider(
\&Git::SVN::Prompt::ssl_client_cert_pw, 2),
SVN::Client::get_username_provider(),
@@ -3648,7 +3788,7 @@ sub escape_uri_only {
my ($uri) = @_;
my @tmp;
foreach (split m{/}, $uri) {
- s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
+ s/([^\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
push @tmp, $_;
}
join('/', @tmp);
@@ -3985,6 +4125,28 @@ sub gs_fetch_loop_common {
$max += $inc;
$max = $head if ($max > $head);
}
+ Git::SVN::gc();
+}
+
+sub get_dir_globbed {
+ my ($self, $left, $depth, $r) = @_;
+
+ my @x = eval { $self->get_dir($left, $r) };
+ return unless scalar @x == 3;
+ my $dirents = $x[0];
+ my @finalents;
+ foreach my $de (keys %$dirents) {
+ next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+ if ($depth > 1) {
+ my @args = ("$left/$de", $depth - 1, $r);
+ foreach my $dir ($self->get_dir_globbed(@args)) {
+ push @finalents, "$de/$dir";
+ }
+ } else {
+ push @finalents, $de;
+ }
+ }
+ @finalents;
}
sub match_globs {
@@ -3992,11 +4154,12 @@ sub match_globs {
sub get_dir_check {
my ($self, $exists, $g, $r) = @_;
- my @x = eval { $self->get_dir($g->{path}->{left}, $r) };
- return unless scalar @x == 3;
- my $dirents = $x[0];
- foreach my $de (keys %$dirents) {
- next if $dirents->{$de}->{kind} != $SVN::Node::dir;
+
+ my @dirs = $self->get_dir_globbed($g->{path}->{left},
+ $g->{path}->{depth},
+ $r);
+
+ foreach my $de (@dirs) {
my $p = $g->{path}->full_path($de);
next if $exists->{$p};
next if (length $g->{path}->{right} &&
@@ -4441,6 +4604,56 @@ out:
print commit_log_separator unless $incremental || $oneline;
}
+sub cmd_blame {
+ my $path = pop;
+
+ config_pager();
+ run_pager();
+
+ my ($fh, $ctx, $rev);
+
+ if ($_git_format) {
+ ($fh, $ctx) = command_output_pipe('blame', @_, $path);
+ while (my $line = <$fh>) {
+ if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
+ # Uncommitted edits show up as a rev ID of
+ # all zeros, which we can't look up with
+ # cmt_metadata
+ if ($1 !~ /^0+$/) {
+ (undef, $rev, undef) =
+ ::cmt_metadata($1);
+ $rev = '0' if (!$rev);
+ } else {
+ $rev = '0';
+ }
+ $rev = sprintf('%-10s', $rev);
+ $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
+ }
+ print $line;
+ }
+ } else {
+ ($fh, $ctx) = command_output_pipe('blame', '-p', @_, 'HEAD',
+ '--', $path);
+ my ($sha1);
+ my %authors;
+ while (my $line = <$fh>) {
+ if ($line =~ /^([[:xdigit:]]{40})\s\d+\s\d+/) {
+ $sha1 = $1;
+ (undef, $rev, undef) = ::cmt_metadata($1);
+ $rev = '0' if (!$rev);
+ }
+ elsif ($line =~ /^author (.*)/) {
+ $authors{$rev} = $1;
+ $authors{$rev} =~ s/\s/_/g;
+ }
+ elsif ($line =~ /^\t(.*)$/) {
+ printf("%6s %10s %s\n", $rev, $authors{$rev}, $1);
+ }
+ }
+ }
+ command_close_pipe($fh, $ctx);
+}
+
package Git::SVN::Migration;
# these version numbers do NOT correspond to actual version numbers
# of git nor git-svn. They are just relative.
@@ -4527,7 +4740,7 @@ sub migrate_from_v1 {
mkpath([$svn_dir]);
print STDERR "Data from a previous version of git-svn exists, but\n\t",
"$svn_dir\n\t(required for this version ",
- "($::VERSION) of git-svn) does not. exist\n";
+ "($::VERSION) of git-svn) does not exist.\n";
my ($fh, $ctx) = command_output_pipe(qw/rev-parse --symbolic --all/);
while (<$fh>) {
my $x = $_;
@@ -4610,8 +4823,7 @@ sub minimize_connections {
# skip existing cases where we already connect to the root
if (($ra->{url} eq $ra->{repos_root}) ||
- (Git::SVN::sanitize_remote_name($ra->{repos_root}) eq
- $repo_id)) {
+ ($ra->{repos_root} eq $repo_id)) {
$root_repos->{$ra->{url}} = $repo_id;
next;
}
@@ -4650,8 +4862,7 @@ sub minimize_connections {
foreach my $url (keys %$new_urls) {
# see if we can re-use an existing [svn-remote "repo_id"]
# instead of creating a(n ugly) new section:
- my $repo_id = $root_repos->{$url} ||
- Git::SVN::sanitize_remote_name($url);
+ my $repo_id = $root_repos->{$url} || $url;
my $fetch = $new_urls->{$url};
foreach my $path (keys %$fetch) {
@@ -4730,15 +4941,20 @@ sub new {
my ($class, $glob) = @_;
my $re = $glob;
$re =~ s!/+$!!g; # no need for trailing slashes
- my $nr = ($re =~ s!^(.*)\*(.*)$!\(\[^/\]+\)!g);
- my ($left, $right) = ($1, $2);
- if ($nr > 1) {
- die "Only one '*' wildcard expansion ",
- "is supported (got $nr): '$glob'\n";
- } elsif ($nr == 0) {
+ $re =~ m!^([^*]*)(\*(?:/\*)*)([^*]*)$!;
+ my $temp = $re;
+ my ($left, $right) = ($1, $3);
+ $re = $2;
+ my $depth = $re =~ tr/*/*/;
+ if ($depth != $temp =~ tr/*/*/) {
+ die "Only one set of wildcard directories " .
+ "(e.g. '*' or '*/*/*') is supported: '$glob'\n";
+ }
+ if ($depth == 0) {
die "One '*' is needed for glob: '$glob'\n";
}
- $re = quotemeta($left) . $re . quotemeta($right);
+ $re =~ s!\*!\[^/\]*!g;
+ $re = quotemeta($left) . "($re)" . quotemeta($right);
if (length $left && !($left =~ s!/+$!!g)) {
die "Missing trailing '/' on left side of: '$glob' ($left)\n";
}
@@ -4747,7 +4963,7 @@ sub new {
}
my $left_re = qr/^\/\Q$left\E(\/|$)/;
bless { left => $left, right => $right, left_regex => $left_re,
- regex => qr/$re/, glob => $glob }, $class;
+ regex => qr/$re/, glob => $glob, depth => $depth }, $class;
}
sub full_path {
diff --git a/git-help--browse.sh b/git-web--browse.sh
index 10b0a36a3..384148a59 100755
--- a/git-help--browse.sh
+++ b/git-web--browse.sh
@@ -16,31 +16,32 @@
# git maintainer.
#
-USAGE='[--browser=browser|--tool=browser] [cmd to display] ...'
+USAGE='[--browser=browser|--tool=browser] [--config=conf.var] url/file ...'
# This must be capable of running outside of git directory, so
# the vanilla git-sh-setup should not be used.
NONGIT_OK=Yes
. git-sh-setup
-# Install data.
-html_dir="@@HTMLDIR@@"
-
-test -f "$html_dir/git.html" || die "No documentation directory found."
+valid_custom_tool()
+{
+ browser_cmd="$(git config "browser.$1.cmd")"
+ test -n "$browser_cmd"
+}
valid_tool() {
case "$1" in
- firefox | iceweasel | konqueror | w3m | links | lynx | dillo)
+ firefox | iceweasel | konqueror | w3m | links | lynx | dillo | open)
;; # happy
*)
- return 1
+ valid_custom_tool "$1" || return 1
;;
esac
}
init_browser_path() {
- browser_path=`git config browser.$1.path`
- test -z "$browser_path" && browser_path=$1
+ browser_path=$(git config "browser.$1.path")
+ test -z "$browser_path" && browser_path="$1"
}
while test $# != 0
@@ -58,6 +59,18 @@ do
shift ;;
esac
;;
+ -c|--config*)
+ case "$#,$1" in
+ *,*=*)
+ conf=`expr "z$1" : 'z-[^=]*=\(.*\)'`
+ ;;
+ 1,*)
+ usage ;;
+ *)
+ conf="$2"
+ shift ;;
+ esac
+ ;;
--)
break
;;
@@ -71,17 +84,20 @@ do
shift
done
+test $# = 0 && usage
+
if test -z "$browser"
then
- for opt in "help.browser" "web.browser"
+ for opt in "$conf" "web.browser"
do
+ test -z "$opt" && continue
browser="`git config $opt`"
test -z "$browser" || break
done
if test -n "$browser" && ! valid_tool "$browser"; then
- echo >&2 "git config option $opt set to unknown browser: $browser"
- echo >&2 "Resetting to default..."
- unset browser
+ echo >&2 "git config option $opt set to unknown browser: $browser"
+ echo >&2 "Resetting to default..."
+ unset browser
fi
fi
@@ -94,6 +110,10 @@ if test -z "$browser" ; then
else
browser_candidates="w3m links lynx"
fi
+ # SECURITYSESSIONID indicates an OS X GUI login session
+ if test -n "$SECURITYSESSIONID"; then
+ browser_candidates="open $browser_candidates"
+ fi
for i in $browser_candidates; do
init_browser_path $i
@@ -108,21 +128,18 @@ else
init_browser_path "$browser"
- if ! type "$browser_path" > /dev/null 2>&1; then
+ if test -z "$browser_cmd" && ! type "$browser_path" > /dev/null 2>&1; then
die "The browser $browser is not available as '$browser_path'."
fi
fi
-pages=$(for p in "$@"; do echo "$html_dir/$p.html" ; done)
-test -z "$pages" && pages="$html_dir/git.html"
-
case "$browser" in
firefox|iceweasel)
# Check version because firefox < 2.0 does not support "-new-tab".
vers=$(expr "$($browser_path -version)" : '.* \([0-9][0-9]*\)\..*')
NEWTAB='-new-tab'
test "$vers" -lt 2 && NEWTAB=''
- nohup "$browser_path" $NEWTAB $pages &
+ "$browser_path" $NEWTAB "$@" &
;;
konqueror)
case "$(basename "$browser_path")" in
@@ -130,20 +147,25 @@ case "$browser" in
# It's simpler to use kfmclient to open a new tab in konqueror.
browser_path="$(echo "$browser_path" | sed -e 's/konqueror$/kfmclient/')"
type "$browser_path" > /dev/null 2>&1 || die "No '$browser_path' found."
- eval "$browser_path" newTab $pages
+ eval "$browser_path" newTab "$@"
;;
kfmclient)
- eval "$browser_path" newTab $pages
+ eval "$browser_path" newTab "$@"
;;
*)
- nohup "$browser_path" $pages &
+ "$browser_path" "$@" &
;;
esac
;;
- w3m|links|lynx)
- eval "$browser_path" $pages
+ w3m|links|lynx|open)
+ eval "$browser_path" "$@"
;;
dillo)
- nohup "$browser_path" $pages &
+ "$browser_path" "$@" &
+ ;;
+ *)
+ if test -n "$browser_cmd"; then
+ ( eval $browser_cmd "$@" )
+ fi
;;
esac
diff --git a/git.c b/git.c
index fc156863b..37b1d76a0 100644
--- a/git.c
+++ b/git.c
@@ -6,6 +6,46 @@
const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
+const char git_more_info_string[] =
+ "See 'git help COMMAND' for more information on a specific command.";
+
+static int use_pager = -1;
+struct pager_config {
+ const char *cmd;
+ int val;
+};
+
+static int pager_command_config(const char *var, const char *value, void *data)
+{
+ struct pager_config *c = data;
+ if (!prefixcmp(var, "pager.") && !strcmp(var + 6, c->cmd))
+ c->val = git_config_bool(var, value);
+ return 0;
+}
+
+/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */
+int check_pager_config(const char *cmd)
+{
+ struct pager_config c;
+ c.cmd = cmd;
+ c.val = -1;
+ git_config(pager_command_config, &c);
+ return c.val;
+}
+
+static void commit_pager_choice(void) {
+ switch (use_pager) {
+ case 0:
+ setenv("GIT_PAGER", "cat", 1);
+ break;
+ case 1:
+ setup_pager();
+ break;
+ default:
+ break;
+ }
+}
+
static int handle_options(const char*** argv, int* argc, int* envchanged)
{
int handled = 0;
@@ -35,9 +75,9 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
exit(0);
}
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
- setup_pager();
+ use_pager = 1;
} else if (!strcmp(cmd, "--no-pager")) {
- setenv("GIT_PAGER", "cat", 1);
+ use_pager = 0;
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--git-dir")) {
@@ -87,81 +127,20 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
return handled;
}
-static const char *alias_command;
-static char *alias_string;
-
-static int git_alias_config(const char *var, const char *value)
-{
- if (!prefixcmp(var, "alias.") && !strcmp(var + 6, alias_command)) {
- alias_string = xstrdup(value);
- }
- return 0;
-}
-
-static int split_cmdline(char *cmdline, const char ***argv)
-{
- int src, dst, count = 0, size = 16;
- char quoted = 0;
-
- *argv = xmalloc(sizeof(char*) * size);
-
- /* split alias_string */
- (*argv)[count++] = cmdline;
- for (src = dst = 0; cmdline[src];) {
- char c = cmdline[src];
- if (!quoted && isspace(c)) {
- cmdline[dst++] = 0;
- while (cmdline[++src]
- && isspace(cmdline[src]))
- ; /* skip */
- if (count >= size) {
- size += 16;
- *argv = xrealloc(*argv, sizeof(char*) * size);
- }
- (*argv)[count++] = cmdline + dst;
- } else if(!quoted && (c == '\'' || c == '"')) {
- quoted = c;
- src++;
- } else if (c == quoted) {
- quoted = 0;
- src++;
- } else {
- if (c == '\\' && quoted != '\'') {
- src++;
- c = cmdline[src];
- if (!c) {
- free(*argv);
- *argv = NULL;
- return error("cmdline ends with \\");
- }
- }
- cmdline[dst++] = c;
- src++;
- }
- }
-
- cmdline[dst] = 0;
-
- if (quoted) {
- free(*argv);
- *argv = NULL;
- return error("unclosed quote");
- }
-
- return count;
-}
-
static int handle_alias(int *argcp, const char ***argv)
{
- int nongit = 0, envchanged = 0, ret = 0, saved_errno = errno;
+ int envchanged = 0, ret = 0, saved_errno = errno;
const char *subdir;
int count, option_count;
const char** new_argv;
+ const char *alias_command;
+ char *alias_string;
+ int unused_nongit;
- subdir = setup_git_directory_gently(&nongit);
+ subdir = setup_git_directory_gently(&unused_nongit);
alias_command = (*argv)[0];
- git_config(git_alias_config);
+ alias_string = alias_lookup(alias_command);
if (alias_string) {
if (alias_string[0] == '!') {
if (*argcp > 1) {
@@ -247,8 +226,13 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
prefix = NULL;
if (p->option & RUN_SETUP)
prefix = setup_git_directory();
- if (p->option & USE_PAGER)
- setup_pager();
+
+ if (use_pager == -1 && p->option & RUN_SETUP)
+ use_pager = check_pager_config(p->cmd);
+ if (use_pager == -1 && p->option & USE_PAGER)
+ use_pager = 1;
+ commit_pager_choice();
+
if (p->option & NEED_WORK_TREE)
setup_work_tree();
@@ -291,9 +275,10 @@ static void handle_internal_command(int argc, const char **argv)
{ "checkout-index", cmd_checkout_index,
RUN_SETUP | NEED_WORK_TREE},
{ "check-ref-format", cmd_check_ref_format },
- { "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE },
+ { "check-attr", cmd_check_attr, RUN_SETUP },
{ "cherry", cmd_cherry, RUN_SETUP },
{ "cherry-pick", cmd_cherry_pick, RUN_SETUP | NEED_WORK_TREE },
+ { "clone", cmd_clone },
{ "clean", cmd_clean, RUN_SETUP | NEED_WORK_TREE },
{ "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
@@ -301,7 +286,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "count-objects", cmd_count_objects, RUN_SETUP },
{ "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff },
- { "diff-files", cmd_diff_files },
+ { "diff-files", cmd_diff_files, RUN_SETUP },
{ "diff-index", cmd_diff_index, RUN_SETUP },
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
{ "fast-export", cmd_fast_export, RUN_SETUP },
@@ -328,10 +313,12 @@ static void handle_internal_command(int argc, const char **argv)
{ "ls-remote", cmd_ls_remote },
{ "mailinfo", cmd_mailinfo },
{ "mailsplit", cmd_mailsplit },
+ { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
{ "merge-base", cmd_merge_base, RUN_SETUP },
{ "merge-file", cmd_merge_file },
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
+ { "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
@@ -342,6 +329,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "push", cmd_push, RUN_SETUP },
{ "read-tree", cmd_read_tree, RUN_SETUP },
{ "reflog", cmd_reflog, RUN_SETUP },
+ { "remote", cmd_remote, RUN_SETUP },
{ "repo-config", cmd_config },
{ "rerere", cmd_rerere, RUN_SETUP },
{ "reset", cmd_reset, RUN_SETUP },
@@ -350,7 +338,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
{ "rm", cmd_rm, RUN_SETUP },
{ "send-pack", cmd_send_pack, RUN_SETUP },
- { "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
+ { "shortlog", cmd_shortlog, USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
@@ -371,6 +359,16 @@ static void handle_internal_command(int argc, const char **argv)
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
};
int i;
+ static const char ext[] = STRIP_EXTENSION;
+
+ if (sizeof(ext) > 1) {
+ i = strlen(argv[0]) - strlen(ext);
+ if (i > 0 && !strcmp(argv[0] + i, ext)) {
+ char *argv0 = strdup(argv[0]);
+ argv[0] = cmd = argv0;
+ argv0[i] = '\0';
+ }
+ }
/* Turn "git cmd --help" into "git help cmd" */
if (argc > 1 && !strcmp(argv[1], "--help")) {
@@ -386,11 +384,40 @@ static void handle_internal_command(int argc, const char **argv)
}
}
+static void execv_dashed_external(const char **argv)
+{
+ struct strbuf cmd;
+ const char *tmp;
+
+ strbuf_init(&cmd, 0);
+ strbuf_addf(&cmd, "git-%s", argv[0]);
+
+ /*
+ * argv[0] must be the git command, but the argv array
+ * belongs to the caller, and may be reused in
+ * subsequent loop iterations. Save argv[0] and
+ * restore it on error.
+ */
+ tmp = argv[0];
+ argv[0] = cmd.buf;
+
+ trace_argv_printf(argv, "trace: exec:");
+
+ /* execvp() can only ever return if it fails */
+ execvp(cmd.buf, (char **)argv);
+
+ trace_printf("trace: exec failed: %s\n", strerror(errno));
+
+ argv[0] = tmp;
+
+ strbuf_release(&cmd);
+}
+
+
int main(int argc, const char **argv)
{
- const char *cmd = argv[0] ? argv[0] : "git-help";
- char *slash = strrchr(cmd, '/');
- const char *cmd_path = NULL;
+ const char *cmd = argv[0] && *argv[0] ? argv[0] : "git-help";
+ char *slash = (char *)cmd + strlen(cmd);
int done_alias = 0;
/*
@@ -398,9 +425,12 @@ int main(int argc, const char **argv)
* name, and the dirname as the default exec_path
* if we don't have anything better.
*/
- if (slash) {
+ do
+ --slash;
+ while (cmd <= slash && !is_dir_sep(*slash));
+ if (cmd <= slash) {
*slash++ = 0;
- cmd_path = cmd;
+ git_set_argv0_path(cmd);
cmd = slash;
}
@@ -425,6 +455,7 @@ int main(int argc, const char **argv)
argv++;
argc--;
handle_options(&argv, &argc, NULL);
+ commit_pager_choice();
if (argc > 0) {
if (!prefixcmp(argv[0], "--"))
argv[0] += 2;
@@ -432,6 +463,7 @@ int main(int argc, const char **argv)
/* The user didn't specify a command; give them help */
printf("usage: %s\n\n", git_usage_string);
list_common_cmds_help();
+ printf("\n%s\n", git_more_info_string);
exit(1);
}
cmd = argv[0];
@@ -442,14 +474,14 @@ int main(int argc, const char **argv)
* environment, and the $(gitexecdir) from the Makefile at build
* time.
*/
- setup_path(cmd_path);
+ setup_path();
while (1) {
/* See if it's an internal command */
handle_internal_command(argc, argv);
/* .. then try the external ones */
- execv_git_cmd(argv);
+ execv_dashed_external(argv);
/* It could be an alias -- this works around the insanity
* of overriding "git log" with "git show" by having
diff --git a/git.spec.in b/git.spec.in
index 659f05881..c6492e5be 100644
--- a/git.spec.in
+++ b/git.spec.in
@@ -3,88 +3,94 @@
Name: git
Version: @@VERSION@@
Release: 1%{?dist}
-Summary: Git core and tools
+Summary: Core git tools
License: GPL
Group: Development/Tools
URL: http://kernel.org/pub/software/scm/git/
Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz
-BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3}
+BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel, gettext %{!?_without_docs:, xmlto, asciidoc > 6.0.3}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: git-core = %{version}-%{release}
-Requires: git-svn = %{version}-%{release}
-Requires: git-cvs = %{version}-%{release}
-Requires: git-arch = %{version}-%{release}
-Requires: git-email = %{version}-%{release}
-Requires: gitk = %{version}-%{release}
-Requires: git-gui = %{version}-%{release}
Requires: perl-Git = %{version}-%{release}
+Requires: zlib >= 1.2, rsync, less, openssh-clients, expat
+Provides: git-core = %{version}-%{release}
+Obsoletes: git-core <= 1.5.4.2
+Obsoletes: git-p4
%description
Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.
-This is a dummy package which brings in all subpackages.
+The git rpm installs the core tools with minimal dependencies. To
+install all git packages, including tools for integrating with other
+SCMs, install the git-all meta-package.
-%package core
-Summary: Core git tools
+%package all
+Summary: Meta-package to pull in all git tools
Group: Development/Tools
-Requires: zlib >= 1.2, rsync, curl, less, openssh-clients, expat
-Obsoletes: git-p4
-%description core
+Requires: git = %{version}-%{release}
+Requires: git-svn = %{version}-%{release}
+Requires: git-cvs = %{version}-%{release}
+Requires: git-arch = %{version}-%{release}
+Requires: git-email = %{version}-%{release}
+Requires: gitk = %{version}-%{release}
+Requires: git-gui = %{version}-%{release}
+Obsoletes: git <= 1.5.4.2
+
+%description all
Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.
-These are the core tools with minimal dependencies.
+This is a dummy package which brings in all subpackages.
%package svn
Summary: Git tools for importing Subversion repositories
Group: Development/Tools
-Requires: git-core = %{version}-%{release}, subversion
+Requires: git = %{version}-%{release}, subversion
%description svn
Git tools for importing Subversion repositories.
%package cvs
Summary: Git tools for importing CVS repositories
Group: Development/Tools
-Requires: git-core = %{version}-%{release}, cvs, cvsps
+Requires: git = %{version}-%{release}, cvs, cvsps
%description cvs
Git tools for importing CVS repositories.
%package arch
Summary: Git tools for importing Arch repositories
Group: Development/Tools
-Requires: git-core = %{version}-%{release}, tla
+Requires: git = %{version}-%{release}, tla
%description arch
Git tools for importing Arch repositories.
%package email
Summary: Git tools for sending email
Group: Development/Tools
-Requires: git-core = %{version}-%{release}
+Requires: git = %{version}-%{release}
%description email
Git tools for sending email.
%package gui
Summary: Git GUI tool
Group: Development/Tools
-Requires: git-core = %{version}-%{release}, tk >= 8.4
+Requires: git = %{version}-%{release}, tk >= 8.4
%description gui
Git GUI tool
%package -n gitk
Summary: Git revision tree visualiser ('gitk')
Group: Development/Tools
-Requires: git-core = %{version}-%{release}, tk >= 8.4
+Requires: git = %{version}-%{release}, tk >= 8.4
%description -n gitk
Git revision tree visualiser ('gitk')
%package -n perl-Git
Summary: Perl interface to Git
Group: Development/Libraries
-Requires: git-core = %{version}-%{release}
+Requires: git = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
BuildRequires: perl(Error)
@@ -111,6 +117,7 @@ find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';'
find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';'
(find $RPM_BUILD_ROOT%{_bindir} -type f | grep -vE "archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@) > bin-man-doc-files
+(find $RPM_BUILD_ROOT%{_libexecdir}/git-core -type f | grep -vE "archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@) >> bin-man-doc-files
(find $RPM_BUILD_ROOT%{perl_vendorlib} -type f | sed -e s@^$RPM_BUILD_ROOT@@) >> perl-files
%if %{!?_without_docs:1}0
(find $RPM_BUILD_ROOT%{_mandir} $RPM_BUILD_ROOT/Documentation -type f | grep -vE "archimport|svn|git-cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@ -e 's/$/*/' ) >> bin-man-doc-files
@@ -121,12 +128,16 @@ rm -rf $RPM_BUILD_ROOT%{_mandir}
%clean
rm -rf $RPM_BUILD_ROOT
-%files
-# These are no files in the root package
+%files -f bin-man-doc-files
+%defattr(-,root,root)
+%{_datadir}/git-core/
+%doc README COPYING Documentation/*.txt
+%{!?_without_docs: %doc Documentation/*.html Documentation/howto}
+%{!?_without_docs: %doc Documentation/technical}
%files svn
%defattr(-,root,root)
-%{_bindir}/*svn*
+%{_libexecdir}/git-core/*svn*
%doc Documentation/*svn*.txt
%{!?_without_docs: %{_mandir}/man1/*svn*.1*}
%{!?_without_docs: %doc Documentation/*svn*.html }
@@ -134,28 +145,28 @@ rm -rf $RPM_BUILD_ROOT
%files cvs
%defattr(-,root,root)
%doc Documentation/*git-cvs*.txt
-%{_bindir}/*cvs*
+%{_libexecdir}/git-core/*cvs*
%{!?_without_docs: %{_mandir}/man1/*cvs*.1*}
%{!?_without_docs: %doc Documentation/*git-cvs*.html }
%files arch
%defattr(-,root,root)
%doc Documentation/git-archimport.txt
-%{_bindir}/git-archimport
+%{_libexecdir}/git-core/git-archimport
%{!?_without_docs: %{_mandir}/man1/git-archimport.1*}
%{!?_without_docs: %doc Documentation/git-archimport.html }
%files email
%defattr(-,root,root)
%doc Documentation/*email*.txt
-%{_bindir}/*email*
+%{_libexecdir}/git-core/*email*
%{!?_without_docs: %{_mandir}/man1/*email*.1*}
%{!?_without_docs: %doc Documentation/*email*.html }
%files gui
%defattr(-,root,root)
-%{_bindir}/git-gui
-%{_bindir}/git-citool
+%{_libexecdir}/git-core/git-gui
+%{_libexecdir}/git-core/git-citool
%{_datadir}/git-gui/
%{!?_without_docs: %{_mandir}/man1/git-gui.1*}
%{!?_without_docs: %doc Documentation/git-gui.html}
@@ -173,14 +184,19 @@ rm -rf $RPM_BUILD_ROOT
%files -n perl-Git -f perl-files
%defattr(-,root,root)
-%files core -f bin-man-doc-files
-%defattr(-,root,root)
-%{_datadir}/git-core/
-%doc README COPYING Documentation/*.txt
-%{!?_without_docs: %doc Documentation/*.html Documentation/howto}
-%{!?_without_docs: %doc Documentation/technical}
+%files all
+# No files for you!
%changelog
+* Sun Jun 15 2008 Junio C Hamano <gitster@pobox.com>
+- Remove curl from Requires list.
+
+* Fri Feb 15 2008 Kristian Høgsberg <krh@redhat.com>
+- Rename git-core to just git and rename meta package from git to git-all.
+
+* Sun Feb 03 2008 James Bowes <jbowes@dangerouslyinc.com>
+- Add a BuildRequires for gettext
+
* Fri Jan 11 2008 Junio C Hamano <gitster@pobox.com>
- Include gitk message files
diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index ae2b80b10..e1b604560 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -8,6 +8,7 @@ gitk_libdir ?= $(sharedir)/gitk/lib
msgsdir ?= $(gitk_libdir)/msgs
msgsdir_SQ = $(subst ','\'',$(msgsdir))
+TCL_PATH ?= tclsh
TCLTK_PATH ?= wish
INSTALL ?= install
RM ?= rm -f
@@ -22,6 +23,9 @@ ifdef NO_MSGFMT
MSGFMT ?= $(TCL_PATH) po/po2msg.sh
else
MSGFMT ?= msgfmt
+ ifneq ($(shell $(MSGFMT) --tcl -l C -d . /dev/null 2>/dev/null; echo $$?),0)
+ MSGFMT := $(TCL_PATH) po/po2msg.sh
+ endif
endif
PO_TEMPLATE = po/gitk.pot
@@ -36,9 +40,9 @@ endif
all:: gitk-wish $(ALL_MSGFILES)
install:: all
- $(INSTALL) gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
- $(INSTALL) -d '$(DESTDIR_SQ)$(msgsdir_SQ)'
- $(foreach p,$(ALL_MSGFILES), $(INSTALL) $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
+ $(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
+ $(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
uninstall::
$(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 5560e4dc5..087c4ac73 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2,7 +2,7 @@
# Tcl ignores the next line -*- tcl -*- \
exec wish "$0" -- "$@"
-# Copyright (C) 2005-2006 Paul Mackerras. All rights reserved.
+# Copyright © 2005-2008 Paul Mackerras. All rights reserved.
# This program is free software; it may be used, copied, modified
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.
@@ -22,11 +22,11 @@ proc gitdir {} {
# run before X event handlers, so reading from a fast source can
# make the GUI completely unresponsive.
proc run args {
- global isonrunq runq
+ global isonrunq runq currunq
set script $args
if {[info exists isonrunq($script)]} return
- if {$runq eq {}} {
+ if {$runq eq {} && ![info exists currunq]} {
after idle dorunq
}
lappend runq [list {} $script]
@@ -38,27 +38,41 @@ proc filerun {fd script} {
}
proc filereadable {fd script} {
- global runq
+ global runq currunq
fileevent $fd readable {}
- if {$runq eq {}} {
+ if {$runq eq {} && ![info exists currunq]} {
after idle dorunq
}
lappend runq [list $fd $script]
}
+proc nukefile {fd} {
+ global runq
+
+ for {set i 0} {$i < [llength $runq]} {} {
+ if {[lindex $runq $i 0] eq $fd} {
+ set runq [lreplace $runq $i $i]
+ } else {
+ incr i
+ }
+ }
+}
+
proc dorunq {} {
- global isonrunq runq
+ global isonrunq runq currunq
set tstart [clock clicks -milliseconds]
set t0 $tstart
- while {$runq ne {}} {
+ while {[llength $runq] > 0} {
set fd [lindex $runq 0 0]
set script [lindex $runq 0 1]
+ set currunq [lindex $runq 0]
+ set runq [lrange $runq 1 end]
set repeat [eval $script]
+ unset currunq
set t1 [clock clicks -milliseconds]
set t [expr {$t1 - $t0}]
- set runq [lrange $runq 1 end]
if {$repeat ne {} && $repeat} {
if {$fd eq {} || $repeat == 2} {
# script returns 1 if it wants to be readded
@@ -78,67 +92,464 @@ proc dorunq {} {
}
}
-# Start off a git rev-list process and arrange to read its output
+proc reg_instance {fd} {
+ global commfd leftover loginstance
+
+ set i [incr loginstance]
+ set commfd($i) $fd
+ set leftover($i) {}
+ return $i
+}
+
+proc unmerged_files {files} {
+ global nr_unmerged
+
+ # find the list of unmerged files
+ set mlist {}
+ set nr_unmerged 0
+ if {[catch {
+ set fd [open "| git ls-files -u" r]
+ } err]} {
+ show_error {} . "[mc "Couldn't get list of unmerged files:"] $err"
+ exit 1
+ }
+ while {[gets $fd line] >= 0} {
+ set i [string first "\t" $line]
+ if {$i < 0} continue
+ set fname [string range $line [expr {$i+1}] end]
+ if {[lsearch -exact $mlist $fname] >= 0} continue
+ incr nr_unmerged
+ if {$files eq {} || [path_filter $files $fname]} {
+ lappend mlist $fname
+ }
+ }
+ catch {close $fd}
+ return $mlist
+}
+
+proc parseviewargs {n arglist} {
+ global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs
+
+ set vdatemode($n) 0
+ set vmergeonly($n) 0
+ set glflags {}
+ set diffargs {}
+ set nextisval 0
+ set revargs {}
+ set origargs $arglist
+ set allknown 1
+ set filtered 0
+ set i -1
+ foreach arg $arglist {
+ incr i
+ if {$nextisval} {
+ lappend glflags $arg
+ set nextisval 0
+ continue
+ }
+ switch -glob -- $arg {
+ "-d" -
+ "--date-order" {
+ set vdatemode($n) 1
+ # remove from origargs in case we hit an unknown option
+ set origargs [lreplace $origargs $i $i]
+ incr i -1
+ }
+ # These request or affect diff output, which we don't want.
+ # Some could be used to set our defaults for diff display.
+ "-[puabwcrRBMC]" -
+ "--no-renames" - "--full-index" - "--binary" - "--abbrev=*" -
+ "--find-copies-harder" - "-l*" - "--ext-diff" - "--no-ext-diff" -
+ "--src-prefix=*" - "--dst-prefix=*" - "--no-prefix" -
+ "-O*" - "--text" - "--full-diff" - "--ignore-space-at-eol" -
+ "--ignore-space-change" - "-U*" - "--unified=*" {
+ lappend diffargs $arg
+ }
+ # These cause our parsing of git log's output to fail, or else
+ # they're options we want to set ourselves, so ignore them.
+ "--raw" - "--patch-with-raw" - "--patch-with-stat" -
+ "--name-only" - "--name-status" - "--color" - "--color-words" -
+ "--log-size" - "--pretty=*" - "--decorate" - "--abbrev-commit" -
+ "--cc" - "-z" - "--header" - "--parents" - "--boundary" -
+ "--no-color" - "-g" - "--walk-reflogs" - "--no-walk" -
+ "--timestamp" - "relative-date" - "--date=*" - "--stdin" -
+ "--objects" - "--objects-edge" - "--reverse" {
+ }
+ # These are harmless, and some are even useful
+ "--stat=*" - "--numstat" - "--shortstat" - "--summary" -
+ "--check" - "--exit-code" - "--quiet" - "--topo-order" -
+ "--full-history" - "--dense" - "--sparse" -
+ "--follow" - "--left-right" - "--encoding=*" {
+ lappend glflags $arg
+ }
+ # These mean that we get a subset of the commits
+ "--diff-filter=*" - "--no-merges" - "--unpacked" -
+ "--max-count=*" - "--skip=*" - "--since=*" - "--after=*" -
+ "--until=*" - "--before=*" - "--max-age=*" - "--min-age=*" -
+ "--author=*" - "--committer=*" - "--grep=*" - "-[iE]" -
+ "--remove-empty" - "--first-parent" - "--cherry-pick" -
+ "-S*" - "--pickaxe-all" - "--pickaxe-regex" - {
+ set filtered 1
+ lappend glflags $arg
+ }
+ # This appears to be the only one that has a value as a
+ # separate word following it
+ "-n" {
+ set filtered 1
+ set nextisval 1
+ lappend glflags $arg
+ }
+ "--not" {
+ set notflag [expr {!$notflag}]
+ lappend revargs $arg
+ }
+ "--all" {
+ lappend revargs $arg
+ }
+ "--merge" {
+ set vmergeonly($n) 1
+ # git rev-parse doesn't understand --merge
+ lappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD
+ }
+ # Other flag arguments including -<n>
+ "-*" {
+ if {[string is digit -strict [string range $arg 1 end]]} {
+ set filtered 1
+ } else {
+ # a flag argument that we don't recognize;
+ # that means we can't optimize
+ set allknown 0
+ }
+ lappend glflags $arg
+ }
+ # Non-flag arguments specify commits or ranges of commits
+ default {
+ if {[string match "*...*" $arg]} {
+ lappend revargs --gitk-symmetric-diff-marker
+ }
+ lappend revargs $arg
+ }
+ }
+ }
+ set vdflags($n) $diffargs
+ set vflags($n) $glflags
+ set vrevs($n) $revargs
+ set vfiltered($n) $filtered
+ set vorigargs($n) $origargs
+ return $allknown
+}
+
+proc parseviewrevs {view revs} {
+ global vposids vnegids
+
+ if {$revs eq {}} {
+ set revs HEAD
+ }
+ if {[catch {set ids [eval exec git rev-parse $revs]} err]} {
+ # we get stdout followed by stderr in $err
+ # for an unknown rev, git rev-parse echoes it and then errors out
+ set errlines [split $err "\n"]
+ set badrev {}
+ for {set l 0} {$l < [llength $errlines]} {incr l} {
+ set line [lindex $errlines $l]
+ if {!([string length $line] == 40 && [string is xdigit $line])} {
+ if {[string match "fatal:*" $line]} {
+ if {[string match "fatal: ambiguous argument*" $line]
+ && $badrev ne {}} {
+ if {[llength $badrev] == 1} {
+ set err "unknown revision $badrev"
+ } else {
+ set err "unknown revisions: [join $badrev ", "]"
+ }
+ } else {
+ set err [join [lrange $errlines $l end] "\n"]
+ }
+ break
+ }
+ lappend badrev $line
+ }
+ }
+ error_popup "Error parsing revisions: $err"
+ return {}
+ }
+ set ret {}
+ set pos {}
+ set neg {}
+ set sdm 0
+ foreach id [split $ids "\n"] {
+ if {$id eq "--gitk-symmetric-diff-marker"} {
+ set sdm 4
+ } elseif {[string match "^*" $id]} {
+ if {$sdm != 1} {
+ lappend ret $id
+ if {$sdm == 3} {
+ set sdm 0
+ }
+ }
+ lappend neg [string range $id 1 end]
+ } else {
+ if {$sdm != 2} {
+ lappend ret $id
+ } else {
+ lset ret end [lindex $ret end]...$id
+ }
+ lappend pos $id
+ }
+ incr sdm -1
+ }
+ set vposids($view) $pos
+ set vnegids($view) $neg
+ return $ret
+}
+
+# Start off a git log process and arrange to read its output
proc start_rev_list {view} {
- global startmsecs
- global commfd leftover tclencoding datemode
- global viewargs viewfiles commitidx viewcomplete vnextroot
- global showlocalchanges commitinterest mainheadid
- global progressdirn progresscoords proglastnc curview
+ global startmsecs commitidx viewcomplete curview
+ global tclencoding
+ global viewargs viewargscmd viewfiles vfilelimit
+ global showlocalchanges commitinterest
+ global viewactive viewinstances vmergeonly
+ global mainheadid
+ global vcanopt vflags vrevs vorigargs
set startmsecs [clock clicks -milliseconds]
set commitidx($view) 0
- set viewcomplete($view) 0
- set vnextroot($view) 0
- set order "--topo-order"
- if {$datemode} {
- set order "--date-order"
+ # these are set this way for the error exits
+ set viewcomplete($view) 1
+ set viewactive($view) 0
+ varcinit $view
+
+ set args $viewargs($view)
+ if {$viewargscmd($view) ne {}} {
+ if {[catch {
+ set str [exec sh -c $viewargscmd($view)]
+ } err]} {
+ error_popup "Error executing --argscmd command: $err"
+ return 0
+ }
+ set args [concat $args [split $str "\n"]]
+ }
+ set vcanopt($view) [parseviewargs $view $args]
+
+ set files $viewfiles($view)
+ if {$vmergeonly($view)} {
+ set files [unmerged_files $files]
+ if {$files eq {}} {
+ global nr_unmerged
+ if {$nr_unmerged == 0} {
+ error_popup [mc "No files selected: --merge specified but\
+ no files are unmerged."]
+ } else {
+ error_popup [mc "No files selected: --merge specified but\
+ no unmerged files are within file limit."]
+ }
+ return 0
+ }
}
+ set vfilelimit($view) $files
+
+ if {$vcanopt($view)} {
+ set revs [parseviewrevs $view $vrevs($view)]
+ if {$revs eq {}} {
+ return 0
+ }
+ set args [concat $vflags($view) $revs]
+ } else {
+ set args $vorigargs($view)
+ }
+
if {[catch {
- set fd [open [concat | git log --no-color -z --pretty=raw $order --parents \
- --boundary $viewargs($view) "--" $viewfiles($view)] r]
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
+ --boundary $args "--" $files] r]
} err]} {
- error_popup "[mc "Error executing git rev-list:"] $err"
- exit 1
+ error_popup "[mc "Error executing git log:"] $err"
+ return 0
}
- set commfd($view) $fd
- set leftover($view) {}
- if {$showlocalchanges} {
+ set i [reg_instance $fd]
+ set viewinstances($view) [list $i]
+ if {$showlocalchanges && $mainheadid ne {}} {
lappend commitinterest($mainheadid) {dodiffindex}
}
fconfigure $fd -blocking 0 -translation lf -eofchar {}
if {$tclencoding != {}} {
fconfigure $fd -encoding $tclencoding
}
- filerun $fd [list getcommitlines $fd $view]
+ filerun $fd [list getcommitlines $fd $i $view 0]
nowbusy $view [mc "Reading"]
- if {$view == $curview} {
- set progressdirn 1
- set progresscoords {0 0}
- set proglastnc 0
- }
+ set viewcomplete($view) 0
+ set viewactive($view) 1
+ return 1
}
-proc stop_rev_list {} {
- global commfd curview
+proc stop_instance {inst} {
+ global commfd leftover
- if {![info exists commfd($curview)]} return
- set fd $commfd($curview)
+ set fd $commfd($inst)
catch {
set pid [pid $fd]
- exec kill $pid
+
+ if {$::tcl_platform(platform) eq {windows}} {
+ exec kill -f $pid
+ } else {
+ exec kill $pid
+ }
}
catch {close $fd}
- unset commfd($curview)
+ nukefile $fd
+ unset commfd($inst)
+ unset leftover($inst)
+}
+
+proc stop_backends {} {
+ global commfd
+
+ foreach inst [array names commfd] {
+ stop_instance $inst
+ }
}
-proc getcommits {} {
- global phase canv curview
+proc stop_rev_list {view} {
+ global viewinstances
+
+ foreach inst $viewinstances($view) {
+ stop_instance $inst
+ }
+ set viewinstances($view) {}
+}
+
+proc reset_pending_select {selid} {
+ global pending_select mainheadid
+
+ if {$selid ne {}} {
+ set pending_select $selid
+ } else {
+ set pending_select $mainheadid
+ }
+}
+
+proc getcommits {selid} {
+ global canv curview need_redisplay viewactive
- set phase getcommits
initlayout
- start_rev_list $curview
- show_status [mc "Reading commits..."]
+ if {[start_rev_list $curview]} {
+ reset_pending_select $selid
+ show_status [mc "Reading commits..."]
+ set need_redisplay 1
+ } else {
+ show_status [mc "No commits selected"]
+ }
+}
+
+proc updatecommits {} {
+ global curview vcanopt vorigargs vfilelimit viewinstances
+ global viewactive viewcomplete tclencoding
+ global startmsecs showneartags showlocalchanges
+ global mainheadid pending_select
+ global isworktree
+ global varcid vposids vnegids vflags vrevs
+
+ set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
+ set oldmainid $mainheadid
+ rereadrefs
+ if {$showlocalchanges} {
+ if {$mainheadid ne $oldmainid} {
+ dohidelocalchanges
+ }
+ if {[commitinview $mainheadid $curview]} {
+ dodiffindex
+ }
+ }
+ set view $curview
+ if {$vcanopt($view)} {
+ set oldpos $vposids($view)
+ set oldneg $vnegids($view)
+ set revs [parseviewrevs $view $vrevs($view)]
+ if {$revs eq {}} {
+ return
+ }
+ # note: getting the delta when negative refs change is hard,
+ # and could require multiple git log invocations, so in that
+ # case we ask git log for all the commits (not just the delta)
+ if {$oldneg eq $vnegids($view)} {
+ set newrevs {}
+ set npos 0
+ # take out positive refs that we asked for before or
+ # that we have already seen
+ foreach rev $revs {
+ if {[string length $rev] == 40} {
+ if {[lsearch -exact $oldpos $rev] < 0
+ && ![info exists varcid($view,$rev)]} {
+ lappend newrevs $rev
+ incr npos
+ }
+ } else {
+ lappend $newrevs $rev
+ }
+ }
+ if {$npos == 0} return
+ set revs $newrevs
+ set vposids($view) [lsort -unique [concat $oldpos $vposids($view)]]
+ }
+ set args [concat $vflags($view) $revs --not $oldpos]
+ } else {
+ set args $vorigargs($view)
+ }
+ if {[catch {
+ set fd [open [concat | git log --no-color -z --pretty=raw --parents \
+ --boundary $args "--" $vfilelimit($view)] r]
+ } err]} {
+ error_popup "Error executing git log: $err"
+ return
+ }
+ if {$viewactive($view) == 0} {
+ set startmsecs [clock clicks -milliseconds]
+ }
+ set i [reg_instance $fd]
+ lappend viewinstances($view) $i
+ fconfigure $fd -blocking 0 -translation lf -eofchar {}
+ if {$tclencoding != {}} {
+ fconfigure $fd -encoding $tclencoding
+ }
+ filerun $fd [list getcommitlines $fd $i $view 1]
+ incr viewactive($view)
+ set viewcomplete($view) 0
+ reset_pending_select {}
+ nowbusy $view "Reading"
+ if {$showneartags} {
+ getallcommits
+ }
+}
+
+proc reloadcommits {} {
+ global curview viewcomplete selectedline currentid thickerline
+ global showneartags treediffs commitinterest cached_commitrow
+ global targetid
+
+ set selid {}
+ if {$selectedline ne {}} {
+ set selid $currentid
+ }
+
+ if {!$viewcomplete($curview)} {
+ stop_rev_list $curview
+ }
+ resetvarcs $curview
+ set selectedline {}
+ catch {unset currentid}
+ catch {unset thickerline}
+ catch {unset treediffs}
+ readrefs
+ changedrefs
+ if {$showneartags} {
+ getallcommits
+ }
+ clear_display
+ catch {unset commitinterest}
+ catch {unset cached_commitrow}
+ catch {unset targetid}
+ setcanvscroll
+ getcommits $selid
+ return 0
}
# This makes a string representation of a positive integer which
@@ -154,46 +565,759 @@ proc strrep {n} {
return [format "z%.8x" $n]
}
-proc getcommitlines {fd view} {
- global commitlisted commitinterest
- global leftover commfd
- global displayorder commitidx viewcomplete commitrow commitdata
- global parentlist children curview hlview
- global vparentlist vdisporder vcmitlisted
- global ordertok vnextroot idpending
+# Procedures used in reordering commits from git log (without
+# --topo-order) into the order for display.
+
+proc varcinit {view} {
+ global varcstart vupptr vdownptr vleftptr vbackptr varctok varcrow
+ global vtokmod varcmod vrowmod varcix vlastins
+
+ set varcstart($view) {{}}
+ set vupptr($view) {0}
+ set vdownptr($view) {0}
+ set vleftptr($view) {0}
+ set vbackptr($view) {0}
+ set varctok($view) {{}}
+ set varcrow($view) {{}}
+ set vtokmod($view) {}
+ set varcmod($view) 0
+ set vrowmod($view) 0
+ set varcix($view) {{}}
+ set vlastins($view) {0}
+}
+
+proc resetvarcs {view} {
+ global varcid varccommits parents children vseedcount ordertok
+
+ foreach vid [array names varcid $view,*] {
+ unset varcid($vid)
+ unset children($vid)
+ unset parents($vid)
+ }
+ # some commits might have children but haven't been seen yet
+ foreach vid [array names children $view,*] {
+ unset children($vid)
+ }
+ foreach va [array names varccommits $view,*] {
+ unset varccommits($va)
+ }
+ foreach vd [array names vseedcount $view,*] {
+ unset vseedcount($vd)
+ }
+ catch {unset ordertok}
+}
+
+# returns a list of the commits with no children
+proc seeds {v} {
+ global vdownptr vleftptr varcstart
+
+ set ret {}
+ set a [lindex $vdownptr($v) 0]
+ while {$a != 0} {
+ lappend ret [lindex $varcstart($v) $a]
+ set a [lindex $vleftptr($v) $a]
+ }
+ return $ret
+}
+
+proc newvarc {view id} {
+ global varcid varctok parents children vdatemode
+ global vupptr vdownptr vleftptr vbackptr varcrow varcix varcstart
+ global commitdata commitinfo vseedcount varccommits vlastins
+
+ set a [llength $varctok($view)]
+ set vid $view,$id
+ if {[llength $children($vid)] == 0 || $vdatemode($view)} {
+ if {![info exists commitinfo($id)]} {
+ parsecommit $id $commitdata($id) 1
+ }
+ set cdate [lindex $commitinfo($id) 4]
+ if {![string is integer -strict $cdate]} {
+ set cdate 0
+ }
+ if {![info exists vseedcount($view,$cdate)]} {
+ set vseedcount($view,$cdate) -1
+ }
+ set c [incr vseedcount($view,$cdate)]
+ set cdate [expr {$cdate ^ 0xffffffff}]
+ set tok "s[strrep $cdate][strrep $c]"
+ } else {
+ set tok {}
+ }
+ set ka 0
+ if {[llength $children($vid)] > 0} {
+ set kid [lindex $children($vid) end]
+ set k $varcid($view,$kid)
+ if {[string compare [lindex $varctok($view) $k] $tok] > 0} {
+ set ki $kid
+ set ka $k
+ set tok [lindex $varctok($view) $k]
+ }
+ }
+ if {$ka != 0} {
+ set i [lsearch -exact $parents($view,$ki) $id]
+ set j [expr {[llength $parents($view,$ki)] - 1 - $i}]
+ append tok [strrep $j]
+ }
+ set c [lindex $vlastins($view) $ka]
+ if {$c == 0 || [string compare $tok [lindex $varctok($view) $c]] < 0} {
+ set c $ka
+ set b [lindex $vdownptr($view) $ka]
+ } else {
+ set b [lindex $vleftptr($view) $c]
+ }
+ while {$b != 0 && [string compare $tok [lindex $varctok($view) $b]] >= 0} {
+ set c $b
+ set b [lindex $vleftptr($view) $c]
+ }
+ if {$c == $ka} {
+ lset vdownptr($view) $ka $a
+ lappend vbackptr($view) 0
+ } else {
+ lset vleftptr($view) $c $a
+ lappend vbackptr($view) $c
+ }
+ lset vlastins($view) $ka $a
+ lappend vupptr($view) $ka
+ lappend vleftptr($view) $b
+ if {$b != 0} {
+ lset vbackptr($view) $b $a
+ }
+ lappend varctok($view) $tok
+ lappend varcstart($view) $id
+ lappend vdownptr($view) 0
+ lappend varcrow($view) {}
+ lappend varcix($view) {}
+ set varccommits($view,$a) {}
+ lappend vlastins($view) 0
+ return $a
+}
+
+proc splitvarc {p v} {
+ global varcid varcstart varccommits varctok
+ global vupptr vdownptr vleftptr vbackptr varcix varcrow vlastins
+
+ set oa $varcid($v,$p)
+ set ac $varccommits($v,$oa)
+ set i [lsearch -exact $varccommits($v,$oa) $p]
+ if {$i <= 0} return
+ set na [llength $varctok($v)]
+ # "%" sorts before "0"...
+ set tok "[lindex $varctok($v) $oa]%[strrep $i]"
+ lappend varctok($v) $tok
+ lappend varcrow($v) {}
+ lappend varcix($v) {}
+ set varccommits($v,$oa) [lrange $ac 0 [expr {$i - 1}]]
+ set varccommits($v,$na) [lrange $ac $i end]
+ lappend varcstart($v) $p
+ foreach id $varccommits($v,$na) {
+ set varcid($v,$id) $na
+ }
+ lappend vdownptr($v) [lindex $vdownptr($v) $oa]
+ lappend vlastins($v) [lindex $vlastins($v) $oa]
+ lset vdownptr($v) $oa $na
+ lset vlastins($v) $oa 0
+ lappend vupptr($v) $oa
+ lappend vleftptr($v) 0
+ lappend vbackptr($v) 0
+ for {set b [lindex $vdownptr($v) $na]} {$b != 0} {set b [lindex $vleftptr($v) $b]} {
+ lset vupptr($v) $b $na
+ }
+}
+
+proc renumbervarc {a v} {
+ global parents children varctok varcstart varccommits
+ global vupptr vdownptr vleftptr vbackptr vlastins varcid vtokmod vdatemode
+
+ set t1 [clock clicks -milliseconds]
+ set todo {}
+ set isrelated($a) 1
+ set kidchanged($a) 1
+ set ntot 0
+ while {$a != 0} {
+ if {[info exists isrelated($a)]} {
+ lappend todo $a
+ set id [lindex $varccommits($v,$a) end]
+ foreach p $parents($v,$id) {
+ if {[info exists varcid($v,$p)]} {
+ set isrelated($varcid($v,$p)) 1
+ }
+ }
+ }
+ incr ntot
+ set b [lindex $vdownptr($v) $a]
+ if {$b == 0} {
+ while {$a != 0} {
+ set b [lindex $vleftptr($v) $a]
+ if {$b != 0} break
+ set a [lindex $vupptr($v) $a]
+ }
+ }
+ set a $b
+ }
+ foreach a $todo {
+ if {![info exists kidchanged($a)]} continue
+ set id [lindex $varcstart($v) $a]
+ if {[llength $children($v,$id)] > 1} {
+ set children($v,$id) [lsort -command [list vtokcmp $v] \
+ $children($v,$id)]
+ }
+ set oldtok [lindex $varctok($v) $a]
+ if {!$vdatemode($v)} {
+ set tok {}
+ } else {
+ set tok $oldtok
+ }
+ set ka 0
+ set kid [last_real_child $v,$id]
+ if {$kid ne {}} {
+ set k $varcid($v,$kid)
+ if {[string compare [lindex $varctok($v) $k] $tok] > 0} {
+ set ki $kid
+ set ka $k
+ set tok [lindex $varctok($v) $k]
+ }
+ }
+ if {$ka != 0} {
+ set i [lsearch -exact $parents($v,$ki) $id]
+ set j [expr {[llength $parents($v,$ki)] - 1 - $i}]
+ append tok [strrep $j]
+ }
+ if {$tok eq $oldtok} {
+ continue
+ }
+ set id [lindex $varccommits($v,$a) end]
+ foreach p $parents($v,$id) {
+ if {[info exists varcid($v,$p)]} {
+ set kidchanged($varcid($v,$p)) 1
+ } else {
+ set sortkids($p) 1
+ }
+ }
+ lset varctok($v) $a $tok
+ set b [lindex $vupptr($v) $a]
+ if {$b != $ka} {
+ if {[string compare [lindex $varctok($v) $ka] $vtokmod($v)] < 0} {
+ modify_arc $v $ka
+ }
+ if {[string compare [lindex $varctok($v) $b] $vtokmod($v)] < 0} {
+ modify_arc $v $b
+ }
+ set c [lindex $vbackptr($v) $a]
+ set d [lindex $vleftptr($v) $a]
+ if {$c == 0} {
+ lset vdownptr($v) $b $d
+ } else {
+ lset vleftptr($v) $c $d
+ }
+ if {$d != 0} {
+ lset vbackptr($v) $d $c
+ }
+ if {[lindex $vlastins($v) $b] == $a} {
+ lset vlastins($v) $b $c
+ }
+ lset vupptr($v) $a $ka
+ set c [lindex $vlastins($v) $ka]
+ if {$c == 0 || \
+ [string compare $tok [lindex $varctok($v) $c]] < 0} {
+ set c $ka
+ set b [lindex $vdownptr($v) $ka]
+ } else {
+ set b [lindex $vleftptr($v) $c]
+ }
+ while {$b != 0 && \
+ [string compare $tok [lindex $varctok($v) $b]] >= 0} {
+ set c $b
+ set b [lindex $vleftptr($v) $c]
+ }
+ if {$c == $ka} {
+ lset vdownptr($v) $ka $a
+ lset vbackptr($v) $a 0
+ } else {
+ lset vleftptr($v) $c $a
+ lset vbackptr($v) $a $c
+ }
+ lset vleftptr($v) $a $b
+ if {$b != 0} {
+ lset vbackptr($v) $b $a
+ }
+ lset vlastins($v) $ka $a
+ }
+ }
+ foreach id [array names sortkids] {
+ if {[llength $children($v,$id)] > 1} {
+ set children($v,$id) [lsort -command [list vtokcmp $v] \
+ $children($v,$id)]
+ }
+ }
+ set t2 [clock clicks -milliseconds]
+ #puts "renumbervarc did [llength $todo] of $ntot arcs in [expr {$t2-$t1}]ms"
+}
+
+# Fix up the graph after we have found out that in view $v,
+# $p (a commit that we have already seen) is actually the parent
+# of the last commit in arc $a.
+proc fix_reversal {p a v} {
+ global varcid varcstart varctok vupptr
+
+ set pa $varcid($v,$p)
+ if {$p ne [lindex $varcstart($v) $pa]} {
+ splitvarc $p $v
+ set pa $varcid($v,$p)
+ }
+ # seeds always need to be renumbered
+ if {[lindex $vupptr($v) $pa] == 0 ||
+ [string compare [lindex $varctok($v) $a] \
+ [lindex $varctok($v) $pa]] > 0} {
+ renumbervarc $pa $v
+ }
+}
+
+proc insertrow {id p v} {
+ global cmitlisted children parents varcid varctok vtokmod
+ global varccommits ordertok commitidx numcommits curview
+ global targetid targetrow
+
+ readcommit $id
+ set vid $v,$id
+ set cmitlisted($vid) 1
+ set children($vid) {}
+ set parents($vid) [list $p]
+ set a [newvarc $v $id]
+ set varcid($vid) $a
+ if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] < 0} {
+ modify_arc $v $a
+ }
+ lappend varccommits($v,$a) $id
+ set vp $v,$p
+ if {[llength [lappend children($vp) $id]] > 1} {
+ set children($vp) [lsort -command [list vtokcmp $v] $children($vp)]
+ catch {unset ordertok}
+ }
+ fix_reversal $p $a $v
+ incr commitidx($v)
+ if {$v == $curview} {
+ set numcommits $commitidx($v)
+ setcanvscroll
+ if {[info exists targetid]} {
+ if {![comes_before $targetid $p]} {
+ incr targetrow
+ }
+ }
+ }
+}
+
+proc insertfakerow {id p} {
+ global varcid varccommits parents children cmitlisted
+ global commitidx varctok vtokmod targetid targetrow curview numcommits
+
+ set v $curview
+ set a $varcid($v,$p)
+ set i [lsearch -exact $varccommits($v,$a) $p]
+ if {$i < 0} {
+ puts "oops: insertfakerow can't find [shortids $p] on arc $a"
+ return
+ }
+ set children($v,$id) {}
+ set parents($v,$id) [list $p]
+ set varcid($v,$id) $a
+ lappend children($v,$p) $id
+ set cmitlisted($v,$id) 1
+ set numcommits [incr commitidx($v)]
+ # note we deliberately don't update varcstart($v) even if $i == 0
+ set varccommits($v,$a) [linsert $varccommits($v,$a) $i $id]
+ modify_arc $v $a $i
+ if {[info exists targetid]} {
+ if {![comes_before $targetid $p]} {
+ incr targetrow
+ }
+ }
+ setcanvscroll
+ drawvisible
+}
+
+proc removefakerow {id} {
+ global varcid varccommits parents children commitidx
+ global varctok vtokmod cmitlisted currentid selectedline
+ global targetid curview numcommits
+
+ set v $curview
+ if {[llength $parents($v,$id)] != 1} {
+ puts "oops: removefakerow [shortids $id] has [llength $parents($v,$id)] parents"
+ return
+ }
+ set p [lindex $parents($v,$id) 0]
+ set a $varcid($v,$id)
+ set i [lsearch -exact $varccommits($v,$a) $id]
+ if {$i < 0} {
+ puts "oops: removefakerow can't find [shortids $id] on arc $a"
+ return
+ }
+ unset varcid($v,$id)
+ set varccommits($v,$a) [lreplace $varccommits($v,$a) $i $i]
+ unset parents($v,$id)
+ unset children($v,$id)
+ unset cmitlisted($v,$id)
+ set numcommits [incr commitidx($v) -1]
+ set j [lsearch -exact $children($v,$p) $id]
+ if {$j >= 0} {
+ set children($v,$p) [lreplace $children($v,$p) $j $j]
+ }
+ modify_arc $v $a $i
+ if {[info exist currentid] && $id eq $currentid} {
+ unset currentid
+ set selectedline {}
+ }
+ if {[info exists targetid] && $targetid eq $id} {
+ set targetid $p
+ }
+ setcanvscroll
+ drawvisible
+}
+
+proc first_real_child {vp} {
+ global children nullid nullid2
+
+ foreach id $children($vp) {
+ if {$id ne $nullid && $id ne $nullid2} {
+ return $id
+ }
+ }
+ return {}
+}
+
+proc last_real_child {vp} {
+ global children nullid nullid2
+
+ set kids $children($vp)
+ for {set i [llength $kids]} {[incr i -1] >= 0} {} {
+ set id [lindex $kids $i]
+ if {$id ne $nullid && $id ne $nullid2} {
+ return $id
+ }
+ }
+ return {}
+}
+
+proc vtokcmp {v a b} {
+ global varctok varcid
+
+ return [string compare [lindex $varctok($v) $varcid($v,$a)] \
+ [lindex $varctok($v) $varcid($v,$b)]]
+}
+
+# This assumes that if lim is not given, the caller has checked that
+# arc a's token is less than $vtokmod($v)
+proc modify_arc {v a {lim {}}} {
+ global varctok vtokmod varcmod varcrow vupptr curview vrowmod varccommits
+
+ if {$lim ne {}} {
+ set c [string compare [lindex $varctok($v) $a] $vtokmod($v)]
+ if {$c > 0} return
+ if {$c == 0} {
+ set r [lindex $varcrow($v) $a]
+ if {$r ne {} && $vrowmod($v) <= $r + $lim} return
+ }
+ }
+ set vtokmod($v) [lindex $varctok($v) $a]
+ set varcmod($v) $a
+ if {$v == $curview} {
+ while {$a != 0 && [lindex $varcrow($v) $a] eq {}} {
+ set a [lindex $vupptr($v) $a]
+ set lim {}
+ }
+ set r 0
+ if {$a != 0} {
+ if {$lim eq {}} {
+ set lim [llength $varccommits($v,$a)]
+ }
+ set r [expr {[lindex $varcrow($v) $a] + $lim}]
+ }
+ set vrowmod($v) $r
+ undolayout $r
+ }
+}
+
+proc update_arcrows {v} {
+ global vtokmod varcmod vrowmod varcrow commitidx currentid selectedline
+ global varcid vrownum varcorder varcix varccommits
+ global vupptr vdownptr vleftptr varctok
+ global displayorder parentlist curview cached_commitrow
+
+ if {$vrowmod($v) == $commitidx($v)} return
+ if {$v == $curview} {
+ if {[llength $displayorder] > $vrowmod($v)} {
+ set displayorder [lrange $displayorder 0 [expr {$vrowmod($v) - 1}]]
+ set parentlist [lrange $parentlist 0 [expr {$vrowmod($v) - 1}]]
+ }
+ catch {unset cached_commitrow}
+ }
+ set narctot [expr {[llength $varctok($v)] - 1}]
+ set a $varcmod($v)
+ while {$a != 0 && [lindex $varcix($v) $a] eq {}} {
+ # go up the tree until we find something that has a row number,
+ # or we get to a seed
+ set a [lindex $vupptr($v) $a]
+ }
+ if {$a == 0} {
+ set a [lindex $vdownptr($v) 0]
+ if {$a == 0} return
+ set vrownum($v) {0}
+ set varcorder($v) [list $a]
+ lset varcix($v) $a 0
+ lset varcrow($v) $a 0
+ set arcn 0
+ set row 0
+ } else {
+ set arcn [lindex $varcix($v) $a]
+ if {[llength $vrownum($v)] > $arcn + 1} {
+ set vrownum($v) [lrange $vrownum($v) 0 $arcn]
+ set varcorder($v) [lrange $varcorder($v) 0 $arcn]
+ }
+ set row [lindex $varcrow($v) $a]
+ }
+ while {1} {
+ set p $a
+ incr row [llength $varccommits($v,$a)]
+ # go down if possible
+ set b [lindex $vdownptr($v) $a]
+ if {$b == 0} {
+ # if not, go left, or go up until we can go left
+ while {$a != 0} {
+ set b [lindex $vleftptr($v) $a]
+ if {$b != 0} break
+ set a [lindex $vupptr($v) $a]
+ }
+ if {$a == 0} break
+ }
+ set a $b
+ incr arcn
+ lappend vrownum($v) $row
+ lappend varcorder($v) $a
+ lset varcix($v) $a $arcn
+ lset varcrow($v) $a $row
+ }
+ set vtokmod($v) [lindex $varctok($v) $p]
+ set varcmod($v) $p
+ set vrowmod($v) $row
+ if {[info exists currentid]} {
+ set selectedline [rowofcommit $currentid]
+ }
+}
+
+# Test whether view $v contains commit $id
+proc commitinview {id v} {
+ global varcid
+
+ return [info exists varcid($v,$id)]
+}
+
+# Return the row number for commit $id in the current view
+proc rowofcommit {id} {
+ global varcid varccommits varcrow curview cached_commitrow
+ global varctok vtokmod
+
+ set v $curview
+ if {![info exists varcid($v,$id)]} {
+ puts "oops rowofcommit no arc for [shortids $id]"
+ return {}
+ }
+ set a $varcid($v,$id)
+ if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] >= 0} {
+ update_arcrows $v
+ }
+ if {[info exists cached_commitrow($id)]} {
+ return $cached_commitrow($id)
+ }
+ set i [lsearch -exact $varccommits($v,$a) $id]
+ if {$i < 0} {
+ puts "oops didn't find commit [shortids $id] in arc $a"
+ return {}
+ }
+ incr i [lindex $varcrow($v) $a]
+ set cached_commitrow($id) $i
+ return $i
+}
+
+# Returns 1 if a is on an earlier row than b, otherwise 0
+proc comes_before {a b} {
+ global varcid varctok curview
+
+ set v $curview
+ if {$a eq $b || ![info exists varcid($v,$a)] || \
+ ![info exists varcid($v,$b)]} {
+ return 0
+ }
+ if {$varcid($v,$a) != $varcid($v,$b)} {
+ return [expr {[string compare [lindex $varctok($v) $varcid($v,$a)] \
+ [lindex $varctok($v) $varcid($v,$b)]] < 0}]
+ }
+ return [expr {[rowofcommit $a] < [rowofcommit $b]}]
+}
+
+proc bsearch {l elt} {
+ if {[llength $l] == 0 || $elt <= [lindex $l 0]} {
+ return 0
+ }
+ set lo 0
+ set hi [llength $l]
+ while {$hi - $lo > 1} {
+ set mid [expr {int(($lo + $hi) / 2)}]
+ set t [lindex $l $mid]
+ if {$elt < $t} {
+ set hi $mid
+ } elseif {$elt > $t} {
+ set lo $mid
+ } else {
+ return $mid
+ }
+ }
+ return $lo
+}
+
+# Make sure rows $start..$end-1 are valid in displayorder and parentlist
+proc make_disporder {start end} {
+ global vrownum curview commitidx displayorder parentlist
+ global varccommits varcorder parents vrowmod varcrow
+ global d_valid_start d_valid_end
+
+ if {$end > $vrowmod($curview)} {
+ update_arcrows $curview
+ }
+ set ai [bsearch $vrownum($curview) $start]
+ set start [lindex $vrownum($curview) $ai]
+ set narc [llength $vrownum($curview)]
+ for {set r $start} {$ai < $narc && $r < $end} {incr ai} {
+ set a [lindex $varcorder($curview) $ai]
+ set l [llength $displayorder]
+ set al [llength $varccommits($curview,$a)]
+ if {$l < $r + $al} {
+ if {$l < $r} {
+ set pad [ntimes [expr {$r - $l}] {}]
+ set displayorder [concat $displayorder $pad]
+ set parentlist [concat $parentlist $pad]
+ } elseif {$l > $r} {
+ set displayorder [lrange $displayorder 0 [expr {$r - 1}]]
+ set parentlist [lrange $parentlist 0 [expr {$r - 1}]]
+ }
+ foreach id $varccommits($curview,$a) {
+ lappend displayorder $id
+ lappend parentlist $parents($curview,$id)
+ }
+ } elseif {[lindex $displayorder [expr {$r + $al - 1}]] eq {}} {
+ set i $r
+ foreach id $varccommits($curview,$a) {
+ lset displayorder $i $id
+ lset parentlist $i $parents($curview,$id)
+ incr i
+ }
+ }
+ incr r $al
+ }
+}
+
+proc commitonrow {row} {
+ global displayorder
+
+ set id [lindex $displayorder $row]
+ if {$id eq {}} {
+ make_disporder $row [expr {$row + 1}]
+ set id [lindex $displayorder $row]
+ }
+ return $id
+}
+
+proc closevarcs {v} {
+ global varctok varccommits varcid parents children
+ global cmitlisted commitidx commitinterest vtokmod
+
+ set missing_parents 0
+ set scripts {}
+ set narcs [llength $varctok($v)]
+ for {set a 1} {$a < $narcs} {incr a} {
+ set id [lindex $varccommits($v,$a) end]
+ foreach p $parents($v,$id) {
+ if {[info exists varcid($v,$p)]} continue
+ # add p as a new commit
+ incr missing_parents
+ set cmitlisted($v,$p) 0
+ set parents($v,$p) {}
+ if {[llength $children($v,$p)] == 1 &&
+ [llength $parents($v,$id)] == 1} {
+ set b $a
+ } else {
+ set b [newvarc $v $p]
+ }
+ set varcid($v,$p) $b
+ if {[string compare [lindex $varctok($v) $b] $vtokmod($v)] < 0} {
+ modify_arc $v $b
+ }
+ lappend varccommits($v,$b) $p
+ incr commitidx($v)
+ if {[info exists commitinterest($p)]} {
+ foreach script $commitinterest($p) {
+ lappend scripts [string map [list "%I" $p] $script]
+ }
+ unset commitinterest($id)
+ }
+ }
+ }
+ if {$missing_parents > 0} {
+ foreach s $scripts {
+ eval $s
+ }
+ }
+}
+
+# Use $rwid as a substitute for $id, i.e. reparent $id's children to $rwid
+# Assumes we already have an arc for $rwid.
+proc rewrite_commit {v id rwid} {
+ global children parents varcid varctok vtokmod varccommits
+
+ foreach ch $children($v,$id) {
+ # make $rwid be $ch's parent in place of $id
+ set i [lsearch -exact $parents($v,$ch) $id]
+ if {$i < 0} {
+ puts "oops rewrite_commit didn't find $id in parent list for $ch"
+ }
+ set parents($v,$ch) [lreplace $parents($v,$ch) $i $i $rwid]
+ # add $ch to $rwid's children and sort the list if necessary
+ if {[llength [lappend children($v,$rwid) $ch]] > 1} {
+ set children($v,$rwid) [lsort -command [list vtokcmp $v] \
+ $children($v,$rwid)]
+ }
+ # fix the graph after joining $id to $rwid
+ set a $varcid($v,$ch)
+ fix_reversal $rwid $a $v
+ # parentlist is wrong for the last element of arc $a
+ # even if displayorder is right, hence the 3rd arg here
+ modify_arc $v $a [expr {[llength $varccommits($v,$a)] - 1}]
+ }
+}
+
+proc getcommitlines {fd inst view updating} {
+ global cmitlisted commitinterest leftover
+ global commitidx commitdata vdatemode
+ global parents children curview hlview
+ global idpending ordertok
+ global varccommits varcid varctok vtokmod vfilelimit
set stuff [read $fd 500000]
# git log doesn't terminate the last commit with a null...
- if {$stuff == {} && $leftover($view) ne {} && [eof $fd]} {
+ if {$stuff == {} && $leftover($inst) ne {} && [eof $fd]} {
set stuff "\0"
}
if {$stuff == {}} {
if {![eof $fd]} {
return 1
}
- # Check if we have seen any ids listed as parents that haven't
- # appeared in the list
- foreach vid [array names idpending "$view,*"] {
- # should only get here if git log is buggy
- set id [lindex [split $vid ","] 1]
- set commitrow($vid) $commitidx($view)
- incr commitidx($view)
- if {$view == $curview} {
- lappend parentlist {}
- lappend displayorder $id
- lappend commitlisted 0
- } else {
- lappend vparentlist($view) {}
- lappend vdisporder($view) $id
- lappend vcmitlisted($view) 0
- }
+ global commfd viewcomplete viewactive viewname
+ global viewinstances
+ unset commfd($inst)
+ set i [lsearch -exact $viewinstances($view) $inst]
+ if {$i >= 0} {
+ set viewinstances($view) [lreplace $viewinstances($view) $i $i]
}
- set viewcomplete($view) 1
- global viewname progresscoords
- unset commfd($view)
- notbusy $view
- set progresscoords {0 0}
- adjustprogress
# set it blocking so we wait for the process to terminate
fconfigure $fd -blocking 1
if {[catch {close $fd} err]} {
@@ -203,10 +1327,10 @@ proc getcommitlines {fd view} {
}
if {[string range $err 0 4] == "usage"} {
set err "Gitk: error reading commits$fv:\
- bad arguments to git rev-list."
+ bad arguments to git log."
if {$viewname($view) eq "Command line"} {
append err \
- " (Note: arguments to gitk are passed to git rev-list\
+ " (Note: arguments to gitk are passed to git log\
to allow selection of commits to be displayed.)"
}
} else {
@@ -214,23 +1338,31 @@ proc getcommitlines {fd view} {
}
error_popup $err
}
+ if {[incr viewactive($view) -1] <= 0} {
+ set viewcomplete($view) 1
+ # Check if we have seen any ids listed as parents that haven't
+ # appeared in the list
+ closevarcs $view
+ notbusy $view
+ }
if {$view == $curview} {
- run chewcommits $view
+ run chewcommits
}
return 0
}
set start 0
set gotsome 0
+ set scripts {}
while 1 {
set i [string first "\0" $stuff $start]
if {$i < 0} {
- append leftover($view) [string range $stuff $start end]
+ append leftover($inst) [string range $stuff $start end]
break
}
if {$start == 0} {
- set cmit $leftover($view)
+ set cmit $leftover($inst)
append cmit [string range $stuff 0 [expr {$i - 1}]]
- set leftover($view) {}
+ set leftover($inst) {}
} else {
set cmit [string range $stuff $start [expr {$i - 1}]]
}
@@ -240,11 +1372,12 @@ proc getcommitlines {fd view} {
set listed 1
if {$j >= 0 && [string match "commit *" $cmit]} {
set ids [string range $cmit 7 [expr {$j - 1}]]
- if {[string match {[-<>]*} $ids]} {
+ if {[string match {[-^<>]*} $ids]} {
switch -- [string index $ids 0] {
"-" {set listed 0}
- "<" {set listed 2}
- ">" {set listed 3}
+ "^" {set listed 2}
+ "<" {set listed 3}
+ ">" {set listed 4}
}
set ids [string range $ids 1 end]
}
@@ -265,121 +1398,134 @@ proc getcommitlines {fd view} {
exit 1
}
set id [lindex $ids 0]
- if {![info exists ordertok($view,$id)]} {
- set otok "o[strrep $vnextroot($view)]"
- incr vnextroot($view)
- set ordertok($view,$id) $otok
- } else {
- set otok $ordertok($view,$id)
- unset idpending($view,$id)
+ set vid $view,$id
+
+ if {!$listed && $updating && ![info exists varcid($vid)] &&
+ $vfilelimit($view) ne {}} {
+ # git log doesn't rewrite parents for unlisted commits
+ # when doing path limiting, so work around that here
+ # by working out the rewritten parent with git rev-list
+ # and if we already know about it, using the rewritten
+ # parent as a substitute parent for $id's children.
+ if {![catch {
+ set rwid [exec git rev-list --first-parent --max-count=1 \
+ $id -- $vfilelimit($view)]
+ }]} {
+ if {$rwid ne {} && [info exists varcid($view,$rwid)]} {
+ # use $rwid in place of $id
+ rewrite_commit $view $id $rwid
+ continue
+ }
+ }
+ }
+
+ set a 0
+ if {[info exists varcid($vid)]} {
+ if {$cmitlisted($vid) || !$listed} continue
+ set a $varcid($vid)
}
if {$listed} {
set olds [lrange $ids 1 end]
- if {[llength $olds] == 1} {
- set p [lindex $olds 0]
- lappend children($view,$p) $id
- if {![info exists ordertok($view,$p)]} {
- set ordertok($view,$p) $ordertok($view,$id)
- set idpending($view,$p) 1
- }
- } else {
- set i 0
- foreach p $olds {
- if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
- lappend children($view,$p) $id
- }
- if {![info exists ordertok($view,$p)]} {
- set ordertok($view,$p) "$otok[strrep $i]]"
- set idpending($view,$p) 1
- }
- incr i
- }
- }
} else {
set olds {}
}
- if {![info exists children($view,$id)]} {
- set children($view,$id) {}
- }
set commitdata($id) [string range $cmit [expr {$j + 1}] end]
- set commitrow($view,$id) $commitidx($view)
- incr commitidx($view)
- if {$view == $curview} {
- lappend parentlist $olds
- lappend displayorder $id
- lappend commitlisted $listed
- } else {
- lappend vparentlist($view) $olds
- lappend vdisporder($view) $id
- lappend vcmitlisted($view) $listed
+ set cmitlisted($vid) $listed
+ set parents($vid) $olds
+ if {![info exists children($vid)]} {
+ set children($vid) {}
+ } elseif {$a == 0 && [llength $children($vid)] == 1} {
+ set k [lindex $children($vid) 0]
+ if {[llength $parents($view,$k)] == 1 &&
+ (!$vdatemode($view) ||
+ $varcid($view,$k) == [llength $varctok($view)] - 1)} {
+ set a $varcid($view,$k)
+ }
+ }
+ if {$a == 0} {
+ # new arc
+ set a [newvarc $view $id]
+ }
+ if {[string compare [lindex $varctok($view) $a] $vtokmod($view)] < 0} {
+ modify_arc $view $a
+ }
+ if {![info exists varcid($vid)]} {
+ set varcid($vid) $a
+ lappend varccommits($view,$a) $id
+ incr commitidx($view)
}
+
+ set i 0
+ foreach p $olds {
+ if {$i == 0 || [lsearch -exact $olds $p] >= $i} {
+ set vp $view,$p
+ if {[llength [lappend children($vp) $id]] > 1 &&
+ [vtokcmp $view [lindex $children($vp) end-1] $id] > 0} {
+ set children($vp) [lsort -command [list vtokcmp $view] \
+ $children($vp)]
+ catch {unset ordertok}
+ }
+ if {[info exists varcid($view,$p)]} {
+ fix_reversal $p $a $view
+ }
+ }
+ incr i
+ }
+
if {[info exists commitinterest($id)]} {
foreach script $commitinterest($id) {
- eval [string map [list "%I" $id] $script]
+ lappend scripts [string map [list "%I" $id] $script]
}
unset commitinterest($id)
}
set gotsome 1
}
if {$gotsome} {
- run chewcommits $view
+ global numcommits hlview
+
if {$view == $curview} {
- # update progress bar
- global progressdirn progresscoords proglastnc
- set inc [expr {($commitidx($view) - $proglastnc) * 0.0002}]
- set proglastnc $commitidx($view)
- set l [lindex $progresscoords 0]
- set r [lindex $progresscoords 1]
- if {$progressdirn} {
- set r [expr {$r + $inc}]
- if {$r >= 1.0} {
- set r 1.0
- set progressdirn 0
- }
- if {$r > 0.2} {
- set l [expr {$r - 0.2}]
- }
- } else {
- set l [expr {$l - $inc}]
- if {$l <= 0.0} {
- set l 0.0
- set progressdirn 1
- }
- set r [expr {$l + 0.2}]
- }
- set progresscoords [list $l $r]
- adjustprogress
+ set numcommits $commitidx($view)
+ run chewcommits
+ }
+ if {[info exists hlview] && $view == $hlview} {
+ # we never actually get here...
+ run vhighlightmore
+ }
+ foreach s $scripts {
+ eval $s
}
}
return 2
}
-proc chewcommits {view} {
+proc chewcommits {} {
global curview hlview viewcomplete
- global selectedline pending_select
+ global pending_select
+
+ layoutmore
+ if {$viewcomplete($curview)} {
+ global commitidx varctok
+ global numcommits startmsecs
- if {$view == $curview} {
- layoutmore
- if {$viewcomplete($view)} {
- global displayorder commitidx phase
- global numcommits startmsecs
+ if {[info exists pending_select]} {
+ update
+ reset_pending_select {}
- if {[info exists pending_select]} {
+ if {[commitinview $pending_select $curview]} {
+ selectline [rowofcommit $pending_select] 1
+ } else {
set row [first_real_row]
selectline $row 1
}
- if {$commitidx($curview) > 0} {
- #set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
- #puts "overall $ms ms for $numcommits commits"
- } else {
- show_status [mc "No commits selected"]
- }
- notbusy layout
- set phase {}
}
- }
- if {[info exists hlview] && $view == $hlview} {
- vhighlightmore
+ if {$commitidx($curview) > 0} {
+ #set ms [expr {[clock clicks -milliseconds] - $startmsecs}]
+ #puts "overall $ms ms for $numcommits commits"
+ #puts "[llength $varctok($view)] arcs, $commitidx($view) commits"
+ } else {
+ show_status [mc "No commits selected"]
+ }
+ notbusy layout
}
return 0
}
@@ -389,35 +1535,6 @@ proc readcommit {id} {
parsecommit $id $contents 0
}
-proc updatecommits {} {
- global viewdata curview phase displayorder ordertok idpending
- global children commitrow selectedline thickerline showneartags
-
- if {$phase ne {}} {
- stop_rev_list
- set phase {}
- }
- set n $curview
- foreach id $displayorder {
- catch {unset children($n,$id)}
- catch {unset commitrow($n,$id)}
- catch {unset ordertok($n,$id)}
- }
- foreach vid [array names idpending "$n,*"] {
- unset idpending($vid)
- }
- set curview -1
- catch {unset selectedline}
- catch {unset thickerline}
- catch {unset viewdata($n)}
- readrefs
- changedrefs
- if {$showneartags} {
- getallcommits
- }
- showview $n
-}
-
proc parsecommit {id contents listed} {
global commitinfo cdate
@@ -458,7 +1575,7 @@ proc parsecommit {id contents listed} {
set headline [string trimright [string range $headline 0 $i]]
}
if {!$listed} {
- # git rev-list indents the comment by 4 spaces;
+ # git log indents the comment by 4 spaces;
# if we got this via git cat-file, add the indentation
set newcomment {}
foreach line [split $comment "\n"] {
@@ -532,22 +1649,20 @@ proc readrefs {} {
set mainhead {}
set mainheadid {}
catch {
+ set mainheadid [exec git rev-parse HEAD]
set thehead [exec git symbolic-ref HEAD]
if {[string match "refs/heads/*" $thehead]} {
set mainhead [string range $thehead 11 end]
- if {[info exists headids($mainhead)]} {
- set mainheadid $headids($mainhead)
- }
}
}
}
# skip over fake commits
proc first_real_row {} {
- global nullid nullid2 displayorder numcommits
+ global nullid nullid2 numcommits
for {set row 0} {$row < $numcommits} {incr row} {
- set id [lindex $displayorder $row]
+ set id [commitonrow $row]
if {$id ne $nullid && $id ne $nullid2} {
break
}
@@ -627,11 +1742,12 @@ proc setoptions {} {
}
proc makewindow {} {
- global canv canv2 canv3 linespc charspc ctext cflist
+ global canv canv2 canv3 linespc charspc ctext cflist cscroll
global tabstop
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
global diffcontextstring diffcontext
+ global ignorespace
global maincursor textcursor curtextcursor
global rowctxmenu fakerowmenu mergemax wrapcomment
global highlight_files gdttype
@@ -639,13 +1755,14 @@ proc makewindow {} {
global bgcolor fgcolor bglist fglist diffcolors selectbgcolor
global headctxmenu progresscanv progressitem progresscoords statusw
global fprogitem fprogcoord lastprogupdate progupdatepending
- global rprogitem rprogcoord
+ global rprogitem rprogcoord rownumsel numcommits
global have_tk85
menu .bar
.bar add cascade -label [mc "File"] -menu .bar.file
menu .bar.file
.bar.file add command -label [mc "Update"] -command updatecommits
+ .bar.file add command -label [mc "Reload"] -command reloadcommits
.bar.file add command -label [mc "Reread references"] -command rereadrefs
.bar.file add command -label [mc "List references"] -command showrefs
.bar.file add command -label [mc "Quit"] -command doquit
@@ -754,6 +1871,18 @@ proc makewindow {} {
-state disabled -width 26
pack .tf.bar.rightbut -side left -fill y
+ label .tf.bar.rowlabel -text [mc "Row"]
+ set rownumsel {}
+ label .tf.bar.rownum -width 7 -font textfont -textvariable rownumsel \
+ -relief sunken -anchor e
+ label .tf.bar.rowlabel2 -text "/"
+ label .tf.bar.numcommits -width 7 -font textfont -textvariable numcommits \
+ -relief sunken -anchor e
+ pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
+ -side left
+ global selectedline
+ trace add variable selectedline write selectedline_change
+
# Status label and progress bar
set statusw .tf.bar.status
label $statusw -width 15 -relief sunken
@@ -825,6 +1954,7 @@ proc makewindow {} {
}
frame .bleft.top
frame .bleft.mid
+ frame .bleft.bottom
button .bleft.top.search -text [mc "Search"] -command dosearch
pack .bleft.top.search -side left -padx 5
@@ -849,18 +1979,28 @@ proc makewindow {} {
trace add variable diffcontextstring write diffcontextchange
lappend entries .bleft.mid.diffcontext
pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
- set ctext .bleft.ctext
+ checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
+ -command changeignorespace -variable ignorespace
+ pack .bleft.mid.ignspace -side left -padx 5
+ set ctext .bleft.bottom.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-state disabled -font textfont \
- -yscrollcommand scrolltext -wrap none
+ -yscrollcommand scrolltext -wrap none \
+ -xscrollcommand ".bleft.bottom.sbhorizontal set"
if {$have_tk85} {
$ctext conf -tabstyle wordprocessor
}
- scrollbar .bleft.sb -command "$ctext yview"
+ scrollbar .bleft.bottom.sb -command "$ctext yview"
+ scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \
+ -width 10
pack .bleft.top -side top -fill x
pack .bleft.mid -side top -fill x
- pack .bleft.sb -side right -fill y
- pack $ctext -side left -fill both -expand 1
+ grid $ctext .bleft.bottom.sb -sticky nsew
+ grid .bleft.bottom.sbhorizontal -sticky ew
+ grid columnconfigure .bleft.bottom 0 -weight 1
+ grid rowconfigure .bleft.bottom 0 -weight 1
+ grid rowconfigure .bleft.bottom 1 -weight 0
+ pack .bleft.bottom -side top -fill both -expand 1
lappend bglist $ctext
lappend fglist $ctext
@@ -925,9 +2065,17 @@ proc makewindow {} {
.pwbottom add .bright
.ctop add .pwbottom
- # restore window position if known
+ # restore window width & height if known
if {[info exists geometry(main)]} {
- wm geometry . "$geometry(main)"
+ if {[scan $geometry(main) "%dx%d" w h] >= 2} {
+ if {$w > [winfo screenwidth .]} {
+ set w [winfo screenwidth .]
+ }
+ if {$h > [winfo screenheight .]} {
+ set h [winfo screenheight .]
+ }
+ wm geometry . "${w}x$h"
+ }
}
if {[tk windowingsystem] eq {aqua}} {
@@ -982,7 +2130,7 @@ proc makewindow {} {
bindkey k "selnextline 1"
bindkey j "goback"
bindkey l "goforw"
- bindkey b "$ctext yview scroll -1 pages"
+ bindkey b prevfile
bindkey d "$ctext yview scroll 18 units"
bindkey u "$ctext yview scroll -18 units"
bindkey / {dofind 1 1}
@@ -1001,6 +2149,7 @@ proc makewindow {} {
bind . <$M1B-minus> {incrfont -1}
bind . <$M1B-KP_Subtract> {incrfont -1}
wm protocol . WM_DELETE_WINDOW doquit
+ bind . <Destroy> {stop_backends}
bind . <Button-1> "click %W"
bind $fstring <Key-Return> {dofind 1 1}
bind $sha1entry <Key-Return> gotocommit
@@ -1054,6 +2203,8 @@ proc makewindow {} {
-command {flist_hl 0}
$flist_menu add command -label [mc "Highlight this only"] \
-command {flist_hl 1}
+ $flist_menu add command -label [mc "External diff"] \
+ -command {external_diff}
}
# Windows sends all mouse wheel events to the current focused window, not
@@ -1074,6 +2225,17 @@ proc windows_mousewheel_redirector {W X Y D} {
}
}
+# Update row number label when selectedline changes
+proc selectedline_change {n1 n2 op} {
+ global selectedline rownumsel
+
+ if {$selectedline eq {}} {
+ set rownumsel {}
+ } else {
+ set rownumsel [expr {$selectedline + 1}]
+ }
+}
+
# mouse-2 makes all windows scan vertically, but only the one
# the cursor is in scans horizontally
proc canvscan {op w x y} {
@@ -1089,7 +2251,7 @@ proc canvscan {op w x y} {
proc scrollcanv {cscroll f0 f1} {
$cscroll set $f0 $f1
- drawfrac $f0 $f1
+ drawvisible
flushhighlights
}
@@ -1155,9 +2317,10 @@ proc savestuff {w} {
global canv canv2 canv3 mainfont textfont uifont tabstop
global stuffsaved findmergefiles maxgraphpct
global maxwidth showneartags showlocalchanges
- global viewname viewfiles viewargs viewperm nextviewnum
+ global viewname viewfiles viewargs viewargscmd viewperm nextviewnum
global cmitmode wrapcomment datetimeformat limitdiffs
global colors bgcolor fgcolor diffcolors diffcontext selectbgcolor
+ global autoselect extdifftool
if {$stuffsaved} return
if {![winfo viewable .]} return
@@ -1172,6 +2335,7 @@ proc savestuff {w} {
puts $f [list set maxwidth $maxwidth]
puts $f [list set cmitmode $cmitmode]
puts $f [list set wrapcomment $wrapcomment]
+ puts $f [list set autoselect $autoselect]
puts $f [list set showneartags $showneartags]
puts $f [list set showlocalchanges $showlocalchanges]
puts $f [list set datetimeformat $datetimeformat]
@@ -1182,6 +2346,7 @@ proc savestuff {w} {
puts $f [list set diffcolors $diffcolors]
puts $f [list set diffcontext $diffcontext]
puts $f [list set selectbgcolor $selectbgcolor]
+ puts $f [list set extdifftool $extdifftool]
puts $f "set geometry(main) [wm geometry .]"
puts $f "set geometry(topwidth) [winfo width .tf]"
@@ -1194,7 +2359,7 @@ proc savestuff {w} {
puts -nonewline $f "set permviews {"
for {set v 0} {$v < $nextviewnum} {incr v} {
if {$viewperm($v)} {
- puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v)]}"
+ puts $f "{[list $viewname($v) $viewfiles($v) $viewargs($v) $viewargscmd($v)]}"
}
}
puts $f "}"
@@ -1282,7 +2447,7 @@ proc about {} {
message $w.m -text [mc "
Gitk - a commit viewer for git
-Copyright © 2005-2006 Paul Mackerras
+Copyright © 2005-2008 Paul Mackerras
Use and redistribute under the terms of the GNU General Public License"] \
-justify center -aspect 400 -border 2 -bg white -relief groove
@@ -1307,45 +2472,45 @@ proc keys {} {
}
toplevel $w
wm title $w [mc "Gitk key bindings"]
- message $w.m -text [mc "
-Gitk key bindings:
-
-<$M1T-Q> Quit
-<Home> Move to first commit
-<End> Move to last commit
-<Up>, p, i Move up one commit
-<Down>, n, k Move down one commit
-<Left>, z, j Go back in history list
-<Right>, x, l Go forward in history list
-<PageUp> Move up one page in commit list
-<PageDown> Move down one page in commit list
-<$M1T-Home> Scroll to top of commit list
-<$M1T-End> Scroll to bottom of commit list
-<$M1T-Up> Scroll commit list up one line
-<$M1T-Down> Scroll commit list down one line
-<$M1T-PageUp> Scroll commit list up one page
-<$M1T-PageDown> Scroll commit list down one page
-<Shift-Up> Find backwards (upwards, later commits)
-<Shift-Down> Find forwards (downwards, earlier commits)
-<Delete>, b Scroll diff view up one page
-<Backspace> Scroll diff view up one page
-<Space> Scroll diff view down one page
-u Scroll diff view up 18 lines
-d Scroll diff view down 18 lines
-<$M1T-F> Find
-<$M1T-G> Move to next find hit
-<Return> Move to next find hit
-/ Move to next find hit, or redo find
-? Move to previous find hit
-f Scroll diff view to next file
-<$M1T-S> Search for next hit in diff view
-<$M1T-R> Search for previous hit in diff view
-<$M1T-KP+> Increase font size
-<$M1T-plus> Increase font size
-<$M1T-KP-> Decrease font size
-<$M1T-minus> Decrease font size
-<F5> Update
-"] \
+ message $w.m -text "
+[mc "Gitk key bindings:"]
+
+[mc "<%s-Q> Quit" $M1T]
+[mc "<Home> Move to first commit"]
+[mc "<End> Move to last commit"]
+[mc "<Up>, p, i Move up one commit"]
+[mc "<Down>, n, k Move down one commit"]
+[mc "<Left>, z, j Go back in history list"]
+[mc "<Right>, x, l Go forward in history list"]
+[mc "<PageUp> Move up one page in commit list"]
+[mc "<PageDown> Move down one page in commit list"]
+[mc "<%s-Home> Scroll to top of commit list" $M1T]
+[mc "<%s-End> Scroll to bottom of commit list" $M1T]
+[mc "<%s-Up> Scroll commit list up one line" $M1T]
+[mc "<%s-Down> Scroll commit list down one line" $M1T]
+[mc "<%s-PageUp> Scroll commit list up one page" $M1T]
+[mc "<%s-PageDown> Scroll commit list down one page" $M1T]
+[mc "<Shift-Up> Find backwards (upwards, later commits)"]
+[mc "<Shift-Down> Find forwards (downwards, earlier commits)"]
+[mc "<Delete>, b Scroll diff view up one page"]
+[mc "<Backspace> Scroll diff view up one page"]
+[mc "<Space> Scroll diff view down one page"]
+[mc "u Scroll diff view up 18 lines"]
+[mc "d Scroll diff view down 18 lines"]
+[mc "<%s-F> Find" $M1T]
+[mc "<%s-G> Move to next find hit" $M1T]
+[mc "<Return> Move to next find hit"]
+[mc "/ Move to next find hit, or redo find"]
+[mc "? Move to previous find hit"]
+[mc "f Scroll diff view to next file"]
+[mc "<%s-S> Search for next hit in diff view" $M1T]
+[mc "<%s-R> Search for previous hit in diff view" $M1T]
+[mc "<%s-KP+> Increase font size" $M1T]
+[mc "<%s-plus> Increase font size" $M1T]
+[mc "<%s-KP-> Decrease font size" $M1T]
+[mc "<%s-minus> Decrease font size" $M1T]
+[mc "<F5> Update"]
+" \
-justify left -bg white -border 2 -relief groove
pack $w.m -side top -fill both -padx 2 -pady 2
button $w.ok -text [mc "Close"] -command "destroy $w" -default active
@@ -1639,7 +2804,7 @@ image create bitmap reficon-o -background black -foreground "#ddddff" \
-data $rectdata -maskdata $rectmask
proc init_flist {first} {
- global cflist cflist_top selectedline difffilestart
+ global cflist cflist_top difffilestart
$cflist conf -state normal
$cflist delete 0.0 end
@@ -1732,6 +2897,12 @@ proc pop_flist_menu {w X Y x y} {
set e [lindex $treediffs($diffids) [expr {$l-2}]]
}
set flist_menu_file $e
+ set xdiffstate "normal"
+ if {$cmitmode eq "tree"} {
+ set xdiffstate "disabled"
+ }
+ # Disable "External diff" item in tree mode
+ $flist_menu entryconf 2 -state $xdiffstate
tk_popup $flist_menu $X $Y
}
@@ -1747,6 +2918,113 @@ proc flist_hl {only} {
set gdttype [mc "touching paths:"]
}
+proc save_file_from_commit {filename output what} {
+ global nullfile
+
+ if {[catch {exec git show $filename -- > $output} err]} {
+ if {[string match "fatal: bad revision *" $err]} {
+ return $nullfile
+ }
+ error_popup "Error getting \"$filename\" from $what: $err"
+ return {}
+ }
+ return $output
+}
+
+proc external_diff_get_one_file {diffid filename diffdir} {
+ global nullid nullid2 nullfile
+ global gitdir
+
+ if {$diffid == $nullid} {
+ set difffile [file join [file dirname $gitdir] $filename]
+ if {[file exists $difffile]} {
+ return $difffile
+ }
+ return $nullfile
+ }
+ if {$diffid == $nullid2} {
+ set difffile [file join $diffdir "\[index\] [file tail $filename]"]
+ return [save_file_from_commit :$filename $difffile index]
+ }
+ set difffile [file join $diffdir "\[$diffid\] [file tail $filename]"]
+ return [save_file_from_commit $diffid:$filename $difffile \
+ "revision $diffid"]
+}
+
+proc external_diff {} {
+ global gitktmpdir nullid nullid2
+ global flist_menu_file
+ global diffids
+ global diffnum
+ global gitdir extdifftool
+
+ if {[llength $diffids] == 1} {
+ # no reference commit given
+ set diffidto [lindex $diffids 0]
+ if {$diffidto eq $nullid} {
+ # diffing working copy with index
+ set diffidfrom $nullid2
+ } elseif {$diffidto eq $nullid2} {
+ # diffing index with HEAD
+ set diffidfrom "HEAD"
+ } else {
+ # use first parent commit
+ global parentlist selectedline
+ set diffidfrom [lindex $parentlist $selectedline 0]
+ }
+ } else {
+ set diffidfrom [lindex $diffids 0]
+ set diffidto [lindex $diffids 1]
+ }
+
+ # make sure that several diffs wont collide
+ if {![info exists gitktmpdir]} {
+ set gitktmpdir [file join [file dirname $gitdir] \
+ [format ".gitk-tmp.%s" [pid]]]
+ if {[catch {file mkdir $gitktmpdir} err]} {
+ error_popup "Error creating temporary directory $gitktmpdir: $err"
+ unset gitktmpdir
+ return
+ }
+ set diffnum 0
+ }
+ incr diffnum
+ set diffdir [file join $gitktmpdir $diffnum]
+ if {[catch {file mkdir $diffdir} err]} {
+ error_popup "Error creating temporary directory $diffdir: $err"
+ return
+ }
+
+ # gather files to diff
+ set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir]
+ set difftofile [external_diff_get_one_file $diffidto $flist_menu_file $diffdir]
+
+ if {$difffromfile ne {} && $difftofile ne {}} {
+ set cmd [concat | [shellsplit $extdifftool] \
+ [list $difffromfile $difftofile]]
+ if {[catch {set fl [open $cmd r]} err]} {
+ file delete -force $diffdir
+ error_popup [mc "$extdifftool: command failed: $err"]
+ } else {
+ fconfigure $fl -blocking 0
+ filerun $fl [list delete_at_eof $fl $diffdir]
+ }
+ }
+}
+
+# delete $dir when we see eof on $f (presumably because the child has exited)
+proc delete_at_eof {f dir} {
+ while {[gets $f line] >= 0} {}
+ if {[eof $f]} {
+ if {[catch {close $f} err]} {
+ error_popup "External diff viewer failed: $err"
+ }
+ file delete -force $dir
+ return 0
+ }
+ return 1
+}
+
# Functions for adding and removing shell-type quoting
proc shellquote {str} {
@@ -1845,7 +3123,7 @@ proc shellsplit {str} {
proc newview {ishighlight} {
global nextviewnum newviewname newviewperm newishighlight
- global newviewargs revtreeargs
+ global newviewargs revtreeargs viewargscmd newviewargscmd curview
set newishighlight $ishighlight
set top .gitkview
@@ -1853,16 +3131,17 @@ proc newview {ishighlight} {
raise $top
return
}
- set newviewname($nextviewnum) "View $nextviewnum"
+ set newviewname($nextviewnum) "[mc "View"] $nextviewnum"
set newviewperm($nextviewnum) 0
set newviewargs($nextviewnum) [shellarglist $revtreeargs]
+ set newviewargscmd($nextviewnum) $viewargscmd($curview)
vieweditor $top $nextviewnum [mc "Gitk view definition"]
}
proc editview {} {
global curview
global viewname viewperm newviewname newviewperm
- global viewargs newviewargs
+ global viewargs newviewargs viewargscmd newviewargscmd
set top .gitkvedit-$curview
if {[winfo exists $top]} {
@@ -1872,6 +3151,7 @@ proc editview {} {
set newviewname($curview) $viewname($curview)
set newviewperm($curview) $viewperm($curview)
set newviewargs($curview) [shellarglist $viewargs($curview)]
+ set newviewargscmd($curview) $viewargscmd($curview)
vieweditor $top $curview "Gitk: edit view $viewname($curview)"
}
@@ -1887,11 +3167,19 @@ proc vieweditor {top n title} {
-variable newviewperm($n)
grid $top.perm - -pady 5 -sticky w
message $top.al -aspect 1000 \
- -text [mc "Commits to include (arguments to git rev-list):"]
+ -text [mc "Commits to include (arguments to git log):"]
grid $top.al - -sticky w -pady 5
entry $top.args -width 50 -textvariable newviewargs($n) \
-background $bgcolor
grid $top.args - -sticky ew -padx 5
+
+ message $top.ac -aspect 1000 \
+ -text [mc "Command to generate more commits to include:"]
+ grid $top.ac - -sticky w -pady 5
+ entry $top.argscmd -width 50 -textvariable newviewargscmd($n) \
+ -background white
+ grid $top.argscmd - -sticky ew -padx 5
+
message $top.l -aspect 1000 \
-text [mc "Enter files and directories to include, one per line:"]
grid $top.l - -sticky w
@@ -1935,7 +3223,7 @@ proc allviewmenus {n op args} {
proc newviewok {top n} {
global nextviewnum newviewperm newviewname newishighlight
global viewname viewfiles viewperm selectedview curview
- global viewargs newviewargs viewhlmenu
+ global viewargs newviewargs viewargscmd newviewargscmd viewhlmenu
if {[catch {
set newargs [shellsplit $newviewargs($n)]
@@ -1959,6 +3247,7 @@ proc newviewok {top n} {
set viewperm($n) $newviewperm($n)
set viewfiles($n) $files
set viewargs($n) $newargs
+ set viewargscmd($n) $newviewargscmd($n)
addviewmenu $n
if {!$newishighlight} {
run showview $n
@@ -1975,11 +3264,13 @@ proc newviewok {top n} {
# doviewmenu $viewhlmenu 1 [list addvhighlight $n] \
# entryconf [list -label $viewname($n) -value $viewname($n)]
}
- if {$files ne $viewfiles($n) || $newargs ne $viewargs($n)} {
+ if {$files ne $viewfiles($n) || $newargs ne $viewargs($n) || \
+ $newviewargscmd($n) ne $viewargscmd($n)} {
set viewfiles($n) $files
set viewargs($n) $newargs
+ set viewargscmd($n) $newviewargscmd($n)
if {$curview == $n} {
- run updatecommits
+ run reloadcommits
}
}
}
@@ -1987,7 +3278,7 @@ proc newviewok {top n} {
}
proc delview {} {
- global curview viewdata viewperm hlview selectedhlview
+ global curview viewperm hlview selectedhlview
if {$curview == 0} return
if {[info exists hlview] && $hlview == $curview} {
@@ -1995,7 +3286,6 @@ proc delview {} {
unset hlview
}
allviewmenus $curview delete
- set viewdata($curview) {}
set viewperm($curview) 0
showview 0
}
@@ -2009,52 +3299,30 @@ proc addviewmenu {n} {
# -command [list addvhighlight $n] -variable selectedhlview
}
-proc flatten {var} {
- global $var
-
- set ret {}
- foreach i [array names $var] {
- lappend ret $i [set $var\($i\)]
- }
- return $ret
-}
-
-proc unflatten {var l} {
- global $var
-
- catch {unset $var}
- foreach {i v} $l {
- set $var\($i\) $v
- }
-}
-
proc showview {n} {
- global curview viewdata viewfiles
+ global curview cached_commitrow ordertok
global displayorder parentlist rowidlist rowisopt rowfinal
- global colormap rowtextx commitrow nextcolor canvxmax
- global numcommits commitlisted
+ global colormap rowtextx nextcolor canvxmax
+ global numcommits viewcomplete
global selectedline currentid canv canvy0
global treediffs
- global pending_select phase
+ global pending_select mainheadid
global commitidx
- global commfd
- global selectedview selectfirst
- global vparentlist vdisporder vcmitlisted
+ global selectedview
global hlview selectedhlview commitinterest
if {$n == $curview} return
set selid {}
- if {[info exists selectedline]} {
+ set ymax [lindex [$canv cget -scrollregion] 3]
+ set span [$canv yview]
+ set ytop [expr {[lindex $span 0] * $ymax}]
+ set ybot [expr {[lindex $span 1] * $ymax}]
+ set yscreen [expr {($ybot - $ytop) / 2}]
+ if {$selectedline ne {}} {
set selid $currentid
set y [yc $selectedline]
- set ymax [lindex [$canv cget -scrollregion] 3]
- set span [$canv yview]
- set ytop [expr {[lindex $span 0] * $ymax}]
- set ybot [expr {[lindex $span 1] * $ymax}]
if {$ytop < $y && $y < $ybot} {
set yscreen [expr {$y - $ytop}]
- } else {
- set yscreen [expr {($ybot - $ytop) / 2}]
}
} elseif {[info exists pending_select]} {
set selid $pending_select
@@ -2062,17 +3330,6 @@ proc showview {n} {
}
unselectline
normalline
- if {$curview >= 0} {
- set vparentlist($curview) $parentlist
- set vdisporder($curview) $displayorder
- set vcmitlisted($curview) $commitlisted
- if {$phase ne {} ||
- ![info exists viewdata($curview)] ||
- [lindex $viewdata($curview) 0] ne {}} {
- set viewdata($curview) \
- [list $phase $rowidlist $rowisopt $rowfinal]
- }
- }
catch {unset treediffs}
clear_display
if {[info exists hlview] && $hlview == $n} {
@@ -2080,6 +3337,8 @@ proc showview {n} {
set selectedhlview [mc "None"]
}
catch {unset commitinterest}
+ catch {unset cached_commitrow}
+ catch {unset ordertok}
set curview $n
set selectedview $n
@@ -2087,22 +3346,16 @@ proc showview {n} {
.bar.view entryconf [mc "Delete view"] -state [expr {$n == 0? "disabled": "normal"}]
run refill_reflist
- if {![info exists viewdata($n)]} {
- if {$selid ne {}} {
- set pending_select $selid
- }
- getcommits
+ if {![info exists viewcomplete($n)]} {
+ getcommits $selid
return
}
- set v $viewdata($n)
- set phase [lindex $v 0]
- set displayorder $vdisporder($n)
- set parentlist $vparentlist($n)
- set commitlisted $vcmitlisted($n)
- set rowidlist [lindex $v 1]
- set rowisopt [lindex $v 2]
- set rowfinal [lindex $v 3]
+ set displayorder {}
+ set parentlist {}
+ set rowidlist {}
+ set rowisopt {}
+ set rowfinal {}
set numcommits $commitidx($n)
catch {unset colormap}
@@ -2114,9 +3367,8 @@ proc showview {n} {
setcanvscroll
set yf 0
set row {}
- set selectfirst 0
- if {$selid ne {} && [info exists commitrow($n,$selid)]} {
- set row $commitrow($n,$selid)
+ if {$selid ne {} && [commitinview $selid $n]} {
+ set row [rowofcommit $selid]
# try to get the selected row in the same position on the screen
set ymax [lindex [$canv cget -scrollregion] 3]
set ytop [expr {[yc $row] - $yscreen}]
@@ -2129,21 +3381,24 @@ proc showview {n} {
drawvisible
if {$row ne {}} {
selectline $row 0
- } elseif {$selid ne {}} {
- set pending_select $selid
+ } elseif {!$viewcomplete($n)} {
+ reset_pending_select $selid
} else {
- set row [first_real_row]
- if {$row < $numcommits} {
- selectline $row 0
+ reset_pending_select {}
+
+ if {[commitinview $pending_select $curview]} {
+ selectline [rowofcommit $pending_select] 1
} else {
- set selectfirst 1
+ set row [first_real_row]
+ if {$row < $numcommits} {
+ selectline $row 0
+ }
}
}
- if {$phase ne {}} {
- if {$phase eq "getcommits"} {
+ if {!$viewcomplete($n)} {
+ if {$numcommits == 0} {
show_status [mc "Reading commits..."]
}
- run chewcommits $n
} elseif {$numcommits == 0} {
show_status [mc "No commits selected"]
}
@@ -2151,20 +3406,20 @@ proc showview {n} {
# Stuff relating to the highlighting facility
-proc ishighlighted {row} {
+proc ishighlighted {id} {
global vhighlights fhighlights nhighlights rhighlights
- if {[info exists nhighlights($row)] && $nhighlights($row) > 0} {
- return $nhighlights($row)
+ if {[info exists nhighlights($id)] && $nhighlights($id) > 0} {
+ return $nhighlights($id)
}
- if {[info exists vhighlights($row)] && $vhighlights($row) > 0} {
- return $vhighlights($row)
+ if {[info exists vhighlights($id)] && $vhighlights($id) > 0} {
+ return $vhighlights($id)
}
- if {[info exists fhighlights($row)] && $fhighlights($row) > 0} {
- return $fhighlights($row)
+ if {[info exists fhighlights($id)] && $fhighlights($id) > 0} {
+ return $fhighlights($id)
}
- if {[info exists rhighlights($row)] && $rhighlights($row) > 0} {
- return $rhighlights($row)
+ if {[info exists rhighlights($id)] && $rhighlights($id) > 0} {
+ return $rhighlights($id)
}
return 0
}
@@ -2174,7 +3429,7 @@ proc bolden {row font} {
lappend boldrows $row
$canv itemconf $linehtag($row) -font $font
- if {[info exists selectedline] && $row == $selectedline} {
+ if {$row == $selectedline} {
$canv delete secsel
set t [eval $canv create rect [$canv bbox $linehtag($row)] \
-outline {{}} -tags secsel \
@@ -2188,7 +3443,7 @@ proc bolden_name {row font} {
lappend boldnamerows $row
$canv2 itemconf $linentag($row) -font $font
- if {[info exists selectedline] && $row == $selectedline} {
+ if {$row == $selectedline} {
$canv2 delete secsel
set t [eval $canv2 create rect [$canv2 bbox $linentag($row)] \
-outline {{}} -tags secsel \
@@ -2202,7 +3457,7 @@ proc unbolden {} {
set stillbold {}
foreach row $boldrows {
- if {![ishighlighted $row]} {
+ if {![ishighlighted [commitonrow $row]]} {
bolden $row mainfont
} else {
lappend stillbold $row
@@ -2212,17 +3467,13 @@ proc unbolden {} {
}
proc addvhighlight {n} {
- global hlview curview viewdata vhl_done vhighlights commitidx
+ global hlview viewcomplete curview vhl_done commitidx
if {[info exists hlview]} {
delvhighlight
}
set hlview $n
- if {$n != $curview && ![info exists viewdata($n)]} {
- set viewdata($n) [list getcommits {{}} 0 0 0]
- set vparentlist($n) {}
- set vdisporder($n) {}
- set vcmitlisted($n) {}
+ if {$n != $curview && ![info exists viewcomplete($n)]} {
start_rev_list $n
}
set vhl_done $commitidx($hlview)
@@ -2241,43 +3492,38 @@ proc delvhighlight {} {
}
proc vhighlightmore {} {
- global hlview vhl_done commitidx vhighlights
- global displayorder vdisporder curview
+ global hlview vhl_done commitidx vhighlights curview
set max $commitidx($hlview)
- if {$hlview == $curview} {
- set disp $displayorder
- } else {
- set disp $vdisporder($hlview)
- }
set vr [visiblerows]
set r0 [lindex $vr 0]
set r1 [lindex $vr 1]
for {set i $vhl_done} {$i < $max} {incr i} {
- set id [lindex $disp $i]
- if {[info exists commitrow($curview,$id)]} {
- set row $commitrow($curview,$id)
+ set id [commitonrow $i $hlview]
+ if {[commitinview $id $curview]} {
+ set row [rowofcommit $id]
if {$r0 <= $row && $row <= $r1} {
if {![highlighted $row]} {
bolden $row mainfontbold
}
- set vhighlights($row) 1
+ set vhighlights($id) 1
}
}
}
set vhl_done $max
+ return 0
}
proc askvhighlight {row id} {
- global hlview vhighlights commitrow iddrawn
+ global hlview vhighlights iddrawn
- if {[info exists commitrow($hlview,$id)]} {
- if {[info exists iddrawn($id)] && ![ishighlighted $row]} {
+ if {[commitinview $id $hlview]} {
+ if {[info exists iddrawn($id)] && ![ishighlighted $id]} {
bolden $row mainfontbold
}
- set vhighlights($row) 1
+ set vhighlights($id) 1
} else {
- set vhighlights($row) 0
+ set vhighlights($id) 0
}
}
@@ -2415,12 +3661,12 @@ proc askfilehighlight {row id} {
global filehighlight fhighlights fhl_list
lappend fhl_list $id
- set fhighlights($row) -1
+ set fhighlights($id) -1
puts $filehighlight $id
}
proc readfhighlight {} {
- global filehighlight fhighlights commitrow curview iddrawn
+ global filehighlight fhighlights curview iddrawn
global fhl_list find_dirn
if {![info exists filehighlight]} {
@@ -2433,18 +3679,16 @@ proc readfhighlight {} {
if {$i < 0} continue
for {set j 0} {$j < $i} {incr j} {
set id [lindex $fhl_list $j]
- if {[info exists commitrow($curview,$id)]} {
- set fhighlights($commitrow($curview,$id)) 0
- }
+ set fhighlights($id) 0
}
set fhl_list [lrange $fhl_list [expr {$i+1}] end]
if {$line eq {}} continue
- if {![info exists commitrow($curview,$line)]} continue
- set row $commitrow($curview,$line)
- if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
+ if {![commitinview $line $curview]} continue
+ set row [rowofcommit $line]
+ if {[info exists iddrawn($line)] && ![ishighlighted $line]} {
bolden $row mainfontbold
}
- set fhighlights($row) 1
+ set fhighlights($line) 1
}
if {[eof $filehighlight]} {
# strange...
@@ -2493,7 +3737,7 @@ proc askfindhighlight {row id} {
}
}
if {$isbold && [info exists iddrawn($id)]} {
- if {![ishighlighted $row]} {
+ if {![ishighlighted $id]} {
bolden $row mainfontbold
if {$isbold > 1} {
bolden_name $row mainfontbold
@@ -2503,7 +3747,7 @@ proc askfindhighlight {row id} {
markrowmatches $row $id
}
}
- set nhighlights($row) $isbold
+ set nhighlights($id) $isbold
}
proc markrowmatches {row id} {
@@ -2541,7 +3785,7 @@ proc vrel_change {name ix op} {
# prepare for testing whether commits are descendents or ancestors of a
proc rhighlight_sel {a} {
global descendent desc_todo ancestor anc_todo
- global highlight_related rhighlights
+ global highlight_related
catch {unset descendent}
set desc_todo [list $a]
@@ -2561,16 +3805,16 @@ proc rhighlight_none {} {
}
proc is_descendent {a} {
- global curview children commitrow descendent desc_todo
+ global curview children descendent desc_todo
set v $curview
- set la $commitrow($v,$a)
+ set la [rowofcommit $a]
set todo $desc_todo
set leftover {}
set done 0
for {set i 0} {$i < [llength $todo]} {incr i} {
set do [lindex $todo $i]
- if {$commitrow($v,$do) < $la} {
+ if {[rowofcommit $do] < $la} {
lappend leftover $do
continue
}
@@ -2593,20 +3837,20 @@ proc is_descendent {a} {
}
proc is_ancestor {a} {
- global curview parentlist commitrow ancestor anc_todo
+ global curview parents ancestor anc_todo
set v $curview
- set la $commitrow($v,$a)
+ set la [rowofcommit $a]
set todo $anc_todo
set leftover {}
set done 0
for {set i 0} {$i < [llength $todo]} {incr i} {
set do [lindex $todo $i]
- if {![info exists commitrow($v,$do)] || $commitrow($v,$do) > $la} {
+ if {![commitinview $do $v] || [rowofcommit $do] > $la} {
lappend leftover $do
continue
}
- foreach np [lindex $parentlist $commitrow($v,$do)] {
+ foreach np $parents($v,$do) {
if {![info exists ancestor($np)]} {
set ancestor($np) 1
lappend todo $np
@@ -2628,7 +3872,7 @@ proc askrelhighlight {row id} {
global descendent highlight_related iddrawn rhighlights
global selectedline ancestor
- if {![info exists selectedline]} return
+ if {$selectedline eq {}} return
set isbold 0
if {$highlight_related eq [mc "Descendant"] ||
$highlight_related eq [mc "Not descendant"]} {
@@ -2648,11 +3892,11 @@ proc askrelhighlight {row id} {
}
}
if {[info exists iddrawn($id)]} {
- if {$isbold && ![ishighlighted $row]} {
+ if {$isbold && ![ishighlighted $id]} {
bolden $row mainfontbold
}
}
- set rhighlights($row) $isbold
+ set rhighlights($id) $isbold
}
# Graph layout functions
@@ -2683,40 +3927,81 @@ proc ntimes {n o} {
return $ret
}
+proc ordertoken {id} {
+ global ordertok curview varcid varcstart varctok curview parents children
+ global nullid nullid2
+
+ if {[info exists ordertok($id)]} {
+ return $ordertok($id)
+ }
+ set origid $id
+ set todo {}
+ while {1} {
+ if {[info exists varcid($curview,$id)]} {
+ set a $varcid($curview,$id)
+ set p [lindex $varcstart($curview) $a]
+ } else {
+ set p [lindex $children($curview,$id) 0]
+ }
+ if {[info exists ordertok($p)]} {
+ set tok $ordertok($p)
+ break
+ }
+ set id [first_real_child $curview,$p]
+ if {$id eq {}} {
+ # it's a root
+ set tok [lindex $varctok($curview) $varcid($curview,$p)]
+ break
+ }
+ if {[llength $parents($curview,$id)] == 1} {
+ lappend todo [list $p {}]
+ } else {
+ set j [lsearch -exact $parents($curview,$id) $p]
+ if {$j < 0} {
+ puts "oops didn't find [shortids $p] in parents of [shortids $id]"
+ }
+ lappend todo [list $p [strrep $j]]
+ }
+ }
+ for {set i [llength $todo]} {[incr i -1] >= 0} {} {
+ set p [lindex $todo $i 0]
+ append tok [lindex $todo $i 1]
+ set ordertok($p) $tok
+ }
+ set ordertok($origid) $tok
+ return $tok
+}
+
# Work out where id should go in idlist so that order-token
# values increase from left to right
proc idcol {idlist id {i 0}} {
- global ordertok curview
-
- set t $ordertok($curview,$id)
- if {$i >= [llength $idlist] ||
- $t < $ordertok($curview,[lindex $idlist $i])} {
+ set t [ordertoken $id]
+ if {$i < 0} {
+ set i 0
+ }
+ if {$i >= [llength $idlist] || $t < [ordertoken [lindex $idlist $i]]} {
if {$i > [llength $idlist]} {
set i [llength $idlist]
}
- while {[incr i -1] >= 0 &&
- $t < $ordertok($curview,[lindex $idlist $i])} {}
+ while {[incr i -1] >= 0 && $t < [ordertoken [lindex $idlist $i]]} {}
incr i
} else {
- if {$t > $ordertok($curview,[lindex $idlist $i])} {
+ if {$t > [ordertoken [lindex $idlist $i]]} {
while {[incr i] < [llength $idlist] &&
- $t >= $ordertok($curview,[lindex $idlist $i])} {}
+ $t >= [ordertoken [lindex $idlist $i]]} {}
}
}
return $i
}
proc initlayout {} {
- global rowidlist rowisopt rowfinal displayorder commitlisted
+ global rowidlist rowisopt rowfinal displayorder parentlist
global numcommits canvxmax canv
global nextcolor
- global parentlist
global colormap rowtextx
- global selectfirst
set numcommits 0
set displayorder {}
- set commitlisted {}
set parentlist {}
set nextcolor 0
set rowidlist {}
@@ -2725,16 +4010,19 @@ proc initlayout {} {
set canvxmax [$canv cget -width]
catch {unset colormap}
catch {unset rowtextx}
- set selectfirst 1
+ setcanvscroll
}
proc setcanvscroll {} {
global canv canv2 canv3 numcommits linespc canvxmax canvy0
+ global lastscrollset lastscrollrows
set ymax [expr {$canvy0 + ($numcommits - 0.5) * $linespc + 2}]
$canv conf -scrollregion [list 0 0 $canvxmax $ymax]
$canv2 conf -scrollregion [list 0 0 0 $ymax]
$canv3 conf -scrollregion [list 0 0 0 $ymax]
+ set lastscrollset [clock clicks -milliseconds]
+ set lastscrollrows $numcommits
}
proc visiblerows {} {
@@ -2757,101 +4045,60 @@ proc visiblerows {} {
}
proc layoutmore {} {
- global commitidx viewcomplete numcommits
- global uparrowlen downarrowlen mingaplen curview
+ global commitidx viewcomplete curview
+ global numcommits pending_select curview
+ global lastscrollset lastscrollrows commitinterest
- set show $commitidx($curview)
- if {$show > $numcommits || $viewcomplete($curview)} {
- showstuff $show $viewcomplete($curview)
- }
-}
-
-proc showstuff {canshow last} {
- global numcommits commitrow pending_select selectedline curview
- global mainheadid displayorder selectfirst
- global lastscrollset commitinterest
-
- if {$numcommits == 0} {
- global phase
- set phase "incrdraw"
- allcanvs delete all
- }
- set r0 $numcommits
- set prev $numcommits
- set numcommits $canshow
- set t [clock clicks -milliseconds]
- if {$prev < 100 || $last || $t - $lastscrollset > 500} {
- set lastscrollset $t
+ if {$lastscrollrows < 100 || $viewcomplete($curview) ||
+ [clock clicks -milliseconds] - $lastscrollset > 500} {
setcanvscroll
}
- set rows [visiblerows]
- set r1 [lindex $rows 1]
- if {$r1 >= $canshow} {
- set r1 [expr {$canshow - 1}]
- }
- if {$r0 <= $r1} {
- drawcommits $r0 $r1
- }
if {[info exists pending_select] &&
- [info exists commitrow($curview,$pending_select)] &&
- $commitrow($curview,$pending_select) < $numcommits} {
- selectline $commitrow($curview,$pending_select) 1
- }
- if {$selectfirst} {
- if {[info exists selectedline] || [info exists pending_select]} {
- set selectfirst 0
- } else {
- set l [first_real_row]
- selectline $l 1
- set selectfirst 0
- }
+ [commitinview $pending_select $curview]} {
+ update
+ selectline [rowofcommit $pending_select] 1
}
+ drawvisible
}
proc doshowlocalchanges {} {
- global curview mainheadid phase commitrow
+ global curview mainheadid
- if {[info exists commitrow($curview,$mainheadid)] &&
- ($phase eq {} || $commitrow($curview,$mainheadid) < $numcommits - 1)} {
+ if {$mainheadid eq {}} return
+ if {[commitinview $mainheadid $curview]} {
dodiffindex
- } elseif {$phase ne {}} {
- lappend commitinterest($mainheadid) {}
+ } else {
+ lappend commitinterest($mainheadid) {dodiffindex}
}
}
proc dohidelocalchanges {} {
- global localfrow localirow lserial
+ global nullid nullid2 lserial curview
- if {$localfrow >= 0} {
- removerow $localfrow
- set localfrow -1
- if {$localirow > 0} {
- incr localirow -1
- }
+ if {[commitinview $nullid $curview]} {
+ removefakerow $nullid
}
- if {$localirow >= 0} {
- removerow $localirow
- set localirow -1
+ if {[commitinview $nullid2 $curview]} {
+ removefakerow $nullid2
}
incr lserial
}
# spawn off a process to do git diff-index --cached HEAD
proc dodiffindex {} {
- global localirow localfrow lserial showlocalchanges
+ global lserial showlocalchanges
+ global isworktree
- if {!$showlocalchanges} return
+ if {!$showlocalchanges || !$isworktree} return
incr lserial
- set localfrow -1
- set localirow -1
set fd [open "|git diff-index --cached HEAD" r]
fconfigure $fd -blocking 0
- filerun $fd [list readdiffindex $fd $lserial]
+ set i [reg_instance $fd]
+ filerun $fd [list readdiffindex $fd $lserial $i]
}
-proc readdiffindex {fd serial} {
- global localirow commitrow mainheadid nullid2 curview
- global commitinfo commitdata lserial
+proc readdiffindex {fd serial inst} {
+ global mainheadid nullid nullid2 curview commitinfo commitdata lserial
set isdiff 1
if {[gets $fd line] < 0} {
@@ -2861,28 +4108,35 @@ proc readdiffindex {fd serial} {
set isdiff 0
}
# we only need to see one line and we don't really care what it says...
- close $fd
+ stop_instance $inst
- # now see if there are any local changes not checked in to the index
- if {$serial == $lserial} {
- set fd [open "|git diff-files" r]
- fconfigure $fd -blocking 0
- filerun $fd [list readdifffiles $fd $serial]
+ if {$serial != $lserial} {
+ return 0
}
- if {$isdiff && $serial == $lserial && $localirow == -1} {
+ # now see if there are any local changes not checked in to the index
+ set fd [open "|git diff-files" r]
+ fconfigure $fd -blocking 0
+ set i [reg_instance $fd]
+ filerun $fd [list readdifffiles $fd $serial $i]
+
+ if {$isdiff && ![commitinview $nullid2 $curview]} {
# add the line for the changes in the index to the graph
- set localirow $commitrow($curview,$mainheadid)
set hl [mc "Local changes checked in to index but not committed"]
set commitinfo($nullid2) [list $hl {} {} {} {} " $hl\n"]
set commitdata($nullid2) "\n $hl\n"
- insertrow $localirow $nullid2
+ if {[commitinview $nullid $curview]} {
+ removefakerow $nullid
+ }
+ insertfakerow $nullid2 $mainheadid
+ } elseif {!$isdiff && [commitinview $nullid2 $curview]} {
+ removefakerow $nullid2
}
return 0
}
-proc readdifffiles {fd serial} {
- global localirow localfrow commitrow mainheadid nullid curview
+proc readdifffiles {fd serial inst} {
+ global mainheadid nullid nullid2 curview
global commitinfo commitdata lserial
set isdiff 1
@@ -2893,52 +4147,57 @@ proc readdifffiles {fd serial} {
set isdiff 0
}
# we only need to see one line and we don't really care what it says...
- close $fd
+ stop_instance $inst
+
+ if {$serial != $lserial} {
+ return 0
+ }
- if {$isdiff && $serial == $lserial && $localfrow == -1} {
+ if {$isdiff && ![commitinview $nullid $curview]} {
# add the line for the local diff to the graph
- if {$localirow >= 0} {
- set localfrow $localirow
- incr localirow
- } else {
- set localfrow $commitrow($curview,$mainheadid)
- }
set hl [mc "Local uncommitted changes, not checked in to index"]
set commitinfo($nullid) [list $hl {} {} {} {} " $hl\n"]
set commitdata($nullid) "\n $hl\n"
- insertrow $localfrow $nullid
+ if {[commitinview $nullid2 $curview]} {
+ set p $nullid2
+ } else {
+ set p $mainheadid
+ }
+ insertfakerow $nullid $p
+ } elseif {!$isdiff && [commitinview $nullid $curview]} {
+ removefakerow $nullid
}
return 0
}
proc nextuse {id row} {
- global commitrow curview children
+ global curview children
if {[info exists children($curview,$id)]} {
foreach kid $children($curview,$id) {
- if {![info exists commitrow($curview,$kid)]} {
+ if {![commitinview $kid $curview]} {
return -1
}
- if {$commitrow($curview,$kid) > $row} {
- return $commitrow($curview,$kid)
+ if {[rowofcommit $kid] > $row} {
+ return [rowofcommit $kid]
}
}
}
- if {[info exists commitrow($curview,$id)]} {
- return $commitrow($curview,$id)
+ if {[commitinview $id $curview]} {
+ return [rowofcommit $id]
}
return -1
}
proc prevuse {id row} {
- global commitrow curview children
+ global curview children
set ret -1
if {[info exists children($curview,$id)]} {
foreach kid $children($curview,$id) {
- if {![info exists commitrow($curview,$kid)]} break
- if {$commitrow($curview,$kid) < $row} {
- set ret $commitrow($curview,$kid)
+ if {![commitinview $kid $curview]} break
+ if {[rowofcommit $kid] < $row} {
+ set ret [rowofcommit $kid]
}
}
}
@@ -2947,7 +4206,7 @@ proc prevuse {id row} {
proc make_idlist {row} {
global displayorder parentlist uparrowlen downarrowlen mingaplen
- global commitidx curview ordertok children commitrow
+ global commitidx curview children
set r [expr {$row - $mingaplen - $downarrowlen - 1}]
if {$r < 0} {
@@ -2961,6 +4220,7 @@ proc make_idlist {row} {
if {$rb > $commitidx($curview)} {
set rb $commitidx($curview)
}
+ make_disporder $r [expr {$rb + 1}]
set ids {}
for {} {$r < $ra} {incr r} {
set nextid [lindex $displayorder [expr {$r + 1}]]
@@ -2969,7 +4229,7 @@ proc make_idlist {row} {
set rn [nextuse $p $r]
if {$rn >= $row &&
$rn <= $r + $downarrowlen + $mingaplen + $uparrowlen} {
- lappend ids [list $ordertok($curview,$p) $p]
+ lappend ids [list [ordertoken $p] $p]
}
}
}
@@ -2979,25 +4239,25 @@ proc make_idlist {row} {
if {$p eq $nextid} continue
set rn [nextuse $p $r]
if {$rn < 0 || $rn >= $row} {
- lappend ids [list $ordertok($curview,$p) $p]
+ lappend ids [list [ordertoken $p] $p]
}
}
}
set id [lindex $displayorder $row]
- lappend ids [list $ordertok($curview,$id) $id]
+ lappend ids [list [ordertoken $id] $id]
while {$r < $rb} {
foreach p [lindex $parentlist $r] {
set firstkid [lindex $children($curview,$p) 0]
- if {$commitrow($curview,$firstkid) < $row} {
- lappend ids [list $ordertok($curview,$p) $p]
+ if {[rowofcommit $firstkid] < $row} {
+ lappend ids [list [ordertoken $p] $p]
}
}
incr r
set id [lindex $displayorder $r]
if {$id ne {}} {
set firstkid [lindex $children($curview,$id) 0]
- if {$firstkid ne {} && $commitrow($curview,$firstkid) < $row} {
- lappend ids [list $ordertok($curview,$id) $id]
+ if {$firstkid ne {} && [rowofcommit $firstkid] < $row} {
+ lappend ids [list [ordertoken $id] $id]
}
}
}
@@ -3043,8 +4303,9 @@ proc layoutrows {row endrow} {
global rowidlist rowisopt rowfinal displayorder
global uparrowlen downarrowlen maxwidth mingaplen
global children parentlist
- global commitidx viewcomplete curview commitrow
+ global commitidx viewcomplete curview
+ make_disporder [expr {$row - 1}] [expr {$endrow + $uparrowlen}]
set idlist {}
if {$row > 0} {
set rm1 [expr {$row - 1}]
@@ -3100,7 +4361,7 @@ proc layoutrows {row endrow} {
foreach p [lindex $parentlist $r] {
if {[lsearch -exact $idlist $p] >= 0} continue
set fk [lindex $children($curview,$p) 0]
- if {$commitrow($curview,$fk) < $row} {
+ if {[rowofcommit $fk] < $row} {
set x [idcol $idlist $p $x]
set idlist [linsert $idlist $x $p]
}
@@ -3109,7 +4370,7 @@ proc layoutrows {row endrow} {
set p [lindex $displayorder $r]
if {[lsearch -exact $idlist $p] < 0} {
set fk [lindex $children($curview,$p) 0]
- if {$fk ne {} && $commitrow($curview,$fk) < $row} {
+ if {$fk ne {} && [rowofcommit $fk] < $row} {
set x [idcol $idlist $p $x]
set idlist [linsert $idlist $x $p]
}
@@ -3324,7 +4585,7 @@ proc linewidth {id} {
}
proc rowranges {id} {
- global commitrow curview children uparrowlen downarrowlen
+ global curview children uparrowlen downarrowlen
global rowidlist
set kids $children($curview,$id)
@@ -3334,13 +4595,13 @@ proc rowranges {id} {
set ret {}
lappend kids $id
foreach child $kids {
- if {![info exists commitrow($curview,$child)]} break
- set row $commitrow($curview,$child)
+ if {![commitinview $child $curview]} break
+ set row [rowofcommit $child]
if {![info exists prev]} {
lappend ret [expr {$row + 1}]
} else {
if {$row <= $prevrow} {
- puts "oops children out of order [shortids $id] $row < [shortids $prev] $prevrow"
+ puts "oops children of [shortids $id] out of order [shortids $child] $row <= [shortids $prev] $prevrow"
}
# see if the line extends the whole way from prevrow to row
if {$row > $prevrow + $uparrowlen + $downarrowlen &&
@@ -3373,7 +4634,7 @@ proc rowranges {id} {
if {$child eq $id} {
lappend ret $row
}
- set prev $id
+ set prev $child
set prevrow $row
}
return $ret
@@ -3621,29 +4882,32 @@ proc drawlines {id} {
}
proc drawcmittext {id row col} {
- global linespc canv canv2 canv3 canvy0 fgcolor curview
- global commitlisted commitinfo rowidlist parentlist
+ global linespc canv canv2 canv3 fgcolor curview
+ global cmitlisted commitinfo rowidlist parentlist
global rowtextx idpos idtags idheads idotherrefs
global linehtag linentag linedtag selectedline
- global canvxmax boldrows boldnamerows fgcolor nullid nullid2
+ global canvxmax boldrows boldnamerows fgcolor
+ global mainheadid nullid nullid2 circleitem circlecolors
- # listed is 0 for boundary, 1 for normal, 2 for left, 3 for right
- set listed [lindex $commitlisted $row]
+ # listed is 0 for boundary, 1 for normal, 2 for negative, 3 for left, 4 for right
+ set listed $cmitlisted($curview,$id)
if {$id eq $nullid} {
set ofill red
} elseif {$id eq $nullid2} {
set ofill green
+ } elseif {$id eq $mainheadid} {
+ set ofill yellow
} else {
- set ofill [expr {$listed != 0? "blue": "white"}]
+ set ofill [lindex $circlecolors $listed]
}
set x [xc $row $col]
set y [yc $row]
set orad [expr {$linespc / 3}]
- if {$listed <= 1} {
+ if {$listed <= 2} {
set t [$canv create oval [expr {$x - $orad}] [expr {$y - $orad}] \
[expr {$x + $orad - 1}] [expr {$y + $orad - 1}] \
-fill $ofill -outline $fgcolor -width 1 -tags circle]
- } elseif {$listed == 2} {
+ } elseif {$listed == 3} {
# triangle pointing left for left-side commits
set t [$canv create polygon \
[expr {$x - $orad}] $y \
@@ -3658,6 +4922,7 @@ proc drawcmittext {id row col} {
[expr {$x - $orad}] [expr {$y + $orad - 1}] \
-fill $ofill -outline $fgcolor -width 1 -tags circle]
}
+ set circleitem($row) $t
$canv raise $t
$canv bind $t <1> {selcanvline {} %x %y}
set rmx [llength [lindex $rowidlist $row]]
@@ -3684,7 +4949,7 @@ proc drawcmittext {id row col} {
set date [formatdate $date]
set font mainfont
set nfont mainfont
- set isbold [ishighlighted $row]
+ set isbold [ishighlighted $id]
if {$isbold > 0} {
lappend boldrows $row
set font mainfontbold
@@ -3700,7 +4965,7 @@ proc drawcmittext {id row col} {
-text $name -font $nfont -tags text]
set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
-text $date -font mainfont -tags text]
- if {[info exists selectedline] && $selectedline == $row} {
+ if {$selectedline == $row} {
make_secsel $row
}
set xr [expr {$xt + [font measure $font $headline]}]
@@ -3713,7 +4978,7 @@ proc drawcmittext {id row col} {
proc drawcmitrow {row} {
global displayorder rowidlist nrows_drawn
global iddrawn markingmatches
- global commitinfo parentlist numcommits
+ global commitinfo numcommits
global filehighlight fhighlights findpattern nhighlights
global hlview vhighlights
global highlight_related rhighlights
@@ -3721,16 +4986,16 @@ proc drawcmitrow {row} {
if {$row >= $numcommits} return
set id [lindex $displayorder $row]
- if {[info exists hlview] && ![info exists vhighlights($row)]} {
+ if {[info exists hlview] && ![info exists vhighlights($id)]} {
askvhighlight $row $id
}
- if {[info exists filehighlight] && ![info exists fhighlights($row)]} {
+ if {[info exists filehighlight] && ![info exists fhighlights($id)]} {
askfilehighlight $row $id
}
- if {$findpattern ne {} && ![info exists nhighlights($row)]} {
+ if {$findpattern ne {} && ![info exists nhighlights($id)]} {
askfindhighlight $row $id
}
- if {$highlight_related ne [mc "None"] && ![info exists rhighlights($row)]} {
+ if {$highlight_related ne [mc "None"] && ![info exists rhighlights($id)]} {
askrelhighlight $row $id
}
if {![info exists iddrawn($id)]} {
@@ -3833,30 +5098,92 @@ proc drawcommits {row {endrow {}}} {
}
}
-proc drawfrac {f0 f1} {
- global canv linespc
+proc undolayout {row} {
+ global uparrowlen mingaplen downarrowlen
+ global rowidlist rowisopt rowfinal need_redisplay
+ set r [expr {$row - ($uparrowlen + $mingaplen + $downarrowlen)}]
+ if {$r < 0} {
+ set r 0
+ }
+ if {[llength $rowidlist] > $r} {
+ incr r -1
+ set rowidlist [lrange $rowidlist 0 $r]
+ set rowfinal [lrange $rowfinal 0 $r]
+ set rowisopt [lrange $rowisopt 0 $r]
+ set need_redisplay 1
+ run drawvisible
+ }
+}
+
+proc drawvisible {} {
+ global canv linespc curview vrowmod selectedline targetrow targetid
+ global need_redisplay cscroll numcommits
+
+ set fs [$canv yview]
set ymax [lindex [$canv cget -scrollregion] 3]
- if {$ymax eq {} || $ymax == 0} return
+ if {$ymax eq {} || $ymax == 0 || $numcommits == 0} return
+ set f0 [lindex $fs 0]
+ set f1 [lindex $fs 1]
set y0 [expr {int($f0 * $ymax)}]
- set row [expr {int(($y0 - 3) / $linespc) - 1}]
set y1 [expr {int($f1 * $ymax)}]
+
+ if {[info exists targetid]} {
+ if {[commitinview $targetid $curview]} {
+ set r [rowofcommit $targetid]
+ if {$r != $targetrow} {
+ # Fix up the scrollregion and change the scrolling position
+ # now that our target row has moved.
+ set diff [expr {($r - $targetrow) * $linespc}]
+ set targetrow $r
+ setcanvscroll
+ set ymax [lindex [$canv cget -scrollregion] 3]
+ incr y0 $diff
+ incr y1 $diff
+ set f0 [expr {$y0 / $ymax}]
+ set f1 [expr {$y1 / $ymax}]
+ allcanvs yview moveto $f0
+ $cscroll set $f0 $f1
+ set need_redisplay 1
+ }
+ } else {
+ unset targetid
+ }
+ }
+
+ set row [expr {int(($y0 - 3) / $linespc) - 1}]
set endrow [expr {int(($y1 - 3) / $linespc) + 1}]
+ if {$endrow >= $vrowmod($curview)} {
+ update_arcrows $curview
+ }
+ if {$selectedline ne {} &&
+ $row <= $selectedline && $selectedline <= $endrow} {
+ set targetrow $selectedline
+ } elseif {[info exists targetid]} {
+ set targetrow [expr {int(($row + $endrow) / 2)}]
+ }
+ if {[info exists targetrow]} {
+ if {$targetrow >= $numcommits} {
+ set targetrow [expr {$numcommits - 1}]
+ }
+ set targetid [commitonrow $targetrow]
+ }
drawcommits $row $endrow
}
-proc drawvisible {} {
- global canv
- eval drawfrac [$canv yview]
-}
-
proc clear_display {} {
global iddrawn linesegs need_redisplay nrows_drawn
global vhighlights fhighlights nhighlights rhighlights
+ global linehtag linentag linedtag boldrows boldnamerows
allcanvs delete all
catch {unset iddrawn}
catch {unset linesegs}
+ catch {unset linehtag}
+ catch {unset linentag}
+ catch {unset linedtag}
+ set boldrows {}
+ set boldnamerows {}
catch {unset vhighlights}
catch {unset fhighlights}
catch {unset nhighlights}
@@ -3902,7 +5229,7 @@ proc findcrossings {id} {
proc assigncolor {id} {
global colormap colors nextcolor
- global commitrow parentlist children children curview
+ global parents children children curview
if {[info exists colormap($id)]} return
set ncolors [llength $colors]
@@ -3914,7 +5241,7 @@ proc assigncolor {id} {
if {[llength $kids] == 1} {
set child [lindex $kids 0]
if {[info exists colormap($child)]
- && [llength [lindex $parentlist $commitrow($curview,$child)]] == 1} {
+ && [llength $parents($curview,$child)] == 1} {
set colormap($id) $colormap($child)
return
}
@@ -3942,7 +5269,7 @@ proc assigncolor {id} {
&& [lsearch -exact $badcolors $colormap($child)] < 0} {
lappend badcolors $colormap($child)
}
- foreach p [lindex $parentlist $commitrow($curview,$child)] {
+ foreach p $parents($curview,$child) {
if {[info exists colormap($p)]
&& [lsearch -exact $badcolors $colormap($p)] < 0} {
lappend badcolors $colormap($p)
@@ -3975,7 +5302,7 @@ proc bindline {t id} {
proc drawtags {id x xt y1} {
global idtags idheads idotherrefs mainhead
global linespc lthickness
- global canv commitrow rowtextx curview fgcolor bgcolor
+ global canv rowtextx curview fgcolor bgcolor
set marks {}
set ntags 0
@@ -4025,7 +5352,7 @@ proc drawtags {id x xt y1} {
$xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
-width 1 -outline black -fill yellow -tags tag.$id]
$canv bind $t <1> [list showtag $tag 1]
- set rowtextx($commitrow($curview,$id)) [expr {$xr + $linespc}]
+ set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
} else {
# draw a head or other ref
if {[incr nheads -1] >= 0} {
@@ -4079,103 +5406,6 @@ proc show_status {msg} {
-tags text -fill $fgcolor
}
-# Insert a new commit as the child of the commit on row $row.
-# The new commit will be displayed on row $row and the commits
-# on that row and below will move down one row.
-proc insertrow {row newcmit} {
- global displayorder parentlist commitlisted children
- global commitrow curview rowidlist rowisopt rowfinal numcommits
- global numcommits
- global selectedline commitidx ordertok
-
- if {$row >= $numcommits} {
- puts "oops, inserting new row $row but only have $numcommits rows"
- return
- }
- set p [lindex $displayorder $row]
- set displayorder [linsert $displayorder $row $newcmit]
- set parentlist [linsert $parentlist $row $p]
- set kids $children($curview,$p)
- lappend kids $newcmit
- set children($curview,$p) $kids
- set children($curview,$newcmit) {}
- set commitlisted [linsert $commitlisted $row 1]
- set l [llength $displayorder]
- for {set r $row} {$r < $l} {incr r} {
- set id [lindex $displayorder $r]
- set commitrow($curview,$id) $r
- }
- incr commitidx($curview)
- set ordertok($curview,$newcmit) $ordertok($curview,$p)
-
- if {$row < [llength $rowidlist]} {
- set idlist [lindex $rowidlist $row]
- if {$idlist ne {}} {
- if {[llength $kids] == 1} {
- set col [lsearch -exact $idlist $p]
- lset idlist $col $newcmit
- } else {
- set col [llength $idlist]
- lappend idlist $newcmit
- }
- }
- set rowidlist [linsert $rowidlist $row $idlist]
- set rowisopt [linsert $rowisopt $row 0]
- set rowfinal [linsert $rowfinal $row [lindex $rowfinal $row]]
- }
-
- incr numcommits
-
- if {[info exists selectedline] && $selectedline >= $row} {
- incr selectedline
- }
- redisplay
-}
-
-# Remove a commit that was inserted with insertrow on row $row.
-proc removerow {row} {
- global displayorder parentlist commitlisted children
- global commitrow curview rowidlist rowisopt rowfinal numcommits
- global numcommits
- global linesegends selectedline commitidx
-
- if {$row >= $numcommits} {
- puts "oops, removing row $row but only have $numcommits rows"
- return
- }
- set rp1 [expr {$row + 1}]
- set id [lindex $displayorder $row]
- set p [lindex $parentlist $row]
- set displayorder [lreplace $displayorder $row $row]
- set parentlist [lreplace $parentlist $row $row]
- set commitlisted [lreplace $commitlisted $row $row]
- set kids $children($curview,$p)
- set i [lsearch -exact $kids $id]
- if {$i >= 0} {
- set kids [lreplace $kids $i $i]
- set children($curview,$p) $kids
- }
- set l [llength $displayorder]
- for {set r $row} {$r < $l} {incr r} {
- set id [lindex $displayorder $r]
- set commitrow($curview,$id) $r
- }
- incr commitidx($curview) -1
-
- if {$row < [llength $rowidlist]} {
- set rowidlist [lreplace $rowidlist $row $row]
- set rowisopt [lreplace $rowisopt $row $row]
- set rowfinal [lreplace $rowfinal $row $row]
- }
-
- incr numcommits -1
-
- if {[info exists selectedline] && $selectedline > $row} {
- incr selectedline -1
- }
- redisplay
-}
-
# Don't change the text pane cursor if it is currently the hand cursor,
# showing that we are over a sha1 ID link.
proc settextcursor {c} {
@@ -4248,7 +5478,7 @@ proc dofind {{dirn 1} {wrap 1}} {
}
focus .
if {$findstring eq {} || $numcommits == 0} return
- if {![info exists selectedline]} {
+ if {$selectedline eq {}} {
set findstartline [lindex [visiblerows] [expr {$dirn < 0}]]
} else {
set findstartline $selectedline
@@ -4278,9 +5508,9 @@ proc stopfinding {} {
proc findmore {} {
global commitdata commitinfo numcommits findpattern findloc
- global findstartline findcurline displayorder
+ global findstartline findcurline findallowwrap
global find_dirn gdttype fhighlights fprogcoord
- global findallowwrap
+ global curview varcorder vrownum varccommits vrowmod
if {![info exists find_dirn]} {
return 0
@@ -4316,14 +5546,31 @@ proc findmore {} {
set n 500
set moretodo 1
}
+ if {$l + ($find_dirn > 0? $n: 1) > $vrowmod($curview)} {
+ update_arcrows $curview
+ }
set found 0
set domore 1
+ set ai [bsearch $vrownum($curview) $l]
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
if {$gdttype eq [mc "containing:"]} {
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
- set id [lindex $displayorder $l]
+ if {$l < $arow || $l >= $arowend} {
+ incr ai $find_dirn
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ }
+ set id [lindex $ids [expr {$l - $arow}]]
# shouldn't happen unless git log doesn't give all the commits...
- if {![info exists commitdata($id)]} continue
- if {![doesmatch $commitdata($id)]} continue
+ if {![info exists commitdata($id)] ||
+ ![doesmatch $commitdata($id)]} {
+ continue
+ }
if {![info exists commitinfo($id)]} {
getcommit $id
}
@@ -4339,16 +5586,27 @@ proc findmore {} {
}
} else {
for {} {$n > 0} {incr n -1; incr l $find_dirn} {
- set id [lindex $displayorder $l]
- if {![info exists fhighlights($l)]} {
+ if {$l < $arow || $l >= $arowend} {
+ incr ai $find_dirn
+ set a [lindex $varcorder($curview) $ai]
+ set arow [lindex $vrownum($curview) $ai]
+ set ids [lindex $varccommits($curview,$a)]
+ set arowend [expr {$arow + [llength $ids]}]
+ }
+ set id [lindex $ids [expr {$l - $arow}]]
+ if {![info exists fhighlights($id)]} {
+ # this sets fhighlights($id) to -1
askfilehighlight $l $id
+ }
+ if {$fhighlights($id) > 0} {
+ set found $domore
+ break
+ }
+ if {$fhighlights($id) < 0} {
if {$domore} {
set domore 0
set findcurline [expr {$l - $find_dirn}]
}
- } elseif {$fhighlights($l)} {
- set found $domore
- break
}
}
}
@@ -4416,7 +5674,7 @@ proc markmatches {canv l str tag matches font row} {
[expr {$x0+$xlen+2}] $y1 \
-outline {} -tags [list match$l matches] -fill yellow]
$canv lower $t
- if {[info exists selectedline] && $row == $selectedline} {
+ if {$row == $selectedline} {
$canv raise $t secsel
}
}
@@ -4442,7 +5700,9 @@ proc selcanvline {w x y} {
set l 0
}
if {$w eq $canv} {
- if {![info exists rowtextx($l)] || $x < $rowtextx($l)} return
+ set xmax [lindex [$canv cget -scrollregion] 2]
+ set xleft [expr {[lindex [$canv xview] 0] * $xmax}]
+ if {![info exists rowtextx($l)] || $xleft + $x < $rowtextx($l)} return
}
unmarkmatches
selectline $l 1
@@ -4463,7 +5723,7 @@ proc commit_descriptor {p} {
# append some text to the ctext widget, and make any SHA1 ID
# that we know about be a clickable link.
proc appendwithlinks {text tags} {
- global ctext commitrow linknum curview pendinglinks
+ global ctext linknum curview pendinglinks
set start [$ctext index "end - 1c"]
$ctext insert end $text $tags
@@ -4481,11 +5741,11 @@ proc appendwithlinks {text tags} {
}
proc setlink {id lk} {
- global curview commitrow ctext pendinglinks commitinterest
+ global curview ctext pendinglinks commitinterest
- if {[info exists commitrow($curview,$id)]} {
+ if {[commitinview $id $curview]} {
$ctext tag conf $lk -foreground blue -underline 1
- $ctext tag bind $lk <1> [list selectline $commitrow($curview,$id) 1]
+ $ctext tag bind $lk <1> [list selectline [rowofcommit $id] 1]
$ctext tag bind $lk <Enter> {linkcursor %W 1}
$ctext tag bind $lk <Leave> {linkcursor %W -1}
} else {
@@ -4536,7 +5796,7 @@ proc viewnextline {dir} {
# add a list of tag or branch names at position pos
# returns the number of names inserted
proc appendrefs {pos ids var} {
- global ctext commitrow linknum curview $var maxrefs
+ global ctext linknum curview $var maxrefs
if {[catch {$ctext index $pos}]} {
return 0
@@ -4573,7 +5833,7 @@ proc appendrefs {pos ids var} {
proc dispneartags {delay} {
global selectedline currentid showneartags tagphase
- if {![info exists selectedline] || !$showneartags} return
+ if {$selectedline eq {} || !$showneartags} return
after cancel dispnexttag
if {$delay} {
after 200 dispnexttag
@@ -4587,7 +5847,7 @@ proc dispneartags {delay} {
proc dispnexttag {} {
global selectedline currentid showneartags tagphase ctext
- if {![info exists selectedline] || !$showneartags} return
+ if {$selectedline eq {} || !$showneartags} return
switch -- $tagphase {
0 {
set dtags [desctags $currentid]
@@ -4639,12 +5899,13 @@ proc make_secsel {l} {
proc selectline {l isnew} {
global canv ctext commitinfo selectedline
- global displayorder
- global canvy0 linespc parentlist children curview
+ global canvy0 linespc parents children curview
global currentid sha1entry
global commentend idtags linknum
global mergemax numcommits pending_select
global cmitmode showneartags allcommits
+ global targetrow targetid lastscrollrows
+ global autoselect
catch {unset pending_select}
$canv delete hover
@@ -4652,6 +5913,15 @@ proc selectline {l isnew} {
unsel_reflist
stopfinding
if {$l < 0 || $l >= $numcommits} return
+ set id [commitonrow $l]
+ set targetid $id
+ set targetrow $l
+ set selectedline $l
+ set currentid $id
+ if {$lastscrollrows < $numcommits} {
+ setcanvscroll
+ }
+
set y [expr {$canvy0 + $l * $linespc}]
set ymax [lindex [$canv cget -scrollregion] 3]
set ytop [expr {$y - $linespc - 1}]
@@ -4691,22 +5961,23 @@ proc selectline {l isnew} {
make_secsel $l
if {$isnew} {
- addtohistory [list selectline $l 0]
+ addtohistory [list selbyid $id]
}
- set selectedline $l
-
- set id [lindex $displayorder $l]
- set currentid $id
$sha1entry delete 0 end
$sha1entry insert 0 $id
- $sha1entry selection from 0
- $sha1entry selection to end
+ if {$autoselect} {
+ $sha1entry selection from 0
+ $sha1entry selection to end
+ }
rhighlight_sel $id
$ctext conf -state normal
clear_ctext
set linknum 0
+ if {![info exists commitinfo($id)]} {
+ getcommit $id
+ }
set info $commitinfo($id)
set date [formatdate [lindex $info 2]]
$ctext insert end "[mc "Author"]: [lindex $info 1] $date\n"
@@ -4721,7 +5992,7 @@ proc selectline {l isnew} {
}
set headers {}
- set olds [lindex $parentlist $l]
+ set olds $parents($curview,$id)
if {[llength $olds] > 1} {
set np 0
foreach p $olds {
@@ -4779,7 +6050,7 @@ proc selectline {l isnew} {
} elseif {[llength $olds] <= 1} {
startdiff $id
} else {
- mergediff $id $l
+ mergediff $id
}
}
@@ -4798,7 +6069,7 @@ proc sellastline {} {
proc selnextline {dir} {
global selectedline
focus .
- if {![info exists selectedline]} return
+ if {$selectedline eq {}} return
set l [expr {$selectedline + $dir}]
unmarkmatches
selectline $l 1
@@ -4813,7 +6084,7 @@ proc selnextpage {dir} {
}
allcanvs yview scroll [expr {$dir * $lpp}] units
drawvisible
- if {![info exists selectedline]} return
+ if {$selectedline eq {}} return
set l [expr {$selectedline + $dir * $lpp}]
if {$l < 0} {
set l 0
@@ -4827,7 +6098,7 @@ proc selnextpage {dir} {
proc unselectline {} {
global selectedline currentid
- catch {unset selectedline}
+ set selectedline {}
catch {unset currentid}
allcanvs delete secsel
rhighlight_none
@@ -4836,7 +6107,7 @@ proc unselectline {} {
proc reselectline {} {
global selectedline
- if {[info exists selectedline]} {
+ if {$selectedline ne {}} {
selectline $selectedline 0
}
}
@@ -4941,11 +6212,12 @@ proc gettreeline {gtf id} {
if {$diffids eq $nullid} {
set fname $line
} else {
- if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
set i [string first "\t" $line]
if {$i < 0} continue
- set sha1 [lindex $line 2]
set fname [string range $line [expr {$i+1}] end]
+ set line [string range $line 0 [expr {$i-1}]]
+ if {$diffids ne $nullid2 && [lindex $line 1] ne "blob"} continue
+ set sha1 [lindex $line 2]
if {[string index $fname 0] eq "\""} {
set fname [lindex $fname 0]
}
@@ -5024,18 +6296,19 @@ proc getblobline {bf id} {
return [expr {$nl >= 1000? 2: 1}]
}
-proc mergediff {id l} {
+proc mergediff {id} {
global diffmergeid mdifffd
global diffids
- global parentlist
- global limitdiffs viewfiles curview
+ global parents
+ global diffcontext
+ global limitdiffs vfilelimit curview
set diffmergeid $id
set diffids $id
# this doesn't seem to actually affect anything...
- set cmd [concat | git diff-tree --no-commit-id --cc $id]
- if {$limitdiffs && $viewfiles($curview) ne {}} {
- set cmd [concat $cmd -- $viewfiles($curview)]
+ set cmd [concat | git diff-tree --no-commit-id --cc -U$diffcontext $id]
+ if {$limitdiffs && $vfilelimit($curview) ne {}} {
+ set cmd [concat $cmd -- $vfilelimit($curview)]
}
if {[catch {set mdf [open $cmd r]} err]} {
error_popup "[mc "Error getting merge diffs:"] $err"
@@ -5043,7 +6316,7 @@ proc mergediff {id l} {
}
fconfigure $mdf -blocking 0
set mdifffd($id) $mdf
- set np [llength [lindex $parentlist $l]]
+ set np [llength $parents($curview,$id)]
settabs $np
filerun $mdf [list getmergediffline $mdf $id $np]
}
@@ -5204,16 +6477,17 @@ proc diffcmd {ids flags} {
proc gettreediffs {ids} {
global treediff treepending
+ if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
+
set treepending $ids
set treediff {}
- if {[catch {set gdtf [open [diffcmd $ids {--no-commit-id}] r]}]} return
fconfigure $gdtf -blocking 0
filerun $gdtf [list gettreediffline $gdtf $ids]
}
proc gettreediffline {gdtf ids} {
global treediff treediffs treepending diffids diffmergeid
- global cmitmode viewfiles curview limitdiffs
+ global cmitmode vfilelimit curview limitdiffs
set nr 0
while {[incr nr] <= 1000 && [gets $gdtf line] >= 0} {
@@ -5230,10 +6504,10 @@ proc gettreediffline {gdtf ids} {
return [expr {$nr >= 1000? 2: 1}]
}
close $gdtf
- if {$limitdiffs && $viewfiles($curview) ne {}} {
+ if {$limitdiffs && $vfilelimit($curview) ne {}} {
set flist {}
foreach f $treediff {
- if {[path_filter $viewfiles($curview) $f]} {
+ if {[path_filter $vfilelimit($curview) $f]} {
lappend flist $f
}
}
@@ -5270,15 +6544,23 @@ proc diffcontextchange {n1 n2 op} {
}
}
+proc changeignorespace {} {
+ reselectline
+}
+
proc getblobdiffs {ids} {
global blobdifffd diffids env
global diffinhdr treediffs
global diffcontext
- global limitdiffs viewfiles curview
+ global ignorespace
+ global limitdiffs vfilelimit curview
set cmd [diffcmd $ids "-p -C --no-commit-id -U$diffcontext"]
- if {$limitdiffs && $viewfiles($curview) ne {}} {
- set cmd [concat $cmd -- $viewfiles($curview)]
+ if {$ignorespace} {
+ append cmd " -w"
+ }
+ if {$limitdiffs && $vfilelimit($curview) ne {}} {
+ set cmd [concat $cmd -- $vfilelimit($curview)]
}
if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err"
@@ -5418,26 +6700,44 @@ proc changediffdisp {} {
$ctext tag conf d1 -elide [lindex $diffelide 1]
}
+proc highlightfile {loc cline} {
+ global ctext cflist cflist_top
+
+ $ctext yview $loc
+ $cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
+ $cflist tag add highlight $cline.0 "$cline.0 lineend"
+ $cflist see $cline.0
+ set cflist_top $cline
+}
+
proc prevfile {} {
- global difffilestart ctext
- set prev [lindex $difffilestart 0]
+ global difffilestart ctext cmitmode
+
+ if {$cmitmode eq "tree"} return
+ set prev 0.0
+ set prevline 1
set here [$ctext index @0,0]
foreach loc $difffilestart {
if {[$ctext compare $loc >= $here]} {
- $ctext yview $prev
+ highlightfile $prev $prevline
return
}
set prev $loc
+ incr prevline
}
- $ctext yview $prev
+ highlightfile $prev $prevline
}
proc nextfile {} {
- global difffilestart ctext
+ global difffilestart ctext cmitmode
+
+ if {$cmitmode eq "tree"} return
set here [$ctext index @0,0]
+ set line 1
foreach loc $difffilestart {
+ incr line
if {[$ctext compare $loc > $here]} {
- $ctext yview $loc
+ highlightfile $loc $line
return
}
}
@@ -5590,7 +6890,7 @@ proc searchmarkvisible {doall} {
proc scrolltext {f0 f1} {
global searchstring
- .bleft.sb set $f0 $f1
+ .bleft.bottom.sb set $f0 $f1
if {$searchstring ne {}} {
searchmarkvisible 0
}
@@ -5620,7 +6920,7 @@ proc redisplay {} {
setcanvscroll
allcanvs yview moveto [lindex $span 0]
drawvisible
- if {[info exists selectedline]} {
+ if {$selectedline ne {}} {
selectline $selectedline 0
allcanvs yview moveto [lindex $span 0]
}
@@ -5671,7 +6971,7 @@ proc fontname {f} {
}
proc incrfont {inc} {
- global mainfont textfont ctext canv phase cflist showrefstop
+ global mainfont textfont ctext canv cflist showrefstop
global stopped entries fontattr
unmarkmatches
@@ -5722,8 +7022,7 @@ proc sha1change {n1 n2 op} {
}
proc gotocommit {} {
- global sha1string currentid commitrow tagids headids
- global displayorder numcommits curview
+ global sha1string tagids headids curview varcid
if {$sha1string == {}
|| ([info exists currentid] && $sha1string == $currentid)} return
@@ -5734,23 +7033,18 @@ proc gotocommit {} {
} else {
set id [string tolower $sha1string]
if {[regexp {^[0-9a-f]{4,39}$} $id]} {
- set matches {}
- foreach i $displayorder {
- if {[string match $id* $i]} {
- lappend matches $i
- }
- }
+ set matches [array names varcid "$curview,$id*"]
if {$matches ne {}} {
if {[llength $matches] > 1} {
error_popup [mc "Short SHA1 id %s is ambiguous" $id]
return
}
- set id [lindex $matches 0]
+ set id [lindex [split [lindex $matches 0] ","] 1]
}
}
}
- if {[info exists commitrow($curview,$id)]} {
- selectline $commitrow($curview,$id) 1
+ if {[commitinview $id $curview]} {
+ selectline [rowofcommit $id] 1
return
}
if {[regexp {^[0-9a-fA-F]{4,}$} $sha1string]} {
@@ -5859,7 +7153,7 @@ proc arrowjump {id n y} {
}
proc lineclick {x y id isnew} {
- global ctext commitinfo children canv thickerline curview commitrow
+ global ctext commitinfo children canv thickerline curview
if {![info exists commitinfo($id)] && ![getcommit $id]} return
unmarkmatches
@@ -5927,9 +7221,9 @@ proc normalline {} {
}
proc selbyid {id} {
- global commitrow curview
- if {[info exists commitrow($curview,$id)]} {
- selectline $commitrow($curview,$id) 1
+ global curview
+ if {[commitinview $id $curview]} {
+ selectline [rowofcommit $id] 1
}
}
@@ -5942,20 +7236,23 @@ proc mstime {} {
}
proc rowmenu {x y id} {
- global rowctxmenu commitrow selectedline rowmenuid curview
+ global rowctxmenu selectedline rowmenuid curview
global nullid nullid2 fakerowmenu mainhead
stopfinding
set rowmenuid $id
- if {![info exists selectedline]
- || $commitrow($curview,$id) eq $selectedline} {
+ if {$selectedline eq {} || [rowofcommit $id] eq $selectedline} {
set state disabled
} else {
set state normal
}
if {$id ne $nullid && $id ne $nullid2} {
set menu $rowctxmenu
- $menu entryconfigure 7 -label [mc "Reset %s branch to here" $mainhead]
+ if {$mainhead ne {}} {
+ $menu entryconfigure 7 -label [mc "Reset %s branch to here" $mainhead]
+ } else {
+ $menu entryconfigure 7 -label [mc "Detached head: can't reset" $mainhead] -state disabled
+ }
} else {
set menu $fakerowmenu
}
@@ -5966,15 +7263,15 @@ proc rowmenu {x y id} {
}
proc diffvssel {dirn} {
- global rowmenuid selectedline displayorder
+ global rowmenuid selectedline
- if {![info exists selectedline]} return
+ if {$selectedline eq {}} return
if {$dirn} {
- set oldid [lindex $displayorder $selectedline]
+ set oldid [commitonrow $selectedline]
set newid $rowmenuid
} else {
set oldid $rowmenuid
- set newid [lindex $displayorder $selectedline]
+ set newid [commitonrow $selectedline]
}
addtohistory [list doseldiff $oldid $newid]
doseldiff $oldid $newid
@@ -6137,11 +7434,7 @@ proc domktag {} {
return
}
if {[catch {
- set dir [gitdir]
- set fname [file join $dir "refs/tags" $tag]
- set f [open $fname w]
- puts $f $id
- close $f
+ exec git tag $tag $id
} err]} {
error_popup "[mc "Error creating tag:"] $err"
return
@@ -6156,24 +7449,30 @@ proc domktag {} {
}
proc redrawtags {id} {
- global canv linehtag commitrow idpos selectedline curview
- global canvxmax iddrawn
+ global canv linehtag idpos currentid curview cmitlisted
+ global canvxmax iddrawn circleitem mainheadid circlecolors
- if {![info exists commitrow($curview,$id)]} return
+ if {![commitinview $id $curview]} return
if {![info exists iddrawn($id)]} return
- drawcommits $commitrow($curview,$id)
+ set row [rowofcommit $id]
+ if {$id eq $mainheadid} {
+ set ofill yellow
+ } else {
+ set ofill [lindex $circlecolors $cmitlisted($curview,$id)]
+ }
+ $canv itemconf $circleitem($row) -fill $ofill
$canv delete tag.$id
set xt [eval drawtags $id $idpos($id)]
- $canv coords $linehtag($commitrow($curview,$id)) $xt [lindex $idpos($id) 2]
- set text [$canv itemcget $linehtag($commitrow($curview,$id)) -text]
- set xr [expr {$xt + [font measure mainfont $text]}]
+ $canv coords $linehtag($row) $xt [lindex $idpos($id) 2]
+ set text [$canv itemcget $linehtag($row) -text]
+ set font [$canv itemcget $linehtag($row) -font]
+ set xr [expr {$xt + [font measure $font $text]}]
if {$xr > $canvxmax} {
set canvxmax $xr
setcanvscroll
}
- if {[info exists selectedline]
- && $selectedline == $commitrow($curview,$id)} {
- selectline $selectedline 0
+ if {[info exists currentid] && $currentid == $id} {
+ make_secsel $row
}
}
@@ -6299,8 +7598,8 @@ proc mkbrgo {top} {
}
proc cherrypick {} {
- global rowmenuid curview commitrow
- global mainhead
+ global rowmenuid curview
+ global mainhead mainheadid
set oldhead [exec git rev-parse HEAD]
set dheads [descheads $rowmenuid]
@@ -6326,20 +7625,22 @@ proc cherrypick {} {
return
}
addnewchild $newhead $oldhead
- if {[info exists commitrow($curview,$oldhead)]} {
- insertrow $commitrow($curview,$oldhead) $newhead
+ if {[commitinview $oldhead $curview]} {
+ insertrow $newhead $oldhead $curview
if {$mainhead ne {}} {
movehead $newhead $mainhead
movedhead $newhead $mainhead
}
+ set mainheadid $newhead
redrawtags $oldhead
redrawtags $newhead
+ selbyid $newhead
}
notbusy cherrypick
}
proc resethead {} {
- global mainheadid mainhead rowmenuid confirm_ok resettype
+ global mainhead rowmenuid confirm_ok resettype
set confirm_ok 0
set w ".confirmreset"
@@ -6372,12 +7673,13 @@ proc resethead {} {
tkwait window $w
if {!$confirm_ok} return
if {[catch {set fd [open \
- [list | sh -c "git reset --$resettype $rowmenuid 2>&1"] r]} err]} {
+ [list | git reset --$resettype $rowmenuid 2>@1] r]} err]} {
error_popup $err
} else {
dohidelocalchanges
filerun $fd [list readresetstat $fd]
nowbusy reset [mc "Resetting"]
+ selbyid $rowmenuid
}
}
@@ -6429,28 +7731,48 @@ proc headmenu {x y id head} {
}
proc cobranch {} {
- global headmenuid headmenuhead mainhead headids
+ global headmenuid headmenuhead headids
global showlocalchanges mainheadid
# check the tree is clean first??
- set oldmainhead $mainhead
nowbusy checkout [mc "Checking out"]
update
dohidelocalchanges
if {[catch {
- exec git checkout -q $headmenuhead
+ set fd [open [list | git checkout $headmenuhead 2>@1] r]
} err]} {
notbusy checkout
error_popup $err
+ if {$showlocalchanges} {
+ dodiffindex
+ }
} else {
- notbusy checkout
- set mainhead $headmenuhead
- set mainheadid $headmenuid
- if {[info exists headids($oldmainhead)]} {
- redrawtags $headids($oldmainhead)
+ filerun $fd [list readcheckoutstat $fd $headmenuhead $headmenuid]
+ }
+}
+
+proc readcheckoutstat {fd newhead newheadid} {
+ global mainhead mainheadid headids showlocalchanges progresscoords
+
+ if {[gets $fd line] >= 0} {
+ if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
+ set progresscoords [list 0 [expr {1.0 * $m / $n}]]
+ adjustprogress
}
- redrawtags $headmenuid
+ return 1
+ }
+ set progresscoords {0 0}
+ adjustprogress
+ notbusy checkout
+ if {[catch {close $fd} err]} {
+ error_popup $err
}
+ set oldmainid $mainheadid
+ set mainhead $newhead
+ set mainheadid $newheadid
+ redrawtags $oldmainid
+ redrawtags $newheadid
+ selbyid $newheadid
if {$showlocalchanges} {
dodiffindex
}
@@ -6564,13 +7886,13 @@ proc reflistfilter_change {n1 n2 op} {
proc refill_reflist {} {
global reflist reflistfilter showrefstop headids tagids otherrefids
- global commitrow curview commitinterest
+ global curview commitinterest
if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
set refs {}
foreach n [array names headids] {
if {[string match $reflistfilter $n]} {
- if {[info exists commitrow($curview,$headids($n))]} {
+ if {[commitinview $headids($n) $curview]} {
lappend refs [list $n H]
} else {
set commitinterest($headids($n)) {run refill_reflist}
@@ -6579,7 +7901,7 @@ proc refill_reflist {} {
}
foreach n [array names tagids] {
if {[string match $reflistfilter $n]} {
- if {[info exists commitrow($curview,$tagids($n))]} {
+ if {[commitinview $tagids($n) $curview]} {
lappend refs [list $n T]
} else {
set commitinterest($tagids($n)) {run refill_reflist}
@@ -6588,7 +7910,7 @@ proc refill_reflist {} {
}
foreach n [array names otherrefids] {
if {[string match $reflistfilter $n]} {
- if {[info exists commitrow($curview,$otherrefids($n))]} {
+ if {[commitinview $otherrefids($n) $curview]} {
lappend refs [list $n o]
} else {
set commitinterest($otherrefids($n)) {run refill_reflist}
@@ -7732,7 +9054,7 @@ proc changedrefs {} {
}
proc rereadrefs {} {
- global idtags idheads idotherrefs mainhead
+ global idtags idheads idotherrefs mainheadid
set refids [concat [array names idtags] \
[array names idheads] [array names idotherrefs]]
@@ -7741,19 +9063,21 @@ proc rereadrefs {} {
set ref($id) [listrefs $id]
}
}
- set oldmainhead $mainhead
+ set oldmainhead $mainheadid
readrefs
changedrefs
set refids [lsort -unique [concat $refids [array names idtags] \
[array names idheads] [array names idotherrefs]]]
foreach id $refids {
set v [listrefs $id]
- if {![info exists ref($id)] || $ref($id) != $v ||
- ($id eq $oldmainhead && $id ne $mainhead) ||
- ($id eq $mainhead && $id ne $oldmainhead)} {
+ if {![info exists ref($id)] || $ref($id) != $v} {
redrawtags $id
}
}
+ if {$oldmainhead ne $mainheadid} {
+ redrawtags $oldmainhead
+ redrawtags $mainheadid
+ }
run refill_reflist
}
@@ -7802,9 +9126,15 @@ proc showtag {tag isnew} {
proc doquit {} {
global stopped
+ global gitktmpdir
+
set stopped 100
savestuff .
destroy .
+
+ if {[info exists gitktmpdir]} {
+ catch {file delete -force $gitktmpdir}
+ }
}
proc mkfontdisp {font top which} {
@@ -7933,7 +9263,7 @@ proc doprefs {} {
global maxwidth maxgraphpct
global oldprefs prefstop showneartags showlocalchanges
global bgcolor fgcolor ctext diffcolors selectbgcolor
- global tabstop limitdiffs
+ global tabstop limitdiffs autoselect extdifftool
set top .gitkprefs
set prefstop $top
@@ -7963,6 +9293,11 @@ proc doprefs {} {
checkbutton $top.showlocal.b -variable showlocalchanges
pack $top.showlocal.b $top.showlocal.l -side left
grid x $top.showlocal -sticky w
+ frame $top.autoselect
+ label $top.autoselect.l -text [mc "Auto-select SHA1"] -font optionfont
+ checkbutton $top.autoselect.b -variable autoselect
+ pack $top.autoselect.b $top.autoselect.l -side left
+ grid x $top.autoselect -sticky w
label $top.ddisp -text [mc "Diff display options"]
grid $top.ddisp - -sticky w -pady 10
@@ -7980,15 +9315,24 @@ proc doprefs {} {
pack $top.ldiff.b $top.ldiff.l -side left
grid x $top.ldiff -sticky w
+ entry $top.extdifft -textvariable extdifftool
+ frame $top.extdifff
+ label $top.extdifff.l -text [mc "External diff tool" ] -font optionfont \
+ -padx 10
+ button $top.extdifff.b -text [mc "Choose..."] -font optionfont \
+ -command choose_extdiff
+ pack $top.extdifff.l $top.extdifff.b -side left
+ grid x $top.extdifff $top.extdifft -sticky w
+
label $top.cdisp -text [mc "Colors: press to choose"]
grid $top.cdisp - -sticky w -pady 10
label $top.bg -padx 40 -relief sunk -background $bgcolor
button $top.bgbut -text [mc "Background"] -font optionfont \
- -command [list choosecolor bgcolor 0 $top.bg background setbg]
+ -command [list choosecolor bgcolor {} $top.bg background setbg]
grid x $top.bgbut $top.bg -sticky w
label $top.fg -padx 40 -relief sunk -background $fgcolor
button $top.fgbut -text [mc "Foreground"] -font optionfont \
- -command [list choosecolor fgcolor 0 $top.fg foreground setfg]
+ -command [list choosecolor fgcolor {} $top.fg foreground setfg]
grid x $top.fgbut $top.fg -sticky w
label $top.diffold -padx 40 -relief sunk -background [lindex $diffcolors 0]
button $top.diffoldbut -text [mc "Diff: old lines"] -font optionfont \
@@ -8008,7 +9352,7 @@ proc doprefs {} {
grid x $top.hunksepbut $top.hunksep -sticky w
label $top.selbgsep -padx 40 -relief sunk -background $selectbgcolor
button $top.selbgbut -text [mc "Select bg"] -font optionfont \
- -command [list choosecolor selectbgcolor 0 $top.selbgsep background setselbg]
+ -command [list choosecolor selectbgcolor {} $top.selbgsep background setselbg]
grid x $top.selbgbut $top.selbgsep -sticky w
label $top.cfont -text [mc "Fonts: press to choose"]
@@ -8027,6 +9371,15 @@ proc doprefs {} {
bind $top <Visibility> "focus $top.buts.ok"
}
+proc choose_extdiff {} {
+ global extdifftool
+
+ set prog [tk_getOpenFile -title "External diff tool" -multiple false]
+ if {$prog ne {}} {
+ set extdifftool $prog
+ }
+}
+
proc choosecolor {v vi w x cmd} {
global $v
@@ -8418,7 +9771,6 @@ if {[catch {package require Tk 8.4} err]} {
}
# defaults...
-set datemode 0
set wrcomcmd "git diff-tree --stdin -p --pretty"
set gitencoding {}
@@ -8453,14 +9805,20 @@ set maxlinelen 200
set showlocalchanges 1
set limitdiffs 1
set datetimeformat "%Y-%m-%d %H:%M:%S"
+set autoselect 1
+
+set extdifftool "meld"
set colors {green red blue magenta darkgrey brown orange}
set bgcolor white
set fgcolor black
set diffcolors {red "#00a000" blue}
set diffcontext 3
+set ignorespace 0
set selectbgcolor gray85
+set circlecolors {white blue gray blue blue}
+
## For msgcat loading, first locate the installation location.
if { [info exists ::env(GITK_MSGSDIR)] } {
## Msgsdir was manually set in the environment.
@@ -8507,22 +9865,20 @@ if {![file isdirectory $gitdir]} {
exit 1
}
-set mergeonly 0
set revtreeargs {}
set cmdline_files {}
set i 0
+set revtreeargscmd {}
foreach arg $argv {
- switch -- $arg {
+ switch -glob -- $arg {
"" { }
- "-d" { set datemode 1 }
- "--merge" {
- set mergeonly 1
- lappend revtreeargs $arg
- }
"--" {
set cmdline_files [lrange $argv [expr {$i + 1}] end]
break
}
+ "--argscmd=*" {
+ set revtreeargscmd [string range $arg 10 end]
+ }
default {
lappend revtreeargs $arg
}
@@ -8531,7 +9887,7 @@ foreach arg $argv {
}
if {$i >= [llength $argv] && $revtreeargs ne {}} {
- # no -- on command line, but some arguments (other than -d)
+ # no -- on command line, but some arguments (other than --argscmd)
if {[catch {
set f [eval exec git rev-parse --no-revs --no-flags $revtreeargs]
set cmdline_files [split $f "\n"]
@@ -8559,42 +9915,9 @@ if {$i >= [llength $argv] && $revtreeargs ne {}} {
}
}
-if {$mergeonly} {
- # find the list of unmerged files
- set mlist {}
- set nr_unmerged 0
- if {[catch {
- set fd [open "| git ls-files -u" r]
- } err]} {
- show_error {} . "[mc "Couldn't get list of unmerged files:"] $err"
- exit 1
- }
- while {[gets $fd line] >= 0} {
- set i [string first "\t" $line]
- if {$i < 0} continue
- set fname [string range $line [expr {$i+1}] end]
- if {[lsearch -exact $mlist $fname] >= 0} continue
- incr nr_unmerged
- if {$cmdline_files eq {} || [path_filter $cmdline_files $fname]} {
- lappend mlist $fname
- }
- }
- catch {close $fd}
- if {$mlist eq {}} {
- if {$nr_unmerged == 0} {
- show_error {} . [mc "No files selected: --merge specified but\
- no files are unmerged."]
- } else {
- show_error {} . [mc "No files selected: --merge specified but\
- no unmerged files are within file limit."]
- }
- exit 1
- }
- set cmdline_files $mlist
-}
-
set nullid "0000000000000000000000000000000000000000"
set nullid2 "0000000000000000000000000000000000000001"
+set nullfile "/dev/null"
set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}]
@@ -8624,14 +9947,17 @@ set highlight_files {}
set viewfiles(0) {}
set viewperm(0) 0
set viewargs(0) {}
+set viewargscmd(0) {}
+set selectedline {}
+set numcommits 0
+set loginstance 0
set cmdlineok 0
set stopped 0
set stuffsaved 0
set patchnum 0
-set localirow -1
-set localfrow -1
set lserial 0
+set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
setcoords
makewindow
# wait for the window to become visible
@@ -8639,7 +9965,7 @@ tkwait visibility .
wm title . "[file tail $argv0]: [file tail [pwd]]"
readrefs
-if {$cmdline_files ne {} || $revtreeargs ne {}} {
+if {$cmdline_files ne {} || $revtreeargs ne {} || $revtreeargscmd ne {}} {
# create a view for the files/dirs specified on the command line
set curview 1
set selectedview 1
@@ -8647,7 +9973,9 @@ if {$cmdline_files ne {} || $revtreeargs ne {}} {
set viewname(1) [mc "Command line"]
set viewfiles(1) $cmdline_files
set viewargs(1) $revtreeargs
+ set viewargscmd(1) $revtreeargscmd
set viewperm(1) 0
+ set vdatemode(1) 0
addviewmenu 1
.bar.view entryconf [mc "Edit view..."] -state normal
.bar.view entryconf [mc "Delete view"] -state normal
@@ -8660,8 +9988,9 @@ if {[info exists permviews]} {
set viewname($n) [lindex $v 0]
set viewfiles($n) [lindex $v 1]
set viewargs($n) [lindex $v 2]
+ set viewargscmd($n) [lindex $v 3]
set viewperm($n) 1
addviewmenu $n
}
}
-getcommits
+getcommits {}
diff --git a/gitk-git/po/de.po b/gitk-git/po/de.po
index 5ee2fca8b..04ee57099 100644
--- a/gitk-git/po/de.po
+++ b/gitk-git/po/de.po
@@ -7,522 +7,721 @@ msgid ""
msgstr ""
"Project-Id-Version: git-gui\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-01-09 22:20+0100\n"
-"PO-Revision-Date: 2008-01-09 22:21+0100\n"
+"POT-Creation-Date: 2008-05-24 22:32+0200\n"
+"PO-Revision-Date: 2008-05-24 22:40+0200\n"
"Last-Translator: Christian Stimming <stimming@tuhh.de>\n"
"Language-Team: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: gitk:101
-msgid "Error executing git rev-list:"
-msgstr "Fehler beim Ausführen von git-rev-list:"
+#: gitk:102
+msgid "Couldn't get list of unmerged files:"
+msgstr "Liste der nicht-zusammengeführten Dateien nicht gefunden:"
+
+#: gitk:329
+msgid "No files selected: --merge specified but no files are unmerged."
+msgstr ""
+"Keine Dateien ausgewählt: --merge angegeben, es existieren aber keine nicht-"
+"zusammengeführten Dateien."
+
+#: gitk:332
+msgid ""
+"No files selected: --merge specified but no unmerged files are within file "
+"limit."
+msgstr ""
+"Keine Dateien ausgewähle: --merge angegeben, aber keine nicht-"
+"zusammengeführten Dateien sind in der Dateiauswahl."
-#: gitk:114
+#: gitk:354
+msgid "Error executing git log:"
+msgstr "Fehler beim Ausführen von git-log:"
+
+#: gitk:369
msgid "Reading"
msgstr "Lesen"
-#: gitk:141 gitk:2143
+#: gitk:151 gitk:2191
msgid "Reading commits..."
msgstr "Versionen lesen..."
-#: gitk:264
+#: gitk:275
msgid "Can't parse git log output:"
-msgstr "Git log Ausgabe kann nicht erkannt werden:"
+msgstr "Ausgabe von git-log kann nicht erkannt werden:"
-#: gitk:375 gitk:2147
+#: gitk:386 gitk:2195
msgid "No commits selected"
msgstr "Keine Versionen ausgewählt."
-#: gitk:486
+#: gitk:500
msgid "No commit information available"
msgstr "Keine Versionsinformation verfügbar"
-#: gitk:585 gitk:607 gitk:1908 gitk:6366 gitk:7866 gitk:8020
+#: gitk:599 gitk:621 gitk:1955 gitk:6424 gitk:7924 gitk:8083
msgid "OK"
msgstr "Ok"
-#: gitk:609 gitk:1909 gitk:6046 gitk:6117 gitk:6218 gitk:6264 gitk:6368
-#: gitk:7867 gitk:8021
+#: gitk:623 gitk:1956 gitk:6108 gitk:6179 gitk:6276 gitk:6322 gitk:6426
+#: gitk:7925 gitk:8084
msgid "Cancel"
msgstr "Abbrechen"
-#: gitk:646
+#: gitk:661
msgid "File"
msgstr "Datei"
-#: gitk:648
+#: gitk:663
msgid "Update"
msgstr "Aktualisieren"
-#: gitk:649
+#: gitk:1722
+msgid "Reload"
+msgstr "Neu laden"
+
+#: gitk:1723
msgid "Reread references"
msgstr "Zweige neu laden"
-#: gitk:650
+#: gitk:665
msgid "List references"
-msgstr "Zweige auflisten"
+msgstr "Zweige/Markierungen auflisten"
-#: gitk:651
+#: gitk:666
msgid "Quit"
msgstr "Beenden"
-#: gitk:653
+#: gitk:668
msgid "Edit"
msgstr "Bearbeiten"
-#: gitk:654
+#: gitk:669
msgid "Preferences"
msgstr "Einstellungen"
-#: gitk:657
+#: gitk:672 gitk:1892
msgid "View"
msgstr "Ansicht"
-#: gitk:658
+#: gitk:673
msgid "New view..."
msgstr "Neue Ansicht..."
-#: gitk:659 gitk:2085 gitk:8651
+#: gitk:674 gitk:2133 gitk:8723
msgid "Edit view..."
msgstr "Ansicht bearbeiten..."
-#: gitk:661 gitk:2086 gitk:8652
+#: gitk:676 gitk:2134 gitk:8724
msgid "Delete view"
msgstr "Ansicht löschen"
-#: gitk:663
+#: gitk:678
msgid "All files"
msgstr "Alle Dateien"
-#: gitk:667
+#: gitk:682
msgid "Help"
msgstr "Hilfe"
-#: gitk:668 gitk:1280
+#: gitk:683 gitk:1317
msgid "About gitk"
msgstr "Ãœber gitk"
-#: gitk:669
+#: gitk:684
msgid "Key bindings"
msgstr "Tastenkürzel"
-#: gitk:726
+#: gitk:741
msgid "SHA1 ID: "
msgstr "SHA1:"
-#: gitk:776
+#: gitk:1831
+msgid "Row"
+msgstr "Zeile"
+
+#: gitk:1862
msgid "Find"
msgstr "Suche"
-#: gitk:777
+#: gitk:792
msgid "next"
msgstr "nächste"
-#: gitk:778
+#: gitk:793
msgid "prev"
msgstr "vorige"
-#: gitk:779
+#: gitk:794
msgid "commit"
-msgstr "Version"
+msgstr "Version nach"
-#: gitk:782 gitk:784 gitk:2308 gitk:2331 gitk:2355 gitk:4257 gitk:4320
+#: gitk:797 gitk:799 gitk:2356 gitk:2379 gitk:2403 gitk:4306 gitk:4369
msgid "containing:"
-msgstr "enthaltend:"
+msgstr "Beschreibung:"
-#: gitk:785 gitk:1741 gitk:1746 gitk:2383
+#: gitk:800 gitk:1778 gitk:1783 gitk:2431
msgid "touching paths:"
-msgstr "Pfad betreffend:"
+msgstr "Dateien:"
-#: gitk:786 gitk:2388
+#: gitk:801 gitk:2436
msgid "adding/removing string:"
-msgstr "String dazu/löschen:"
+msgstr "Änderungen:"
-#: gitk:795 gitk:797
+#: gitk:810 gitk:812
msgid "Exact"
msgstr "Exakt"
-#: gitk:797 gitk:2466 gitk:4225
+#: gitk:812 gitk:2514 gitk:4274
msgid "IgnCase"
msgstr "Kein Groß/Klein"
-#: gitk:797 gitk:2357 gitk:2464 gitk:4221
+#: gitk:812 gitk:2405 gitk:2512 gitk:4270
msgid "Regexp"
msgstr "Regexp"
-#: gitk:799 gitk:800 gitk:2485 gitk:2515 gitk:2522 gitk:4331 gitk:4387
+#: gitk:814 gitk:815 gitk:2533 gitk:2563 gitk:2570 gitk:4380 gitk:4436
msgid "All fields"
msgstr "Alle Felder"
-#: gitk:800 gitk:2483 gitk:2515 gitk:4287
+#: gitk:815 gitk:2531 gitk:2563 gitk:4336
msgid "Headline"
msgstr "Ãœberschrift"
-#: gitk:801 gitk:2483 gitk:4287 gitk:4387 gitk:4775
+#: gitk:816 gitk:2531 gitk:4336 gitk:4436 gitk:4827
msgid "Comments"
msgstr "Beschreibung"
-#: gitk:801 gitk:2483 gitk:2487 gitk:2522 gitk:4287 gitk:4711 gitk:5895
-#: gitk:5910
+#: gitk:816 gitk:2531 gitk:2535 gitk:2570 gitk:4336 gitk:4763 gitk:5957
+#: gitk:5972
msgid "Author"
msgstr "Autor"
-#: gitk:801 gitk:2483 gitk:4287 gitk:4713
+#: gitk:816 gitk:2531 gitk:4336 gitk:4765
msgid "Committer"
msgstr "Eintragender"
-#: gitk:829
+#: gitk:845
msgid "Search"
msgstr "Suche"
-#: gitk:836
+#: gitk:852
msgid "Diff"
msgstr "Vergleich"
-#: gitk:838
+#: gitk:854
msgid "Old version"
msgstr "Alte Version"
-#: gitk:840
+#: gitk:856
msgid "New version"
msgstr "Neue Version"
-#: gitk:842
+#: gitk:858
msgid "Lines of context"
msgstr "Kontextzeilen"
-#: gitk:900
+#: gitk:868
+msgid "Ignore space change"
+msgstr "Leerzeichenänderungen ignorieren"
+
+#: gitk:926
msgid "Patch"
msgstr "Patch"
-#: gitk:902
+#: gitk:928
msgid "Tree"
msgstr "Baum"
-#: gitk:1018 gitk:1033 gitk:5961
+#: gitk:1053 gitk:1068 gitk:6023
msgid "Diff this -> selected"
msgstr "Vergleich diese -> gewählte"
-#: gitk:1020 gitk:1035 gitk:5962
+#: gitk:1055 gitk:1070 gitk:6024
msgid "Diff selected -> this"
msgstr "Vergleich gewählte -> diese"
-#: gitk:1022 gitk:1037 gitk:5963
+#: gitk:1057 gitk:1072 gitk:6025
msgid "Make patch"
msgstr "Patch erstellen"
-#: gitk:1023 gitk:6101
+#: gitk:1058 gitk:6163
msgid "Create tag"
msgstr "Markierung erstellen"
-#: gitk:1024 gitk:6198
+#: gitk:1059 gitk:6256
msgid "Write commit to file"
msgstr "Version in Datei schreiben"
-#: gitk:1025 gitk:6252
+#: gitk:1060 gitk:6310
msgid "Create new branch"
msgstr "Neuen Zweig erstellen"
-#: gitk:1026
+#: gitk:1061
msgid "Cherry-pick this commit"
msgstr "Diese Version pflücken"
-#: gitk:1028
+#: gitk:1063
msgid "Reset HEAD branch to here"
msgstr "HEAD-Zweig auf diese Version zurücksetzen"
-#: gitk:1044
+#: gitk:1079
msgid "Check out this branch"
msgstr "Auf diesen Zweig umstellen"
-#: gitk:1046
+#: gitk:1081
msgid "Remove this branch"
msgstr "Zweig löschen"
-#: gitk:1052
+#: gitk:1087
msgid "Highlight this too"
msgstr "Diesen auch hervorheben"
-#: gitk:1054
+#: gitk:1089
msgid "Highlight this only"
msgstr "Nur diesen hervorheben"
-#: gitk:1281
+#: gitk:2162
+msgid "External diff"
+msgstr "Externer Vergleich"
+
+#: gitk:2403
msgid ""
"\n"
"Gitk - a commit viewer for git\n"
"\n"
-"Copyright © 2005-2006 Paul Mackerras\n"
+"Copyright © 2005-2008 Paul Mackerras\n"
"\n"
"Use and redistribute under the terms of the GNU General Public License"
msgstr ""
"\n"
"Gitk - eine Visualisierung der Git Historie\n"
"\n"
-"Copyright © 2005-2006 Paul Mackerras\n"
+"Copyright © 2005-2008 Paul Mackerras\n"
"\n"
-"Benutzung und Weiterverbreitung gemäß den Bedingungen der GNU General Public "
-"License\n"
-" "
+"Benutzung und Weiterverbreitung gemäß den Bedingungen der GNU General Public License"
-#: gitk:1289 gitk:1350 gitk:6524
+#: gitk:1326 gitk:1387 gitk:6582
msgid "Close"
msgstr "Schließen"
-#: gitk:1308
+#: gitk:1345
msgid "Gitk key bindings"
msgstr "Gitk Tastaturbelegung"
-#: gitk:1858
+#: gitk:1347
+msgid "Gitk key bindings:"
+msgstr "Gitk Tastaturbelegung:"
+
+#: gitk:1349
+#, tcl-format
+msgid "<%s-Q>\t\tQuit"
+msgstr "<%s-Q>\t\tBeenden"
+
+#: gitk:1350
+msgid "<Home>\t\tMove to first commit"
+msgstr "<Pos1>\t\tZur neuesten Version springen"
+
+#: gitk:1351
+msgid "<End>\t\tMove to last commit"
+msgstr "<Ende>\t\tZur ältesten Version springen"
+
+#: gitk:1352
+msgid "<Up>, p, i\tMove up one commit"
+msgstr "<Hoch>, p, i\tNächste neuere Version"
+
+#: gitk:1353
+msgid "<Down>, n, k\tMove down one commit"
+msgstr "<Runter>, n, k\tNächste ältere Version"
+
+#: gitk:1354
+msgid "<Left>, z, j\tGo back in history list"
+msgstr "<Links>, z, j\tEine Version zurückgehen"
+
+#: gitk:1355
+msgid "<Right>, x, l\tGo forward in history list"
+msgstr "<Rechts>, x, l\tEine Version weitergehen"
+
+#: gitk:1356
+msgid "<PageUp>\tMove up one page in commit list"
+msgstr "<BildHoch>\tEine Seite nach oben blättern"
+
+#: gitk:1357
+msgid "<PageDown>\tMove down one page in commit list"
+msgstr "<BildRunter>\tEine Seite nach unten blättern"
+
+#: gitk:1358
+#, tcl-format
+msgid "<%s-Home>\tScroll to top of commit list"
+msgstr "<%s-Pos1>\tZum oberen Ende der Versionsliste blättern"
+
+#: gitk:1359
+#, tcl-format
+msgid "<%s-End>\tScroll to bottom of commit list"
+msgstr "<%s-Ende>\tZum unteren Ende der Versionsliste blättern"
+
+#: gitk:1360
+#, tcl-format
+msgid "<%s-Up>\tScroll commit list up one line"
+msgstr "<%s-Hoch>\tVersionsliste eine Zeile nach oben blättern"
+
+#: gitk:1361
+#, tcl-format
+msgid "<%s-Down>\tScroll commit list down one line"
+msgstr "<%s-Runter>\tVersionsliste eine Zeile nach unten blättern"
+
+#: gitk:1362
+#, tcl-format
+msgid "<%s-PageUp>\tScroll commit list up one page"
+msgstr "<%s-BildHoch>\tVersionsliste eine Seite hoch blättern"
+
+#: gitk:1363
+#, tcl-format
+msgid "<%s-PageDown>\tScroll commit list down one page"
+msgstr "<%s-BildRunter>\tVersionsliste eine Seite nach unten blättern"
+
+#: gitk:1364
+msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
+msgstr "<Umschalt-Hoch>\tRückwärts suchen (nach oben; neuere Versionen)"
+
+#: gitk:1365
+msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
+msgstr "<Umschalt-Runter> Suchen (nach unten; ältere Versionen)"
+
+#: gitk:1366
+msgid "<Delete>, b\tScroll diff view up one page"
+msgstr "<Entf>, b\t\tVergleich eine Seite nach oben blättern"
+
+#: gitk:1367
+msgid "<Backspace>\tScroll diff view up one page"
+msgstr "<Löschtaste>\tVergleich eine Seite nach oben blättern"
+
+#: gitk:1368
+msgid "<Space>\t\tScroll diff view down one page"
+msgstr "<Leertaste>\tVergleich eine Seite nach unten blättern"
+
+#: gitk:1369
+msgid "u\t\tScroll diff view up 18 lines"
+msgstr "u\t\tVergleich um 18 Zeilen nach oben (»up«) blättern"
+
+#: gitk:1370
+msgid "d\t\tScroll diff view down 18 lines"
+msgstr "d\t\tVergleich um 18 Zeilen nach unten (»down«) blättern"
+
+#: gitk:1371
+#, tcl-format
+msgid "<%s-F>\t\tFind"
+msgstr "<%s-F>\t\tSuchen"
+
+#: gitk:1372
+#, tcl-format
+msgid "<%s-G>\t\tMove to next find hit"
+msgstr "<%s-G>\t\tWeitersuchen"
+
+#: gitk:1373
+msgid "<Return>\tMove to next find hit"
+msgstr "<Eingabetaste>\tWeitersuchen"
+
+#: gitk:1374
+msgid "/\t\tMove to next find hit, or redo find"
+msgstr "/\t\tWeitersuchen oder neue Suche beginnen"
+
+#: gitk:1375
+msgid "?\t\tMove to previous find hit"
+msgstr "?\t\tRückwärts weitersuchen"
+
+#: gitk:1376
+msgid "f\t\tScroll diff view to next file"
+msgstr "f\t\tVergleich zur nächsten Datei (»file«) blättern"
+
+#: gitk:1377
+#, tcl-format
+msgid "<%s-S>\t\tSearch for next hit in diff view"
+msgstr "<%s-S>\t\tWeitersuchen im Vergleich"
+
+#: gitk:1378
+#, tcl-format
+msgid "<%s-R>\t\tSearch for previous hit in diff view"
+msgstr "<%s-R>\t\tRückwärts weitersuchen im Vergleich"
+
+#: gitk:1379
+#, tcl-format
+msgid "<%s-KP+>\tIncrease font size"
+msgstr "<%s-Nummerblock-Plus>\tSchriftgröße vergrößern"
+
+#: gitk:1380
+#, tcl-format
+msgid "<%s-plus>\tIncrease font size"
+msgstr "<%s-Plus>\tSchriftgröße vergrößern"
+
+#: gitk:1381
+#, tcl-format
+msgid "<%s-KP->\tDecrease font size"
+msgstr "<%s-Nummernblock-> Schriftgröße verkleinern"
+
+#: gitk:1382
+#, tcl-format
+msgid "<%s-minus>\tDecrease font size"
+msgstr "<%s-Minus>\tSchriftgröße verkleinern"
+
+#: gitk:1383
+msgid "<F5>\t\tUpdate"
+msgstr "<F5>\t\tAktualisieren"
+
+#: gitk:1896
msgid "Gitk view definition"
msgstr "Gitk Ansichten"
-#: gitk:1882
+#: gitk:1921
msgid "Name"
msgstr "Name"
-#: gitk:1885
+#: gitk:1924
msgid "Remember this view"
msgstr "Diese Ansicht speichern"
-#: gitk:1889
-msgid "Commits to include (arguments to git rev-list):"
-msgstr "Versionen anzeigen (Argumente von git-rev-list):"
+#: gitk:3126
+msgid "Commits to include (arguments to git log):"
+msgstr "Versionen anzeigen (Argumente von git-log):"
+
+#: gitk:3133
+msgid "Command to generate more commits to include:"
+msgstr "Versionsliste durch folgendes Kommando erzeugen lassen:"
-#: gitk:1895
+#: gitk:1942
msgid "Enter files and directories to include, one per line:"
msgstr "Folgende Dateien und Verzeichnisse anzeigen (eine pro Zeile):"
-#: gitk:1942
+#: gitk:1989
msgid "Error in commit selection arguments:"
msgstr "Fehler in den ausgewählten Versionen:"
-#: gitk:1993 gitk:2079 gitk:2535 gitk:2549 gitk:3732 gitk:8620 gitk:8621
+#: gitk:2043 gitk:2127 gitk:2583 gitk:2597 gitk:3781 gitk:8689 gitk:8690
msgid "None"
msgstr "Keine"
-#: gitk:2483 gitk:4287 gitk:5897 gitk:5912
+#: gitk:2531 gitk:4336 gitk:5959 gitk:5974
msgid "Date"
msgstr "Datum"
-#: gitk:2483 gitk:4287
+#: gitk:2531 gitk:4336
msgid "CDate"
msgstr "Eintragedatum"
-#: gitk:2632 gitk:2637
+#: gitk:2680 gitk:2685
msgid "Descendant"
msgstr "Abkömmling"
-#: gitk:2633
+#: gitk:2681
msgid "Not descendant"
msgstr "Nicht Abkömmling"
-#: gitk:2640 gitk:2645
+#: gitk:2688 gitk:2693
msgid "Ancestor"
msgstr "Vorgänger"
-#: gitk:2641
+#: gitk:2689
msgid "Not ancestor"
msgstr "Nicht Vorgänger"
-#: gitk:2875
+#: gitk:2924
msgid "Local changes checked in to index but not committed"
msgstr "Lokale Änderungen bereitgestellt, aber nicht eingetragen"
-#: gitk:2905
+#: gitk:2954
msgid "Local uncommitted changes, not checked in to index"
msgstr "Lokale Änderungen, nicht bereitgestellt"
-#: gitk:4256
+#: gitk:4305
msgid "Searching"
msgstr "Suchen"
-#: gitk:4715
+#: gitk:4767
msgid "Tags:"
msgstr "Markierungen:"
-#: gitk:4732 gitk:4738 gitk:5890
+#: gitk:4784 gitk:4790 gitk:5952
msgid "Parent"
msgstr "Eltern"
-#: gitk:4743
+#: gitk:4795
msgid "Child"
msgstr "Kind"
-#: gitk:4752
+#: gitk:4804
msgid "Branch"
msgstr "Zweig"
-#: gitk:4755
+#: gitk:4807
msgid "Follows"
msgstr "Folgt auf"
-#: gitk:4758
+#: gitk:4810
msgid "Precedes"
msgstr "Vorgänger von"
-#: gitk:5040
+#: gitk:5094
msgid "Error getting merge diffs:"
msgstr "Fehler beim Laden des Vergleichs:"
-#: gitk:5717
+#: gitk:5779
msgid "Goto:"
msgstr "Gehe zu:"
-#: gitk:5719
+#: gitk:5781
msgid "SHA1 ID:"
-msgstr "SHA1 Kennung:"
+msgstr "SHA1-Hashwert:"
-#: gitk:5744
+#: gitk:5806
#, tcl-format
msgid "Short SHA1 id %s is ambiguous"
-msgstr "Kurze SHA1-Kennung »%s« ist mehrdeutig"
+msgstr "Kurzer SHA1-Hashwert »%s« ist mehrdeutig"
-#: gitk:5756
+#: gitk:5818
#, tcl-format
msgid "SHA1 id %s is not known"
-msgstr "SHA1-Kennung »%s« unbekannt"
+msgstr "SHA1-Hashwert »%s« unbekannt"
-#: gitk:5758
+#: gitk:5820
#, tcl-format
msgid "Tag/Head %s is not known"
msgstr "Markierung/Zweig »%s« ist unbekannt"
-#: gitk:5900
+#: gitk:5962
msgid "Children"
msgstr "Kinder"
-#: gitk:5957
+#: gitk:6019
#, tcl-format
msgid "Reset %s branch to here"
msgstr "Zweig »%s« hierher zurücksetzen"
-#: gitk:5988
+#: gitk:7204
+msgid "Detached head: can't reset"
+msgstr "Zweigspitze ist abgetrennt: Zurücksetzen nicht möglich"
+
+#: gitk:7236
msgid "Top"
msgstr "Oben"
-#: gitk:5989
+#: gitk:6051
msgid "From"
msgstr "Von"
-#: gitk:5994
+#: gitk:6056
msgid "To"
msgstr "bis"
-#: gitk:6017
+#: gitk:6079
msgid "Generate patch"
msgstr "Patch erstellen"
-#: gitk:6019
+#: gitk:6081
msgid "From:"
msgstr "Von:"
-#: gitk:6028
+#: gitk:6090
msgid "To:"
msgstr "bis:"
-#: gitk:6037
+#: gitk:6099
msgid "Reverse"
msgstr "Umgekehrt"
-#: gitk:6039 gitk:6212
+#: gitk:6101 gitk:6270
msgid "Output file:"
msgstr "Ausgabedatei:"
-#: gitk:6045
+#: gitk:6107
msgid "Generate"
msgstr "Erzeugen"
-#: gitk:6081
+#: gitk:6143
msgid "Error creating patch:"
msgstr "Fehler beim Patch erzeugen:"
-#: gitk:6103 gitk:6200 gitk:6254
+#: gitk:6165 gitk:6258 gitk:6312
msgid "ID:"
msgstr "ID:"
-#: gitk:6112
+#: gitk:6174
msgid "Tag name:"
msgstr "Markierungsname:"
-#: gitk:6116 gitk:6263
+#: gitk:6178 gitk:6321
msgid "Create"
msgstr "Erstellen"
-#: gitk:6131
+#: gitk:6193
msgid "No tag name specified"
msgstr "Kein Markierungsname angegeben"
-#: gitk:6135
+#: gitk:6197
#, tcl-format
msgid "Tag \"%s\" already exists"
msgstr "Markierung »%s« existiert bereits."
-#: gitk:6145
+#: gitk:6203
msgid "Error creating tag:"
msgstr "Fehler bei Markierung erstellen:"
-#: gitk:6209
+#: gitk:6267
msgid "Command:"
msgstr "Kommando:"
-#: gitk:6217
+#: gitk:6275
msgid "Write"
msgstr "Schreiben"
-#: gitk:6233
+#: gitk:6291
msgid "Error writing commit:"
-msgstr "Fehler beim Version eintragen:"
+msgstr "Fehler beim Schreiben der Version:"
-#: gitk:6259
+#: gitk:6317
msgid "Name:"
msgstr "Name:"
-#: gitk:6278
+#: gitk:6336
msgid "Please specify a name for the new branch"
msgstr "Bitte geben Sie einen Namen für den neuen Zweig an."
-#: gitk:6307
+#: gitk:6365
#, tcl-format
msgid "Commit %s is already included in branch %s -- really re-apply it?"
msgstr ""
"Version »%s« ist bereits im Zweig »%s« enthalten -- trotzdem erneut "
"eintragen?"
-#: gitk:6312
+#: gitk:6370
msgid "Cherry-picking"
msgstr "Version pflücken"
-#: gitk:6324
+#: gitk:6382
msgid "No changes committed"
msgstr "Keine Änderungen eingetragen"
-#: gitk:6347
+#: gitk:6405
msgid "Confirm reset"
msgstr "Zurücksetzen bestätigen"
-#: gitk:6349
+#: gitk:6407
#, tcl-format
msgid "Reset branch %s to %s?"
msgstr "Zweig »%s« auf »%s« zurücksetzen?"
-#: gitk:6353
+#: gitk:6411
msgid "Reset type:"
msgstr "Art des Zurücksetzens:"
-#: gitk:6357
+#: gitk:6415
msgid "Soft: Leave working tree and index untouched"
msgstr "Harmlos: Arbeitskopie und Bereitstellung unverändert"
-#: gitk:6360
+#: gitk:6418
msgid "Mixed: Leave working tree untouched, reset index"
msgstr ""
"Gemischt: Arbeitskopie unverändert,\n"
"Bereitstellung zurückgesetzt"
-#: gitk:6363
+#: gitk:6421
msgid ""
"Hard: Reset working tree and index\n"
"(discard ALL local changes)"
@@ -530,21 +729,21 @@ msgstr ""
"Hart: Arbeitskopie und Bereitstellung\n"
"(Alle lokalen Änderungen werden gelöscht)"
-#: gitk:6379
+#: gitk:6437
msgid "Resetting"
msgstr "Zurücksetzen"
-#: gitk:6436
+#: gitk:6494
msgid "Checking out"
msgstr "Umstellen"
-#: gitk:6466
+#: gitk:6524
msgid "Cannot delete the currently checked-out branch"
msgstr ""
"Der Zweig, auf den die Arbeitskopie momentan umgestellt ist, kann nicht "
"gelöscht werden."
-#: gitk:6472
+#: gitk:6530
#, tcl-format
msgid ""
"The commits on branch %s aren't on any other branch.\n"
@@ -553,16 +752,16 @@ msgstr ""
"Die Versionen auf Zweig »%s« existieren auf keinem anderen Zweig.\n"
"Zweig »%s« trotzdem löschen?"
-#: gitk:6503
+#: gitk:6561
#, tcl-format
msgid "Tags and heads: %s"
msgstr "Markierungen und Zweige: %s"
-#: gitk:6517
+#: gitk:6575
msgid "Filter"
msgstr "Filtern"
-#: gitk:6811
+#: gitk:6869
msgid ""
"Error reading commit topology information; branch and preceding/following "
"tag information will be incomplete."
@@ -570,113 +769,125 @@ msgstr ""
"Fehler beim Lesen der Strukturinformationen; Zweige und Vorgänger/Nachfolger "
"Informationen werden unvollständig sein."
-#: gitk:7795
+#: gitk:7853
msgid "Tag"
msgstr "Markierung"
-#: gitk:7795
+#: gitk:7853
msgid "Id"
msgstr "Id"
-#: gitk:7835
+#: gitk:7893
msgid "Gitk font chooser"
msgstr "Gitk Schriften wählen"
-#: gitk:7852
+#: gitk:7910
msgid "B"
msgstr "F"
-#: gitk:7855
+#: gitk:7913
msgid "I"
msgstr "K"
-#: gitk:7948
+#: gitk:8006
msgid "Gitk preferences"
msgstr "Gitk Einstellungen"
-#: gitk:7949
+#: gitk:8007
msgid "Commit list display options"
msgstr "Anzeige Versionsliste"
-#: gitk:7952
+#: gitk:8010
msgid "Maximum graph width (lines)"
msgstr "Maximale Graphenbreite (Zeilen)"
-#: gitk:7956
+#: gitk:8014
#, tcl-format
msgid "Maximum graph width (% of pane)"
msgstr "Maximale Graphenbreite (% des Fensters)"
-#: gitk:7961
+#: gitk:8019
msgid "Show local changes"
msgstr "Lokale Änderungen anzeigen"
-#: gitk:7966
+#: gitk:8024
+msgid "Auto-select SHA1"
+msgstr "SHA1-Hashwert automatisch markieren"
+
+#: gitk:8029
msgid "Diff display options"
msgstr "Anzeige Vergleich"
-#: gitk:7968
+#: gitk:8031
msgid "Tab spacing"
msgstr "Tabulatorbreite"
-#: gitk:7972
+#: gitk:8035
msgid "Display nearby tags"
msgstr "Naheliegende Ãœberschriften anzeigen"
-#: gitk:7977
+#: gitk:8040
msgid "Limit diffs to listed paths"
msgstr "Vergleich nur für angezeigte Pfade"
-#: gitk:7982
+#: gitk:9264
+msgid "External diff tool"
+msgstr "Externes Vergleich-(Diff-)Programm"
+
+#: gitk:9266
+msgid "Choose..."
+msgstr "Wählen..."
+
+#: gitk:9271
msgid "Colors: press to choose"
msgstr "Farben: Klicken zum Wählen"
-#: gitk:7985
+#: gitk:8048
msgid "Background"
-msgstr "Vordergrund"
+msgstr "Hintergrund"
-#: gitk:7989
+#: gitk:8052
msgid "Foreground"
-msgstr "Hintergrund"
+msgstr "Vordergrund"
-#: gitk:7993
+#: gitk:8056
msgid "Diff: old lines"
msgstr "Vergleich: Alte Zeilen"
-#: gitk:7998
+#: gitk:8061
msgid "Diff: new lines"
msgstr "Vergleich: Neue Zeilen"
-#: gitk:8003
+#: gitk:8066
msgid "Diff: hunk header"
msgstr "Vergleich: Änderungstitel"
-#: gitk:8009
+#: gitk:8072
msgid "Select bg"
msgstr "Hintergrundfarbe Auswählen"
-#: gitk:8013
+#: gitk:8076
msgid "Fonts: press to choose"
msgstr "Schriftart: Klicken zum Wählen"
-#: gitk:8015
+#: gitk:8078
msgid "Main font"
msgstr "Programmschriftart"
-#: gitk:8016
+#: gitk:8079
msgid "Diff display font"
msgstr "Vergleich"
-#: gitk:8017
+#: gitk:8080
msgid "User interface font"
msgstr "Beschriftungen"
-#: gitk:8033
+#: gitk:8096
#, tcl-format
msgid "Gitk: choose color for %s"
msgstr "Gitk: Farbe wählen für %s"
-#: gitk:8414
+#: gitk:8477
msgid ""
"Sorry, gitk cannot run with this version of Tcl/Tk.\n"
" Gitk requires at least Tcl/Tk 8.4."
@@ -684,42 +895,24 @@ msgstr ""
"Gitk läuft nicht mit dieser Version von Tcl/Tk.\n"
"Gitk benötigt mindestens Tcl/Tk 8.4."
-#: gitk:8501
+#: gitk:8566
msgid "Cannot find a git repository here."
msgstr "Kein Git-Projektarchiv gefunden."
-#: gitk:8505
+#: gitk:8570
#, tcl-format
msgid "Cannot find the git directory \"%s\"."
msgstr "Git-Verzeichnis »%s« wurde nicht gefunden."
-#: gitk:8544
+#: gitk:8613
#, tcl-format
msgid "Ambiguous argument '%s': both revision and filename"
msgstr "Mehrdeutige Angabe »%s«: Sowohl Version als auch Dateiname existiert."
-#: gitk:8556
+#: gitk:8625
msgid "Bad arguments to gitk:"
msgstr "Falsche Kommandozeilen-Parameter für gitk:"
-#: gitk:8568
-msgid "Couldn't get list of unmerged files:"
-msgstr "Liste der nicht-zusammengeführten Dateien nicht gefunden:"
-
-#: gitk:8584
-msgid "No files selected: --merge specified but no files are unmerged."
-msgstr ""
-"Keine Dateien ausgewähle: --merge angegeben, es existieren aber keine nicht-"
-"zusammengeführten Dateien."
-
-#: gitk:8587
-msgid ""
-"No files selected: --merge specified but no unmerged files are within file "
-"limit."
-msgstr ""
-"Keine Dateien ausgewähle: --merge angegeben, aber keine nicht-"
-"zusammengeführten Dateien sind in der Dateiauswahl."
-
-#: gitk:8646
+#: gitk:9915
msgid "Command line"
msgstr "Kommandozeile"
diff --git a/gitk-git/po/es.po b/gitk-git/po/es.po
new file mode 100644
index 000000000..2cb148624
--- /dev/null
+++ b/gitk-git/po/es.po
@@ -0,0 +1,890 @@
+# Translation of gitk
+# Copyright (C) 2005-2008 Santiago Gala
+# This file is distributed under the same license as the gitk package.
+# Santiago Gala <santiago.gala@gmail.com>, 2008.
+#
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gitk\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-03-13 17:29+0100\n"
+"PO-Revision-Date: 2008-03-25 11:20+0100\n"
+"Last-Translator: Santiago Gala <santiago.gala@gmail.com>\n"
+"Language-Team: Spanish\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gitk:111
+msgid "Error executing git rev-list:"
+msgstr "Error al ejecutar git rev-list:"
+
+#: gitk:124
+msgid "Reading"
+msgstr "Leyendo"
+
+#: gitk:151 gitk:2191
+msgid "Reading commits..."
+msgstr "Leyendo revisiones..."
+
+#: gitk:275
+msgid "Can't parse git log output:"
+msgstr "Error analizando la salida de git log:"
+
+#: gitk:386 gitk:2195
+msgid "No commits selected"
+msgstr "No se seleccionaron revisiones"
+
+#: gitk:500
+msgid "No commit information available"
+msgstr "Falta información sobre las revisiones"
+
+#: gitk:599 gitk:621 gitk:1955 gitk:6423 gitk:7923 gitk:8082
+msgid "OK"
+msgstr "Aceptar"
+
+#: gitk:623 gitk:1956 gitk:6107 gitk:6178 gitk:6275 gitk:6321 gitk:6425
+#: gitk:7924 gitk:8083
+msgid "Cancel"
+msgstr "Cancelar"
+
+#: gitk:661
+msgid "File"
+msgstr "Archivo"
+
+#: gitk:663
+msgid "Update"
+msgstr "Actualizar"
+
+#: gitk:664
+msgid "Reread references"
+msgstr "Releer referencias"
+
+#: gitk:665
+msgid "List references"
+msgstr "Lista de referencias"
+
+#: gitk:666
+msgid "Quit"
+msgstr "Salir"
+
+#: gitk:668
+msgid "Edit"
+msgstr "Editar"
+
+#: gitk:669
+msgid "Preferences"
+msgstr "Preferencias"
+
+#: gitk:672 gitk:1892
+msgid "View"
+msgstr "Vista"
+
+#: gitk:673
+msgid "New view..."
+msgstr "Nueva vista..."
+
+#: gitk:674 gitk:2133 gitk:8722
+msgid "Edit view..."
+msgstr "Modificar vista..."
+
+#: gitk:676 gitk:2134 gitk:8723
+msgid "Delete view"
+msgstr "Eliminar vista"
+
+#: gitk:678
+msgid "All files"
+msgstr "Todos los archivos"
+
+#: gitk:682
+msgid "Help"
+msgstr "Ayuda"
+
+#: gitk:683 gitk:1317
+msgid "About gitk"
+msgstr "Acerca de gitk"
+
+#: gitk:684
+msgid "Key bindings"
+msgstr "Combinaciones de teclas"
+
+#: gitk:741
+msgid "SHA1 ID: "
+msgstr "SHA1 ID: "
+
+#: gitk:791
+msgid "Find"
+msgstr "Buscar"
+
+#: gitk:792
+msgid "next"
+msgstr "<<"
+
+#: gitk:793
+msgid "prev"
+msgstr ">>"
+
+#: gitk:794
+msgid "commit"
+msgstr "revisión"
+
+#: gitk:797 gitk:799 gitk:2356 gitk:2379 gitk:2403 gitk:4306 gitk:4369
+msgid "containing:"
+msgstr "que contiene:"
+
+#: gitk:800 gitk:1778 gitk:1783 gitk:2431
+msgid "touching paths:"
+msgstr "que modifica la ruta:"
+
+#: gitk:801 gitk:2436
+msgid "adding/removing string:"
+msgstr "que añade/elimina cadena:"
+
+#: gitk:810 gitk:812
+msgid "Exact"
+msgstr "Exacto"
+
+#: gitk:812 gitk:2514 gitk:4274
+msgid "IgnCase"
+msgstr "NoMayús"
+
+#: gitk:812 gitk:2405 gitk:2512 gitk:4270
+msgid "Regexp"
+msgstr "Regex"
+
+#: gitk:814 gitk:815 gitk:2533 gitk:2563 gitk:2570 gitk:4380 gitk:4436
+msgid "All fields"
+msgstr "Todos los campos"
+
+#: gitk:815 gitk:2531 gitk:2563 gitk:4336
+msgid "Headline"
+msgstr "Título"
+
+#: gitk:816 gitk:2531 gitk:4336 gitk:4436 gitk:4827
+msgid "Comments"
+msgstr "Comentarios"
+
+#: gitk:816 gitk:2531 gitk:2535 gitk:2570 gitk:4336 gitk:4763 gitk:5956
+#: gitk:5971
+msgid "Author"
+msgstr "Autor"
+
+#: gitk:816 gitk:2531 gitk:4336 gitk:4765
+msgid "Committer"
+msgstr ""
+
+#: gitk:845
+msgid "Search"
+msgstr "Buscar"
+
+#: gitk:852
+msgid "Diff"
+msgstr "Diferencia"
+
+#: gitk:854
+msgid "Old version"
+msgstr "Versión antigua"
+
+#: gitk:856
+msgid "New version"
+msgstr "Versión nueva"
+
+#: gitk:858
+msgid "Lines of context"
+msgstr "Líneas de contexto"
+
+#: gitk:868
+msgid "Ignore space change"
+msgstr "Ignora cambios de espaciado"
+
+#: gitk:926
+msgid "Patch"
+msgstr "Parche"
+
+#: gitk:928
+msgid "Tree"
+msgstr "Ãrbol"
+
+#: gitk:1053 gitk:1068 gitk:6022
+msgid "Diff this -> selected"
+msgstr "Diferencia de esta -> seleccionada"
+
+#: gitk:1055 gitk:1070 gitk:6023
+msgid "Diff selected -> this"
+msgstr "Diferencia de seleccionada -> esta"
+
+#: gitk:1057 gitk:1072 gitk:6024
+msgid "Make patch"
+msgstr "Crear patch"
+
+#: gitk:1058 gitk:6162
+msgid "Create tag"
+msgstr "Crear etiqueta"
+
+#: gitk:1059 gitk:6255
+msgid "Write commit to file"
+msgstr "Escribir revisiones a archivo"
+
+#: gitk:1060 gitk:6309
+msgid "Create new branch"
+msgstr "Crear nueva rama"
+
+#: gitk:1061
+msgid "Cherry-pick this commit"
+msgstr "Añadir esta revisión a la rama actual (cherry-pick)"
+
+#: gitk:1063
+msgid "Reset HEAD branch to here"
+msgstr "Traer la rama HEAD aquí"
+
+#: gitk:1079
+msgid "Check out this branch"
+msgstr "Cambiar a esta rama"
+
+#: gitk:1081
+msgid "Remove this branch"
+msgstr "Eliminar esta rama"
+
+#: gitk:1087
+msgid "Highlight this too"
+msgstr "Seleccionar también"
+
+#: gitk:1089
+msgid "Highlight this only"
+msgstr "Seleccionar sólo"
+
+#: gitk:1318
+msgid ""
+"\n"
+"Gitk - a commit viewer for git\n"
+"\n"
+"Copyright © 2005-2006 Paul Mackerras\n"
+"\n"
+"Use and redistribute under the terms of the GNU General Public License"
+msgstr ""
+"\n"
+"Gitk - un visualizador de revisiones para git\n"
+"\n"
+"Copyright © 2005-2006 Paul Mackerras\n"
+"\n"
+"Uso y redistribución permitidos según los términos de la Licencia Pública General de "
+"GNU (GNU GPL)"
+
+#: gitk:1326 gitk:1387 gitk:6581
+msgid "Close"
+msgstr "Cerrar"
+
+#: gitk:1345
+msgid "Gitk key bindings"
+msgstr "Combinaciones de tecla de Gitk"
+
+#: gitk:1347
+msgid "Gitk key bindings:"
+msgstr "Combinaciones de tecla de Gitk:"
+
+#: gitk:1349
+#, tcl-format
+msgid "<%s-Q>\t\tQuit"
+msgstr "<%s-Q>\t\tSalir"
+
+#: gitk:1350
+msgid "<Home>\t\tMove to first commit"
+msgstr "<Home>\t\tIr a la primera revisión"
+
+#: gitk:1351
+msgid "<End>\t\tMove to last commit"
+msgstr "<End>\t\tIr a la última revisión"
+
+#: gitk:1352
+msgid "<Up>, p, i\tMove up one commit"
+msgstr "<Up>, p, i\tSubir una revisión"
+
+#: gitk:1353
+msgid "<Down>, n, k\tMove down one commit"
+msgstr "<Down>, n, k\tBajar una revisión"
+
+#: gitk:1354
+msgid "<Left>, z, j\tGo back in history list"
+msgstr "<Left>, z, j\tRetroceder en la historia"
+
+#: gitk:1355
+msgid "<Right>, x, l\tGo forward in history list"
+msgstr "<Right>, x, l\tAvanzar en la historia"
+
+#: gitk:1356
+msgid "<PageUp>\tMove up one page in commit list"
+msgstr "<PageUp>\tSubir una página en la lista de revisiones"
+
+#: gitk:1357
+msgid "<PageDown>\tMove down one page in commit list"
+msgstr "<PageDown>\tBajar una página en la lista de revisiones"
+
+#: gitk:1358
+#, tcl-format
+msgid "<%s-Home>\tScroll to top of commit list"
+msgstr "<%s-Home>\tDesplazarse al inicio de la lista de revisiones"
+
+#: gitk:1359
+#, tcl-format
+msgid "<%s-End>\tScroll to bottom of commit list"
+msgstr "<%s-End>\tDesplazarse al final de la lista de revisiones"
+
+#: gitk:1360
+#, tcl-format
+msgid "<%s-Up>\tScroll commit list up one line"
+msgstr "<%s-Up>\tDesplazar una línea hacia arriba la lista de revisiones"
+
+#: gitk:1361
+#, tcl-format
+msgid "<%s-Down>\tScroll commit list down one line"
+msgstr "<%s-Down>\tDesplazar una línea hacia abajo la lista de revisiones"
+
+#: gitk:1362
+#, tcl-format
+msgid "<%s-PageUp>\tScroll commit list up one page"
+msgstr "<%s-PageUp>\tDesplazar una página hacia arriba la lista de revisiones"
+
+#: gitk:1363
+#, tcl-format
+msgid "<%s-PageDown>\tScroll commit list down one page"
+msgstr "<%s-PageDown>\tDesplazar una página hacia abajo la lista de revisiones"
+
+#: gitk:1364
+msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
+msgstr "<Shift-Up>\tBuscar hacia atrás (arriba, revisiones siguientes)"
+
+#: gitk:1365
+msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
+msgstr "<Shift-Down>\tBuscar hacia adelante (abajo, revisiones anteriores)"
+
+#: gitk:1366
+msgid "<Delete>, b\tScroll diff view up one page"
+msgstr "<Delete>, b\tDesplaza hacia arriba una página la vista de diferencias"
+
+#: gitk:1367
+msgid "<Backspace>\tScroll diff view up one page"
+msgstr "<Backspace>\tDesplaza hacia arriba una página la vista de diferencias"
+
+#: gitk:1368
+msgid "<Space>\t\tScroll diff view down one page"
+msgstr "<Space>\t\tDesplaza hacia abajo una página la vista de diferencias"
+
+#: gitk:1369
+msgid "u\t\tScroll diff view up 18 lines"
+msgstr "u\t\tDesplaza hacia arriba 18 líneas la vista de diferencias"
+
+#: gitk:1370
+msgid "d\t\tScroll diff view down 18 lines"
+msgstr "d\t\tDesplaza hacia abajo 18 líneas la vista de diferencias"
+
+#: gitk:1371
+#, tcl-format
+msgid "<%s-F>\t\tFind"
+msgstr "<%s-F>\t\tBuscar"
+
+#: gitk:1372
+#, tcl-format
+msgid "<%s-G>\t\tMove to next find hit"
+msgstr "<%s-G>\t\tBuscar el siguiente"
+
+#: gitk:1373
+msgid "<Return>\tMove to next find hit"
+msgstr "<Return>\tBuscar el siguiente"
+
+#: gitk:1374
+msgid "/\t\tMove to next find hit, or redo find"
+msgstr "/\t\tBuscar el siguiente, o reiniciar la búsqueda"
+
+#: gitk:1375
+msgid "?\t\tMove to previous find hit"
+msgstr "?\t\tBuscar el anterior"
+
+#: gitk:1376
+msgid "f\t\tScroll diff view to next file"
+msgstr "f\t\tDesplazar la vista de diferencias al archivo siguiente"
+
+#: gitk:1377
+#, tcl-format
+msgid "<%s-S>\t\tSearch for next hit in diff view"
+msgstr "<%s-S>\t\tBuscar siguiente en la vista de diferencias"
+
+#: gitk:1378
+#, tcl-format
+msgid "<%s-R>\t\tSearch for previous hit in diff view"
+msgstr "<%s-R>\t\tBuscar anterior en la vista de diferencias"
+
+#: gitk:1379
+#, tcl-format
+msgid "<%s-KP+>\tIncrease font size"
+msgstr "<%s-KP+>\tAumentar tamaño del texto"
+
+#: gitk:1380
+#, tcl-format
+msgid "<%s-plus>\tIncrease font size"
+msgstr "<%s-plus>\tAumentar tamaño del texto"
+
+#: gitk:1381
+#, tcl-format
+msgid "<%s-KP->\tDecrease font size"
+msgstr "<%s-KP->\tDisminuir tamaño del texto"
+
+#: gitk:1382
+#, tcl-format
+msgid "<%s-minus>\tDecrease font size"
+msgstr "<%s-minus>\tDisminuir tamaño del texto"
+
+#: gitk:1383
+msgid "<F5>\t\tUpdate"
+msgstr "<F5>\t\tActualizar"
+
+#: gitk:1896
+msgid "Gitk view definition"
+msgstr "Definición de vistas de Gitk"
+
+#: gitk:1921
+msgid "Name"
+msgstr "Nombre"
+
+#: gitk:1924
+msgid "Remember this view"
+msgstr "Recordar esta vista"
+
+#: gitk:1928
+msgid "Commits to include (arguments to git rev-list):"
+msgstr "Revisiones a incluir (argumentos a git rev-list):"
+
+#: gitk:1935
+msgid "Command to generate more commits to include:"
+msgstr "Comando que genera más revisiones a incluir:"
+
+#: gitk:1942
+msgid "Enter files and directories to include, one per line:"
+msgstr "Introducir archivos y directorios a incluir, uno por línea:"
+
+#: gitk:1989
+msgid "Error in commit selection arguments:"
+msgstr "Error en los argumentos de selección de las revisiones:"
+
+#: gitk:2043 gitk:2127 gitk:2583 gitk:2597 gitk:3781 gitk:8688 gitk:8689
+msgid "None"
+msgstr "Ninguno"
+
+#: gitk:2531 gitk:4336 gitk:5958 gitk:5973
+msgid "Date"
+msgstr "Fecha"
+
+#: gitk:2531 gitk:4336
+msgid "CDate"
+msgstr "Fecha de creación"
+
+#: gitk:2680 gitk:2685
+msgid "Descendant"
+msgstr "Descendiente"
+
+#: gitk:2681
+msgid "Not descendant"
+msgstr "No descendiente"
+
+#: gitk:2688 gitk:2693
+msgid "Ancestor"
+msgstr "Antepasado"
+
+#: gitk:2689
+msgid "Not ancestor"
+msgstr "No antepasado"
+
+#: gitk:2924
+msgid "Local changes checked in to index but not committed"
+msgstr "Cambios locales añadidos al índice pero sin completar revisión"
+
+#: gitk:2954
+msgid "Local uncommitted changes, not checked in to index"
+msgstr "Cambios locales sin añadir al índice"
+
+#: gitk:4305
+msgid "Searching"
+msgstr "Buscando"
+
+#: gitk:4767
+msgid "Tags:"
+msgstr "Etiquetas:"
+
+#: gitk:4784 gitk:4790 gitk:5951
+msgid "Parent"
+msgstr "Padre"
+
+#: gitk:4795
+msgid "Child"
+msgstr "Hija"
+
+#: gitk:4804
+msgid "Branch"
+msgstr "Rama"
+
+#: gitk:4807
+msgid "Follows"
+msgstr "Sigue-a"
+
+#: gitk:4810
+msgid "Precedes"
+msgstr "Precede-a"
+
+#: gitk:5093
+msgid "Error getting merge diffs:"
+msgstr "Error al leer las diferencias de fusión:"
+
+#: gitk:5778
+msgid "Goto:"
+msgstr "Ir a:"
+
+#: gitk:5780
+msgid "SHA1 ID:"
+msgstr "SHA1 ID:"
+
+#: gitk:5805
+#, tcl-format
+msgid "Short SHA1 id %s is ambiguous"
+msgstr "La id SHA1 abreviada %s es ambigua"
+
+#: gitk:5817
+#, tcl-format
+msgid "SHA1 id %s is not known"
+msgstr "La id SHA1 %s es desconocida"
+
+#: gitk:5819
+#, tcl-format
+msgid "Tag/Head %s is not known"
+msgstr "La etiqueta/rama %s es deconocida"
+
+#: gitk:5961
+msgid "Children"
+msgstr "Hijas"
+
+#: gitk:6018
+#, tcl-format
+msgid "Reset %s branch to here"
+msgstr "Poner la rama %s en esta revisión"
+
+#: gitk:6049
+msgid "Top"
+msgstr "Origen"
+
+#: gitk:6050
+msgid "From"
+msgstr "De"
+
+#: gitk:6055
+msgid "To"
+msgstr "A"
+
+#: gitk:6078
+msgid "Generate patch"
+msgstr "Generar parche"
+
+#: gitk:6080
+msgid "From:"
+msgstr "De:"
+
+#: gitk:6089
+msgid "To:"
+msgstr "Para:"
+
+#: gitk:6098
+msgid "Reverse"
+msgstr "Invertir"
+
+#: gitk:6100 gitk:6269
+msgid "Output file:"
+msgstr "Escribir a archivo:"
+
+#: gitk:6106
+msgid "Generate"
+msgstr "Generar"
+
+#: gitk:6142
+msgid "Error creating patch:"
+msgstr "Error en la creación del parche:"
+
+#: gitk:6164 gitk:6257 gitk:6311
+msgid "ID:"
+msgstr "ID:"
+
+#: gitk:6173
+msgid "Tag name:"
+msgstr "Nombre de etiqueta:"
+
+#: gitk:6177 gitk:6320
+msgid "Create"
+msgstr "Crear"
+
+#: gitk:6192
+msgid "No tag name specified"
+msgstr "No se ha especificado etiqueta"
+
+#: gitk:6196
+#, tcl-format
+msgid "Tag \"%s\" already exists"
+msgstr "La etiqueta \"%s\" ya existe"
+
+#: gitk:6202
+msgid "Error creating tag:"
+msgstr "Error al crear la etiqueta:"
+
+#: gitk:6266
+msgid "Command:"
+msgstr "Comando:"
+
+#: gitk:6274
+msgid "Write"
+msgstr "Escribir"
+
+#: gitk:6290
+msgid "Error writing commit:"
+msgstr "Error al escribir revisión:"
+
+#: gitk:6316
+msgid "Name:"
+msgstr "Nombre:"
+
+#: gitk:6335
+msgid "Please specify a name for the new branch"
+msgstr "Especifique un nombre para la nueva rama"
+
+#: gitk:6364
+#, tcl-format
+msgid "Commit %s is already included in branch %s -- really re-apply it?"
+msgstr "La revisión %s ya está incluida en la rama %s -- ¿Volver a aplicarla?"
+
+#: gitk:6369
+msgid "Cherry-picking"
+msgstr "Eligiendo revisiones (cherry-picking)"
+
+#: gitk:6381
+msgid "No changes committed"
+msgstr "No se han guardado cambios"
+
+#: gitk:6404
+msgid "Confirm reset"
+msgstr "Confirmar git reset"
+
+#: gitk:6406
+#, tcl-format
+msgid "Reset branch %s to %s?"
+msgstr "¿Reponer la rama %s a %s?"
+
+#: gitk:6410
+msgid "Reset type:"
+msgstr "Tipo de reposición:"
+
+#: gitk:6414
+msgid "Soft: Leave working tree and index untouched"
+msgstr "Suave: No altera la copia de trabajo ni el índice"
+
+#: gitk:6417
+msgid "Mixed: Leave working tree untouched, reset index"
+msgstr "Mixta: Actualiza el índice, no altera la copia de trabajo"
+
+#: gitk:6420
+msgid ""
+"Hard: Reset working tree and index\n"
+"(discard ALL local changes)"
+msgstr ""
+"Dura: Actualiza el índice y la copia de trabajo\n"
+"(abandona TODAS las modificaciones locales)"
+
+#: gitk:6436
+msgid "Resetting"
+msgstr "Reponiendo"
+
+#: gitk:6493
+msgid "Checking out"
+msgstr "Creando copia de trabajo"
+
+#: gitk:6523
+msgid "Cannot delete the currently checked-out branch"
+msgstr "No se puede borrar la rama actual"
+
+#: gitk:6529
+#, tcl-format
+msgid ""
+"The commits on branch %s aren't on any other branch.\n"
+"Really delete branch %s?"
+msgstr ""
+"Las revisiones de la rama %s no están presentes en otras ramas.\n"
+"¿Borrar la rama %s?"
+
+#: gitk:6560
+#, tcl-format
+msgid "Tags and heads: %s"
+msgstr "Etiquetas y ramas: %s"
+
+#: gitk:6574
+msgid "Filter"
+msgstr "Filtro"
+
+#: gitk:6868
+msgid ""
+"Error reading commit topology information; branch and preceding/following "
+"tag information will be incomplete."
+msgstr ""
+"Error al leer la topología de revisiones: la información sobre "
+"las ramas y etiquetas precedentes y siguientes será incompleta."
+
+#: gitk:7852
+msgid "Tag"
+msgstr "Etiqueta"
+
+#: gitk:7852
+msgid "Id"
+msgstr "Id"
+
+#: gitk:7892
+msgid "Gitk font chooser"
+msgstr "Selector de tipografías gitk"
+
+#: gitk:7909
+msgid "B"
+msgstr "B"
+
+#: gitk:7912
+msgid "I"
+msgstr "I"
+
+#: gitk:8005
+msgid "Gitk preferences"
+msgstr "Preferencias de gitk"
+
+#: gitk:8006
+msgid "Commit list display options"
+msgstr "Opciones de visualización de la lista de revisiones"
+
+#: gitk:8009
+msgid "Maximum graph width (lines)"
+msgstr "Ancho máximo del gráfico (en líneas)"
+
+#: gitk:8013
+#, tcl-format
+msgid "Maximum graph width (% of pane)"
+msgstr "Ancho máximo del gráfico (en % del panel)"
+
+#: gitk:8018
+msgid "Show local changes"
+msgstr "Mostrar cambios locales"
+
+#: gitk:8023
+msgid "Auto-select SHA1"
+msgstr "Seleccionar automáticamente SHA1 hash"
+
+#: gitk:8028
+msgid "Diff display options"
+msgstr "Opciones de visualización de diferencias"
+
+#: gitk:8030
+msgid "Tab spacing"
+msgstr "Espaciado de tabulador"
+
+#: gitk:8034
+msgid "Display nearby tags"
+msgstr "Mostrar etiquetas cercanas"
+
+#: gitk:8039
+msgid "Limit diffs to listed paths"
+msgstr "Limitar las diferencias a las rutas seleccionadas"
+
+#: gitk:8044
+msgid "Colors: press to choose"
+msgstr "Colores: pulse para seleccionar"
+
+#: gitk:8047
+msgid "Background"
+msgstr "Fondo"
+
+#: gitk:8051
+msgid "Foreground"
+msgstr "Primer plano"
+
+#: gitk:8055
+msgid "Diff: old lines"
+msgstr "Diff: líneas viejas"
+
+#: gitk:8060
+msgid "Diff: new lines"
+msgstr "Diff: líneas nuevas"
+
+#: gitk:8065
+msgid "Diff: hunk header"
+msgstr "Diff: cabecera de fragmento"
+
+#: gitk:8071
+msgid "Select bg"
+msgstr "Color de fondo de la selección"
+
+#: gitk:8075
+msgid "Fonts: press to choose"
+msgstr "Tipografías: pulse para elegir"
+
+#: gitk:8077
+msgid "Main font"
+msgstr "Tipografía principal"
+
+#: gitk:8078
+msgid "Diff display font"
+msgstr "Tipografía para diferencias"
+
+#: gitk:8079
+msgid "User interface font"
+msgstr "Tipografía para interfaz de usuario"
+
+#: gitk:8095
+#, tcl-format
+msgid "Gitk: choose color for %s"
+msgstr "Gitk: elegir color para %s"
+
+#: gitk:8476
+msgid ""
+"Sorry, gitk cannot run with this version of Tcl/Tk.\n"
+" Gitk requires at least Tcl/Tk 8.4."
+msgstr ""
+"Esta versión de Tcl/Tk es demasiado antigua.\n"
+" Gitk requiere Tcl/Tk versión 8.4 o superior."
+
+#: gitk:8565
+msgid "Cannot find a git repository here."
+msgstr "No hay un repositorio git aquí."
+
+#: gitk:8569
+#, tcl-format
+msgid "Cannot find the git directory \"%s\"."
+msgstr "No hay directorio git \"%s\"."
+
+#: gitk:8612
+#, tcl-format
+msgid "Ambiguous argument '%s': both revision and filename"
+msgstr "Argumento ambiguo: '%s' es tanto una revisión como un nombre de archivo"
+
+#: gitk:8624
+msgid "Bad arguments to gitk:"
+msgstr "Argumentos incorrectos a Gitk:"
+
+#: gitk:8636
+msgid "Couldn't get list of unmerged files:"
+msgstr "Imposible obtener la lista de archivos pendientes de fusión:"
+
+#: gitk:8652
+msgid "No files selected: --merge specified but no files are unmerged."
+msgstr ""
+"No hay archivos seleccionados: se seleccionó la opción --merge pero no hay "
+"archivos pendientes de fusión."
+
+#: gitk:8655
+msgid ""
+"No files selected: --merge specified but no unmerged files are within file "
+"limit."
+msgstr ""
+"No hay archivos seleccionados: se seleccionó la opción --merge pero los archivos "
+"especificados no necesitan fusión."
+
+#: gitk:8716
+msgid "Command line"
+msgstr "Línea de comandos"
diff --git a/gitk-git/po/it.po b/gitk-git/po/it.po
new file mode 100644
index 000000000..d0f4c2e19
--- /dev/null
+++ b/gitk-git/po/it.po
@@ -0,0 +1,890 @@
+# Translation of gitk
+# Copyright (C) 2005-2008 Paul Mackerras
+# This file is distributed under the same license as the gitk package.
+# Michele Ballabio <barra_cuda@katamail.com>, 2008.
+#
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: gitk\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-03-13 17:29+0100\n"
+"PO-Revision-Date: 2008-03-13 17:34+0100\n"
+"Last-Translator: Michele Ballabio <barra_cuda@katamail.com>\n"
+"Language-Team: Italian\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gitk:111
+msgid "Error executing git rev-list:"
+msgstr "Errore nell'esecuzione di git rev-list:"
+
+#: gitk:124
+msgid "Reading"
+msgstr "Lettura in corso"
+
+#: gitk:151 gitk:2191
+msgid "Reading commits..."
+msgstr "Lettura delle revisioni in corso..."
+
+#: gitk:275
+msgid "Can't parse git log output:"
+msgstr "Impossibile elaborare i dati di git log:"
+
+#: gitk:386 gitk:2195
+msgid "No commits selected"
+msgstr "Nessuna revisione selezionata"
+
+#: gitk:500
+msgid "No commit information available"
+msgstr "Nessuna informazione disponibile sulle revisioni"
+
+#: gitk:599 gitk:621 gitk:1955 gitk:6423 gitk:7923 gitk:8082
+msgid "OK"
+msgstr "OK"
+
+#: gitk:623 gitk:1956 gitk:6107 gitk:6178 gitk:6275 gitk:6321 gitk:6425
+#: gitk:7924 gitk:8083
+msgid "Cancel"
+msgstr "Annulla"
+
+#: gitk:661
+msgid "File"
+msgstr "File"
+
+#: gitk:663
+msgid "Update"
+msgstr "Aggiorna"
+
+#: gitk:664
+msgid "Reread references"
+msgstr "Rileggi riferimenti"
+
+#: gitk:665
+msgid "List references"
+msgstr "Elenca riferimenti"
+
+#: gitk:666
+msgid "Quit"
+msgstr "Esci"
+
+#: gitk:668
+msgid "Edit"
+msgstr "Modifica"
+
+#: gitk:669
+msgid "Preferences"
+msgstr "Preferenze"
+
+#: gitk:672 gitk:1892
+msgid "View"
+msgstr "Vista"
+
+#: gitk:673
+msgid "New view..."
+msgstr "Nuova vista..."
+
+#: gitk:674 gitk:2133 gitk:8722
+msgid "Edit view..."
+msgstr "Modifica vista..."
+
+#: gitk:676 gitk:2134 gitk:8723
+msgid "Delete view"
+msgstr "Elimina vista"
+
+#: gitk:678
+msgid "All files"
+msgstr "Tutti i file"
+
+#: gitk:682
+msgid "Help"
+msgstr "Aiuto"
+
+#: gitk:683 gitk:1317
+msgid "About gitk"
+msgstr "Informazioni su gitk"
+
+#: gitk:684
+msgid "Key bindings"
+msgstr "Scorciatoie da tastiera"
+
+#: gitk:741
+msgid "SHA1 ID: "
+msgstr "SHA1 ID: "
+
+#: gitk:791
+msgid "Find"
+msgstr "Trova"
+
+#: gitk:792
+msgid "next"
+msgstr "succ"
+
+#: gitk:793
+msgid "prev"
+msgstr "prec"
+
+#: gitk:794
+msgid "commit"
+msgstr "revisione"
+
+#: gitk:797 gitk:799 gitk:2356 gitk:2379 gitk:2403 gitk:4306 gitk:4369
+msgid "containing:"
+msgstr "contenente:"
+
+#: gitk:800 gitk:1778 gitk:1783 gitk:2431
+msgid "touching paths:"
+msgstr "che riguarda i percorsi:"
+
+#: gitk:801 gitk:2436
+msgid "adding/removing string:"
+msgstr "che aggiunge/rimuove la stringa:"
+
+#: gitk:810 gitk:812
+msgid "Exact"
+msgstr "Esatto"
+
+#: gitk:812 gitk:2514 gitk:4274
+msgid "IgnCase"
+msgstr ""
+
+#: gitk:812 gitk:2405 gitk:2512 gitk:4270
+msgid "Regexp"
+msgstr ""
+
+#: gitk:814 gitk:815 gitk:2533 gitk:2563 gitk:2570 gitk:4380 gitk:4436
+msgid "All fields"
+msgstr "Tutti i campi"
+
+#: gitk:815 gitk:2531 gitk:2563 gitk:4336
+msgid "Headline"
+msgstr "Titolo"
+
+#: gitk:816 gitk:2531 gitk:4336 gitk:4436 gitk:4827
+msgid "Comments"
+msgstr "Commenti"
+
+#: gitk:816 gitk:2531 gitk:2535 gitk:2570 gitk:4336 gitk:4763 gitk:5956
+#: gitk:5971
+msgid "Author"
+msgstr "Autore"
+
+#: gitk:816 gitk:2531 gitk:4336 gitk:4765
+msgid "Committer"
+msgstr "Revisione creata da"
+
+#: gitk:845
+msgid "Search"
+msgstr "Cerca"
+
+#: gitk:852
+msgid "Diff"
+msgstr ""
+
+#: gitk:854
+msgid "Old version"
+msgstr "Vecchia versione"
+
+#: gitk:856
+msgid "New version"
+msgstr "Nuova versione"
+
+#: gitk:858
+msgid "Lines of context"
+msgstr "Linee di contesto"
+
+#: gitk:868
+msgid "Ignore space change"
+msgstr "Ignora modifiche agli spazi"
+
+#: gitk:926
+msgid "Patch"
+msgstr "Modifiche"
+
+#: gitk:928
+msgid "Tree"
+msgstr "Directory"
+
+#: gitk:1053 gitk:1068 gitk:6022
+msgid "Diff this -> selected"
+msgstr "Diff questo -> selezionato"
+
+#: gitk:1055 gitk:1070 gitk:6023
+msgid "Diff selected -> this"
+msgstr "Diff selezionato -> questo"
+
+#: gitk:1057 gitk:1072 gitk:6024
+msgid "Make patch"
+msgstr "Crea patch"
+
+#: gitk:1058 gitk:6162
+msgid "Create tag"
+msgstr "Crea etichetta"
+
+#: gitk:1059 gitk:6255
+msgid "Write commit to file"
+msgstr "Scrivi revisione in un file"
+
+#: gitk:1060 gitk:6309
+msgid "Create new branch"
+msgstr "Crea un nuovo ramo"
+
+#: gitk:1061
+msgid "Cherry-pick this commit"
+msgstr "Porta questa revisione in cima al ramo attuale"
+
+#: gitk:1063
+msgid "Reset HEAD branch to here"
+msgstr "Aggiorna il ramo HEAD a questa revisione"
+
+#: gitk:1079
+msgid "Check out this branch"
+msgstr "Attiva questo ramo"
+
+#: gitk:1081
+msgid "Remove this branch"
+msgstr "Elimina questo ramo"
+
+#: gitk:1087
+msgid "Highlight this too"
+msgstr "Evidenzia anche questo"
+
+#: gitk:1089
+msgid "Highlight this only"
+msgstr "Evidenzia solo questo"
+
+#: gitk:1318
+msgid ""
+"\n"
+"Gitk - a commit viewer for git\n"
+"\n"
+"Copyright © 2005-2006 Paul Mackerras\n"
+"\n"
+"Use and redistribute under the terms of the GNU General Public License"
+msgstr ""
+"\n"
+"Gitk - un visualizzatore di revisioni per git\n"
+"\n"
+"Copyright © 2005-2006 Paul Mackerras\n"
+"\n"
+"Utilizzo e redistribuzione permessi sotto i termini della GNU General Public "
+"License"
+
+#: gitk:1326 gitk:1387 gitk:6581
+msgid "Close"
+msgstr "Chiudi"
+
+#: gitk:1345
+msgid "Gitk key bindings"
+msgstr "Scorciatoie da tastiera di Gitk"
+
+#: gitk:1347
+msgid "Gitk key bindings:"
+msgstr "Scorciatoie da tastiera di Gitk:"
+
+#: gitk:1349
+#, tcl-format
+msgid "<%s-Q>\t\tQuit"
+msgstr "<%s-Q>\t\tEsci"
+
+#: gitk:1350
+msgid "<Home>\t\tMove to first commit"
+msgstr "<Home>\t\tVai alla prima revisione"
+
+#: gitk:1351
+msgid "<End>\t\tMove to last commit"
+msgstr "<End>\t\tVai all'ultima revisione"
+
+#: gitk:1352
+msgid "<Up>, p, i\tMove up one commit"
+msgstr "<Up>, p, i\tVai più in alto di una revisione"
+
+#: gitk:1353
+msgid "<Down>, n, k\tMove down one commit"
+msgstr "<Down>, n, k\tVai più in basso di una revisione"
+
+#: gitk:1354
+msgid "<Left>, z, j\tGo back in history list"
+msgstr "<Left>, z, j\tTorna indietro nella cronologia"
+
+#: gitk:1355
+msgid "<Right>, x, l\tGo forward in history list"
+msgstr "<Right>, x, l\tVai avanti nella cronologia"
+
+#: gitk:1356
+msgid "<PageUp>\tMove up one page in commit list"
+msgstr "<PageUp>\tVai più in alto di una pagina nella lista delle revisioni"
+
+#: gitk:1357
+msgid "<PageDown>\tMove down one page in commit list"
+msgstr "<PageDown>\tVai più in basso di una pagina nella lista delle revisioni"
+
+#: gitk:1358
+#, tcl-format
+msgid "<%s-Home>\tScroll to top of commit list"
+msgstr "<%s-Home>\tScorri alla cima della lista delle revisioni"
+
+#: gitk:1359
+#, tcl-format
+msgid "<%s-End>\tScroll to bottom of commit list"
+msgstr "<%s-End>\tScorri alla fine della lista delle revisioni"
+
+#: gitk:1360
+#, tcl-format
+msgid "<%s-Up>\tScroll commit list up one line"
+msgstr "<%s-Up>\tScorri la lista delle revisioni in alto di una riga"
+
+#: gitk:1361
+#, tcl-format
+msgid "<%s-Down>\tScroll commit list down one line"
+msgstr "<%s-Down>\tScorri la lista delle revisioni in basso di una riga"
+
+#: gitk:1362
+#, tcl-format
+msgid "<%s-PageUp>\tScroll commit list up one page"
+msgstr "<%s-PageUp>\tScorri la lista delle revisioni in alto di una pagina"
+
+#: gitk:1363
+#, tcl-format
+msgid "<%s-PageDown>\tScroll commit list down one page"
+msgstr "<%s-PageDown>\tScorri la lista delle revisioni in basso di una pagina"
+
+#: gitk:1364
+msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
+msgstr "<Shift-Up>\tTrova all'indietro (verso l'alto, revisioni successive)"
+
+#: gitk:1365
+msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
+msgstr "<Shift-Down>\tTrova in avanti (verso il basso, revisioni precedenti)"
+
+#: gitk:1366
+msgid "<Delete>, b\tScroll diff view up one page"
+msgstr "<Delete>, b\tScorri la vista delle differenze in alto di una pagina"
+
+#: gitk:1367
+msgid "<Backspace>\tScroll diff view up one page"
+msgstr "<Backspace>\tScorri la vista delle differenze in alto di una pagina"
+
+#: gitk:1368
+msgid "<Space>\t\tScroll diff view down one page"
+msgstr "<Space>\t\tScorri la vista delle differenze in basso di una pagina"
+
+#: gitk:1369
+msgid "u\t\tScroll diff view up 18 lines"
+msgstr "u\t\tScorri la vista delle differenze in alto di 18 linee"
+
+#: gitk:1370
+msgid "d\t\tScroll diff view down 18 lines"
+msgstr "d\t\tScorri la vista delle differenze in basso di 18 linee"
+
+#: gitk:1371
+#, tcl-format
+msgid "<%s-F>\t\tFind"
+msgstr "<%s-F>\t\tTrova"
+
+#: gitk:1372
+#, tcl-format
+msgid "<%s-G>\t\tMove to next find hit"
+msgstr "<%s-G>\t\tTrova in avanti"
+
+#: gitk:1373
+msgid "<Return>\tMove to next find hit"
+msgstr "<Return>\tTrova in avanti"
+
+#: gitk:1374
+msgid "/\t\tMove to next find hit, or redo find"
+msgstr "/\t\tTrova in avanti, o cerca di nuovo"
+
+#: gitk:1375
+msgid "?\t\tMove to previous find hit"
+msgstr "?\t\tTrova all'indietro"
+
+#: gitk:1376
+msgid "f\t\tScroll diff view to next file"
+msgstr "f\t\tScorri la vista delle differenze al file successivo"
+
+#: gitk:1377
+#, tcl-format
+msgid "<%s-S>\t\tSearch for next hit in diff view"
+msgstr "<%s-S>\t\tCerca in avanti nella vista delle differenze"
+
+#: gitk:1378
+#, tcl-format
+msgid "<%s-R>\t\tSearch for previous hit in diff view"
+msgstr "<%s-R>\t\tCerca all'indietro nella vista delle differenze"
+
+#: gitk:1379
+#, tcl-format
+msgid "<%s-KP+>\tIncrease font size"
+msgstr "<%s-KP+>\tAumenta grandezza carattere"
+
+#: gitk:1380
+#, tcl-format
+msgid "<%s-plus>\tIncrease font size"
+msgstr "<%s-plus>\tAumenta grandezza carattere"
+
+#: gitk:1381
+#, tcl-format
+msgid "<%s-KP->\tDecrease font size"
+msgstr "<%s-KP->\tDiminuisci grandezza carattere"
+
+#: gitk:1382
+#, tcl-format
+msgid "<%s-minus>\tDecrease font size"
+msgstr "<%s-minus>\tDiminuisci grandezza carattere"
+
+#: gitk:1383
+msgid "<F5>\t\tUpdate"
+msgstr "<F5>\t\tAggiorna"
+
+#: gitk:1896
+msgid "Gitk view definition"
+msgstr "Scelta vista Gitk"
+
+#: gitk:1921
+msgid "Name"
+msgstr "Nome"
+
+#: gitk:1924
+msgid "Remember this view"
+msgstr "Ricorda questa vista"
+
+#: gitk:1928
+msgid "Commits to include (arguments to git rev-list):"
+msgstr "Revisioni da includere (argomenti di git rev-list):"
+
+#: gitk:1935
+msgid "Command to generate more commits to include:"
+msgstr "Comando che genera altre revisioni da visualizzare:"
+
+#: gitk:1942
+msgid "Enter files and directories to include, one per line:"
+msgstr "Inserire file e directory da includere, uno per riga:"
+
+#: gitk:1989
+msgid "Error in commit selection arguments:"
+msgstr "Errore negli argomenti di selezione delle revisioni:"
+
+#: gitk:2043 gitk:2127 gitk:2583 gitk:2597 gitk:3781 gitk:8688 gitk:8689
+msgid "None"
+msgstr "Nessuno"
+
+#: gitk:2531 gitk:4336 gitk:5958 gitk:5973
+msgid "Date"
+msgstr "Data"
+
+#: gitk:2531 gitk:4336
+msgid "CDate"
+msgstr ""
+
+#: gitk:2680 gitk:2685
+msgid "Descendant"
+msgstr "Discendente"
+
+#: gitk:2681
+msgid "Not descendant"
+msgstr "Non discendente"
+
+#: gitk:2688 gitk:2693
+msgid "Ancestor"
+msgstr "Ascendente"
+
+#: gitk:2689
+msgid "Not ancestor"
+msgstr "Non ascendente"
+
+#: gitk:2924
+msgid "Local changes checked in to index but not committed"
+msgstr "Modifiche locali presenti nell'indice ma non nell'archivio"
+
+#: gitk:2954
+msgid "Local uncommitted changes, not checked in to index"
+msgstr "Modifiche locali non presenti né nell'archivio né nell'indice"
+
+#: gitk:4305
+msgid "Searching"
+msgstr "Ricerca in corso"
+
+#: gitk:4767
+msgid "Tags:"
+msgstr "Etichette:"
+
+#: gitk:4784 gitk:4790 gitk:5951
+msgid "Parent"
+msgstr "Genitore"
+
+#: gitk:4795
+msgid "Child"
+msgstr "Figlio"
+
+#: gitk:4804
+msgid "Branch"
+msgstr "Ramo"
+
+#: gitk:4807
+msgid "Follows"
+msgstr "Segue"
+
+#: gitk:4810
+msgid "Precedes"
+msgstr "Precede"
+
+#: gitk:5093
+msgid "Error getting merge diffs:"
+msgstr "Errore nella lettura delle differenze di fusione:"
+
+#: gitk:5778
+msgid "Goto:"
+msgstr "Vai a:"
+
+#: gitk:5780
+msgid "SHA1 ID:"
+msgstr "SHA1 ID:"
+
+#: gitk:5805
+#, tcl-format
+msgid "Short SHA1 id %s is ambiguous"
+msgstr "La SHA1 id abbreviata %s è ambigua"
+
+#: gitk:5817
+#, tcl-format
+msgid "SHA1 id %s is not known"
+msgstr "La SHA1 id %s è sconosciuta"
+
+#: gitk:5819
+#, tcl-format
+msgid "Tag/Head %s is not known"
+msgstr "L'etichetta/ramo %s è sconosciuto"
+
+#: gitk:5961
+msgid "Children"
+msgstr "Figli"
+
+#: gitk:6018
+#, tcl-format
+msgid "Reset %s branch to here"
+msgstr "Aggiorna il ramo %s a questa revisione"
+
+#: gitk:6049
+msgid "Top"
+msgstr "Inizio"
+
+#: gitk:6050
+msgid "From"
+msgstr "Da"
+
+#: gitk:6055
+msgid "To"
+msgstr "A"
+
+#: gitk:6078
+msgid "Generate patch"
+msgstr "Genera patch"
+
+#: gitk:6080
+msgid "From:"
+msgstr "Da:"
+
+#: gitk:6089
+msgid "To:"
+msgstr "A:"
+
+#: gitk:6098
+msgid "Reverse"
+msgstr "Inverti"
+
+#: gitk:6100 gitk:6269
+msgid "Output file:"
+msgstr "Scrivi sul file:"
+
+#: gitk:6106
+msgid "Generate"
+msgstr "Genera"
+
+#: gitk:6142
+msgid "Error creating patch:"
+msgstr "Errore nella creazione della patch:"
+
+#: gitk:6164 gitk:6257 gitk:6311
+msgid "ID:"
+msgstr "ID:"
+
+#: gitk:6173
+msgid "Tag name:"
+msgstr "Nome etichetta:"
+
+#: gitk:6177 gitk:6320
+msgid "Create"
+msgstr "Crea"
+
+#: gitk:6192
+msgid "No tag name specified"
+msgstr "Nessuna etichetta specificata"
+
+#: gitk:6196
+#, tcl-format
+msgid "Tag \"%s\" already exists"
+msgstr "L'etichetta \"%s\" esiste già"
+
+#: gitk:6202
+msgid "Error creating tag:"
+msgstr "Errore nella creazione dell'etichetta:"
+
+#: gitk:6266
+msgid "Command:"
+msgstr "Comando:"
+
+#: gitk:6274
+msgid "Write"
+msgstr "Scrivi"
+
+#: gitk:6290
+msgid "Error writing commit:"
+msgstr "Errore nella scrittura della revisione:"
+
+#: gitk:6316
+msgid "Name:"
+msgstr "Nome:"
+
+#: gitk:6335
+msgid "Please specify a name for the new branch"
+msgstr "Specificare un nome per il nuovo ramo"
+
+#: gitk:6364
+#, tcl-format
+msgid "Commit %s is already included in branch %s -- really re-apply it?"
+msgstr "La revisione %s è già inclusa nel ramo %s -- applicarla di nuovo?"
+
+#: gitk:6369
+msgid "Cherry-picking"
+msgstr ""
+
+#: gitk:6381
+msgid "No changes committed"
+msgstr "Nessuna modifica archiviata"
+
+#: gitk:6404
+msgid "Confirm reset"
+msgstr "Conferma git reset"
+
+#: gitk:6406
+#, tcl-format
+msgid "Reset branch %s to %s?"
+msgstr "Aggiornare il ramo %s a %s?"
+
+#: gitk:6410
+msgid "Reset type:"
+msgstr "Tipo di aggiornamento:"
+
+#: gitk:6414
+msgid "Soft: Leave working tree and index untouched"
+msgstr "Soft: Lascia la direcory di lavoro e l'indice come sono"
+
+#: gitk:6417
+msgid "Mixed: Leave working tree untouched, reset index"
+msgstr "Mixed: Lascia la directory di lavoro come è, aggiorna l'indice"
+
+#: gitk:6420
+msgid ""
+"Hard: Reset working tree and index\n"
+"(discard ALL local changes)"
+msgstr ""
+"Hard: Aggiorna la directory di lavoro e l'indice\n"
+"(abbandona TUTTE le modifiche locali)"
+
+#: gitk:6436
+msgid "Resetting"
+msgstr "git reset in corso"
+
+#: gitk:6493
+msgid "Checking out"
+msgstr "Attivazione in corso"
+
+#: gitk:6523
+msgid "Cannot delete the currently checked-out branch"
+msgstr "Impossibile cancellare il ramo attualmente attivo"
+
+#: gitk:6529
+#, tcl-format
+msgid ""
+"The commits on branch %s aren't on any other branch.\n"
+"Really delete branch %s?"
+msgstr ""
+"Le revisioni nel ramo %s non sono presenti su altri rami.\n"
+"Cancellare il ramo %s?"
+
+#: gitk:6560
+#, tcl-format
+msgid "Tags and heads: %s"
+msgstr "Etichette e rami: %s"
+
+#: gitk:6574
+msgid "Filter"
+msgstr "Filtro"
+
+#: gitk:6868
+msgid ""
+"Error reading commit topology information; branch and preceding/following "
+"tag information will be incomplete."
+msgstr ""
+"Errore nella lettura della topologia delle revisioni: le informazioni sul "
+"ramo e le etichette precedenti e seguenti saranno incomplete."
+
+#: gitk:7852
+msgid "Tag"
+msgstr "Etichetta"
+
+#: gitk:7852
+msgid "Id"
+msgstr "Id"
+
+#: gitk:7892
+msgid "Gitk font chooser"
+msgstr "Scelta caratteri gitk"
+
+#: gitk:7909
+msgid "B"
+msgstr "B"
+
+#: gitk:7912
+msgid "I"
+msgstr "I"
+
+#: gitk:8005
+msgid "Gitk preferences"
+msgstr "Preferenze gitk"
+
+#: gitk:8006
+msgid "Commit list display options"
+msgstr "Opzioni visualizzazione dell'elenco revisioni"
+
+#: gitk:8009
+msgid "Maximum graph width (lines)"
+msgstr "Larghezza massima del grafico (in linee)"
+
+#: gitk:8013
+#, tcl-format
+msgid "Maximum graph width (% of pane)"
+msgstr "Larghezza massima del grafico (% del pannello)"
+
+#: gitk:8018
+msgid "Show local changes"
+msgstr "Mostra modifiche locali"
+
+#: gitk:8023
+msgid "Auto-select SHA1"
+msgstr "Seleziona automaticamente SHA1 hash"
+
+#: gitk:8028
+msgid "Diff display options"
+msgstr "Opzioni di visualizzazione delle differenze"
+
+#: gitk:8030
+msgid "Tab spacing"
+msgstr "Spaziatura tabulazioni"
+
+#: gitk:8034
+msgid "Display nearby tags"
+msgstr "Mostra etichette vicine"
+
+#: gitk:8039
+msgid "Limit diffs to listed paths"
+msgstr "Limita le differenze ai percorsi elencati"
+
+#: gitk:8044
+msgid "Colors: press to choose"
+msgstr "Colori: premere per scegliere"
+
+#: gitk:8047
+msgid "Background"
+msgstr "Sfondo"
+
+#: gitk:8051
+msgid "Foreground"
+msgstr "Primo piano"
+
+#: gitk:8055
+msgid "Diff: old lines"
+msgstr "Diff: vecchie linee"
+
+#: gitk:8060
+msgid "Diff: new lines"
+msgstr "Diff: nuove linee"
+
+#: gitk:8065
+msgid "Diff: hunk header"
+msgstr "Diff: intestazione della sezione"
+
+#: gitk:8071
+msgid "Select bg"
+msgstr "Sfondo selezione"
+
+#: gitk:8075
+msgid "Fonts: press to choose"
+msgstr "Carattere: premere per scegliere"
+
+#: gitk:8077
+msgid "Main font"
+msgstr "Carattere principale"
+
+#: gitk:8078
+msgid "Diff display font"
+msgstr "Carattere per differenze"
+
+#: gitk:8079
+msgid "User interface font"
+msgstr "Carattere per interfaccia utente"
+
+#: gitk:8095
+#, tcl-format
+msgid "Gitk: choose color for %s"
+msgstr "Gitk: scegliere un colore per %s"
+
+#: gitk:8476
+msgid ""
+"Sorry, gitk cannot run with this version of Tcl/Tk.\n"
+" Gitk requires at least Tcl/Tk 8.4."
+msgstr ""
+"Questa versione di Tcl/Tk non può avviare gitk.\n"
+" Gitk richiede Tcl/Tk versione 8.4 o superiore."
+
+#: gitk:8565
+msgid "Cannot find a git repository here."
+msgstr "Archivio git non trovato."
+
+#: gitk:8569
+#, tcl-format
+msgid "Cannot find the git directory \"%s\"."
+msgstr "Directory git \"%s\" non trovata."
+
+#: gitk:8612
+#, tcl-format
+msgid "Ambiguous argument '%s': both revision and filename"
+msgstr "Argomento ambiguo: '%s' è sia revisione che nome di file"
+
+#: gitk:8624
+msgid "Bad arguments to gitk:"
+msgstr "Gitk: argomenti errati:"
+
+#: gitk:8636
+msgid "Couldn't get list of unmerged files:"
+msgstr "Impossibile ottenere l'elenco dei file in attesa di fusione:"
+
+#: gitk:8652
+msgid "No files selected: --merge specified but no files are unmerged."
+msgstr ""
+"Nessun file selezionato: è stata specificata l'opzione --merge ma non ci "
+"sono file in attesa di fusione."
+
+#: gitk:8655
+msgid ""
+"No files selected: --merge specified but no unmerged files are within file "
+"limit."
+msgstr ""
+"Nessun file selezionato: è stata specificata l'opzione --merge ma i file "
+"specificati non sono in attesa di fusione."
+
+#: gitk:8716
+msgid "Command line"
+msgstr "Linea di comando"
diff --git a/gitk-git/po/sv.po b/gitk-git/po/sv.po
new file mode 100644
index 000000000..e1ecfb758
--- /dev/null
+++ b/gitk-git/po/sv.po
@@ -0,0 +1,915 @@
+# Swedish translation for gitk
+# Copyright (C) 2005-2008 Paul Mackerras
+# This file is distributed under the same license as the gitk package.
+#
+# Peter Karlsson <peter@softwolves.pp.se>, 2008.
+# Mikael Magnusson <mikachu@gmail.com>, 2008.
+msgid ""
+msgstr ""
+"Project-Id-Version: sv\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-08-03 18:58+0200\n"
+"PO-Revision-Date: 2008-08-03 19:03+0200\n"
+"Last-Translator: Mikael Magnusson <mikachu@gmail.com>\n"
+"Language-Team: Swedish <sv@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: gitk:102
+msgid "Couldn't get list of unmerged files:"
+msgstr "Kunde inta hämta lista över ej sammanslagna filer:"
+
+#: gitk:329
+msgid "No files selected: --merge specified but no files are unmerged."
+msgstr ""
+"Inga filer valdes: --merge angavs men det finns inga filer som inte har "
+"slagits samman."
+
+#: gitk:332
+msgid ""
+"No files selected: --merge specified but no unmerged files are within file "
+"limit."
+msgstr ""
+"Inga filer valdes: --merge angavs men det finns inga filer inom "
+"filbegränsningen."
+
+#: gitk:354
+msgid "Error executing git log:"
+msgstr "Fel vid körning av git log:"
+
+#: gitk:369
+msgid "Reading"
+msgstr "Läser"
+
+#: gitk:400 gitk:3356
+msgid "Reading commits..."
+msgstr "Läser incheckningar..."
+
+#: gitk:403 gitk:1480 gitk:3359
+msgid "No commits selected"
+msgstr "Inga incheckningar markerade"
+
+#: gitk:1358
+msgid "Can't parse git log output:"
+msgstr "Kan inte tolka utdata från git log:"
+
+#: gitk:1557
+msgid "No commit information available"
+msgstr "Ingen incheckningsinformation är tillgänglig"
+
+#: gitk:1654 gitk:1676 gitk:3150 gitk:7620 gitk:9149 gitk:9317
+msgid "OK"
+msgstr "OK"
+
+#: gitk:1678 gitk:3151 gitk:7296 gitk:7367 gitk:7470 gitk:7516 gitk:7622
+#: gitk:9150 gitk:9318
+msgid "Cancel"
+msgstr "Avbryt"
+
+#: gitk:1716
+msgid "File"
+msgstr "Arkiv"
+
+#: gitk:1718
+msgid "Update"
+msgstr "Uppdatera"
+
+#: gitk:1719
+msgid "Reload"
+msgstr "Ladda om"
+
+#: gitk:1720
+msgid "Reread references"
+msgstr "Läs om referenser"
+
+#: gitk:1721
+msgid "List references"
+msgstr "Visa referenser"
+
+#: gitk:1722
+msgid "Quit"
+msgstr "Avsluta"
+
+#: gitk:1724
+msgid "Edit"
+msgstr "Redigera"
+
+#: gitk:1725
+msgid "Preferences"
+msgstr "Inställningar"
+
+#: gitk:1728 gitk:3087
+msgid "View"
+msgstr "Visa"
+
+#: gitk:1729
+msgid "New view..."
+msgstr "Ny vy..."
+
+#: gitk:1730 gitk:3298 gitk:9932
+msgid "Edit view..."
+msgstr "Ändra vy..."
+
+#: gitk:1732 gitk:3299 gitk:9933
+msgid "Delete view"
+msgstr "Ta bort vy"
+
+#: gitk:1734
+msgid "All files"
+msgstr "Alla filer"
+
+#: gitk:1738
+msgid "Help"
+msgstr "Hjälp"
+
+#: gitk:1739 gitk:2399
+msgid "About gitk"
+msgstr "Om gitk"
+
+#: gitk:1740
+msgid "Key bindings"
+msgstr "Tangentbordsbindningar"
+
+#: gitk:1797
+msgid "SHA1 ID: "
+msgstr "SHA1-id: "
+
+#: gitk:1828
+msgid "Row"
+msgstr "Rad"
+
+#: gitk:1859
+msgid "Find"
+msgstr "Sök"
+
+#: gitk:1860
+msgid "next"
+msgstr "nästa"
+
+#: gitk:1861
+msgid "prev"
+msgstr "föreg"
+
+#: gitk:1862
+msgid "commit"
+msgstr "incheckning"
+
+#: gitk:1865 gitk:1867 gitk:3511 gitk:3534 gitk:3558 gitk:5441 gitk:5512
+msgid "containing:"
+msgstr "som innehåller:"
+
+#: gitk:1868 gitk:2866 gitk:2871 gitk:3586
+msgid "touching paths:"
+msgstr "som rör sökväg:"
+
+#: gitk:1869 gitk:3591
+msgid "adding/removing string:"
+msgstr "som lägger/till tar bort sträng:"
+
+#: gitk:1878 gitk:1880
+msgid "Exact"
+msgstr "Exakt"
+
+#: gitk:1880 gitk:3667 gitk:5409
+msgid "IgnCase"
+msgstr "IgnVersaler"
+
+#: gitk:1880 gitk:3560 gitk:3665 gitk:5405
+msgid "Regexp"
+msgstr "Reg.uttr."
+
+#: gitk:1882 gitk:1883 gitk:3686 gitk:3716 gitk:3723 gitk:5532 gitk:5599
+msgid "All fields"
+msgstr "Alla fält"
+
+#: gitk:1883 gitk:3684 gitk:3716 gitk:5471
+msgid "Headline"
+msgstr "Rubrik"
+
+#: gitk:1884 gitk:3684 gitk:5471 gitk:5599 gitk:6000
+msgid "Comments"
+msgstr "Kommentarer"
+
+#: gitk:1884 gitk:3684 gitk:3688 gitk:3723 gitk:5471 gitk:5936 gitk:7142
+#: gitk:7157
+msgid "Author"
+msgstr "Författare"
+
+#: gitk:1884 gitk:3684 gitk:5471 gitk:5938
+msgid "Committer"
+msgstr "Incheckare"
+
+#: gitk:1913
+msgid "Search"
+msgstr "Sök"
+
+#: gitk:1920
+msgid "Diff"
+msgstr "Diff"
+
+#: gitk:1922
+msgid "Old version"
+msgstr "Gammal version"
+
+#: gitk:1924
+msgid "New version"
+msgstr "Ny version"
+
+#: gitk:1926
+msgid "Lines of context"
+msgstr "Rader sammanhang"
+
+#: gitk:1936
+msgid "Ignore space change"
+msgstr "Ignorera ändringar i blanksteg"
+
+#: gitk:1994
+msgid "Patch"
+msgstr "Patch"
+
+#: gitk:1996
+msgid "Tree"
+msgstr "Träd"
+
+#: gitk:2121 gitk:2136 gitk:7211
+msgid "Diff this -> selected"
+msgstr "Diff denna -> markerad"
+
+#: gitk:2123 gitk:2138 gitk:7212
+msgid "Diff selected -> this"
+msgstr "Diff markerad -> denna"
+
+#: gitk:2125 gitk:2140 gitk:7213
+msgid "Make patch"
+msgstr "Skapa patch"
+
+#: gitk:2126 gitk:7351
+msgid "Create tag"
+msgstr "Skapa tagg"
+
+#: gitk:2127 gitk:7450
+msgid "Write commit to file"
+msgstr "Skriv incheckning till fil"
+
+#: gitk:2128 gitk:7504
+msgid "Create new branch"
+msgstr "Skapa ny gren"
+
+#: gitk:2129
+msgid "Cherry-pick this commit"
+msgstr "Plocka denna incheckning"
+
+#: gitk:2131
+msgid "Reset HEAD branch to here"
+msgstr "Återställ HEAD-grenen hit"
+
+#: gitk:2147
+msgid "Check out this branch"
+msgstr "Checka ut denna gren"
+
+#: gitk:2149
+msgid "Remove this branch"
+msgstr "Ta bort denna gren"
+
+#: gitk:2155
+msgid "Highlight this too"
+msgstr "Markera även detta"
+
+#: gitk:2157
+msgid "Highlight this only"
+msgstr "Markera bara detta"
+
+#: gitk:2159
+msgid "External diff"
+msgstr "Extern diff"
+
+#: gitk:2400
+msgid ""
+"\n"
+"Gitk - a commit viewer for git\n"
+"\n"
+"Copyright © 2005-2008 Paul Mackerras\n"
+"\n"
+"Use and redistribute under the terms of the GNU General Public License"
+msgstr ""
+"\n"
+"Gitk - en incheckningsvisare för git\n"
+"\n"
+"Copyright © 2005-2008 Paul Mackerras\n"
+"\n"
+"Använd och vidareförmedla enligt villkoren i GNU General Public License"
+
+#: gitk:2408 gitk:2469 gitk:7799
+msgid "Close"
+msgstr "Stäng"
+
+#: gitk:2427
+msgid "Gitk key bindings"
+msgstr "Tangentbordsbindningar för Gitk"
+
+#: gitk:2429
+msgid "Gitk key bindings:"
+msgstr "Tangentbordsbindningar för Gitk:"
+
+#: gitk:2431
+#, tcl-format
+msgid "<%s-Q>\t\tQuit"
+msgstr "<%s-Q>\t\tAvsluta"
+
+#: gitk:2432
+msgid "<Home>\t\tMove to first commit"
+msgstr "<Home>\t\tGå till första incheckning"
+
+#: gitk:2433
+msgid "<End>\t\tMove to last commit"
+msgstr "<End>\t\tGÃ¥ till sista incheckning"
+
+#: gitk:2434
+msgid "<Up>, p, i\tMove up one commit"
+msgstr "<Upp>, p, i\tGÃ¥ en incheckning upp"
+
+#: gitk:2435
+msgid "<Down>, n, k\tMove down one commit"
+msgstr "<Ned>, n, k\tGÃ¥ en incheckning ned"
+
+#: gitk:2436
+msgid "<Left>, z, j\tGo back in history list"
+msgstr "<Vänster>, z, j\tGå bakåt i historiken"
+
+#: gitk:2437
+msgid "<Right>, x, l\tGo forward in history list"
+msgstr "<Höger>, x, l\tGå framåt i historiken"
+
+#: gitk:2438
+msgid "<PageUp>\tMove up one page in commit list"
+msgstr "<PageUp>\tGÃ¥ upp en sida i incheckningslistan"
+
+#: gitk:2439
+msgid "<PageDown>\tMove down one page in commit list"
+msgstr "<PageDown>\tGÃ¥ ned en sida i incheckningslistan"
+
+#: gitk:2440
+#, tcl-format
+msgid "<%s-Home>\tScroll to top of commit list"
+msgstr "<%s-Home>\tRulla till början av incheckningslistan"
+
+#: gitk:2441
+#, tcl-format
+msgid "<%s-End>\tScroll to bottom of commit list"
+msgstr "<%s-End>\tRulla till slutet av incheckningslistan"
+
+#: gitk:2442
+#, tcl-format
+msgid "<%s-Up>\tScroll commit list up one line"
+msgstr "<%s-Upp>\tRulla incheckningslistan upp ett steg"
+
+#: gitk:2443
+#, tcl-format
+msgid "<%s-Down>\tScroll commit list down one line"
+msgstr "<%s-Ned>\tRulla incheckningslistan ned ett steg"
+
+#: gitk:2444
+#, tcl-format
+msgid "<%s-PageUp>\tScroll commit list up one page"
+msgstr "<%s-PageUp>\tRulla incheckningslistan upp en sida"
+
+#: gitk:2445
+#, tcl-format
+msgid "<%s-PageDown>\tScroll commit list down one page"
+msgstr "<%s-PageDown>\tRulla incheckningslistan ned en sida"
+
+#: gitk:2446
+msgid "<Shift-Up>\tFind backwards (upwards, later commits)"
+msgstr "<Skift-Upp>\tSök bakåt (uppåt, senare incheckningar)"
+
+#: gitk:2447
+msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)"
+msgstr "<Skift-Ned>\tSök framåt (nedåt, tidigare incheckningar)"
+
+#: gitk:2448
+msgid "<Delete>, b\tScroll diff view up one page"
+msgstr "<Delete>, b\tRulla diffvisningen upp en sida"
+
+#: gitk:2449
+msgid "<Backspace>\tScroll diff view up one page"
+msgstr "<Baksteg>\tRulla diffvisningen upp en sida"
+
+#: gitk:2450
+msgid "<Space>\t\tScroll diff view down one page"
+msgstr "<Blanksteg>\tRulla diffvisningen ned en sida"
+
+#: gitk:2451
+msgid "u\t\tScroll diff view up 18 lines"
+msgstr "u\t\tRulla diffvisningen upp 18 rader"
+
+#: gitk:2452
+msgid "d\t\tScroll diff view down 18 lines"
+msgstr "d\t\tRulla diffvisningen ned 18 rader"
+
+#: gitk:2453
+#, tcl-format
+msgid "<%s-F>\t\tFind"
+msgstr "<%s-F>\t\tSök"
+
+#: gitk:2454
+#, tcl-format
+msgid "<%s-G>\t\tMove to next find hit"
+msgstr "<%s-G>\t\tGå till nästa sökträff"
+
+#: gitk:2455
+msgid "<Return>\tMove to next find hit"
+msgstr "<Return>\t\tGå till nästa sökträff"
+
+#: gitk:2456
+msgid "/\t\tMove to next find hit, or redo find"
+msgstr "/\t\tGå till nästa sökträff, eller sök på nytt"
+
+#: gitk:2457
+msgid "?\t\tMove to previous find hit"
+msgstr "?\t\tGå till föregående sökträff"
+
+#: gitk:2458
+msgid "f\t\tScroll diff view to next file"
+msgstr "f\t\tRulla diffvisningen till nästa fil"
+
+#: gitk:2459
+#, tcl-format
+msgid "<%s-S>\t\tSearch for next hit in diff view"
+msgstr "<%s-S>\t\tGå till nästa sökträff i diffvisningen"
+
+#: gitk:2460
+#, tcl-format
+msgid "<%s-R>\t\tSearch for previous hit in diff view"
+msgstr "<%s-R>\t\tGå till föregående sökträff i diffvisningen"
+
+#: gitk:2461
+#, tcl-format
+msgid "<%s-KP+>\tIncrease font size"
+msgstr "<%s-Num+>\tÖka teckenstorlek"
+
+#: gitk:2462
+#, tcl-format
+msgid "<%s-plus>\tIncrease font size"
+msgstr "<%s-plus>\tÖka teckenstorlek"
+
+#: gitk:2463
+#, tcl-format
+msgid "<%s-KP->\tDecrease font size"
+msgstr "<%s-Num->\tMinska teckenstorlek"
+
+#: gitk:2464
+#, tcl-format
+msgid "<%s-minus>\tDecrease font size"
+msgstr "<%s-minus>\tMinska teckenstorlek"
+
+#: gitk:2465
+msgid "<F5>\t\tUpdate"
+msgstr "<F5>\t\tUppdatera"
+
+#: gitk:3091
+msgid "Gitk view definition"
+msgstr "Definition av Gitk-vy"
+
+#: gitk:3116
+msgid "Name"
+msgstr "Namn"
+
+#: gitk:3119
+msgid "Remember this view"
+msgstr "Spara denna vy"
+
+#: gitk:3123
+msgid "Commits to include (arguments to git log):"
+msgstr "Incheckningar att ta med (argument till git log):"
+
+#: gitk:3130
+msgid "Command to generate more commits to include:"
+msgstr "Kommando för att generera fler incheckningar att ta med:"
+
+#: gitk:3137
+msgid "Enter files and directories to include, one per line:"
+msgstr "Ange filer och kataloger att ta med, en per rad:"
+
+#: gitk:3184
+msgid "Error in commit selection arguments:"
+msgstr "Fel i argument för val av incheckningar:"
+
+#: gitk:3238 gitk:3290 gitk:3736 gitk:3750 gitk:4951 gitk:9896 gitk:9897
+msgid "None"
+msgstr "Inget"
+
+#: gitk:3684 gitk:5471 gitk:7144 gitk:7159
+msgid "Date"
+msgstr "Datum"
+
+#: gitk:3684 gitk:5471
+msgid "CDate"
+msgstr "Skapat datum"
+
+#: gitk:3833 gitk:3838
+msgid "Descendant"
+msgstr "Avkomling"
+
+#: gitk:3834
+msgid "Not descendant"
+msgstr "Inte avkomling"
+
+#: gitk:3841 gitk:3846
+msgid "Ancestor"
+msgstr "Förfader"
+
+#: gitk:3842
+msgid "Not ancestor"
+msgstr "Inte förfader"
+
+#: gitk:4078
+msgid "Local changes checked in to index but not committed"
+msgstr "Lokala ändringar sparade i indexet men inte incheckade"
+
+#: gitk:4111
+msgid "Local uncommitted changes, not checked in to index"
+msgstr "Lokala ändringar, ej sparade i indexet"
+
+#: gitk:5440
+msgid "Searching"
+msgstr "Söker"
+
+#: gitk:5940
+msgid "Tags:"
+msgstr "Taggar:"
+
+#: gitk:5957 gitk:5963 gitk:7137
+msgid "Parent"
+msgstr "Förälder"
+
+#: gitk:5968
+msgid "Child"
+msgstr "Barn"
+
+#: gitk:5977
+msgid "Branch"
+msgstr "Gren"
+
+#: gitk:5980
+msgid "Follows"
+msgstr "Följer"
+
+#: gitk:5983
+msgid "Precedes"
+msgstr "Föregår"
+
+#: gitk:6267
+msgid "Error getting merge diffs:"
+msgstr "Fel vid hämtning av sammanslagningsdiff:"
+
+#: gitk:6970
+msgid "Goto:"
+msgstr "GÃ¥ till:"
+
+#: gitk:6972
+msgid "SHA1 ID:"
+msgstr "SHA1-id:"
+
+#: gitk:6991
+#, tcl-format
+msgid "Short SHA1 id %s is ambiguous"
+msgstr "Förkortat SHA1-id %s är tvetydigt"
+
+#: gitk:7003
+#, tcl-format
+msgid "SHA1 id %s is not known"
+msgstr "SHA-id:t %s är inte känt"
+
+#: gitk:7005
+#, tcl-format
+msgid "Tag/Head %s is not known"
+msgstr "Tagg/huvud %s är okänt"
+
+#: gitk:7147
+msgid "Children"
+msgstr "Barn"
+
+#: gitk:7204
+#, tcl-format
+msgid "Reset %s branch to here"
+msgstr "Återställ grenen %s hit"
+
+#: gitk:7206
+msgid "Detached head: can't reset"
+msgstr "Frånkopplad head: kan inte återställa"
+
+#: gitk:7238
+msgid "Top"
+msgstr "Topp"
+
+#: gitk:7239
+msgid "From"
+msgstr "Från"
+
+#: gitk:7244
+msgid "To"
+msgstr "Till"
+
+#: gitk:7267
+msgid "Generate patch"
+msgstr "Generera patch"
+
+#: gitk:7269
+msgid "From:"
+msgstr "Från:"
+
+#: gitk:7278
+msgid "To:"
+msgstr "Till:"
+
+#: gitk:7287
+msgid "Reverse"
+msgstr "Vänd"
+
+#: gitk:7289 gitk:7464
+msgid "Output file:"
+msgstr "Utdatafil:"
+
+#: gitk:7295
+msgid "Generate"
+msgstr "Generera"
+
+#: gitk:7331
+msgid "Error creating patch:"
+msgstr "Fel vid generering av patch:"
+
+#: gitk:7353 gitk:7452 gitk:7506
+msgid "ID:"
+msgstr "Id:"
+
+#: gitk:7362
+msgid "Tag name:"
+msgstr "Taggnamn:"
+
+#: gitk:7366 gitk:7515
+msgid "Create"
+msgstr "Skapa"
+
+#: gitk:7381
+msgid "No tag name specified"
+msgstr "Inget taggnamn angavs"
+
+#: gitk:7385
+#, tcl-format
+msgid "Tag \"%s\" already exists"
+msgstr "Taggen \"%s\" finns redan"
+
+#: gitk:7391
+msgid "Error creating tag:"
+msgstr "Fel vid skapande av tagg:"
+
+#: gitk:7461
+msgid "Command:"
+msgstr "Kommando:"
+
+#: gitk:7469
+msgid "Write"
+msgstr "Skriv"
+
+#: gitk:7485
+msgid "Error writing commit:"
+msgstr "Fel vid skrivning av incheckning:"
+
+#: gitk:7511
+msgid "Name:"
+msgstr "Namn:"
+
+#: gitk:7530
+msgid "Please specify a name for the new branch"
+msgstr "Ange ett namn för den nya grenen"
+
+#: gitk:7559
+#, tcl-format
+msgid "Commit %s is already included in branch %s -- really re-apply it?"
+msgstr ""
+"Incheckningen %s finns redan på grenen %s -- skall den verkligen appliceras "
+"på nytt?"
+
+#: gitk:7564
+msgid "Cherry-picking"
+msgstr "Plockar"
+
+#: gitk:7576
+msgid "No changes committed"
+msgstr "Inga ändringar incheckade"
+
+#: gitk:7601
+msgid "Confirm reset"
+msgstr "Bekräfta återställning"
+
+#: gitk:7603
+#, tcl-format
+msgid "Reset branch %s to %s?"
+msgstr "Återställa grenen %s till %s?"
+
+#: gitk:7607
+msgid "Reset type:"
+msgstr "Typ av återställning:"
+
+#: gitk:7611
+msgid "Soft: Leave working tree and index untouched"
+msgstr "Mjuk: Rör inte utcheckning och index"
+
+#: gitk:7614
+msgid "Mixed: Leave working tree untouched, reset index"
+msgstr "Blandad: Rör inte utcheckning, återställ index"
+
+#: gitk:7617
+msgid ""
+"Hard: Reset working tree and index\n"
+"(discard ALL local changes)"
+msgstr ""
+"Hård: Återställ utcheckning och index\n"
+"(förkastar ALLA lokala ändringar)"
+
+#: gitk:7633
+msgid "Resetting"
+msgstr "Återställer"
+
+#: gitk:7690
+msgid "Checking out"
+msgstr "Checkar ut"
+
+#: gitk:7741
+msgid "Cannot delete the currently checked-out branch"
+msgstr "Kan inte ta bort den just nu utcheckade grenen"
+
+#: gitk:7747
+#, tcl-format
+msgid ""
+"The commits on branch %s aren't on any other branch.\n"
+"Really delete branch %s?"
+msgstr ""
+"Incheckningarna på grenen %s existerar inte på någon annan gren.\n"
+"Vill du verkligen ta bort grenen %s?"
+
+#: gitk:7778
+#, tcl-format
+msgid "Tags and heads: %s"
+msgstr "Taggar och huvuden: %s"
+
+#: gitk:7792
+msgid "Filter"
+msgstr "Filter"
+
+#: gitk:8086
+msgid ""
+"Error reading commit topology information; branch and preceding/following "
+"tag information will be incomplete."
+msgstr ""
+"Fel vid läsning av information om incheckningstopologi; information om "
+"grenar och föregående/senare taggar kommer inte vara komplett."
+
+#: gitk:9072
+msgid "Tag"
+msgstr "Tagg"
+
+#: gitk:9072
+msgid "Id"
+msgstr "Id"
+
+#: gitk:9118
+msgid "Gitk font chooser"
+msgstr "Teckensnittsväljare för Gitk"
+
+#: gitk:9135
+msgid "B"
+msgstr "F"
+
+#: gitk:9138
+msgid "I"
+msgstr "K"
+
+#: gitk:9231
+msgid "Gitk preferences"
+msgstr "Inställningar för Gitk"
+
+#: gitk:9232
+msgid "Commit list display options"
+msgstr "Alternativ för incheckningslistvy"
+
+#: gitk:9235
+msgid "Maximum graph width (lines)"
+msgstr "Maximal grafbredd (rader)"
+
+#: gitk:9239
+#, tcl-format
+msgid "Maximum graph width (% of pane)"
+msgstr "Maximal grafbredd (% av ruta)"
+
+#: gitk:9244
+msgid "Show local changes"
+msgstr "Visa lokala ändringar"
+
+#: gitk:9249
+msgid "Auto-select SHA1"
+msgstr "Välj SHA1 automatiskt"
+
+#: gitk:9254
+msgid "Diff display options"
+msgstr "Alternativ för diffvy"
+
+#: gitk:9256
+msgid "Tab spacing"
+msgstr "Blanksteg för tabulatortecken"
+
+#: gitk:9260
+msgid "Display nearby tags"
+msgstr "Visa närliggande taggar"
+
+#: gitk:9265
+msgid "Limit diffs to listed paths"
+msgstr "Begränsa diff till listade sökvägar"
+
+#: gitk:9272
+msgid "External diff tool"
+msgstr "Externt diff-verktyg"
+
+#: gitk:9274
+msgid "Choose..."
+msgstr "Välj..."
+
+#: gitk:9279
+msgid "Colors: press to choose"
+msgstr "Färger: tryck för att välja"
+
+#: gitk:9282
+msgid "Background"
+msgstr "Bakgrund"
+
+#: gitk:9286
+msgid "Foreground"
+msgstr "Förgrund"
+
+#: gitk:9290
+msgid "Diff: old lines"
+msgstr "Diff: gamla rader"
+
+#: gitk:9295
+msgid "Diff: new lines"
+msgstr "Diff: nya rader"
+
+#: gitk:9300
+msgid "Diff: hunk header"
+msgstr "Diff: delhuvud"
+
+#: gitk:9306
+msgid "Select bg"
+msgstr "Markerad bakgrund"
+
+#: gitk:9310
+msgid "Fonts: press to choose"
+msgstr "Teckensnitt: tryck för att välja"
+
+#: gitk:9312
+msgid "Main font"
+msgstr "Huvudteckensnitt"
+
+#: gitk:9313
+msgid "Diff display font"
+msgstr "Teckensnitt för diffvisning"
+
+#: gitk:9314
+msgid "User interface font"
+msgstr "Teckensnitt för användargränssnitt"
+
+#: gitk:9339
+#, tcl-format
+msgid "Gitk: choose color for %s"
+msgstr "Gitk: välj färg för %s"
+
+#: gitk:9720
+msgid ""
+"Sorry, gitk cannot run with this version of Tcl/Tk.\n"
+" Gitk requires at least Tcl/Tk 8.4."
+msgstr ""
+"Gitk kan tyvärr inte köra med denna version av Tcl/Tk.\n"
+" Gitk kräver åtminstone Tcl/Tk 8.4."
+
+#: gitk:9812
+msgid "Cannot find a git repository here."
+msgstr "Hittar inget gitk-arkiv här."
+
+#: gitk:9816
+#, tcl-format
+msgid "Cannot find the git directory \"%s\"."
+msgstr "Hittar inte git-katalogen \"%s\"."
+
+#: gitk:9853
+#, tcl-format
+msgid "Ambiguous argument '%s': both revision and filename"
+msgstr "Tvetydigt argument \"%s\": både revision och filnamn"
+
+#: gitk:9865
+msgid "Bad arguments to gitk:"
+msgstr "Felaktiga argument till gitk:"
+
+#: gitk:9925
+msgid "Command line"
+msgstr "Kommandorad"
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index 9cd5b0a2b..26967e201 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -29,40 +29,40 @@ Build time configuration
See also "How to configure gitweb for your local system" in README
file for gitweb (in gitweb/README).
-- There are many configuration variables which affects building of
+- There are many configuration variables which affect building of
gitweb.cgi; see "default configuration for gitweb" section in main
(top dir) Makefile, and instructions for building gitweb/gitweb.cgi
target.
- One of most important is where to find git wrapper binary. Gitweb
- tries to find git wrapper at $(bindir)/git, so you have to set $bindir
+ One of the most important is where to find the git wrapper binary. Gitweb
+ tries to find the git wrapper at $(bindir)/git, so you have to set $bindir
when building gitweb.cgi, or $prefix from which $bindir is derived. If
- you build and install gitweb together with the rest of git suite,
+ you build and install gitweb together with the rest of the git suite,
there should be no problems. Otherwise, if git was for example
installed from a binary package, you have to set $prefix (or $bindir)
accordingly.
- Another important issue is where are git repositories you want to make
- available to gitweb. By default gitweb search for repositories under
+ available to gitweb. By default gitweb searches for repositories under
/pub/git; if you want to have projects somewhere else, like /home/git,
use GITWEB_PROJECTROOT build configuration variable.
By default all git repositories under projectroot are visible and
- available to gitweb. List of projects is generated by default by
+ available to gitweb. The list of projects is generated by default by
scanning the projectroot directory for git repositories. This can be
changed (configured) as described in "Gitweb repositories" section
below.
- Note that gitweb deals directly with object database, and does not
- need working directory; the name of the project is the name of its
+ Note that gitweb deals directly with the object database, and does not
+ need a working directory; the name of the project is the name of its
repository object database, usually projectname.git for bare
repositories. If you want to provide gitweb access to non-bare (live)
- repository, you can make projectname.git symbolic link under
+ repositories, you can make projectname.git a symbolic link under
projectroot linking to projectname/.git (but it is just
a suggestion).
- You can control where gitweb tries to find its main CSS style file,
- its favicon and logo with GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
+ its favicon and logo with the GITWEB_CSS, GITWEB_FAVICON and GITWEB_LOGO
build configuration variables. By default gitweb tries to find them
in the same directory as gitweb.cgi script.
@@ -91,13 +91,17 @@ Gitweb config file
See also "Runtime gitweb configuration" section in README file
for gitweb (in gitweb/README).
-- You can configure gitweb further using gitweb configuration file;
- by default it is file named gitweb_config.perl in the same place as
- gitweb.cgi script. You can control default place for config file
- using GITWEB_CONFIG build configuration variable, and you can set it
- using GITWEB_CONFIG environmental variable.
-
-- Gitweb config file is [fragment] of perl code. You can set variables
+- You can configure gitweb further using the gitweb configuration file;
+ by default this is a file named gitweb_config.perl in the same place as
+ gitweb.cgi script. You can control the default place for the config file
+ using the GITWEB_CONFIG build configuration variable, and you can set it
+ using the GITWEB_CONFIG environment variable. If this file does not
+ exist, gitweb looks for a system-wide configuration file, normally
+ /etc/gitweb.conf. You can change the default using the
+ GITWEB_CONFIG_SYSTEM build configuration variable, and override it
+ through the GITWEB_CONFIG_SYSTEM environment variable.
+
+- The gitweb config file is a fragment of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
of a line is ignored. See perlsyn(1) for details.
@@ -124,36 +128,43 @@ Gitweb repositories
-------------------
- By default all git repositories under projectroot are visible and
- available to gitweb. List of projects is generated by default by
+ available to gitweb. The list of projects is generated by default by
scanning the projectroot directory for git repositories (for object
databases to be more exact).
- You can provide pre-generated list of [visible] repositories,
+ You can provide a pre-generated list of [visible] repositories,
together with information about their owners (the project ownership
- is taken from owner of repository directory otherwise), by setting
- GITWEB_LIST build configuration variable (or $projects_list variable
- in gitweb config file) to point to a plain file.
-
- Each line of projects list file should consist of url-encoded path
- to project repository database (relative to projectroot) separated
- by space from url-encoded project owner; spaces in both project path
- and project owner have to be encoded as either '%20' or '+'.
-
- You can generate projects list index file using project_index action
- (the 'TXT' link on projects list page) directly from gitweb.
-
-- By default even if project is not visible on projects list page, you
- can view it nevertheless by hand-crafting gitweb URL. You can set
- GITWEB_STRICT_EXPORT build configuration variable (or $strict_export
- variable in gitweb config file) to only allow viewing of
+ defaults to the owner of the repository directory otherwise), by setting
+ the GITWEB_LIST build configuration variable (or the $projects_list
+ variable in the gitweb config file) to point to a plain file.
+
+ Each line of the projects list file should consist of the url-encoded path
+ to the project repository database (relative to projectroot), followed
+ by the url-encoded project owner on the same line (separated by a space).
+ Spaces in both project path and project owner have to be encoded as either
+ '%20' or '+'.
+
+ Other characters that have to be url-encoded, i.e. replaced by '%'
+ followed by two-digit character number in octal, are: other whitespace
+ characters (because they are field separator in a record), plus sign '+'
+ (because it can be used as replacement for spaces), and percent sign '%'
+ (which is used for encoding / escaping).
+
+ You can generate the projects list index file using the project_index
+ action (the 'TXT' link on projects list page) directly from gitweb.
+
+- By default, even if a project is not visible on projects list page, you
+ can view it nevertheless by hand-crafting a gitweb URL. You can set the
+ GITWEB_STRICT_EXPORT build configuration variable (or the $strict_export
+ variable in the gitweb config file) to only allow viewing of
repositories also shown on the overview page.
- Alternatively, you can configure gitweb to only list and allow
- viewing of the explicitly exported repositories, via
- GITWEB_EXPORT_OK build configuration variable (or $export_ok
+ viewing of the explicitly exported repositories, via the
+ GITWEB_EXPORT_OK build configuration variable (or the $export_ok
variable in gitweb config file). If it evaluates to true, gitweb
- show repository only if this file exists in its object database
- (if directory has the magic file $export_ok).
+ shows repositories only if this file exists in its object database
+ (if directory has the magic file named $export_ok).
Generating projects list using gitweb
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/gitweb/README b/gitweb/README
index b28f59f57..825162a0b 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -2,7 +2,7 @@ GIT web Interface
=================
The one working on:
- http://www.kernel.org/git/
+ http://git.kernel.org/
From the git version 1.4.0 gitweb is bundled with git.
@@ -10,13 +10,13 @@ From the git version 1.4.0 gitweb is bundled with git.
How to configure gitweb for your local system
---------------------------------------------
-See also "Build time configuration" section in INSTALL
+See also the "Build time configuration" section in the INSTALL
file for gitweb (in gitweb/INSTALL).
You can specify the following configuration variables when building GIT:
* GIT_BINDIR
- Points out where to find git executable. You should set up it to
- the place where git binary was installed (usually /usr/bin) if you
+ Points where to find the git executable. You should set it up to
+ the place where the git binary was installed (usually /usr/bin) if you
don't install git from sources together with gitweb. [Default: $(bindir)]
* GITWEB_SITENAME
Shown in the title of all generated pages, defaults to the server name
@@ -24,13 +24,13 @@ You can specify the following configuration variables when building GIT:
* GITWEB_PROJECTROOT
The root directory for all projects shown by gitweb. Must be set
correctly for gitweb to find repositories to display. See also
- "Gitweb repositories" in INSTALL file for gitweb. [Default: /pub/git]
+ "Gitweb repositories" in the INSTALL file for gitweb. [Default: /pub/git]
* GITWEB_PROJECT_MAXDEPTH
- The filesystem traversing limit for getting projects list; the number
+ The filesystem traversing limit for getting the project list; the number
is taken as depth relative to the projectroot. It is used when
GITWEB_LIST is a directory (or is not set; then project root is used).
Is is meant to speed up project listing on large work trees by limiting
- find depth. [Default: 2007]
+ search depth. [Default: 2007]
* GITWEB_LIST
Points to a directory to scan for projects (defaults to project root
if not set / if empty) or to a file with explicit listing of projects
@@ -72,15 +72,15 @@ You can specify the following configuration variables when building GIT:
Git base URLs used for URL to where fetch project from, i.e. full
URL is "$git_base_url/$project". Shown on projects summary page.
Repository URL for project can be also configured per repository; this
- takes precendence over URL composed from base URL and project name.
+ takes precedence over URLs composed from base URL and a project name.
Note that you can setup multiple base URLs (for example one for
- git:// protocol access, one for http:// access) from gitweb config
- file. [No default]
+ git:// protocol access, another for http:// access) from the gitweb
+ config file. [No default]
* GITWEB_CSS
Points to the location where you put gitweb.css on your web server
- (or to be more generic URI of gitweb stylesheet). Relative to base
- URI of gitweb. Note that you can setup multiple stylesheets from
- gitweb config file. [Default: gitweb.css]
+ (or to be more generic, the URI of gitweb stylesheet). Relative to the
+ base URI of gitweb. Note that you can setup multiple stylesheets from
+ the gitweb config file. [Default: gitweb.css]
* GITWEB_LOGO
Points to the location where you put git-logo.png on your web server
(or to be more generic URI of logo, 72x27 size, displayed in top right
@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:
is set when gitweb.cgi is executed, then the file specified in the
environment variable will be loaded instead of the file specified
when gitweb.cgi was created. [Default: gitweb_config.perl]
+ * GITWEB_CONFIG_SYSTEM
+ This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
+ does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
+ when gitweb.cgi is executed, then the file specified in the environment
+ variable will be loaded instead of the file specified when gitweb.cgi was
+ created. [Default: /etc/gitweb.conf]
Runtime gitweb configuration
----------------------------
You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
-(defaults to 'gitweb_config.perl' in the same directory as the CGI).
+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
The most notable thing that is not configurable at compile time are the
optional features, stored in the '%features' variable.
@@ -114,32 +121,46 @@ Ultimate description on how to reconfigure the default features setting
in your `GITWEB_CONFIG` or per-project in `project.git/config` can be found
as comments inside 'gitweb.cgi'.
-See also "Gitweb config file" (with example of gitweb config file), and
-"Gitweb repositories" sections in INSTALL file for gitweb.
+See also the "Gitweb config file" (with an example of config file), and
+the "Gitweb repositories" sections in INSTALL file for gitweb.
-Gitweb config file is [fragment] of perl code. You can set variables
+The gitweb config file is a fragment of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
of a line is ignored. See perlsyn(1) man page for details.
-Below there is list of vaiables which you might want to set in gitweb config.
+Below is the list of variables which you might want to set in gitweb config.
See the top of 'gitweb.cgi' for the full list of variables and their
descriptions.
Gitweb config file variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You can set, among others, the following variables in gitweb config files:
+You can set, among others, the following variables in gitweb config files
+(with the exception of $projectroot and $projects_list this list does
+not include variables usually directly set during build):
* $GIT
- Cure git executable to use. By default set to "$GIT_BINDIR/git", which
+ 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 from binary
package, set this to "/usr/bin/git". This can just be "git" if your
webserver has a sensible PATH. If you have multiple git versions
- installed it is / can be used to choose which one to use.
+ installed it can be used to choose which one to use.
* $version
Gitweb version, set automatically when creating gitweb.cgi from
gitweb.perl. You might want to modify it if you are running modified
gitweb.
+ * $projectroot
+ Absolute filesystem path which will be prepended to project path;
+ the path to repository is $projectroot/$project. Set to
+ $GITWEB_PROJECTROOT during installation. This variable have to be
+ set correctly for gitweb to find repositories.
+ * $projects_list
+ Source of projects list, either directory to scan, or text file
+ with list of repositories (in the "<URI-encoded repository path> SP
+ <URI-encoded repository owner>" line format; actually there can be
+ any sequence of whitespace in place of space (SP)). Set to
+ $GITWEB_LIST during installation. If empty, $projectroot is used
+ to scan for repositories.
* $my_url, $my_uri
URL and absolute URL of gitweb script; you might need to set those
variables if you are using 'pathinfo' feature: see also below.
@@ -156,7 +177,7 @@ You can set, among others, the following variables in gitweb config files:
to make it easier to upgrade gitweb. You can add 'site' stylesheet
for example by using
push @stylesheets, "gitweb-site.css";
- in gitweb config file.
+ in the gitweb config file.
* $logo_url, $logo_label
URI and label (title) of GIT logo link (or your site logo, if you choose
to use different logo image). By default they point to git homepage;
@@ -178,12 +199,12 @@ You can set, among others, the following variables in gitweb config files:
Default mimetype for blob_plain (raw) view, if mimetype checking
doesn't result in some other type; by default 'text/plain'.
* $default_text_plain_charset
- Default charset for text files. If not set, web serwer configuration
+ Default charset for text files. If not set, web server configuration
would be used.
* $mimetypes_file
File to use for (filename extension based) guessing of MIME types before
- trying /etc/mime.types. Path, if relative, is taken currently as taken
- relative to current git repositoy.
+ trying /etc/mime.types. Path, if relative, is taken currently as
+ relative to the current git repository.
* $fallback_encoding
Gitweb assumes this charset if line contains non-UTF-8 characters.
Fallback decoding is used without error checking, so it can be even
@@ -194,6 +215,39 @@ You can set, among others, the following variables in gitweb config files:
('-M'); set it to ('-C') or ('-C', '-C') to also detect copies, or
set it to () if you don't want to have renames detection.
+
+Projects list file format
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Instead of having gitweb find repositories by scanning filesystem starting
+from $projectroot (or $projects_list, if it points to directory), you can
+provide list of projects by setting $projects_list to a text file with list
+of projects (and some additional info). This file uses the following
+format:
+
+One record (for project / repository) per line, whitespace separated fields;
+does not support (at least for now) lines continuation (newline escaping).
+Leading and trailing whitespace are ignored, any run of whitespace can be
+used as field separator (rules for Perl's "split(' ', $line)"). Keyed by
+the first field, which is project name, i.e. path to repository GIT_DIR
+relative to $projectroot. Fields use modified URI encoding, defined in
+RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding"
+(see http://en.wikipedia.org/wiki/Query_string#URL_encoding), the difference
+being that SP (' ') can be encoded as '+' (and therefore '+' has to be also
+percent-encoded). Reserved characters are: '%' (used for encoding), '+'
+(can be used to encode SPACE), all whitespace characters as defined in Perl,
+including SP, TAB and LF, (used to separate fields in a record).
+
+Currently list of fields is
+ * <repository path> - path to repository GIT_DIR, relative to $projectroot
+ * <repository owner> - displayed as repository owner, preferably full name,
+ or email, or both
+
+You can additionally use $projects_list file to limit which repositories
+are visible, and together with $strict_export to limit access to
+repositories (see "Gitweb repositories" section in gitweb/INSTALL).
+
+
Per-repository gitweb configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -205,21 +259,26 @@ You can use the following files in repository:
* README.html
A .html file (HTML fragment) which is included on the gitweb project
summary page inside <div> block element. You can use it for longer
- description of a project, to provide links for example to projects
- homepage, etc.
+ description of a project, to provide links (for example to project's
+ homepage), etc.
* description (or gitweb.description)
Short (shortened by default to 25 characters in the projects list page)
single line description of a project (of a repository). Plain text file;
HTML will be escaped. By default set to
Unnamed repository; edit this file to name it for gitweb.
- from the template during creating repository. You can use
+ from the template during repository creation. You can use the
gitweb.description repo configuration variable, but the file takes
- precendence.
+ precedence.
* cloneurl (or multiple-valued gitweb.url)
File with repository URL (used for clone and fetch), one per line.
Displayed in the project summary page. You can use multiple-valued
gitweb.url repository configuration variable for that, but the file
- takes precendence.
+ takes precedence.
+ * gitweb.owner
+ You can use the gitweb.owner repository configuration variable to set
+ repository's owner. It is displayed in the project list and summary
+ page. If it's not set, filesystem directory's owner is used
+ (via GECOS field / real name field from getpwiud(3)).
* various gitweb.* config variables (in config)
Read description of %feature hash for detailed list, and some
descriptions.
@@ -231,12 +290,15 @@ Webserver configuration
If you want to have one URL for both gitweb and your http://
repositories, you can configure apache like this:
-<VirtualHost www:80>
- ServerName git.domain.org
+<VirtualHost *:80>
+ ServerName git.example.org
DocumentRoot /pub/git
- RewriteEngine on
- RewriteRule ^/(.*\.git/(?!/?(info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
SetEnv GITWEB_CONFIG /etc/gitweb.conf
+ RewriteEngine on
+ # make the front page an internal rewrite to the gitweb script
+ RewriteRule ^/$ /cgi-bin/gitweb.cgi
+ # make access for "dumb clients" work
+ RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT]
</VirtualHost>
The above configuration expects your public repositories to live under
@@ -252,6 +314,13 @@ override the defaults given at the head of the gitweb.perl (or
gitweb.cgi). Look at the comments in that file for information on
which variables and what they mean.
+If you use the rewrite rules from the example you'll likely also need
+something like the following in your gitweb.conf (or gitweb_config.perl) file:
+
+ @stylesheets = ("/some/absolute/path/gitweb.css");
+ $my_uri = "/";
+ $home_link = "/";
+
Originally written by:
Kay Sievers <kay.sievers@vrfy.org>
diff --git a/gitweb/gitweb.css b/gitweb/gitweb.css
index 446a1c333..aa0eeca24 100644
--- a/gitweb/gitweb.css
+++ b/gitweb/gitweb.css
@@ -464,6 +464,14 @@ a.rss_logo:hover {
background-color: #ee5500;
}
+a.rss_logo.generic {
+ background-color: #ff8800;
+}
+
+a.rss_logo.generic:hover {
+ background-color: #ee7700;
+}
+
span.refs span {
padding: 0px 4px;
font-size: 70%;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6256641ac..90cd99bf9 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -369,10 +369,15 @@ sub filter_snapshot_fmts {
}
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (-e $GITWEB_CONFIG) {
+ do $GITWEB_CONFIG;
+} else {
+ our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+ do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
+}
# version of the core git binary
-our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
+our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown";
$projects_list ||= $projectroot;
@@ -381,7 +386,7 @@ $projects_list ||= $projectroot;
our $action = $cgi->param('a');
if (defined $action) {
if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
- die_error(undef, "Invalid action parameter");
+ die_error(400, "Invalid action parameter");
}
}
@@ -394,21 +399,21 @@ if (defined $project) {
($export_ok && !(-e "$projectroot/$project/$export_ok")) ||
($strict_export && !project_in_list($project))) {
undef $project;
- die_error(undef, "No such project");
+ die_error(404, "No such project");
}
}
our $file_name = $cgi->param('f');
if (defined $file_name) {
if (!validate_pathname($file_name)) {
- die_error(undef, "Invalid file parameter");
+ die_error(400, "Invalid file parameter");
}
}
our $file_parent = $cgi->param('fp');
if (defined $file_parent) {
if (!validate_pathname($file_parent)) {
- die_error(undef, "Invalid file parent parameter");
+ die_error(400, "Invalid file parent parameter");
}
}
@@ -416,21 +421,21 @@ if (defined $file_parent) {
our $hash = $cgi->param('h');
if (defined $hash) {
if (!validate_refname($hash)) {
- die_error(undef, "Invalid hash parameter");
+ die_error(400, "Invalid hash parameter");
}
}
our $hash_parent = $cgi->param('hp');
if (defined $hash_parent) {
if (!validate_refname($hash_parent)) {
- die_error(undef, "Invalid hash parent parameter");
+ die_error(400, "Invalid hash parent parameter");
}
}
our $hash_base = $cgi->param('hb');
if (defined $hash_base) {
if (!validate_refname($hash_base)) {
- die_error(undef, "Invalid hash base parameter");
+ die_error(400, "Invalid hash base parameter");
}
}
@@ -442,10 +447,10 @@ our @extra_options = $cgi->param('opt');
if (defined @extra_options) {
foreach my $opt (@extra_options) {
if (not exists $allowed_options{$opt}) {
- die_error(undef, "Invalid option parameter");
+ die_error(400, "Invalid option parameter");
}
if (not grep(/^$action$/, @{$allowed_options{$opt}})) {
- die_error(undef, "Invalid option parameter for this action");
+ die_error(400, "Invalid option parameter for this action");
}
}
}
@@ -453,7 +458,7 @@ if (defined @extra_options) {
our $hash_parent_base = $cgi->param('hpb');
if (defined $hash_parent_base) {
if (!validate_refname($hash_parent_base)) {
- die_error(undef, "Invalid hash parent base parameter");
+ die_error(400, "Invalid hash parent base parameter");
}
}
@@ -461,24 +466,26 @@ if (defined $hash_parent_base) {
our $page = $cgi->param('pg');
if (defined $page) {
if ($page =~ m/[^0-9]/) {
- die_error(undef, "Invalid page parameter");
+ die_error(400, "Invalid page parameter");
}
}
our $searchtype = $cgi->param('st');
if (defined $searchtype) {
if ($searchtype =~ m/[^a-z]/) {
- die_error(undef, "Invalid searchtype parameter");
+ die_error(400, "Invalid searchtype parameter");
}
}
+our $search_use_regexp = $cgi->param('sr');
+
our $searchtext = $cgi->param('s');
our $search_regexp;
if (defined $searchtext) {
if (length($searchtext) < 2) {
- die_error(undef, "At least two characters are required for search parameter");
+ die_error(403, "At least two characters are required for search parameter");
}
- $search_regexp = quotemeta $searchtext;
+ $search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;
}
# now read PATH_INFO and use it as alternative to parameters
@@ -504,7 +511,7 @@ sub evaluate_path_info {
}
# do not change any parameters if an action is given using the query string
return if $action;
- $path_info =~ s,^$project/*,,;
+ $path_info =~ s,^\Q$project\E/*,,;
my ($refname, $pathname) = split(/:/, $path_info, 2);
if (defined $pathname) {
# we got "project.git/branch:filename" or "project.git/branch:dir/"
@@ -532,7 +539,7 @@ $git_dir = "$projectroot/$project" if $project;
# dispatch
my %actions = (
- "blame" => \&git_blame2,
+ "blame" => \&git_blame,
"blobdiff" => \&git_blobdiff,
"blobdiff_plain" => \&git_blobdiff_plain,
"blob" => \&git_blob,
@@ -573,11 +580,11 @@ if (!defined $action) {
}
}
if (!defined($actions{$action})) {
- die_error(undef, "Unknown action");
+ die_error(400, "Unknown action");
}
if ($action !~ m/^(opml|project_list|project_index)$/ &&
!$project) {
- die_error(undef, "Project needed");
+ die_error(400, "Project needed");
}
$actions{$action}->();
exit;
@@ -585,7 +592,7 @@ exit;
## ======================================================================
## action links
-sub href(%) {
+sub href (%) {
my %params = @_;
# default is to use -absolute url() i.e. $my_uri
my $href = $params{-full} ? $my_url : $my_uri;
@@ -608,9 +615,12 @@ sub href(%) {
searchtype => "st",
snapshot_format => "sf",
extra_options => "opt",
+ search_use_regexp => "sr",
);
my %mapping = @mapping;
+ $params{'project'} = $project unless exists $params{'project'};
+
if ($params{-replay}) {
while (my ($name, $symbol) = each %mapping) {
if (!exists $params{$name}) {
@@ -620,12 +630,10 @@ sub href(%) {
}
}
- $params{'project'} = $project unless exists $params{'project'};
-
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
if ($use_pathinfo) {
# use PATH_INFO for project name
- $href .= "/$params{'project'}" if defined $params{'project'};
+ $href .= "/".esc_url($params{'project'}) if defined $params{'project'};
delete $params{'project'};
# Summary just uses the project path URL
@@ -753,29 +761,40 @@ sub esc_path {
# Make control characters "printable", using character escape codes (CEC)
sub quot_cec {
my $cntrl = shift;
+ my %opts = @_;
my %es = ( # character escape codes, aka escape sequences
- "\t" => '\t', # tab (HT)
- "\n" => '\n', # line feed (LF)
- "\r" => '\r', # carrige return (CR)
- "\f" => '\f', # form feed (FF)
- "\b" => '\b', # backspace (BS)
- "\a" => '\a', # alarm (bell) (BEL)
- "\e" => '\e', # escape (ESC)
- "\013" => '\v', # vertical tab (VT)
- "\000" => '\0', # nul character (NUL)
- );
+ "\t" => '\t', # tab (HT)
+ "\n" => '\n', # line feed (LF)
+ "\r" => '\r', # carrige return (CR)
+ "\f" => '\f', # form feed (FF)
+ "\b" => '\b', # backspace (BS)
+ "\a" => '\a', # alarm (bell) (BEL)
+ "\e" => '\e', # escape (ESC)
+ "\013" => '\v', # vertical tab (VT)
+ "\000" => '\0', # nul character (NUL)
+ );
my $chr = ( (exists $es{$cntrl})
? $es{$cntrl}
: sprintf('\%03o', ord($cntrl)) );
- return "<span class=\"cntrl\">$chr</span>";
+ if ($opts{-nohtml}) {
+ return $chr;
+ } else {
+ return "<span class=\"cntrl\">$chr</span>";
+ }
}
# Alternatively use unicode control pictures codepoints,
# Unicode "printable representation" (PR)
sub quot_upr {
my $cntrl = shift;
+ my %opts = @_;
+
my $chr = sprintf('&#%04d;', 0x2400+ord($cntrl));
- return "<span class=\"cntrl\">$chr</span>";
+ if ($opts{-nohtml}) {
+ return $chr;
+ } else {
+ return "<span class=\"cntrl\">$chr</span>";
+ }
}
# git may return quoted and escaped filenames
@@ -800,7 +819,7 @@ sub unquote {
return chr(oct($seq));
} elsif (exists $es{$seq}) {
# C escape sequence, aka character escape code
- return $es{$seq}
+ return $es{$seq};
}
# quoted ordinary character
return $seq;
@@ -837,37 +856,82 @@ sub project_in_list {
## ----------------------------------------------------------------------
## HTML aware string manipulation
+# Try to chop given string on a word boundary between position
+# $len and $len+$add_len. If there is no word boundary there,
+# chop at $len+$add_len. Do not chop if chopped part plus ellipsis
+# (marking chopped part) would be longer than given string.
sub chop_str {
my $str = shift;
my $len = shift;
my $add_len = shift || 10;
+ my $where = shift || 'right'; # 'left' | 'center' | 'right'
+
+ # Make sure perl knows it is utf8 encoded so we don't
+ # cut in the middle of a utf8 multibyte char.
+ $str = to_utf8($str);
# allow only $len chars, but don't cut a word if it would fit in $add_len
# if it doesn't fit, cut it if it's still longer than the dots we would add
- $str =~ m/^(.{0,$len}[^ \/\-_:\.@]{0,$add_len})(.*)/;
- my $body = $1;
- my $tail = $2;
- if (length($tail) > 4) {
- $tail = " ...";
- $body =~ s/&[^;]*$//; # remove chopped character entities
+ # remove chopped character entities entirely
+
+ # when chopping in the middle, distribute $len into left and right part
+ # return early if chopping wouldn't make string shorter
+ if ($where eq 'center') {
+ return $str if ($len + 5 >= length($str)); # filler is length 5
+ $len = int($len/2);
+ } else {
+ return $str if ($len + 4 >= length($str)); # filler is length 4
+ }
+
+ # regexps: ending and beginning with word part up to $add_len
+ my $endre = qr/.{$len}\w{0,$add_len}/;
+ my $begre = qr/\w{0,$add_len}.{$len}/;
+
+ if ($where eq 'left') {
+ $str =~ m/^(.*?)($begre)$/;
+ my ($lead, $body) = ($1, $2);
+ if (length($lead) > 4) {
+ $body =~ s/^[^;]*;// if ($lead =~ m/&[^;]*$/);
+ $lead = " ...";
+ }
+ return "$lead$body";
+
+ } elsif ($where eq 'center') {
+ $str =~ m/^($endre)(.*)$/;
+ my ($left, $str) = ($1, $2);
+ $str =~ m/^(.*?)($begre)$/;
+ my ($mid, $right) = ($1, $2);
+ if (length($mid) > 5) {
+ $left =~ s/&[^;]*$//;
+ $right =~ s/^[^;]*;// if ($mid =~ m/&[^;]*$/);
+ $mid = " ... ";
+ }
+ return "$left$mid$right";
+
+ } else {
+ $str =~ m/^($endre)(.*)$/;
+ my $body = $1;
+ my $tail = $2;
+ if (length($tail) > 4) {
+ $body =~ s/&[^;]*$//;
+ $tail = "... ";
+ }
+ return "$body$tail";
}
- return "$body$tail";
}
# takes the same arguments as chop_str, but also wraps a <span> around the
# result with a title attribute if it does get chopped. Additionally, the
# string is HTML-escaped.
sub chop_and_escape_str {
- my $str = shift;
- my $len = shift;
- my $add_len = shift || 10;
+ my ($str) = @_;
- my $chopped = chop_str($str, $len, $add_len);
+ my $chopped = chop_str(@_);
if ($chopped eq $str) {
return esc_html($chopped);
} else {
- return qq{<span title="} . esc_html($str) . qq{">} .
- esc_html($chopped) . qq{</span>};
+ $str =~ s/([[:cntrl:]])/?/g;
+ return $cgi->span({-title=>$str}, esc_html($chopped));
}
}
@@ -1388,6 +1452,46 @@ sub format_snapshot_links {
}
}
+## ......................................................................
+## functions returning values to be passed, perhaps after some
+## transformation, to other functions; e.g. returning arguments to href()
+
+# returns hash to be passed to href to generate gitweb URL
+# in -title key it returns description of link
+sub get_feed_info {
+ my $format = shift || 'Atom';
+ my %res = (action => lc($format));
+
+ # feed links are possible only for project views
+ return unless (defined $project);
+ # some views should link to OPML, or to generic project feed,
+ # or don't have specific feed yet (so they should use generic)
+ return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
+
+ my $branch;
+ # branches refs uses 'refs/heads/' prefix (fullname) to differentiate
+ # from tag links; this also makes possible to detect branch links
+ if ((defined $hash_base && $hash_base =~ m!^refs/heads/(.*)$!) ||
+ (defined $hash && $hash =~ m!^refs/heads/(.*)$!)) {
+ $branch = $1;
+ }
+ # find log type for feed description (title)
+ my $type = 'log';
+ if (defined $file_name) {
+ $type = "history of $file_name";
+ $type .= "/" if ($action eq 'tree');
+ $type .= " on '$branch'" if (defined $branch);
+ } else {
+ $type = "log of $branch" if (defined $branch);
+ }
+
+ $res{-title} = $type;
+ $res{'hash'} = (defined $branch ? "refs/heads/$branch" : undef);
+ $res{'file_name'} = $file_name;
+
+ return %res;
+}
+
## ----------------------------------------------------------------------
## git utility subroutines, invoking git commands
@@ -1396,9 +1500,13 @@ sub git_cmd {
return $GIT, '--git-dir='.$git_dir;
}
-# returns path to the core git executable and the --git-dir parameter as string
-sub git_cmd_str {
- return join(' ', git_cmd());
+# quote the given arguments for passing them to the shell
+# quote_command("command", "arg 1", "arg with ' and ! characters")
+# => "'command' 'arg 1' 'arg with '\'' and '\!' characters'"
+# Try to avoid using this function wherever possible.
+sub quote_command {
+ return join(' ',
+ map( { my $a = $_; $a =~ s/(['!])/'\\$1'/g; "'$a'" } @_ ));
}
# get HEAD ref of given project as hash
@@ -1557,7 +1665,7 @@ sub git_get_hash_by_path {
$path =~ s,/+$,,;
open my $fd, "-|", git_cmd(), "ls-tree", $base, "--", $path
- or die_error(undef, "Open git-ls-tree failed");
+ or die_error(500, "Open git-ls-tree failed");
my $line = <$fd>;
close $fd or return undef;
@@ -1606,7 +1714,7 @@ sub git_get_project_description {
my $path = shift;
$git_dir = "$projectroot/$path";
- open my $fd, "$projectroot/$path/description"
+ open my $fd, "$git_dir/description"
or return git_get_project_config('description');
my $descr = <$fd>;
close $fd;
@@ -1620,7 +1728,7 @@ sub git_get_project_url_list {
my $path = shift;
$git_dir = "$projectroot/$path";
- open my $fd, "$projectroot/$path/cloneurl"
+ open my $fd, "$git_dir/cloneurl"
or return wantarray ?
@{ config_to_multi(git_get_project_config('url')) } :
config_to_multi(git_get_project_config('url'));
@@ -1759,6 +1867,7 @@ sub git_get_project_owner {
my $owner;
return undef unless $project;
+ $git_dir = "$projectroot/$project";
if (!defined $gitweb_project_owner) {
git_get_project_list_from_file();
@@ -1767,8 +1876,11 @@ sub git_get_project_owner {
if (exists $gitweb_project_owner->{$project}) {
$owner = $gitweb_project_owner->{$project};
}
+ if (!defined $owner){
+ $owner = git_get_project_config('owner');
+ }
if (!defined $owner) {
- $owner = get_file_owner("$projectroot/$project");
+ $owner = get_file_owner("$git_dir");
}
return $owner;
@@ -2015,7 +2127,7 @@ sub parse_commit {
"--max-count=1",
$commit_id,
"--",
- or die_error(undef, "Open git-rev-list failed");
+ or die_error(500, "Open git-rev-list failed");
%co = parse_commit_text(<$fd>, 1);
close $fd;
@@ -2023,7 +2135,7 @@ sub parse_commit {
}
sub parse_commits {
- my ($commit_id, $maxcount, $skip, $arg, $filename) = @_;
+ my ($commit_id, $maxcount, $skip, $filename, @args) = @_;
my @cos;
$maxcount ||= 1;
@@ -2033,14 +2145,14 @@ sub parse_commits {
open my $fd, "-|", git_cmd(), "rev-list",
"--header",
- ($arg ? ($arg) : ()),
+ @args,
("--max-count=" . $maxcount),
("--skip=" . $skip),
@extra_options,
$commit_id,
"--",
($filename ? ($filename) : ())
- or die_error(undef, "Open git-rev-list failed");
+ or die_error(500, "Open git-rev-list failed");
while (my $line = <$fd>) {
my %co = parse_commit_text($line);
push @cos, \%co;
@@ -2050,49 +2162,6 @@ sub parse_commits {
return wantarray ? @cos : \@cos;
}
-# parse ref from ref_file, given by ref_id, with given type
-sub parse_ref {
- my $ref_file = shift;
- my $ref_id = shift;
- my $type = shift || git_get_type($ref_id);
- my %ref_item;
-
- $ref_item{'type'} = $type;
- $ref_item{'id'} = $ref_id;
- $ref_item{'epoch'} = 0;
- $ref_item{'age'} = "unknown";
- if ($type eq "tag") {
- my %tag = parse_tag($ref_id);
- $ref_item{'comment'} = $tag{'comment'};
- if ($tag{'type'} eq "commit") {
- my %co = parse_commit($tag{'object'});
- $ref_item{'epoch'} = $co{'committer_epoch'};
- $ref_item{'age'} = $co{'age_string'};
- } elsif (defined($tag{'epoch'})) {
- my $age = time - $tag{'epoch'};
- $ref_item{'epoch'} = $tag{'epoch'};
- $ref_item{'age'} = age_string($age);
- }
- $ref_item{'reftype'} = $tag{'type'};
- $ref_item{'name'} = $tag{'name'};
- $ref_item{'refid'} = $tag{'object'};
- } elsif ($type eq "commit"){
- my %co = parse_commit($ref_id);
- $ref_item{'reftype'} = "commit";
- $ref_item{'name'} = $ref_file;
- $ref_item{'title'} = $co{'title'};
- $ref_item{'refid'} = $ref_id;
- $ref_item{'epoch'} = $co{'committer_epoch'};
- $ref_item{'age'} = $co{'age_string'};
- } else {
- $ref_item{'reftype'} = $type;
- $ref_item{'name'} = $ref_file;
- $ref_item{'refid'} = $ref_id;
- }
-
- return %ref_item;
-}
-
# parse line of git-diff-tree "raw" output
sub parse_difftree_raw_line {
my $line = shift;
@@ -2105,7 +2174,7 @@ sub parse_difftree_raw_line {
$res{'to_mode'} = $2;
$res{'from_id'} = $3;
$res{'to_id'} = $4;
- $res{'status'} = $res{'status_str'} = $5;
+ $res{'status'} = $5;
$res{'similarity'} = $6;
if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied
($res{'from_file'}, $res{'to_file'}) = map { unquote($_) } split("\t", $7);
@@ -2121,7 +2190,6 @@ sub parse_difftree_raw_line {
$res{'to_mode'} = pop @{$res{'from_mode'}};
$res{'from_id'} = [ split(' ', $3) ];
$res{'to_id'} = pop @{$res{'from_id'}};
- $res{'status_str'} = $4;
$res{'status'} = [ split('', $4) ];
$res{'to_file'} = unquote($5);
}
@@ -2374,8 +2442,7 @@ sub blob_mimetype {
return $default_blob_plain_mimetype unless $fd;
if (-T $fd) {
- return 'text/plain' .
- ($default_text_plain_charset ? '; charset='.$default_text_plain_charset : '');
+ return 'text/plain';
} elsif (! $filename) {
return 'application/octet-stream';
} elsif ($filename =~ m/\.png$/i) {
@@ -2389,6 +2456,17 @@ sub blob_mimetype {
}
}
+sub blob_contenttype {
+ my ($fd, $file_name, $type) = @_;
+
+ $type ||= blob_mimetype($fd, $file_name);
+ if ($type eq 'text/plain' && defined $default_text_plain_charset) {
+ $type .= "; charset=$default_text_plain_charset";
+ }
+
+ return $type;
+}
+
## ======================================================================
## functions printing HTML: header, footer, error page
@@ -2447,30 +2525,49 @@ EOF
}
}
if (defined $project) {
- printf('<link rel="alternate" title="%s log RSS feed" '.
- 'href="%s" type="application/rss+xml" />'."\n",
- esc_param($project), href(action=>"rss"));
- printf('<link rel="alternate" title="%s log RSS feed (no merges)" '.
- 'href="%s" type="application/rss+xml" />'."\n",
- esc_param($project), href(action=>"rss",
- extra_options=>"--no-merges"));
- printf('<link rel="alternate" title="%s log Atom feed" '.
- 'href="%s" type="application/atom+xml" />'."\n",
- esc_param($project), href(action=>"atom"));
- printf('<link rel="alternate" title="%s log Atom feed (no merges)" '.
- 'href="%s" type="application/atom+xml" />'."\n",
- esc_param($project), href(action=>"atom",
- extra_options=>"--no-merges"));
+ my %href_params = get_feed_info();
+ if (!exists $href_params{'-title'}) {
+ $href_params{'-title'} = 'log';
+ }
+
+ foreach my $format qw(RSS Atom) {
+ my $type = lc($format);
+ my %link_attr = (
+ '-rel' => 'alternate',
+ '-title' => "$project - $href_params{'-title'} - $format feed",
+ '-type' => "application/$type+xml"
+ );
+
+ $href_params{'action'} = $type;
+ $link_attr{'-href'} = href(%href_params);
+ print "<link ".
+ "rel=\"$link_attr{'-rel'}\" ".
+ "title=\"$link_attr{'-title'}\" ".
+ "href=\"$link_attr{'-href'}\" ".
+ "type=\"$link_attr{'-type'}\" ".
+ "/>\n";
+
+ $href_params{'extra_options'} = '--no-merges';
+ $link_attr{'-href'} = href(%href_params);
+ $link_attr{'-title'} .= ' (no merges)';
+ print "<link ".
+ "rel=\"$link_attr{'-rel'}\" ".
+ "title=\"$link_attr{'-title'}\" ".
+ "href=\"$link_attr{'-href'}\" ".
+ "type=\"$link_attr{'-type'}\" ".
+ "/>\n";
+ }
+
} else {
printf('<link rel="alternate" title="%s projects list" '.
- 'href="%s" type="text/plain; charset=utf-8"/>'."\n",
+ 'href="%s" type="text/plain; charset=utf-8" />'."\n",
$site_name, href(project=>undef, action=>"project_index"));
printf('<link rel="alternate" title="%s projects feeds" '.
- 'href="%s" type="text/x-opml"/>'."\n",
+ 'href="%s" type="text/x-opml" />'."\n",
$site_name, href(project=>undef, action=>"opml"));
}
if (defined $favicon) {
- print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
+ print qq(<link rel="shortcut icon" href="$favicon" type="image/png" />\n);
}
print "</head>\n" .
@@ -2497,7 +2594,7 @@ EOF
print "</div>\n";
my ($have_search) = gitweb_check_feature('search');
- if ((defined $project) && ($have_search)) {
+ if (defined $project && $have_search) {
if (!defined $searchtext) {
$searchtext = "";
}
@@ -2512,45 +2609,58 @@ EOF
my $action = $my_uri;
my ($use_pathinfo) = gitweb_check_feature('pathinfo');
if ($use_pathinfo) {
- $action .= "/$project";
- } else {
- $cgi->param("p", $project);
+ $action .= "/".esc_url($project);
}
- $cgi->param("a", "search");
- $cgi->param("h", $search_hash);
print $cgi->startform(-method => "get", -action => $action) .
"<div class=\"search\">\n" .
- (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .
- $cgi->hidden(-name => "a") . "\n" .
- $cgi->hidden(-name => "h") . "\n" .
+ (!$use_pathinfo &&
+ $cgi->input({-name=>"p", -value=>$project, -type=>"hidden"}) . "\n") .
+ $cgi->input({-name=>"a", -value=>"search", -type=>"hidden"}) . "\n" .
+ $cgi->input({-name=>"h", -value=>$search_hash, -type=>"hidden"}) . "\n" .
$cgi->popup_menu(-name => 'st', -default => 'commit',
-values => ['commit', 'grep', 'author', 'committer', 'pickaxe']) .
$cgi->sup($cgi->a({-href => href(action=>"search_help")}, "?")) .
" search:\n",
$cgi->textfield(-name => "s", -value => $searchtext) . "\n" .
+ "<span title=\"Extended regular expression\">" .
+ $cgi->checkbox(-name => 'sr', -value => 1, -label => 're',
+ -checked => $search_use_regexp) .
+ "</span>" .
"</div>" .
$cgi->end_form() . "\n";
}
}
sub git_footer_html {
+ my $feed_class = 'rss_logo';
+
print "<div class=\"page_footer\">\n";
if (defined $project) {
my $descr = git_get_project_description($project);
if (defined $descr) {
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
}
- print $cgi->a({-href => href(action=>"rss"),
- -class => "rss_logo"}, "RSS") . " ";
- print $cgi->a({-href => href(action=>"atom"),
- -class => "rss_logo"}, "Atom") . "\n";
+
+ my %href_params = get_feed_info();
+ if (!%href_params) {
+ $feed_class .= ' generic';
+ }
+ $href_params{'-title'} ||= 'log';
+
+ foreach my $format qw(RSS Atom) {
+ $href_params{'action'} = lc($format);
+ print $cgi->a({-href => href(%href_params),
+ -title => "$href_params{'-title'} $format feed",
+ -class => $feed_class}, $format)."\n";
+ }
+
} else {
print $cgi->a({-href => href(project=>undef, action=>"opml"),
- -class => "rss_logo"}, "OPML") . " ";
+ -class => $feed_class}, "OPML") . " ";
print $cgi->a({-href => href(project=>undef, action=>"project_index"),
- -class => "rss_logo"}, "TXT") . "\n";
+ -class => $feed_class}, "TXT") . "\n";
}
- print "</div>\n" ;
+ print "</div>\n"; # class="page_footer"
if (-f $site_footer) {
open (my $fd, $site_footer);
@@ -2562,11 +2672,26 @@ sub git_footer_html {
"</html>";
}
+# die_error(<http_status_code>, <error_message>)
+# Example: die_error(404, 'Hash not found')
+# By convention, use the following status codes (as defined in RFC 2616):
+# 400: Invalid or missing CGI parameters, or
+# requested object exists but has wrong type.
+# 403: Requested feature (like "pickaxe" or "snapshot") not enabled on
+# this server or project.
+# 404: Requested object/revision/project doesn't exist.
+# 500: The server isn't configured properly, or
+# an internal error occurred (e.g. failed assertions caused by bugs), or
+# an unknown error occurred (e.g. the git binary died unexpectedly).
sub die_error {
- my $status = shift || "403 Forbidden";
- my $error = shift || "Malformed query, file missing or permission denied";
-
- git_header_html($status);
+ my $status = shift || 500;
+ my $error = shift || "Internal server error";
+
+ my %http_responses = (400 => '400 Bad Request',
+ 403 => '403 Forbidden',
+ 404 => '404 Not Found',
+ 500 => '500 Internal Server Error');
+ git_header_html($http_responses{$status});
print <<EOF;
<div class="page_body">
<br /><br />
@@ -2614,7 +2739,7 @@ sub git_print_page_nav {
}
sub format_paging_nav {
- my ($action, $hash, $head, $page, $nrevs) = @_;
+ my ($action, $hash, $head, $page, $has_next_link) = @_;
my $paging_nav;
@@ -2632,7 +2757,7 @@ sub format_paging_nav {
$paging_nav .= " &sdot; prev";
}
- if ($nrevs >= (100 * ($page+1)-1)) {
+ if ($has_next_link) {
$paging_nav .= " &sdot; " .
$cgi->a({-href => href(-replay=>1, page=>$page+1),
-accesskey => "n", -title => "Alt-n"}, "next");
@@ -2939,7 +3064,7 @@ sub fill_from_file_info {
sub is_deleted {
my $diffinfo = shift;
- return $diffinfo->{'status_str'} =~ /D/;
+ return $diffinfo->{'to_id'} eq ('0' x 40);
}
# does patch correspond to [previous] difftree raw line
@@ -3410,21 +3535,24 @@ sub git_patchset_body {
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
-sub git_project_list_body {
- my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
-
- my ($check_forks) = gitweb_check_feature('forks');
-
+# fills project list info (age, description, owner, forks) for each
+# project in the list, removing invalid projects from returned list
+# NOTE: modifies $projlist, but does not remove entries from it
+sub fill_project_list_info {
+ my ($projlist, $check_forks) = @_;
my @projects;
+
+ PROJECT:
foreach my $pr (@$projlist) {
- my (@aa) = git_get_last_activity($pr->{'path'});
- unless (@aa) {
- next;
+ my (@activity) = git_get_last_activity($pr->{'path'});
+ unless (@activity) {
+ next PROJECT;
}
- ($pr->{'age'}, $pr->{'age_string'}) = @aa;
+ ($pr->{'age'}, $pr->{'age_string'}) = @activity;
if (!defined $pr->{'descr'}) {
my $descr = git_get_project_description($pr->{'path'}) || "";
- $pr->{'descr_long'} = to_utf8($descr);
+ $descr = to_utf8($descr);
+ $pr->{'descr_long'} = $descr;
$pr->{'descr'} = chop_str($descr, $projects_list_description_width, 5);
}
if (!defined $pr->{'owner'}) {
@@ -3436,14 +3564,52 @@ sub git_project_list_body {
($pname !~ /\/$/) &&
(-d "$projectroot/$pname")) {
$pr->{'forks'} = "-d $projectroot/$pname";
- }
- else {
+ } else {
$pr->{'forks'} = 0;
}
}
push @projects, $pr;
}
+ return @projects;
+}
+
+# print 'sort by' <th> element, either sorting by $key if $name eq $order
+# (changing $list), or generating 'sort by $name' replay link otherwise
+sub print_sort_th {
+ my ($str_sort, $name, $order, $key, $header, $list) = @_;
+ $key ||= $name;
+ $header ||= ucfirst($name);
+
+ if ($order eq $name) {
+ if ($str_sort) {
+ @$list = sort {$a->{$key} cmp $b->{$key}} @$list;
+ } else {
+ @$list = sort {$a->{$key} <=> $b->{$key}} @$list;
+ }
+ print "<th>$header</th>\n";
+ } else {
+ print "<th>" .
+ $cgi->a({-href => href(-replay=>1, order=>$name),
+ -class => "header"}, $header) .
+ "</th>\n";
+ }
+}
+
+sub print_sort_th_str {
+ print_sort_th(1, @_);
+}
+
+sub print_sort_th_num {
+ print_sort_th(0, @_);
+}
+
+sub git_project_list_body {
+ my ($projlist, $order, $from, $to, $extra, $no_header) = @_;
+
+ my ($check_forks) = gitweb_check_feature('forks');
+ my @projects = fill_project_list_info($projlist, $check_forks);
+
$order ||= $default_projects_order;
$from = 0 unless defined $from;
$to = $#projects if (!defined $to || $#projects < $to);
@@ -3454,43 +3620,15 @@ sub git_project_list_body {
if ($check_forks) {
print "<th></th>\n";
}
- if ($order eq "project") {
- @projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
- print "<th>Project</th>\n";
- } else {
- print "<th>" .
- $cgi->a({-href => href(project=>undef, order=>'project'),
- -class => "header"}, "Project") .
- "</th>\n";
- }
- if ($order eq "descr") {
- @projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
- print "<th>Description</th>\n";
- } else {
- print "<th>" .
- $cgi->a({-href => href(project=>undef, order=>'descr'),
- -class => "header"}, "Description") .
- "</th>\n";
- }
- if ($order eq "owner") {
- @projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
- print "<th>Owner</th>\n";
- } else {
- print "<th>" .
- $cgi->a({-href => href(project=>undef, order=>'owner'),
- -class => "header"}, "Owner") .
- "</th>\n";
- }
- if ($order eq "age") {
- @projects = sort {$a->{'age'} <=> $b->{'age'}} @projects;
- print "<th>Last Change</th>\n";
- } else {
- print "<th>" .
- $cgi->a({-href => href(project=>undef, order=>'age'),
- -class => "header"}, "Last Change") .
- "</th>\n";
- }
- print "<th></th>\n" .
+ print_sort_th_str('project', $order, 'path',
+ 'Project', \@projects);
+ print_sort_th_str('descr', $order, 'descr_long',
+ 'Description', \@projects);
+ print_sort_th_str('owner', $order, 'owner',
+ 'Owner', \@projects);
+ print_sort_th_num('age', $order, 'age',
+ 'Last Change', \@projects);
+ print "<th></th>\n" . # for links
"</tr>\n";
}
my $alternate = 1;
@@ -3769,18 +3907,24 @@ sub git_search_grep_body {
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
"<td><i>" . $author . "</i></td>\n" .
"<td>" .
- $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}), -class => "list subject"},
- chop_and_escape_str($co{'title'}, 50) . "<br/>");
+ $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}),
+ -class => "list subject"},
+ chop_and_escape_str($co{'title'}, 50) . "<br/>");
my $comment = $co{'comment'};
foreach my $line (@$comment) {
- if ($line =~ m/^(.*)($search_regexp)(.*)$/i) {
- my $lead = esc_html($1) || "";
- $lead = chop_str($lead, 30, 10);
- my $match = esc_html($2) || "";
- my $trail = esc_html($3) || "";
- $trail = chop_str($trail, 30, 10);
- my $text = "$lead<span class=\"match\">$match</span>$trail";
- print chop_str($text, 80, 5) . "<br/>\n";
+ if ($line =~ m/^(.*?)($search_regexp)(.*)$/i) {
+ my ($lead, $match, $trail) = ($1, $2, $3);
+ $match = chop_str($match, 70, 5, 'center');
+ my $contextlen = int((80 - length($match))/2);
+ $contextlen = 30 if ($contextlen > 30);
+ $lead = chop_str($lead, $contextlen, 10, 'left');
+ $trail = chop_str($trail, $contextlen, 10, 'right');
+
+ $lead = esc_html($lead);
+ $match = esc_html($match);
+ $trail = esc_html($trail);
+
+ print "$lead<span class=\"match\">$match</span>$trail<br />";
}
}
print "</td>\n" .
@@ -3808,12 +3952,12 @@ sub git_search_grep_body {
sub git_project_list {
my $order = $cgi->param('o');
if (defined $order && $order !~ m/none|project|descr|owner|age/) {
- die_error(undef, "Unknown order parameter");
+ die_error(400, "Unknown order parameter");
}
my @list = git_get_projects_list();
if (!@list) {
- die_error(undef, "No projects found");
+ die_error(404, "No projects found");
}
git_header_html();
@@ -3831,12 +3975,12 @@ sub git_project_list {
sub git_forks {
my $order = $cgi->param('o');
if (defined $order && $order !~ m/none|project|descr|owner|age/) {
- die_error(undef, "Unknown order parameter");
+ die_error(400, "Unknown order parameter");
}
my @list = git_get_projects_list($project);
if (!@list) {
- die_error(undef, "No forks found");
+ die_error(404, "No forks found");
}
git_header_html();
@@ -3965,7 +4109,7 @@ sub git_tag {
my %tag = parse_tag($hash);
if (! %tag) {
- die_error(undef, "Unknown tag object");
+ die_error(404, "Unknown tag object");
}
git_print_header_div('commit', esc_html($tag{'name'}), $hash);
@@ -3997,30 +4141,29 @@ sub git_tag {
git_footer_html();
}
-sub git_blame2 {
+sub git_blame {
my $fd;
my $ftype;
- my ($have_blame) = gitweb_check_feature('blame');
- if (!$have_blame) {
- die_error('403 Permission denied', "Permission denied");
- }
- die_error('404 Not Found', "File name not defined") if (!$file_name);
+ gitweb_check_feature('blame')
+ or die_error(403, "Blame view not allowed");
+
+ die_error(400, "No file name given") unless $file_name;
$hash_base ||= git_get_head_hash($project);
- die_error(undef, "Couldn't find base commit") unless ($hash_base);
+ die_error(404, "Couldn't find base commit") unless ($hash_base);
my %co = parse_commit($hash_base)
- or die_error(undef, "Reading commit failed");
+ or die_error(404, "Commit not found");
if (!defined $hash) {
$hash = git_get_hash_by_path($hash_base, $file_name, "blob")
- or die_error(undef, "Error looking up file");
+ or die_error(404, "Error looking up file");
}
$ftype = git_get_type($hash);
if ($ftype !~ "blob") {
- die_error('400 Bad Request', "Object is not a blob");
+ die_error(400, "Object is not a blob");
}
open ($fd, "-|", git_cmd(), "blame", '-p', '--',
$file_name, $hash_base)
- or die_error(undef, "Open git-blame failed");
+ or die_error(500, "Open git-blame failed");
git_header_html();
my $formats_nav =
$cgi->a({-href => href(action=>"blob", -replay=>1)},
@@ -4082,7 +4225,7 @@ HTML
print "</td>\n";
}
open (my $dd, "-|", git_cmd(), "rev-parse", "$full_rev^")
- or die_error(undef, "Open git-rev-parse failed");
+ or die_error(500, "Open git-rev-parse failed");
my $parent_commit = <$dd>;
close $dd;
chomp($parent_commit);
@@ -4105,103 +4248,6 @@ HTML
git_footer_html();
}
-sub git_blame {
- my $fd;
-
- my ($have_blame) = gitweb_check_feature('blame');
- if (!$have_blame) {
- die_error('403 Permission denied', "Permission denied");
- }
- die_error('404 Not Found', "File name not defined") if (!$file_name);
- $hash_base ||= git_get_head_hash($project);
- die_error(undef, "Couldn't find base commit") unless ($hash_base);
- my %co = parse_commit($hash_base)
- or die_error(undef, "Reading commit failed");
- if (!defined $hash) {
- $hash = git_get_hash_by_path($hash_base, $file_name, "blob")
- or die_error(undef, "Error lookup file");
- }
- open ($fd, "-|", git_cmd(), "annotate", '-l', '-t', '-r', $file_name, $hash_base)
- or die_error(undef, "Open git-annotate failed");
- git_header_html();
- my $formats_nav =
- $cgi->a({-href => href(action=>"blob", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
- "blob") .
- " | " .
- $cgi->a({-href => href(action=>"history", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},
- "history") .
- " | " .
- $cgi->a({-href => href(action=>"blame", file_name=>$file_name)},
- "HEAD");
- git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
- git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
- git_print_page_path($file_name, 'blob', $hash_base);
- print "<div class=\"page_body\">\n";
- print <<HTML;
-<table class="blame">
- <tr>
- <th>Commit</th>
- <th>Age</th>
- <th>Author</th>
- <th>Line</th>
- <th>Data</th>
- </tr>
-HTML
- my @line_class = (qw(light dark));
- my $line_class_len = scalar (@line_class);
- my $line_class_num = $#line_class;
- while (my $line = <$fd>) {
- my $long_rev;
- my $short_rev;
- my $author;
- my $time;
- my $lineno;
- my $data;
- my $age;
- my $age_str;
- my $age_class;
-
- chomp $line;
- $line_class_num = ($line_class_num + 1) % $line_class_len;
-
- if ($line =~ m/^([0-9a-fA-F]{40})\t\(\s*([^\t]+)\t(\d+) [+-]\d\d\d\d\t(\d+)\)(.*)$/) {
- $long_rev = $1;
- $author = $2;
- $time = $3;
- $lineno = $4;
- $data = $5;
- } else {
- print qq( <tr><td colspan="5" class="error">Unable to parse: $line</td></tr>\n);
- next;
- }
- $short_rev = substr ($long_rev, 0, 8);
- $age = time () - $time;
- $age_str = age_string ($age);
- $age_str =~ s/ /&nbsp;/g;
- $age_class = age_class($age);
- $author = esc_html ($author);
- $author =~ s/ /&nbsp;/g;
-
- $data = untabify($data);
- $data = esc_html ($data);
-
- print <<HTML;
- <tr class="$line_class[$line_class_num]">
- <td class="sha1"><a href="${\href (action=>"commit", hash=>$long_rev)}" class="text">$short_rev..</a></td>
- <td class="$age_class">$age_str</td>
- <td>$author</td>
- <td class="linenr"><a id="$lineno" href="#$lineno" class="linenr">$lineno</a></td>
- <td class="pre">$data</td>
- </tr>
-HTML
- } # while (my $line = <$fd>)
- print "</table>\n\n";
- close $fd
- or print "Reading blob failed.\n";
- print "</div>";
- git_footer_html();
-}
-
sub git_tags {
my $head = git_get_head_hash($project);
git_header_html();
@@ -4229,28 +4275,29 @@ sub git_heads {
}
sub git_blob_plain {
+ my $type = shift;
my $expires;
if (!defined $hash) {
if (defined $file_name) {
my $base = $hash_base || git_get_head_hash($project);
$hash = git_get_hash_by_path($base, $file_name, "blob")
- or die_error(undef, "Error lookup file");
+ or die_error(404, "Cannot find file");
} else {
- die_error(undef, "No file name defined");
+ die_error(400, "No file name defined");
}
} elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
# blobs defined by non-textual hash id's can be cached
$expires = "+1d";
}
- my $type = shift;
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
- or die_error(undef, "Couldn't cat $file_name, $hash");
+ or die_error(500, "Open git-cat-file blob '$hash' failed");
- $type ||= blob_mimetype($fd, $file_name);
+ # content-type (can include charset)
+ $type = blob_contenttype($fd, $file_name, $type);
- # save as filename, even when no $file_name is given
+ # "save as" filename, even when no $file_name is given
my $save_as = "$hash";
if (defined $file_name) {
$save_as = $file_name;
@@ -4259,9 +4306,9 @@ sub git_blob_plain {
}
print $cgi->header(
- -type => "$type",
- -expires=>$expires,
- -content_disposition => 'inline; filename="' . "$save_as" . '"');
+ -type => $type,
+ -expires => $expires,
+ -content_disposition => 'inline; filename="' . $save_as . '"');
undef $/;
binmode STDOUT, ':raw';
print <$fd>;
@@ -4277,9 +4324,9 @@ sub git_blob {
if (defined $file_name) {
my $base = $hash_base || git_get_head_hash($project);
$hash = git_get_hash_by_path($base, $file_name, "blob")
- or die_error(undef, "Error lookup file");
+ or die_error(404, "Cannot find file");
} else {
- die_error(undef, "No file name defined");
+ die_error(400, "No file name defined");
}
} elsif ($hash =~ m/^[0-9a-fA-F]{40}$/) {
# blobs defined by non-textual hash id's can be cached
@@ -4288,7 +4335,7 @@ sub git_blob {
my ($have_blame) = gitweb_check_feature('blame');
open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
- or die_error(undef, "Couldn't cat $file_name, $hash");
+ or die_error(500, "Couldn't cat $file_name, $hash");
my $mimetype = blob_mimetype($fd, $file_name);
if ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)! && -B $fd) {
close $fd;
@@ -4369,9 +4416,9 @@ sub git_tree {
}
$/ = "\0";
open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
- or die_error(undef, "Open git-ls-tree failed");
+ or die_error(500, "Open git-ls-tree failed");
my @entries = map { chomp; $_ } <$fd>;
- close $fd or die_error(undef, "Reading tree failed");
+ close $fd or die_error(404, "Reading tree failed");
$/ = "\n";
my $refs = git_get_references();
@@ -4461,23 +4508,22 @@ sub git_snapshot {
my $format = $cgi->param('sf');
if (!@supported_fmts) {
- die_error('403 Permission denied', "Permission denied");
+ die_error(403, "Snapshots not allowed");
}
# default to first supported snapshot format
$format ||= $supported_fmts[0];
if ($format !~ m/^[a-z0-9]+$/) {
- die_error(undef, "Invalid snapshot format parameter");
+ die_error(400, "Invalid snapshot format parameter");
} elsif (!exists($known_snapshot_formats{$format})) {
- die_error(undef, "Unknown snapshot format");
+ die_error(400, "Unknown snapshot format");
} elsif (!grep($_ eq $format, @supported_fmts)) {
- die_error(undef, "Unsupported snapshot format");
+ die_error(403, "Unsupported snapshot format");
}
if (!defined $hash) {
$hash = git_get_head_hash($project);
}
- my $git_command = git_cmd_str();
my $name = $project;
$name =~ s,([^/])/*\.git$,$1,;
$name = basename($name);
@@ -4485,11 +4531,12 @@ sub git_snapshot {
$name =~ s/\047/\047\\\047\047/g;
my $cmd;
$filename .= "-$hash$known_snapshot_formats{$format}{'suffix'}";
- $cmd = "$git_command archive " .
- "--format=$known_snapshot_formats{$format}{'format'} " .
- "--prefix=\'$name\'/ $hash";
+ $cmd = quote_command(
+ git_cmd(), 'archive',
+ "--format=$known_snapshot_formats{$format}{'format'}",
+ "--prefix=$name/", $hash);
if (exists $known_snapshot_formats{$format}{'compressor'}) {
- $cmd .= ' | ' . join ' ', @{$known_snapshot_formats{$format}{'compressor'}};
+ $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});
}
print $cgi->header(
@@ -4498,7 +4545,7 @@ sub git_snapshot {
-status => '200 OK');
open my $fd, "-|", $cmd
- or die_error(undef, "Execute git-archive failed");
+ or die_error(500, "Execute git-archive failed");
binmode STDOUT, ':raw';
print <$fd>;
binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
@@ -4517,7 +4564,7 @@ sub git_log {
my @commitlist = parse_commits($hash, 101, (100 * $page));
- my $paging_nav = format_paging_nav('log', $hash, $head, $page, (100 * ($page+1)));
+ my $paging_nav = format_paging_nav('log', $hash, $head, $page, $#commitlist >= 100);
git_header_html();
git_print_page_nav('log','', $hash,undef,undef, $paging_nav);
@@ -4566,10 +4613,8 @@ sub git_log {
sub git_commit {
$hash ||= $hash_base || "HEAD";
- my %co = parse_commit($hash);
- if (!%co) {
- die_error(undef, "Unknown commit object");
- }
+ my %co = parse_commit($hash)
+ or die_error(404, "Unknown commit object");
my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
@@ -4609,9 +4654,9 @@ sub git_commit {
@diff_opts,
(@$parents <= 1 ? $parent : '-c'),
$hash, "--"
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
@difftree = map { chomp; $_ } <$fd>;
- close $fd or die_error(undef, "Reading git-diff-tree failed");
+ close $fd or die_error(404, "Reading git-diff-tree failed");
# non-textual hash id's can be cached
my $expires;
@@ -4702,35 +4747,35 @@ sub git_object {
if ($hash || ($hash_base && !defined $file_name)) {
my $object_id = $hash || $hash_base;
- my $git_command = git_cmd_str();
- open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
- or die_error('404 Not Found', "Object does not exist");
+ open my $fd, "-|", quote_command(
+ git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null'
+ or die_error(404, "Object does not exist");
$type = <$fd>;
chomp $type;
close $fd
- or die_error('404 Not Found', "Object does not exist");
+ or die_error(404, "Object does not exist");
# - hash_base and file_name
} elsif ($hash_base && defined $file_name) {
$file_name =~ s,/+$,,;
system(git_cmd(), "cat-file", '-e', $hash_base) == 0
- or die_error('404 Not Found', "Base object does not exist");
+ or die_error(404, "Base object does not exist");
# here errors should not hapen
open my $fd, "-|", git_cmd(), "ls-tree", $hash_base, "--", $file_name
- or die_error(undef, "Open git-ls-tree failed");
+ or die_error(500, "Open git-ls-tree failed");
my $line = <$fd>;
close $fd;
#'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa panic.c'
unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
- die_error('404 Not Found', "File or directory for given base does not exist");
+ die_error(404, "File or directory for given base does not exist");
}
$type = $2;
$hash = $3;
} else {
- die_error('404 Not Found', "Not enough information to find object");
+ die_error(400, "Not enough information to find object");
}
print $cgi->redirect(-uri => href(action=>$type, -full=>1,
@@ -4755,12 +4800,12 @@ sub git_blobdiff {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
$hash_parent_base, $hash_base,
"--", (defined $file_parent ? $file_parent : ()), $file_name
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
@difftree = map { chomp; $_ } <$fd>;
close $fd
- or die_error(undef, "Reading git-diff-tree failed");
+ or die_error(404, "Reading git-diff-tree failed");
@difftree
- or die_error('404 Not Found', "Blob diff not found");
+ or die_error(404, "Blob diff not found");
} elsif (defined $hash &&
$hash =~ /[0-9a-fA-F]{40}/) {
@@ -4769,23 +4814,23 @@ sub git_blobdiff {
# read filtered raw output
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
$hash_parent_base, $hash_base, "--"
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
@difftree =
# ':100644 100644 03b21826... 3b93d5e7... M ls-files.c'
# $hash == to_id
grep { /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} $hash/ }
map { chomp; $_ } <$fd>;
close $fd
- or die_error(undef, "Reading git-diff-tree failed");
+ or die_error(404, "Reading git-diff-tree failed");
@difftree
- or die_error('404 Not Found', "Blob diff not found");
+ or die_error(404, "Blob diff not found");
} else {
- die_error('404 Not Found', "Missing one of the blob diff parameters");
+ die_error(400, "Missing one of the blob diff parameters");
}
if (@difftree > 1) {
- die_error('404 Not Found', "Ambiguous blob diff specification");
+ die_error(400, "Ambiguous blob diff specification");
}
%diffinfo = parse_difftree_raw_line($difftree[0]);
@@ -4806,7 +4851,7 @@ sub git_blobdiff {
'-p', ($format eq 'html' ? "--full-index" : ()),
$hash_parent_base, $hash_base,
"--", (defined $file_parent ? $file_parent : ()), $file_name
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
}
# old/legacy style URI
@@ -4842,9 +4887,9 @@ sub git_blobdiff {
open $fd, "-|", git_cmd(), "diff", @diff_opts,
'-p', ($format eq 'html' ? "--full-index" : ()),
$hash_parent, $hash, "--"
- or die_error(undef, "Open git-diff failed");
+ or die_error(500, "Open git-diff failed");
} else {
- die_error('404 Not Found', "Missing one of the blob diff parameters")
+ die_error(400, "Missing one of the blob diff parameters")
unless %diffinfo;
}
@@ -4877,7 +4922,7 @@ sub git_blobdiff {
print "X-Git-Url: " . $cgi->self_url() . "\n\n";
} else {
- die_error(undef, "Unknown blobdiff format");
+ die_error(400, "Unknown blobdiff format");
}
# patch
@@ -4912,10 +4957,8 @@ sub git_blobdiff_plain {
sub git_commitdiff {
my $format = shift || 'html';
$hash ||= $hash_base || "HEAD";
- my %co = parse_commit($hash);
- if (!%co) {
- die_error(undef, "Unknown commit object");
- }
+ my %co = parse_commit($hash)
+ or die_error(404, "Unknown commit object");
# choose format for commitdiff for merge
if (! defined $hash_parent && @{$co{'parents'}} > 1) {
@@ -4997,7 +5040,7 @@ sub git_commitdiff {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
"--no-commit-id", "--patch-with-raw", "--full-index",
$hash_parent_param, $hash, "--"
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
while (my $line = <$fd>) {
chomp $line;
@@ -5009,10 +5052,10 @@ sub git_commitdiff {
} elsif ($format eq 'plain') {
open $fd, "-|", git_cmd(), "diff-tree", '-r', @diff_opts,
'-p', $hash_parent_param, $hash, "--"
- or die_error(undef, "Open git-diff-tree failed");
+ or die_error(500, "Open git-diff-tree failed");
} else {
- die_error(undef, "Unknown commitdiff format");
+ die_error(400, "Unknown commitdiff format");
}
# non-textual hash id's can be cached
@@ -5048,16 +5091,15 @@ sub git_commitdiff {
-expires => $expires,
-content_disposition => 'inline; filename="' . "$filename" . '"');
my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
- print <<TEXT;
-From: $co{'author'}
-Date: $ad{'rfc2822'} ($ad{'tz_local'})
-Subject: $co{'title'}
-TEXT
+ print "From: " . to_utf8($co{'author'}) . "\n";
+ print "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n";
+ print "Subject: " . to_utf8($co{'title'}) . "\n";
+
print "X-Git-Tag: $tagname\n" if $tagname;
print "X-Git-Url: " . $cgi->self_url() . "\n\n";
foreach my $line (@{$co{'comment'}}) {
- print "$line\n";
+ print to_utf8($line) . "\n";
}
print "---\n\n";
}
@@ -5096,22 +5138,30 @@ sub git_history {
$page = 0;
}
my $ftype;
- my %co = parse_commit($hash_base);
- if (!%co) {
- die_error(undef, "Unknown commit object");
- }
+ my %co = parse_commit($hash_base)
+ or die_error(404, "Unknown commit object");
my $refs = git_get_references();
my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
+ my @commitlist = parse_commits($hash_base, 101, (100 * $page),
+ $file_name, "--full-history")
+ or die_error(404, "No such file or directory on given branch");
+
if (!defined $hash && defined $file_name) {
- $hash = git_get_hash_by_path($hash_base, $file_name);
+ # some commits could have deleted file in question,
+ # and not have it in tree, but one of them has to have it
+ for (my $i = 0; $i <= @commitlist; $i++) {
+ $hash = git_get_hash_by_path($commitlist[$i]{'id'}, $file_name);
+ last if defined $hash;
+ }
}
if (defined $hash) {
$ftype = git_get_type($hash);
}
-
- my @commitlist = parse_commits($hash_base, 101, (100 * $page), "--full-history", $file_name);
+ if (!defined $ftype) {
+ die_error(500, "Unknown type of object");
+ }
my $paging_nav = '';
if ($page > 0) {
@@ -5148,19 +5198,16 @@ sub git_history {
}
sub git_search {
- my ($have_search) = gitweb_check_feature('search');
- if (!$have_search) {
- die_error('403 Permission denied', "Permission denied");
- }
+ gitweb_check_feature('search') or die_error(403, "Search is disabled");
if (!defined $searchtext) {
- die_error(undef, "Text field empty");
+ die_error(400, "Text field is empty");
}
if (!defined $hash) {
$hash = git_get_head_hash($project);
}
my %co = parse_commit($hash);
if (!%co) {
- die_error(undef, "Unknown commit object");
+ die_error(404, "Unknown commit object");
}
if (!defined $page) {
$page = 0;
@@ -5170,16 +5217,12 @@ sub git_search {
if ($searchtype eq 'pickaxe') {
# pickaxe may take all resources of your box and run for several minutes
# with every query - so decide by yourself how public you make this feature
- my ($have_pickaxe) = gitweb_check_feature('pickaxe');
- if (!$have_pickaxe) {
- die_error('403 Permission denied', "Permission denied");
- }
+ gitweb_check_feature('pickaxe')
+ or die_error(403, "Pickaxe is disabled");
}
if ($searchtype eq 'grep') {
- my ($have_grep) = gitweb_check_feature('grep');
- if (!$have_grep) {
- die_error('403 Permission denied', "Permission denied");
- }
+ gitweb_check_feature('grep')
+ or die_error(403, "Grep is disabled");
}
git_header_html();
@@ -5193,14 +5236,17 @@ sub git_search {
} elsif ($searchtype eq 'committer') {
$greptype = "--committer=";
}
- $greptype .= $search_regexp;
- my @commitlist = parse_commits($hash, 101, (100 * $page), $greptype);
+ $greptype .= $searchtext;
+ my @commitlist = parse_commits($hash, 101, (100 * $page), undef,
+ $greptype, '--regexp-ignore-case',
+ $search_use_regexp ? '--extended-regexp' : '--fixed-strings');
my $paging_nav = '';
if ($page > 0) {
$paging_nav .=
$cgi->a({-href => href(action=>"search", hash=>$hash,
- searchtext=>$searchtext, searchtype=>$searchtype)},
+ searchtext=>$searchtext,
+ searchtype=>$searchtype)},
"first");
$paging_nav .= " &sdot; " .
$cgi->a({-href => href(-replay=>1, page=>$page-1),
@@ -5234,50 +5280,19 @@ sub git_search {
print "<table class=\"pickaxe search\">\n";
my $alternate = 1;
$/ = "\n";
- my $git_command = git_cmd_str();
- my $searchqtext = $searchtext;
- $searchqtext =~ s/'/'\\''/;
- open my $fd, "-|", "$git_command rev-list $hash | " .
- "$git_command diff-tree -r --stdin -S\'$searchqtext\'";
+ open my $fd, '-|', git_cmd(), '--no-pager', 'log', @diff_opts,
+ '--pretty=format:%H', '--no-abbrev', '--raw', "-S$searchtext",
+ ($search_use_regexp ? '--pickaxe-regex' : ());
undef %co;
my @files;
while (my $line = <$fd>) {
- if (%co && $line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$/) {
- my %set;
- $set{'file'} = $6;
- $set{'from_id'} = $3;
- $set{'to_id'} = $4;
- $set{'id'} = $set{'to_id'};
- if ($set{'id'} =~ m/0{40}/) {
- $set{'id'} = $set{'from_id'};
- }
- if ($set{'id'} =~ m/0{40}/) {
- next;
- }
- push @files, \%set;
- } elsif ($line =~ m/^([0-9a-fA-F]{40})$/){
+ chomp $line;
+ next unless $line;
+
+ my %set = parse_difftree_raw_line($line);
+ if (defined $set{'commit'}) {
+ # finish previous commit
if (%co) {
- if ($alternate) {
- print "<tr class=\"dark\">\n";
- } else {
- print "<tr class=\"light\">\n";
- }
- $alternate ^= 1;
- my $author = chop_and_escape_str($co{'author_name'}, 15, 5);
- print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
- "<td><i>" . $author . "</i></td>\n" .
- "<td>" .
- $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}),
- -class => "list subject"},
- chop_and_escape_str($co{'title'}, 50) . "<br/>");
- while (my $setref = shift @files) {
- my %set = %$setref;
- print $cgi->a({-href => href(action=>"blob", hash_base=>$co{'id'},
- hash=>$set{'id'}, file_name=>$set{'file'}),
- -class => "list"},
- "<span class=\"match\">" . esc_path($set{'file'}) . "</span>") .
- "<br/>\n";
- }
print "</td>\n" .
"<td class=\"link\">" .
$cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") .
@@ -5286,11 +5301,44 @@ sub git_search {
print "</td>\n" .
"</tr>\n";
}
- %co = parse_commit($1);
+
+ if ($alternate) {
+ print "<tr class=\"dark\">\n";
+ } else {
+ print "<tr class=\"light\">\n";
+ }
+ $alternate ^= 1;
+ %co = parse_commit($set{'commit'});
+ my $author = chop_and_escape_str($co{'author_name'}, 15, 5);
+ print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
+ "<td><i>$author</i></td>\n" .
+ "<td>" .
+ $cgi->a({-href => href(action=>"commit", hash=>$co{'id'}),
+ -class => "list subject"},
+ chop_and_escape_str($co{'title'}, 50) . "<br/>");
+ } elsif (defined $set{'to_id'}) {
+ next if ($set{'to_id'} =~ m/^0{40}$/);
+
+ print $cgi->a({-href => href(action=>"blob", hash_base=>$co{'id'},
+ hash=>$set{'to_id'}, file_name=>$set{'to_file'}),
+ -class => "list"},
+ "<span class=\"match\">" . esc_path($set{'file'}) . "</span>") .
+ "<br/>\n";
}
}
close $fd;
+ # finish last commit (warning: repetition!)
+ if (%co) {
+ print "</td>\n" .
+ "<td class=\"link\">" .
+ $cgi->a({-href => href(action=>"commit", hash=>$co{'id'})}, "commit") .
+ " | " .
+ $cgi->a({-href => href(action=>"tree", hash=>$co{'tree'}, hash_base=>$co{'id'})}, "tree");
+ print "</td>\n" .
+ "</tr>\n";
+ }
+
print "</table>\n";
}
@@ -5302,7 +5350,9 @@ sub git_search {
my $alternate = 1;
my $matches = 0;
$/ = "\n";
- open my $fd, "-|", git_cmd(), 'grep', '-n', '-i', '-E', $searchtext, $co{'tree'};
+ open my $fd, "-|", git_cmd(), 'grep', '-n',
+ $search_use_regexp ? ('-E', '-i') : '-F',
+ $searchtext, $co{'tree'};
my $lastfile = '';
while (my $line = <$fd>) {
chomp $line;
@@ -5332,7 +5382,7 @@ sub git_search {
print "<div class=\"binary\">Binary file</div>\n";
} else {
$ltext = untabify($ltext);
- if ($ltext =~ m/^(.*)($searchtext)(.*)$/i) {
+ if ($ltext =~ m/^(.*)($search_regexp)(.*)$/i) {
$ltext = esc_html($1, -nbsp=>1);
$ltext .= '<span class="match">';
$ltext .= esc_html($2, -nbsp=>1);
@@ -5367,27 +5417,31 @@ sub git_search_help {
git_header_html();
git_print_page_nav('','', $hash,$hash,$hash);
print <<EOT;
+<p><strong>Pattern</strong> is by default a normal string that is matched precisely (but without
+regard to case, except in the case of pickaxe). However, when you check the <em>re</em> checkbox,
+the pattern entered is recognized as the POSIX extended
+<a href="http://en.wikipedia.org/wiki/Regular_expression">regular expression</a> (also case
+insensitive).</p>
<dl>
<dt><b>commit</b></dt>
-<dd>The commit messages and authorship information will be scanned for the given string.</dd>
+<dd>The commit messages and authorship information will be scanned for the given pattern.</dd>
EOT
my ($have_grep) = gitweb_check_feature('grep');
if ($have_grep) {
print <<EOT;
<dt><b>grep</b></dt>
<dd>All files in the currently selected tree (HEAD unless you are explicitly browsing
- a different one) are searched for the given
-<a href="http://en.wikipedia.org/wiki/Regular_expression">regular expression</a>
-(POSIX extended) and the matches are listed. On large
-trees, this search can take a while and put some strain on the server, so please use it with
-some consideration.</dd>
+ a different one) are searched for the given pattern. On large trees, this search can take
+a while and put some strain on the server, so please use it with some consideration. Note that
+due to git-grep peculiarity, currently if regexp mode is turned off, the matches are
+case-sensitive.</dd>
EOT
}
print <<EOT;
<dt><b>author</b></dt>
-<dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given string.</dd>
+<dd>Name and e-mail of the change author and date of birth of the patch will be scanned for the given pattern.</dd>
<dt><b>committer</b></dt>
-<dd>Name and e-mail of the committer and date of commit will be scanned for the given string.</dd>
+<dd>Name and e-mail of the committer and date of commit will be scanned for the given pattern.</dd>
EOT
my ($have_pickaxe) = gitweb_check_feature('pickaxe');
if ($have_pickaxe) {
@@ -5395,7 +5449,8 @@ EOT
<dt><b>pickaxe</b></dt>
<dd>All commits that caused the string to appear or disappear from any file (changes that
added, removed or "modified" the string) will be listed. This search can take a while and
-takes a lot of strain on the server, so please use it wisely.</dd>
+takes a lot of strain on the server, so please use it wisely. Note that since you may be
+interested even in changes just changing the case as well, this search is case sensitive.</dd>
EOT
}
print "</dl>\n";
@@ -5414,7 +5469,7 @@ sub git_shortlog {
my @commitlist = parse_commits($hash, 101, (100 * $page));
- my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, (100 * ($page+1)));
+ my $paging_nav = format_paging_nav('shortlog', $hash, $head, $page, $#commitlist >= 100);
my $next_link = '';
if ($#commitlist >= 100) {
$next_link =
@@ -5441,12 +5496,12 @@ sub git_feed {
# Atom: http://www.atomenabled.org/developers/syndication/
# RSS: http://www.notestips.com/80256B3A007F2692/1/NAMO5P9UPQ
if ($format ne 'rss' && $format ne 'atom') {
- die_error(undef, "Unknown web feed format");
+ die_error(400, "Unknown web feed format");
}
# log/feed of current (HEAD) branch, log of given branch, history of file/directory
my $head = $hash || 'HEAD';
- my @commitlist = parse_commits($head, 150, 0, undef, $file_name);
+ my @commitlist = parse_commits($head, 150, 0, $file_name);
my %latest_commit;
my %latest_date;
@@ -5566,7 +5621,7 @@ XML
or next;
# print element (entry, item)
- my $co_url = href(-full=>1, action=>"commit", hash=>$commit);
+ my $co_url = href(-full=>1, action=>"commitdiff", hash=>$commit);
if ($format eq 'rss') {
print "<item>\n" .
"<title>" . esc_html($co{'title'}) . "</title>\n" .
diff --git a/gitweb/test/Märchen b/gitweb/test/Märchen
deleted file mode 100644
index 8f7a1d3e9..000000000
--- a/gitweb/test/Märchen
+++ /dev/null
@@ -1,2 +0,0 @@
-Märchen
-Märchen
diff --git a/gitweb/test/file with spaces b/gitweb/test/file with spaces
deleted file mode 100644
index f108543c4..000000000
--- a/gitweb/test/file with spaces
+++ /dev/null
@@ -1,4 +0,0 @@
-This
-filename
-contains
-spaces.
diff --git a/gitweb/test/file+plus+sign b/gitweb/test/file+plus+sign
deleted file mode 100644
index fd0527880..000000000
--- a/gitweb/test/file+plus+sign
+++ /dev/null
@@ -1,6 +0,0 @@
-This
-filename
-contains
-+
-plus
-chars.
diff --git a/graph.c b/graph.c
new file mode 100644
index 000000000..e2633f837
--- /dev/null
+++ b/graph.c
@@ -0,0 +1,1132 @@
+#include "cache.h"
+#include "commit.h"
+#include "graph.h"
+#include "diff.h"
+#include "revision.h"
+
+/*
+ * TODO:
+ * - Add colors to the graph.
+ * Pick a color for each column, and print all characters
+ * in that column with the specified color.
+ *
+ * - Limit the number of columns, similar to the way gitk does.
+ * If we reach more than a specified number of columns, omit
+ * sections of some columns.
+ *
+ * - The output during the GRAPH_PRE_COMMIT and GRAPH_COLLAPSING states
+ * could be made more compact by printing horizontal lines, instead of
+ * long diagonal lines. For example, during collapsing, something like
+ * this: instead of this:
+ * | | | | | | | | | |
+ * | |_|_|/ | | | |/
+ * |/| | | | | |/|
+ * | | | | | |/| |
+ * |/| | |
+ * | | | |
+ *
+ * If there are several parallel diagonal lines, they will need to be
+ * replaced with horizontal lines on subsequent rows.
+ */
+
+struct column {
+ /*
+ * The parent commit of this column.
+ */
+ struct commit *commit;
+ /*
+ * XXX: Once we add support for colors, struct column could also
+ * contain the color of its branch line.
+ */
+};
+
+enum graph_state {
+ GRAPH_PADDING,
+ GRAPH_SKIP,
+ GRAPH_PRE_COMMIT,
+ GRAPH_COMMIT,
+ GRAPH_POST_MERGE,
+ GRAPH_COLLAPSING
+};
+
+struct git_graph {
+ /*
+ * The commit currently being processed
+ */
+ struct commit *commit;
+ /* The rev-info used for the current traversal */
+ struct rev_info *revs;
+ /*
+ * The number of interesting parents that this commit has.
+ *
+ * Note that this is not the same as the actual number of parents.
+ * This count excludes parents that won't be printed in the graph
+ * output, as determined by graph_is_interesting().
+ */
+ int num_parents;
+ /*
+ * The width of the graph output for this commit.
+ * All rows for this commit are padded to this width, so that
+ * messages printed after the graph output are aligned.
+ */
+ int width;
+ /*
+ * The next expansion row to print
+ * when state is GRAPH_PRE_COMMIT
+ */
+ int expansion_row;
+ /*
+ * The current output state.
+ * This tells us what kind of line graph_next_line() should output.
+ */
+ enum graph_state state;
+ /*
+ * The output state for the previous line of output.
+ * This is primarily used to determine how the first merge line
+ * should appear, based on the last line of the previous commit.
+ */
+ enum graph_state prev_state;
+ /*
+ * The index of the column that refers to this commit.
+ *
+ * If none of the incoming columns refer to this commit,
+ * this will be equal to num_columns.
+ */
+ int commit_index;
+ /*
+ * The commit_index for the previously displayed commit.
+ *
+ * This is used to determine how the first line of a merge
+ * graph output should appear, based on the last line of the
+ * previous commit.
+ */
+ int prev_commit_index;
+ /*
+ * The maximum number of columns that can be stored in the columns
+ * and new_columns arrays. This is also half the number of entries
+ * that can be stored in the mapping and new_mapping arrays.
+ */
+ int column_capacity;
+ /*
+ * The number of columns (also called "branch lines" in some places)
+ */
+ int num_columns;
+ /*
+ * The number of columns in the new_columns array
+ */
+ int num_new_columns;
+ /*
+ * The number of entries in the mapping array
+ */
+ int mapping_size;
+ /*
+ * The column state before we output the current commit.
+ */
+ struct column *columns;
+ /*
+ * The new column state after we output the current commit.
+ * Only valid when state is GRAPH_COLLAPSING.
+ */
+ struct column *new_columns;
+ /*
+ * An array that tracks the current state of each
+ * character in the output line during state GRAPH_COLLAPSING.
+ * Each entry is -1 if this character is empty, or a non-negative
+ * integer if the character contains a branch line. The value of
+ * the integer indicates the target position for this branch line.
+ * (I.e., this array maps the current column positions to their
+ * desired positions.)
+ *
+ * The maximum capacity of this array is always
+ * sizeof(int) * 2 * column_capacity.
+ */
+ int *mapping;
+ /*
+ * A temporary array for computing the next mapping state
+ * while we are outputting a mapping line. This is stored as part
+ * of the git_graph simply so we don't have to allocate a new
+ * temporary array each time we have to output a collapsing line.
+ */
+ int *new_mapping;
+};
+
+struct git_graph *graph_init(struct rev_info *opt)
+{
+ struct git_graph *graph = xmalloc(sizeof(struct git_graph));
+ graph->commit = NULL;
+ graph->revs = opt;
+ graph->num_parents = 0;
+ graph->expansion_row = 0;
+ graph->state = GRAPH_PADDING;
+ graph->prev_state = GRAPH_PADDING;
+ graph->commit_index = 0;
+ graph->prev_commit_index = 0;
+ graph->num_columns = 0;
+ graph->num_new_columns = 0;
+ graph->mapping_size = 0;
+
+ /*
+ * Allocate a reasonably large default number of columns
+ * We'll automatically grow columns later if we need more room.
+ */
+ graph->column_capacity = 30;
+ graph->columns = xmalloc(sizeof(struct column) *
+ graph->column_capacity);
+ graph->new_columns = xmalloc(sizeof(struct column) *
+ graph->column_capacity);
+ graph->mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
+ graph->new_mapping = xmalloc(sizeof(int) * 2 * graph->column_capacity);
+
+ return graph;
+}
+
+void graph_release(struct git_graph *graph)
+{
+ free(graph->columns);
+ free(graph->new_columns);
+ free(graph->mapping);
+ free(graph);
+}
+
+static void graph_update_state(struct git_graph *graph, enum graph_state s)
+{
+ graph->prev_state = graph->state;
+ graph->state = s;
+}
+
+static void graph_ensure_capacity(struct git_graph *graph, int num_columns)
+{
+ if (graph->column_capacity >= num_columns)
+ return;
+
+ do {
+ graph->column_capacity *= 2;
+ } while (graph->column_capacity < num_columns);
+
+ graph->columns = xrealloc(graph->columns,
+ sizeof(struct column) *
+ graph->column_capacity);
+ graph->new_columns = xrealloc(graph->new_columns,
+ sizeof(struct column) *
+ graph->column_capacity);
+ graph->mapping = xrealloc(graph->mapping,
+ sizeof(int) * 2 * graph->column_capacity);
+ graph->new_mapping = xrealloc(graph->new_mapping,
+ sizeof(int) * 2 * graph->column_capacity);
+}
+
+/*
+ * Returns 1 if the commit will be printed in the graph output,
+ * and 0 otherwise.
+ */
+static int graph_is_interesting(struct git_graph *graph, struct commit *commit)
+{
+ /*
+ * If revs->boundary is set, commits whose children have
+ * been shown are always interesting, even if they have the
+ * UNINTERESTING or TREESAME flags set.
+ */
+ if (graph->revs && graph->revs->boundary) {
+ if (commit->object.flags & CHILD_SHOWN)
+ return 1;
+ }
+
+ /*
+ * Uninteresting and pruned commits won't be printed
+ */
+ return (commit->object.flags & (UNINTERESTING | TREESAME)) ? 0 : 1;
+}
+
+static struct commit_list *next_interesting_parent(struct git_graph *graph,
+ struct commit_list *orig)
+{
+ struct commit_list *list;
+
+ /*
+ * If revs->first_parent_only is set, only the first
+ * parent is interesting. None of the others are.
+ */
+ if (graph->revs->first_parent_only)
+ return NULL;
+
+ /*
+ * Return the next interesting commit after orig
+ */
+ for (list = orig->next; list; list = list->next) {
+ if (graph_is_interesting(graph, list->item))
+ return list;
+ }
+
+ return NULL;
+}
+
+static struct commit_list *first_interesting_parent(struct git_graph *graph)
+{
+ struct commit_list *parents = graph->commit->parents;
+
+ /*
+ * If this commit has no parents, ignore it
+ */
+ if (!parents)
+ return NULL;
+
+ /*
+ * If the first parent is interesting, return it
+ */
+ if (graph_is_interesting(graph, parents->item))
+ return parents;
+
+ /*
+ * Otherwise, call next_interesting_parent() to get
+ * the next interesting parent
+ */
+ return next_interesting_parent(graph, parents);
+}
+
+static void graph_insert_into_new_columns(struct git_graph *graph,
+ struct commit *commit,
+ int *mapping_index)
+{
+ int i;
+
+ /*
+ * If the commit is already in the new_columns list, we don't need to
+ * add it. Just update the mapping correctly.
+ */
+ for (i = 0; i < graph->num_new_columns; i++) {
+ if (graph->new_columns[i].commit == commit) {
+ graph->mapping[*mapping_index] = i;
+ *mapping_index += 2;
+ return;
+ }
+ }
+
+ /*
+ * This commit isn't already in new_columns. Add it.
+ */
+ graph->new_columns[graph->num_new_columns].commit = commit;
+ graph->mapping[*mapping_index] = graph->num_new_columns;
+ *mapping_index += 2;
+ graph->num_new_columns++;
+}
+
+static void graph_update_width(struct git_graph *graph,
+ int is_commit_in_existing_columns)
+{
+ /*
+ * Compute the width needed to display the graph for this commit.
+ * This is the maximum width needed for any row. All other rows
+ * will be padded to this width.
+ *
+ * Compute the number of columns in the widest row:
+ * Count each existing column (graph->num_columns), and each new
+ * column added by this commit.
+ */
+ int max_cols = graph->num_columns + graph->num_parents;
+
+ /*
+ * Even if the current commit has no parents to be printed, it
+ * still takes up a column for itself.
+ */
+ if (graph->num_parents < 1)
+ max_cols++;
+
+ /*
+ * We added a column for the the current commit as part of
+ * graph->num_parents. If the current commit was already in
+ * graph->columns, then we have double counted it.
+ */
+ if (is_commit_in_existing_columns)
+ max_cols--;
+
+ /*
+ * Each column takes up 2 spaces
+ */
+ graph->width = max_cols * 2;
+}
+
+static void graph_update_columns(struct git_graph *graph)
+{
+ struct commit_list *parent;
+ struct column *tmp_columns;
+ int max_new_columns;
+ int mapping_idx;
+ int i, seen_this, is_commit_in_columns;
+
+ /*
+ * Swap graph->columns with graph->new_columns
+ * graph->columns contains the state for the previous commit,
+ * and new_columns now contains the state for our commit.
+ *
+ * We'll re-use the old columns array as storage to compute the new
+ * columns list for the commit after this one.
+ */
+ tmp_columns = graph->columns;
+ graph->columns = graph->new_columns;
+ graph->num_columns = graph->num_new_columns;
+
+ graph->new_columns = tmp_columns;
+ graph->num_new_columns = 0;
+
+ /*
+ * Now update new_columns and mapping with the information for the
+ * commit after this one.
+ *
+ * First, make sure we have enough room. At most, there will
+ * be graph->num_columns + graph->num_parents columns for the next
+ * commit.
+ */
+ max_new_columns = graph->num_columns + graph->num_parents;
+ graph_ensure_capacity(graph, max_new_columns);
+
+ /*
+ * Clear out graph->mapping
+ */
+ graph->mapping_size = 2 * max_new_columns;
+ for (i = 0; i < graph->mapping_size; i++)
+ graph->mapping[i] = -1;
+
+ /*
+ * Populate graph->new_columns and graph->mapping
+ *
+ * Some of the parents of this commit may already be in
+ * graph->columns. If so, graph->new_columns should only contain a
+ * single entry for each such commit. graph->mapping should
+ * contain information about where each current branch line is
+ * supposed to end up after the collapsing is performed.
+ */
+ seen_this = 0;
+ mapping_idx = 0;
+ is_commit_in_columns = 1;
+ for (i = 0; i <= graph->num_columns; i++) {
+ struct commit *col_commit;
+ if (i == graph->num_columns) {
+ if (seen_this)
+ break;
+ is_commit_in_columns = 0;
+ col_commit = graph->commit;
+ } else {
+ col_commit = graph->columns[i].commit;
+ }
+
+ if (col_commit == graph->commit) {
+ int old_mapping_idx = mapping_idx;
+ seen_this = 1;
+ graph->commit_index = i;
+ for (parent = first_interesting_parent(graph);
+ parent;
+ parent = next_interesting_parent(graph, parent)) {
+ graph_insert_into_new_columns(graph,
+ parent->item,
+ &mapping_idx);
+ }
+ /*
+ * We always need to increment mapping_idx by at
+ * least 2, even if it has no interesting parents.
+ * The current commit always takes up at least 2
+ * spaces.
+ */
+ if (mapping_idx == old_mapping_idx)
+ mapping_idx += 2;
+ } else {
+ graph_insert_into_new_columns(graph, col_commit,
+ &mapping_idx);
+ }
+ }
+
+ /*
+ * Shrink mapping_size to be the minimum necessary
+ */
+ while (graph->mapping_size > 1 &&
+ graph->mapping[graph->mapping_size - 1] < 0)
+ graph->mapping_size--;
+
+ /*
+ * Compute graph->width for this commit
+ */
+ graph_update_width(graph, is_commit_in_columns);
+}
+
+void graph_update(struct git_graph *graph, struct commit *commit)
+{
+ struct commit_list *parent;
+
+ /*
+ * Set the new commit
+ */
+ graph->commit = commit;
+
+ /*
+ * Count how many interesting parents this commit has
+ */
+ graph->num_parents = 0;
+ for (parent = first_interesting_parent(graph);
+ parent;
+ parent = next_interesting_parent(graph, parent))
+ {
+ graph->num_parents++;
+ }
+
+ /*
+ * Store the old commit_index in prev_commit_index.
+ * graph_update_columns() will update graph->commit_index for this
+ * commit.
+ */
+ graph->prev_commit_index = graph->commit_index;
+
+ /*
+ * Call graph_update_columns() to update
+ * columns, new_columns, and mapping.
+ */
+ graph_update_columns(graph);
+
+ graph->expansion_row = 0;
+
+ /*
+ * Update graph->state.
+ * Note that we don't call graph_update_state() here, since
+ * we don't want to update graph->prev_state. No line for
+ * graph->state was ever printed.
+ *
+ * If the previous commit didn't get to the GRAPH_PADDING state,
+ * it never finished its output. Goto GRAPH_SKIP, to print out
+ * a line to indicate that portion of the graph is missing.
+ *
+ * If there are 3 or more parents, we may need to print extra rows
+ * before the commit, to expand the branch lines around it and make
+ * room for it. We need to do this only if there is a branch row
+ * (or more) to the right of this commit.
+ *
+ * If there are less than 3 parents, we can immediately print the
+ * commit line.
+ */
+ if (graph->state != GRAPH_PADDING)
+ graph->state = GRAPH_SKIP;
+ else if (graph->num_parents >= 3 &&
+ graph->commit_index < (graph->num_columns - 1))
+ graph->state = GRAPH_PRE_COMMIT;
+ else
+ graph->state = GRAPH_COMMIT;
+}
+
+static int graph_is_mapping_correct(struct git_graph *graph)
+{
+ int i;
+
+ /*
+ * The mapping is up to date if each entry is at its target,
+ * or is 1 greater than its target.
+ * (If it is 1 greater than the target, '/' will be printed, so it
+ * will look correct on the next row.)
+ */
+ for (i = 0; i < graph->mapping_size; i++) {
+ int target = graph->mapping[i];
+ if (target < 0)
+ continue;
+ if (target == (i / 2))
+ continue;
+ return 0;
+ }
+
+ return 1;
+}
+
+static void graph_pad_horizontally(struct git_graph *graph, struct strbuf *sb)
+{
+ /*
+ * Add additional spaces to the end of the strbuf, so that all
+ * lines for a particular commit have the same width.
+ *
+ * This way, fields printed to the right of the graph will remain
+ * aligned for the entire commit.
+ */
+ int extra;
+ if (sb->len >= graph->width)
+ return;
+
+ extra = graph->width - sb->len;
+ strbuf_addf(sb, "%*s", (int) extra, "");
+}
+
+static void graph_output_padding_line(struct git_graph *graph,
+ struct strbuf *sb)
+{
+ int i;
+
+ /*
+ * We could conceivable be called with a NULL commit
+ * if our caller has a bug, and invokes graph_next_line()
+ * immediately after graph_init(), without first calling
+ * graph_update(). Return without outputting anything in this
+ * case.
+ */
+ if (!graph->commit)
+ return;
+
+ /*
+ * Output a padding row, that leaves all branch lines unchanged
+ */
+ for (i = 0; i < graph->num_new_columns; i++) {
+ strbuf_addstr(sb, "| ");
+ }
+
+ graph_pad_horizontally(graph, sb);
+}
+
+static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb)
+{
+ /*
+ * Output an ellipsis to indicate that a portion
+ * of the graph is missing.
+ */
+ strbuf_addstr(sb, "...");
+ graph_pad_horizontally(graph, sb);
+
+ if (graph->num_parents >= 3 &&
+ graph->commit_index < (graph->num_columns - 1))
+ graph_update_state(graph, GRAPH_PRE_COMMIT);
+ else
+ graph_update_state(graph, GRAPH_COMMIT);
+}
+
+static void graph_output_pre_commit_line(struct git_graph *graph,
+ struct strbuf *sb)
+{
+ int num_expansion_rows;
+ int i, seen_this;
+
+ /*
+ * This function formats a row that increases the space around a commit
+ * with multiple parents, to make room for it. It should only be
+ * called when there are 3 or more parents.
+ *
+ * We need 2 extra rows for every parent over 2.
+ */
+ assert(graph->num_parents >= 3);
+ num_expansion_rows = (graph->num_parents - 2) * 2;
+
+ /*
+ * graph->expansion_row tracks the current expansion row we are on.
+ * It should be in the range [0, num_expansion_rows - 1]
+ */
+ assert(0 <= graph->expansion_row &&
+ graph->expansion_row < num_expansion_rows);
+
+ /*
+ * Output the row
+ */
+ seen_this = 0;
+ for (i = 0; i < graph->num_columns; i++) {
+ struct column *col = &graph->columns[i];
+ if (col->commit == graph->commit) {
+ seen_this = 1;
+ strbuf_addf(sb, "| %*s", graph->expansion_row, "");
+ } else if (seen_this && (graph->expansion_row == 0)) {
+ /*
+ * This is the first line of the pre-commit output.
+ * If the previous commit was a merge commit and
+ * ended in the GRAPH_POST_MERGE state, all branch
+ * lines after graph->prev_commit_index were
+ * printed as "\" on the previous line. Continue
+ * to print them as "\" on this line. Otherwise,
+ * print the branch lines as "|".
+ */
+ if (graph->prev_state == GRAPH_POST_MERGE &&
+ graph->prev_commit_index < i)
+ strbuf_addstr(sb, "\\ ");
+ else
+ strbuf_addstr(sb, "| ");
+ } else if (seen_this && (graph->expansion_row > 0)) {
+ strbuf_addstr(sb, "\\ ");
+ } else {
+ strbuf_addstr(sb, "| ");
+ }
+ }
+
+ graph_pad_horizontally(graph, sb);
+
+ /*
+ * Increment graph->expansion_row,
+ * and move to state GRAPH_COMMIT if necessary
+ */
+ graph->expansion_row++;
+ if (graph->expansion_row >= num_expansion_rows)
+ graph_update_state(graph, GRAPH_COMMIT);
+}
+
+static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)
+{
+ /*
+ * For boundary commits, print 'o'
+ * (We should only see boundary commits when revs->boundary is set.)
+ */
+ if (graph->commit->object.flags & BOUNDARY) {
+ assert(graph->revs->boundary);
+ strbuf_addch(sb, 'o');
+ return;
+ }
+
+ /*
+ * If revs->left_right is set, print '<' for commits that
+ * come from the left side, and '>' for commits from the right
+ * side.
+ */
+ if (graph->revs && graph->revs->left_right) {
+ if (graph->commit->object.flags & SYMMETRIC_LEFT)
+ strbuf_addch(sb, '<');
+ else
+ strbuf_addch(sb, '>');
+ return;
+ }
+
+ /*
+ * Print '*' in all other cases
+ */
+ strbuf_addch(sb, '*');
+}
+
+void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
+{
+ int seen_this = 0;
+ int i, j;
+
+ /*
+ * Output the row containing this commit
+ * Iterate up to and including graph->num_columns,
+ * since the current commit may not be in any of the existing
+ * columns. (This happens when the current commit doesn't have any
+ * children that we have already processed.)
+ */
+ seen_this = 0;
+ for (i = 0; i <= graph->num_columns; i++) {
+ struct commit *col_commit;
+ if (i == graph->num_columns) {
+ if (seen_this)
+ break;
+ col_commit = graph->commit;
+ } else {
+ col_commit = graph->columns[i].commit;
+ }
+
+ if (col_commit == graph->commit) {
+ seen_this = 1;
+ graph_output_commit_char(graph, sb);
+
+ if (graph->num_parents < 3)
+ strbuf_addch(sb, ' ');
+ else {
+ int num_dashes =
+ ((graph->num_parents - 2) * 2) - 1;
+ for (j = 0; j < num_dashes; j++)
+ strbuf_addch(sb, '-');
+ strbuf_addstr(sb, ". ");
+ }
+ } else if (seen_this && (graph->num_parents > 2)) {
+ strbuf_addstr(sb, "\\ ");
+ } else if (seen_this && (graph->num_parents == 2)) {
+ /*
+ * This is a 2-way merge commit.
+ * There is no GRAPH_PRE_COMMIT stage for 2-way
+ * merges, so this is the first line of output
+ * for this commit. Check to see what the previous
+ * line of output was.
+ *
+ * If it was GRAPH_POST_MERGE, the branch line
+ * coming into this commit may have been '\',
+ * and not '|' or '/'. If so, output the branch
+ * line as '\' on this line, instead of '|'. This
+ * makes the output look nicer.
+ */
+ if (graph->prev_state == GRAPH_POST_MERGE &&
+ graph->prev_commit_index < i)
+ strbuf_addstr(sb, "\\ ");
+ else
+ strbuf_addstr(sb, "| ");
+ } else {
+ strbuf_addstr(sb, "| ");
+ }
+ }
+
+ graph_pad_horizontally(graph, sb);
+
+ /*
+ * Update graph->state
+ */
+ if (graph->num_parents > 1)
+ graph_update_state(graph, GRAPH_POST_MERGE);
+ else if (graph_is_mapping_correct(graph))
+ graph_update_state(graph, GRAPH_PADDING);
+ else
+ graph_update_state(graph, GRAPH_COLLAPSING);
+}
+
+void graph_output_post_merge_line(struct git_graph *graph, struct strbuf *sb)
+{
+ int seen_this = 0;
+ int i, j;
+
+ /*
+ * Output the post-merge row
+ */
+ for (i = 0; i <= graph->num_columns; i++) {
+ struct commit *col_commit;
+ if (i == graph->num_columns) {
+ if (seen_this)
+ break;
+ col_commit = graph->commit;
+ } else {
+ col_commit = graph->columns[i].commit;
+ }
+
+ if (col_commit == graph->commit) {
+ seen_this = 1;
+ strbuf_addch(sb, '|');
+ for (j = 0; j < graph->num_parents - 1; j++)
+ strbuf_addstr(sb, "\\ ");
+ } else if (seen_this) {
+ strbuf_addstr(sb, "\\ ");
+ } else {
+ strbuf_addstr(sb, "| ");
+ }
+ }
+
+ graph_pad_horizontally(graph, sb);
+
+ /*
+ * Update graph->state
+ */
+ if (graph_is_mapping_correct(graph))
+ graph_update_state(graph, GRAPH_PADDING);
+ else
+ graph_update_state(graph, GRAPH_COLLAPSING);
+}
+
+void graph_output_collapsing_line(struct git_graph *graph, struct strbuf *sb)
+{
+ int i;
+ int *tmp_mapping;
+
+ /*
+ * Clear out the new_mapping array
+ */
+ for (i = 0; i < graph->mapping_size; i++)
+ graph->new_mapping[i] = -1;
+
+ for (i = 0; i < graph->mapping_size; i++) {
+ int target = graph->mapping[i];
+ if (target < 0)
+ continue;
+
+ /*
+ * Since update_columns() always inserts the leftmost
+ * column first, each branch's target location should
+ * always be either its current location or to the left of
+ * its current location.
+ *
+ * We never have to move branches to the right. This makes
+ * the graph much more legible, since whenever branches
+ * cross, only one is moving directions.
+ */
+ assert(target * 2 <= i);
+
+ if (target * 2 == i) {
+ /*
+ * This column is already in the
+ * correct place
+ */
+ assert(graph->new_mapping[i] == -1);
+ graph->new_mapping[i] = target;
+ } else if (graph->new_mapping[i - 1] < 0) {
+ /*
+ * Nothing is to the left.
+ * Move to the left by one
+ */
+ graph->new_mapping[i - 1] = target;
+ } else if (graph->new_mapping[i - 1] == target) {
+ /*
+ * There is a branch line to our left
+ * already, and it is our target. We
+ * combine with this line, since we share
+ * the same parent commit.
+ *
+ * We don't have to add anything to the
+ * output or new_mapping, since the
+ * existing branch line has already taken
+ * care of it.
+ */
+ } else {
+ /*
+ * There is a branch line to our left,
+ * but it isn't our target. We need to
+ * cross over it.
+ *
+ * The space just to the left of this
+ * branch should always be empty.
+ */
+ assert(graph->new_mapping[i - 1] > target);
+ assert(graph->new_mapping[i - 2] < 0);
+ graph->new_mapping[i - 2] = target;
+ }
+ }
+
+ /*
+ * The new mapping may be 1 smaller than the old mapping
+ */
+ if (graph->new_mapping[graph->mapping_size - 1] < 0)
+ graph->mapping_size--;
+
+ /*
+ * Output out a line based on the new mapping info
+ */
+ for (i = 0; i < graph->mapping_size; i++) {
+ int target = graph->new_mapping[i];
+ if (target < 0)
+ strbuf_addch(sb, ' ');
+ else if (target * 2 == i)
+ strbuf_addch(sb, '|');
+ else
+ strbuf_addch(sb, '/');
+ }
+
+ graph_pad_horizontally(graph, sb);
+
+ /*
+ * Swap mapping and new_mapping
+ */
+ tmp_mapping = graph->mapping;
+ graph->mapping = graph->new_mapping;
+ graph->new_mapping = tmp_mapping;
+
+ /*
+ * If graph->mapping indicates that all of the branch lines
+ * are already in the correct positions, we are done.
+ * Otherwise, we need to collapse some branch lines together.
+ */
+ if (graph_is_mapping_correct(graph))
+ graph_update_state(graph, GRAPH_PADDING);
+}
+
+int graph_next_line(struct git_graph *graph, struct strbuf *sb)
+{
+ switch (graph->state) {
+ case GRAPH_PADDING:
+ graph_output_padding_line(graph, sb);
+ return 0;
+ case GRAPH_SKIP:
+ graph_output_skip_line(graph, sb);
+ return 0;
+ case GRAPH_PRE_COMMIT:
+ graph_output_pre_commit_line(graph, sb);
+ return 0;
+ case GRAPH_COMMIT:
+ graph_output_commit_line(graph, sb);
+ return 1;
+ case GRAPH_POST_MERGE:
+ graph_output_post_merge_line(graph, sb);
+ return 0;
+ case GRAPH_COLLAPSING:
+ graph_output_collapsing_line(graph, sb);
+ return 0;
+ }
+
+ assert(0);
+ return 0;
+}
+
+void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
+{
+ int i, j;
+
+ if (graph->state != GRAPH_COMMIT) {
+ graph_next_line(graph, sb);
+ return;
+ }
+
+ /*
+ * Output the row containing this commit
+ * Iterate up to and including graph->num_columns,
+ * since the current commit may not be in any of the existing
+ * columns. (This happens when the current commit doesn't have any
+ * children that we have already processed.)
+ */
+ for (i = 0; i < graph->num_columns; i++) {
+ struct commit *col_commit = graph->columns[i].commit;
+ if (col_commit == graph->commit) {
+ strbuf_addch(sb, '|');
+
+ if (graph->num_parents < 3)
+ strbuf_addch(sb, ' ');
+ else {
+ int num_spaces = ((graph->num_parents - 2) * 2);
+ for (j = 0; j < num_spaces; j++)
+ strbuf_addch(sb, ' ');
+ }
+ } else {
+ strbuf_addstr(sb, "| ");
+ }
+ }
+
+ graph_pad_horizontally(graph, sb);
+
+ /*
+ * Update graph->prev_state since we have output a padding line
+ */
+ graph->prev_state = GRAPH_PADDING;
+}
+
+int graph_is_commit_finished(struct git_graph const *graph)
+{
+ return (graph->state == GRAPH_PADDING);
+}
+
+void graph_show_commit(struct git_graph *graph)
+{
+ struct strbuf msgbuf;
+ int shown_commit_line = 0;
+
+ if (!graph)
+ return;
+
+ strbuf_init(&msgbuf, 0);
+
+ while (!shown_commit_line) {
+ shown_commit_line = graph_next_line(graph, &msgbuf);
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ if (!shown_commit_line)
+ putchar('\n');
+ strbuf_setlen(&msgbuf, 0);
+ }
+
+ strbuf_release(&msgbuf);
+}
+
+void graph_show_oneline(struct git_graph *graph)
+{
+ struct strbuf msgbuf;
+
+ if (!graph)
+ return;
+
+ strbuf_init(&msgbuf, 0);
+ graph_next_line(graph, &msgbuf);
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ strbuf_release(&msgbuf);
+}
+
+void graph_show_padding(struct git_graph *graph)
+{
+ struct strbuf msgbuf;
+
+ if (!graph)
+ return;
+
+ strbuf_init(&msgbuf, 0);
+ graph_padding_line(graph, &msgbuf);
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ strbuf_release(&msgbuf);
+}
+
+int graph_show_remainder(struct git_graph *graph)
+{
+ struct strbuf msgbuf;
+ int shown = 0;
+
+ if (!graph)
+ return 0;
+
+ if (graph_is_commit_finished(graph))
+ return 0;
+
+ strbuf_init(&msgbuf, 0);
+ for (;;) {
+ graph_next_line(graph, &msgbuf);
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ strbuf_setlen(&msgbuf, 0);
+ shown = 1;
+
+ if (!graph_is_commit_finished(graph))
+ putchar('\n');
+ else
+ break;
+ }
+ strbuf_release(&msgbuf);
+
+ return shown;
+}
+
+
+void graph_show_strbuf(struct git_graph *graph, struct strbuf const *sb)
+{
+ char *p;
+
+ if (!graph) {
+ fwrite(sb->buf, sizeof(char), sb->len, stdout);
+ return;
+ }
+
+ /*
+ * Print the strbuf line by line,
+ * and display the graph info before each line but the first.
+ */
+ p = sb->buf;
+ while (p) {
+ size_t len;
+ char *next_p = strchr(p, '\n');
+ if (next_p) {
+ next_p++;
+ len = next_p - p;
+ } else {
+ len = (sb->buf + sb->len) - p;
+ }
+ fwrite(p, sizeof(char), len, stdout);
+ if (next_p && *next_p != '\0')
+ graph_show_oneline(graph);
+ p = next_p;
+ }
+}
+
+void graph_show_commit_msg(struct git_graph *graph,
+ struct strbuf const *sb)
+{
+ int newline_terminated;
+
+ if (!graph) {
+ /*
+ * If there's no graph, just print the message buffer.
+ *
+ * The message buffer for CMIT_FMT_ONELINE and
+ * CMIT_FMT_USERFORMAT are already missing a terminating
+ * newline. All of the other formats should have it.
+ */
+ fwrite(sb->buf, sizeof(char), sb->len, stdout);
+ return;
+ }
+
+ newline_terminated = (sb->len && sb->buf[sb->len - 1] == '\n');
+
+ /*
+ * Show the commit message
+ */
+ graph_show_strbuf(graph, sb);
+
+ /*
+ * If there is more output needed for this commit, show it now
+ */
+ if (!graph_is_commit_finished(graph)) {
+ /*
+ * If sb doesn't have a terminating newline, print one now,
+ * so we can start the remainder of the graph output on a
+ * new line.
+ */
+ if (!newline_terminated)
+ putchar('\n');
+
+ graph_show_remainder(graph);
+
+ /*
+ * If sb ends with a newline, our output should too.
+ */
+ if (newline_terminated)
+ putchar('\n');
+ }
+}
diff --git a/graph.h b/graph.h
new file mode 100644
index 000000000..eab4e3dab
--- /dev/null
+++ b/graph.h
@@ -0,0 +1,121 @@
+#ifndef GRAPH_H
+#define GRAPH_H
+
+/* A graph is a pointer to this opaque structure */
+struct git_graph;
+
+/*
+ * Create a new struct git_graph.
+ * The graph should be freed with graph_release() when no longer needed.
+ */
+struct git_graph *graph_init(struct rev_info *opt);
+
+/*
+ * Destroy a struct git_graph and free associated memory.
+ */
+void graph_release(struct git_graph *graph);
+
+/*
+ * Update a git_graph with a new commit.
+ * This will cause the graph to begin outputting lines for the new commit
+ * the next time graph_next_line() is called.
+ *
+ * If graph_update() is called before graph_is_commit_finished() returns 1,
+ * the next call to graph_next_line() will output an ellipsis ("...")
+ * to indicate that a portion of the graph is missing.
+ */
+void graph_update(struct git_graph *graph, struct commit *commit);
+
+/*
+ * Output the next line for a graph.
+ * This formats the next graph line into the specified strbuf. It is not
+ * terminated with a newline.
+ *
+ * Returns 1 if the line includes the current commit, and 0 otherwise.
+ * graph_next_line() will return 1 exactly once for each time
+ * graph_update() is called.
+ */
+int graph_next_line(struct git_graph *graph, struct strbuf *sb);
+
+/*
+ * Output a padding line in the graph.
+ * This is similar to graph_next_line(). However, it is guaranteed to
+ * never print the current commit line. Instead, if the commit line is
+ * next, it will simply output a line of vertical padding, extending the
+ * branch lines downwards, but leaving them otherwise unchanged.
+ */
+void graph_padding_line(struct git_graph *graph, struct strbuf *sb);
+
+/*
+ * Determine if a graph has finished outputting lines for the current
+ * commit.
+ *
+ * Returns 1 if graph_next_line() needs to be called again before
+ * graph_update() should be called. Returns 0 if no more lines are needed
+ * for this commit. If 0 is returned, graph_next_line() may still be
+ * called without calling graph_update(), and it will merely output
+ * appropriate "vertical padding" in the graph.
+ */
+int graph_is_commit_finished(struct git_graph const *graph);
+
+
+/*
+ * graph_show_*: helper functions for printing to stdout
+ */
+
+
+/*
+ * If the graph is non-NULL, print the history graph to stdout,
+ * up to and including the line containing this commit.
+ * Does not print a terminating newline on the last line.
+ */
+void graph_show_commit(struct git_graph *graph);
+
+/*
+ * If the graph is non-NULL, print one line of the history graph to stdout.
+ * Does not print a terminating newline on the last line.
+ */
+void graph_show_oneline(struct git_graph *graph);
+
+/*
+ * If the graph is non-NULL, print one line of vertical graph padding to
+ * stdout. Does not print a terminating newline on the last line.
+ */
+void graph_show_padding(struct git_graph *graph);
+
+/*
+ * If the graph is non-NULL, print the rest of the history graph for this
+ * commit to stdout. Does not print a terminating newline on the last line.
+ */
+int graph_show_remainder(struct git_graph *graph);
+
+/*
+ * Print a strbuf to stdout. If the graph is non-NULL, all lines but the
+ * first will be prefixed with the graph output.
+ *
+ * If the strbuf ends with a newline, the output will end after this
+ * newline. A new graph line will not be printed after the final newline.
+ * If the strbuf is empty, no output will be printed.
+ *
+ * Since the first line will not include the graph ouput, the caller is
+ * responsible for printing this line's graph (perhaps via
+ * graph_show_commit() or graph_show_oneline()) before calling
+ * graph_show_strbuf().
+ */
+void graph_show_strbuf(struct git_graph *graph, struct strbuf const *sb);
+
+/*
+ * Print a commit message strbuf and the remainder of the graph to stdout.
+ *
+ * This is similar to graph_show_strbuf(), but it always prints the
+ * remainder of the graph.
+ *
+ * If the strbuf ends with a newline, the output printed by
+ * graph_show_commit_msg() will end with a newline. If the strbuf is
+ * missing a terminating newline (including if it is empty), the output
+ * printed by graph_show_commit_msg() will also be missing a terminating
+ * newline.
+ */
+void graph_show_commit_msg(struct git_graph *graph, struct strbuf const *sb);
+
+#endif /* GRAPH_H */
diff --git a/hash-object.c b/hash-object.c
index 0a58f3f12..46c06a955 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -6,6 +6,7 @@
*/
#include "cache.h"
#include "blob.h"
+#include "quote.h"
static void hash_object(const char *path, enum object_type type, int write_object)
{
@@ -20,6 +21,7 @@ static void hash_object(const char *path, enum object_type type, int write_objec
? "Unable to add %s to database"
: "Unable to hash %s", path);
printf("%s\n", sha1_to_hex(sha1));
+ maybe_flush_or_die(stdout, "hash to stdout");
}
static void hash_stdin(const char *type, int write_object)
@@ -30,8 +32,27 @@ static void hash_stdin(const char *type, int write_object)
printf("%s\n", sha1_to_hex(sha1));
}
+static void hash_stdin_paths(const char *type, int write_objects)
+{
+ struct strbuf buf, nbuf;
+
+ strbuf_init(&buf, 0);
+ strbuf_init(&nbuf, 0);
+ while (strbuf_getline(&buf, stdin, '\n') != EOF) {
+ if (buf.buf[0] == '"') {
+ strbuf_reset(&nbuf);
+ if (unquote_c_style(&nbuf, buf.buf, NULL))
+ die("line is badly quoted");
+ strbuf_swap(&buf, &nbuf);
+ }
+ hash_object(buf.buf, type_from_string(type), write_objects);
+ }
+ strbuf_release(&buf);
+ strbuf_release(&nbuf);
+}
+
static const char hash_object_usage[] =
-"git-hash-object [-t <type>] [-w] [--stdin] <file>...";
+"git hash-object [ [-t <type>] [-w] [--stdin] <file>... | --stdin-paths < <list-of-paths> ]";
int main(int argc, char **argv)
{
@@ -41,8 +62,10 @@ int main(int argc, char **argv)
const char *prefix = NULL;
int prefix_length = -1;
int no_more_flags = 0;
+ int hashstdin = 0;
+ int stdin_paths = 0;
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
for (i = 1 ; i < argc; i++) {
if (!no_more_flags && argv[i][0] == '-') {
@@ -64,14 +87,38 @@ int main(int argc, char **argv)
}
else if (!strcmp(argv[i], "--help"))
usage(hash_object_usage);
+ else if (!strcmp(argv[i], "--stdin-paths")) {
+ if (hashstdin) {
+ error("Can't use --stdin-paths with --stdin");
+ usage(hash_object_usage);
+ }
+ stdin_paths = 1;
+
+ }
else if (!strcmp(argv[i], "--stdin")) {
- hash_stdin(type, write_object);
+ if (stdin_paths) {
+ error("Can't use %s with --stdin-paths", argv[i]);
+ usage(hash_object_usage);
+ }
+ if (hashstdin)
+ die("Multiple --stdin arguments are not supported");
+ hashstdin = 1;
}
else
usage(hash_object_usage);
}
else {
const char *arg = argv[i];
+
+ if (stdin_paths) {
+ error("Can't specify files (such as \"%s\") with --stdin-paths", arg);
+ usage(hash_object_usage);
+ }
+
+ if (hashstdin) {
+ hash_stdin(type, write_object);
+ hashstdin = 0;
+ }
if (0 <= prefix_length)
arg = prefix_filename(prefix, prefix_length,
arg);
@@ -79,5 +126,11 @@ int main(int argc, char **argv)
no_more_flags = 1;
}
}
+
+ if (stdin_paths)
+ hash_stdin_paths(type, write_object);
+
+ if (hashstdin)
+ hash_stdin(type, write_object);
return 0;
}
diff --git a/hash.c b/hash.c
index 7b492d4fc..1cd4c9d5c 100644
--- a/hash.c
+++ b/hash.c
@@ -9,7 +9,7 @@
* the existing entry, or the empty slot if none existed. The caller
* can then look at the (*ptr) to see whether it existed or not.
*/
-static struct hash_table_entry *lookup_hash_entry(unsigned int hash, struct hash_table *table)
+static struct hash_table_entry *lookup_hash_entry(unsigned int hash, const struct hash_table *table)
{
unsigned int size = table->size, nr = hash % size;
struct hash_table_entry *array = table->array;
@@ -66,11 +66,11 @@ static void grow_hash_table(struct hash_table *table)
free(old_array);
}
-void *lookup_hash(unsigned int hash, struct hash_table *table)
+void *lookup_hash(unsigned int hash, const struct hash_table *table)
{
if (!table->array)
return NULL;
- return &lookup_hash_entry(hash, table)->ptr;
+ return lookup_hash_entry(hash, table)->ptr;
}
void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
@@ -81,7 +81,7 @@ void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
return insert_hash_entry(hash, ptr, table);
}
-int for_each_hash(struct hash_table *table, int (*fn)(void *))
+int for_each_hash(const struct hash_table *table, int (*fn)(void *))
{
int sum = 0;
unsigned int i;
diff --git a/hash.h b/hash.h
index a8b0fbb5b..69e33a47b 100644
--- a/hash.h
+++ b/hash.h
@@ -28,9 +28,9 @@ struct hash_table {
struct hash_table_entry *array;
};
-extern void *lookup_hash(unsigned int hash, struct hash_table *table);
+extern void *lookup_hash(unsigned int hash, const struct hash_table *table);
extern void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table);
-extern int for_each_hash(struct hash_table *table, int (*fn)(void *));
+extern int for_each_hash(const struct hash_table *table, int (*fn)(void *));
extern void free_hash(struct hash_table *table);
static inline void init_hash(struct hash_table *table)
diff --git a/help.c b/help.c
index 1302a61c8..3cb196289 100644
--- a/help.c
+++ b/help.c
@@ -7,43 +7,269 @@
#include "builtin.h"
#include "exec_cmd.h"
#include "common-cmds.h"
+#include "parse-options.h"
+#include "run-command.h"
+
+static struct man_viewer_list {
+ struct man_viewer_list *next;
+ char name[FLEX_ARRAY];
+} *man_viewer_list;
+
+static struct man_viewer_info_list {
+ struct man_viewer_info_list *next;
+ const char *info;
+ char name[FLEX_ARRAY];
+} *man_viewer_info_list;
+
+enum help_format {
+ HELP_FORMAT_MAN,
+ HELP_FORMAT_INFO,
+ HELP_FORMAT_WEB,
+};
+
+static int show_all = 0;
+static enum help_format help_format = HELP_FORMAT_MAN;
+static struct option builtin_help_options[] = {
+ OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
+ OPT_SET_INT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
+ OPT_SET_INT('w', "web", &help_format, "show manual in web browser",
+ HELP_FORMAT_WEB),
+ OPT_SET_INT('i', "info", &help_format, "show info page",
+ HELP_FORMAT_INFO),
+ OPT_END(),
+};
+
+static const char * const builtin_help_usage[] = {
+ "git help [--all] [--man|--web|--info] [command]",
+ NULL
+};
+
+static enum help_format parse_help_format(const char *format)
+{
+ if (!strcmp(format, "man"))
+ return HELP_FORMAT_MAN;
+ if (!strcmp(format, "info"))
+ return HELP_FORMAT_INFO;
+ if (!strcmp(format, "web") || !strcmp(format, "html"))
+ return HELP_FORMAT_WEB;
+ die("unrecognized help format '%s'", format);
+}
-static const char *help_default_format;
+static const char *get_man_viewer_info(const char *name)
+{
+ struct man_viewer_info_list *viewer;
-static enum help_format {
- man_format,
- info_format,
- web_format,
-} help_format = man_format;
+ for (viewer = man_viewer_info_list; viewer; viewer = viewer->next)
+ {
+ if (!strcasecmp(name, viewer->name))
+ return viewer->info;
+ }
+ return NULL;
+}
-static void parse_help_format(const char *format)
+static int check_emacsclient_version(void)
{
- if (!format) {
- help_format = man_format;
- return;
+ struct strbuf buffer = STRBUF_INIT;
+ struct child_process ec_process;
+ const char *argv_ec[] = { "emacsclient", "--version", NULL };
+ int version;
+
+ /* emacsclient prints its version number on stderr */
+ memset(&ec_process, 0, sizeof(ec_process));
+ ec_process.argv = argv_ec;
+ ec_process.err = -1;
+ ec_process.stdout_to_stderr = 1;
+ if (start_command(&ec_process)) {
+ fprintf(stderr, "Failed to start emacsclient.\n");
+ return -1;
}
- if (!strcmp(format, "man")) {
- help_format = man_format;
- return;
+ strbuf_read(&buffer, ec_process.err, 20);
+ close(ec_process.err);
+
+ /*
+ * Don't bother checking return value, because "emacsclient --version"
+ * seems to always exits with code 1.
+ */
+ finish_command(&ec_process);
+
+ if (prefixcmp(buffer.buf, "emacsclient")) {
+ fprintf(stderr, "Failed to parse emacsclient version.\n");
+ strbuf_release(&buffer);
+ return -1;
}
- if (!strcmp(format, "info")) {
- help_format = info_format;
- return;
+
+ strbuf_remove(&buffer, 0, strlen("emacsclient"));
+ version = atoi(buffer.buf);
+
+ if (version < 22) {
+ fprintf(stderr,
+ "emacsclient version '%d' too old (< 22).\n",
+ version);
+ strbuf_release(&buffer);
+ return -1;
}
- if (!strcmp(format, "web") || !strcmp(format, "html")) {
- help_format = web_format;
- return;
+
+ strbuf_release(&buffer);
+ return 0;
+}
+
+static void exec_woman_emacs(const char* path, const char *page)
+{
+ if (!check_emacsclient_version()) {
+ /* This works only with emacsclient version >= 22. */
+ struct strbuf man_page = STRBUF_INIT;
+
+ if (!path)
+ path = "emacsclient";
+ strbuf_addf(&man_page, "(woman \"%s\")", page);
+ execlp(path, "emacsclient", "-e", man_page.buf, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
}
- die("unrecognized help format '%s'", format);
}
-static int git_help_config(const char *var, const char *value)
+static void exec_man_konqueror(const char* path, const char *page)
+{
+ const char *display = getenv("DISPLAY");
+ if (display && *display) {
+ struct strbuf man_page = STRBUF_INIT;
+ const char *filename = "kfmclient";
+
+ /* It's simpler to launch konqueror using kfmclient. */
+ if (path) {
+ const char *file = strrchr(path, '/');
+ if (file && !strcmp(file + 1, "konqueror")) {
+ char *new = xstrdup(path);
+ char *dest = strrchr(new, '/');
+
+ /* strlen("konqueror") == strlen("kfmclient") */
+ strcpy(dest + 1, "kfmclient");
+ path = new;
+ }
+ if (file)
+ filename = file;
+ } else
+ path = "kfmclient";
+ strbuf_addf(&man_page, "man:%s(1)", page);
+ execlp(path, filename, "newTab", man_page.buf, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
+ }
+}
+
+static void exec_man_man(const char* path, const char *page)
+{
+ if (!path)
+ path = "man";
+ execlp(path, "man", page, NULL);
+ warning("failed to exec '%s': %s", path, strerror(errno));
+}
+
+static void exec_man_cmd(const char *cmd, const char *page)
+{
+ struct strbuf shell_cmd = STRBUF_INIT;
+ strbuf_addf(&shell_cmd, "%s %s", cmd, page);
+ execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL);
+ warning("failed to exec '%s': %s", cmd, strerror(errno));
+}
+
+static void add_man_viewer(const char *name)
+{
+ struct man_viewer_list **p = &man_viewer_list;
+ size_t len = strlen(name);
+
+ while (*p)
+ p = &((*p)->next);
+ *p = xcalloc(1, (sizeof(**p) + len + 1));
+ strncpy((*p)->name, name, len);
+}
+
+static int supported_man_viewer(const char *name, size_t len)
+{
+ return (!strncasecmp("man", name, len) ||
+ !strncasecmp("woman", name, len) ||
+ !strncasecmp("konqueror", name, len));
+}
+
+static void do_add_man_viewer_info(const char *name,
+ size_t len,
+ const char *value)
+{
+ struct man_viewer_info_list *new = xcalloc(1, sizeof(*new) + len + 1);
+
+ strncpy(new->name, name, len);
+ new->info = xstrdup(value);
+ new->next = man_viewer_info_list;
+ man_viewer_info_list = new;
+}
+
+static int add_man_viewer_path(const char *name,
+ size_t len,
+ const char *value)
+{
+ if (supported_man_viewer(name, len))
+ do_add_man_viewer_info(name, len, value);
+ else
+ warning("'%s': path for unsupported man viewer.\n"
+ "Please consider using 'man.<tool>.cmd' instead.",
+ name);
+
+ return 0;
+}
+
+static int add_man_viewer_cmd(const char *name,
+ size_t len,
+ const char *value)
+{
+ if (supported_man_viewer(name, len))
+ warning("'%s': cmd for supported man viewer.\n"
+ "Please consider using 'man.<tool>.path' instead.",
+ name);
+ else
+ do_add_man_viewer_info(name, len, value);
+
+ return 0;
+}
+
+static int add_man_viewer_info(const char *var, const char *value)
+{
+ const char *name = var + 4;
+ const char *subkey = strrchr(name, '.');
+
+ if (!subkey)
+ return error("Config with no key for man viewer: %s", name);
+
+ if (!strcmp(subkey, ".path")) {
+ if (!value)
+ return config_error_nonbool(var);
+ return add_man_viewer_path(name, subkey - name, value);
+ }
+ if (!strcmp(subkey, ".cmd")) {
+ if (!value)
+ return config_error_nonbool(var);
+ return add_man_viewer_cmd(name, subkey - name, value);
+ }
+
+ warning("'%s': unsupported man viewer sub key.", subkey);
+ return 0;
+}
+
+static int git_help_config(const char *var, const char *value, void *cb)
{
if (!strcmp(var, "help.format")) {
- help_default_format = xstrdup(value);
+ if (!value)
+ return config_error_nonbool(var);
+ help_format = parse_help_format(value);
return 0;
}
- return git_default_config(var, value);
+ if (!strcmp(var, "man.viewer")) {
+ if (!value)
+ return config_error_nonbool(var);
+ add_man_viewer(value);
+ return 0;
+ }
+ if (!prefixcmp(var, "man."))
+ return add_man_viewer_info(var, value);
+
+ return git_default_config(var, value, cb);
}
/* most GUI terminals set COLUMNS (although some don't export it) */
@@ -165,6 +391,32 @@ static void pretty_print_string_list(struct cmdnames *cmds, int longest)
}
}
+static int is_executable(const char *name)
+{
+ struct stat st;
+
+ if (stat(name, &st) || /* stat, not lstat */
+ !S_ISREG(st.st_mode))
+ return 0;
+
+#ifdef __MINGW32__
+ /* cannot trust the executable bit, peek into the file instead */
+ char buf[3] = { 0 };
+ int n;
+ int fd = open(name, O_RDONLY);
+ st.st_mode &= ~S_IXUSR;
+ if (fd >= 0) {
+ n = read(fd, buf, 2);
+ if (n == 2)
+ /* DOS executables start with "MZ" */
+ if (!strcmp(buf, "#!") || !strcmp(buf, "MZ"))
+ st.st_mode |= S_IXUSR;
+ close(fd);
+ }
+#endif
+ return st.st_mode & S_IXUSR;
+}
+
static unsigned int list_commands_in_dir(struct cmdnames *cmds,
const char *path)
{
@@ -173,20 +425,24 @@ static unsigned int list_commands_in_dir(struct cmdnames *cmds,
int prefix_len = strlen(prefix);
DIR *dir = opendir(path);
struct dirent *de;
+ struct strbuf buf = STRBUF_INIT;
+ int len;
- if (!dir || chdir(path))
+ if (!dir)
return 0;
+ strbuf_addf(&buf, "%s/", path);
+ len = buf.len;
+
while ((de = readdir(dir)) != NULL) {
- struct stat st;
int entlen;
if (prefixcmp(de->d_name, prefix))
continue;
- if (stat(de->d_name, &st) || /* stat, not lstat */
- !S_ISREG(st.st_mode) ||
- !(st.st_mode & S_IXUSR))
+ strbuf_setlen(&buf, len);
+ strbuf_addstr(&buf, de->d_name);
+ if (!is_executable(buf.buf))
continue;
entlen = strlen(de->d_name) - prefix_len;
@@ -199,11 +455,12 @@ static unsigned int list_commands_in_dir(struct cmdnames *cmds,
add_cmdname(cmds, de->d_name + prefix_len, entlen);
}
closedir(dir);
+ strbuf_release(&buf);
return longest;
}
-static void list_commands(void)
+static unsigned int load_command_list(void)
{
unsigned int longest = 0;
unsigned int len;
@@ -221,7 +478,7 @@ static void list_commands(void)
path = paths = xstrdup(env_path);
while (1) {
- if ((colon = strchr(path, ':')))
+ if ((colon = strchr(path, PATH_SEP)))
*colon = 0;
len = list_commands_in_dir(&other_cmds, path);
@@ -243,6 +500,14 @@ static void list_commands(void)
uniq(&other_cmds);
exclude_cmds(&other_cmds, &main_cmds);
+ return longest;
+}
+
+static void list_commands(void)
+{
+ unsigned int longest = load_command_list();
+ const char *exec_path = git_exec_path();
+
if (main_cmds.cnt) {
printf("available git commands in '%s'\n", exec_path);
printf("----------------------------");
@@ -277,20 +542,42 @@ void list_common_cmds_help(void)
}
}
+static int is_in_cmdlist(struct cmdnames *c, const char *s)
+{
+ int i;
+ for (i = 0; i < c->cnt; i++)
+ if (!strcmp(s, c->names[i]->name))
+ return 1;
+ return 0;
+}
+
+static int is_git_command(const char *s)
+{
+ load_command_list();
+ return is_in_cmdlist(&main_cmds, s) ||
+ is_in_cmdlist(&other_cmds, s);
+}
+
+static const char *prepend(const char *prefix, const char *cmd)
+{
+ size_t pre_len = strlen(prefix);
+ size_t cmd_len = strlen(cmd);
+ char *p = xmalloc(pre_len + cmd_len + 1);
+ memcpy(p, prefix, pre_len);
+ strcpy(p + pre_len, cmd);
+ return p;
+}
+
static const char *cmd_to_page(const char *git_cmd)
{
if (!git_cmd)
return "git";
else if (!prefixcmp(git_cmd, "git"))
return git_cmd;
- else {
- int page_len = strlen(git_cmd) + 4;
- char *p = xmalloc(page_len + 1);
- strcpy(p, "git-");
- strcpy(p + 4, git_cmd);
- p[page_len] = 0;
- return p;
- }
+ else if (is_git_command(git_cmd))
+ return prepend("git-", git_cmd);
+ else
+ return prepend("git", git_cmd);
}
static void setup_man_path(void)
@@ -314,11 +601,34 @@ static void setup_man_path(void)
strbuf_release(&new_path);
}
+static void exec_viewer(const char *name, const char *page)
+{
+ const char *info = get_man_viewer_info(name);
+
+ if (!strcasecmp(name, "man"))
+ exec_man_man(info, page);
+ else if (!strcasecmp(name, "woman"))
+ exec_woman_emacs(info, page);
+ else if (!strcasecmp(name, "konqueror"))
+ exec_man_konqueror(info, page);
+ else if (info)
+ exec_man_cmd(info, page);
+ else
+ warning("'%s': unknown man viewer.", name);
+}
+
static void show_man_page(const char *git_cmd)
{
+ struct man_viewer_list *viewer;
const char *page = cmd_to_page(git_cmd);
+
setup_man_path();
- execlp("man", "man", page, NULL);
+ for (viewer = man_viewer_list; viewer; viewer = viewer->next)
+ {
+ exec_viewer(viewer->name, page); /* will return when unable */
+ }
+ exec_viewer("man", page);
+ die("no man viewer handled the request");
}
static void show_info_page(const char *git_cmd)
@@ -328,10 +638,40 @@ static void show_info_page(const char *git_cmd)
execlp("info", "info", "gitman", page, NULL);
}
+static void get_html_page_path(struct strbuf *page_path, const char *page)
+{
+ struct stat st;
+ const char *html_path = system_path(GIT_HTML_PATH);
+
+ /* Check that we have a git documentation directory. */
+ if (stat(mkpath("%s/git.html", html_path), &st)
+ || !S_ISREG(st.st_mode))
+ die("'%s': not a documentation directory.", html_path);
+
+ strbuf_init(page_path, 0);
+ strbuf_addf(page_path, "%s/%s.html", html_path, page);
+}
+
+/*
+ * If open_html is not defined in a platform-specific way (see for
+ * example compat/mingw.h), we use the script web--browse to display
+ * HTML.
+ */
+#ifndef open_html
+void open_html(const char *path)
+{
+ execl_git_cmd("web--browse", "-c", "help.browser", path, NULL);
+}
+#endif
+
static void show_html_page(const char *git_cmd)
{
const char *page = cmd_to_page(git_cmd);
- execl_git_cmd("help--browse", page, NULL);
+ struct strbuf page_path; /* it leaks but we exec bellow */
+
+ get_html_page_path(&page_path, page);
+
+ open_html(page_path.buf);
}
void help_unknown_cmd(const char *cmd)
@@ -348,50 +688,45 @@ int cmd_version(int argc, const char **argv, const char *prefix)
int cmd_help(int argc, const char **argv, const char *prefix)
{
- const char *help_cmd = argv[1];
+ int nongit;
+ const char *alias;
- if (argc < 2) {
- printf("usage: %s\n\n", git_usage_string);
- list_common_cmds_help();
- exit(0);
- }
+ setup_git_directory_gently(&nongit);
+ git_config(git_help_config, NULL);
+
+ argc = parse_options(argc, argv, builtin_help_options,
+ builtin_help_usage, 0);
- if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
+ if (show_all) {
printf("usage: %s\n\n", git_usage_string);
list_commands();
+ printf("%s\n", git_more_info_string);
+ return 0;
}
- else if (!strcmp(help_cmd, "--web") || !strcmp(help_cmd, "-w")) {
- show_html_page(argc > 2 ? argv[2] : NULL);
- }
-
- else if (!strcmp(help_cmd, "--info") || !strcmp(help_cmd, "-i")) {
- show_info_page(argc > 2 ? argv[2] : NULL);
+ if (!argv[0]) {
+ printf("usage: %s\n\n", git_usage_string);
+ list_common_cmds_help();
+ printf("\n%s\n", git_more_info_string);
+ return 0;
}
- else if (!strcmp(help_cmd, "--man") || !strcmp(help_cmd, "-m")) {
- show_man_page(argc > 2 ? argv[2] : NULL);
+ alias = alias_lookup(argv[0]);
+ if (alias && !is_git_command(argv[0])) {
+ printf("`git %s' is aliased to `%s'\n", argv[0], alias);
+ return 0;
}
- else {
- int nongit;
-
- setup_git_directory_gently(&nongit);
- git_config(git_help_config);
- if (help_default_format)
- parse_help_format(help_default_format);
-
- switch (help_format) {
- case man_format:
- show_man_page(help_cmd);
- break;
- case info_format:
- show_info_page(help_cmd);
- break;
- case web_format:
- show_html_page(help_cmd);
- break;
- }
+ switch (help_format) {
+ case HELP_FORMAT_MAN:
+ show_man_page(argv[0]);
+ break;
+ case HELP_FORMAT_INFO:
+ show_info_page(argv[0]);
+ break;
+ case HELP_FORMAT_WEB:
+ show_html_page(argv[0]);
+ break;
}
return 0;
diff --git a/http-push.c b/http-push.c
index b2b410df9..680528885 100644
--- a/http-push.c
+++ b/http-push.c
@@ -9,11 +9,12 @@
#include "revision.h"
#include "exec_cmd.h"
#include "remote.h"
+#include "list-objects.h"
#include <expat.h>
static const char http_push_usage[] =
-"git-http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\n";
+"git http-push [--all] [--dry-run] [--force] [--verbose] <remote> [<head>...]\n";
#ifndef XML_STATUS_OK
enum XML_Status {
@@ -664,8 +665,7 @@ static void release_request(struct transfer_request *request)
close(request->local_fileno);
if (request->local_stream)
fclose(request->local_stream);
- if (request->url != NULL)
- free(request->url);
+ free(request->url);
free(request);
}
@@ -783,7 +783,7 @@ static void finish_request(struct transfer_request *request)
lst = &((*lst)->next);
*lst = (*lst)->next;
- if (!verify_pack(target, 0))
+ if (!verify_pack(target))
install_packed_git(target);
else
remote->can_update_info_refs = 0;
@@ -1283,10 +1283,8 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
strbuf_release(&in_buffer);
if (lock->token == NULL || lock->timeout <= 0) {
- if (lock->token != NULL)
- free(lock->token);
- if (lock->owner != NULL)
- free(lock->owner);
+ free(lock->token);
+ free(lock->owner);
free(url);
free(lock);
lock = NULL;
@@ -1344,8 +1342,7 @@ static int unlock_remote(struct remote_lock *lock)
prev->next = prev->next->next;
}
- if (lock->owner != NULL)
- free(lock->owner);
+ free(lock->owner);
free(lock->url);
free(lock->token);
free(lock);
@@ -1353,6 +1350,24 @@ static int unlock_remote(struct remote_lock *lock)
return rc;
}
+static void remove_locks(void)
+{
+ struct remote_lock *lock = remote->locks;
+
+ fprintf(stderr, "Removing remote locks...\n");
+ while (lock) {
+ unlock_remote(lock);
+ lock = lock->next;
+ }
+}
+
+static void remove_locks_on_signal(int signo)
+{
+ remove_locks();
+ signal(signo, SIG_DFL);
+ raise(signo);
+}
+
static void remote_ls(const char *path, int flags,
void (*userFunc)(struct remote_ls_ctx *ls),
void *userData);
@@ -1634,12 +1649,19 @@ static struct object_list **process_tree(struct tree *tree,
init_tree_desc(&desc, tree->buffer, tree->size);
- while (tree_entry(&desc, &entry)) {
- if (S_ISDIR(entry.mode))
+ while (tree_entry(&desc, &entry))
+ switch (object_type(entry.mode)) {
+ case OBJ_TREE:
p = process_tree(lookup_tree(entry.sha1), p, &me, name);
- else
+ break;
+ case OBJ_BLOB:
p = process_blob(lookup_blob(entry.sha1), p, &me, name);
- }
+ break;
+ default:
+ /* Subproject commit - not in this repository */
+ break;
+ }
+
free(tree->buffer);
tree->buffer = NULL;
return p;
@@ -1756,15 +1778,15 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
static void one_remote_ref(char *refname)
{
struct ref *ref;
- unsigned char remote_sha1[20];
struct object *obj;
- int len = strlen(refname) + 1;
- if (http_fetch_ref(remote->url, refname + 5 /* "refs/" */,
- remote_sha1) != 0) {
+ ref = alloc_ref_from_str(refname);
+
+ if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
"Unable to fetch ref %s from %s\n",
refname, remote->url);
+ free(ref);
return;
}
@@ -1772,18 +1794,15 @@ static void one_remote_ref(char *refname)
* Fetch a copy of the object if it doesn't exist locally - it
* may be required for updating server info later.
*/
- if (remote->can_update_info_refs && !has_sha1_file(remote_sha1)) {
- obj = lookup_unknown_object(remote_sha1);
+ if (remote->can_update_info_refs && !has_sha1_file(ref->old_sha1)) {
+ obj = lookup_unknown_object(ref->old_sha1);
if (obj) {
fprintf(stderr, " fetch %s for %s\n",
- sha1_to_hex(remote_sha1), refname);
+ sha1_to_hex(ref->old_sha1), refname);
add_fetch_request(obj);
}
}
- ref = xcalloc(1, sizeof(*ref) + len);
- hashcpy(ref->old_sha1, remote_sha1);
- memcpy(ref->name, refname, len);
*remote_tail = ref;
remote_tail = &ref->next;
}
@@ -1860,61 +1879,39 @@ static int ref_newer(const unsigned char *new_sha1,
return found;
}
-static void mark_edge_parents_uninteresting(struct commit *commit)
-{
- struct commit_list *parents;
-
- for (parents = commit->parents; parents; parents = parents->next) {
- struct commit *parent = parents->item;
- if (!(parent->object.flags & UNINTERESTING))
- continue;
- mark_tree_uninteresting(parent->tree);
- }
-}
-
-static void mark_edges_uninteresting(struct commit_list *list)
-{
- for ( ; list; list = list->next) {
- struct commit *commit = list->item;
-
- if (commit->object.flags & UNINTERESTING) {
- mark_tree_uninteresting(commit->tree);
- continue;
- }
- mark_edge_parents_uninteresting(commit);
- }
-}
-
static void add_remote_info_ref(struct remote_ls_ctx *ls)
{
struct strbuf *buf = (struct strbuf *)ls->userData;
- unsigned char remote_sha1[20];
struct object *o;
int len;
char *ref_info;
+ struct ref *ref;
+
+ ref = alloc_ref_from_str(ls->dentry_name);
- if (http_fetch_ref(remote->url, ls->dentry_name + 5 /* "refs/" */,
- remote_sha1) != 0) {
+ if (http_fetch_ref(remote->url, ref) != 0) {
fprintf(stderr,
"Unable to fetch ref %s from %s\n",
ls->dentry_name, remote->url);
aborted = 1;
+ free(ref);
return;
}
- o = parse_object(remote_sha1);
+ o = parse_object(ref->old_sha1);
if (!o) {
fprintf(stderr,
"Unable to parse object %s for remote ref %s\n",
- sha1_to_hex(remote_sha1), ls->dentry_name);
+ sha1_to_hex(ref->old_sha1), ls->dentry_name);
aborted = 1;
+ free(ref);
return;
}
len = strlen(ls->dentry_name) + 42;
ref_info = xcalloc(len + 1, 1);
sprintf(ref_info, "%s %s\n",
- sha1_to_hex(remote_sha1), ls->dentry_name);
+ sha1_to_hex(ref->old_sha1), ls->dentry_name);
fwrite_buffer(ref_info, 1, len, buf);
free(ref_info);
@@ -1929,6 +1926,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
free(ref_info);
}
}
+ free(ref);
}
static void update_remote_info_refs(struct remote_lock *lock)
@@ -2028,8 +2026,7 @@ static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
}
free(url);
- if (*symref != NULL)
- free(*symref);
+ free(*symref);
*symref = NULL;
hashclr(sha1);
@@ -2131,6 +2128,8 @@ static int delete_remote_branch(char *pattern, int force)
/* Send delete request */
fprintf(stderr, "Removing remote branch '%s'\n", remote_ref->name);
+ if (dry_run)
+ return 0;
url = xmalloc(strlen(remote->url) + strlen(remote_ref->name) + 1);
sprintf(url, "%s%s", remote->url, remote_ref->name);
slot = get_active_slot();
@@ -2233,7 +2232,7 @@ int main(int argc, char **argv)
memset(remote_dir_exists, -1, 256);
- http_init();
+ http_init(NULL);
no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
@@ -2251,6 +2250,11 @@ int main(int argc, char **argv)
goto cleanup;
}
+ signal(SIGINT, remove_locks_on_signal);
+ signal(SIGHUP, remove_locks_on_signal);
+ signal(SIGQUIT, remove_locks_on_signal);
+ signal(SIGTERM, remove_locks_on_signal);
+
/* Check whether the remote has server info files */
remote->can_update_info_refs = 0;
remote->has_info_refs = remote_exists("info/refs");
@@ -2304,6 +2308,16 @@ int main(int argc, char **argv)
if (!ref->peer_ref)
continue;
+
+ if (is_zero_sha1(ref->peer_ref->new_sha1)) {
+ if (delete_remote_branch(ref->name, 1) == -1) {
+ error("Could not remove %s", ref->name);
+ rc = -4;
+ }
+ new_refs++;
+ continue;
+ }
+
if (!hashcmp(ref->old_sha1, ref->peer_ref->new_sha1)) {
if (push_verbosely || 1)
fprintf(stderr, "'%s': up-to-date\n", ref->name);
@@ -2335,11 +2349,6 @@ int main(int argc, char **argv)
}
}
hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
- if (is_zero_sha1(ref->new_sha1)) {
- error("cannot happen anymore");
- rc = -3;
- continue;
- }
new_refs++;
strcpy(old_hex, sha1_to_hex(ref->old_sha1));
new_hex = sha1_to_hex(ref->new_sha1);
@@ -2375,6 +2384,7 @@ int main(int argc, char **argv)
}
init_revisions(&revs, setup_git_directory());
setup_revisions(commit_argc, commit_argv, &revs, NULL);
+ revs.edge_hint = 0; /* just in case */
free(new_sha1_hex);
if (old_sha1_hex) {
free(old_sha1_hex);
@@ -2383,8 +2393,9 @@ int main(int argc, char **argv)
/* Generate a list of objects that need to be pushed */
pushing = 0;
- prepare_revision_walk(&revs);
- mark_edges_uninteresting(revs.commits);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
+ mark_edges_uninteresting(revs.commits, &revs, NULL);
objects_to_send = get_delta(&revs, ref_lock);
finish_all_active_slots();
@@ -2398,15 +2409,17 @@ int main(int argc, char **argv)
fill_active_slots();
add_fill_function(NULL, fill_active_slot);
#endif
- finish_all_active_slots();
+ do {
+ finish_all_active_slots();
+#ifdef USE_CURL_MULTI
+ fill_active_slots();
+#endif
+ } while (request_queue_head && !aborted);
/* Update the remote branch if all went well */
- if (aborted || !update_remote(ref->new_sha1, ref_lock)) {
+ if (aborted || !update_remote(ref->new_sha1, ref_lock))
rc = 1;
- goto unlock;
- }
- unlock:
if (!rc)
fprintf(stderr, " done\n");
unlock_remote(ref_lock);
@@ -2425,8 +2438,7 @@ int main(int argc, char **argv)
}
cleanup:
- if (rewritten_url)
- free(rewritten_url);
+ free(rewritten_url);
if (info_ref_lock)
unlock_remote(info_ref_lock);
free(remote);
diff --git a/http-walker.c b/http-walker.c
index 2c3786870..9dc6b27b4 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -442,6 +442,8 @@ static int setup_index(struct walker *walker, struct alt_base *repo, unsigned ch
return -1;
new_pack = parse_pack_index(sha1);
+ if (!new_pack)
+ return -1; /* parse_pack_index() already issued error message */
new_pack->next = repo->packs;
repo->packs = new_pack;
return 0;
@@ -795,7 +797,7 @@ static int fetch_pack(struct walker *walker, struct alt_base *repo, unsigned cha
lst = &((*lst)->next);
*lst = (*lst)->next;
- if (verify_pack(target, 0))
+ if (verify_pack(target))
return -1;
install_packed_git(target);
@@ -888,10 +890,10 @@ static int fetch(struct walker *walker, unsigned char *sha1)
data->alt->base);
}
-static int fetch_ref(struct walker *walker, char *ref, unsigned char *sha1)
+static int fetch_ref(struct walker *walker, struct ref *ref)
{
struct walker_data *data = walker->data;
- return http_fetch_ref(data->alt->base, ref, sha1);
+ return http_fetch_ref(data->alt->base, ref);
}
static void cleanup(struct walker *walker)
@@ -902,13 +904,13 @@ static void cleanup(struct walker *walker)
curl_slist_free_all(data->no_pragma_header);
}
-struct walker *get_http_walker(const char *url)
+struct walker *get_http_walker(const char *url, struct remote *remote)
{
char *s;
struct walker_data *data = xmalloc(sizeof(struct walker_data));
struct walker *walker = xmalloc(sizeof(struct walker));
- http_init();
+ http_init(remote);
data->no_pragma_header = curl_slist_append(NULL, "Pragma:");
diff --git a/http.c b/http.c
index d2c11aee9..1108ab4a3 100644
--- a/http.c
+++ b/http.c
@@ -13,14 +13,14 @@ static CURL *curl_default;
char curl_errorstr[CURL_ERROR_SIZE];
static int curl_ssl_verify = -1;
-static char *ssl_cert = NULL;
+static const char *ssl_cert = NULL;
#if LIBCURL_VERSION_NUM >= 0x070902
-static char *ssl_key = NULL;
+static const char *ssl_key = NULL;
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
-static char *ssl_capath = NULL;
+static const char *ssl_capath = NULL;
#endif
-static char *ssl_cainfo = NULL;
+static const char *ssl_cainfo = NULL;
static long curl_low_speed_limit = -1;
static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv = 0;
@@ -30,10 +30,11 @@ static struct curl_slist *pragma_header;
static struct active_request_slot *active_queue_head = NULL;
-size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
- struct buffer *buffer)
+size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
{
size_t size = eltsize * nmemb;
+ struct buffer *buffer = buffer_;
+
if (size > buffer->buf.len - buffer->posn)
size = buffer->buf.len - buffer->posn;
memcpy(ptr, buffer->buf.buf + buffer->posn, size);
@@ -42,17 +43,17 @@ size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
return size;
}
-size_t fwrite_buffer(const void *ptr, size_t eltsize,
- size_t nmemb, struct strbuf *buffer)
+size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
{
size_t size = eltsize * nmemb;
+ struct strbuf *buffer = buffer_;
+
strbuf_add(buffer, ptr, size);
data_received++;
return size;
}
-size_t fwrite_null(const void *ptr, size_t eltsize,
- size_t nmemb, struct strbuf *buffer)
+size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf)
{
data_received++;
return eltsize * nmemb;
@@ -90,7 +91,7 @@ static void process_curl_messages(void)
}
#endif
-static int http_options(const char *var, const char *value)
+static int http_options(const char *var, const char *value, void *cb)
{
if (!strcmp("http.sslverify", var)) {
if (curl_ssl_verify == -1) {
@@ -100,35 +101,27 @@ static int http_options(const char *var, const char *value)
}
if (!strcmp("http.sslcert", var)) {
- if (ssl_cert == NULL) {
- ssl_cert = xmalloc(strlen(value)+1);
- strcpy(ssl_cert, value);
- }
+ if (ssl_cert == NULL)
+ return git_config_string(&ssl_cert, var, value);
return 0;
}
#if LIBCURL_VERSION_NUM >= 0x070902
if (!strcmp("http.sslkey", var)) {
- if (ssl_key == NULL) {
- ssl_key = xmalloc(strlen(value)+1);
- strcpy(ssl_key, value);
- }
+ if (ssl_key == NULL)
+ return git_config_string(&ssl_key, var, value);
return 0;
}
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
if (!strcmp("http.sslcapath", var)) {
- if (ssl_capath == NULL) {
- ssl_capath = xmalloc(strlen(value)+1);
- strcpy(ssl_capath, value);
- }
+ if (ssl_capath == NULL)
+ return git_config_string(&ssl_capath, var, value);
return 0;
}
#endif
if (!strcmp("http.sslcainfo", var)) {
- if (ssl_cainfo == NULL) {
- ssl_cainfo = xmalloc(strlen(value)+1);
- strcpy(ssl_cainfo, value);
- }
+ if (ssl_cainfo == NULL)
+ return git_config_string(&ssl_cainfo, var, value);
return 0;
}
@@ -157,14 +150,15 @@ static int http_options(const char *var, const char *value)
}
if (!strcmp("http.proxy", var)) {
if (curl_http_proxy == NULL) {
- curl_http_proxy = xmalloc(strlen(value)+1);
- strcpy(curl_http_proxy, value);
+ if (!value)
+ return config_error_nonbool(var);
+ curl_http_proxy = xstrdup(value);
}
return 0;
}
/* Fall back on the default ones */
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
static CURL* get_curl_handle(void)
@@ -213,13 +207,16 @@ static CURL* get_curl_handle(void)
return result;
}
-void http_init(void)
+void http_init(struct remote *remote)
{
char *low_speed_limit;
char *low_speed_time;
curl_global_init(CURL_GLOBAL_ALL);
+ if (remote && remote->http_proxy)
+ curl_http_proxy = xstrdup(remote->http_proxy);
+
pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
#ifdef USE_CURL_MULTI
@@ -255,7 +252,7 @@ void http_init(void)
if (low_speed_time != NULL)
curl_low_speed_time = strtol(low_speed_time, NULL, 10);
- git_config(http_options);
+ git_config(http_options, NULL);
if (curl_ssl_verify == -1)
curl_ssl_verify = 1;
@@ -276,23 +273,15 @@ void http_init(void)
void http_cleanup(void)
{
struct active_request_slot *slot = active_queue_head;
-#ifdef USE_CURL_MULTI
- char *wait_url;
-#endif
while (slot != NULL) {
struct active_request_slot *next = slot->next;
+ if (slot->curl != NULL) {
#ifdef USE_CURL_MULTI
- if (slot->in_use) {
- curl_easy_getinfo(slot->curl,
- CURLINFO_EFFECTIVE_URL,
- &wait_url);
- fprintf(stderr, "Waiting for %s\n", wait_url);
- run_active_slot(slot);
- }
+ curl_multi_remove_handle(curlm, slot->curl);
#endif
- if (slot->curl != NULL)
curl_easy_cleanup(slot->curl);
+ }
free(slot);
slot = next;
}
@@ -309,6 +298,11 @@ void http_cleanup(void)
curl_slist_free_all(pragma_header);
pragma_header = NULL;
+
+ if (curl_http_proxy) {
+ free(curl_http_proxy);
+ curl_http_proxy = NULL;
+ }
}
struct active_request_slot *get_active_slot(void)
@@ -578,14 +572,15 @@ static char *quote_ref_url(const char *base, const char *ref)
int len, baselen, ch;
baselen = strlen(base);
- len = baselen + 7; /* "/refs/" + NUL */
+ len = baselen + 2; /* '/' after base and terminating NUL */
for (cp = ref; (ch = *cp) != 0; cp++, len++)
if (needs_quote(ch))
len += 2; /* extra two hex plus replacement % */
qref = xmalloc(len);
memcpy(qref, base, baselen);
- memcpy(qref + baselen, "/refs/", 6);
- for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) {
+ dp = qref + baselen;
+ *(dp++) = '/';
+ for (cp = ref; (ch = *cp) != 0; cp++) {
if (needs_quote(ch)) {
*dp++ = '%';
*dp++ = hex((ch >> 4) & 0xF);
@@ -599,7 +594,7 @@ static char *quote_ref_url(const char *base, const char *ref)
return qref;
}
-int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
+int http_fetch_ref(const char *base, struct ref *ref)
{
char *url;
struct strbuf buffer = STRBUF_INIT;
@@ -607,7 +602,7 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
struct slot_results results;
int ret;
- url = quote_ref_url(base, ref);
+ url = quote_ref_url(base, ref->name);
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
@@ -619,12 +614,15 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1)
if (results.curl_result == CURLE_OK) {
strbuf_rtrim(&buffer);
if (buffer.len == 40)
- ret = get_sha1_hex(buffer.buf, sha1);
- else
+ ret = get_sha1_hex(buffer.buf, ref->old_sha1);
+ else if (!prefixcmp(buffer.buf, "ref: ")) {
+ ref->symref = xstrdup(buffer.buf + 5);
+ ret = 0;
+ } else
ret = 1;
} else {
ret = error("Couldn't get %s for %s\n%s",
- url, ref, curl_errorstr);
+ url, ref->name, curl_errorstr);
}
} else {
ret = error("Unable to start request");
diff --git a/http.h b/http.h
index aeba9301f..905b4629a 100644
--- a/http.h
+++ b/http.h
@@ -7,6 +7,15 @@
#include <curl/easy.h>
#include "strbuf.h"
+#include "remote.h"
+
+/*
+ * We detect based on the cURL version if multi-transfer is
+ * usable in this implementation and define this symbol accordingly.
+ * This is not something Makefile should set nor users should pass
+ * via CFLAGS.
+ */
+#undef USE_CURL_MULTI
#if LIBCURL_VERSION_NUM >= 0x071000
#define USE_CURL_MULTI
@@ -55,12 +64,9 @@ struct buffer
};
/* Curl request read/write callbacks */
-extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
- struct buffer *buffer);
-extern size_t fwrite_buffer(const void *ptr, size_t eltsize,
- size_t nmemb, struct strbuf *buffer);
-extern size_t fwrite_null(const void *ptr, size_t eltsize,
- size_t nmemb, struct strbuf *buffer);
+extern size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *strbuf);
+extern size_t fwrite_buffer(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);
+extern size_t fwrite_null(const void *ptr, size_t eltsize, size_t nmemb, void *strbuf);
/* Slot lifecycle functions */
extern struct active_request_slot *get_active_slot(void);
@@ -75,7 +81,7 @@ extern void add_fill_function(void *data, int (*fill)(void *));
extern void step_active_slots(void);
#endif
-extern void http_init(void);
+extern void http_init(struct remote *remote);
extern void http_cleanup(void);
extern int data_received;
@@ -96,6 +102,6 @@ static inline int missing__target(int code, int result)
#define missing_target(a) missing__target((a)->http_code, (a)->curl_result)
-extern int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1);
+extern int http_fetch_ref(const char *base, struct ref *ref);
#endif /* HTTP_H */
diff --git a/ident.c b/ident.c
index b839dcf5f..09cf0c95c 100644
--- a/ident.c
+++ b/ident.c
@@ -171,7 +171,7 @@ static const char au_env[] = "GIT_AUTHOR_NAME";
static const char co_env[] = "GIT_COMMITTER_NAME";
static const char *env_hint =
"\n"
-"*** Your name cannot be determined from your system services (gecos).\n"
+"*** Please tell me who you are.\n"
"\n"
"Run\n"
"\n"
@@ -204,7 +204,7 @@ const char *fmt_ident(const char *name, const char *email,
if ((warn_on_no_name || error_on_no_name) &&
name == git_default_name && env_hint) {
fprintf(stderr, env_hint, au_env, co_env);
- env_hint = NULL; /* warn only once, for "git-var -l" */
+ env_hint = NULL; /* warn only once, for "git var -l" */
}
if (error_on_no_name)
die("empty ident %s <%s> not allowed", name, email);
@@ -250,6 +250,9 @@ const char *git_author_info(int flag)
const char *git_committer_info(int flag)
{
+ if (getenv("GIT_COMMITTER_NAME") &&
+ getenv("GIT_COMMITTER_EMAIL"))
+ user_ident_explicitly_given = 1;
return fmt_ident(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL"),
getenv("GIT_COMMITTER_DATE"),
diff --git a/imap-send.c b/imap-send.c
index a429a76a6..1ec131092 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -472,7 +472,7 @@ v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,
if (socket_write( &imap->buf.sock, buf, bufl ) != bufl) {
free( cmd->cmd );
free( cmd );
- if (cb && cb->data)
+ if (cb)
free( cb->data );
return NULL;
}
@@ -858,8 +858,7 @@ get_cmd_result( imap_store_t *ctx, struct imap_cmd *tcmd )
normal:
if (cmdp->cb.done)
cmdp->cb.done( ctx, cmdp, resp );
- if (cmdp->cb.data)
- free( cmdp->cb.data );
+ free( cmdp->cb.data );
free( cmdp->cmd );
free( cmdp );
if (!tcmd || tcmd == cmdp)
@@ -1248,12 +1247,16 @@ static imap_server_conf_t server =
static char *imap_folder;
static int
-git_imap_config(const char *key, const char *val)
+git_imap_config(const char *key, const char *val, void *cb)
{
char imap_key[] = "imap.";
if (strncmp( key, imap_key, sizeof imap_key - 1 ))
return 0;
+
+ if (!val)
+ return config_error_nonbool(key);
+
key += sizeof imap_key - 1;
if (!strcmp( "folder", key )) {
@@ -1293,12 +1296,19 @@ main(int argc, char **argv)
/* init the random number generator */
arc4_init();
- git_config( git_imap_config );
+ git_config(git_imap_config, NULL);
if (!imap_folder) {
fprintf( stderr, "no imap store specified\n" );
return 1;
}
+ if (!server.host) {
+ if (!server.tunnel) {
+ fprintf( stderr, "no imap host specified\n" );
+ return 1;
+ }
+ server.host = "tunnel";
+ }
/* read the messages */
if (!read_message( stdin, &all_msgs )) {
diff --git a/index-pack.c b/index-pack.c
index 9fd6982a9..52064befd 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -7,9 +7,10 @@
#include "tag.h"
#include "tree.h"
#include "progress.h"
+#include "fsck.h"
static const char index_pack_usage[] =
-"git-index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
+"git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
struct object_entry
{
@@ -25,12 +26,23 @@ union delta_base {
off_t offset;
};
+struct base_data {
+ struct base_data *base;
+ struct base_data *child;
+ struct object_entry *obj;
+ void *data;
+ unsigned long size;
+};
+
/*
* Even if sizeof(union delta_base) == 24 on 64-bit archs, we really want
* to memcmp() only the first 20 bytes.
*/
#define UNION_BASE_SZ 20
+#define FLAG_LINK (1u<<20)
+#define FLAG_CHECKED (1u<<21)
+
struct delta_entry
{
union delta_base base;
@@ -39,11 +51,14 @@ struct delta_entry
static struct object_entry *objects;
static struct delta_entry *deltas;
+static struct base_data *base_cache;
+static size_t base_cache_used;
static int nr_objects;
static int nr_deltas;
static int nr_resolved_deltas;
static int from_stdin;
+static int strict;
static int verbose;
static struct progress *progress;
@@ -56,6 +71,48 @@ static SHA_CTX input_ctx;
static uint32_t input_crc32;
static int input_fd, output_fd, pack_fd;
+static int mark_link(struct object *obj, int type, void *data)
+{
+ if (!obj)
+ return -1;
+
+ if (type != OBJ_ANY && obj->type != type)
+ die("object type mismatch at %s", sha1_to_hex(obj->sha1));
+
+ obj->flags |= FLAG_LINK;
+ return 0;
+}
+
+/* The content of each linked object must have been checked
+ or it must be already present in the object database */
+static void check_object(struct object *obj)
+{
+ if (!obj)
+ return;
+
+ if (!(obj->flags & FLAG_LINK))
+ return;
+
+ if (!(obj->flags & FLAG_CHECKED)) {
+ unsigned long size;
+ int type = sha1_object_info(obj->sha1, &size);
+ if (type != obj->type || type <= 0)
+ die("object of unexpected type");
+ obj->flags |= FLAG_CHECKED;
+ return;
+ }
+}
+
+static void check_objects(void)
+{
+ unsigned i, max;
+
+ max = get_max_object_index();
+ for (i = 0; i < max; i++)
+ check_object(get_indexed_object(i));
+}
+
+
/* Discard current buffer used content. */
static void flush(void)
{
@@ -143,7 +200,8 @@ static void parse_pack_header(void)
if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
die("pack signature mismatch");
if (!pack_version_ok(hdr->hdr_version))
- die("pack version %d unsupported", ntohl(hdr->hdr_version));
+ die("pack version %"PRIu32" unsupported",
+ ntohl(hdr->hdr_version));
nr_objects = ntohl(hdr->hdr_entries);
use(sizeof(struct pack_header));
@@ -163,6 +221,46 @@ static void bad_object(unsigned long offset, const char *format, ...)
die("pack has bad object at offset %lu: %s", offset, buf);
}
+static void prune_base_data(struct base_data *retain)
+{
+ struct base_data *b = base_cache;
+ for (b = base_cache;
+ base_cache_used > delta_base_cache_limit && b;
+ b = b->child) {
+ if (b->data && b != retain) {
+ free(b->data);
+ b->data = NULL;
+ base_cache_used -= b->size;
+ }
+ }
+}
+
+static void link_base_data(struct base_data *base, struct base_data *c)
+{
+ if (base)
+ base->child = c;
+ else
+ base_cache = c;
+
+ c->base = base;
+ c->child = NULL;
+ base_cache_used += c->size;
+ prune_base_data(c);
+}
+
+static void unlink_base_data(struct base_data *c)
+{
+ struct base_data *base = c->base;
+ if (base)
+ base->child = NULL;
+ else
+ base_cache = NULL;
+ if (c->data) {
+ free(c->data);
+ base_cache_used -= c->size;
+ }
+}
+
static void *unpack_entry_data(unsigned long offset, unsigned long size)
{
z_stream stream;
@@ -341,35 +439,97 @@ static void sha1_object(const void *data, unsigned long size,
die("SHA1 COLLISION FOUND WITH %s !", sha1_to_hex(sha1));
free(has_data);
}
+ if (strict) {
+ if (type == OBJ_BLOB) {
+ struct blob *blob = lookup_blob(sha1);
+ if (blob)
+ blob->object.flags |= FLAG_CHECKED;
+ else
+ die("invalid blob object %s", sha1_to_hex(sha1));
+ } else {
+ struct object *obj;
+ int eaten;
+ void *buf = (void *) data;
+
+ /*
+ * we do not need to free the memory here, as the
+ * buf is deleted by the caller.
+ */
+ obj = parse_object_buffer(sha1, type, size, buf, &eaten);
+ if (!obj)
+ die("invalid %s", typename(type));
+ if (fsck_object(obj, 1, fsck_error_function))
+ die("Error in object");
+ if (fsck_walk(obj, mark_link, 0))
+ die("Not all child objects of %s are reachable", sha1_to_hex(obj->sha1));
+
+ if (obj->type == OBJ_TREE) {
+ struct tree *item = (struct tree *) obj;
+ item->buffer = NULL;
+ }
+ if (obj->type == OBJ_COMMIT) {
+ struct commit *commit = (struct commit *) obj;
+ commit->buffer = NULL;
+ }
+ obj->flags |= FLAG_CHECKED;
+ }
+ }
+}
+
+static void *get_base_data(struct base_data *c)
+{
+ if (!c->data) {
+ struct object_entry *obj = c->obj;
+
+ if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
+ void *base = get_base_data(c->base);
+ void *raw = get_data_from_pack(obj);
+ c->data = patch_delta(
+ base, c->base->size,
+ raw, obj->size,
+ &c->size);
+ free(raw);
+ if (!c->data)
+ bad_object(obj->idx.offset, "failed to apply delta");
+ } else
+ c->data = get_data_from_pack(obj);
+
+ base_cache_used += c->size;
+ prune_base_data(c);
+ }
+ return c->data;
}
-static void resolve_delta(struct object_entry *delta_obj, void *base_data,
- unsigned long base_size, enum object_type type)
+static void resolve_delta(struct object_entry *delta_obj,
+ struct base_data *base_obj, enum object_type type)
{
void *delta_data;
unsigned long delta_size;
- void *result;
- unsigned long result_size;
union delta_base delta_base;
int j, first, last;
+ struct base_data result;
delta_obj->real_type = type;
delta_data = get_data_from_pack(delta_obj);
delta_size = delta_obj->size;
- result = patch_delta(base_data, base_size, delta_data, delta_size,
- &result_size);
+ result.data = patch_delta(get_base_data(base_obj), base_obj->size,
+ delta_data, delta_size,
+ &result.size);
free(delta_data);
- if (!result)
+ if (!result.data)
bad_object(delta_obj->idx.offset, "failed to apply delta");
- sha1_object(result, result_size, type, delta_obj->idx.sha1);
+ sha1_object(result.data, result.size, type, delta_obj->idx.sha1);
nr_resolved_deltas++;
+ result.obj = delta_obj;
+ link_base_data(base_obj, &result);
+
hashcpy(delta_base.sha1, delta_obj->idx.sha1);
if (!find_delta_children(&delta_base, &first, &last)) {
for (j = first; j <= last; j++) {
struct object_entry *child = objects + deltas[j].obj_no;
if (child->real_type == OBJ_REF_DELTA)
- resolve_delta(child, result, result_size, type);
+ resolve_delta(child, &result, type);
}
}
@@ -379,11 +539,11 @@ static void resolve_delta(struct object_entry *delta_obj, void *base_data,
for (j = first; j <= last; j++) {
struct object_entry *child = objects + deltas[j].obj_no;
if (child->real_type == OBJ_OFS_DELTA)
- resolve_delta(child, result, result_size, type);
+ resolve_delta(child, &result, type);
}
}
- free(result);
+ unlink_base_data(&result);
}
static int compare_delta_entry(const void *a, const void *b)
@@ -398,7 +558,6 @@ static void parse_pack_objects(unsigned char *sha1)
{
int i;
struct delta_entry *delta = deltas;
- void *data;
struct stat st;
/*
@@ -413,7 +572,7 @@ static void parse_pack_objects(unsigned char *sha1)
nr_objects);
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
- data = unpack_raw_entry(obj, &delta->base);
+ void *data = unpack_raw_entry(obj, &delta->base);
obj->real_type = obj->type;
if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA) {
nr_deltas++;
@@ -462,6 +621,7 @@ static void parse_pack_objects(unsigned char *sha1)
struct object_entry *obj = &objects[i];
union delta_base base;
int j, ref, ref_first, ref_last, ofs, ofs_first, ofs_last;
+ struct base_data base_obj;
if (obj->type == OBJ_REF_DELTA || obj->type == OBJ_OFS_DELTA)
continue;
@@ -472,22 +632,24 @@ static void parse_pack_objects(unsigned char *sha1)
ofs = !find_delta_children(&base, &ofs_first, &ofs_last);
if (!ref && !ofs)
continue;
- data = get_data_from_pack(obj);
+ base_obj.data = get_data_from_pack(obj);
+ base_obj.size = obj->size;
+ base_obj.obj = obj;
+ link_base_data(NULL, &base_obj);
+
if (ref)
for (j = ref_first; j <= ref_last; j++) {
struct object_entry *child = objects + deltas[j].obj_no;
if (child->real_type == OBJ_REF_DELTA)
- resolve_delta(child, data,
- obj->size, obj->type);
+ resolve_delta(child, &base_obj, obj->type);
}
if (ofs)
for (j = ofs_first; j <= ofs_last; j++) {
struct object_entry *child = objects + deltas[j].obj_no;
if (child->real_type == OBJ_OFS_DELTA)
- resolve_delta(child, data,
- obj->size, obj->type);
+ resolve_delta(child, &base_obj, obj->type);
}
- free(data);
+ unlink_base_data(&base_obj);
display_progress(progress, nr_resolved_deltas);
}
}
@@ -518,7 +680,8 @@ static int write_compressed(int fd, void *in, unsigned int size, uint32_t *obj_c
return size;
}
-static void append_obj_to_pack(const unsigned char *sha1, void *buf,
+static struct object_entry *append_obj_to_pack(
+ const unsigned char *sha1, void *buf,
unsigned long size, enum object_type type)
{
struct object_entry *obj = &objects[nr_objects++];
@@ -536,9 +699,14 @@ static void append_obj_to_pack(const unsigned char *sha1, void *buf,
write_or_die(output_fd, header, n);
obj[0].idx.crc32 = crc32(0, Z_NULL, 0);
obj[0].idx.crc32 = crc32(obj[0].idx.crc32, header, n);
+ obj[0].size = size;
+ obj[0].hdr_size = n;
+ obj[0].type = type;
+ obj[0].real_type = type;
obj[1].idx.offset = obj[0].idx.offset + n;
obj[1].idx.offset += write_compressed(output_fd, buf, size, &obj[0].idx.crc32);
hashcpy(obj->idx.sha1, sha1);
+ return obj;
}
static int delta_pos_compare(const void *_a, const void *_b)
@@ -573,28 +741,31 @@ static void fix_unresolved_deltas(int nr_unresolved)
for (i = 0; i < n; i++) {
struct delta_entry *d = sorted_by_pos[i];
- void *data;
- unsigned long size;
enum object_type type;
int j, first, last;
+ struct base_data base_obj;
if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
continue;
- data = read_sha1_file(d->base.sha1, &type, &size);
- if (!data)
+ base_obj.data = read_sha1_file(d->base.sha1, &type, &base_obj.size);
+ if (!base_obj.data)
continue;
+ if (check_sha1_signature(d->base.sha1, base_obj.data,
+ base_obj.size, typename(type)))
+ die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
+ base_obj.obj = append_obj_to_pack(d->base.sha1, base_obj.data,
+ base_obj.size, type);
+ link_base_data(NULL, &base_obj);
+
find_delta_children(&d->base, &first, &last);
for (j = first; j <= last; j++) {
struct object_entry *child = objects + deltas[j].obj_no;
if (child->real_type == OBJ_REF_DELTA)
- resolve_delta(child, data, size, type);
+ resolve_delta(child, &base_obj, type);
}
- if (check_sha1_signature(d->base.sha1, data, size, typename(type)))
- die("local object %s is corrupt", sha1_to_hex(d->base.sha1));
- append_obj_to_pack(d->base.sha1, data, size, type);
- free(data);
+ unlink_base_data(&base_obj);
display_progress(progress, nr_resolved_deltas);
}
free(sorted_by_pos);
@@ -612,6 +783,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
if (!from_stdin) {
close(input_fd);
} else {
+ fsync_or_die(output_fd, curr_pack_name);
err = close(output_fd);
if (err)
die("error while closing pack file: %s", strerror(errno));
@@ -683,15 +855,16 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
}
}
-static int git_index_pack_config(const char *k, const char *v)
+static int git_index_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.indexversion")) {
pack_idx_default_version = git_config_int(k, v);
if (pack_idx_default_version > 2)
- die("bad pack.indexversion=%d", pack_idx_default_version);
+ die("bad pack.indexversion=%"PRIu32,
+ pack_idx_default_version);
return 0;
}
- return git_default_config(k, v);
+ return git_default_config(k, v, cb);
}
int main(int argc, char **argv)
@@ -704,7 +877,7 @@ int main(int argc, char **argv)
struct pack_idx_entry **idx_objects;
unsigned char sha1[20];
- git_config(git_index_pack_config);
+ git_config(git_index_pack_config, NULL);
for (i = 1; i < argc; i++) {
char *arg = argv[i];
@@ -714,6 +887,8 @@ int main(int argc, char **argv)
from_stdin = 1;
} else if (!strcmp(arg, "--fix-thin")) {
fix_thin_pack = 1;
+ } else if (!strcmp(arg, "--strict")) {
+ strict = 1;
} else if (!strcmp(arg, "--keep")) {
keep_msg = "";
} else if (!prefixcmp(arg, "--keep=")) {
@@ -812,6 +987,8 @@ int main(int argc, char **argv)
nr_deltas - nr_resolved_deltas);
}
free(deltas);
+ if (strict)
+ check_objects();
idx_objects = xmalloc((nr_objects) * sizeof(struct pack_idx_entry *));
for (i = 0; i < nr_objects; i++)
diff --git a/interpolate.c b/interpolate.c
index 6ef53f246..7f03bd99c 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -11,8 +11,7 @@ void interp_set_entry(struct interp *table, int slot, const char *value)
char *oldval = table[slot].value;
char *newval = NULL;
- if (oldval)
- free(oldval);
+ free(oldval);
if (value)
newval = xstrdup(value);
diff --git a/list-objects.c b/list-objects.c
index 4ef58e7ec..c8b8375e4 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -18,6 +18,8 @@ static void process_blob(struct rev_info *revs,
if (!revs->blob_objects)
return;
+ if (!obj)
+ die("bad blob object");
if (obj->flags & (UNINTERESTING | SEEN))
return;
obj->flags |= SEEN;
@@ -69,6 +71,8 @@ static void process_tree(struct rev_info *revs,
if (!revs->tree_objects)
return;
+ if (!obj)
+ die("bad tree object");
if (obj->flags & (UNINTERESTING | SEEN))
return;
if (parse_tree(tree) < 0)
diff --git a/ll-merge.c b/ll-merge.c
new file mode 100644
index 000000000..9837c842a
--- /dev/null
+++ b/ll-merge.c
@@ -0,0 +1,379 @@
+/*
+ * Low level 3-way in-core file merge.
+ *
+ * Copyright (c) 2007 Junio C Hamano
+ */
+
+#include "cache.h"
+#include "attr.h"
+#include "xdiff-interface.h"
+#include "run-command.h"
+#include "interpolate.h"
+#include "ll-merge.h"
+
+struct ll_merge_driver;
+
+typedef int (*ll_merge_fn)(const struct ll_merge_driver *,
+ mmbuffer_t *result,
+ const char *path,
+ mmfile_t *orig,
+ mmfile_t *src1, const char *name1,
+ mmfile_t *src2, const char *name2,
+ int virtual_ancestor);
+
+struct ll_merge_driver {
+ const char *name;
+ const char *description;
+ ll_merge_fn fn;
+ const char *recursive;
+ struct ll_merge_driver *next;
+ char *cmdline;
+};
+
+/*
+ * Built-in low-levels
+ */
+static int ll_binary_merge(const struct ll_merge_driver *drv_unused,
+ mmbuffer_t *result,
+ const char *path_unused,
+ mmfile_t *orig,
+ mmfile_t *src1, const char *name1,
+ mmfile_t *src2, const char *name2,
+ int virtual_ancestor)
+{
+ /*
+ * The tentative merge result is "ours" for the final round,
+ * or common ancestor for an internal merge. Still return
+ * "conflicted merge" status.
+ */
+ mmfile_t *stolen = virtual_ancestor ? orig : src1;
+
+ result->ptr = stolen->ptr;
+ result->size = stolen->size;
+ stolen->ptr = NULL;
+ return 1;
+}
+
+static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
+ mmbuffer_t *result,
+ const char *path_unused,
+ mmfile_t *orig,
+ mmfile_t *src1, const char *name1,
+ mmfile_t *src2, const char *name2,
+ int virtual_ancestor)
+{
+ xpparam_t xpp;
+
+ if (buffer_is_binary(orig->ptr, orig->size) ||
+ buffer_is_binary(src1->ptr, src1->size) ||
+ buffer_is_binary(src2->ptr, src2->size)) {
+ warning("Cannot merge binary files: %s vs. %s\n",
+ name1, name2);
+ return ll_binary_merge(drv_unused, result,
+ path_unused,
+ orig, src1, name1,
+ src2, name2,
+ virtual_ancestor);
+ }
+
+ memset(&xpp, 0, sizeof(xpp));
+ return xdl_merge(orig,
+ src1, name1,
+ src2, name2,
+ &xpp, XDL_MERGE_ZEALOUS,
+ result);
+}
+
+static int ll_union_merge(const struct ll_merge_driver *drv_unused,
+ mmbuffer_t *result,
+ const char *path_unused,
+ mmfile_t *orig,
+ mmfile_t *src1, const char *name1,
+ mmfile_t *src2, const char *name2,
+ int virtual_ancestor)
+{
+ char *src, *dst;
+ long size;
+ const int marker_size = 7;
+
+ int status = ll_xdl_merge(drv_unused, result, path_unused,
+ orig, src1, NULL, src2, NULL,
+ virtual_ancestor);
+ if (status <= 0)
+ return status;
+ size = result->size;
+ src = dst = result->ptr;
+ while (size) {
+ char ch;
+ if ((marker_size < size) &&
+ (*src == '<' || *src == '=' || *src == '>')) {
+ int i;
+ ch = *src;
+ for (i = 0; i < marker_size; i++)
+ if (src[i] != ch)
+ goto not_a_marker;
+ if (src[marker_size] != '\n')
+ goto not_a_marker;
+ src += marker_size + 1;
+ size -= marker_size + 1;
+ continue;
+ }
+ not_a_marker:
+ do {
+ ch = *src++;
+ *dst++ = ch;
+ size--;
+ } while (ch != '\n' && size);
+ }
+ result->size = dst - result->ptr;
+ return 0;
+}
+
+#define LL_BINARY_MERGE 0
+#define LL_TEXT_MERGE 1
+#define LL_UNION_MERGE 2
+static struct ll_merge_driver ll_merge_drv[] = {
+ { "binary", "built-in binary merge", ll_binary_merge },
+ { "text", "built-in 3-way text merge", ll_xdl_merge },
+ { "union", "built-in union merge", ll_union_merge },
+};
+
+static void create_temp(mmfile_t *src, char *path)
+{
+ int fd;
+
+ strcpy(path, ".merge_file_XXXXXX");
+ fd = xmkstemp(path);
+ if (write_in_full(fd, src->ptr, src->size) != src->size)
+ die("unable to write temp-file");
+ close(fd);
+}
+
+/*
+ * User defined low-level merge driver support.
+ */
+static int ll_ext_merge(const struct ll_merge_driver *fn,
+ mmbuffer_t *result,
+ const char *path,
+ mmfile_t *orig,
+ mmfile_t *src1, const char *name1,
+ mmfile_t *src2, const char *name2,
+ int virtual_ancestor)
+{
+ char temp[3][50];
+ char cmdbuf[2048];
+ struct interp table[] = {
+ { "%O" },
+ { "%A" },
+ { "%B" },
+ };
+ struct child_process child;
+ const char *args[20];
+ int status, fd, i;
+ struct stat st;
+
+ if (fn->cmdline == NULL)
+ die("custom merge driver %s lacks command line.", fn->name);
+
+ result->ptr = NULL;
+ result->size = 0;
+ create_temp(orig, temp[0]);
+ create_temp(src1, temp[1]);
+ create_temp(src2, temp[2]);
+
+ interp_set_entry(table, 0, temp[0]);
+ interp_set_entry(table, 1, temp[1]);
+ interp_set_entry(table, 2, temp[2]);
+
+ interpolate(cmdbuf, sizeof(cmdbuf), fn->cmdline, table, 3);
+
+ memset(&child, 0, sizeof(child));
+ child.argv = args;
+ args[0] = "sh";
+ args[1] = "-c";
+ args[2] = cmdbuf;
+ args[3] = NULL;
+
+ status = run_command(&child);
+ if (status < -ERR_RUN_COMMAND_FORK)
+ ; /* failure in run-command */
+ else
+ status = -status;
+ fd = open(temp[1], O_RDONLY);
+ if (fd < 0)
+ goto bad;
+ if (fstat(fd, &st))
+ goto close_bad;
+ result->size = st.st_size;
+ result->ptr = xmalloc(result->size + 1);
+ if (read_in_full(fd, result->ptr, result->size) != result->size) {
+ free(result->ptr);
+ result->ptr = NULL;
+ result->size = 0;
+ }
+ close_bad:
+ close(fd);
+ bad:
+ for (i = 0; i < 3; i++)
+ unlink(temp[i]);
+ return status;
+}
+
+/*
+ * merge.default and merge.driver configuration items
+ */
+static struct ll_merge_driver *ll_user_merge, **ll_user_merge_tail;
+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;
+ int namelen;
+
+ if (!strcmp(var, "merge.default")) {
+ if (value)
+ default_ll_merge = strdup(value);
+ return 0;
+ }
+
+ /*
+ * We are not interested in anything but "merge.<name>.variable";
+ * 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)
+ 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;
+ if (!fn) {
+ fn = xcalloc(1, sizeof(struct ll_merge_driver));
+ fn->name = xmemdupz(name, namelen);
+ fn->fn = ll_ext_merge;
+ *ll_user_merge_tail = fn;
+ ll_user_merge_tail = &(fn->next);
+ }
+
+ ep++;
+
+ if (!strcmp("name", ep)) {
+ if (!value)
+ return error("%s: lacks value", var);
+ fn->description = strdup(value);
+ return 0;
+ }
+
+ if (!strcmp("driver", ep)) {
+ if (!value)
+ return error("%s: lacks value", var);
+ /*
+ * merge.<name>.driver specifies the command line:
+ *
+ * command-line
+ *
+ * The command-line will be interpolated with the following
+ * tokens and is given to the shell:
+ *
+ * %O - temporary file name for the merge base.
+ * %A - temporary file name for our version.
+ * %B - temporary file name for the other branches' version.
+ *
+ * The external merge driver should write the results in the
+ * file named by %A, and signal that it has done with zero exit
+ * status.
+ */
+ fn->cmdline = strdup(value);
+ return 0;
+ }
+
+ if (!strcmp("recursive", ep)) {
+ if (!value)
+ return error("%s: lacks value", var);
+ fn->recursive = strdup(value);
+ return 0;
+ }
+
+ return 0;
+}
+
+static void initialize_ll_merge(void)
+{
+ if (ll_user_merge_tail)
+ return;
+ ll_user_merge_tail = &ll_user_merge;
+ git_config(read_merge_config, NULL);
+}
+
+static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr)
+{
+ struct ll_merge_driver *fn;
+ const char *name;
+ int i;
+
+ initialize_ll_merge();
+
+ if (ATTR_TRUE(merge_attr))
+ return &ll_merge_drv[LL_TEXT_MERGE];
+ else if (ATTR_FALSE(merge_attr))
+ return &ll_merge_drv[LL_BINARY_MERGE];
+ else if (ATTR_UNSET(merge_attr)) {
+ if (!default_ll_merge)
+ return &ll_merge_drv[LL_TEXT_MERGE];
+ else
+ name = default_ll_merge;
+ }
+ else
+ name = merge_attr;
+
+ for (fn = ll_user_merge; fn; fn = fn->next)
+ if (!strcmp(fn->name, name))
+ return fn;
+
+ for (i = 0; i < ARRAY_SIZE(ll_merge_drv); i++)
+ if (!strcmp(ll_merge_drv[i].name, name))
+ return &ll_merge_drv[i];
+
+ /* default to the 3-way */
+ return &ll_merge_drv[LL_TEXT_MERGE];
+}
+
+static const char *git_path_check_merge(const char *path)
+{
+ static struct git_attr_check attr_merge_check;
+
+ if (!attr_merge_check.attr)
+ attr_merge_check.attr = git_attr("merge", 5);
+
+ if (git_checkattr(path, 1, &attr_merge_check))
+ return NULL;
+ return attr_merge_check.value;
+}
+
+int ll_merge(mmbuffer_t *result_buf,
+ const char *path,
+ mmfile_t *ancestor,
+ mmfile_t *ours, const char *our_label,
+ mmfile_t *theirs, const char *their_label,
+ int virtual_ancestor)
+{
+ const char *ll_driver_name;
+ const struct ll_merge_driver *driver;
+
+ ll_driver_name = git_path_check_merge(path);
+ driver = find_ll_merge_driver(ll_driver_name);
+
+ if (virtual_ancestor && driver->recursive)
+ driver = find_ll_merge_driver(driver->recursive);
+ return driver->fn(driver, result_buf, path,
+ ancestor,
+ ours, our_label,
+ theirs, their_label, virtual_ancestor);
+}
diff --git a/ll-merge.h b/ll-merge.h
new file mode 100644
index 000000000..5388422d0
--- /dev/null
+++ b/ll-merge.h
@@ -0,0 +1,15 @@
+/*
+ * Low level 3-way in-core file merge.
+ */
+
+#ifndef LL_MERGE_H
+#define LL_MERGE_H
+
+int ll_merge(mmbuffer_t *result_buf,
+ const char *path,
+ mmfile_t *ancestor,
+ mmfile_t *ours, const char *our_label,
+ mmfile_t *theirs, const char *their_label,
+ int virtual_ancestor);
+
+#endif
diff --git a/lockfile.c b/lockfile.c
index 663f18f9c..4023797b0 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -24,7 +24,7 @@ static void remove_lock_file(void)
static void remove_lock_file_on_signal(int signo)
{
remove_lock_file();
- signal(SIGINT, SIG_DFL);
+ signal(signo, SIG_DFL);
raise(signo);
}
@@ -135,6 +135,9 @@ static int lock_file(struct lock_file *lk, const char *path)
if (0 <= lk->fd) {
if (!lock_file_list) {
signal(SIGINT, remove_lock_file_on_signal);
+ signal(SIGHUP, remove_lock_file_on_signal);
+ signal(SIGTERM, remove_lock_file_on_signal);
+ signal(SIGQUIT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
lk->owner = getpid();
@@ -160,6 +163,34 @@ int hold_lock_file_for_update(struct lock_file *lk, const char *path, int die_on
return fd;
}
+int hold_lock_file_for_append(struct lock_file *lk, const char *path, int die_on_error)
+{
+ int fd, orig_fd;
+
+ fd = lock_file(lk, path);
+ if (fd < 0) {
+ if (die_on_error)
+ die("unable to create '%s.lock': %s", path, strerror(errno));
+ return fd;
+ }
+
+ orig_fd = open(path, O_RDONLY);
+ if (orig_fd < 0) {
+ if (errno != ENOENT) {
+ if (die_on_error)
+ die("cannot open '%s' for copying", path);
+ close(fd);
+ return error("cannot open '%s' for copying", path);
+ }
+ } else if (copy_fd(orig_fd, fd)) {
+ if (die_on_error)
+ exit(128);
+ close(fd);
+ return -1;
+ }
+ return fd;
+}
+
int close_lock_file(struct lock_file *lk)
{
int fd = lk->fd;
diff --git a/log-tree.c b/log-tree.c
index 1f3fcf16a..bd8b9e45a 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "diff.h"
#include "commit.h"
+#include "graph.h"
#include "log-tree.h"
#include "reflog-walk.h"
@@ -137,128 +138,179 @@ static int has_non_ascii(const char *s)
return 0;
}
-void show_log(struct rev_info *opt, const char *sep)
+void log_write_email_headers(struct rev_info *opt, const char *name,
+ const char **subject_p,
+ const char **extra_headers_p,
+ int *need_8bit_cte_p)
+{
+ const char *subject = NULL;
+ const char *extra_headers = opt->extra_headers;
+
+ *need_8bit_cte_p = 0; /* unknown */
+ if (opt->total > 0) {
+ static char buffer[64];
+ snprintf(buffer, sizeof(buffer),
+ "Subject: [%s %0*d/%d] ",
+ opt->subject_prefix,
+ digits_in_number(opt->total),
+ opt->nr, opt->total);
+ subject = buffer;
+ } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
+ static char buffer[256];
+ snprintf(buffer, sizeof(buffer),
+ "Subject: [%s] ",
+ opt->subject_prefix);
+ subject = buffer;
+ } else {
+ subject = "Subject: ";
+ }
+
+ printf("From %s Mon Sep 17 00:00:00 2001\n", name);
+ graph_show_oneline(opt->graph);
+ if (opt->message_id) {
+ printf("Message-Id: <%s>\n", opt->message_id);
+ graph_show_oneline(opt->graph);
+ }
+ if (opt->ref_message_id) {
+ printf("In-Reply-To: <%s>\nReferences: <%s>\n",
+ opt->ref_message_id, opt->ref_message_id);
+ graph_show_oneline(opt->graph);
+ }
+ if (opt->mime_boundary) {
+ static char subject_buffer[1024];
+ static char buffer[1024];
+ *need_8bit_cte_p = -1; /* NEVER */
+ snprintf(subject_buffer, sizeof(subject_buffer) - 1,
+ "%s"
+ "MIME-Version: 1.0\n"
+ "Content-Type: multipart/mixed;"
+ " boundary=\"%s%s\"\n"
+ "\n"
+ "This is a multi-part message in MIME "
+ "format.\n"
+ "--%s%s\n"
+ "Content-Type: text/plain; "
+ "charset=UTF-8; format=fixed\n"
+ "Content-Transfer-Encoding: 8bit\n\n",
+ extra_headers ? extra_headers : "",
+ mime_boundary_leader, opt->mime_boundary,
+ mime_boundary_leader, opt->mime_boundary);
+ extra_headers = subject_buffer;
+
+ snprintf(buffer, sizeof(buffer) - 1,
+ "\n--%s%s\n"
+ "Content-Type: text/x-patch;"
+ " name=\"%s.diff\"\n"
+ "Content-Transfer-Encoding: 8bit\n"
+ "Content-Disposition: %s;"
+ " filename=\"%s.diff\"\n\n",
+ mime_boundary_leader, opt->mime_boundary,
+ name,
+ opt->no_inline ? "attachment" : "inline",
+ name);
+ opt->diffopt.stat_sep = buffer;
+ }
+ *subject_p = subject;
+ *extra_headers_p = extra_headers;
+}
+
+void show_log(struct rev_info *opt)
{
struct strbuf msgbuf;
struct log_info *log = opt->loginfo;
struct commit *commit = log->commit, *parent = log->parent;
int abbrev = opt->diffopt.abbrev;
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
- const char *extra;
const char *subject = NULL, *extra_headers = opt->extra_headers;
+ int need_8bit_cte = 0;
opt->loginfo = NULL;
if (!opt->verbose_header) {
- if (opt->left_right) {
+ graph_show_commit(opt->graph);
+
+ if (!opt->graph) {
if (commit->object.flags & BOUNDARY)
putchar('-');
- else if (commit->object.flags & SYMMETRIC_LEFT)
- putchar('<');
- else
- putchar('>');
+ else if (commit->object.flags & UNINTERESTING)
+ putchar('^');
+ else if (opt->left_right) {
+ if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
- if (opt->parents)
+ if (opt->print_parents)
show_parents(commit, abbrev_commit);
show_decorations(commit);
+ if (opt->graph && !graph_is_commit_finished(opt->graph)) {
+ putchar('\n');
+ graph_show_remainder(opt->graph);
+ }
putchar(opt->diffopt.line_termination);
return;
}
/*
- * The "oneline" format has several special cases:
- * - The pretty-printed commit lacks a newline at the end
- * of the buffer, but we do want to make sure that we
- * have a newline there. If the separator isn't already
- * a newline, add an extra one.
- * - unlike other log messages, the one-line format does
- * not have an empty line between entries.
+ * If use_terminator is set, add a newline at the end of the entry.
+ * Otherwise, add a diffopt.line_termination character before all
+ * entries but the first. (IOW, as a separator between entries)
*/
- extra = "";
- if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
- extra = "\n";
- if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
+ if (opt->shown_one && !opt->use_terminator) {
+ /*
+ * If entries are separated by a newline, the output
+ * should look human-readable. If the last entry ended
+ * with a newline, print the graph output before this
+ * newline. Otherwise it will end up as a completely blank
+ * line and will look like a gap in the graph.
+ *
+ * If the entry separator is not a newline, the output is
+ * primarily intended for programmatic consumption, and we
+ * never want the extra graph output before the entry
+ * separator.
+ */
+ if (opt->diffopt.line_termination == '\n' &&
+ !opt->missing_newline)
+ graph_show_padding(opt->graph);
putchar(opt->diffopt.line_termination);
+ }
opt->shown_one = 1;
/*
+ * If the history graph was requested,
+ * print the graph, up to this commit's line
+ */
+ graph_show_commit(opt->graph);
+
+ /*
* Print header line of header..
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
- char *sha1 = sha1_to_hex(commit->object.sha1);
- if (opt->total > 0) {
- static char buffer[64];
- snprintf(buffer, sizeof(buffer),
- "Subject: [%s %0*d/%d] ",
- opt->subject_prefix,
- digits_in_number(opt->total),
- opt->nr, opt->total);
- subject = buffer;
- } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
- static char buffer[256];
- snprintf(buffer, sizeof(buffer),
- "Subject: [%s] ",
- opt->subject_prefix);
- subject = buffer;
- } else {
- subject = "Subject: ";
- }
-
- printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
- if (opt->message_id)
- printf("Message-Id: <%s>\n", opt->message_id);
- if (opt->ref_message_id)
- printf("In-Reply-To: <%s>\nReferences: <%s>\n",
- opt->ref_message_id, opt->ref_message_id);
- if (opt->mime_boundary) {
- static char subject_buffer[1024];
- static char buffer[1024];
- snprintf(subject_buffer, sizeof(subject_buffer) - 1,
- "%s"
- "MIME-Version: 1.0\n"
- "Content-Type: multipart/mixed;"
- " boundary=\"%s%s\"\n"
- "\n"
- "This is a multi-part message in MIME "
- "format.\n"
- "--%s%s\n"
- "Content-Type: text/plain; "
- "charset=UTF-8; format=fixed\n"
- "Content-Transfer-Encoding: 8bit\n\n",
- extra_headers ? extra_headers : "",
- mime_boundary_leader, opt->mime_boundary,
- mime_boundary_leader, opt->mime_boundary);
- extra_headers = subject_buffer;
-
- snprintf(buffer, sizeof(buffer) - 1,
- "--%s%s\n"
- "Content-Type: text/x-patch;"
- " name=\"%s.diff\"\n"
- "Content-Transfer-Encoding: 8bit\n"
- "Content-Disposition: %s;"
- " filename=\"%s.diff\"\n\n",
- mime_boundary_leader, opt->mime_boundary,
- sha1,
- opt->no_inline ? "attachment" : "inline",
- sha1);
- opt->diffopt.stat_sep = buffer;
- }
+ log_write_email_headers(opt, sha1_to_hex(commit->object.sha1),
+ &subject, &extra_headers,
+ &need_8bit_cte);
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
fputs("commit ", stdout);
- if (commit->object.flags & BOUNDARY)
- putchar('-');
- else if (opt->left_right) {
- if (commit->object.flags & SYMMETRIC_LEFT)
- putchar('<');
- else
- putchar('>');
+
+ if (!opt->graph) {
+ if (commit->object.flags & BOUNDARY)
+ putchar('-');
+ else if (commit->object.flags & UNINTERESTING)
+ putchar('^');
+ else if (opt->left_right) {
+ if (commit->object.flags & SYMMETRIC_LEFT)
+ putchar('<');
+ else
+ putchar('>');
+ }
}
fputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),
stdout);
- if (opt->parents)
+ if (opt->print_parents)
show_parents(commit, abbrev_commit);
if (parent)
printf(" (from %s)",
@@ -266,33 +318,66 @@ void show_log(struct rev_info *opt, const char *sep)
abbrev_commit));
show_decorations(commit);
printf("%s", diff_get_color_opt(&opt->diffopt, DIFF_RESET));
- putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
+ if (opt->commit_format == CMIT_FMT_ONELINE) {
+ putchar(' ');
+ } else {
+ putchar('\n');
+ graph_show_oneline(opt->graph);
+ }
if (opt->reflog_info) {
+ /*
+ * setup_revisions() ensures that opt->reflog_info
+ * and opt->graph cannot both be set,
+ * so we don't need to worry about printing the
+ * graph info here.
+ */
show_reflog_message(opt->reflog_info,
opt->commit_format == CMIT_FMT_ONELINE,
opt->date_mode);
- if (opt->commit_format == CMIT_FMT_ONELINE) {
- printf("%s", sep);
+ if (opt->commit_format == CMIT_FMT_ONELINE)
return;
- }
}
}
+ if (!commit->buffer)
+ return;
+
/*
* And then the pretty-printed message itself
*/
strbuf_init(&msgbuf, 0);
+ if (need_8bit_cte >= 0)
+ need_8bit_cte = has_non_ascii(opt->add_signoff);
pretty_print_commit(opt->commit_format, commit, &msgbuf,
abbrev, subject, extra_headers, opt->date_mode,
- has_non_ascii(opt->add_signoff));
+ need_8bit_cte);
if (opt->add_signoff)
append_signoff(&msgbuf, opt->add_signoff);
- if (opt->show_log_size)
+ if (opt->show_log_size) {
printf("log size %i\n", (int)msgbuf.len);
+ graph_show_oneline(opt->graph);
+ }
+
+ /*
+ * Set opt->missing_newline if msgbuf doesn't
+ * end in a newline (including if it is empty)
+ */
+ if (!msgbuf.len || msgbuf.buf[msgbuf.len - 1] != '\n')
+ opt->missing_newline = 1;
+ else
+ opt->missing_newline = 0;
+
+ if (opt->graph)
+ graph_show_commit_msg(opt->graph, &msgbuf);
+ else
+ fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
+ if (opt->use_terminator) {
+ if (!opt->missing_newline)
+ graph_show_padding(opt->graph);
+ putchar('\n');
+ }
- if (msgbuf.len)
- printf("%s%s%s", msgbuf.buf, extra, sep);
strbuf_release(&msgbuf);
}
@@ -314,7 +399,7 @@ int log_tree_diff_flush(struct rev_info *opt)
* an extra newline between the end of log and the
* output for readability.
*/
- show_log(opt, opt->diffopt.msg_sep);
+ show_log(opt);
if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
opt->verbose_header &&
opt->commit_format != CMIT_FMT_ONELINE) {
@@ -402,7 +487,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)
shown = log_tree_diff(opt, commit, &log);
if (!shown && opt->loginfo && opt->always_show_header) {
log.parent = NULL;
- show_log(opt, "");
+ show_log(opt);
shown = 1;
}
opt->loginfo = NULL;
diff --git a/log-tree.h b/log-tree.h
index b33f7cd7a..59ba4c48b 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -11,7 +11,11 @@ void init_log_tree_opt(struct rev_info *);
int log_tree_diff_flush(struct rev_info *);
int log_tree_commit(struct rev_info *, struct commit *);
int log_tree_opt_parse(struct rev_info *, const char **, int);
-void show_log(struct rev_info *opt, const char *sep);
+void show_log(struct rev_info *opt);
void show_decorations(struct commit *commit);
+void log_write_email_headers(struct rev_info *opt, const char *name,
+ const char **subject_p,
+ const char **extra_headers_p,
+ int *need_8bit_cte_p);
#endif
diff --git a/mailmap.c b/mailmap.c
index f0172552e..88fc6f394 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,8 +1,8 @@
#include "cache.h"
-#include "path-list.h"
+#include "string-list.h"
#include "mailmap.h"
-int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev)
+int read_mailmap(struct string_list *map, const char *filename, char **repo_abbrev)
{
char buffer[1024];
FILE *f = fopen(filename, "r");
@@ -54,16 +54,16 @@ int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev
for (i = 0; i < right_bracket - left_bracket - 1; i++)
email[i] = tolower(left_bracket[i + 1]);
email[right_bracket - left_bracket - 1] = '\0';
- path_list_insert(email, map)->util = name;
+ string_list_insert(email, map)->util = name;
}
fclose(f);
return 0;
}
-int map_email(struct path_list *map, const char *email, char *name, int maxlen)
+int map_email(struct string_list *map, const char *email, char *name, int maxlen)
{
char *p;
- struct path_list_item *item;
+ struct string_list_item *item;
char buf[1024], *mailbuf;
int i;
@@ -80,7 +80,7 @@ int map_email(struct path_list *map, const char *email, char *name, int maxlen)
for (i = 0; i < p - email; i++)
mailbuf[i] = tolower(email[i]);
mailbuf[i] = 0;
- item = path_list_lookup(mailbuf, map);
+ item = string_list_lookup(mailbuf, map);
if (mailbuf != buf)
free(mailbuf);
if (item != NULL) {
diff --git a/mailmap.h b/mailmap.h
index 3503fd272..6e48f83ce 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -1,7 +1,7 @@
#ifndef MAILMAP_H
#define MAILMAP_H
-int read_mailmap(struct path_list *map, const char *filename, char **repo_abbrev);
-int map_email(struct path_list *mailmap, const char *email, char *name, int maxlen);
+int read_mailmap(struct string_list *map, const char *filename, char **repo_abbrev);
+int map_email(struct string_list *mailmap, const char *email, char *name, int maxlen);
#endif
diff --git a/merge-index.c b/merge-index.c
index bbb700b54..7491c56ad 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -91,7 +91,7 @@ int main(int argc, char **argv)
signal(SIGCHLD, SIG_DFL);
if (argc < 3)
- usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
+ usage("git-merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)");
setup_git_directory();
read_cache();
diff --git a/merge-tree.c b/merge-tree.c
index e08324686..02fc10f7e 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -168,7 +168,13 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsi
return res;
}
-static void resolve(const char *base, struct name_entry *branch1, struct name_entry *result)
+static char *traverse_path(const struct traverse_info *info, const struct name_entry *n)
+{
+ char *path = xmalloc(traverse_path_len(info, n) + 1);
+ return make_traverse_path(path, info, n);
+}
+
+static void resolve(const struct traverse_info *info, struct name_entry *branch1, struct name_entry *result)
{
struct merge_list *orig, *final;
const char *path;
@@ -177,7 +183,7 @@ static void resolve(const char *base, struct name_entry *branch1, struct name_en
if (!branch1)
return;
- path = xstrdup(mkpath("%s%s", base, result->path));
+ path = traverse_path(info, result);
orig = create_entry(2, branch1->mode, branch1->sha1, path);
final = create_entry(0, result->mode, result->sha1, path);
@@ -186,9 +192,8 @@ static void resolve(const char *base, struct name_entry *branch1, struct name_en
add_merge_entry(final);
}
-static int unresolved_directory(const char *base, struct name_entry n[3])
+static int unresolved_directory(const struct traverse_info *info, struct name_entry n[3])
{
- int baselen, pathlen;
char *newbase;
struct name_entry *p;
struct tree_desc t[3];
@@ -204,13 +209,7 @@ static int unresolved_directory(const char *base, struct name_entry n[3])
}
if (!S_ISDIR(p->mode))
return 0;
- baselen = strlen(base);
- pathlen = tree_entry_len(p->path, p->sha1);
- newbase = xmalloc(baselen + pathlen + 2);
- memcpy(newbase, base, baselen);
- memcpy(newbase + baselen, p->path, pathlen);
- memcpy(newbase + baselen + pathlen, "/", 2);
-
+ newbase = traverse_path(info, p);
buf0 = fill_tree_descriptor(t+0, n[0].sha1);
buf1 = fill_tree_descriptor(t+1, n[1].sha1);
buf2 = fill_tree_descriptor(t+2, n[2].sha1);
@@ -224,7 +223,7 @@ static int unresolved_directory(const char *base, struct name_entry n[3])
}
-static struct merge_list *link_entry(unsigned stage, const char *base, struct name_entry *n, struct merge_list *entry)
+static struct merge_list *link_entry(unsigned stage, const struct traverse_info *info, struct name_entry *n, struct merge_list *entry)
{
const char *path;
struct merge_list *link;
@@ -234,17 +233,17 @@ static struct merge_list *link_entry(unsigned stage, const char *base, struct na
if (entry)
path = entry->path;
else
- path = xstrdup(mkpath("%s%s", base, n->path));
+ path = traverse_path(info, n);
link = create_entry(stage, n->mode, n->sha1, path);
link->link = entry;
return link;
}
-static void unresolved(const char *base, struct name_entry n[3])
+static void unresolved(const struct traverse_info *info, struct name_entry n[3])
{
struct merge_list *entry = NULL;
- if (unresolved_directory(base, n))
+ if (unresolved_directory(info, n))
return;
/*
@@ -252,9 +251,9 @@ static void unresolved(const char *base, struct name_entry n[3])
* list has the stages in order - link_entry adds new
* links at the front.
*/
- entry = link_entry(3, base, n + 2, entry);
- entry = link_entry(2, base, n + 1, entry);
- entry = link_entry(1, base, n + 0, entry);
+ entry = link_entry(3, info, n + 2, entry);
+ entry = link_entry(2, info, n + 1, entry);
+ entry = link_entry(1, info, n + 0, entry);
add_merge_entry(entry);
}
@@ -288,36 +287,41 @@ static void unresolved(const char *base, struct name_entry n[3])
* The successful merge rules are the same as for the three-way merge
* in git-read-tree.
*/
-static void threeway_callback(int n, unsigned long mask, struct name_entry *entry, const char *base)
+static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
{
/* Same in both? */
if (same_entry(entry+1, entry+2)) {
if (entry[0].sha1) {
- resolve(base, NULL, entry+1);
- return;
+ resolve(info, NULL, entry+1);
+ return mask;
}
}
if (same_entry(entry+0, entry+1)) {
if (entry[2].sha1 && !S_ISDIR(entry[2].mode)) {
- resolve(base, entry+1, entry+2);
- return;
+ resolve(info, entry+1, entry+2);
+ return mask;
}
}
if (same_entry(entry+0, entry+2)) {
if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
- resolve(base, NULL, entry+1);
- return;
+ resolve(info, NULL, entry+1);
+ return mask;
}
}
- unresolved(base, entry);
+ unresolved(info, entry);
+ return mask;
}
static void merge_trees(struct tree_desc t[3], const char *base)
{
- traverse_trees(3, t, base, threeway_callback);
+ struct traverse_info info;
+
+ setup_traverse_info(&info, base);
+ info.fn = threeway_callback;
+ traverse_trees(3, t, &info);
}
static void *get_tree_descriptor(struct tree_desc *desc, const char *rev)
diff --git a/mktag.c b/mktag.c
index b05260c83..0b34341f7 100644
--- a/mktag.c
+++ b/mktag.c
@@ -8,10 +8,11 @@
* message and a signature block that git itself doesn't care about,
* but that can be verified with gpg or similar.
*
- * The first three lines are guaranteed to be at least 63 bytes:
+ * The first four lines are guaranteed to be at least 83 bytes:
* "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the
- * shortest possible type-line, and "tag .\n" at 6 bytes is the
- * shortest single-character-tag line.
+ * shortest possible type-line, "tag .\n" at 6 bytes is the shortest
+ * single-character-tag line, and "tagger . <> 0 +0000\n" at 20 bytes is
+ * the shortest possible tagger-line.
*/
/*
@@ -43,9 +44,10 @@ static int verify_tag(char *buffer, unsigned long size)
int typelen;
char type[20];
unsigned char sha1[20];
- const char *object, *type_line, *tag_line, *tagger_line;
+ const char *object, *type_line, *tag_line, *tagger_line, *lb, *rb;
+ size_t len;
- if (size < 64)
+ if (size < 84)
return error("wanna fool me ? you obviously got the size wrong !");
buffer[size] = 0;
@@ -97,11 +99,51 @@ static int verify_tag(char *buffer, unsigned long size)
/* Verify the tagger line */
tagger_line = tag_line;
- if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
- return error("char" PD_FMT ": could not find \"tagger\"", tagger_line - buffer);
-
- /* TODO: check for committer info + blank line? */
- /* Also, the minimum length is probably + "tagger .", or 63+8=71 */
+ if (memcmp(tagger_line, "tagger ", 7))
+ return error("char" PD_FMT ": could not find \"tagger \"",
+ tagger_line - buffer);
+
+ /*
+ * Check for correct form for name and email
+ * i.e. " <" followed by "> " on _this_ line
+ * No angle brackets within the name or email address fields.
+ * No spaces within the email address field.
+ */
+ tagger_line += 7;
+ if (!(lb = strstr(tagger_line, " <")) || !(rb = strstr(lb+2, "> ")) ||
+ strpbrk(tagger_line, "<>\n") != lb+1 ||
+ strpbrk(lb+2, "><\n ") != rb)
+ return error("char" PD_FMT ": malformed tagger field",
+ tagger_line - buffer);
+
+ /* Check for author name, at least one character, space is acceptable */
+ if (lb == tagger_line)
+ return error("char" PD_FMT ": missing tagger name",
+ tagger_line - buffer);
+
+ /* timestamp, 1 or more digits followed by space */
+ tagger_line = rb + 2;
+ if (!(len = strspn(tagger_line, "0123456789")))
+ return error("char" PD_FMT ": missing tag timestamp",
+ tagger_line - buffer);
+ tagger_line += len;
+ if (*tagger_line != ' ')
+ return error("char" PD_FMT ": malformed tag timestamp",
+ tagger_line - buffer);
+ tagger_line++;
+
+ /* timezone, 5 digits [+-]hhmm, max. 1400 */
+ if (!((tagger_line[0] == '+' || tagger_line[0] == '-') &&
+ strspn(tagger_line+1, "0123456789") == 4 &&
+ tagger_line[5] == '\n' && atoi(tagger_line+1) <= 1400))
+ return error("char" PD_FMT ": malformed tag timezone",
+ tagger_line - buffer);
+ tagger_line += 6;
+
+ /* Verify the blank line separating the header from the body */
+ if (*tagger_line != '\n')
+ return error("char" PD_FMT ": trailing garbage in tag header",
+ tagger_line - buffer);
/* The actual stuff afterwards we don't care about.. */
return 0;
diff --git a/name-hash.c b/name-hash.c
new file mode 100644
index 000000000..0031d78e8
--- /dev/null
+++ b/name-hash.c
@@ -0,0 +1,119 @@
+/*
+ * name-hash.c
+ *
+ * Hashing names in the index state
+ *
+ * Copyright (C) 2008 Linus Torvalds
+ */
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
+#include "cache.h"
+
+/*
+ * This removes bit 5 if bit 6 is set.
+ *
+ * That will make US-ASCII characters hash to their upper-case
+ * equivalent. We could easily do this one whole word at a time,
+ * but that's for future worries.
+ */
+static inline unsigned char icase_hash(unsigned char c)
+{
+ return c & ~((c & 0x40) >> 1);
+}
+
+static unsigned int hash_name(const char *name, int namelen)
+{
+ unsigned int hash = 0x123;
+
+ do {
+ unsigned char c = *name++;
+ c = icase_hash(c);
+ hash = hash*101 + c;
+ } while (--namelen);
+ return hash;
+}
+
+static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
+{
+ void **pos;
+ unsigned int hash;
+
+ if (ce->ce_flags & CE_HASHED)
+ return;
+ ce->ce_flags |= CE_HASHED;
+ ce->next = NULL;
+ hash = hash_name(ce->name, ce_namelen(ce));
+ pos = insert_hash(hash, ce, &istate->name_hash);
+ if (pos) {
+ ce->next = *pos;
+ *pos = ce;
+ }
+}
+
+static void lazy_init_name_hash(struct index_state *istate)
+{
+ int nr;
+
+ if (istate->name_hash_initialized)
+ return;
+ for (nr = 0; nr < istate->cache_nr; nr++)
+ hash_index_entry(istate, istate->cache[nr]);
+ istate->name_hash_initialized = 1;
+}
+
+void add_name_hash(struct index_state *istate, struct cache_entry *ce)
+{
+ ce->ce_flags &= ~CE_UNHASHED;
+ if (istate->name_hash_initialized)
+ hash_index_entry(istate, ce);
+}
+
+static int slow_same_name(const char *name1, int len1, const char *name2, int len2)
+{
+ if (len1 != len2)
+ return 0;
+
+ while (len1) {
+ unsigned char c1 = *name1++;
+ unsigned char c2 = *name2++;
+ len1--;
+ if (c1 != c2) {
+ c1 = toupper(c1);
+ c2 = toupper(c2);
+ if (c1 != c2)
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static int same_name(const struct cache_entry *ce, const char *name, int namelen, int icase)
+{
+ int len = ce_namelen(ce);
+
+ /*
+ * Always do exact compare, even if we want a case-ignoring comparison;
+ * we do the quick exact one first, because it will be the common case.
+ */
+ if (len == namelen && !cache_name_compare(name, namelen, ce->name, len))
+ return 1;
+
+ return icase && slow_same_name(name, namelen, ce->name, len);
+}
+
+struct cache_entry *index_name_exists(struct index_state *istate, const char *name, int namelen, int icase)
+{
+ unsigned int hash = hash_name(name, namelen);
+ struct cache_entry *ce;
+
+ lazy_init_name_hash(istate);
+ ce = lookup_hash(hash, &istate->name_hash);
+
+ while (ce) {
+ if (!(ce->ce_flags & CE_UNHASHED)) {
+ if (same_name(ce, name, namelen, icase))
+ return ce;
+ }
+ ce = ce->next;
+ }
+ return NULL;
+}
diff --git a/object-refs.c b/object-refs.c
deleted file mode 100644
index 534567156..000000000
--- a/object-refs.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "cache.h"
-#include "object.h"
-#include "decorate.h"
-
-int track_object_refs = 0;
-
-static struct decoration ref_decorate;
-
-struct object_refs *lookup_object_refs(struct object *base)
-{
- return lookup_decoration(&ref_decorate, base);
-}
-
-static void add_object_refs(struct object *obj, struct object_refs *refs)
-{
- if (add_decoration(&ref_decorate, obj, refs))
- die("object %s tried to add refs twice!", sha1_to_hex(obj->sha1));
-}
-
-struct object_refs *alloc_object_refs(unsigned count)
-{
- struct object_refs *refs;
- size_t size = sizeof(*refs) + count*sizeof(struct object *);
-
- refs = xcalloc(1, size);
- refs->count = count;
- return refs;
-}
-
-static int compare_object_pointers(const void *a, const void *b)
-{
- const struct object * const *pa = a;
- const struct object * const *pb = b;
- if (*pa == *pb)
- return 0;
- else if (*pa < *pb)
- return -1;
- else
- return 1;
-}
-
-void set_object_refs(struct object *obj, struct object_refs *refs)
-{
- unsigned int i, j;
-
- /* Do not install empty list of references */
- if (refs->count < 1) {
- free(refs);
- return;
- }
-
- /* Sort the list and filter out duplicates */
- qsort(refs->ref, refs->count, sizeof(refs->ref[0]),
- compare_object_pointers);
- for (i = j = 1; i < refs->count; i++) {
- if (refs->ref[i] != refs->ref[i - 1])
- refs->ref[j++] = refs->ref[i];
- }
- if (j < refs->count) {
- /* Duplicates were found - reallocate list */
- size_t size = sizeof(*refs) + j*sizeof(struct object *);
- refs->count = j;
- refs = xrealloc(refs, size);
- }
-
- for (i = 0; i < refs->count; i++)
- refs->ref[i]->used = 1;
- add_object_refs(obj, refs);
-}
-
-void mark_reachable(struct object *obj, unsigned int mask)
-{
- const struct object_refs *refs;
-
- if (!track_object_refs)
- die("cannot do reachability with object refs turned off");
- /* If we've been here already, don't bother */
- if (obj->flags & mask)
- return;
- obj->flags |= mask;
- refs = lookup_object_refs(obj);
- if (refs) {
- unsigned i;
- for (i = 0; i < refs->count; i++)
- mark_reachable(refs->ref[i], mask);
- }
-}
diff --git a/object.c b/object.c
index 5a5ebe27b..50b652800 100644
--- a/object.c
+++ b/object.c
@@ -140,7 +140,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
if (type == OBJ_BLOB) {
struct blob *blob = lookup_blob(sha1);
if (blob) {
- parse_blob_buffer(blob, buffer, size);
+ if (parse_blob_buffer(blob, buffer, size))
+ return NULL;
obj = &blob->object;
}
} else if (type == OBJ_TREE) {
@@ -148,14 +149,16 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
if (tree) {
obj = &tree->object;
if (!tree->object.parsed) {
- parse_tree_buffer(tree, buffer, size);
+ if (parse_tree_buffer(tree, buffer, size))
+ return NULL;
eaten = 1;
}
}
} else if (type == OBJ_COMMIT) {
struct commit *commit = lookup_commit(sha1);
if (commit) {
- parse_commit_buffer(commit, buffer, size);
+ if (parse_commit_buffer(commit, buffer, size))
+ return NULL;
if (!commit->buffer) {
commit->buffer = buffer;
eaten = 1;
@@ -165,7 +168,8 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
} else if (type == OBJ_TAG) {
struct tag *tag = lookup_tag(sha1);
if (tag) {
- parse_tag_buffer(tag, buffer, size);
+ if (parse_tag_buffer(tag, buffer, size))
+ return NULL;
obj = &tag->object;
}
} else {
diff --git a/object.h b/object.h
index 397bbfa09..036bd66fe 100644
--- a/object.h
+++ b/object.h
@@ -35,14 +35,11 @@ struct object {
unsigned char sha1[20];
};
-extern int track_object_refs;
-
extern const char *typename(unsigned int type);
extern int type_from_string(const char *str);
extern unsigned int get_max_object_index(void);
extern struct object *get_indexed_object(unsigned int);
-extern struct object_refs *lookup_object_refs(struct object *);
/** Internal only **/
struct object *lookup_object(const unsigned char *sha1);
@@ -61,11 +58,6 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
/** Returns the object, with potentially excess memory allocated. **/
struct object *lookup_unknown_object(const unsigned char *sha1);
-struct object_refs *alloc_object_refs(unsigned count);
-void set_object_refs(struct object *obj, struct object_refs *refs);
-
-void mark_reachable(struct object *obj, unsigned int mask);
-
struct object_list *object_list_insert(struct object *item,
struct object_list **list_p);
diff --git a/pack-check.c b/pack-check.c
index d7dd62bb8..f596bf2db 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,10 +1,12 @@
#include "cache.h"
#include "pack.h"
+#include "pack-revindex.h"
struct idx_entry
{
- const unsigned char *sha1;
off_t offset;
+ const unsigned char *sha1;
+ unsigned int nr;
};
static int compare_entries(const void *e1, const void *e2)
@@ -18,16 +20,38 @@ static int compare_entries(const void *e1, const void *e2)
return 0;
}
+int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,
+ off_t offset, off_t len, unsigned int nr)
+{
+ const uint32_t *index_crc;
+ uint32_t data_crc = crc32(0, Z_NULL, 0);
+
+ do {
+ unsigned int avail;
+ void *data = use_pack(p, w_curs, offset, &avail);
+ if (avail > len)
+ avail = len;
+ data_crc = crc32(data_crc, data, avail);
+ offset += avail;
+ len -= avail;
+ } while (len);
+
+ index_crc = p->index_data;
+ index_crc += 2 + 256 + p->num_objects * (20/4) + nr;
+
+ return data_crc != ntohl(*index_crc);
+}
+
static int verify_packfile(struct packed_git *p,
struct pack_window **w_curs)
{
off_t index_size = p->index_size;
const unsigned char *index_base = p->index_data;
SHA_CTX ctx;
- unsigned char sha1[20];
- off_t offset = 0, pack_sig = p->pack_size - 20;
+ unsigned char sha1[20], *pack_sig;
+ off_t offset = 0, pack_sig_ofs = p->pack_size - 20;
uint32_t nr_objects, i;
- int err;
+ int err = 0;
struct idx_entry *entries;
/* Note that the pack header checks are actually performed by
@@ -37,21 +61,22 @@ static int verify_packfile(struct packed_git *p,
*/
SHA1_Init(&ctx);
- while (offset < pack_sig) {
+ while (offset < pack_sig_ofs) {
unsigned int remaining;
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
offset += remaining;
- if (offset > pack_sig)
- remaining -= (unsigned int)(offset - pack_sig);
+ if (offset > pack_sig_ofs)
+ remaining -= (unsigned int)(offset - pack_sig_ofs);
SHA1_Update(&ctx, in, remaining);
}
SHA1_Final(sha1, &ctx);
- if (hashcmp(sha1, use_pack(p, w_curs, pack_sig, NULL)))
- return error("Packfile %s SHA1 mismatch with itself",
- p->pack_name);
- if (hashcmp(sha1, index_base + index_size - 40))
- return error("Packfile %s SHA1 mismatch with idx",
- p->pack_name);
+ pack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);
+ if (hashcmp(sha1, pack_sig))
+ err = error("%s SHA1 checksum mismatch",
+ p->pack_name);
+ if (hashcmp(index_base + index_size - 40, pack_sig))
+ err = error("%s SHA1 does not match its inddex",
+ p->pack_name);
unuse_pack(w_curs);
/* Make sure everything reachable from idx is valid. Since we
@@ -59,34 +84,45 @@ static int verify_packfile(struct packed_git *p,
* we do not do scan-streaming check on the pack file.
*/
nr_objects = p->num_objects;
- entries = xmalloc(nr_objects * sizeof(*entries));
+ entries = xmalloc((nr_objects + 1) * sizeof(*entries));
+ entries[nr_objects].offset = pack_sig_ofs;
/* first sort entries by pack offset, since unpacking them is more efficient that way */
for (i = 0; i < nr_objects; i++) {
entries[i].sha1 = nth_packed_object_sha1(p, i);
if (!entries[i].sha1)
die("internal error pack-check nth-packed-object");
- entries[i].offset = find_pack_entry_one(entries[i].sha1, p);
- if (!entries[i].offset)
- die("internal error pack-check find-pack-entry-one");
+ entries[i].offset = nth_packed_object_offset(p, i);
+ entries[i].nr = i;
}
qsort(entries, nr_objects, sizeof(*entries), compare_entries);
- for (i = 0, err = 0; i < nr_objects; i++) {
+ for (i = 0; i < nr_objects; i++) {
void *data;
enum object_type type;
unsigned long size;
+ if (p->index_version > 1) {
+ off_t offset = entries[i].offset;
+ off_t len = entries[i+1].offset - offset;
+ unsigned int nr = entries[i].nr;
+ if (check_pack_crc(p, w_curs, offset, len, nr))
+ err = error("index CRC mismatch for object %s "
+ "from %s at offset %"PRIuMAX"",
+ sha1_to_hex(entries[i].sha1),
+ p->pack_name, (uintmax_t)offset);
+ }
data = unpack_entry(p, entries[i].offset, &type, &size);
if (!data) {
- err = error("cannot unpack %s from %s",
- sha1_to_hex(entries[i].sha1), p->pack_name);
- continue;
+ err = error("cannot unpack %s from %s at offset %"PRIuMAX"",
+ sha1_to_hex(entries[i].sha1), p->pack_name,
+ (uintmax_t)entries[i].offset);
+ break;
}
if (check_sha1_signature(entries[i].sha1, data, size, typename(type))) {
err = error("packed %s from %s is corrupt",
sha1_to_hex(entries[i].sha1), p->pack_name);
free(data);
- continue;
+ break;
}
free(data);
}
@@ -95,97 +131,31 @@ static int verify_packfile(struct packed_git *p,
return err;
}
-
-#define MAX_CHAIN 50
-
-static void show_pack_info(struct packed_git *p)
-{
- uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
- nr_objects = p->num_objects;
- memset(chain_histogram, 0, sizeof(chain_histogram));
-
- for (i = 0; i < nr_objects; i++) {
- const unsigned char *sha1;
- unsigned char base_sha1[20];
- const char *type;
- unsigned long size;
- unsigned long store_size;
- off_t offset;
- unsigned int delta_chain_length;
-
- sha1 = nth_packed_object_sha1(p, i);
- if (!sha1)
- die("internal error pack-check nth-packed-object");
- offset = find_pack_entry_one(sha1, p);
- if (!offset)
- die("internal error pack-check find-pack-entry-one");
-
- type = packed_object_info_detail(p, offset, &size, &store_size,
- &delta_chain_length,
- base_sha1);
- printf("%s ", sha1_to_hex(sha1));
- if (!delta_chain_length)
- printf("%-6s %lu %"PRIuMAX"\n",
- type, size, (uintmax_t)offset);
- else {
- printf("%-6s %lu %"PRIuMAX" %u %s\n",
- type, size, (uintmax_t)offset,
- delta_chain_length, sha1_to_hex(base_sha1));
- if (delta_chain_length <= MAX_CHAIN)
- chain_histogram[delta_chain_length]++;
- else
- chain_histogram[0]++;
- }
- }
-
- for (i = 0; i <= MAX_CHAIN; i++) {
- if (!chain_histogram[i])
- continue;
- printf("chain length = %d: %d object%s\n", i,
- chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
- }
- if (chain_histogram[0])
- printf("chain length > %d: %d object%s\n", MAX_CHAIN,
- chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
-}
-
-int verify_pack(struct packed_git *p, int verbose)
+int verify_pack(struct packed_git *p)
{
off_t index_size;
const unsigned char *index_base;
SHA_CTX ctx;
unsigned char sha1[20];
- int ret;
+ int err = 0;
+ struct pack_window *w_curs = NULL;
if (open_pack_index(p))
return error("packfile %s index not opened", p->pack_name);
index_size = p->index_size;
index_base = p->index_data;
- ret = 0;
/* Verify SHA1 sum of the index file */
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
SHA1_Final(sha1, &ctx);
if (hashcmp(sha1, index_base + index_size - 20))
- ret = error("Packfile index for %s SHA1 mismatch",
+ err = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
- if (!ret) {
- /* Verify pack file */
- struct pack_window *w_curs = NULL;
- ret = verify_packfile(p, &w_curs);
- unuse_pack(&w_curs);
- }
+ /* Verify pack file */
+ err |= verify_packfile(p, &w_curs);
+ unuse_pack(&w_curs);
- if (verbose) {
- if (ret)
- printf("%s: bad\n", p->pack_name);
- else {
- show_pack_info(p);
- printf("%s: ok\n", p->pack_name);
- }
- }
-
- return ret;
+ return err;
}
diff --git a/pack-redundant.c b/pack-redundant.c
index f5cd0ac59..25b81a445 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -11,7 +11,7 @@
#define BLKSIZE 512
static const char pack_redundant_usage[] =
-"git-pack-redundant [ --verbose ] [ --alt-odb ] < --all | <.pack filename> ...>";
+"git pack-redundant [ --verbose ] [ --alt-odb ] < --all | <.pack filename> ...>";
static int load_all_packs, verbose, alt_odb;
diff --git a/pack-refs.c b/pack-refs.c
new file mode 100644
index 000000000..848d311c2
--- /dev/null
+++ b/pack-refs.c
@@ -0,0 +1,117 @@
+#include "cache.h"
+#include "refs.h"
+#include "tag.h"
+#include "pack-refs.h"
+
+struct ref_to_prune {
+ struct ref_to_prune *next;
+ unsigned char sha1[20];
+ char name[FLEX_ARRAY];
+};
+
+struct pack_refs_cb_data {
+ unsigned int flags;
+ struct ref_to_prune *ref_to_prune;
+ FILE *refs_file;
+};
+
+static int do_not_prune(int flags)
+{
+ /* If it is already packed or if it is a symref,
+ * do not prune it.
+ */
+ return (flags & (REF_ISSYMREF|REF_ISPACKED));
+}
+
+static int handle_one_ref(const char *path, const unsigned char *sha1,
+ int flags, void *cb_data)
+{
+ struct pack_refs_cb_data *cb = cb_data;
+ int is_tag_ref;
+
+ /* Do not pack the symbolic refs */
+ if ((flags & REF_ISSYMREF))
+ return 0;
+ is_tag_ref = !prefixcmp(path, "refs/tags/");
+
+ /* ALWAYS pack refs that were already packed or are tags */
+ if (!(cb->flags & PACK_REFS_ALL) && !is_tag_ref && !(flags & REF_ISPACKED))
+ return 0;
+
+ fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
+ if (is_tag_ref) {
+ struct object *o = parse_object(sha1);
+ if (o->type == OBJ_TAG) {
+ o = deref_tag(o, path, 0);
+ if (o)
+ fprintf(cb->refs_file, "^%s\n",
+ sha1_to_hex(o->sha1));
+ }
+ }
+
+ if ((cb->flags & PACK_REFS_PRUNE) && !do_not_prune(flags)) {
+ int namelen = strlen(path) + 1;
+ struct ref_to_prune *n = xcalloc(1, sizeof(*n) + namelen);
+ hashcpy(n->sha1, sha1);
+ strcpy(n->name, path);
+ n->next = cb->ref_to_prune;
+ cb->ref_to_prune = n;
+ }
+ return 0;
+}
+
+/* make sure nobody touched the ref, and unlink */
+static void prune_ref(struct ref_to_prune *r)
+{
+ struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
+
+ if (lock) {
+ unlink(git_path("%s", r->name));
+ unlock_ref(lock);
+ }
+}
+
+static void prune_refs(struct ref_to_prune *r)
+{
+ while (r) {
+ prune_ref(r);
+ r = r->next;
+ }
+}
+
+static struct lock_file packed;
+
+int pack_refs(unsigned int flags)
+{
+ int fd;
+ struct pack_refs_cb_data cbdata;
+
+ memset(&cbdata, 0, sizeof(cbdata));
+ cbdata.flags = flags;
+
+ fd = hold_lock_file_for_update(&packed, git_path("packed-refs"), 1);
+ cbdata.refs_file = fdopen(fd, "w");
+ if (!cbdata.refs_file)
+ die("unable to create ref-pack file structure (%s)",
+ strerror(errno));
+
+ /* perhaps other traits later as well */
+ fprintf(cbdata.refs_file, "# pack-refs with: peeled \n");
+
+ for_each_ref(handle_one_ref, &cbdata);
+ if (ferror(cbdata.refs_file))
+ die("failed to write ref-pack file");
+ if (fflush(cbdata.refs_file) || fsync(fd) || fclose(cbdata.refs_file))
+ die("failed to write ref-pack file (%s)", strerror(errno));
+ /*
+ * Since the lock file was fdopen()'ed and then fclose()'ed above,
+ * assign -1 to the lock file descriptor so that commit_lock_file()
+ * won't try to close() it.
+ */
+ packed.fd = -1;
+ if (commit_lock_file(&packed) < 0)
+ die("unable to overwrite old ref-pack file (%s)", strerror(errno));
+ if (cbdata.flags & PACK_REFS_PRUNE)
+ prune_refs(cbdata.ref_to_prune);
+ return 0;
+}
diff --git a/pack-refs.h b/pack-refs.h
new file mode 100644
index 000000000..518acfb37
--- /dev/null
+++ b/pack-refs.h
@@ -0,0 +1,18 @@
+#ifndef PACK_REFS_H
+#define PACK_REFS_H
+
+/*
+ * Flags for controlling behaviour of pack_refs()
+ * PACK_REFS_PRUNE: Prune loose refs after packing
+ * PACK_REFS_ALL: Pack _all_ refs, not just tags and already packed refs
+ */
+#define PACK_REFS_PRUNE 0x0001
+#define PACK_REFS_ALL 0x0002
+
+/*
+ * Write a packed-refs file for the current repository.
+ * flags: Combination of the above PACK_REFS_* flags.
+ */
+int pack_refs(unsigned int flags);
+
+#endif /* PACK_REFS_H */
diff --git a/pack-revindex.c b/pack-revindex.c
new file mode 100644
index 000000000..cd300bdff
--- /dev/null
+++ b/pack-revindex.c
@@ -0,0 +1,144 @@
+#include "cache.h"
+#include "pack-revindex.h"
+
+/*
+ * Pack index for existing packs give us easy access to the offsets into
+ * corresponding pack file where each object's data starts, but the entries
+ * do not store the size of the compressed representation (uncompressed
+ * size is easily available by examining the pack entry header). It is
+ * also rather expensive to find the sha1 for an object given its offset.
+ *
+ * We build a hashtable of existing packs (pack_revindex), and keep reverse
+ * index here -- pack index file is sorted by object name mapping to offset;
+ * this pack_revindex[].revindex array is a list of offset/index_nr pairs
+ * ordered by offset, so if you know the offset of an object, next offset
+ * is where its packed representation ends and the index_nr can be used to
+ * get the object sha1 from the main index.
+ */
+
+struct pack_revindex {
+ struct packed_git *p;
+ struct revindex_entry *revindex;
+};
+
+static struct pack_revindex *pack_revindex;
+static int pack_revindex_hashsz;
+
+static int pack_revindex_ix(struct packed_git *p)
+{
+ unsigned long ui = (unsigned long)p;
+ int i;
+
+ ui = ui ^ (ui >> 16); /* defeat structure alignment */
+ i = (int)(ui % pack_revindex_hashsz);
+ while (pack_revindex[i].p) {
+ if (pack_revindex[i].p == p)
+ return i;
+ if (++i == pack_revindex_hashsz)
+ i = 0;
+ }
+ return -1 - i;
+}
+
+static void init_pack_revindex(void)
+{
+ int num;
+ struct packed_git *p;
+
+ for (num = 0, p = packed_git; p; p = p->next)
+ num++;
+ if (!num)
+ return;
+ pack_revindex_hashsz = num * 11;
+ pack_revindex = xcalloc(sizeof(*pack_revindex), pack_revindex_hashsz);
+ for (p = packed_git; p; p = p->next) {
+ num = pack_revindex_ix(p);
+ num = - 1 - num;
+ pack_revindex[num].p = p;
+ }
+ /* revindex elements are lazily initialized */
+}
+
+static int cmp_offset(const void *a_, const void *b_)
+{
+ const struct revindex_entry *a = a_;
+ const struct revindex_entry *b = b_;
+ return (a->offset < b->offset) ? -1 : (a->offset > b->offset) ? 1 : 0;
+}
+
+/*
+ * Ordered list of offsets of objects in the pack.
+ */
+static void create_pack_revindex(struct pack_revindex *rix)
+{
+ struct packed_git *p = rix->p;
+ int num_ent = p->num_objects;
+ int i;
+ const char *index = p->index_data;
+
+ rix->revindex = xmalloc(sizeof(*rix->revindex) * (num_ent + 1));
+ index += 4 * 256;
+
+ if (p->index_version > 1) {
+ const uint32_t *off_32 =
+ (uint32_t *)(index + 8 + p->num_objects * (20 + 4));
+ const uint32_t *off_64 = off_32 + p->num_objects;
+ for (i = 0; i < num_ent; i++) {
+ uint32_t off = ntohl(*off_32++);
+ if (!(off & 0x80000000)) {
+ rix->revindex[i].offset = off;
+ } else {
+ rix->revindex[i].offset =
+ ((uint64_t)ntohl(*off_64++)) << 32;
+ rix->revindex[i].offset |=
+ ntohl(*off_64++);
+ }
+ rix->revindex[i].nr = i;
+ }
+ } else {
+ for (i = 0; i < num_ent; i++) {
+ uint32_t hl = *((uint32_t *)(index + 24 * i));
+ rix->revindex[i].offset = ntohl(hl);
+ rix->revindex[i].nr = i;
+ }
+ }
+
+ /* This knows the pack format -- the 20-byte trailer
+ * follows immediately after the last object data.
+ */
+ rix->revindex[num_ent].offset = p->pack_size - 20;
+ rix->revindex[num_ent].nr = -1;
+ qsort(rix->revindex, num_ent, sizeof(*rix->revindex), cmp_offset);
+}
+
+struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)
+{
+ int num;
+ int lo, hi;
+ struct pack_revindex *rix;
+ struct revindex_entry *revindex;
+
+ if (!pack_revindex_hashsz)
+ init_pack_revindex();
+ num = pack_revindex_ix(p);
+ if (num < 0)
+ die("internal error: pack revindex fubar");
+
+ rix = &pack_revindex[num];
+ if (!rix->revindex)
+ create_pack_revindex(rix);
+ revindex = rix->revindex;
+
+ lo = 0;
+ hi = p->num_objects + 1;
+ do {
+ int mi = (lo + hi) / 2;
+ if (revindex[mi].offset == ofs) {
+ return revindex + mi;
+ } else if (ofs < revindex[mi].offset)
+ hi = mi;
+ else
+ lo = mi + 1;
+ } while (lo < hi);
+ die("internal error: pack revindex corrupt");
+}
diff --git a/pack-revindex.h b/pack-revindex.h
new file mode 100644
index 000000000..36a514a6c
--- /dev/null
+++ b/pack-revindex.h
@@ -0,0 +1,11 @@
+#ifndef PACK_REVINDEX_H
+#define PACK_REVINDEX_H
+
+struct revindex_entry {
+ off_t offset;
+ unsigned int nr;
+};
+
+struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs);
+
+#endif
diff --git a/pack-write.c b/pack-write.c
index 665e2b29b..a8f026993 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -2,7 +2,7 @@
#include "pack.h"
#include "csum-file.h"
-uint32_t pack_idx_default_version = 1;
+uint32_t pack_idx_default_version = 2;
uint32_t pack_idx_off32_limit = 0x7fffffff;
static int sha1_compare(const void *_a, const void *_b)
@@ -139,7 +139,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
}
sha1write(f, sha1, 20);
- sha1close(f, NULL, 1);
+ sha1close(f, NULL, CSUM_FSYNC);
SHA1_Final(sha1, &ctx);
return index_name;
}
@@ -183,7 +183,6 @@ void fixup_pack_header_footer(int pack_fd,
char *index_pack_lockfile(int ip_out)
{
- int len, s;
char packname[46];
/*
@@ -193,11 +192,8 @@ char *index_pack_lockfile(int ip_out)
* case, we need it to remove the corresponding .keep file
* later on. If we don't get that then tough luck with it.
*/
- for (len = 0;
- len < 46 && (s = xread(ip_out, packname+len, 46-len)) > 0;
- len += s);
- if (len == 46 && packname[45] == '\n' &&
- memcmp(packname, "keep\t", 5) == 0) {
+ if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
+ memcmp(packname, "keep\t", 5) == 0) {
char path[PATH_MAX];
packname[45] = 0;
snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",
diff --git a/pack.h b/pack.h
index b31b37608..76e6aa2aa 100644
--- a/pack.h
+++ b/pack.h
@@ -56,8 +56,8 @@ struct pack_idx_entry {
};
extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
-
-extern int verify_pack(struct packed_git *, int);
+extern int check_pack_crc(struct packed_git *p, struct pack_window **w_curs, off_t offset, off_t len, unsigned int nr);
+extern int verify_pack(struct packed_git *);
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t);
extern char *index_pack_lockfile(int fd);
diff --git a/pager.c b/pager.c
index 0376953cb..6b5c9e44b 100644
--- a/pager.c
+++ b/pager.c
@@ -1,12 +1,13 @@
#include "cache.h"
/*
- * This is split up from the rest of git so that we might do
- * something different on Windows, for example.
+ * This is split up from the rest of git so that we can do
+ * something different on Windows.
*/
static int spawned_pager;
+#ifndef __MINGW32__
static void run_pager(const char *pager)
{
/*
@@ -22,18 +23,38 @@ static void run_pager(const char *pager)
execlp(pager, pager, NULL);
execl("/bin/sh", "sh", "-c", pager, NULL);
}
+#else
+#include "run-command.h"
+
+static const char *pager_argv[] = { "sh", "-c", NULL, NULL };
+static struct child_process pager_process = {
+ .argv = pager_argv,
+ .in = -1
+};
+static void wait_for_pager(void)
+{
+ fflush(stdout);
+ fflush(stderr);
+ /* signal EOF to pager */
+ close(1);
+ close(2);
+ finish_command(&pager_process);
+}
+#endif
void setup_pager(void)
{
+#ifndef __MINGW32__
pid_t pid;
int fd[2];
+#endif
const char *pager = getenv("GIT_PAGER");
if (!isatty(1))
return;
if (!pager) {
if (!pager_program)
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
pager = pager_program;
}
if (!pager)
@@ -45,6 +66,7 @@ void setup_pager(void)
spawned_pager = 1; /* means we are emitting to terminal */
+#ifndef __MINGW32__
if (pipe(fd) < 0)
return;
pid = fork();
@@ -57,6 +79,7 @@ void setup_pager(void)
/* return in the child */
if (!pid) {
dup2(fd[1], 1);
+ dup2(fd[1], 2);
close(fd[0]);
close(fd[1]);
return;
@@ -71,6 +94,20 @@ void setup_pager(void)
run_pager(pager);
die("unable to execute pager '%s'", pager);
exit(255);
+#else
+ /* spawn the pager */
+ pager_argv[2] = pager;
+ if (start_command(&pager_process))
+ return;
+
+ /* original process continues, but writes to the pipe */
+ dup2(pager_process.in, 1);
+ dup2(pager_process.in, 2);
+ close(pager_process.in);
+
+ /* this makes sure that the parent terminates after the pager */
+ atexit(wait_for_pager);
+#endif
}
int pager_in_use(void)
diff --git a/parse-options.c b/parse-options.c
index 7a08a0c64..fd08bb425 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -1,32 +1,10 @@
#include "git-compat-util.h"
#include "parse-options.h"
+#include "cache.h"
#define OPT_SHORT 1
#define OPT_UNSET 2
-struct optparse_t {
- const char **argv;
- int argc;
- const char *opt;
-};
-
-static inline const char *get_arg(struct optparse_t *p)
-{
- if (p->opt) {
- const char *res = p->opt;
- p->opt = NULL;
- return res;
- }
- p->argc--;
- return *++p->argv;
-}
-
-static inline const char *skip_prefix(const char *str, const char *prefix)
-{
- size_t len = strlen(prefix);
- return strncmp(str, prefix, len) ? NULL : str + len;
-}
-
static int opterror(const struct option *opt, const char *reason, int flags)
{
if (flags & OPT_SHORT)
@@ -36,8 +14,24 @@ static int opterror(const struct option *opt, const char *reason, int flags)
return error("option `%s' %s", opt->long_name, reason);
}
-static int get_value(struct optparse_t *p,
- const struct option *opt, int flags)
+static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
+ int flags, const char **arg)
+{
+ if (p->opt) {
+ *arg = p->opt;
+ p->opt = NULL;
+ } else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) {
+ *arg = (const char *)opt->defval;
+ } else if (p->argc > 1) {
+ p->argc--;
+ *arg = *++p->argv;
+ } else
+ return opterror(opt, "requires a value", flags);
+ return 0;
+}
+
+static int get_value(struct parse_opt_ctx_t *p,
+ const struct option *opt, int flags)
{
const char *s, *arg;
const int unset = flags & OPT_UNSET;
@@ -63,7 +57,6 @@ static int get_value(struct optparse_t *p,
}
}
- arg = p->opt ? p->opt : (p->argc > 1 ? p->argv[1] : NULL);
switch (opt->type) {
case OPTION_BIT:
if (unset)
@@ -85,29 +78,24 @@ static int get_value(struct optparse_t *p,
return 0;
case OPTION_STRING:
- if (unset) {
+ if (unset)
*(const char **)opt->value = NULL;
- return 0;
- }
- if (opt->flags & PARSE_OPT_OPTARG && !p->opt) {
+ else if (opt->flags & PARSE_OPT_OPTARG && !p->opt)
*(const char **)opt->value = (const char *)opt->defval;
- return 0;
- }
- if (!arg)
- return opterror(opt, "requires a value", flags);
- *(const char **)opt->value = get_arg(p);
+ else
+ return get_arg(p, opt, flags, (const char **)opt->value);
return 0;
case OPTION_CALLBACK:
if (unset)
- return (*opt->callback)(opt, NULL, 1);
+ return (*opt->callback)(opt, NULL, 1) ? (-1) : 0;
if (opt->flags & PARSE_OPT_NOARG)
- return (*opt->callback)(opt, NULL, 0);
+ return (*opt->callback)(opt, NULL, 0) ? (-1) : 0;
if (opt->flags & PARSE_OPT_OPTARG && !p->opt)
- return (*opt->callback)(opt, NULL, 0);
- if (!arg)
- return opterror(opt, "requires a value", flags);
- return (*opt->callback)(opt, get_arg(p), 0);
+ return (*opt->callback)(opt, NULL, 0) ? (-1) : 0;
+ if (get_arg(p, opt, flags, &arg))
+ return -1;
+ return (*opt->callback)(opt, arg, 0) ? (-1) : 0;
case OPTION_INTEGER:
if (unset) {
@@ -118,9 +106,9 @@ static int get_value(struct optparse_t *p,
*(int *)opt->value = opt->defval;
return 0;
}
- if (!arg)
- return opterror(opt, "requires a value", flags);
- *(int *)opt->value = strtol(get_arg(p), (char **)&s, 10);
+ if (get_arg(p, opt, flags, &arg))
+ return -1;
+ *(int *)opt->value = strtol(arg, (char **)&s, 10);
if (*s)
return opterror(opt, "expects a numerical value", flags);
return 0;
@@ -130,7 +118,7 @@ static int get_value(struct optparse_t *p,
}
}
-static int parse_short_opt(struct optparse_t *p, const struct option *options)
+static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options)
{
for (; options->type != OPTION_END; options++) {
if (options->short_name == *p->opt) {
@@ -138,10 +126,10 @@ static int parse_short_opt(struct optparse_t *p, const struct option *options)
return get_value(p, options, OPT_SHORT);
}
}
- return error("unknown switch `%c'", *p->opt);
+ return -2;
}
-static int parse_long_opt(struct optparse_t *p, const char *arg,
+static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg,
const struct option *options)
{
const char *arg_end = strchr(arg, '=');
@@ -159,6 +147,16 @@ static int parse_long_opt(struct optparse_t *p, const char *arg,
continue;
rest = skip_prefix(arg, options->long_name);
+ if (options->type == OPTION_ARGUMENT) {
+ if (!rest)
+ continue;
+ if (*rest == '=')
+ return opterror(options, "takes no value", flags);
+ if (*rest)
+ continue;
+ p->out[p->cpidx++] = arg - 2;
+ return 0;
+ }
if (!rest) {
/* abbreviated? */
if (!strncmp(options->long_name, arg, arg_end - arg)) {
@@ -213,69 +211,159 @@ is_abbreviated:
abbrev_option->long_name);
if (abbrev_option)
return get_value(p, abbrev_option, abbrev_flags);
- return error("unknown option `%s'", arg);
+ return -2;
}
-static NORETURN void usage_with_options_internal(const char * const *,
- const struct option *, int);
+static void check_typos(const char *arg, const struct option *options)
+{
+ if (strlen(arg) < 3)
+ return;
-int parse_options(int argc, const char **argv, const struct option *options,
- const char * const usagestr[], int flags)
+ if (!prefixcmp(arg, "no-")) {
+ error ("did you mean `--%s` (with two dashes ?)", arg);
+ exit(129);
+ }
+
+ for (; options->type != OPTION_END; options++) {
+ if (!options->long_name)
+ continue;
+ if (!prefixcmp(options->long_name, arg)) {
+ error ("did you mean `--%s` (with two dashes ?)", arg);
+ exit(129);
+ }
+ }
+}
+
+void parse_options_start(struct parse_opt_ctx_t *ctx,
+ int argc, const char **argv, int flags)
+{
+ memset(ctx, 0, sizeof(*ctx));
+ ctx->argc = argc - 1;
+ ctx->argv = argv + 1;
+ ctx->out = argv;
+ ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0);
+ ctx->flags = flags;
+}
+
+static int usage_with_options_internal(const char * const *,
+ const struct option *, int);
+
+int parse_options_step(struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[])
{
- struct optparse_t args = { argv + 1, argc - 1, NULL };
- int j = 0;
+ /* we must reset ->opt, unknown short option leave it dangling */
+ ctx->opt = NULL;
- for (; args.argc; args.argc--, args.argv++) {
- const char *arg = args.argv[0];
+ for (; ctx->argc; ctx->argc--, ctx->argv++) {
+ const char *arg = ctx->argv[0];
if (*arg != '-' || !arg[1]) {
- argv[j++] = args.argv[0];
+ if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION)
+ break;
+ ctx->out[ctx->cpidx++] = ctx->argv[0];
continue;
}
if (arg[1] != '-') {
- args.opt = arg + 1;
- do {
- if (*args.opt == 'h')
- usage_with_options(usagestr, options);
- if (parse_short_opt(&args, options) < 0)
- usage_with_options(usagestr, options);
- } while (args.opt);
+ ctx->opt = arg + 1;
+ if (*ctx->opt == 'h')
+ return parse_options_usage(usagestr, options);
+ switch (parse_short_opt(ctx, options)) {
+ case -1:
+ return parse_options_usage(usagestr, options);
+ case -2:
+ return PARSE_OPT_UNKNOWN;
+ }
+ if (ctx->opt)
+ check_typos(arg + 1, options);
+ while (ctx->opt) {
+ if (*ctx->opt == 'h')
+ return parse_options_usage(usagestr, options);
+ switch (parse_short_opt(ctx, options)) {
+ case -1:
+ return parse_options_usage(usagestr, options);
+ case -2:
+ /* fake a short option thing to hide the fact that we may have
+ * started to parse aggregated stuff
+ *
+ * This is leaky, too bad.
+ */
+ ctx->argv[0] = xstrdup(ctx->opt - 1);
+ *(char *)ctx->argv[0] = '-';
+ return PARSE_OPT_UNKNOWN;
+ }
+ }
continue;
}
if (!arg[2]) { /* "--" */
- if (!(flags & PARSE_OPT_KEEP_DASHDASH)) {
- args.argc--;
- args.argv++;
+ if (!(ctx->flags & PARSE_OPT_KEEP_DASHDASH)) {
+ ctx->argc--;
+ ctx->argv++;
}
break;
}
if (!strcmp(arg + 2, "help-all"))
- usage_with_options_internal(usagestr, options, 1);
+ return usage_with_options_internal(usagestr, options, 1);
if (!strcmp(arg + 2, "help"))
- usage_with_options(usagestr, options);
- if (parse_long_opt(&args, arg + 2, options))
- usage_with_options(usagestr, options);
+ return parse_options_usage(usagestr, options);
+ switch (parse_long_opt(ctx, arg + 2, options)) {
+ case -1:
+ return parse_options_usage(usagestr, options);
+ case -2:
+ return PARSE_OPT_UNKNOWN;
+ }
+ }
+ return PARSE_OPT_DONE;
+}
+
+int parse_options_end(struct parse_opt_ctx_t *ctx)
+{
+ memmove(ctx->out + ctx->cpidx, ctx->argv, ctx->argc * sizeof(*ctx->out));
+ ctx->out[ctx->cpidx + ctx->argc] = NULL;
+ return ctx->cpidx + ctx->argc;
+}
+
+int parse_options(int argc, const char **argv, const struct option *options,
+ const char * const usagestr[], int flags)
+{
+ struct parse_opt_ctx_t ctx;
+
+ parse_options_start(&ctx, argc, argv, flags);
+ switch (parse_options_step(&ctx, options, usagestr)) {
+ case PARSE_OPT_HELP:
+ exit(129);
+ case PARSE_OPT_DONE:
+ break;
+ default: /* PARSE_OPT_UNKNOWN */
+ if (ctx.argv[0][1] == '-') {
+ error("unknown option `%s'", ctx.argv[0] + 2);
+ } else {
+ error("unknown switch `%c'", *ctx.opt);
+ }
+ usage_with_options(usagestr, options);
}
- memmove(argv + j, args.argv, args.argc * sizeof(*argv));
- argv[j + args.argc] = NULL;
- return j + args.argc;
+ return parse_options_end(&ctx);
}
#define USAGE_OPTS_WIDTH 24
#define USAGE_GAP 2
-void usage_with_options_internal(const char * const *usagestr,
- const struct option *opts, int full)
+int usage_with_options_internal(const char * const *usagestr,
+ const struct option *opts, int full)
{
fprintf(stderr, "usage: %s\n", *usagestr++);
while (*usagestr && **usagestr)
fprintf(stderr, " or: %s\n", *usagestr++);
- while (*usagestr)
- fprintf(stderr, " %s\n", *usagestr++);
+ while (*usagestr) {
+ fprintf(stderr, "%s%s\n",
+ **usagestr ? " " : "",
+ *usagestr);
+ usagestr++;
+ }
if (opts->type != OPTION_GROUP)
fputc('\n', stderr);
@@ -302,9 +390,14 @@ void usage_with_options_internal(const char * const *usagestr,
pos += fprintf(stderr, "--%s", opts->long_name);
switch (opts->type) {
+ case OPTION_ARGUMENT:
+ break;
case OPTION_INTEGER:
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, " [<n>]");
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<n>]");
+ else
+ pos += fprintf(stderr, "[<n>]");
else
pos += fprintf(stderr, " <n>");
break;
@@ -315,12 +408,18 @@ void usage_with_options_internal(const char * const *usagestr,
case OPTION_STRING:
if (opts->argh) {
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, " [<%s>]", opts->argh);
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=<%s>]", opts->argh);
+ else
+ pos += fprintf(stderr, "[<%s>]", opts->argh);
else
pos += fprintf(stderr, " <%s>", opts->argh);
} else {
if (opts->flags & PARSE_OPT_OPTARG)
- pos += fprintf(stderr, " [...]");
+ if (opts->long_name)
+ pos += fprintf(stderr, "[=...]");
+ else
+ pos += fprintf(stderr, "[...]");
else
pos += fprintf(stderr, " ...");
}
@@ -339,15 +438,23 @@ void usage_with_options_internal(const char * const *usagestr,
}
fputc('\n', stderr);
- exit(129);
+ return PARSE_OPT_HELP;
}
void usage_with_options(const char * const *usagestr,
- const struct option *opts)
+ const struct option *opts)
{
usage_with_options_internal(usagestr, opts, 0);
+ exit(129);
+}
+
+int parse_options_usage(const char * const *usagestr,
+ const struct option *opts)
+{
+ return usage_with_options_internal(usagestr, opts, 0);
}
+
/*----- some often used options -----*/
#include "cache.h"
@@ -369,3 +476,22 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
*(int *)(opt->value) = v;
return 0;
}
+
+int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
+ int unset)
+{
+ *(unsigned long *)(opt->value) = approxidate(arg);
+ return 0;
+}
+
+/*
+ * This should really be OPTION_FILENAME type as a part of
+ * parse_options that take prefix to do this while parsing.
+ */
+extern const char *parse_options_fix_filename(const char *prefix, const char *file)
+{
+ if (!file || !prefix || is_absolute_path(file) || !strcmp("-", file))
+ return file;
+ return prefix_filename(prefix, strlen(prefix), file);
+}
+
diff --git a/parse-options.h b/parse-options.h
index 102ac31fb..5199950c0 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -4,6 +4,7 @@
enum parse_opt_type {
/* special types */
OPTION_END,
+ OPTION_ARGUMENT,
OPTION_GROUP,
/* options with no arguments */
OPTION_BIT,
@@ -18,6 +19,8 @@ enum parse_opt_type {
enum parse_opt_flags {
PARSE_OPT_KEEP_DASHDASH = 1,
+ PARSE_OPT_STOP_AT_NON_OPTION = 2,
+ PARSE_OPT_KEEP_ARGV0 = 4,
};
enum parse_opt_option_flags {
@@ -25,6 +28,7 @@ enum parse_opt_option_flags {
PARSE_OPT_NOARG = 2,
PARSE_OPT_NONEG = 4,
PARSE_OPT_HIDDEN = 8,
+ PARSE_OPT_LASTARG_DEFAULT = 16,
};
struct option;
@@ -84,6 +88,7 @@ struct option {
};
#define OPT_END() { OPTION_END }
+#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, (h) }
#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
#define OPT_BIT(s, l, v, h, b) { OPTION_BIT, (s), (l), (v), NULL, (h), 0, NULL, (b) }
#define OPT_BOOLEAN(s, l, v, h) { OPTION_BOOLEAN, (s), (l), (v), NULL, (h) }
@@ -91,6 +96,9 @@ struct option {
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) }
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
+#define OPT_DATE(s, l, v, h) \
+ { OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \
+ parse_opt_approxidate_cb }
#define OPT_CALLBACK(s, l, v, a, h, f) \
{ OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) }
@@ -105,8 +113,43 @@ extern int parse_options(int argc, const char **argv,
extern NORETURN void usage_with_options(const char * const *usagestr,
const struct option *options);
+/*----- incremantal advanced APIs -----*/
+
+enum {
+ PARSE_OPT_HELP = -1,
+ PARSE_OPT_DONE,
+ PARSE_OPT_UNKNOWN,
+};
+
+/*
+ * It's okay for the caller to consume argv/argc in the usual way.
+ * Other fields of that structure are private to parse-options and should not
+ * be modified in any way.
+ */
+struct parse_opt_ctx_t {
+ const char **argv;
+ const char **out;
+ int argc, cpidx;
+ const char *opt;
+ int flags;
+};
+
+extern int parse_options_usage(const char * const *usagestr,
+ const struct option *opts);
+
+extern void parse_options_start(struct parse_opt_ctx_t *ctx,
+ int argc, const char **argv, int flags);
+
+extern int parse_options_step(struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[]);
+
+extern int parse_options_end(struct parse_opt_ctx_t *ctx);
+
+
/*----- some often used options -----*/
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
+extern int parse_opt_approxidate_cb(const struct option *, const char *, int);
#define OPT__VERBOSE(var) OPT_BOOLEAN('v', "verbose", (var), "be verbose")
#define OPT__QUIET(var) OPT_BOOLEAN('q', "quiet", (var), "be quiet")
@@ -116,4 +159,6 @@ extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
"use <n> digits to display SHA-1s", \
PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 }
+extern const char *parse_options_fix_filename(const char *prefix, const char *file);
+
#endif
diff --git a/path-list.c b/path-list.c
deleted file mode 100644
index 3d83b7ba9..000000000
--- a/path-list.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "cache.h"
-#include "path-list.h"
-
-/* if there is no exact match, point to the index where the entry could be
- * inserted */
-static int get_entry_index(const struct path_list *list, const char *path,
- int *exact_match)
-{
- int left = -1, right = list->nr;
-
- while (left + 1 < right) {
- int middle = (left + right) / 2;
- int compare = strcmp(path, list->items[middle].path);
- if (compare < 0)
- right = middle;
- else if (compare > 0)
- left = middle;
- else {
- *exact_match = 1;
- return middle;
- }
- }
-
- *exact_match = 0;
- return right;
-}
-
-/* returns -1-index if already exists */
-static int add_entry(struct path_list *list, const char *path)
-{
- int exact_match;
- int index = get_entry_index(list, path, &exact_match);
-
- if (exact_match)
- return -1 - index;
-
- if (list->nr + 1 >= list->alloc) {
- list->alloc += 32;
- list->items = xrealloc(list->items, list->alloc
- * sizeof(struct path_list_item));
- }
- if (index < list->nr)
- memmove(list->items + index + 1, list->items + index,
- (list->nr - index)
- * sizeof(struct path_list_item));
- list->items[index].path = list->strdup_paths ?
- xstrdup(path) : (char *)path;
- list->items[index].util = NULL;
- list->nr++;
-
- return index;
-}
-
-struct path_list_item *path_list_insert(const char *path, struct path_list *list)
-{
- int index = add_entry(list, path);
-
- if (index < 0)
- index = -1 - index;
-
- return list->items + index;
-}
-
-int path_list_has_path(const struct path_list *list, const char *path)
-{
- int exact_match;
- get_entry_index(list, path, &exact_match);
- return exact_match;
-}
-
-struct path_list_item *path_list_lookup(const char *path, struct path_list *list)
-{
- int exact_match, i = get_entry_index(list, path, &exact_match);
- if (!exact_match)
- return NULL;
- return list->items + i;
-}
-
-void path_list_clear(struct path_list *list, int free_util)
-{
- if (list->items) {
- int i;
- if (list->strdup_paths) {
- for (i = 0; i < list->nr; i++)
- free(list->items[i].path);
- }
- if (free_util) {
- for (i = 0; i < list->nr; i++)
- free(list->items[i].util);
- }
- free(list->items);
- }
- list->items = NULL;
- list->nr = list->alloc = 0;
-}
-
-void print_path_list(const char *text, const struct path_list *p)
-{
- int i;
- if ( text )
- printf("%s\n", text);
- for (i = 0; i < p->nr; i++)
- printf("%s:%p\n", p->items[i].path, p->items[i].util);
-}
diff --git a/path-list.h b/path-list.h
deleted file mode 100644
index 5931e2cc0..000000000
--- a/path-list.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef PATH_LIST_H
-#define PATH_LIST_H
-
-struct path_list_item {
- char *path;
- void *util;
-};
-struct path_list
-{
- struct path_list_item *items;
- unsigned int nr, alloc;
- unsigned int strdup_paths:1;
-};
-
-void print_path_list(const char *text, const struct path_list *p);
-
-int path_list_has_path(const struct path_list *list, const char *path);
-void path_list_clear(struct path_list *list, int free_util);
-struct path_list_item *path_list_insert(const char *path, struct path_list *list);
-struct path_list_item *path_list_lookup(const char *path, struct path_list *list);
-
-#endif /* PATH_LIST_H */
diff --git a/path.c b/path.c
index 42609524a..76e887262 100644
--- a/path.c
+++ b/path.c
@@ -91,7 +91,8 @@ int validate_headref(const char *path)
struct stat st;
char *buf, buffer[256];
unsigned char sha1[20];
- int len, fd;
+ int fd;
+ ssize_t len;
if (lstat(path, &st) < 0)
return -1;
@@ -266,90 +267,139 @@ int adjust_shared_perm(const char *path)
if (lstat(path, &st) < 0)
return -1;
mode = st.st_mode;
- if (mode & S_IRUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IRGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IRGRP|S_IROTH)
- : 0));
-
- if (mode & S_IWUSR)
- mode |= S_IWGRP;
-
- if (mode & S_IXUSR)
- mode |= (shared_repository == PERM_GROUP
- ? S_IXGRP
- : (shared_repository == PERM_EVERYBODY
- ? (S_IXGRP|S_IXOTH)
- : 0));
- if (S_ISDIR(mode))
- mode |= S_ISGID;
+
+ if (shared_repository) {
+ int tweak = shared_repository;
+ if (!(mode & S_IWUSR))
+ tweak &= ~0222;
+ mode |= tweak;
+ } else {
+ /* Preserve old PERM_UMASK behaviour */
+ if (mode & S_IWUSR)
+ mode |= S_IWGRP;
+ }
+
+ if (S_ISDIR(mode)) {
+ mode |= FORCE_DIR_SET_GID;
+
+ /* Copy read bits to execute bits */
+ mode |= (shared_repository & 0444) >> 2;
+ }
+
if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
return -2;
return 0;
}
-/* We allow "recursive" symbolic links. Only within reason, though. */
-#define MAXDEPTH 5
+const char *make_relative_path(const char *abs, const char *base)
+{
+ static char buf[PATH_MAX + 1];
+ int baselen;
+ if (!base)
+ return abs;
+ baselen = strlen(base);
+ if (prefixcmp(abs, base))
+ return abs;
+ if (abs[baselen] == '/')
+ baselen++;
+ else if (base[baselen - 1] != '/')
+ return abs;
+ strcpy(buf, abs + baselen);
+ return buf;
+}
-const char *make_absolute_path(const char *path)
+/*
+ * path = absolute path
+ * buf = buffer of at least max(2, strlen(path)+1) bytes
+ * It is okay if buf == path, but they should not overlap otherwise.
+ *
+ * Performs the following normalizations on path, storing the result in buf:
+ * - Removes trailing slashes.
+ * - Removes empty components.
+ * - Removes "." components.
+ * - Removes ".." components, and the components the precede them.
+ * "" and paths that contain only slashes are normalized to "/".
+ * Returns the length of the output.
+ *
+ * Note that this function is purely textual. It does not follow symlinks,
+ * verify the existence of the path, or make any system calls.
+ */
+int normalize_absolute_path(char *buf, const char *path)
{
- static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
- char cwd[1024] = "";
- int buf_index = 1, len;
+ const char *comp_start = path, *comp_end = path;
+ char *dst = buf;
+ int comp_len;
+ assert(buf);
+ assert(path);
+
+ while (*comp_start) {
+ assert(*comp_start == '/');
+ while (*++comp_end && *comp_end != '/')
+ ; /* nothing */
+ comp_len = comp_end - comp_start;
+
+ if (!strncmp("/", comp_start, comp_len) ||
+ !strncmp("/.", comp_start, comp_len))
+ goto next;
+
+ if (!strncmp("/..", comp_start, comp_len)) {
+ while (dst > buf && *--dst != '/')
+ ; /* nothing */
+ goto next;
+ }
- int depth = MAXDEPTH;
- char *last_elem = NULL;
- struct stat st;
+ memcpy(dst, comp_start, comp_len);
+ dst += comp_len;
+ next:
+ comp_start = comp_end;
+ }
- if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
- die ("Too long path: %.*s", 60, path);
-
- while (depth--) {
- if (stat(buf, &st) || !S_ISDIR(st.st_mode)) {
- char *last_slash = strrchr(buf, '/');
- if (last_slash) {
- *last_slash = '\0';
- last_elem = xstrdup(last_slash + 1);
- } else
- last_elem = xstrdup(buf);
- }
+ if (dst == buf)
+ *dst++ = '/';
- if (*buf) {
- if (!*cwd && !getcwd(cwd, sizeof(cwd)))
- die ("Could not get current working directory");
+ *dst = '\0';
+ return dst - buf;
+}
- if (chdir(buf))
- die ("Could not switch to '%s'", buf);
- }
- if (!getcwd(buf, PATH_MAX))
- die ("Could not get current working directory");
-
- if (last_elem) {
- int len = strlen(buf);
- if (len + strlen(last_elem) + 2 > PATH_MAX)
- die ("Too long path name: '%s/%s'",
- buf, last_elem);
- buf[len] = '/';
- strcpy(buf + len + 1, last_elem);
- free(last_elem);
- last_elem = NULL;
- }
+/*
+ * path = Canonical absolute path
+ * prefix_list = Colon-separated list of absolute paths
+ *
+ * Determines, for each path in prefix_list, whether the "prefix" really
+ * is an ancestor directory of path. Returns the length of the longest
+ * ancestor directory, excluding any trailing slashes, or -1 if no prefix
+ * is an ancestor. (Note that this means 0 is returned if prefix_list is
+ * "/".) "/foo" is not considered an ancestor of "/foobar". Directories
+ * are not considered to be their own ancestors. path must be in a
+ * canonical form: empty components, or "." or ".." components are not
+ * allowed. prefix_list may be null, which is like "".
+ */
+int longest_ancestor_length(const char *path, const char *prefix_list)
+{
+ char buf[PATH_MAX+1];
+ const char *ceil, *colon;
+ int len, max_len = -1;
- if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
- len = readlink(buf, next_buf, PATH_MAX);
- if (len < 0)
- die ("Invalid symlink: %s", buf);
- next_buf[len] = '\0';
- buf = next_buf;
- buf_index = 1 - buf_index;
- next_buf = bufs[buf_index];
- } else
- break;
- }
+ if (prefix_list == NULL || !strcmp(path, "/"))
+ return -1;
- if (*cwd && chdir(cwd))
- die ("Could not change back to '%s'", cwd);
+ for (colon = ceil = prefix_list; *colon; ceil = colon+1) {
+ for (colon = ceil; *colon && *colon != ':'; colon++);
+ len = colon - ceil;
+ if (len == 0 || len > PATH_MAX || !is_absolute_path(ceil))
+ continue;
+ strlcpy(buf, ceil, len+1);
+ len = normalize_absolute_path(buf, buf);
+ /* Strip "trailing slashes" from "/". */
+ if (len == 1)
+ len = 0;
+
+ if (!strncmp(path, buf, len) &&
+ path[len] == '/' &&
+ len > max_len) {
+ max_len = len;
+ }
+ }
- return buf;
+ return max_len;
}
diff --git a/perl/Git.pm b/perl/Git.pm
index a2812ea61..102e6a4ce 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -39,6 +39,10 @@ $VERSION = '0.01';
my $lastrev = $repo->command_oneline( [ 'rev-list', '--all' ],
STDERR => 0 );
+ my $sha1 = $repo->hash_and_insert_object('file.txt');
+ my $tempfile = tempfile();
+ my $size = $repo->cat_blob($sha1, $tempfile);
+
=cut
@@ -51,7 +55,10 @@ require Exporter;
# Methods which can be called as standalone functions as well:
@EXPORT_OK = qw(command command_oneline command_noisy
command_output_pipe command_input_pipe command_close_pipe
- version exec_path hash_object git_cmd_try);
+ command_bidi_pipe command_close_bidi_pipe
+ version exec_path hash_object git_cmd_try
+ remote_refs
+ temp_acquire temp_release temp_reset);
=head1 DESCRIPTION
@@ -84,7 +91,7 @@ TODO: In the future, we might also do
Currently, the module merely wraps calls to external Git tools. In the future,
it will provide a much faster way to interact with Git by linking directly
to libgit. This should be completely opaque to the user, though (performance
-increate nonwithstanding).
+increase notwithstanding).
=cut
@@ -92,7 +99,8 @@ increate nonwithstanding).
use Carp qw(carp croak); # but croak is bad - throw instead
use Error qw(:try);
use Cwd qw(abs_path);
-
+use IPC::Open2 qw(open2);
+use Fcntl qw(SEEK_SET SEEK_CUR);
}
@@ -216,7 +224,6 @@ sub repository {
bless $self, $class;
}
-
=back
=head1 METHODS
@@ -375,6 +382,61 @@ sub command_close_pipe {
_cmd_close($fh, $ctx);
}
+=item command_bidi_pipe ( COMMAND [, ARGUMENTS... ] )
+
+Execute the given C<COMMAND> in the same way as command_output_pipe()
+does but return both an input pipe filehandle and an output pipe filehandle.
+
+The function will return return C<($pid, $pipe_in, $pipe_out, $ctx)>.
+See C<command_close_bidi_pipe()> for details.
+
+=cut
+
+sub command_bidi_pipe {
+ my ($pid, $in, $out);
+ $pid = open2($in, $out, 'git', @_);
+ return ($pid, $in, $out, join(' ', @_));
+}
+
+=item command_close_bidi_pipe ( PID, PIPE_IN, PIPE_OUT [, CTX] )
+
+Close the C<PIPE_IN> and C<PIPE_OUT> as returned from C<command_bidi_pipe()>,
+checking whether the command finished successfully. The optional C<CTX>
+argument is required if you want to see the command name in the error message,
+and it is the fourth value returned by C<command_bidi_pipe()>. The call idiom
+is:
+
+ my ($pid, $in, $out, $ctx) = $r->command_bidi_pipe('cat-file --batch-check');
+ print "000000000\n" $out;
+ while (<$in>) { ... }
+ $r->command_close_bidi_pipe($pid, $in, $out, $ctx);
+
+Note that you should not rely on whatever actually is in C<CTX>;
+currently it is simply the command name but in future the context might
+have more complicated structure.
+
+=cut
+
+sub command_close_bidi_pipe {
+ local $?;
+ my ($pid, $in, $out, $ctx) = @_;
+ foreach my $fh ($in, $out) {
+ unless (close $fh) {
+ if ($!) {
+ carp "error closing pipe: $!";
+ } elsif ($? >> 8) {
+ throw Git::Error::Command($ctx, $? >>8);
+ }
+ }
+ }
+
+ waitpid $pid, 0;
+
+ if ($? >> 8) {
+ throw Git::Error::Command($ctx, $? >>8);
+ }
+}
+
=item command_noisy ( COMMAND [, ARGUMENTS... ] )
@@ -487,28 +549,26 @@ does. In scalar context requires the variable to be set only one time
(exception is thrown otherwise), in array context returns allows the
variable to be set multiple times and returns all the values.
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
+ my @cmd = ('config');
+ unshift @cmd, $self if $self;
if (wantarray) {
- return $self->command('config', '--get-all', $var);
+ return command(@cmd, '--get-all', $var);
} else {
- return $self->command_oneline('config', '--get', $var);
+ return command_oneline(@cmd, '--get', $var);
}
} catch Git::Error::Command with {
my $E = shift;
if ($E->value() == 1) {
# Key not found.
- return undef;
+ return;
} else {
throw $E;
}
@@ -522,20 +582,17 @@ Retrieve the bool configuration C<VARIABLE>. The return value
is usable as a boolean in perl (and C<undef> if it's not defined,
of course).
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config_bool {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
- my $val = $self->command_oneline('config', '--bool', '--get',
- $var);
+ my @cmd = ('config', '--bool', '--get', $var);
+ unshift @cmd, $self if $self;
+ my $val = command_oneline(@cmd);
return undef unless defined $val;
return $val eq 'true';
} catch Git::Error::Command with {
@@ -557,19 +614,17 @@ or 'g' in the config file will cause the value to be multiplied
by 1024, 1048576 (1024^2), or 1073741824 (1024^3) prior to output.
It would return C<undef> if configuration variable is not defined,
-Must be called on a repository instance.
-
This currently wraps command('config') so it is not so fast.
=cut
sub config_int {
- my ($self, $var) = @_;
- $self->repo_path()
- or throw Error::Simple("not a repository");
+ my ($self, $var) = _maybe_self(@_);
try {
- return $self->command_oneline('config', '--int', '--get', $var);
+ my @cmd = ('config', '--int', '--get', $var);
+ unshift @cmd, $self if $self;
+ return command_oneline(@cmd);
} catch Git::Error::Command with {
my $E = shift;
if ($E->value() == 1) {
@@ -616,6 +671,59 @@ sub get_color {
return $color;
}
+=item remote_refs ( REPOSITORY [, GROUPS [, REFGLOBS ] ] )
+
+This function returns a hashref of refs stored in a given remote repository.
+The hash is in the format C<refname =\> hash>. For tags, the C<refname> entry
+contains the tag object while a C<refname^{}> entry gives the tagged objects.
+
+C<REPOSITORY> has the same meaning as the appropriate C<git-ls-remote>
+argument; either an URL or a remote name (if called on a repository instance).
+C<GROUPS> is an optional arrayref that can contain 'tags' to return all the
+tags and/or 'heads' to return all the heads. C<REFGLOB> is an optional array
+of strings containing a shell-like glob to further limit the refs returned in
+the hash; the meaning is again the same as the appropriate C<git-ls-remote>
+argument.
+
+This function may or may not be called on a repository instance. In the former
+case, remote names as defined in the repository are recognized as repository
+specifiers.
+
+=cut
+
+sub remote_refs {
+ my ($self, $repo, $groups, $refglobs) = _maybe_self(@_);
+ my @args;
+ if (ref $groups eq 'ARRAY') {
+ foreach (@$groups) {
+ if ($_ eq 'heads') {
+ push (@args, '--heads');
+ } elsif ($_ eq 'tags') {
+ push (@args, '--tags');
+ } else {
+ # Ignore unknown groups for future
+ # compatibility
+ }
+ }
+ }
+ push (@args, $repo);
+ if (ref $refglobs eq 'ARRAY') {
+ push (@args, @$refglobs);
+ }
+
+ my @self = $self ? ($self) : (); # Ultra trickery
+ my ($fh, $ctx) = Git::command_output_pipe(@self, 'ls-remote', @args);
+ my %refs;
+ while (<$fh>) {
+ chomp;
+ my ($hash, $ref) = split(/\t/, $_, 2);
+ $refs{$ref} = $hash;
+ }
+ Git::command_close_pipe(@self, $fh, $ctx);
+ return \%refs;
+}
+
+
=item ident ( TYPE | IDENTSTR )
=item ident_person ( TYPE | IDENTSTR | IDENTARRAY )
@@ -624,7 +732,7 @@ This suite of functions retrieves and parses ident information, as stored
in the commit and tag objects or produced by C<var GIT_type_IDENT> (thus
C<TYPE> can be either I<author> or I<committer>; case is insignificant).
-The C<ident> method retrieves the ident information from C<git-var>
+The C<ident> method retrieves the ident information from C<git var>
and either returns it as a scalar string or as an array with the fields parsed.
Alternatively, it can take a prepared ident string (e.g. from the commit
object) and just parse it.
@@ -639,15 +747,15 @@ The synopsis is like:
"$name <$email>" eq ident_person($name);
$time_tz =~ /^\d+ [+-]\d{4}$/;
-Both methods must be called on a repository instance.
-
=cut
sub ident {
- my ($self, $type) = @_;
+ my ($self, $type) = _maybe_self(@_);
my $identstr;
if (lc $type eq lc 'committer' or lc $type eq lc 'author') {
- $identstr = $self->command_oneline('var', 'GIT_'.uc($type).'_IDENT');
+ my @cmd = ('var', 'GIT_'.uc($type).'_IDENT');
+ unshift @cmd, $self if $self;
+ $identstr = command_oneline(@cmd);
} else {
$identstr = $type;
}
@@ -659,17 +767,16 @@ sub ident {
}
sub ident_person {
- my ($self, @ident) = @_;
- $#ident == 0 and @ident = $self->ident($ident[0]);
+ my ($self, @ident) = _maybe_self(@_);
+ $#ident == 0 and @ident = $self ? $self->ident($ident[0]) : ident($ident[0]);
return "$ident[0] <$ident[1]>";
}
=item hash_object ( TYPE, FILENAME )
-Compute the SHA1 object id of the given C<FILENAME> (or data waiting in
-C<FILEHANDLE>) considering it is of the C<TYPE> object type (C<blob>,
-C<commit>, C<tree>).
+Compute the SHA1 object id of the given C<FILENAME> considering it is
+of the C<TYPE> object type (C<blob>, C<commit>, C<tree>).
The method can be called without any instance or on a specified Git repository,
it makes zero difference.
@@ -685,6 +792,272 @@ sub hash_object {
}
+=item hash_and_insert_object ( FILENAME )
+
+Compute the SHA1 object id of the given C<FILENAME> and add the object to the
+object database.
+
+The function returns the SHA1 hash.
+
+=cut
+
+# TODO: Support for passing FILEHANDLE instead of FILENAME
+sub hash_and_insert_object {
+ my ($self, $filename) = @_;
+
+ carp "Bad filename \"$filename\"" if $filename =~ /[\r\n]/;
+
+ $self->_open_hash_and_insert_object_if_needed();
+ my ($in, $out) = ($self->{hash_object_in}, $self->{hash_object_out});
+
+ unless (print $out $filename, "\n") {
+ $self->_close_hash_and_insert_object();
+ throw Error::Simple("out pipe went bad");
+ }
+
+ chomp(my $hash = <$in>);
+ unless (defined($hash)) {
+ $self->_close_hash_and_insert_object();
+ throw Error::Simple("in pipe went bad");
+ }
+
+ return $hash;
+}
+
+sub _open_hash_and_insert_object_if_needed {
+ my ($self) = @_;
+
+ return if defined($self->{hash_object_pid});
+
+ ($self->{hash_object_pid}, $self->{hash_object_in},
+ $self->{hash_object_out}, $self->{hash_object_ctx}) =
+ command_bidi_pipe(qw(hash-object -w --stdin-paths));
+}
+
+sub _close_hash_and_insert_object {
+ my ($self) = @_;
+
+ return unless defined($self->{hash_object_pid});
+
+ my @vars = map { 'hash_object_' . $_ } qw(pid in out ctx);
+
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
+}
+
+=item cat_blob ( SHA1, FILEHANDLE )
+
+Prints the contents of the blob identified by C<SHA1> to C<FILEHANDLE> and
+returns the number of bytes printed.
+
+=cut
+
+sub cat_blob {
+ my ($self, $sha1, $fh) = @_;
+
+ $self->_open_cat_blob_if_needed();
+ my ($in, $out) = ($self->{cat_blob_in}, $self->{cat_blob_out});
+
+ unless (print $out $sha1, "\n") {
+ $self->_close_cat_blob();
+ throw Error::Simple("out pipe went bad");
+ }
+
+ my $description = <$in>;
+ if ($description =~ / missing$/) {
+ carp "$sha1 doesn't exist in the repository";
+ return -1;
+ }
+
+ if ($description !~ /^[0-9a-fA-F]{40} \S+ (\d+)$/) {
+ carp "Unexpected result returned from git cat-file";
+ return -1;
+ }
+
+ my $size = $1;
+
+ my $blob;
+ my $bytesRead = 0;
+
+ while (1) {
+ my $bytesLeft = $size - $bytesRead;
+ last unless $bytesLeft;
+
+ my $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024;
+ my $read = read($in, $blob, $bytesToRead, $bytesRead);
+ unless (defined($read)) {
+ $self->_close_cat_blob();
+ throw Error::Simple("in pipe went bad");
+ }
+
+ $bytesRead += $read;
+ }
+
+ # Skip past the trailing newline.
+ my $newline;
+ my $read = read($in, $newline, 1);
+ unless (defined($read)) {
+ $self->_close_cat_blob();
+ throw Error::Simple("in pipe went bad");
+ }
+ unless ($read == 1 && $newline eq "\n") {
+ $self->_close_cat_blob();
+ throw Error::Simple("didn't find newline after blob");
+ }
+
+ unless (print $fh $blob) {
+ $self->_close_cat_blob();
+ throw Error::Simple("couldn't write to passed in filehandle");
+ }
+
+ return $size;
+}
+
+sub _open_cat_blob_if_needed {
+ my ($self) = @_;
+
+ return if defined($self->{cat_blob_pid});
+
+ ($self->{cat_blob_pid}, $self->{cat_blob_in},
+ $self->{cat_blob_out}, $self->{cat_blob_ctx}) =
+ command_bidi_pipe(qw(cat-file --batch));
+}
+
+sub _close_cat_blob {
+ my ($self) = @_;
+
+ return unless defined($self->{cat_blob_pid});
+
+ my @vars = map { 'cat_blob_' . $_ } qw(pid in out ctx);
+
+ command_close_bidi_pipe(@$self{@vars});
+ delete @$self{@vars};
+}
+
+
+{ # %TEMP_* Lexical Context
+
+my (%TEMP_LOCKS, %TEMP_FILES);
+
+=item temp_acquire ( NAME )
+
+Attempts to retreive the temporary file mapped to the string C<NAME>. If an
+associated temp file has not been created this session or was closed, it is
+created, cached, and set for autoflush and binmode.
+
+Internally locks the file mapped to C<NAME>. This lock must be released with
+C<temp_release()> when the temp file is no longer needed. Subsequent attempts
+to retrieve temporary files mapped to the same C<NAME> while still locked will
+cause an error. This locking mechanism provides a weak guarantee and is not
+threadsafe. It does provide some error checking to help prevent temp file refs
+writing over one another.
+
+In general, the L<File::Handle> returned should not be closed by consumers as
+it defeats the purpose of this caching mechanism. If you need to close the temp
+file handle, then you should use L<File::Temp> or another temp file faculty
+directly. If a handle is closed and then requested again, then a warning will
+issue.
+
+=cut
+
+sub temp_acquire {
+ my ($self, $name) = _maybe_self(@_);
+
+ my $temp_fd = _temp_cache($name);
+
+ $TEMP_LOCKS{$temp_fd} = 1;
+ $temp_fd;
+}
+
+=item temp_release ( NAME )
+
+=item temp_release ( FILEHANDLE )
+
+Releases a lock acquired through C<temp_acquire()>. Can be called either with
+the C<NAME> mapping used when acquiring the temp file or with the C<FILEHANDLE>
+referencing a locked temp file.
+
+Warns if an attempt is made to release a file that is not locked.
+
+The temp file will be truncated before being released. This can help to reduce
+disk I/O where the system is smart enough to detect the truncation while data
+is in the output buffers. Beware that after the temp file is released and
+truncated, any operations on that file may fail miserably until it is
+re-acquired. All contents are lost between each release and acquire mapped to
+the same string.
+
+=cut
+
+sub temp_release {
+ my ($self, $temp_fd, $trunc) = _maybe_self(@_);
+
+ if (ref($temp_fd) ne 'File::Temp') {
+ $temp_fd = $TEMP_FILES{$temp_fd};
+ }
+ unless ($TEMP_LOCKS{$temp_fd}) {
+ carp "Attempt to release temp file '",
+ $temp_fd, "' that has not been locked";
+ }
+ temp_reset($temp_fd) if $trunc and $temp_fd->opened;
+
+ $TEMP_LOCKS{$temp_fd} = 0;
+ undef;
+}
+
+sub _temp_cache {
+ my ($name) = @_;
+
+ _verify_require();
+
+ my $temp_fd = \$TEMP_FILES{$name};
+ if (defined $$temp_fd and $$temp_fd->opened) {
+ if ($TEMP_LOCKS{$$temp_fd}) {
+ throw Error::Simple("Temp file with moniker '",
+ $name, "' already in use");
+ }
+ } else {
+ if (defined $$temp_fd) {
+ # then we're here because of a closed handle.
+ carp "Temp file '", $name,
+ "' was closed. Opening replacement.";
+ }
+ $$temp_fd = File::Temp->new(
+ TEMPLATE => 'Git_XXXXXX',
+ DIR => File::Spec->tmpdir
+ ) or throw Error::Simple("couldn't open new temp file");
+ $$temp_fd->autoflush;
+ binmode $$temp_fd;
+ }
+ $$temp_fd;
+}
+
+sub _verify_require {
+ eval { require File::Temp; require File::Spec; };
+ $@ and throw Error::Simple($@);
+}
+
+=item temp_reset ( FILEHANDLE )
+
+Truncates and resets the position of the C<FILEHANDLE>.
+
+=cut
+
+sub temp_reset {
+ my ($self, $temp_fd) = _maybe_self(@_);
+
+ truncate $temp_fd, 0
+ or throw Error::Simple("couldn't truncate file");
+ sysseek($temp_fd, 0, SEEK_SET) and seek($temp_fd, 0, SEEK_SET)
+ or throw Error::Simple("couldn't seek to beginning of file");
+ sysseek($temp_fd, 0, SEEK_CUR) == 0 and tell($temp_fd) == 0
+ or throw Error::Simple("expected file position to be reset");
+}
+
+sub END {
+ unlink values %TEMP_FILES if %TEMP_FILES;
+}
+
+} # %TEMP_* Lexical Context
=back
@@ -902,7 +1275,11 @@ sub _cmd_close {
}
-sub DESTROY { }
+sub DESTROY {
+ my ($self) = @_;
+ $self->_close_hash_and_insert_object();
+ $self->_close_cat_blob();
+}
# Pipe implementation for ActiveState Perl.
diff --git a/perl/Makefile b/perl/Makefile
index 5e079ad01..e3dd1a554 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -22,13 +22,18 @@ clean:
ifdef NO_PERL_MAKEMAKER
instdir_SQ = $(subst ','\'',$(prefix)/lib)
$(makfile): ../GIT-CFLAGS Makefile
- echo all: > $@
- echo ' :' >> $@
+ echo all: private-Error.pm Git.pm > $@
+ echo ' mkdir -p blib/lib' >> $@
+ echo ' $(RM) blib/lib/Git.pm; cp Git.pm blib/lib/' >> $@
+ echo ' $(RM) blib/lib/Error.pm' >> $@
+ '$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
+ echo ' cp private-Error.pm blib/lib/Error.pm' >> $@
echo install: >> $@
- echo ' mkdir -p $(instdir_SQ)' >> $@
- echo ' $(RM) $(instdir_SQ)/Git.pm; cp Git.pm $(instdir_SQ)' >> $@
- echo ' $(RM) $(instdir_SQ)/Error.pm; \
- cp private-Error.pm $(instdir_SQ)/Error.pm' >> $@
+ echo ' mkdir -p "$(instdir_SQ)"' >> $@
+ echo ' $(RM) "$(instdir_SQ)/Git.pm"; cp Git.pm "$(instdir_SQ)"' >> $@
+ echo ' $(RM) "$(instdir_SQ)/Error.pm"' >> $@
+ '$(PERL_PATH_SQ)' -MError -e 'exit($$Error::VERSION < 0.15009)' || \
+ echo ' cp private-Error.pm "$(instdir_SQ)/Error.pm"' >> $@
echo instlibdir: >> $@
echo ' echo $(instdir_SQ)' >> $@
else
diff --git a/pkt-line.c b/pkt-line.c
index 355546a1a..f5d00863a 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -65,16 +65,11 @@ void packet_write(int fd, const char *fmt, ...)
static void safe_read(int fd, void *buffer, unsigned size)
{
- size_t n = 0;
-
- while (n < size) {
- ssize_t ret = xread(fd, (char *) buffer + n, size - n);
- if (ret < 0)
- die("read error (%s)", strerror(errno));
- if (!ret)
- die("The remote end hung up unexpectedly");
- n += ret;
- }
+ ssize_t ret = read_in_full(fd, buffer, size);
+ if (ret < 0)
+ die("read error (%s)", strerror(errno));
+ else if (ret < size)
+ die("The remote end hung up unexpectedly");
}
int packet_read_line(int fd, char *buffer, unsigned size)
diff --git a/pretty.c b/pretty.c
index b987ff245..33ef34a41 100644
--- a/pretty.c
+++ b/pretty.c
@@ -3,42 +3,50 @@
#include "utf8.h"
#include "diff.h"
#include "revision.h"
-
-static struct cmt_fmt_map {
- const char *n;
- size_t cmp_len;
- enum cmit_fmt v;
-} cmt_fmts[] = {
- { "raw", 1, CMIT_FMT_RAW },
- { "medium", 1, CMIT_FMT_MEDIUM },
- { "short", 1, CMIT_FMT_SHORT },
- { "email", 1, CMIT_FMT_EMAIL },
- { "full", 5, CMIT_FMT_FULL },
- { "fuller", 5, CMIT_FMT_FULLER },
- { "oneline", 1, CMIT_FMT_ONELINE },
- { "format:", 7, CMIT_FMT_USERFORMAT},
-};
+#include "string-list.h"
+#include "mailmap.h"
static char *user_format;
-enum cmit_fmt get_commit_format(const char *arg)
+void get_commit_format(const char *arg, struct rev_info *rev)
{
int i;
+ static struct cmt_fmt_map {
+ const char *n;
+ size_t cmp_len;
+ enum cmit_fmt v;
+ } cmt_fmts[] = {
+ { "raw", 1, CMIT_FMT_RAW },
+ { "medium", 1, CMIT_FMT_MEDIUM },
+ { "short", 1, CMIT_FMT_SHORT },
+ { "email", 1, CMIT_FMT_EMAIL },
+ { "full", 5, CMIT_FMT_FULL },
+ { "fuller", 5, CMIT_FMT_FULLER },
+ { "oneline", 1, CMIT_FMT_ONELINE },
+ };
- if (!arg || !*arg)
- return CMIT_FMT_DEFAULT;
- if (*arg == '=')
- arg++;
- if (!prefixcmp(arg, "format:")) {
- if (user_format)
- free(user_format);
- user_format = xstrdup(arg + 7);
- return CMIT_FMT_USERFORMAT;
+ rev->use_terminator = 0;
+ if (!arg || !*arg) {
+ rev->commit_format = CMIT_FMT_DEFAULT;
+ return;
+ }
+ if (!prefixcmp(arg, "format:") || !prefixcmp(arg, "tformat:")) {
+ const char *cp = strchr(arg, ':') + 1;
+ free(user_format);
+ user_format = xstrdup(cp);
+ if (arg[0] == 't')
+ rev->use_terminator = 1;
+ rev->commit_format = CMIT_FMT_USERFORMAT;
+ return;
}
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&
- !strncmp(arg, cmt_fmts[i].n, strlen(arg)))
- return cmt_fmts[i].v;
+ !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {
+ if (cmt_fmts[i].v == CMIT_FMT_ONELINE)
+ rev->use_terminator = 1;
+ rev->commit_format = cmt_fmts[i].v;
+ return;
+ }
}
die("invalid --pretty format: %s", arg);
@@ -110,9 +118,9 @@ needquote:
strbuf_addstr(sb, "?=");
}
-static void add_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
- const char *line, enum date_mode dmode,
- const char *encoding)
+void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
+ const char *line, enum date_mode dmode,
+ const char *encoding)
{
char *date;
int namelen;
@@ -282,59 +290,80 @@ static char *logmsg_reencode(const struct commit *commit,
return out;
}
-static void format_person_part(struct strbuf *sb, char part,
+static int mailmap_name(struct strbuf *sb, const char *email)
+{
+ static struct string_list *mail_map;
+ char buffer[1024];
+
+ if (!mail_map) {
+ mail_map = xcalloc(1, sizeof(*mail_map));
+ read_mailmap(mail_map, ".mailmap", NULL);
+ }
+
+ if (!mail_map->nr)
+ return -1;
+
+ if (!map_email(mail_map, email, buffer, sizeof(buffer)))
+ return -1;
+ strbuf_addstr(sb, buffer);
+ return 0;
+}
+
+static size_t format_person_part(struct strbuf *sb, char part,
const char *msg, int len)
{
+ /* currently all placeholders have same length */
+ const int placeholder_len = 2;
int start, end, tz = 0;
- unsigned long date;
+ unsigned long date = 0;
char *ep;
- /* parse name */
+ /* advance 'end' to point to email start delimiter */
for (end = 0; end < len && msg[end] != '<'; end++)
; /* do nothing */
+
/*
- * If it does not even have a '<' and '>', that is
- * quite a bogus commit author and we discard it;
- * this is in line with add_user_info() that is used
- * in the normal codepath. When end points at the '<'
- * that we found, it should have matching '>' later,
- * which means start (beginning of email address) must
- * be strictly below len.
+ * When end points at the '<' that we found, it should have
+ * matching '>' later, which means 'end' must be strictly
+ * below len - 1.
*/
- start = end + 1;
- if (start >= len - 1)
- return;
- while (end > 0 && isspace(msg[end - 1]))
- end--;
- if (part == 'n') { /* name */
- strbuf_add(sb, msg, end);
- return;
+ if (end >= len - 2)
+ goto skip;
+
+ if (part == 'n' || part == 'N') { /* name */
+ while (end > 0 && isspace(msg[end - 1]))
+ end--;
+ if (part != 'N' || !msg[end] || !msg[end + 1] ||
+ mailmap_name(sb, msg + end + 2) < 0)
+ strbuf_add(sb, msg, end);
+ return placeholder_len;
}
+ start = ++end; /* save email start position */
- /* parse email */
- for (end = start; end < len && msg[end] != '>'; end++)
+ /* advance 'end' to point to email end delimiter */
+ for ( ; end < len && msg[end] != '>'; end++)
; /* do nothing */
if (end >= len)
- return;
+ goto skip;
if (part == 'e') { /* email */
strbuf_add(sb, msg + start, end - start);
- return;
+ return placeholder_len;
}
- /* parse date */
+ /* advance 'start' to point to date start delimiter */
for (start = end + 1; start < len && isspace(msg[start]); start++)
; /* do nothing */
if (start >= len)
- return;
+ goto skip;
date = strtoul(msg + start, &ep, 10);
if (msg + start == ep)
- return;
+ goto skip;
if (part == 't') { /* date, UNIX timestamp */
strbuf_add(sb, msg + start, ep - (msg + start));
- return;
+ return placeholder_len;
}
/* parse tz */
@@ -349,17 +378,28 @@ static void format_person_part(struct strbuf *sb, char part,
switch (part) {
case 'd': /* date */
strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
- return;
+ return placeholder_len;
case 'D': /* date, RFC2822 style */
strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
- return;
+ return placeholder_len;
case 'r': /* date, relative */
strbuf_addstr(sb, show_date(date, tz, DATE_RELATIVE));
- return;
+ return placeholder_len;
case 'i': /* date, ISO 8601 */
strbuf_addstr(sb, show_date(date, tz, DATE_ISO8601));
- return;
+ return placeholder_len;
}
+
+skip:
+ /*
+ * bogus commit, 'sb' cannot be updated, but we still need to
+ * compute a valid return value.
+ */
+ if (part == 'n' || part == 'e' || part == 't' || part == 'd'
+ || part == 'D' || part == 'r' || part == 'i')
+ return placeholder_len;
+
+ return 0; /* unknown placeholder */
}
struct chunk {
@@ -440,34 +480,45 @@ static void parse_commit_header(struct format_commit_context *context)
context->commit_header_parsed = 1;
}
-static void format_commit_item(struct strbuf *sb, const char *placeholder,
+static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void *context)
{
struct format_commit_context *c = context;
const struct commit *commit = c->commit;
const char *msg = commit->buffer;
struct commit_list *p;
+ int h1, h2;
/* these are independent of the commit */
switch (placeholder[0]) {
case 'C':
- switch (placeholder[3]) {
- case 'd': /* red */
+ if (!prefixcmp(placeholder + 1, "red")) {
strbuf_addstr(sb, "\033[31m");
- return;
- case 'e': /* green */
+ return 4;
+ } else if (!prefixcmp(placeholder + 1, "green")) {
strbuf_addstr(sb, "\033[32m");
- return;
- case 'u': /* blue */
+ return 6;
+ } else if (!prefixcmp(placeholder + 1, "blue")) {
strbuf_addstr(sb, "\033[34m");
- return;
- case 's': /* reset color */
+ return 5;
+ } else if (!prefixcmp(placeholder + 1, "reset")) {
strbuf_addstr(sb, "\033[m");
- return;
- }
+ return 6;
+ } else
+ return 0;
case 'n': /* newline */
strbuf_addch(sb, '\n');
- return;
+ return 1;
+ case 'x':
+ /* %x00 == NUL, %x0a == LF, etc. */
+ if (0 <= (h1 = hexval_table[0xff & placeholder[1]]) &&
+ h1 <= 16 &&
+ 0 <= (h2 = hexval_table[0xff & placeholder[2]]) &&
+ h2 <= 16) {
+ strbuf_addch(sb, (h1<<4)|h2);
+ return 3;
+ } else
+ return 0;
}
/* these depend on the commit */
@@ -477,34 +528,34 @@ static void format_commit_item(struct strbuf *sb, const char *placeholder,
switch (placeholder[0]) {
case 'H': /* commit hash */
strbuf_addstr(sb, sha1_to_hex(commit->object.sha1));
- return;
+ return 1;
case 'h': /* abbreviated commit hash */
if (add_again(sb, &c->abbrev_commit_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->object.sha1,
DEFAULT_ABBREV));
c->abbrev_commit_hash.len = sb->len - c->abbrev_commit_hash.off;
- return;
+ return 1;
case 'T': /* tree hash */
strbuf_addstr(sb, sha1_to_hex(commit->tree->object.sha1));
- return;
+ return 1;
case 't': /* abbreviated tree hash */
if (add_again(sb, &c->abbrev_tree_hash))
- return;
+ return 1;
strbuf_addstr(sb, find_unique_abbrev(commit->tree->object.sha1,
DEFAULT_ABBREV));
c->abbrev_tree_hash.len = sb->len - c->abbrev_tree_hash.off;
- return;
+ return 1;
case 'P': /* parent hashes */
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
strbuf_addstr(sb, sha1_to_hex(p->item->object.sha1));
}
- return;
+ return 1;
case 'p': /* abbreviated parent hashes */
if (add_again(sb, &c->abbrev_parent_hashes))
- return;
+ return 1;
for (p = commit->parents; p; p = p->next) {
if (p != commit->parents)
strbuf_addch(sb, ' ');
@@ -513,14 +564,14 @@ static void format_commit_item(struct strbuf *sb, const char *placeholder,
}
c->abbrev_parent_hashes.len = sb->len -
c->abbrev_parent_hashes.off;
- return;
+ return 1;
case 'm': /* left/right/bottom */
strbuf_addch(sb, (commit->object.flags & BOUNDARY)
? '-'
: (commit->object.flags & SYMMETRIC_LEFT)
? '<'
: '>');
- return;
+ return 1;
}
/* For the rest we have to parse the commit header. */
@@ -528,66 +579,33 @@ static void format_commit_item(struct strbuf *sb, const char *placeholder,
parse_commit_header(c);
switch (placeholder[0]) {
- case 's':
+ case 's': /* subject */
strbuf_add(sb, msg + c->subject.off, c->subject.len);
- return;
- case 'a':
- format_person_part(sb, placeholder[1],
+ return 1;
+ case 'a': /* author ... */
+ return format_person_part(sb, placeholder[1],
msg + c->author.off, c->author.len);
- return;
- case 'c':
- format_person_part(sb, placeholder[1],
+ case 'c': /* committer ... */
+ return format_person_part(sb, placeholder[1],
msg + c->committer.off, c->committer.len);
- return;
- case 'e':
+ case 'e': /* encoding */
strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
- return;
- case 'b':
+ return 1;
+ case 'b': /* body */
strbuf_addstr(sb, msg + c->body_off);
- return;
+ return 1;
}
+ return 0; /* unknown placeholder */
}
void format_commit_message(const struct commit *commit,
const void *format, struct strbuf *sb)
{
- const char *placeholders[] = {
- "H", /* commit hash */
- "h", /* abbreviated commit hash */
- "T", /* tree hash */
- "t", /* abbreviated tree hash */
- "P", /* parent hashes */
- "p", /* abbreviated parent hashes */
- "an", /* author name */
- "ae", /* author email */
- "ad", /* author date */
- "aD", /* author date, RFC2822 style */
- "ar", /* author date, relative */
- "at", /* author date, UNIX timestamp */
- "ai", /* author date, ISO 8601 */
- "cn", /* committer name */
- "ce", /* committer email */
- "cd", /* committer date */
- "cD", /* committer date, RFC2822 style */
- "cr", /* committer date, relative */
- "ct", /* committer date, UNIX timestamp */
- "ci", /* committer date, ISO 8601 */
- "e", /* encoding */
- "s", /* subject */
- "b", /* body */
- "Cred", /* red */
- "Cgreen", /* green */
- "Cblue", /* blue */
- "Creset", /* reset color */
- "n", /* newline */
- "m", /* left/right/bottom */
- NULL
- };
struct format_commit_context context;
memset(&context, 0, sizeof(context));
context.commit = commit;
- strbuf_expand(sb, format, placeholders, format_commit_item, &context);
+ strbuf_expand(sb, format, format_commit_item, &context);
}
static void pp_header(enum cmit_fmt fmt,
@@ -643,23 +661,23 @@ static void pp_header(enum cmit_fmt fmt,
*/
if (!memcmp(line, "author ", 7)) {
strbuf_grow(sb, linelen + 80);
- add_user_info("Author", fmt, sb, line + 7, dmode, encoding);
+ pp_user_info("Author", fmt, sb, line + 7, dmode, encoding);
}
if (!memcmp(line, "committer ", 10) &&
(fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER)) {
strbuf_grow(sb, linelen + 80);
- add_user_info("Commit", fmt, sb, line + 10, dmode, encoding);
+ pp_user_info("Commit", fmt, sb, line + 10, dmode, encoding);
}
}
}
-static void pp_title_line(enum cmit_fmt fmt,
- const char **msg_p,
- struct strbuf *sb,
- const char *subject,
- const char *after_subject,
- const char *encoding,
- int plain_non_ascii)
+void pp_title_line(enum cmit_fmt fmt,
+ const char **msg_p,
+ struct strbuf *sb,
+ const char *subject,
+ const char *after_subject,
+ const char *encoding,
+ int need_8bit_cte)
{
struct strbuf title;
@@ -692,7 +710,7 @@ static void pp_title_line(enum cmit_fmt fmt,
}
strbuf_addch(sb, '\n');
- if (plain_non_ascii) {
+ if (need_8bit_cte > 0) {
const char *header_fmt =
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=%s\n"
@@ -708,10 +726,10 @@ static void pp_title_line(enum cmit_fmt fmt,
strbuf_release(&title);
}
-static void pp_remainder(enum cmit_fmt fmt,
- const char **msg_p,
- struct strbuf *sb,
- int indent)
+void pp_remainder(enum cmit_fmt fmt,
+ const char **msg_p,
+ struct strbuf *sb,
+ int indent)
{
int first = 1;
for (;;) {
@@ -741,9 +759,9 @@ static void pp_remainder(enum cmit_fmt fmt,
}
void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
- struct strbuf *sb, int abbrev,
- const char *subject, const char *after_subject,
- enum date_mode dmode, int plain_non_ascii)
+ struct strbuf *sb, int abbrev,
+ const char *subject, const char *after_subject,
+ enum date_mode dmode, int need_8bit_cte)
{
unsigned long beginning_of_body;
int indent = 4;
@@ -769,13 +787,11 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)
indent = 0;
- /* After-subject is used to pass in Content-Type: multipart
- * MIME header; in that case we do not have to do the
- * plaintext content type even if the commit message has
- * non 7-bit ASCII character. Otherwise, check if we need
- * to say this is not a 7-bit ASCII.
+ /*
+ * We need to check and emit Content-type: to mark it
+ * as 8-bit if we haven't done so.
*/
- if (fmt == CMIT_FMT_EMAIL && !after_subject) {
+ if (fmt == CMIT_FMT_EMAIL && need_8bit_cte == 0) {
int i, ch, in_body;
for (in_body = i = 0; (ch = msg[i]); i++) {
@@ -788,7 +804,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
in_body = 1;
}
else if (non_ascii(ch)) {
- plain_non_ascii = 1;
+ need_8bit_cte = 1;
break;
}
}
@@ -813,7 +829,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
/* These formats treat the title line specially. */
if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL)
pp_title_line(fmt, &msg, sb, subject,
- after_subject, encoding, plain_non_ascii);
+ after_subject, encoding, need_8bit_cte);
beginning_of_body = sb->len;
if (fmt != CMIT_FMT_ONELINE)
diff --git a/progress.c b/progress.c
index d19f80c0b..55a8687ad 100644
--- a/progress.c
+++ b/progress.c
@@ -241,16 +241,21 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
*p_progress = NULL;
if (progress->last_value != -1) {
/* Force the last update */
- char buf[strlen(msg) + 5];
+ char buf[128], *bufp;
+ size_t len = strlen(msg) + 5;
struct throughput *tp = progress->throughput;
+
+ bufp = (len < sizeof(buf)) ? buf : xmalloc(len + 1);
if (tp) {
unsigned int rate = !tp->avg_misecs ? 0 :
tp->avg_bytes / tp->avg_misecs;
throughput_string(tp, tp->curr_total, rate);
}
progress_update = 1;
- sprintf(buf, ", %s.\n", msg);
- display(progress, progress->last_value, buf);
+ sprintf(bufp, ", %s.\n", msg);
+ display(progress, progress->last_value, bufp);
+ if (buf != bufp)
+ free(bufp);
}
clear_progress_signal();
free(progress->throughput);
diff --git a/quote.c b/quote.c
index d061626c3..6a520855d 100644
--- a/quote.c
+++ b/quote.c
@@ -1,6 +1,8 @@
#include "cache.h"
#include "quote.h"
+int quote_path_fully = 1;
+
/* Help to copy the thing properly quoted for the shell safety.
* any single quote is replaced with '\'', any exclamation point
* is replaced with '\!', and the whole thing is enclosed in a
@@ -260,6 +262,48 @@ extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
fputc(terminator, fp);
}
+/* quote path as relative to the given prefix */
+char *quote_path_relative(const char *in, int len,
+ struct strbuf *out, const char *prefix)
+{
+ int needquote;
+
+ if (len < 0)
+ len = strlen(in);
+
+ /* "../" prefix itself does not need quoting, but "in" might. */
+ needquote = next_quote_pos(in, len) < len;
+ strbuf_setlen(out, 0);
+ strbuf_grow(out, len);
+
+ if (needquote)
+ strbuf_addch(out, '"');
+ if (prefix) {
+ int off = 0;
+ while (prefix[off] && off < len && prefix[off] == in[off])
+ if (prefix[off] == '/') {
+ prefix += off + 1;
+ in += off + 1;
+ len -= off + 1;
+ off = 0;
+ } else
+ off++;
+
+ for (; *prefix; prefix++)
+ if (*prefix == '/')
+ strbuf_addstr(out, "../");
+ }
+
+ quote_c_style_counted (in, len, out, NULL, 1);
+
+ if (needquote)
+ strbuf_addch(out, '"');
+ if (!out->len)
+ strbuf_addstr(out, "./");
+
+ return out->buf;
+}
+
/*
* C-style name unquoting.
*
@@ -288,7 +332,7 @@ int unquote_c_style(struct strbuf *sb, const char *quoted, const char **endp)
switch (*quoted++) {
case '"':
if (endp)
- *endp = quoted + 1;
+ *endp = quoted;
return 0;
case '\\':
break;
diff --git a/quote.h b/quote.h
index 4da110ec0..c5eea6f18 100644
--- a/quote.h
+++ b/quote.h
@@ -47,6 +47,10 @@ extern void write_name_quoted(const char *name, FILE *, int terminator);
extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,
const char *name, FILE *, int terminator);
+/* quote path as relative to the given prefix */
+char *quote_path_relative(const char *in, int len,
+ struct strbuf *out, const char *prefix);
+
/* quoting as a string literal for other languages */
extern void perl_quote_print(FILE *stream, const char *src);
extern void python_quote_print(FILE *stream, const char *src);
diff --git a/reachable.c b/reachable.c
index 00f289f2f..3b1c18ff9 100644
--- a/reachable.c
+++ b/reachable.c
@@ -15,6 +15,8 @@ static void process_blob(struct blob *blob,
{
struct object *obj = &blob->object;
+ if (!blob)
+ die("bad blob object");
if (obj->flags & SEEN)
return;
obj->flags |= SEEN;
@@ -39,6 +41,8 @@ static void process_tree(struct tree *tree,
struct name_entry entry;
struct name_path me;
+ if (!tree)
+ die("bad tree object");
if (obj->flags & SEEN)
return;
obj->flags |= SEEN;
@@ -79,7 +83,8 @@ static void process_tag(struct tag *tag, struct object_array *p, const char *nam
if (parse_tag(tag) < 0)
die("bad tag object %s", sha1_to_hex(obj->sha1));
- add_object(tag->tagged, p, NULL, name);
+ if (tag->tagged)
+ add_object(tag->tagged, p, NULL, name);
}
static void walk_commit_list(struct rev_info *revs)
@@ -150,7 +155,8 @@ static int add_one_reflog(const char *path, const unsigned char *sha1, int flag,
static void add_one_tree(const unsigned char *sha1, struct rev_info *revs)
{
struct tree *tree = lookup_tree(sha1);
- add_pending_object(revs, &tree->object, "");
+ if (tree)
+ add_pending_object(revs, &tree->object, "");
}
static void add_cache_tree(struct cache_tree *it, struct rev_info *revs)
@@ -215,6 +221,7 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
* Set up the revision walk - this will move all commits
* from the pending list to the commit walking list.
*/
- prepare_revision_walk(revs);
+ if (prepare_revision_walk(revs))
+ die("revision walk setup failed");
walk_commit_list(revs);
}
diff --git a/read-cache.c b/read-cache.c
index 22d7b4624..2c03ec306 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -23,88 +23,35 @@
struct index_state the_index;
-static unsigned int hash_name(const char *name, int namelen)
-{
- unsigned int hash = 0x123;
-
- do {
- unsigned char c = *name++;
- hash = hash*101 + c;
- } while (--namelen);
- return hash;
-}
-
-static void hash_index_entry(struct index_state *istate, struct cache_entry *ce)
-{
- void **pos;
- unsigned int hash = hash_name(ce->name, ce_namelen(ce));
-
- pos = insert_hash(hash, ce, &istate->name_hash);
- if (pos) {
- ce->next = *pos;
- *pos = ce;
- }
-}
-
-static void lazy_init_name_hash(struct index_state *istate)
-{
- int nr;
-
- if (istate->name_hash_initialized)
- return;
- for (nr = 0; nr < istate->cache_nr; nr++)
- hash_index_entry(istate, istate->cache[nr]);
- istate->name_hash_initialized = 1;
-}
-
static void set_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
{
istate->cache[nr] = ce;
- if (istate->name_hash_initialized)
- hash_index_entry(istate, ce);
-}
-
-/*
- * We don't actually *remove* it, we can just mark it invalid so that
- * we won't find it in lookups.
- *
- * Not only would we have to search the lists (simple enough), but
- * we'd also have to rehash other hash buckets in case this makes the
- * hash bucket empty (common). So it's much better to just mark
- * it.
- */
-static void remove_hash_entry(struct index_state *istate, struct cache_entry *ce)
-{
- ce->ce_flags |= CE_UNHASHED;
+ add_name_hash(istate, ce);
}
static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
{
struct cache_entry *old = istate->cache[nr];
- if (ce != old) {
- remove_hash_entry(istate, old);
- set_index_entry(istate, nr, ce);
- }
+ remove_name_hash(old);
+ set_index_entry(istate, nr, ce);
istate->cache_changed = 1;
}
-int index_name_exists(struct index_state *istate, const char *name, int namelen)
+void rename_index_entry_at(struct index_state *istate, int nr, const char *new_name)
{
- unsigned int hash = hash_name(name, namelen);
- struct cache_entry *ce;
-
- lazy_init_name_hash(istate);
- ce = lookup_hash(hash, &istate->name_hash);
-
- while (ce) {
- if (!(ce->ce_flags & CE_UNHASHED)) {
- if (!cache_name_compare(name, namelen, ce->name, ce->ce_flags))
- return 1;
- }
- ce = ce->next;
- }
- return 0;
+ struct cache_entry *old = istate->cache[nr], *new;
+ int namelen = strlen(new_name);
+
+ new = xmalloc(cache_entry_size(namelen));
+ copy_cache_entry(new, old);
+ new->ce_flags &= ~(CE_STATE_MASK | CE_NAMEMASK);
+ new->ce_flags |= (namelen >= CE_NAMEMASK ? CE_NAMEMASK : namelen);
+ memcpy(new->name, new_name, namelen + 1);
+
+ cache_tree_invalidate_path(istate->cache_tree, old->name);
+ remove_index_entry_at(istate, nr);
+ add_index_entry(istate, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
}
/*
@@ -200,13 +147,23 @@ static int ce_modified_check_fs(struct cache_entry *ce, struct stat *st)
break;
case S_IFDIR:
if (S_ISGITLINK(ce->ce_mode))
- return 0;
+ return ce_compare_gitlink(ce) ? DATA_CHANGED : 0;
default:
return TYPE_CHANGED;
}
return 0;
}
+static int is_empty_blob_sha1(const unsigned char *sha1)
+{
+ static const unsigned char empty_blob_sha1[20] = {
+ 0xe6,0x9d,0xe2,0x9b,0xb2,0xd1,0xd6,0x43,0x4b,0x8b,
+ 0x29,0xae,0x77,0x5a,0xd8,0xc2,0xe4,0x8c,0x53,0x91
+ };
+
+ return !hashcmp(sha1, empty_blob_sha1);
+}
+
static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
{
unsigned int changed = 0;
@@ -230,6 +187,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
changed |= TYPE_CHANGED;
break;
case S_IFGITLINK:
+ /* We ignore most of the st_xxx fields for gitlinks */
if (!S_ISDIR(st->st_mode))
changed |= TYPE_CHANGED;
else if (ce_compare_gitlink(ce))
@@ -240,7 +198,7 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
}
if (ce->ce_mtime != (unsigned int) st->st_mtime)
changed |= MTIME_CHANGED;
- if (ce->ce_ctime != (unsigned int) st->st_ctime)
+ if (trust_ctime && ce->ce_ctime != (unsigned int) st->st_ctime)
changed |= CTIME_CHANGED;
if (ce->ce_uid != (unsigned int) st->st_uid ||
@@ -262,16 +220,23 @@ static int ce_match_stat_basic(struct cache_entry *ce, struct stat *st)
if (ce->ce_size != (unsigned int) st->st_size)
changed |= DATA_CHANGED;
+ /* Racily smudged entry? */
+ if (!ce->ce_size) {
+ if (!is_empty_blob_sha1(ce->sha1))
+ changed |= DATA_CHANGED;
+ }
+
return changed;
}
-static int is_racy_timestamp(struct index_state *istate, struct cache_entry *ce)
+static int is_racy_timestamp(const struct index_state *istate, struct cache_entry *ce)
{
- return (istate->timestamp &&
+ return (!S_ISGITLINK(ce->ce_mode) &&
+ istate->timestamp &&
((unsigned int)istate->timestamp) <= ce->ce_mtime);
}
-int ie_match_stat(struct index_state *istate,
+int ie_match_stat(const struct index_state *istate,
struct cache_entry *ce, struct stat *st,
unsigned int options)
{
@@ -314,7 +279,7 @@ int ie_match_stat(struct index_state *istate,
return changed;
}
-int ie_modified(struct index_state *istate,
+int ie_modified(const struct index_state *istate,
struct cache_entry *ce, struct stat *st, unsigned int options)
{
int changed, changed_fs;
@@ -329,11 +294,22 @@ int ie_modified(struct index_state *istate,
if (changed & (MODE_CHANGED | TYPE_CHANGED))
return changed;
- /* Immediately after read-tree or update-index --cacheinfo,
- * the length field is zero. For other cases the ce_size
- * should match the SHA1 recorded in the index entry.
+ /*
+ * Immediately after read-tree or update-index --cacheinfo,
+ * the length field is zero, as we have never even read the
+ * lstat(2) information once, and we cannot trust DATA_CHANGED
+ * returned by ie_match_stat() which in turn was returned by
+ * ce_match_stat_basic() to signal that the filesize of the
+ * blob changed. We have to actually go to the filesystem to
+ * see if the contents match, and if so, should answer "unchanged".
+ *
+ * The logic does not apply to gitlinks, as ce_match_stat_basic()
+ * already has checked the actual HEAD from the filesystem in the
+ * subproject. If ie_match_stat() already said it is different,
+ * then we know it is.
*/
- if ((changed & DATA_CHANGED) && ce->ce_size != 0)
+ if ((changed & DATA_CHANGED) &&
+ (S_ISGITLINK(ce->ce_mode) || ce->ce_size != 0))
return changed;
changed_fs = ce_modified_check_fs(ce, st);
@@ -361,6 +337,41 @@ int base_name_compare(const char *name1, int len1, int mode1,
return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
}
+/*
+ * df_name_compare() is identical to base_name_compare(), except it
+ * compares conflicting directory/file entries as equal. Note that
+ * while a directory name compares as equal to a regular file, they
+ * then individually compare _differently_ to a filename that has
+ * a dot after the basename (because '\0' < '.' < '/').
+ *
+ * This is used by routines that want to traverse the git namespace
+ * but then handle conflicting entries together when possible.
+ */
+int df_name_compare(const char *name1, int len1, int mode1,
+ const char *name2, int len2, int mode2)
+{
+ int len = len1 < len2 ? len1 : len2, cmp;
+ unsigned char c1, c2;
+
+ cmp = memcmp(name1, name2, len);
+ if (cmp)
+ return cmp;
+ /* Directories and files compare equal (same length, same name) */
+ if (len1 == len2)
+ return 0;
+ c1 = name1[len];
+ if (!c1 && S_ISDIR(mode1))
+ c1 = '/';
+ c2 = name2[len];
+ if (!c2 && S_ISDIR(mode2))
+ c2 = '/';
+ if (c1 == '/' && !c2)
+ return 0;
+ if (c2 == '/' && !c1)
+ return 0;
+ return c1 - c2;
+}
+
int cache_name_compare(const char *name1, int flags1, const char *name2, int flags2)
{
int len1 = flags1 & CE_NAMEMASK;
@@ -387,7 +398,7 @@ int cache_name_compare(const char *name1, int flags1, const char *name2, int fla
return 0;
}
-int index_name_pos(struct index_state *istate, const char *name, int namelen)
+int index_name_pos(const struct index_state *istate, const char *name, int namelen)
{
int first, last;
@@ -413,7 +424,7 @@ int remove_index_entry_at(struct index_state *istate, int pos)
{
struct cache_entry *ce = istate->cache[pos];
- remove_hash_entry(istate, ce);
+ remove_name_hash(ce);
istate->cache_changed = 1;
istate->cache_nr--;
if (pos >= istate->cache_nr)
@@ -463,21 +474,52 @@ static int index_name_pos_also_unmerged(struct index_state *istate,
return pos;
}
-int add_file_to_index(struct index_state *istate, const char *path, int verbose)
+static int different_name(struct cache_entry *ce, struct cache_entry *alias)
{
- int size, namelen, pos;
- struct stat st;
- struct cache_entry *ce;
- unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
+ int len = ce_namelen(ce);
+ return ce_namelen(alias) != len || memcmp(ce->name, alias->name, len);
+}
- if (lstat(path, &st))
- die("%s: unable to stat (%s)", path, strerror(errno));
+/*
+ * If we add a filename that aliases in the cache, we will use the
+ * name that we already have - but we don't want to update the same
+ * alias twice, because that implies that there were actually two
+ * different files with aliasing names!
+ *
+ * So we use the CE_ADDED flag to verify that the alias was an old
+ * one before we accept it as
+ */
+static struct cache_entry *create_alias_ce(struct cache_entry *ce, struct cache_entry *alias)
+{
+ int len;
+ struct cache_entry *new;
+
+ if (alias->ce_flags & CE_ADDED)
+ die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name);
+
+ /* Ok, create the new entry using the name of the existing alias */
+ len = ce_namelen(alias);
+ new = xcalloc(1, cache_entry_size(len));
+ memcpy(new->name, alias->name, len);
+ copy_cache_entry(new, ce);
+ free(ce);
+ return new;
+}
- if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode) && !S_ISDIR(st.st_mode))
- die("%s: can only add regular files, symbolic links or git-directories", path);
+int add_to_index(struct index_state *istate, const char *path, struct stat *st, int flags)
+{
+ int size, namelen, was_same;
+ mode_t st_mode = st->st_mode;
+ struct cache_entry *ce, *alias;
+ unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
+ int verbose = flags & (ADD_CACHE_VERBOSE | ADD_CACHE_PRETEND);
+ int pretend = flags & ADD_CACHE_PRETEND;
+
+ if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
+ return error("%s: can only add regular files, symbolic links or git-directories", path);
namelen = strlen(path);
- if (S_ISDIR(st.st_mode)) {
+ if (S_ISDIR(st_mode)) {
while (namelen && path[namelen-1] == '/')
namelen--;
}
@@ -485,10 +527,10 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
ce = xcalloc(1, size);
memcpy(ce->name, path, namelen);
ce->ce_flags = namelen;
- fill_stat_cache_info(ce, &st);
+ fill_stat_cache_info(ce, st);
if (trust_executable_bit && has_symlinks)
- ce->ce_mode = create_ce_mode(st.st_mode);
+ ce->ce_mode = create_ce_mode(st_mode);
else {
/* If there is an existing entry, pick the mode bits and type
* from it, otherwise assume unexecutable regular file.
@@ -497,28 +539,46 @@ int add_file_to_index(struct index_state *istate, const char *path, int verbose)
int pos = index_name_pos_also_unmerged(istate, path, namelen);
ent = (0 <= pos) ? istate->cache[pos] : NULL;
- ce->ce_mode = ce_mode_from_stat(ent, st.st_mode);
+ ce->ce_mode = ce_mode_from_stat(ent, st_mode);
}
- pos = index_name_pos(istate, ce->name, namelen);
- if (0 <= pos &&
- !ce_stage(istate->cache[pos]) &&
- !ie_match_stat(istate, istate->cache[pos], &st, ce_option)) {
+ alias = index_name_exists(istate, ce->name, ce_namelen(ce), ignore_case);
+ if (alias && !ce_stage(alias) && !ie_match_stat(istate, alias, st, ce_option)) {
/* Nothing changed, really */
free(ce);
- ce_mark_uptodate(istate->cache[pos]);
+ ce_mark_uptodate(alias);
+ alias->ce_flags |= CE_ADDED;
return 0;
}
-
- if (index_path(ce->sha1, path, &st, 1))
- die("unable to index file %s", path);
- if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
- die("unable to add %s to index",path);
- if (verbose)
+ if (index_path(ce->sha1, path, st, 1))
+ return error("unable to index file %s", path);
+ if (ignore_case && alias && different_name(ce, alias))
+ ce = create_alias_ce(ce, alias);
+ ce->ce_flags |= CE_ADDED;
+
+ /* It was suspected to be racily clean, but it turns out to be Ok */
+ was_same = (alias &&
+ !ce_stage(alias) &&
+ !hashcmp(alias->sha1, ce->sha1) &&
+ ce->ce_mode == alias->ce_mode);
+
+ if (pretend)
+ ;
+ else if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
+ return error("unable to add %s to index",path);
+ if (verbose && !was_same)
printf("add '%s'\n", path);
return 0;
}
+int add_file_to_index(struct index_state *istate, const char *path, int flags)
+{
+ struct stat st;
+ if (lstat(path, &st))
+ die("%s: unable to stat (%s)", path, strerror(errno));
+ return add_to_index(istate, path, &st, flags);
+}
+
struct cache_entry *make_cache_entry(unsigned int mode,
const unsigned char *sha1, const char *path, int stage,
int refresh)
@@ -877,6 +937,15 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
if (ce_uptodate(ce))
return ce;
+ /*
+ * CE_VALID means the user promised us that the change to
+ * the work tree does not matter and told us not to worry.
+ */
+ if (!ignore_valid && (ce->ce_flags & CE_VALID)) {
+ ce_mark_uptodate(ce);
+ return ce;
+ }
+
if (lstat(ce->name, &st) < 0) {
if (err)
*err = errno;
@@ -937,13 +1006,20 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
int allow_unmerged = (flags & REFRESH_UNMERGED) != 0;
int quiet = (flags & REFRESH_QUIET) != 0;
int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
+ int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
+ const char *needs_update_message;
+ needs_update_message = ((flags & REFRESH_SAY_CHANGED)
+ ? "locally modified" : "needs update");
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new;
int cache_errno = 0;
ce = istate->cache[i];
+ if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
+ continue;
+
if (ce_stage(ce)) {
while ((i < istate->cache_nr) &&
! strcmp(istate->cache[i]->name, ce->name))
@@ -974,7 +1050,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p
}
if (quiet)
continue;
- printf("%s: needs update\n", ce->name);
+ printf("%s: %s\n", ce->name, needs_update_message);
has_errors = 1;
continue;
}
@@ -1176,7 +1252,7 @@ int discard_index(struct index_state *istate)
return 0;
}
-int unmerged_index(struct index_state *istate)
+int unmerged_index(const struct index_state *istate)
{
int i;
for (i = 0; i < istate->cache_nr; i++) {
@@ -1262,6 +1338,11 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
* falsely clean entry due to touch-update-touch race, so we leave
* everything else as they are. We are called for entries whose
* ce_mtime match the index file mtime.
+ *
+ * Note that this actually does not do much for gitlinks, for
+ * which ce_match_stat_basic() always goes to the actual
+ * contents. The caller checks with is_racy_timestamp() which
+ * always says "no" for gitlinks, so we are not called for them ;-)
*/
struct stat st;
@@ -1321,7 +1402,7 @@ static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)
return ce_write(c, fd, ondisk, size);
}
-int write_index(struct index_state *istate, int newfd)
+int write_index(const struct index_state *istate, int newfd)
{
SHA_CTX c;
struct cache_header hdr;
@@ -1345,7 +1426,7 @@ int write_index(struct index_state *istate, int newfd)
struct cache_entry *ce = cache[i];
if (ce->ce_flags & CE_REMOVE)
continue;
- if (is_racy_timestamp(istate, ce))
+ if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce))
ce_smudge_racily_clean_entry(ce);
if (ce_write_entry(&c, newfd, ce) < 0)
return -1;
@@ -1365,3 +1446,34 @@ int write_index(struct index_state *istate, int newfd)
}
return ce_flush(&c, newfd);
}
+
+/*
+ * Read the index file that is potentially unmerged into given
+ * index_state, dropping any unmerged entries. Returns true is
+ * the index is unmerged. Callers who want to refuse to work
+ * from an unmerged state can call this and check its return value,
+ * instead of calling read_cache().
+ */
+int read_index_unmerged(struct index_state *istate)
+{
+ int i;
+ struct cache_entry **dst;
+ struct cache_entry *last = NULL;
+
+ read_index(istate);
+ dst = istate->cache;
+ for (i = 0; i < istate->cache_nr; i++) {
+ struct cache_entry *ce = istate->cache[i];
+ if (ce_stage(ce)) {
+ remove_name_hash(ce);
+ if (last && !strcmp(ce->name, last->name))
+ continue;
+ cache_tree_invalidate_path(istate->cache_tree, ce->name);
+ last = ce;
+ continue;
+ }
+ *dst++ = ce;
+ }
+ istate->cache_nr = dst - istate->cache;
+ return !!last;
+}
diff --git a/receive-pack.c b/receive-pack.c
index 326749583..d44c19e6b 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -10,6 +10,7 @@
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
static int deny_non_fast_forwards = 0;
+static int receive_fsck_objects;
static int receive_unpack_limit = -1;
static int transfer_unpack_limit = -1;
static int unpack_limit = 100;
@@ -18,7 +19,7 @@ static int report_status;
static char capabilities[] = " report-status delete-refs ";
static int capabilities_sent;
-static int receive_pack_config(const char *var, const char *value)
+static int receive_pack_config(const char *var, const char *value, void *cb)
{
if (strcmp(var, "receive.denynonfastforwards") == 0) {
deny_non_fast_forwards = git_config_bool(var, value);
@@ -35,7 +36,12 @@ static int receive_pack_config(const char *var, const char *value)
return 0;
}
- return git_default_config(var, value);
+ if (strcmp(var, "receive.fsckobjects") == 0) {
+ receive_fsck_objects = git_config_bool(var, value);
+ return 0;
+ }
+
+ return git_default_config(var, value, cb);
}
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
@@ -132,6 +138,7 @@ static int run_hook(const char *hook_name)
break;
}
}
+ close(proc.in);
return hook_status(finish_command(&proc), hook_name);
}
@@ -363,15 +370,18 @@ static const char *unpack(void)
hdr_err = parse_pack_header(&hdr);
if (hdr_err)
return hdr_err;
- snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
+ snprintf(hdr_arg, sizeof(hdr_arg),
+ "--pack_header=%"PRIu32",%"PRIu32,
ntohl(hdr.hdr_version), ntohl(hdr.hdr_entries));
if (ntohl(hdr.hdr_entries) < unpack_limit) {
- int code;
- const char *unpacker[3];
- unpacker[0] = "unpack-objects";
- unpacker[1] = hdr_arg;
- unpacker[2] = NULL;
+ int code, i = 0;
+ const char *unpacker[4];
+ unpacker[i++] = "unpack-objects";
+ if (receive_fsck_objects)
+ unpacker[i++] = "--strict";
+ unpacker[i++] = hdr_arg;
+ unpacker[i++] = NULL;
code = run_command_v_opt(unpacker, RUN_GIT_CMD);
switch (code) {
case 0:
@@ -392,8 +402,8 @@ static const char *unpack(void)
return "unpacker exited with error code";
}
} else {
- const char *keeper[6];
- int s, status;
+ const char *keeper[7];
+ int s, status, i = 0;
char keep_arg[256];
struct child_process ip;
@@ -401,12 +411,14 @@ static const char *unpack(void)
if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
strcpy(keep_arg + s, "localhost");
- keeper[0] = "index-pack";
- keeper[1] = "--stdin";
- keeper[2] = "--fix-thin";
- keeper[3] = hdr_arg;
- keeper[4] = keep_arg;
- keeper[5] = NULL;
+ keeper[i++] = "index-pack";
+ keeper[i++] = "--stdin";
+ if (receive_fsck_objects)
+ keeper[i++] = "--strict";
+ keeper[i++] = "--fix-thin";
+ keeper[i++] = hdr_arg;
+ keeper[i++] = keep_arg;
+ keeper[i++] = NULL;
memset(&ip, 0, sizeof(ip));
ip.argv = keeper;
ip.out = -1;
@@ -414,6 +426,7 @@ static const char *unpack(void)
if (start_command(&ip))
return "index-pack fork failed";
pack_lockfile = index_pack_lockfile(ip.out);
+ close(ip.out);
status = finish_command(&ip);
if (!status) {
reprepare_packed_git();
@@ -469,13 +482,15 @@ int main(int argc, char **argv)
if (!dir)
usage(receive_pack_usage);
+ setup_path();
+
if (!enter_repo(dir, 0))
die("'%s': unable to chdir or not a git archive", dir);
if (is_repository_shallow())
die("attempt to push into a shallow repository");
- git_config(receive_pack_config);
+ git_config(receive_pack_config, NULL);
if (0 <= transfer_unpack_limit)
unpack_limit = transfer_unpack_limit;
diff --git a/reflog-walk.c b/reflog-walk.c
index ee1456b45..f751fdc8d 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -3,7 +3,7 @@
#include "refs.h"
#include "diff.h"
#include "revision.h"
-#include "path-list.h"
+#include "string-list.h"
#include "reflog-walk.h"
struct complete_reflogs {
@@ -127,7 +127,7 @@ struct commit_reflog {
struct reflog_walk_info {
struct commit_info_lifo reflogs;
- struct path_list complete_reflogs;
+ struct string_list complete_reflogs;
struct commit_reflog *last_commit_reflog;
};
@@ -141,7 +141,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
{
unsigned long timestamp = 0;
int recno = -1;
- struct path_list_item *item;
+ struct string_list_item *item;
struct complete_reflogs *reflogs;
char *branch, *at = strchr(name, '@');
struct commit_reflog *commit_reflog;
@@ -161,7 +161,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
} else
recno = 0;
- item = path_list_lookup(branch, &info->complete_reflogs);
+ item = string_list_lookup(branch, &info->complete_reflogs);
if (item)
reflogs = item->util;
else {
@@ -189,7 +189,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
}
if (!reflogs || reflogs->nr == 0)
return -1;
- path_list_insert(branch, &info->complete_reflogs)->util
+ string_list_insert(branch, &info->complete_reflogs)->util
= reflogs;
}
diff --git a/refs.c b/refs.c
index 67d2a502a..39a3b2380 100644
--- a/refs.c
+++ b/refs.c
@@ -157,6 +157,9 @@ static struct cached_refs {
struct ref_list *loose;
struct ref_list *packed;
} cached_refs;
+static struct ref_list *current_ref;
+
+static struct ref_list *extra_refs;
static void free_ref_list(struct ref_list *list)
{
@@ -214,6 +217,17 @@ static void read_packed_refs(FILE *f, struct cached_refs *cached_refs)
cached_refs->packed = sort_ref_list(list);
}
+void add_extra_ref(const char *name, const unsigned char *sha1, int flag)
+{
+ extra_refs = add_ref(name, sha1, flag, extra_refs, NULL);
+}
+
+void clear_extra_refs(void)
+{
+ free_ref_list(extra_refs);
+ extra_refs = NULL;
+}
+
static struct ref_list *get_packed_refs(void)
{
if (!cached_refs.did_packed) {
@@ -351,6 +365,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
{
int len = strlen(path), retval;
char *gitdir;
+ const char *tmp;
while (len && path[len-1] == '/')
len--;
@@ -358,16 +373,27 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re
return -1;
gitdir = xmalloc(len + MAXREFLEN + 8);
memcpy(gitdir, path, len);
- memcpy(gitdir + len, "/.git/", 7);
-
- retval = resolve_gitlink_ref_recursive(gitdir, len+6, refname, result, 0);
+ memcpy(gitdir + len, "/.git", 6);
+ len += 5;
+
+ tmp = read_gitfile_gently(gitdir);
+ if (tmp) {
+ free(gitdir);
+ len = strlen(tmp);
+ gitdir = xmalloc(len + MAXREFLEN + 3);
+ memcpy(gitdir, tmp, len);
+ }
+ gitdir[len] = '/';
+ gitdir[++len] = '\0';
+ retval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);
free(gitdir);
return retval;
}
const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag)
{
- int depth = MAXDEPTH, len;
+ int depth = MAXDEPTH;
+ ssize_t len;
char buffer[256];
static char ref_buffer[256];
@@ -476,6 +502,7 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
error("%s does not point to a valid object!", entry->name);
return 0;
}
+ current_ref = entry;
return fn(entry->name + trim, entry->sha1, entry->flag, cb_data);
}
@@ -485,6 +512,16 @@ int peel_ref(const char *ref, unsigned char *sha1)
unsigned char base[20];
struct object *o;
+ if (current_ref && (current_ref->name == ref
+ || !strcmp(current_ref->name, ref))) {
+ if (current_ref->flag & REF_KNOWS_PEELED) {
+ hashcpy(sha1, current_ref->peeled);
+ return 0;
+ }
+ hashcpy(base, current_ref->sha1);
+ goto fallback;
+ }
+
if (!resolve_ref(ref, base, 1, &flag))
return -1;
@@ -504,9 +541,9 @@ int peel_ref(const char *ref, unsigned char *sha1)
}
}
- /* fallback - callers should not call this for unpacked refs */
+fallback:
o = parse_object(base);
- if (o->type == OBJ_TAG) {
+ if (o && o->type == OBJ_TAG) {
o = deref_tag(o, ref, 0);
if (o) {
hashcpy(sha1, o->sha1);
@@ -519,10 +556,15 @@ int peel_ref(const char *ref, unsigned char *sha1)
static int do_for_each_ref(const char *base, each_ref_fn fn, int trim,
void *cb_data)
{
- int retval;
+ int retval = 0;
struct ref_list *packed = get_packed_refs();
struct ref_list *loose = get_loose_refs();
+ struct ref_list *extra;
+
+ for (extra = extra_refs; extra; extra = extra->next)
+ retval = do_one_ref(base, fn, trim, cb_data, extra);
+
while (packed && loose) {
struct ref_list *entry;
int cmp = strcmp(packed->name, loose->name);
@@ -539,15 +581,18 @@ static int do_for_each_ref(const char *base, each_ref_fn fn, int trim,
}
retval = do_one_ref(base, fn, trim, cb_data, entry);
if (retval)
- return retval;
+ goto end_each;
}
for (packed = packed ? packed : loose; packed; packed = packed->next) {
retval = do_one_ref(base, fn, trim, cb_data, packed);
if (retval)
- return retval;
+ goto end_each;
}
- return 0;
+
+end_each:
+ current_ref = NULL;
+ return retval;
}
int head_ref(each_ref_fn fn, void *cb_data)
@@ -880,7 +925,7 @@ int delete_ref(const char *refname, const unsigned char *sha1)
i = strlen(lock->lk->filename) - 5; /* .lock */
lock->lk->filename[i] = 0;
err = unlink(lock->lk->filename);
- if (err) {
+ if (err && errno != ENOENT) {
ret = 1;
error("unlink(%s) failed: %s",
lock->lk->filename, strerror(errno));
@@ -1018,7 +1063,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
return 1;
}
-static int close_ref(struct ref_lock *lock)
+int close_ref(struct ref_lock *lock)
{
if (close_lock_file(lock->lk))
return -1;
@@ -1026,7 +1071,7 @@ static int close_ref(struct ref_lock *lock)
return 0;
}
-static int commit_ref(struct ref_lock *lock)
+int commit_ref(struct ref_lock *lock)
{
if (commit_lock_file(lock->lk))
return -1;
@@ -1367,6 +1412,10 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
tz = strtoul(tz_c, NULL, 10);
if (get_sha1_hex(logdata, sha1))
die("Log %s is corrupt.", logfile);
+ if (is_null_sha1(sha1)) {
+ if (get_sha1_hex(logdata + 41, sha1))
+ die("Log %s is corrupt.", logfile);
+ }
if (msg)
*msg = ref_msg(logdata, logend);
munmap(log_mapped, mapsz);
diff --git a/refs.h b/refs.h
index 9cd16f829..06ad26055 100644
--- a/refs.h
+++ b/refs.h
@@ -24,6 +24,15 @@ extern int for_each_tag_ref(each_ref_fn, void *);
extern int for_each_branch_ref(each_ref_fn, void *);
extern int for_each_remote_ref(each_ref_fn, void *);
+/*
+ * Extra refs will be listed by for_each_ref() before any actual refs
+ * for the duration of this process or until clear_extra_refs() is
+ * called. Only extra refs added before for_each_ref() is called will
+ * be listed on a given call of for_each_ref().
+ */
+extern void add_extra_ref(const char *refname, const unsigned char *sha1, int flags);
+extern void clear_extra_refs(void);
+
extern int peel_ref(const char *, unsigned char *);
/** Locks a "refs/" ref returning the lock on success and NULL on failure. **/
@@ -33,6 +42,12 @@ extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_
#define REF_NODEREF 0x01
extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags);
+/** Close the file descriptor owned by a lock and return the status */
+extern int close_ref(struct ref_lock *lock);
+
+/** Close and commit the ref locked by the lock */
+extern int commit_ref(struct ref_lock *lock);
+
/** Release any lock taken but not written. **/
extern void unlock_ref(struct ref_lock *lock);
diff --git a/remote.c b/remote.c
index 0e006804e..f61a3ab39 100644
--- a/remote.c
+++ b/remote.c
@@ -1,124 +1,198 @@
#include "cache.h"
#include "remote.h"
#include "refs.h"
+#include "commit.h"
+#include "diff.h"
+#include "revision.h"
+
+static struct refspec s_tag_refspec = {
+ 0,
+ 1,
+ 0,
+ "refs/tags/",
+ "refs/tags/"
+};
+
+const struct refspec *tag_refspec = &s_tag_refspec;
+
+struct counted_string {
+ size_t len;
+ const char *s;
+};
+struct rewrite {
+ const char *base;
+ size_t baselen;
+ struct counted_string *instead_of;
+ int instead_of_nr;
+ int instead_of_alloc;
+};
static struct remote **remotes;
-static int allocated_remotes;
+static int remotes_alloc;
+static int remotes_nr;
static struct branch **branches;
-static int allocated_branches;
+static int branches_alloc;
+static int branches_nr;
static struct branch *current_branch;
static const char *default_remote_name;
+static struct rewrite **rewrite;
+static int rewrite_alloc;
+static int rewrite_nr;
+
#define BUF_SIZE (2048)
static char buffer[BUF_SIZE];
+static const char *alias_url(const char *url)
+{
+ int i, j;
+ char *ret;
+ struct counted_string *longest;
+ int longest_i;
+
+ longest = NULL;
+ longest_i = -1;
+ for (i = 0; i < rewrite_nr; i++) {
+ if (!rewrite[i])
+ continue;
+ for (j = 0; j < rewrite[i]->instead_of_nr; j++) {
+ if (!prefixcmp(url, rewrite[i]->instead_of[j].s) &&
+ (!longest ||
+ longest->len < rewrite[i]->instead_of[j].len)) {
+ longest = &(rewrite[i]->instead_of[j]);
+ longest_i = i;
+ }
+ }
+ }
+ if (!longest)
+ return url;
+
+ ret = malloc(rewrite[longest_i]->baselen +
+ (strlen(url) - longest->len) + 1);
+ strcpy(ret, rewrite[longest_i]->base);
+ strcpy(ret + rewrite[longest_i]->baselen, url + longest->len);
+ return ret;
+}
+
static void add_push_refspec(struct remote *remote, const char *ref)
{
- int nr = remote->push_refspec_nr + 1;
- remote->push_refspec =
- xrealloc(remote->push_refspec, nr * sizeof(char *));
- remote->push_refspec[nr-1] = ref;
- remote->push_refspec_nr = nr;
+ ALLOC_GROW(remote->push_refspec,
+ remote->push_refspec_nr + 1,
+ remote->push_refspec_alloc);
+ remote->push_refspec[remote->push_refspec_nr++] = ref;
}
static void add_fetch_refspec(struct remote *remote, const char *ref)
{
- int nr = remote->fetch_refspec_nr + 1;
- remote->fetch_refspec =
- xrealloc(remote->fetch_refspec, nr * sizeof(char *));
- remote->fetch_refspec[nr-1] = ref;
- remote->fetch_refspec_nr = nr;
+ ALLOC_GROW(remote->fetch_refspec,
+ remote->fetch_refspec_nr + 1,
+ remote->fetch_refspec_alloc);
+ remote->fetch_refspec[remote->fetch_refspec_nr++] = ref;
}
static void add_url(struct remote *remote, const char *url)
{
- int nr = remote->url_nr + 1;
- remote->url =
- xrealloc(remote->url, nr * sizeof(char *));
- remote->url[nr-1] = url;
- remote->url_nr = nr;
+ ALLOC_GROW(remote->url, remote->url_nr + 1, remote->url_alloc);
+ remote->url[remote->url_nr++] = url;
+}
+
+static void add_url_alias(struct remote *remote, const char *url)
+{
+ add_url(remote, alias_url(url));
}
static struct remote *make_remote(const char *name, int len)
{
- int i, empty = -1;
+ struct remote *ret;
+ int i;
- for (i = 0; i < allocated_remotes; i++) {
- if (!remotes[i]) {
- if (empty < 0)
- empty = i;
- } else {
- if (len ? (!strncmp(name, remotes[i]->name, len) &&
- !remotes[i]->name[len]) :
- !strcmp(name, remotes[i]->name))
- return remotes[i];
- }
+ for (i = 0; i < remotes_nr; i++) {
+ if (len ? (!strncmp(name, remotes[i]->name, len) &&
+ !remotes[i]->name[len]) :
+ !strcmp(name, remotes[i]->name))
+ return remotes[i];
}
- if (empty < 0) {
- empty = allocated_remotes;
- allocated_remotes += allocated_remotes ? allocated_remotes : 1;
- remotes = xrealloc(remotes,
- sizeof(*remotes) * allocated_remotes);
- memset(remotes + empty, 0,
- (allocated_remotes - empty) * sizeof(*remotes));
- }
- remotes[empty] = xcalloc(1, sizeof(struct remote));
+ ret = xcalloc(1, sizeof(struct remote));
+ ALLOC_GROW(remotes, remotes_nr + 1, remotes_alloc);
+ remotes[remotes_nr++] = ret;
if (len)
- remotes[empty]->name = xstrndup(name, len);
+ ret->name = xstrndup(name, len);
else
- remotes[empty]->name = xstrdup(name);
- return remotes[empty];
+ ret->name = xstrdup(name);
+ return ret;
}
static void add_merge(struct branch *branch, const char *name)
{
- int nr = branch->merge_nr + 1;
- branch->merge_name =
- xrealloc(branch->merge_name, nr * sizeof(char *));
- branch->merge_name[nr-1] = name;
- branch->merge_nr = nr;
+ ALLOC_GROW(branch->merge_name, branch->merge_nr + 1,
+ branch->merge_alloc);
+ branch->merge_name[branch->merge_nr++] = name;
}
static struct branch *make_branch(const char *name, int len)
{
- int i, empty = -1;
+ struct branch *ret;
+ int i;
char *refname;
- for (i = 0; i < allocated_branches; i++) {
- if (!branches[i]) {
- if (empty < 0)
- empty = i;
- } else {
- if (len ? (!strncmp(name, branches[i]->name, len) &&
- !branches[i]->name[len]) :
- !strcmp(name, branches[i]->name))
- return branches[i];
- }
+ for (i = 0; i < branches_nr; i++) {
+ if (len ? (!strncmp(name, branches[i]->name, len) &&
+ !branches[i]->name[len]) :
+ !strcmp(name, branches[i]->name))
+ return branches[i];
}
- if (empty < 0) {
- empty = allocated_branches;
- allocated_branches += allocated_branches ? allocated_branches : 1;
- branches = xrealloc(branches,
- sizeof(*branches) * allocated_branches);
- memset(branches + empty, 0,
- (allocated_branches - empty) * sizeof(*branches));
- }
- branches[empty] = xcalloc(1, sizeof(struct branch));
+ ALLOC_GROW(branches, branches_nr + 1, branches_alloc);
+ ret = xcalloc(1, sizeof(struct branch));
+ branches[branches_nr++] = ret;
if (len)
- branches[empty]->name = xstrndup(name, len);
+ ret->name = xstrndup(name, len);
else
- branches[empty]->name = xstrdup(name);
+ ret->name = xstrdup(name);
refname = malloc(strlen(name) + strlen("refs/heads/") + 1);
strcpy(refname, "refs/heads/");
- strcpy(refname + strlen("refs/heads/"),
- branches[empty]->name);
- branches[empty]->refname = refname;
+ strcpy(refname + strlen("refs/heads/"), ret->name);
+ ret->refname = refname;
+
+ return ret;
+}
+
+static struct rewrite *make_rewrite(const char *base, int len)
+{
+ struct rewrite *ret;
+ int i;
+
+ for (i = 0; i < rewrite_nr; i++) {
+ if (len
+ ? (len == rewrite[i]->baselen &&
+ !strncmp(base, rewrite[i]->base, len))
+ : !strcmp(base, rewrite[i]->base))
+ return rewrite[i];
+ }
+
+ ALLOC_GROW(rewrite, rewrite_nr + 1, rewrite_alloc);
+ ret = xcalloc(1, sizeof(struct rewrite));
+ rewrite[rewrite_nr++] = ret;
+ if (len) {
+ ret->base = xstrndup(base, len);
+ ret->baselen = len;
+ }
+ else {
+ ret->base = xstrdup(base);
+ ret->baselen = strlen(base);
+ }
+ return ret;
+}
- return branches[empty];
+static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
+{
+ ALLOC_GROW(rewrite->instead_of, rewrite->instead_of_nr + 1, rewrite->instead_of_alloc);
+ rewrite->instead_of[rewrite->instead_of_nr].s = instead_of;
+ rewrite->instead_of[rewrite->instead_of_nr].len = strlen(instead_of);
+ rewrite->instead_of_nr++;
}
static void read_remotes_file(struct remote *remote)
@@ -154,7 +228,7 @@ static void read_remotes_file(struct remote *remote)
switch (value_list) {
case 0:
- add_url(remote, xstrdup(s));
+ add_url_alias(remote, xstrdup(s));
break;
case 1:
add_push_refspec(remote, xstrdup(s));
@@ -171,7 +245,7 @@ static void read_branches_file(struct remote *remote)
{
const char *slash = strchr(remote->name, '/');
char *frag;
- char *branch;
+ struct strbuf branch;
int n = slash ? slash - remote->name : 1000;
FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
char *s, *p;
@@ -197,21 +271,37 @@ static void read_branches_file(struct remote *remote)
strcpy(p, s);
if (slash)
strcat(p, slash);
+
+ /*
+ * With "slash", e.g. "git fetch jgarzik/netdev-2.6" when
+ * reading from $GIT_DIR/branches/jgarzik fetches "HEAD" from
+ * the partial URL obtained from the branches file plus
+ * "/netdev-2.6" and does not store it in any tracking ref.
+ * #branch specifier in the file is ignored.
+ *
+ * Otherwise, the branches file would have URL and optionally
+ * #branch specified. The "master" (or specified) branch is
+ * fetched and stored in the local branch of the same name.
+ */
+ strbuf_init(&branch, 0);
frag = strchr(p, '#');
if (frag) {
*(frag++) = '\0';
- branch = xmalloc(strlen(frag) + 12);
- strcpy(branch, "refs/heads/");
- strcat(branch, frag);
+ strbuf_addf(&branch, "refs/heads/%s", frag);
+ } else
+ strbuf_addstr(&branch, "refs/heads/master");
+ if (!slash) {
+ strbuf_addf(&branch, ":refs/heads/%s", remote->name);
} else {
- branch = "refs/heads/master";
+ strbuf_reset(&branch);
+ strbuf_addstr(&branch, "HEAD:");
}
- add_url(remote, p);
- add_fetch_refspec(remote, branch);
+ add_url_alias(remote, p);
+ add_fetch_refspec(remote, strbuf_detach(&branch, 0));
remote->fetch_tags = 1; /* always auto-follow */
}
-static int handle_config(const char *key, const char *value)
+static int handle_config(const char *key, const char *value, void *cb)
{
const char *name;
const char *subkey;
@@ -222,17 +312,33 @@ static int handle_config(const char *key, const char *value)
subkey = strrchr(name, '.');
if (!subkey)
return 0;
- if (!value)
- return 0;
branch = make_branch(name, subkey - name);
if (!strcmp(subkey, ".remote")) {
+ if (!value)
+ return config_error_nonbool(key);
branch->remote_name = xstrdup(value);
if (branch == current_branch)
default_remote_name = branch->remote_name;
- } else if (!strcmp(subkey, ".merge"))
+ } else if (!strcmp(subkey, ".merge")) {
+ if (!value)
+ return config_error_nonbool(key);
add_merge(branch, xstrdup(value));
+ }
return 0;
}
+ if (!prefixcmp(key, "url.")) {
+ struct rewrite *rewrite;
+ name = key + 4;
+ subkey = strrchr(name, '.');
+ if (!subkey)
+ return 0;
+ rewrite = make_rewrite(name, subkey - name);
+ if (!strcmp(subkey, ".insteadof")) {
+ if (!value)
+ return config_error_nonbool(key);
+ add_instead_of(rewrite, xstrdup(value));
+ }
+ }
if (prefixcmp(key, "remote."))
return 0;
name = key + 7;
@@ -244,46 +350,64 @@ static int handle_config(const char *key, const char *value)
return 0;
}
remote = make_remote(name, subkey - name);
- if (!value) {
- /* if we ever have a boolean variable, e.g. "remote.*.disabled"
- * [remote "frotz"]
- * disabled
- * is a valid way to set it to true; we get NULL in value so
- * we need to handle it here.
- *
- * if (!strcmp(subkey, ".disabled")) {
- * val = git_config_bool(key, value);
- * return 0;
- * } else
- *
- */
- return 0; /* ignore unknown booleans */
- }
- if (!strcmp(subkey, ".url")) {
- add_url(remote, xstrdup(value));
+ if (!strcmp(subkey, ".mirror"))
+ remote->mirror = git_config_bool(key, value);
+ else if (!strcmp(subkey, ".skipdefaultupdate"))
+ remote->skip_default_update = git_config_bool(key, value);
+
+ else if (!strcmp(subkey, ".url")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_url(remote, v);
} else if (!strcmp(subkey, ".push")) {
- add_push_refspec(remote, xstrdup(value));
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_push_refspec(remote, v);
} else if (!strcmp(subkey, ".fetch")) {
- add_fetch_refspec(remote, xstrdup(value));
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
+ add_fetch_refspec(remote, v);
} else if (!strcmp(subkey, ".receivepack")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
if (!remote->receivepack)
- remote->receivepack = xstrdup(value);
+ remote->receivepack = v;
else
error("more than one receivepack given, using the first");
} else if (!strcmp(subkey, ".uploadpack")) {
+ const char *v;
+ if (git_config_string(&v, key, value))
+ return -1;
if (!remote->uploadpack)
- remote->uploadpack = xstrdup(value);
+ remote->uploadpack = v;
else
error("more than one uploadpack given, using the first");
} else if (!strcmp(subkey, ".tagopt")) {
if (!strcmp(value, "--no-tags"))
remote->fetch_tags = -1;
} else if (!strcmp(subkey, ".proxy")) {
- remote->http_proxy = xstrdup(value);
+ return git_config_string((const char **)&remote->http_proxy,
+ key, value);
}
return 0;
}
+static void alias_all_urls(void)
+{
+ int i, j;
+ for (i = 0; i < remotes_nr; i++) {
+ if (!remotes[i])
+ continue;
+ for (j = 0; j < remotes[i]->url_nr; j++) {
+ remotes[i]->url[j] = alias_url(remotes[i]->url[j]);
+ }
+ }
+}
+
static void read_config(void)
{
unsigned char sha1[20];
@@ -299,45 +423,185 @@ static void read_config(void)
current_branch =
make_branch(head_ref + strlen("refs/heads/"), 0);
}
- git_config(handle_config);
+ git_config(handle_config, NULL);
+ alias_all_urls();
+}
+
+/*
+ * We need to make sure the tracking branches are well formed, but a
+ * wildcard refspec in "struct refspec" must have a trailing slash. We
+ * temporarily drop the trailing '/' while calling check_ref_format(),
+ * and put it back. The caller knows that a CHECK_REF_FORMAT_ONELEVEL
+ * error return is Ok for a wildcard refspec.
+ */
+static int verify_refname(char *name, int is_glob)
+{
+ int result, len = -1;
+
+ if (is_glob) {
+ len = strlen(name);
+ assert(name[len - 1] == '/');
+ name[len - 1] = '\0';
+ }
+ result = check_ref_format(name);
+ if (is_glob)
+ name[len - 1] = '/';
+ return result;
}
-struct refspec *parse_ref_spec(int nr_refspec, const char **refspec)
+static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
{
int i;
+ int st;
struct refspec *rs = xcalloc(sizeof(*rs), nr_refspec);
+
for (i = 0; i < nr_refspec; i++) {
- const char *sp, *ep, *gp;
- sp = refspec[i];
- if (*sp == '+') {
+ size_t llen;
+ int is_glob;
+ const char *lhs, *rhs;
+
+ llen = is_glob = 0;
+
+ lhs = refspec[i];
+ if (*lhs == '+') {
rs[i].force = 1;
- sp++;
+ lhs++;
+ }
+
+ rhs = strrchr(lhs, ':');
+
+ /*
+ * Before going on, special case ":" (or "+:") as a refspec
+ * for matching refs.
+ */
+ if (!fetch && rhs == lhs && rhs[1] == '\0') {
+ rs[i].matching = 1;
+ continue;
+ }
+
+ if (rhs) {
+ size_t rlen = strlen(++rhs);
+ is_glob = (2 <= rlen && !strcmp(rhs + rlen - 2, "/*"));
+ rs[i].dst = xstrndup(rhs, rlen - is_glob);
+ }
+
+ llen = (rhs ? (rhs - lhs - 1) : strlen(lhs));
+ if (2 <= llen && !memcmp(lhs + llen - 2, "/*", 2)) {
+ if ((rhs && !is_glob) || (!rhs && fetch))
+ goto invalid;
+ is_glob = 1;
+ llen--;
+ } else if (rhs && is_glob) {
+ goto invalid;
}
- gp = strchr(sp, '*');
- ep = strchr(sp, ':');
- if (gp && ep && gp > ep)
- gp = NULL;
- if (ep) {
- if (ep[1]) {
- const char *glob = strchr(ep + 1, '*');
- if (!glob)
- gp = NULL;
- if (gp)
- rs[i].dst = xstrndup(ep + 1,
- glob - ep - 1);
- else
- rs[i].dst = xstrdup(ep + 1);
+
+ rs[i].pattern = is_glob;
+ rs[i].src = xstrndup(lhs, llen);
+
+ if (fetch) {
+ /*
+ * LHS
+ * - empty is allowed; it means HEAD.
+ * - otherwise it must be a valid looking ref.
+ */
+ if (!*rs[i].src)
+ ; /* empty is ok */
+ else {
+ st = verify_refname(rs[i].src, is_glob);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+ goto invalid;
+ }
+ /*
+ * RHS
+ * - missing is ok, and is same as empty.
+ * - empty is ok; it means not to store.
+ * - otherwise it must be a valid looking ref.
+ */
+ if (!rs[i].dst) {
+ ; /* ok */
+ } else if (!*rs[i].dst) {
+ ; /* ok */
+ } else {
+ st = verify_refname(rs[i].dst, is_glob);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+ goto invalid;
}
} else {
- ep = sp + strlen(sp);
- }
- if (gp) {
- rs[i].pattern = 1;
- ep = gp;
+ /*
+ * LHS
+ * - empty is allowed; it means delete.
+ * - when wildcarded, it must be a valid looking ref.
+ * - otherwise, it must be an extended SHA-1, but
+ * there is no existing way to validate this.
+ */
+ if (!*rs[i].src)
+ ; /* empty is ok */
+ else if (is_glob) {
+ st = verify_refname(rs[i].src, is_glob);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+ goto invalid;
+ }
+ else
+ ; /* anything goes, for now */
+ /*
+ * RHS
+ * - missing is allowed, but LHS then must be a
+ * valid looking ref.
+ * - empty is not allowed.
+ * - otherwise it must be a valid looking ref.
+ */
+ if (!rs[i].dst) {
+ st = verify_refname(rs[i].src, is_glob);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+ goto invalid;
+ } else if (!*rs[i].dst) {
+ goto invalid;
+ } else {
+ st = verify_refname(rs[i].dst, is_glob);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL)
+ goto invalid;
+ }
}
- rs[i].src = xstrndup(sp, ep - sp);
}
return rs;
+
+ invalid:
+ if (verify) {
+ free(rs);
+ return NULL;
+ }
+ die("Invalid refspec '%s'", refspec[i]);
+}
+
+int valid_fetch_refspec(const char *fetch_refspec_str)
+{
+ const char *fetch_refspec[] = { fetch_refspec_str };
+ struct refspec *refspec;
+
+ refspec = parse_refspec_internal(1, fetch_refspec, 1, 1);
+ if (refspec)
+ free(refspec);
+ return !!refspec;
+}
+
+struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec)
+{
+ return parse_refspec_internal(nr_refspec, refspec, 1, 0);
+}
+
+struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
+{
+ return parse_refspec_internal(nr_refspec, refspec, 0, 0);
+}
+
+static int valid_remote_nick(const char *name)
+{
+ if (!name[0] || /* not empty */
+ (name[0] == '.' && /* not "." */
+ (!name[1] || /* not ".." */
+ (name[1] == '.' && !name[2]))))
+ return 0;
+ return !strchr(name, '/'); /* no slash */
}
struct remote *remote_get(const char *name)
@@ -348,18 +612,18 @@ struct remote *remote_get(const char *name)
if (!name)
name = default_remote_name;
ret = make_remote(name, 0);
- if (name[0] != '/') {
+ if (valid_remote_nick(name)) {
if (!ret->url)
read_remotes_file(ret);
if (!ret->url)
read_branches_file(ret);
}
if (!ret->url)
- add_url(ret, name);
+ add_url_alias(ret, name);
if (!ret->url)
return NULL;
- ret->fetch = parse_ref_spec(ret->fetch_refspec_nr, ret->fetch_refspec);
- ret->push = parse_ref_spec(ret->push_refspec_nr, ret->push_refspec);
+ ret->fetch = parse_fetch_refspec(ret->fetch_refspec_nr, ret->fetch_refspec);
+ ret->push = parse_push_refspec(ret->push_refspec_nr, ret->push_refspec);
return ret;
}
@@ -367,16 +631,16 @@ int for_each_remote(each_remote_fn fn, void *priv)
{
int i, result = 0;
read_config();
- for (i = 0; i < allocated_remotes && !result; i++) {
+ for (i = 0; i < remotes_nr && !result; i++) {
struct remote *r = remotes[i];
if (!r)
continue;
if (!r->fetch)
- r->fetch = parse_ref_spec(r->fetch_refspec_nr,
- r->fetch_refspec);
+ r->fetch = parse_fetch_refspec(r->fetch_refspec_nr,
+ r->fetch_refspec);
if (!r->push)
- r->push = parse_ref_spec(r->push_refspec_nr,
- r->push_refspec);
+ r->push = parse_push_refspec(r->push_refspec_nr,
+ r->push_refspec);
result = fn(r, priv);
}
return result;
@@ -468,6 +732,13 @@ struct ref *alloc_ref(unsigned namelen)
return ret;
}
+struct ref *alloc_ref_from_str(const char* str)
+{
+ struct ref *ret = alloc_ref(strlen(str) + 1);
+ strcpy(ret->name, str);
+ return ret;
+}
+
static struct ref *copy_ref(const struct ref *ref)
{
struct ref *ret = xmalloc(sizeof(struct ref) + strlen(ref->name) + 1);
@@ -488,14 +759,22 @@ struct ref *copy_ref_list(const struct ref *ref)
return ret;
}
+void free_ref(struct ref *ref)
+{
+ if (!ref)
+ return;
+ free(ref->remote_status);
+ free(ref->symref);
+ free(ref);
+}
+
void free_refs(struct ref *ref)
{
struct ref *next;
while (ref) {
next = ref->next;
- if (ref->peer_ref)
- free(ref->peer_ref);
- free(ref);
+ free(ref->peer_ref);
+ free_ref(ref);
ref = next;
}
}
@@ -566,7 +845,6 @@ static struct ref *try_explicit_object_name(const char *name)
{
unsigned char sha1[20];
struct ref *ref;
- int len;
if (!*name) {
ref = alloc_ref(20);
@@ -576,36 +854,49 @@ static struct ref *try_explicit_object_name(const char *name)
}
if (get_sha1(name, sha1))
return NULL;
- len = strlen(name) + 1;
- ref = alloc_ref(len);
- memcpy(ref->name, name, len);
+ ref = alloc_ref_from_str(name);
hashcpy(ref->new_sha1, sha1);
return ref;
}
static struct ref *make_linked_ref(const char *name, struct ref ***tail)
{
- struct ref *ret;
- size_t len;
-
- len = strlen(name) + 1;
- ret = alloc_ref(len);
- memcpy(ret->name, name, len);
+ struct ref *ret = alloc_ref_from_str(name);
tail_link_ref(ret, tail);
return ret;
}
+static char *guess_ref(const char *name, struct ref *peer)
+{
+ struct strbuf buf = STRBUF_INIT;
+ unsigned char sha1[20];
+
+ const char *r = resolve_ref(peer->name, sha1, 1, NULL);
+ if (!r)
+ return NULL;
+
+ if (!prefixcmp(r, "refs/heads/"))
+ strbuf_addstr(&buf, "refs/heads/");
+ else if (!prefixcmp(r, "refs/tags/"))
+ strbuf_addstr(&buf, "refs/tags/");
+ else
+ return NULL;
+
+ strbuf_addstr(&buf, name);
+ return strbuf_detach(&buf, NULL);
+}
+
static int match_explicit(struct ref *src, struct ref *dst,
struct ref ***dst_tail,
- struct refspec *rs,
- int errs)
+ struct refspec *rs)
{
struct ref *matched_src, *matched_dst;
const char *dst_value = rs->dst;
+ char *dst_guess;
- if (rs->pattern)
- return errs;
+ if (rs->pattern || rs->matching)
+ return 0;
matched_src = matched_dst = NULL;
switch (count_refspec_match(rs->src, src, &matched_src)) {
@@ -618,21 +909,22 @@ static int match_explicit(struct ref *src, struct ref *dst,
*/
matched_src = try_explicit_object_name(rs->src);
if (!matched_src)
- error("src refspec %s does not match any.", rs->src);
+ return error("src refspec %s does not match any.", rs->src);
break;
default:
- matched_src = NULL;
- error("src refspec %s matches more than one.", rs->src);
- break;
+ return error("src refspec %s matches more than one.", rs->src);
}
- if (!matched_src)
- errs = 1;
-
if (!dst_value) {
- if (!matched_src)
- return errs;
- dst_value = matched_src->name;
+ unsigned char sha1[20];
+ int flag;
+
+ dst_value = resolve_ref(matched_src->name, sha1, 1, &flag);
+ if (!dst_value ||
+ ((flag & REF_ISSYMREF) &&
+ prefixcmp(dst_value, "refs/heads/")))
+ die("%s cannot be resolved to branch.",
+ matched_src->name);
}
switch (count_refspec_match(dst_value, dst, &matched_dst)) {
@@ -641,10 +933,15 @@ static int match_explicit(struct ref *src, struct ref *dst,
case 0:
if (!memcmp(dst_value, "refs/", 5))
matched_dst = make_linked_ref(dst_value, dst_tail);
+ else if((dst_guess = guess_ref(dst_value, matched_src)))
+ matched_dst = make_linked_ref(dst_guess, dst_tail);
else
- error("dst refspec %s does not match any "
- "existing ref on the remote and does "
- "not start with refs/.", dst_value);
+ error("unable to push to unqualified destination: %s\n"
+ "The destination refspec neither matches an "
+ "existing ref on the remote nor\n"
+ "begins with refs/, and we are unable to "
+ "guess a prefix based on the source ref.",
+ dst_value);
break;
default:
matched_dst = NULL;
@@ -652,18 +949,16 @@ static int match_explicit(struct ref *src, struct ref *dst,
dst_value);
break;
}
- if (errs || !matched_dst)
- return 1;
- if (matched_dst->peer_ref) {
- errs = 1;
- error("dst ref %s receives from more than one src.",
+ if (!matched_dst)
+ return -1;
+ if (matched_dst->peer_ref)
+ return error("dst ref %s receives from more than one src.",
matched_dst->name);
- }
else {
matched_dst->peer_ref = matched_src;
matched_dst->force = rs->force;
}
- return errs;
+ return 0;
}
static int match_explicit_refs(struct ref *src, struct ref *dst,
@@ -672,8 +967,8 @@ static int match_explicit_refs(struct ref *src, struct ref *dst,
{
int i, errs;
for (i = errs = 0; i < rs_nr; i++)
- errs |= match_explicit(src, dst, dst_tail, &rs[i], errs);
- return -errs;
+ errs += match_explicit(src, dst, dst_tail, &rs[i]);
+ return errs;
}
static const struct refspec *check_pattern_match(const struct refspec *rs,
@@ -681,11 +976,21 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
const struct ref *src)
{
int i;
+ int matching_refs = -1;
for (i = 0; i < rs_nr; i++) {
+ if (rs[i].matching &&
+ (matching_refs == -1 || rs[i].force)) {
+ matching_refs = i;
+ continue;
+ }
+
if (rs[i].pattern && !prefixcmp(src->name, rs[i].src))
return rs + i;
}
- return NULL;
+ if (matching_refs != -1)
+ return rs + matching_refs;
+ else
+ return NULL;
}
/*
@@ -696,11 +1001,16 @@ static const struct refspec *check_pattern_match(const struct refspec *rs,
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
int nr_refspec, const char **refspec, int flags)
{
- struct refspec *rs =
- parse_ref_spec(nr_refspec, (const char **) refspec);
+ struct refspec *rs;
int send_all = flags & MATCH_REFS_ALL;
int send_mirror = flags & MATCH_REFS_MIRROR;
+ static const char *default_refspec[] = { ":", 0 };
+ if (!nr_refspec) {
+ nr_refspec = 1;
+ refspec = default_refspec;
+ }
+ rs = parse_push_refspec(nr_refspec, (const char **) refspec);
if (match_explicit_refs(src, dst, dst_tail, rs, nr_refspec))
return -1;
@@ -711,48 +1021,50 @@ int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
char *dst_name;
if (src->peer_ref)
continue;
- if (nr_refspec) {
- pat = check_pattern_match(rs, nr_refspec, src);
- if (!pat)
- continue;
- }
- else if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
+
+ pat = check_pattern_match(rs, nr_refspec, src);
+ if (!pat)
+ continue;
+
+ if (pat->matching) {
/*
* "matching refs"; traditionally we pushed everything
* including refs outside refs/heads/ hierarchy, but
* that does not make much sense these days.
*/
- continue;
+ if (!send_mirror && prefixcmp(src->name, "refs/heads/"))
+ continue;
+ dst_name = xstrdup(src->name);
- if (pat) {
+ } else {
const char *dst_side = pat->dst ? pat->dst : pat->src;
dst_name = xmalloc(strlen(dst_side) +
strlen(src->name) -
strlen(pat->src) + 2);
strcpy(dst_name, dst_side);
strcat(dst_name, src->name + strlen(pat->src));
- } else
- dst_name = xstrdup(src->name);
+ }
dst_peer = find_ref_by_name(dst, dst_name);
- if (dst_peer && dst_peer->peer_ref)
- /* We're already sending something to this ref. */
- goto free_name;
+ if (dst_peer) {
+ if (dst_peer->peer_ref)
+ /* We're already sending something to this ref. */
+ goto free_name;
+
+ } else {
+ if (pat->matching && !(send_all || send_mirror))
+ /*
+ * Remote doesn't have it, and we have no
+ * explicit pattern, and we don't have
+ * --all nor --mirror.
+ */
+ goto free_name;
- if (!dst_peer && !nr_refspec && !(send_all || send_mirror))
- /*
- * Remote doesn't have it, and we have no
- * explicit pattern, and we don't have
- * --all nor --mirror.
- */
- goto free_name;
- if (!dst_peer) {
/* Create a new one and link it */
dst_peer = make_linked_ref(dst_name, dst_tail);
hashcpy(dst_peer->new_sha1, src->new_sha1);
}
dst_peer->peer_ref = src;
- if (pat)
- dst_peer->force = pat->force;
+ dst_peer->force = pat->force;
free_name:
free(dst_name);
}
@@ -858,9 +1170,7 @@ static struct ref *get_local_ref(const char *name)
return NULL;
if (!prefixcmp(name, "refs/")) {
- ret = alloc_ref(strlen(name) + 1);
- strcpy(ret->name, name);
- return ret;
+ return alloc_ref_from_str(name);
}
if (!prefixcmp(name, "heads/") ||
@@ -881,7 +1191,7 @@ int get_fetch_map(const struct ref *remote_refs,
struct ref ***tail,
int missing_ok)
{
- struct ref *ref_map, *rm;
+ struct ref *ref_map, **rmp;
if (refspec->pattern) {
ref_map = get_expanded_map(remote_refs, refspec);
@@ -898,10 +1208,20 @@ int get_fetch_map(const struct ref *remote_refs,
}
}
- for (rm = ref_map; rm; rm = rm->next) {
- if (rm->peer_ref && check_ref_format(rm->peer_ref->name + 5))
- die("* refusing to create funny ref '%s' locally",
- rm->peer_ref->name);
+ for (rmp = &ref_map; *rmp; ) {
+ if ((*rmp)->peer_ref) {
+ int st = check_ref_format((*rmp)->peer_ref->name + 5);
+ if (st && st != CHECK_REF_FORMAT_ONELEVEL) {
+ struct ref *ignore = *rmp;
+ error("* Ignoring funny ref '%s' locally",
+ (*rmp)->peer_ref->name);
+ *rmp = (*rmp)->next;
+ free(ignore->peer_ref);
+ free(ignore);
+ continue;
+ }
+ }
+ rmp = &((*rmp)->next);
}
if (ref_map)
@@ -909,3 +1229,123 @@ int get_fetch_map(const struct ref *remote_refs,
return 0;
}
+
+int resolve_remote_symref(struct ref *ref, struct ref *list)
+{
+ if (!ref->symref)
+ return 0;
+ for (; list; list = list->next)
+ if (!strcmp(ref->symref, list->name)) {
+ hashcpy(ref->old_sha1, list->old_sha1);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Return true if there is anything to report, otherwise false.
+ */
+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
+{
+ unsigned char sha1[20];
+ struct commit *ours, *theirs;
+ char symmetric[84];
+ struct rev_info revs;
+ const char *rev_argv[10], *base;
+ int rev_argc;
+
+ /*
+ * Nothing to report unless we are marked to build on top of
+ * somebody else.
+ */
+ if (!branch ||
+ !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
+ return 0;
+
+ /*
+ * If what we used to build on no longer exists, there is
+ * nothing to report.
+ */
+ base = branch->merge[0]->dst;
+ if (!resolve_ref(base, sha1, 1, NULL))
+ return 0;
+ theirs = lookup_commit(sha1);
+ if (!theirs)
+ return 0;
+
+ if (!resolve_ref(branch->refname, sha1, 1, NULL))
+ return 0;
+ ours = lookup_commit(sha1);
+ if (!ours)
+ return 0;
+
+ /* are we the same? */
+ if (theirs == ours)
+ return 0;
+
+ /* Run "rev-list --left-right ours...theirs" internally... */
+ rev_argc = 0;
+ rev_argv[rev_argc++] = NULL;
+ rev_argv[rev_argc++] = "--left-right";
+ rev_argv[rev_argc++] = symmetric;
+ rev_argv[rev_argc++] = "--";
+ rev_argv[rev_argc] = NULL;
+
+ strcpy(symmetric, sha1_to_hex(ours->object.sha1));
+ strcpy(symmetric + 40, "...");
+ strcpy(symmetric + 43, sha1_to_hex(theirs->object.sha1));
+
+ init_revisions(&revs, NULL);
+ setup_revisions(rev_argc, rev_argv, &revs, NULL);
+ prepare_revision_walk(&revs);
+
+ /* ... and count the commits on each side. */
+ *num_ours = 0;
+ *num_theirs = 0;
+ while (1) {
+ struct commit *c = get_revision(&revs);
+ if (!c)
+ break;
+ if (c->object.flags & SYMMETRIC_LEFT)
+ (*num_ours)++;
+ else
+ (*num_theirs)++;
+ }
+
+ /* clear object flags smudged by the above traversal */
+ clear_commit_marks(ours, ALL_REV_FLAGS);
+ clear_commit_marks(theirs, ALL_REV_FLAGS);
+ return 1;
+}
+
+/*
+ * Return true when there is anything to report, otherwise false.
+ */
+int format_tracking_info(struct branch *branch, struct strbuf *sb)
+{
+ int num_ours, num_theirs;
+ const char *base;
+
+ if (!stat_tracking_info(branch, &num_ours, &num_theirs))
+ return 0;
+
+ base = branch->merge[0]->dst;
+ if (!prefixcmp(base, "refs/remotes/")) {
+ base += strlen("refs/remotes/");
+ }
+ if (!num_theirs)
+ strbuf_addf(sb, "Your branch is ahead of '%s' "
+ "by %d commit%s.\n",
+ base, num_ours, (num_ours == 1) ? "" : "s");
+ else if (!num_ours)
+ strbuf_addf(sb, "Your branch is behind '%s' "
+ "by %d commit%s, "
+ "and can be fast-forwarded.\n",
+ base, num_theirs, (num_theirs == 1) ? "" : "s");
+ else
+ strbuf_addf(sb, "Your branch and '%s' have diverged,\n"
+ "and have %d and %d different commit(s) each, "
+ "respectively.\n",
+ base, num_ours, num_theirs);
+ return 1;
+}
diff --git a/remote.h b/remote.h
index 86e036d61..091b1d041 100644
--- a/remote.h
+++ b/remote.h
@@ -6,14 +6,17 @@ struct remote {
const char **url;
int url_nr;
+ int url_alloc;
const char **push_refspec;
struct refspec *push;
int push_refspec_nr;
+ int push_refspec_alloc;
const char **fetch_refspec;
struct refspec *fetch;
int fetch_refspec_nr;
+ int fetch_refspec_alloc;
/*
* -1 to never fetch tags
@@ -22,6 +25,8 @@ struct remote {
* 2 to always fetch tags
*/
int fetch_tags;
+ int skip_default_update;
+ int mirror;
const char *receivepack;
const char *uploadpack;
@@ -42,13 +47,18 @@ int remote_has_url(struct remote *remote, const char *url);
struct refspec {
unsigned force : 1;
unsigned pattern : 1;
+ unsigned matching : 1;
char *src;
char *dst;
};
+extern const struct refspec *tag_refspec;
+
struct ref *alloc_ref(unsigned namelen);
+struct ref *alloc_ref_from_str(const char* str);
+
struct ref *copy_ref_list(const struct ref *ref);
int check_ref_type(const struct ref *ref, int flags);
@@ -58,12 +68,16 @@ int check_ref_type(const struct ref *ref, int flags);
*/
void free_refs(struct ref *ref);
+int resolve_remote_symref(struct ref *ref, struct ref *list);
+
/*
* Removes and frees any duplicate refs in the map.
*/
void ref_remove_duplicates(struct ref *ref_map);
-struct refspec *parse_ref_spec(int nr_refspec, const char **refspec);
+int valid_fetch_refspec(const char *refspec);
+struct refspec *parse_fetch_refspec(int nr_refspec, const char **refspec);
+struct refspec *parse_push_refspec(int nr_refspec, const char **refspec);
int match_refs(struct ref *src, struct ref *dst, struct ref ***dst_tail,
int nr_refspec, const char **refspec, int all);
@@ -100,6 +114,7 @@ struct branch {
const char **merge_name;
struct refspec **merge;
int merge_nr;
+ int merge_alloc;
};
struct branch *branch_get(const char *name);
@@ -114,4 +129,8 @@ enum match_refs_flags {
MATCH_REFS_MIRROR = (1 << 1),
};
+/* Reporting of tracking info */
+int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs);
+int format_tracking_info(struct branch *branch, struct strbuf *sb);
+
#endif
diff --git a/rerere.c b/rerere.c
new file mode 100644
index 000000000..323e493da
--- /dev/null
+++ b/rerere.c
@@ -0,0 +1,363 @@
+#include "cache.h"
+#include "string-list.h"
+#include "rerere.h"
+#include "xdiff/xdiff.h"
+#include "xdiff-interface.h"
+
+/* if rerere_enabled == -1, fall back to detection of .git/rr-cache */
+static int rerere_enabled = -1;
+
+/* automatically update cleanly resolved paths to the index */
+static int rerere_autoupdate;
+
+static char *merge_rr_path;
+
+static const char *rr_path(const char *name, const char *file)
+{
+ return git_path("rr-cache/%s/%s", name, file);
+}
+
+static int has_resolution(const char *name)
+{
+ struct stat st;
+ return !stat(rr_path(name, "postimage"), &st);
+}
+
+static void read_rr(struct string_list *rr)
+{
+ unsigned char sha1[20];
+ char buf[PATH_MAX];
+ FILE *in = fopen(merge_rr_path, "r");
+ if (!in)
+ return;
+ while (fread(buf, 40, 1, in) == 1) {
+ int i;
+ char *name;
+ if (get_sha1_hex(buf, sha1))
+ die("corrupt MERGE_RR");
+ buf[40] = '\0';
+ name = xstrdup(buf);
+ if (fgetc(in) != '\t')
+ die("corrupt MERGE_RR");
+ for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++)
+ ; /* do nothing */
+ if (i == sizeof(buf))
+ die("filename too long");
+ string_list_insert(buf, rr)->util = name;
+ }
+ fclose(in);
+}
+
+static struct lock_file write_lock;
+
+static int write_rr(struct string_list *rr, int out_fd)
+{
+ int i;
+ for (i = 0; i < rr->nr; i++) {
+ const char *path;
+ int length;
+ if (!rr->items[i].util)
+ continue;
+ path = rr->items[i].string;
+ length = strlen(path) + 1;
+ if (write_in_full(out_fd, rr->items[i].util, 40) != 40 ||
+ write_in_full(out_fd, "\t", 1) != 1 ||
+ write_in_full(out_fd, path, length) != length)
+ die("unable to write rerere record");
+ }
+ if (commit_lock_file(&write_lock) != 0)
+ die("unable to write rerere record");
+ return 0;
+}
+
+static int handle_file(const char *path,
+ unsigned char *sha1, const char *output)
+{
+ SHA_CTX ctx;
+ char buf[1024];
+ int hunk = 0, hunk_no = 0;
+ struct strbuf one, two;
+ FILE *f = fopen(path, "r");
+ FILE *out = NULL;
+
+ if (!f)
+ return error("Could not open %s", path);
+
+ if (output) {
+ out = fopen(output, "w");
+ if (!out) {
+ fclose(f);
+ return error("Could not write %s", output);
+ }
+ }
+
+ if (sha1)
+ SHA1_Init(&ctx);
+
+ strbuf_init(&one, 0);
+ strbuf_init(&two, 0);
+ while (fgets(buf, sizeof(buf), f)) {
+ if (!prefixcmp(buf, "<<<<<<< ")) {
+ if (hunk)
+ goto bad;
+ hunk = 1;
+ } else if (!prefixcmp(buf, "=======") && isspace(buf[7])) {
+ if (hunk != 1)
+ goto bad;
+ hunk = 2;
+ } else if (!prefixcmp(buf, ">>>>>>> ")) {
+ if (hunk != 2)
+ goto bad;
+ if (strbuf_cmp(&one, &two) > 0)
+ strbuf_swap(&one, &two);
+ hunk_no++;
+ hunk = 0;
+ if (out) {
+ fputs("<<<<<<<\n", out);
+ fwrite(one.buf, one.len, 1, out);
+ fputs("=======\n", out);
+ fwrite(two.buf, two.len, 1, out);
+ fputs(">>>>>>>\n", out);
+ }
+ if (sha1) {
+ SHA1_Update(&ctx, one.buf ? one.buf : "",
+ one.len + 1);
+ SHA1_Update(&ctx, two.buf ? two.buf : "",
+ two.len + 1);
+ }
+ strbuf_reset(&one);
+ strbuf_reset(&two);
+ } else if (hunk == 1)
+ strbuf_addstr(&one, buf);
+ else if (hunk == 2)
+ strbuf_addstr(&two, buf);
+ else if (out)
+ fputs(buf, out);
+ continue;
+ bad:
+ hunk = 99; /* force error exit */
+ break;
+ }
+ strbuf_release(&one);
+ strbuf_release(&two);
+
+ fclose(f);
+ if (out)
+ fclose(out);
+ if (sha1)
+ SHA1_Final(sha1, &ctx);
+ if (hunk) {
+ if (output)
+ unlink(output);
+ return error("Could not parse conflict hunks in %s", path);
+ }
+ return hunk_no;
+}
+
+static int find_conflict(struct string_list *conflict)
+{
+ int i;
+ if (read_cache() < 0)
+ return error("Could not read index");
+ for (i = 0; i+1 < active_nr; i++) {
+ struct cache_entry *e2 = active_cache[i];
+ struct cache_entry *e3 = active_cache[i+1];
+ if (ce_stage(e2) == 2 &&
+ ce_stage(e3) == 3 &&
+ ce_same_name(e2, e3) &&
+ S_ISREG(e2->ce_mode) &&
+ S_ISREG(e3->ce_mode)) {
+ string_list_insert((const char *)e2->name, conflict);
+ i++; /* skip over both #2 and #3 */
+ }
+ }
+ return 0;
+}
+
+static int merge(const char *name, const char *path)
+{
+ int ret;
+ mmfile_t cur, base, other;
+ mmbuffer_t result = {NULL, 0};
+ xpparam_t xpp = {XDF_NEED_MINIMAL};
+
+ if (handle_file(path, NULL, rr_path(name, "thisimage")) < 0)
+ return 1;
+
+ if (read_mmfile(&cur, rr_path(name, "thisimage")) ||
+ read_mmfile(&base, rr_path(name, "preimage")) ||
+ read_mmfile(&other, rr_path(name, "postimage")))
+ return 1;
+ ret = xdl_merge(&base, &cur, "", &other, "",
+ &xpp, XDL_MERGE_ZEALOUS, &result);
+ if (!ret) {
+ FILE *f = fopen(path, "w");
+ if (!f)
+ return error("Could not write to %s", path);
+ fwrite(result.ptr, result.size, 1, f);
+ fclose(f);
+ }
+
+ free(cur.ptr);
+ free(base.ptr);
+ free(other.ptr);
+ free(result.ptr);
+
+ return ret;
+}
+
+static struct lock_file index_lock;
+
+static int update_paths(struct string_list *update)
+{
+ int i;
+ int fd = hold_locked_index(&index_lock, 0);
+ int status = 0;
+
+ if (fd < 0)
+ return -1;
+
+ for (i = 0; i < update->nr; i++) {
+ struct string_list_item *item = &update->items[i];
+ if (add_file_to_cache(item->string, ADD_CACHE_IGNORE_ERRORS))
+ status = -1;
+ }
+
+ if (!status && active_cache_changed) {
+ if (write_cache(fd, active_cache, active_nr) ||
+ commit_locked_index(&index_lock))
+ die("Unable to write new index file");
+ } else if (fd >= 0)
+ rollback_lock_file(&index_lock);
+ return status;
+}
+
+static int do_plain_rerere(struct string_list *rr, int fd)
+{
+ struct string_list conflict = { NULL, 0, 0, 1 };
+ struct string_list update = { NULL, 0, 0, 1 };
+ int i;
+
+ find_conflict(&conflict);
+
+ /*
+ * MERGE_RR records paths with conflicts immediately after merge
+ * failed. Some of the conflicted paths might have been hand resolved
+ * in the working tree since then, but the initial run would catch all
+ * and register their preimages.
+ */
+
+ for (i = 0; i < conflict.nr; i++) {
+ const char *path = conflict.items[i].string;
+ if (!string_list_has_string(rr, path)) {
+ unsigned char sha1[20];
+ char *hex;
+ int ret;
+ ret = handle_file(path, sha1, NULL);
+ if (ret < 1)
+ continue;
+ hex = xstrdup(sha1_to_hex(sha1));
+ string_list_insert(path, rr)->util = hex;
+ if (mkdir(git_path("rr-cache/%s", hex), 0755))
+ continue;;
+ handle_file(path, NULL, rr_path(hex, "preimage"));
+ fprintf(stderr, "Recorded preimage for '%s'\n", path);
+ }
+ }
+
+ /*
+ * Now some of the paths that had conflicts earlier might have been
+ * hand resolved. Others may be similar to a conflict already that
+ * was resolved before.
+ */
+
+ for (i = 0; i < rr->nr; i++) {
+ int ret;
+ const char *path = rr->items[i].string;
+ const char *name = (const char *)rr->items[i].util;
+
+ if (has_resolution(name)) {
+ if (!merge(name, path)) {
+ if (rerere_autoupdate)
+ string_list_insert(path, &update);
+ fprintf(stderr,
+ "%s '%s' using previous resolution.\n",
+ rerere_autoupdate
+ ? "Staged" : "Resolved",
+ path);
+ goto mark_resolved;
+ }
+ }
+
+ /* Let's see if we have resolved it. */
+ ret = handle_file(path, NULL, NULL);
+ if (ret)
+ continue;
+
+ fprintf(stderr, "Recorded resolution for '%s'.\n", path);
+ copy_file(rr_path(name, "postimage"), path, 0666);
+ mark_resolved:
+ rr->items[i].util = NULL;
+ }
+
+ if (update.nr)
+ update_paths(&update);
+
+ return write_rr(rr, fd);
+}
+
+static int git_rerere_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "rerere.enabled"))
+ rerere_enabled = git_config_bool(var, value);
+ else if (!strcmp(var, "rerere.autoupdate"))
+ rerere_autoupdate = git_config_bool(var, value);
+ else
+ return git_default_config(var, value, cb);
+ return 0;
+}
+
+static int is_rerere_enabled(void)
+{
+ struct stat st;
+ const char *rr_cache;
+ int rr_cache_exists;
+
+ if (!rerere_enabled)
+ return 0;
+
+ rr_cache = git_path("rr-cache");
+ rr_cache_exists = !stat(rr_cache, &st) && S_ISDIR(st.st_mode);
+ if (rerere_enabled < 0)
+ return rr_cache_exists;
+
+ if (!rr_cache_exists &&
+ (mkdir(rr_cache, 0777) || adjust_shared_perm(rr_cache)))
+ die("Could not create directory %s", rr_cache);
+ return 1;
+}
+
+int setup_rerere(struct string_list *merge_rr)
+{
+ int fd;
+
+ git_config(git_rerere_config, NULL);
+ if (!is_rerere_enabled())
+ return -1;
+
+ merge_rr_path = xstrdup(git_path("MERGE_RR"));
+ fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
+ read_rr(merge_rr);
+ return fd;
+}
+
+int rerere(void)
+{
+ struct string_list merge_rr = { NULL, 0, 0, 1 };
+ int fd;
+
+ fd = setup_rerere(&merge_rr);
+ if (fd < 0)
+ return 0;
+ return do_plain_rerere(&merge_rr, fd);
+}
diff --git a/rerere.h b/rerere.h
new file mode 100644
index 000000000..f9b03862f
--- /dev/null
+++ b/rerere.h
@@ -0,0 +1,9 @@
+#ifndef RERERE_H
+#define RERERE_H
+
+#include "string-list.h"
+
+extern int setup_rerere(struct string_list *);
+extern int rerere(void);
+
+#endif
diff --git a/revision.c b/revision.c
index 6e85aaa3f..e75079a6e 100644
--- a/revision.c
+++ b/revision.c
@@ -6,9 +6,11 @@
#include "diff.h"
#include "refs.h"
#include "revision.h"
+#include "graph.h"
#include "grep.h"
#include "reflog-walk.h"
#include "patch-ids.h"
+#include "decorate.h"
volatile show_early_output_fn_t show_early_output;
@@ -46,6 +48,8 @@ void add_object(struct object *obj,
static void mark_blob_uninteresting(struct blob *blob)
{
+ if (!blob)
+ return;
if (blob->object.flags & UNINTERESTING)
return;
blob->object.flags |= UNINTERESTING;
@@ -57,6 +61,8 @@ void mark_tree_uninteresting(struct tree *tree)
struct name_entry entry;
struct object *obj = &tree->object;
+ if (!tree)
+ return;
if (obj->flags & UNINTERESTING)
return;
obj->flags |= UNINTERESTING;
@@ -173,6 +179,8 @@ static struct commit *handle_commit(struct rev_info *revs, struct object *object
struct tag *tag = (struct tag *) object;
if (revs->tag_objects && !(flags & UNINTERESTING))
add_pending_object(revs, object, tag->tag);
+ if (!tag->tagged)
+ die("bad tag");
object = parse_object(tag->tagged->sha1);
if (!object)
die("bad object %s", sha1_to_hex(tag->tagged->sha1));
@@ -252,7 +260,7 @@ static int tree_difference = REV_TREE_SAME;
static void file_add_remove(struct diff_options *options,
int addremove, unsigned mode,
const unsigned char *sha1,
- const char *base, const char *path)
+ const char *fullpath)
{
int diff = REV_TREE_DIFFERENT;
@@ -278,7 +286,7 @@ static void file_change(struct diff_options *options,
unsigned old_mode, unsigned new_mode,
const unsigned char *old_sha1,
const unsigned char *new_sha1,
- const char *base, const char *path)
+ const char *fullpath)
{
tree_difference = REV_TREE_DIFFERENT;
DIFF_OPT_SET(options, HAS_CHANGES);
@@ -405,11 +413,26 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
commit->object.flags |= TREESAME;
}
-static int add_parents_to_list(struct rev_info *revs, struct commit *commit, struct commit_list **list)
+static void insert_by_date_cached(struct commit *p, struct commit_list **head,
+ struct commit_list *cached_base, struct commit_list **cache)
+{
+ struct commit_list *new_entry;
+
+ if (cached_base && p->date < cached_base->item->date)
+ new_entry = insert_by_date(p, &cached_base->next);
+ else
+ new_entry = insert_by_date(p, head);
+
+ if (cache && (!*cache || p->date < (*cache)->item->date))
+ *cache = new_entry;
+}
+
+static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
+ struct commit_list **list, struct commit_list **cache_ptr)
{
struct commit_list *parent = commit->parents;
unsigned left_flag;
- int add, rest;
+ struct commit_list *cached_base = cache_ptr ? *cache_ptr : NULL;
if (commit->object.flags & ADDED)
return 0;
@@ -439,7 +462,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str
if (p->object.flags & SEEN)
continue;
p->object.flags |= SEEN;
- insert_by_date(p, list);
+ insert_by_date_cached(p, list, cached_base, cache_ptr);
}
return 0;
}
@@ -456,19 +479,18 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str
left_flag = (commit->object.flags & SYMMETRIC_LEFT);
- rest = !revs->first_parent_only;
- for (parent = commit->parents, add = 1; parent; add = rest) {
+ for (parent = commit->parents; parent; parent = parent->next) {
struct commit *p = parent->item;
- parent = parent->next;
if (parse_commit(p) < 0)
return -1;
p->object.flags |= left_flag;
- if (p->object.flags & SEEN)
- continue;
- p->object.flags |= SEEN;
- if (add)
- insert_by_date(p, list);
+ if (!(p->object.flags & SEEN)) {
+ p->object.flags |= SEEN;
+ insert_by_date_cached(p, list, cached_base, cache_ptr);
+ }
+ if(revs->first_parent_only)
+ break;
}
return 0;
}
@@ -558,8 +580,39 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
free_patch_ids(&ids);
}
+/* How many extra uninteresting commits we want to see.. */
+#define SLOP 5
+
+static int still_interesting(struct commit_list *src, unsigned long date, int slop)
+{
+ /*
+ * No source list at all? We're definitely done..
+ */
+ if (!src)
+ return 0;
+
+ /*
+ * Does the destination list contain entries with a date
+ * before the source list? Definitely _not_ done.
+ */
+ if (date < src->item->date)
+ return SLOP;
+
+ /*
+ * Does the source list still have interesting commits in
+ * it? Definitely not done..
+ */
+ if (!everybody_uninteresting(src))
+ return SLOP;
+
+ /* Ok, we're closing in.. */
+ return slop-1;
+}
+
static int limit_list(struct rev_info *revs)
{
+ int slop = SLOP;
+ unsigned long date = ~0ul;
struct commit_list *list = revs->commits;
struct commit_list *newlist = NULL;
struct commit_list **p = &newlist;
@@ -575,16 +628,23 @@ static int limit_list(struct rev_info *revs)
if (revs->max_age != -1 && (commit->date < revs->max_age))
obj->flags |= UNINTERESTING;
- if (add_parents_to_list(revs, commit, &list) < 0)
+ if (add_parents_to_list(revs, commit, &list, NULL) < 0)
return -1;
if (obj->flags & UNINTERESTING) {
mark_parents_uninteresting(commit);
- if (everybody_uninteresting(list))
- break;
- continue;
+ if (revs->show_all)
+ p = &commit_list_insert(commit, p)->next;
+ slop = still_interesting(list, date, slop);
+ if (slop)
+ continue;
+ /* If showing all, add the whole pending list to the end */
+ if (revs->show_all)
+ *p = list;
+ break;
}
if (revs->min_age != -1 && (commit->date > revs->min_age))
continue;
+ date = commit->date;
p = &commit_list_insert(commit, p)->next;
show = show_early_output;
@@ -617,12 +677,13 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
return 0;
}
-static void handle_all(struct rev_info *revs, unsigned flags)
+static void handle_refs(struct rev_info *revs, unsigned flags,
+ int (*for_each)(each_ref_fn, void *))
{
struct all_refs_cb cb;
cb.all_revs = revs;
cb.all_flags = flags;
- for_each_ref(handle_one_ref, &cb);
+ for_each(handle_one_ref, &cb);
}
static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
@@ -685,6 +746,8 @@ static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
it = get_reference(revs, arg, sha1, 0);
if (it->type != OBJ_TAG)
break;
+ if (!((struct tag*)it)->tagged)
+ return 0;
hashcpy(sha1, ((struct tag*)it)->tagged->sha1);
}
if (it->type != OBJ_COMMIT)
@@ -720,6 +783,10 @@ void init_revisions(struct rev_info *revs, const char *prefix)
revs->commit_format = CMIT_FMT_DEFAULT;
diff_setup(&revs->diffopt);
+ if (prefix && !revs->diffopt.prefix) {
+ revs->diffopt.prefix = prefix;
+ revs->diffopt.prefix_length = strlen(prefix);
+ }
}
static void add_pending_commit_list(struct rev_info *revs,
@@ -749,14 +816,9 @@ static void prepare_show_merge(struct rev_info *revs)
add_pending_object(revs, &head->object, "HEAD");
add_pending_object(revs, &other->object, "MERGE_HEAD");
bases = get_merge_bases(head, other, 1);
- while (bases) {
- struct commit *it = bases->item;
- struct commit_list *n = bases->next;
- free(bases);
- bases = n;
- it->object.flags |= UNINTERESTING;
- add_pending_object(revs, &it->object, "(merge-base)");
- }
+ add_pending_commit_list(revs, bases, UNINTERESTING);
+ free_commit_list(bases);
+ head->object.flags |= SYMMETRIC_LEFT;
if (!active_nr)
read_cache();
@@ -775,6 +837,7 @@ static void prepare_show_merge(struct rev_info *revs)
i++;
}
revs->prune_data = prune;
+ revs->limited = 1;
}
int handle_revision_arg(const char *arg, struct rev_info *revs,
@@ -864,6 +927,23 @@ int handle_revision_arg(const char *arg, struct rev_info *revs,
return 0;
}
+void read_revisions_from_stdin(struct rev_info *revs)
+{
+ char line[1000];
+
+ while (fgets(line, sizeof(line), stdin) != NULL) {
+ int len = strlen(line);
+ if (len && line[len - 1] == '\n')
+ line[--len] = '\0';
+ if (!len)
+ break;
+ if (line[0] == '-')
+ die("options not supported in --stdin mode");
+ if (handle_revision_arg(line, revs, 0, 1))
+ die("bad revision '%s'", line);
+ }
+}
+
static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
{
if (!revs->grep_filter) {
@@ -910,6 +990,226 @@ static void add_ignore_packed(struct rev_info *revs, const char *name)
revs->ignore_packed[num] = NULL;
}
+static int handle_revision_opt(struct rev_info *revs, int argc, const char **argv,
+ int *unkc, const char **unkv)
+{
+ const char *arg = argv[0];
+
+ /* pseudo revision arguments */
+ if (!strcmp(arg, "--all") || !strcmp(arg, "--branches") ||
+ !strcmp(arg, "--tags") || !strcmp(arg, "--remotes") ||
+ !strcmp(arg, "--reflog") || !strcmp(arg, "--not") ||
+ !strcmp(arg, "--no-walk") || !strcmp(arg, "--do-walk"))
+ {
+ unkv[(*unkc)++] = arg;
+ return 1;
+ }
+
+ if (!prefixcmp(arg, "--max-count=")) {
+ revs->max_count = atoi(arg + 12);
+ } else if (!prefixcmp(arg, "--skip=")) {
+ revs->skip_count = atoi(arg + 7);
+ } else if ((*arg == '-') && isdigit(arg[1])) {
+ /* accept -<digit>, like traditional "head" */
+ revs->max_count = atoi(arg + 1);
+ } else if (!strcmp(arg, "-n")) {
+ if (argc <= 1)
+ return error("-n requires an argument");
+ revs->max_count = atoi(argv[1]);
+ return 2;
+ } else if (!prefixcmp(arg, "-n")) {
+ revs->max_count = atoi(arg + 2);
+ } else if (!prefixcmp(arg, "--max-age=")) {
+ revs->max_age = atoi(arg + 10);
+ } else if (!prefixcmp(arg, "--since=")) {
+ revs->max_age = approxidate(arg + 8);
+ } else if (!prefixcmp(arg, "--after=")) {
+ revs->max_age = approxidate(arg + 8);
+ } else if (!prefixcmp(arg, "--min-age=")) {
+ revs->min_age = atoi(arg + 10);
+ } else if (!prefixcmp(arg, "--before=")) {
+ revs->min_age = approxidate(arg + 9);
+ } else if (!prefixcmp(arg, "--until=")) {
+ revs->min_age = approxidate(arg + 8);
+ } else if (!strcmp(arg, "--first-parent")) {
+ revs->first_parent_only = 1;
+ } else if (!strcmp(arg, "-g") || !strcmp(arg, "--walk-reflogs")) {
+ init_reflog_walk(&revs->reflog_info);
+ } else if (!strcmp(arg, "--default")) {
+ if (argc <= 1)
+ return error("bad --default argument");
+ revs->def = argv[1];
+ return 2;
+ } else if (!strcmp(arg, "--merge")) {
+ revs->show_merge = 1;
+ } else if (!strcmp(arg, "--topo-order")) {
+ revs->lifo = 1;
+ revs->topo_order = 1;
+ } else if (!strcmp(arg, "--date-order")) {
+ revs->lifo = 0;
+ revs->topo_order = 1;
+ } else if (!prefixcmp(arg, "--early-output")) {
+ int count = 100;
+ switch (arg[14]) {
+ case '=':
+ count = atoi(arg+15);
+ /* Fallthrough */
+ case 0:
+ revs->topo_order = 1;
+ revs->early_output = count;
+ }
+ } else if (!strcmp(arg, "--parents")) {
+ revs->rewrite_parents = 1;
+ revs->print_parents = 1;
+ } else if (!strcmp(arg, "--dense")) {
+ revs->dense = 1;
+ } else if (!strcmp(arg, "--sparse")) {
+ revs->dense = 0;
+ } else if (!strcmp(arg, "--show-all")) {
+ revs->show_all = 1;
+ } else if (!strcmp(arg, "--remove-empty")) {
+ revs->remove_empty_trees = 1;
+ } else if (!strcmp(arg, "--no-merges")) {
+ revs->no_merges = 1;
+ } else if (!strcmp(arg, "--boundary")) {
+ revs->boundary = 1;
+ } else if (!strcmp(arg, "--left-right")) {
+ revs->left_right = 1;
+ } else if (!strcmp(arg, "--cherry-pick")) {
+ revs->cherry_pick = 1;
+ revs->limited = 1;
+ } else if (!strcmp(arg, "--objects")) {
+ revs->tag_objects = 1;
+ revs->tree_objects = 1;
+ revs->blob_objects = 1;
+ } else if (!strcmp(arg, "--objects-edge")) {
+ revs->tag_objects = 1;
+ revs->tree_objects = 1;
+ revs->blob_objects = 1;
+ revs->edge_hint = 1;
+ } else if (!strcmp(arg, "--unpacked")) {
+ revs->unpacked = 1;
+ free(revs->ignore_packed);
+ revs->ignore_packed = NULL;
+ revs->num_ignore_packed = 0;
+ } else if (!prefixcmp(arg, "--unpacked=")) {
+ revs->unpacked = 1;
+ add_ignore_packed(revs, arg+11);
+ } else if (!strcmp(arg, "-r")) {
+ revs->diff = 1;
+ DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
+ } else if (!strcmp(arg, "-t")) {
+ revs->diff = 1;
+ DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
+ DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
+ } else if (!strcmp(arg, "-m")) {
+ revs->ignore_merges = 0;
+ } else if (!strcmp(arg, "-c")) {
+ revs->diff = 1;
+ revs->dense_combined_merges = 0;
+ revs->combine_merges = 1;
+ } else if (!strcmp(arg, "--cc")) {
+ revs->diff = 1;
+ revs->dense_combined_merges = 1;
+ revs->combine_merges = 1;
+ } else if (!strcmp(arg, "-v")) {
+ revs->verbose_header = 1;
+ } else if (!strcmp(arg, "--pretty")) {
+ revs->verbose_header = 1;
+ get_commit_format(arg+8, revs);
+ } else if (!prefixcmp(arg, "--pretty=")) {
+ revs->verbose_header = 1;
+ get_commit_format(arg+9, revs);
+ } else if (!strcmp(arg, "--graph")) {
+ revs->topo_order = 1;
+ revs->rewrite_parents = 1;
+ revs->graph = graph_init(revs);
+ } else if (!strcmp(arg, "--root")) {
+ revs->show_root_diff = 1;
+ } else if (!strcmp(arg, "--no-commit-id")) {
+ revs->no_commit_id = 1;
+ } else if (!strcmp(arg, "--always")) {
+ revs->always_show_header = 1;
+ } else if (!strcmp(arg, "--no-abbrev")) {
+ revs->abbrev = 0;
+ } else if (!strcmp(arg, "--abbrev")) {
+ revs->abbrev = DEFAULT_ABBREV;
+ } else if (!prefixcmp(arg, "--abbrev=")) {
+ revs->abbrev = strtoul(arg + 9, NULL, 10);
+ if (revs->abbrev < MINIMUM_ABBREV)
+ revs->abbrev = MINIMUM_ABBREV;
+ else if (revs->abbrev > 40)
+ revs->abbrev = 40;
+ } else if (!strcmp(arg, "--abbrev-commit")) {
+ revs->abbrev_commit = 1;
+ } else if (!strcmp(arg, "--full-diff")) {
+ revs->diff = 1;
+ revs->full_diff = 1;
+ } else if (!strcmp(arg, "--full-history")) {
+ revs->simplify_history = 0;
+ } else if (!strcmp(arg, "--relative-date")) {
+ revs->date_mode = DATE_RELATIVE;
+ } else if (!strncmp(arg, "--date=", 7)) {
+ revs->date_mode = parse_date_format(arg + 7);
+ } else if (!strcmp(arg, "--log-size")) {
+ revs->show_log_size = 1;
+ }
+ /*
+ * Grepping the commit log
+ */
+ else if (!prefixcmp(arg, "--author=")) {
+ add_header_grep(revs, "author", arg+9);
+ } else if (!prefixcmp(arg, "--committer=")) {
+ add_header_grep(revs, "committer", arg+12);
+ } else if (!prefixcmp(arg, "--grep=")) {
+ add_message_grep(revs, arg+7);
+ } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
+ if (revs->grep_filter)
+ revs->grep_filter->regflags |= REG_EXTENDED;
+ } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
+ if (revs->grep_filter)
+ revs->grep_filter->regflags |= REG_ICASE;
+ } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
+ if (revs->grep_filter)
+ revs->grep_filter->fixed = 1;
+ } else if (!strcmp(arg, "--all-match")) {
+ if (revs->grep_filter)
+ revs->grep_filter->all_match = 1;
+ } else if (!prefixcmp(arg, "--encoding=")) {
+ arg += 11;
+ if (strcmp(arg, "none"))
+ git_log_output_encoding = xstrdup(arg);
+ else
+ git_log_output_encoding = "";
+ } else if (!strcmp(arg, "--reverse")) {
+ revs->reverse ^= 1;
+ } else if (!strcmp(arg, "--children")) {
+ revs->children.name = "children";
+ revs->limited = 1;
+ } else {
+ int opts = diff_opt_parse(&revs->diffopt, argv, argc);
+ if (!opts)
+ unkv[(*unkc)++] = arg;
+ return opts;
+ }
+
+ return 1;
+}
+
+void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[])
+{
+ int n = handle_revision_opt(revs, ctx->argc, ctx->argv,
+ &ctx->cpidx, ctx->out);
+ if (n <= 0) {
+ error("unknown option `%s'", ctx->argv[0]);
+ usage_with_options(usagestr, options);
+ }
+ ctx->argv += n;
+ ctx->argc -= n;
+}
+
/*
* Parse revision information, filling in the "rev_info" structure,
* and removing the used arguments from the argument list.
@@ -919,11 +1219,7 @@ static void add_ignore_packed(struct rev_info *revs, const char *name)
*/
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def)
{
- int i, flags, seen_dashdash, show_merge;
- const char **unrecognized = argv + 1;
- int left = 1;
- int all_match = 0;
- int regflags = 0;
+ int i, flags, left, seen_dashdash;
/* First, search for "--" */
seen_dashdash = 0;
@@ -939,299 +1235,37 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
break;
}
- flags = show_merge = 0;
- for (i = 1; i < argc; i++) {
+ /* Second, deal with arguments and options */
+ flags = 0;
+ for (left = i = 1; i < argc; i++) {
const char *arg = argv[i];
if (*arg == '-') {
int opts;
- if (!prefixcmp(arg, "--max-count=")) {
- revs->max_count = atoi(arg + 12);
- continue;
- }
- if (!prefixcmp(arg, "--skip=")) {
- revs->skip_count = atoi(arg + 7);
- continue;
- }
- /* accept -<digit>, like traditional "head" */
- if ((*arg == '-') && isdigit(arg[1])) {
- revs->max_count = atoi(arg + 1);
- continue;
- }
- if (!strcmp(arg, "-n")) {
- if (argc <= i + 1)
- die("-n requires an argument");
- revs->max_count = atoi(argv[++i]);
- continue;
- }
- if (!prefixcmp(arg, "-n")) {
- revs->max_count = atoi(arg + 2);
- continue;
- }
- if (!prefixcmp(arg, "--max-age=")) {
- revs->max_age = atoi(arg + 10);
- continue;
- }
- if (!prefixcmp(arg, "--since=")) {
- revs->max_age = approxidate(arg + 8);
- continue;
- }
- if (!prefixcmp(arg, "--after=")) {
- revs->max_age = approxidate(arg + 8);
- continue;
- }
- if (!prefixcmp(arg, "--min-age=")) {
- revs->min_age = atoi(arg + 10);
+
+ if (!strcmp(arg, "--all")) {
+ handle_refs(revs, flags, for_each_ref);
continue;
}
- if (!prefixcmp(arg, "--before=")) {
- revs->min_age = approxidate(arg + 9);
+ if (!strcmp(arg, "--branches")) {
+ handle_refs(revs, flags, for_each_branch_ref);
continue;
}
- if (!prefixcmp(arg, "--until=")) {
- revs->min_age = approxidate(arg + 8);
+ if (!strcmp(arg, "--tags")) {
+ handle_refs(revs, flags, for_each_tag_ref);
continue;
}
- if (!strcmp(arg, "--all")) {
- handle_all(revs, flags);
- continue;
- }
- if (!strcmp(arg, "--first-parent")) {
- revs->first_parent_only = 1;
+ if (!strcmp(arg, "--remotes")) {
+ handle_refs(revs, flags, for_each_remote_ref);
continue;
}
if (!strcmp(arg, "--reflog")) {
handle_reflog(revs, flags);
continue;
}
- if (!strcmp(arg, "-g") ||
- !strcmp(arg, "--walk-reflogs")) {
- init_reflog_walk(&revs->reflog_info);
- continue;
- }
if (!strcmp(arg, "--not")) {
flags ^= UNINTERESTING;
continue;
}
- if (!strcmp(arg, "--default")) {
- if (++i >= argc)
- die("bad --default argument");
- def = argv[i];
- continue;
- }
- if (!strcmp(arg, "--merge")) {
- show_merge = 1;
- continue;
- }
- if (!strcmp(arg, "--topo-order")) {
- revs->topo_order = 1;
- continue;
- }
- if (!strcmp(arg, "--date-order")) {
- revs->lifo = 0;
- revs->topo_order = 1;
- continue;
- }
- if (!prefixcmp(arg, "--early-output")) {
- int count = 100;
- switch (arg[14]) {
- case '=':
- count = atoi(arg+15);
- /* Fallthrough */
- case 0:
- revs->topo_order = 1;
- revs->early_output = count;
- continue;
- }
- }
- if (!strcmp(arg, "--parents")) {
- revs->parents = 1;
- continue;
- }
- if (!strcmp(arg, "--dense")) {
- revs->dense = 1;
- continue;
- }
- if (!strcmp(arg, "--sparse")) {
- revs->dense = 0;
- continue;
- }
- if (!strcmp(arg, "--remove-empty")) {
- revs->remove_empty_trees = 1;
- continue;
- }
- if (!strcmp(arg, "--no-merges")) {
- revs->no_merges = 1;
- continue;
- }
- if (!strcmp(arg, "--boundary")) {
- revs->boundary = 1;
- continue;
- }
- if (!strcmp(arg, "--left-right")) {
- revs->left_right = 1;
- continue;
- }
- if (!strcmp(arg, "--cherry-pick")) {
- revs->cherry_pick = 1;
- revs->limited = 1;
- continue;
- }
- if (!strcmp(arg, "--objects")) {
- revs->tag_objects = 1;
- revs->tree_objects = 1;
- revs->blob_objects = 1;
- continue;
- }
- if (!strcmp(arg, "--objects-edge")) {
- revs->tag_objects = 1;
- revs->tree_objects = 1;
- revs->blob_objects = 1;
- revs->edge_hint = 1;
- continue;
- }
- if (!strcmp(arg, "--unpacked")) {
- revs->unpacked = 1;
- free(revs->ignore_packed);
- revs->ignore_packed = NULL;
- revs->num_ignore_packed = 0;
- continue;
- }
- if (!prefixcmp(arg, "--unpacked=")) {
- revs->unpacked = 1;
- add_ignore_packed(revs, arg+11);
- continue;
- }
- if (!strcmp(arg, "-r")) {
- revs->diff = 1;
- DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
- continue;
- }
- if (!strcmp(arg, "-t")) {
- revs->diff = 1;
- DIFF_OPT_SET(&revs->diffopt, RECURSIVE);
- DIFF_OPT_SET(&revs->diffopt, TREE_IN_RECURSIVE);
- continue;
- }
- if (!strcmp(arg, "-m")) {
- revs->ignore_merges = 0;
- continue;
- }
- if (!strcmp(arg, "-c")) {
- revs->diff = 1;
- revs->dense_combined_merges = 0;
- revs->combine_merges = 1;
- continue;
- }
- if (!strcmp(arg, "--cc")) {
- revs->diff = 1;
- revs->dense_combined_merges = 1;
- revs->combine_merges = 1;
- continue;
- }
- if (!strcmp(arg, "-v")) {
- revs->verbose_header = 1;
- continue;
- }
- if (!prefixcmp(arg, "--pretty")) {
- revs->verbose_header = 1;
- revs->commit_format = get_commit_format(arg+8);
- continue;
- }
- if (!strcmp(arg, "--root")) {
- revs->show_root_diff = 1;
- continue;
- }
- if (!strcmp(arg, "--no-commit-id")) {
- revs->no_commit_id = 1;
- continue;
- }
- if (!strcmp(arg, "--always")) {
- revs->always_show_header = 1;
- continue;
- }
- if (!strcmp(arg, "--no-abbrev")) {
- revs->abbrev = 0;
- continue;
- }
- if (!strcmp(arg, "--abbrev")) {
- revs->abbrev = DEFAULT_ABBREV;
- continue;
- }
- if (!prefixcmp(arg, "--abbrev=")) {
- revs->abbrev = strtoul(arg + 9, NULL, 10);
- if (revs->abbrev < MINIMUM_ABBREV)
- revs->abbrev = MINIMUM_ABBREV;
- else if (revs->abbrev > 40)
- revs->abbrev = 40;
- continue;
- }
- if (!strcmp(arg, "--abbrev-commit")) {
- revs->abbrev_commit = 1;
- continue;
- }
- if (!strcmp(arg, "--full-diff")) {
- revs->diff = 1;
- revs->full_diff = 1;
- continue;
- }
- if (!strcmp(arg, "--full-history")) {
- revs->simplify_history = 0;
- continue;
- }
- if (!strcmp(arg, "--relative-date")) {
- revs->date_mode = DATE_RELATIVE;
- continue;
- }
- if (!strncmp(arg, "--date=", 7)) {
- revs->date_mode = parse_date_format(arg + 7);
- continue;
- }
- if (!strcmp(arg, "--log-size")) {
- revs->show_log_size = 1;
- continue;
- }
-
- /*
- * Grepping the commit log
- */
- if (!prefixcmp(arg, "--author=")) {
- add_header_grep(revs, "author", arg+9);
- continue;
- }
- if (!prefixcmp(arg, "--committer=")) {
- add_header_grep(revs, "committer", arg+12);
- continue;
- }
- if (!prefixcmp(arg, "--grep=")) {
- add_message_grep(revs, arg+7);
- continue;
- }
- if (!strcmp(arg, "--extended-regexp") ||
- !strcmp(arg, "-E")) {
- regflags |= REG_EXTENDED;
- continue;
- }
- if (!strcmp(arg, "--regexp-ignore-case") ||
- !strcmp(arg, "-i")) {
- regflags |= REG_ICASE;
- continue;
- }
- if (!strcmp(arg, "--all-match")) {
- all_match = 1;
- continue;
- }
- if (!prefixcmp(arg, "--encoding=")) {
- arg += 11;
- if (strcmp(arg, "none"))
- git_log_output_encoding = xstrdup(arg);
- else
- git_log_output_encoding = "";
- continue;
- }
- if (!strcmp(arg, "--reverse")) {
- revs->reverse ^= 1;
- continue;
- }
if (!strcmp(arg, "--no-walk")) {
revs->no_walk = 1;
continue;
@@ -1241,13 +1275,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
continue;
}
- opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
+ opts = handle_revision_opt(revs, argc - i, argv + i, &left, argv);
if (opts > 0) {
i += opts - 1;
continue;
}
- *unrecognized++ = arg;
- left++;
+ if (opts < 0)
+ exit(128);
continue;
}
@@ -1271,19 +1305,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
}
}
- if (revs->grep_filter)
- revs->grep_filter->regflags |= regflags;
-
- if (show_merge)
+ if (revs->def == NULL)
+ revs->def = def;
+ if (revs->show_merge)
prepare_show_merge(revs);
- if (def && !revs->pending.nr) {
+ if (revs->def && !revs->pending.nr) {
unsigned char sha1[20];
struct object *object;
unsigned mode;
- if (get_sha1_with_mode(def, sha1, &mode))
- die("bad default revision '%s'", def);
- object = get_reference(revs, def, sha1, 0);
- add_pending_object_with_mode(revs, object, def, mode);
+ if (get_sha1_with_mode(revs->def, sha1, &mode))
+ die("bad default revision '%s'", revs->def);
+ object = get_reference(revs, revs->def, sha1, 0);
+ add_pending_object_with_mode(revs, object, revs->def, mode);
}
/* Did the user ask for any diff output? Run the diff! */
@@ -1317,16 +1350,46 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
die("diff_setup_done failed");
if (revs->grep_filter) {
- revs->grep_filter->all_match = all_match;
compile_grep_patterns(revs->grep_filter);
}
if (revs->reverse && revs->reflog_info)
die("cannot combine --reverse with --walk-reflogs");
+ if (revs->rewrite_parents && revs->children.name)
+ die("cannot combine --parents and --children");
+
+ /*
+ * Limitations on the graph functionality
+ */
+ if (revs->reverse && revs->graph)
+ die("cannot combine --reverse with --graph");
+
+ if (revs->reflog_info && revs->graph)
+ die("cannot combine --walk-reflogs with --graph");
return left;
}
+static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
+{
+ struct commit_list *l = xcalloc(1, sizeof(*l));
+
+ l->item = child;
+ l->next = add_decoration(&revs->children, &parent->object, l);
+}
+
+static void set_children(struct rev_info *revs)
+{
+ struct commit_list *l;
+ for (l = revs->commits; l; l = l->next) {
+ struct commit *commit = l->item;
+ struct commit_list *p;
+
+ for (p = commit->parents; p; p = p->next)
+ add_child(revs, p->item, commit);
+ }
+}
+
int prepare_revision_walk(struct rev_info *revs)
{
int nr = revs->pending.nr;
@@ -1355,6 +1418,8 @@ int prepare_revision_walk(struct rev_info *revs)
return -1;
if (revs->topo_order)
sort_in_topological_order(&revs->commits, revs->lifo);
+ if (revs->children.name)
+ set_children(revs);
return 0;
}
@@ -1366,10 +1431,12 @@ enum rewrite_result {
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp)
{
+ struct commit_list *cache = NULL;
+
for (;;) {
struct commit *p = *pp;
if (!revs->limited)
- if (add_parents_to_list(revs, p, &revs->commits) < 0)
+ if (add_parents_to_list(revs, p, &revs->commits, &cache) < 0)
return rewrite_one_error;
if (p->parents && p->parents->next)
return rewrite_one_ok;
@@ -1432,12 +1499,19 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
commit->buffer, strlen(commit->buffer));
}
+static inline int want_ancestry(struct rev_info *revs)
+{
+ return (revs->rewrite_parents || revs->children.name);
+}
+
enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
{
if (commit->object.flags & SHOWN)
return commit_ignore;
if (revs->unpacked && has_sha1_pack(commit->object.sha1, revs->ignore_packed))
return commit_ignore;
+ if (revs->show_all)
+ return commit_show;
if (commit->object.flags & UNINTERESTING)
return commit_ignore;
if (revs->min_age != -1 && (commit->date > revs->min_age))
@@ -1450,13 +1524,13 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
/* Commit without changes? */
if (commit->object.flags & TREESAME) {
/* drop merges unless we want parenthood */
- if (!revs->parents)
+ if (!want_ancestry(revs))
return commit_ignore;
/* non-merge - always ignore it */
if (!commit->parents || !commit->parents->next)
return commit_ignore;
}
- if (revs->parents && rewrite_parents(revs, commit) < 0)
+ if (want_ancestry(revs) && rewrite_parents(revs, commit) < 0)
return commit_error;
}
return commit_show;
@@ -1486,7 +1560,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
if (revs->max_age != -1 &&
(commit->date < revs->max_age))
continue;
- if (add_parents_to_list(revs, commit, &revs->commits) < 0)
+ if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0)
return NULL;
}
@@ -1523,28 +1597,62 @@ static void gc_boundary(struct object_array *array)
}
}
-struct commit *get_revision(struct rev_info *revs)
+static void create_boundary_commit_list(struct rev_info *revs)
+{
+ unsigned i;
+ struct commit *c;
+ struct object_array *array = &revs->boundary_commits;
+ struct object_array_entry *objects = array->objects;
+
+ /*
+ * If revs->commits is non-NULL at this point, an error occurred in
+ * get_revision_1(). Ignore the error and continue printing the
+ * boundary commits anyway. (This is what the code has always
+ * done.)
+ */
+ if (revs->commits) {
+ free_commit_list(revs->commits);
+ revs->commits = NULL;
+ }
+
+ /*
+ * Put all of the actual boundary commits from revs->boundary_commits
+ * into revs->commits
+ */
+ for (i = 0; i < array->nr; i++) {
+ c = (struct commit *)(objects[i].item);
+ if (!c)
+ continue;
+ if (!(c->object.flags & CHILD_SHOWN))
+ continue;
+ if (c->object.flags & (SHOWN | BOUNDARY))
+ continue;
+ c->object.flags |= BOUNDARY;
+ commit_list_insert(c, &revs->commits);
+ }
+
+ /*
+ * If revs->topo_order is set, sort the boundary commits
+ * in topological order
+ */
+ sort_in_topological_order(&revs->commits, revs->lifo);
+}
+
+static struct commit *get_revision_internal(struct rev_info *revs)
{
struct commit *c = NULL;
struct commit_list *l;
if (revs->boundary == 2) {
- unsigned i;
- struct object_array *array = &revs->boundary_commits;
- struct object_array_entry *objects = array->objects;
- for (i = 0; i < array->nr; i++) {
- c = (struct commit *)(objects[i].item);
- if (!c)
- continue;
- if (!(c->object.flags & CHILD_SHOWN))
- continue;
- if (!(c->object.flags & SHOWN))
- break;
- }
- if (array->nr <= i)
- return NULL;
-
- c->object.flags |= SHOWN | BOUNDARY;
+ /*
+ * All of the normal commits have already been returned,
+ * and we are now returning boundary commits.
+ * create_boundary_commit_list() has populated
+ * revs->commits with the remaining commits to return.
+ */
+ c = pop_commit(&revs->commits);
+ if (c)
+ c->object.flags |= SHOWN;
return c;
}
@@ -1608,7 +1716,14 @@ struct commit *get_revision(struct rev_info *revs)
* switch to boundary commits output mode.
*/
revs->boundary = 2;
- return get_revision(revs);
+
+ /*
+ * Update revs->commits to contain the list of
+ * boundary commits.
+ */
+ create_boundary_commit_list(revs);
+
+ return get_revision_internal(revs);
}
/*
@@ -1630,3 +1745,11 @@ struct commit *get_revision(struct rev_info *revs)
return c;
}
+
+struct commit *get_revision(struct rev_info *revs)
+{
+ struct commit *c = get_revision_internal(revs);
+ if (c && revs->graph)
+ graph_update(revs->graph, c);
+ return c;
+}
diff --git a/revision.h b/revision.h
index 857231595..f64e8ce7f 100644
--- a/revision.h
+++ b/revision.h
@@ -1,6 +1,8 @@
#ifndef REVISION_H
#define REVISION_H
+#include "parse-options.h"
+
#define SEEN (1u<<0)
#define UNINTERESTING (1u<<1)
#define TREESAME (1u<<2)
@@ -10,7 +12,7 @@
#define CHILD_SHOWN (1u<<6)
#define ADDED (1u<<7) /* Parents already parsed and added? */
#define SYMMETRIC_LEFT (1u<<8)
-#define TOPOSORT (1u<<9) /* In the active toposort list.. */
+#define ALL_REV_FLAGS ((1u<<9)-1)
struct rev_info;
struct log_info;
@@ -25,6 +27,7 @@ struct rev_info {
/* Basic information */
const char *prefix;
+ const char *def;
void *prune_data;
unsigned int early_output;
@@ -33,6 +36,7 @@ struct rev_info {
prune:1,
no_merges:1,
no_walk:1,
+ show_all:1,
remove_empty_trees:1,
simplify_history:1,
lifo:1,
@@ -45,7 +49,8 @@ struct rev_info {
unpacked:1, /* see also ignore_packed below */
boundary:2,
left_right:1,
- parents:1,
+ rewrite_parents:1,
+ print_parents:1,
reverse:1,
cherry_pick:1,
first_parent_only:1;
@@ -63,7 +68,10 @@ struct rev_info {
/* Format info */
unsigned int shown_one:1,
- abbrev_commit:1;
+ show_merge:1,
+ abbrev_commit:1,
+ use_terminator:1,
+ missing_newline:1;
enum date_mode date_mode;
const char **ignore_packed; /* pretend objects in these are unpacked */
@@ -74,7 +82,7 @@ struct rev_info {
struct log_info *loginfo;
int nr, total;
const char *mime_boundary;
- const char *message_id;
+ char *message_id;
const char *ref_message_id;
const char *add_signoff;
const char *extra_headers;
@@ -86,6 +94,9 @@ struct rev_info {
/* Filter by commit log message */
struct grep_opt *grep_filter;
+ /* Display history graph */
+ struct git_graph *graph;
+
/* special limits */
int skip_count;
int max_count;
@@ -97,6 +108,7 @@ struct rev_info {
struct diff_options pruning;
struct reflog_walk_info *reflog_info;
+ struct decoration children;
};
#define REV_TREE_SAME 0
@@ -104,11 +116,16 @@ struct rev_info {
#define REV_TREE_DIFFERENT 2
/* revision.c */
+void read_revisions_from_stdin(struct rev_info *revs);
+
typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
volatile show_early_output_fn_t show_early_output;
extern void init_revisions(struct rev_info *revs, const char *prefix);
extern int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def);
+extern void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
+ const struct option *options,
+ const char * const usagestr[]);
extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,int cant_be_filename);
extern int prepare_revision_walk(struct rev_info *revs);
diff --git a/run-command.c b/run-command.c
index 476d00c21..bbb9c777e 100644
--- a/run-command.c
+++ b/run-command.c
@@ -20,12 +20,19 @@ int start_command(struct child_process *cmd)
int need_in, need_out, need_err;
int fdin[2], fdout[2], fderr[2];
+ /*
+ * In case of errors we must keep the promise to close FDs
+ * that have been passed in via ->in and ->out.
+ */
+
need_in = !cmd->no_stdin && cmd->in < 0;
if (need_in) {
- if (pipe(fdin) < 0)
+ if (pipe(fdin) < 0) {
+ if (cmd->out > 0)
+ close(cmd->out);
return -ERR_RUN_COMMAND_PIPE;
+ }
cmd->in = fdin[1];
- cmd->close_in = 1;
}
need_out = !cmd->no_stdout
@@ -35,10 +42,11 @@ int start_command(struct child_process *cmd)
if (pipe(fdout) < 0) {
if (need_in)
close_pair(fdin);
+ else if (cmd->in)
+ close(cmd->in);
return -ERR_RUN_COMMAND_PIPE;
}
cmd->out = fdout[0];
- cmd->close_out = 1;
}
need_err = !cmd->no_stderr && cmd->err < 0;
@@ -46,24 +54,22 @@ int start_command(struct child_process *cmd)
if (pipe(fderr) < 0) {
if (need_in)
close_pair(fdin);
+ else if (cmd->in)
+ close(cmd->in);
if (need_out)
close_pair(fdout);
+ else if (cmd->out)
+ close(cmd->out);
return -ERR_RUN_COMMAND_PIPE;
}
cmd->err = fderr[0];
}
- cmd->pid = fork();
- if (cmd->pid < 0) {
- if (need_in)
- close_pair(fdin);
- if (need_out)
- close_pair(fdout);
- if (need_err)
- close_pair(fderr);
- return -ERR_RUN_COMMAND_FORK;
- }
+ trace_argv_printf(cmd->argv, "trace: run_command:");
+#ifndef __MINGW32__
+ fflush(NULL);
+ cmd->pid = fork();
if (!cmd->pid) {
if (cmd->no_stdin)
dup_devnull(0);
@@ -75,6 +81,13 @@ int start_command(struct child_process *cmd)
close(cmd->in);
}
+ if (cmd->no_stderr)
+ dup_devnull(2);
+ else if (need_err) {
+ dup2(fderr[1], 2);
+ close_pair(fderr);
+ }
+
if (cmd->no_stdout)
dup_devnull(1);
else if (cmd->stdout_to_stderr)
@@ -87,13 +100,6 @@ int start_command(struct child_process *cmd)
close(cmd->out);
}
- if (cmd->no_stderr)
- dup_devnull(2);
- else if (need_err) {
- dup2(fderr[1], 2);
- close_pair(fderr);
- }
-
if (cmd->dir && chdir(cmd->dir))
die("exec %s: cd to %s failed (%s)", cmd->argv[0],
cmd->dir, strerror(errno));
@@ -112,6 +118,85 @@ int start_command(struct child_process *cmd)
}
die("exec %s failed.", cmd->argv[0]);
}
+#else
+ int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
+ const char **sargv = cmd->argv;
+ char **env = environ;
+
+ if (cmd->no_stdin) {
+ s0 = dup(0);
+ dup_devnull(0);
+ } else if (need_in) {
+ s0 = dup(0);
+ dup2(fdin[0], 0);
+ } else if (cmd->in) {
+ s0 = dup(0);
+ dup2(cmd->in, 0);
+ }
+
+ if (cmd->no_stderr) {
+ s2 = dup(2);
+ dup_devnull(2);
+ } else if (need_err) {
+ s2 = dup(2);
+ dup2(fderr[1], 2);
+ }
+
+ if (cmd->no_stdout) {
+ s1 = dup(1);
+ dup_devnull(1);
+ } else if (cmd->stdout_to_stderr) {
+ s1 = dup(1);
+ dup2(2, 1);
+ } else if (need_out) {
+ s1 = dup(1);
+ dup2(fdout[1], 1);
+ } else if (cmd->out > 1) {
+ s1 = dup(1);
+ dup2(cmd->out, 1);
+ }
+
+ if (cmd->dir)
+ die("chdir in start_command() not implemented");
+ if (cmd->env) {
+ env = copy_environ();
+ for (; *cmd->env; cmd->env++)
+ env = env_setenv(env, *cmd->env);
+ }
+
+ if (cmd->git_cmd) {
+ cmd->argv = prepare_git_cmd(cmd->argv);
+ }
+
+ cmd->pid = mingw_spawnvpe(cmd->argv[0], cmd->argv, env);
+
+ if (cmd->env)
+ free_environ(env);
+ if (cmd->git_cmd)
+ free(cmd->argv);
+
+ cmd->argv = sargv;
+ if (s0 >= 0)
+ dup2(s0, 0), close(s0);
+ if (s1 >= 0)
+ dup2(s1, 1), close(s1);
+ if (s2 >= 0)
+ dup2(s2, 2), close(s2);
+#endif
+
+ if (cmd->pid < 0) {
+ if (need_in)
+ close_pair(fdin);
+ else if (cmd->in)
+ close(cmd->in);
+ if (need_out)
+ close_pair(fdout);
+ else if (cmd->out)
+ close(cmd->out);
+ if (need_err)
+ close_pair(fderr);
+ return -ERR_RUN_COMMAND_FORK;
+ }
if (need_in)
close(fdin[0]);
@@ -120,7 +205,7 @@ int start_command(struct child_process *cmd)
if (need_out)
close(fdout[1]);
- else if (cmd->out > 1)
+ else if (cmd->out)
close(cmd->out);
if (need_err)
@@ -157,10 +242,6 @@ static int wait_or_whine(pid_t pid)
int finish_command(struct child_process *cmd)
{
- if (cmd->close_in)
- close(cmd->in);
- if (cmd->close_out)
- close(cmd->out);
return wait_or_whine(cmd->pid);
}
@@ -207,12 +288,25 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd);
}
+#ifdef __MINGW32__
+static __stdcall unsigned run_thread(void *data)
+{
+ struct async *async = data;
+ return async->proc(async->fd_for_proc, async->data);
+}
+#endif
+
int start_async(struct async *async)
{
int pipe_out[2];
if (pipe(pipe_out) < 0)
return error("cannot create pipe: %s", strerror(errno));
+ async->out = pipe_out[0];
+
+#ifndef __MINGW32__
+ /* Flush stdio before fork() to avoid cloning buffers */
+ fflush(NULL);
async->pid = fork();
if (async->pid < 0) {
@@ -224,16 +318,33 @@ int start_async(struct async *async)
close(pipe_out[0]);
exit(!!async->proc(pipe_out[1], async->data));
}
- async->out = pipe_out[0];
close(pipe_out[1]);
+#else
+ async->fd_for_proc = pipe_out[1];
+ async->tid = (HANDLE) _beginthreadex(NULL, 0, run_thread, async, 0, NULL);
+ if (!async->tid) {
+ error("cannot create thread: %s", strerror(errno));
+ close_pair(pipe_out);
+ return -1;
+ }
+#endif
return 0;
}
int finish_async(struct async *async)
{
+#ifndef __MINGW32__
int ret = 0;
if (wait_or_whine(async->pid))
ret = error("waitpid (async) failed");
+#else
+ DWORD ret = 0;
+ if (WaitForSingleObject(async->tid, INFINITE) != WAIT_OBJECT_0)
+ ret = error("waiting for thread failed: %lu", GetLastError());
+ else if (!GetExitCodeThread(async->tid, &ret))
+ ret = error("cannot get thread exit code: %lu", GetLastError());
+ CloseHandle(async->tid);
+#endif
return ret;
}
diff --git a/run-command.h b/run-command.h
index 1fc781d76..5203a9ebb 100644
--- a/run-command.h
+++ b/run-command.h
@@ -14,13 +14,29 @@ enum {
struct child_process {
const char **argv;
pid_t pid;
+ /*
+ * Using .in, .out, .err:
+ * - Specify 0 for no redirections (child inherits stdin, stdout,
+ * stderr from parent).
+ * - Specify -1 to have a pipe allocated as follows:
+ * .in: returns the writable pipe end; parent writes to it,
+ * the readable pipe end becomes child's stdin
+ * .out, .err: returns the readable pipe end; parent reads from
+ * it, the writable pipe end becomes child's stdout/stderr
+ * The caller of start_command() must close the returned FDs
+ * after it has completed reading from/writing to it!
+ * - Specify > 0 to set a channel to a particular FD as follows:
+ * .in: a readable FD, becomes child's stdin
+ * .out: a writable FD, becomes child's stdout/stderr
+ * .err > 0 not supported
+ * The specified FD is closed by start_command(), even in case
+ * of errors!
+ */
int in;
int out;
int err;
const char *dir;
const char *const *env;
- unsigned close_in:1;
- unsigned close_out:1;
unsigned no_stdin:1;
unsigned no_stdout:1;
unsigned no_stderr:1;
@@ -60,7 +76,12 @@ struct async {
int (*proc)(int fd, void *data);
void *data;
int out; /* caller reads from here and closes it */
+#ifndef __MINGW32__
pid_t pid;
+#else
+ HANDLE tid;
+ int fd_for_proc;
+#endif
};
int start_async(struct async *async);
diff --git a/setup.c b/setup.c
index adede16a4..6cf909463 100644
--- a/setup.c
+++ b/setup.c
@@ -4,51 +4,121 @@
static int inside_git_dir = -1;
static int inside_work_tree = -1;
-const char *prefix_path(const char *prefix, int len, const char *path)
+static int sanitary_path_copy(char *dst, const char *src)
{
- const char *orig = path;
+ char *dst0;
+
+ if (has_dos_drive_prefix(src)) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ }
+ dst0 = dst;
+
+ if (is_dir_sep(*src)) {
+ *dst++ = '/';
+ while (is_dir_sep(*src))
+ src++;
+ }
+
for (;;) {
- char c;
- if (*path != '.')
- break;
- c = path[1];
- /* "." */
- if (!c) {
- path++;
- break;
- }
- /* "./" */
- if (c == '/') {
- path += 2;
- continue;
+ char c = *src;
+
+ /*
+ * A path component that begins with . could be
+ * special:
+ * (1) "." and ends -- ignore and terminate.
+ * (2) "./" -- ignore them, eat slash and continue.
+ * (3) ".." and ends -- strip one and terminate.
+ * (4) "../" -- strip one, eat slash and continue.
+ */
+ if (c == '.') {
+ if (!src[1]) {
+ /* (1) */
+ src++;
+ } else if (is_dir_sep(src[1])) {
+ /* (2) */
+ src += 2;
+ while (is_dir_sep(*src))
+ src++;
+ continue;
+ } else if (src[1] == '.') {
+ if (!src[2]) {
+ /* (3) */
+ src += 2;
+ goto up_one;
+ } else if (is_dir_sep(src[2])) {
+ /* (4) */
+ src += 3;
+ while (is_dir_sep(*src))
+ src++;
+ goto up_one;
+ }
+ }
}
- if (c != '.')
- break;
- c = path[2];
- if (!c)
- path += 2;
- else if (c == '/')
- path += 3;
- else
+
+ /* copy up to the next '/', and eat all '/' */
+ while ((c = *src++) != '\0' && !is_dir_sep(c))
+ *dst++ = c;
+ if (is_dir_sep(c)) {
+ *dst++ = '/';
+ while (is_dir_sep(c))
+ c = *src++;
+ src--;
+ } else if (!c)
break;
- /* ".." and "../" */
- /* Remove last component of the prefix */
- do {
- if (!len)
- die("'%s' is outside repository", orig);
- len--;
- } while (len && prefix[len-1] != '/');
continue;
+
+ up_one:
+ /*
+ * dst0..dst is prefix portion, and dst[-1] is '/';
+ * go up one level.
+ */
+ dst -= 2; /* go past trailing '/' if any */
+ if (dst < dst0)
+ return -1;
+ while (1) {
+ if (dst <= dst0)
+ break;
+ c = *dst--;
+ if (c == '/') { /* MinGW: cannot be '\\' anymore */
+ dst += 2;
+ break;
+ }
+ }
}
- if (len) {
- int speclen = strlen(path);
- char *n = xmalloc(speclen + len + 1);
+ *dst = '\0';
+ return 0;
+}
- memcpy(n, prefix, len);
- memcpy(n + len, path, speclen+1);
- path = n;
+const char *prefix_path(const char *prefix, int len, const char *path)
+{
+ const char *orig = path;
+ char *sanitized = xmalloc(len + strlen(path) + 1);
+ if (is_absolute_path(orig))
+ strcpy(sanitized, path);
+ else {
+ if (len)
+ memcpy(sanitized, prefix, len);
+ strcpy(sanitized + len, path);
}
- return path;
+ if (sanitary_path_copy(sanitized, sanitized))
+ goto error_out;
+ if (is_absolute_path(orig)) {
+ const char *work_tree = get_git_work_tree();
+ size_t len = strlen(work_tree);
+ size_t total = strlen(sanitized) + 1;
+ if (strncmp(sanitized, work_tree, len) ||
+ (sanitized[len] != '\0' && sanitized[len] != '/')) {
+ error_out:
+ error("'%s' is outside repository", orig);
+ free(sanitized);
+ return NULL;
+ }
+ if (sanitized[len] == '/')
+ len++;
+ memmove(sanitized, sanitized + len, total - len);
+ }
+ return sanitized;
}
/*
@@ -59,10 +129,23 @@ const char *prefix_path(const char *prefix, int len, const char *path)
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
{
static char path[PATH_MAX];
+#ifndef __MINGW32__
if (!pfx || !*pfx || is_absolute_path(arg))
return arg;
memcpy(path, pfx, pfx_len);
strcpy(path + pfx_len, arg);
+#else
+ char *p;
+ /* don't add prefix to absolute paths, but still replace '\' by '/' */
+ if (is_absolute_path(arg))
+ pfx_len = 0;
+ else
+ memcpy(path, pfx, pfx_len);
+ strcpy(path + pfx_len, arg);
+ for (p = path + pfx_len; *p; p++)
+ if (*p == '\\')
+ *p = '/';
+#endif
return path;
}
@@ -114,7 +197,7 @@ void verify_non_filename(const char *prefix, const char *arg)
const char **get_pathspec(const char *prefix, const char **pathspec)
{
const char *entry = *pathspec;
- const char **p;
+ const char **src, **dst;
int prefixlen;
if (!prefix && !entry)
@@ -128,12 +211,21 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
}
/* Otherwise we have to re-write the entries.. */
- p = pathspec;
+ src = pathspec;
+ dst = pathspec;
prefixlen = prefix ? strlen(prefix) : 0;
- do {
- *p = prefix_path(prefix, prefixlen, entry);
- } while ((entry = *++p) != NULL);
- return (const char **) pathspec;
+ while (*src) {
+ const char *p = prefix_path(prefix, prefixlen, *src);
+ if (p)
+ *(dst++) = p;
+ else
+ exit(128); /* error message already given */
+ src++;
+ }
+ *dst = NULL;
+ if (!*pathspec)
+ return NULL;
+ return pathspec;
}
/*
@@ -216,15 +308,16 @@ void setup_work_tree(void)
work_tree = get_git_work_tree();
git_dir = get_git_dir();
if (!is_absolute_path(git_dir))
- set_git_dir(make_absolute_path(git_dir));
+ git_dir = make_absolute_path(git_dir);
if (!work_tree || chdir(work_tree))
die("This operation must be run in a work tree");
+ set_git_dir(make_relative_path(git_dir, work_tree));
initialized = 1;
}
static int check_repository_format_gently(int *nongit_ok)
{
- git_config(check_repository_format_version);
+ git_config(check_repository_format_version, NULL);
if (GIT_REPO_VERSION < repository_format_version) {
if (!nongit_ok)
die ("Expected git repo version <= %d, found %d",
@@ -239,15 +332,63 @@ static int check_repository_format_gently(int *nongit_ok)
}
/*
+ * Try to read the location of the git directory from the .git file,
+ * return path to git directory if found.
+ */
+const char *read_gitfile_gently(const char *path)
+{
+ char *buf;
+ struct stat st;
+ int fd;
+ size_t len;
+
+ if (stat(path, &st))
+ return NULL;
+ if (!S_ISREG(st.st_mode))
+ return NULL;
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ die("Error opening %s: %s", path, strerror(errno));
+ buf = xmalloc(st.st_size + 1);
+ len = read_in_full(fd, buf, st.st_size);
+ close(fd);
+ if (len != st.st_size)
+ die("Error reading %s", path);
+ buf[len] = '\0';
+ if (prefixcmp(buf, "gitdir: "))
+ die("Invalid gitfile format: %s", path);
+ while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
+ len--;
+ if (len < 9)
+ die("No path in gitfile: %s", path);
+ buf[len] = '\0';
+ if (!is_git_directory(buf + 8))
+ die("Not a git repository: %s", buf + 8);
+ path = make_absolute_path(buf + 8);
+ free(buf);
+ return path;
+}
+
+/*
* We cannot decide in this function whether we are in the work tree or
* not, since the config can only be read _after_ this function was called.
*/
const char *setup_git_directory_gently(int *nongit_ok)
{
const char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);
+ const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
static char cwd[PATH_MAX+1];
const char *gitdirenv;
- int len, offset;
+ const char *gitfile_dir;
+ int len, offset, ceil_offset;
+
+ /*
+ * Let's assume that we are in a git repository.
+ * If it turns out later that we are somewhere else, the value will be
+ * updated accordingly.
+ */
+ if (nongit_ok)
+ *nongit_ok = 0;
/*
* If GIT_DIR is set explicitly, we're not going
@@ -291,10 +432,16 @@ const char *setup_git_directory_gently(int *nongit_ok)
if (!getcwd(cwd, sizeof(cwd)-1))
die("Unable to read current working directory");
+ ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
+ if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
+ ceil_offset = 1;
+
/*
* Test in the following order (relative to the cwd):
+ * - .git (file containing "gitdir: <path>")
* - .git/
* - ./ (bare)
+ * - ../.git
* - ../.git/
* - ../ (bare)
* - ../../.git/
@@ -302,6 +449,12 @@ const char *setup_git_directory_gently(int *nongit_ok)
*/
offset = len = strlen(cwd);
for (;;) {
+ gitfile_dir = read_gitfile_gently(DEFAULT_GIT_DIR_ENVIRONMENT);
+ if (gitfile_dir) {
+ if (set_git_dir(gitfile_dir))
+ die("Repository setup failed");
+ break;
+ }
if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
break;
if (is_git_directory(".")) {
@@ -312,18 +465,17 @@ const char *setup_git_directory_gently(int *nongit_ok)
check_repository_format_gently(nongit_ok);
return NULL;
}
- chdir("..");
- do {
- if (!offset) {
- if (nongit_ok) {
- if (chdir(cwd))
- die("Cannot come back to cwd");
- *nongit_ok = 1;
- return NULL;
- }
- die("Not a git repository");
+ while (--offset > ceil_offset && cwd[offset] != '/');
+ if (offset <= ceil_offset) {
+ if (nongit_ok) {
+ if (chdir(cwd))
+ die("Cannot come back to cwd");
+ *nongit_ok = 1;
+ return NULL;
}
- } while (cwd[--offset] != '/');
+ die("Not a git repository");
+ }
+ chdir("..");
}
inside_git_dir = 0;
@@ -344,24 +496,56 @@ const char *setup_git_directory_gently(int *nongit_ok)
int git_config_perm(const char *var, const char *value)
{
- if (value) {
- int i;
- if (!strcmp(value, "umask"))
- return PERM_UMASK;
- if (!strcmp(value, "group"))
- return PERM_GROUP;
- if (!strcmp(value, "all") ||
- !strcmp(value, "world") ||
- !strcmp(value, "everybody"))
- return PERM_EVERYBODY;
- i = atoi(value);
- if (i > 1)
- return i;
+ int i;
+ char *endptr;
+
+ if (value == NULL)
+ return PERM_GROUP;
+
+ if (!strcmp(value, "umask"))
+ return PERM_UMASK;
+ if (!strcmp(value, "group"))
+ return PERM_GROUP;
+ if (!strcmp(value, "all") ||
+ !strcmp(value, "world") ||
+ !strcmp(value, "everybody"))
+ return PERM_EVERYBODY;
+
+ /* Parse octal numbers */
+ i = strtol(value, &endptr, 8);
+
+ /* If not an octal number, maybe true/false? */
+ if (*endptr != 0)
+ return git_config_bool(var, value) ? PERM_GROUP : PERM_UMASK;
+
+ /*
+ * Treat values 0, 1 and 2 as compatibility cases, otherwise it is
+ * a chmod value.
+ */
+ switch (i) {
+ case PERM_UMASK: /* 0 */
+ return PERM_UMASK;
+ case OLD_PERM_GROUP: /* 1 */
+ return PERM_GROUP;
+ case OLD_PERM_EVERYBODY: /* 2 */
+ return PERM_EVERYBODY;
}
- return git_config_bool(var, value);
+
+ /* A filemode value was given: 0xxx */
+
+ if ((i & 0600) != 0600)
+ die("Problem with core.sharedRepository filemode value "
+ "(0%.3o).\nThe owner of files must always have "
+ "read and write permissions.", i);
+
+ /*
+ * Mask filemode value. Others can not get write permission.
+ * x flags for directories are handled separately.
+ */
+ return i & 0666;
}
-int check_repository_format_version(const char *var, const char *value)
+int check_repository_format_version(const char *var, const char *value, void *cb)
{
if (strcmp(var, "core.repositoryformatversion") == 0)
repository_format_version = git_config_int(var, value);
@@ -372,8 +556,9 @@ int check_repository_format_version(const char *var, const char *value)
if (is_bare_repository_cfg == 1)
inside_work_tree = -1;
} else if (strcmp(var, "core.worktree") == 0) {
- if (git_work_tree_cfg)
- free(git_work_tree_cfg);
+ if (!value)
+ return config_error_nonbool(var);
+ free(git_work_tree_cfg);
git_work_tree_cfg = xstrdup(value);
inside_work_tree = -1;
}
diff --git a/sha1-lookup.c b/sha1-lookup.c
new file mode 100644
index 000000000..da357479c
--- /dev/null
+++ b/sha1-lookup.c
@@ -0,0 +1,171 @@
+#include "cache.h"
+#include "sha1-lookup.h"
+
+/*
+ * Conventional binary search loop looks like this:
+ *
+ * unsigned lo, hi;
+ * do {
+ * unsigned mi = (lo + hi) / 2;
+ * int cmp = "entry pointed at by mi" minus "target";
+ * if (!cmp)
+ * return (mi is the wanted one)
+ * if (cmp > 0)
+ * hi = mi; "mi is larger than target"
+ * else
+ * lo = mi+1; "mi is smaller than target"
+ * } while (lo < hi);
+ *
+ * The invariants are:
+ *
+ * - When entering the loop, lo points at a slot that is never
+ * above the target (it could be at the target), hi points at a
+ * slot that is guaranteed to be above the target (it can never
+ * be at the target).
+ *
+ * - We find a point 'mi' between lo and hi (mi could be the same
+ * as lo, but never can be as same as hi), and check if it hits
+ * the target. There are three cases:
+ *
+ * - if it is a hit, we are happy.
+ *
+ * - if it is strictly higher than the target, we set it to hi,
+ * and repeat the search.
+ *
+ * - if it is strictly lower than the target, we update lo to
+ * one slot after it, because we allow lo to be at the target.
+ *
+ * If the loop exits, there is no matching entry.
+ *
+ * When choosing 'mi', we do not have to take the "middle" but
+ * anywhere in between lo and hi, as long as lo <= mi < hi is
+ * satisfied. When we somehow know that the distance between the
+ * target and lo is much shorter than the target and hi, we could
+ * pick mi that is much closer to lo than the midway.
+ *
+ * Now, we can take advantage of the fact that SHA-1 is a good hash
+ * function, and as long as there are enough entries in the table, we
+ * can expect uniform distribution. An entry that begins with for
+ * example "deadbeef..." is much likely to appear much later than in
+ * the midway of the table. It can reasonably be expected to be near
+ * 87% (222/256) from the top of the table.
+ *
+ * However, we do not want to pick "mi" too precisely. If the entry at
+ * the 87% in the above example turns out to be higher than the target
+ * we are looking for, we would end up narrowing the search space down
+ * only by 13%, instead of 50% we would get if we did a simple binary
+ * search. So we would want to hedge our bets by being less aggressive.
+ *
+ * The table at "table" holds at least "nr" entries of "elem_size"
+ * bytes each. Each entry has the SHA-1 key at "key_offset". The
+ * table is sorted by the SHA-1 key of the entries. The caller wants
+ * to find the entry with "key", and knows that the entry at "lo" is
+ * not higher than the entry it is looking for, and that the entry at
+ * "hi" is higher than the entry it is looking for.
+ */
+int sha1_entry_pos(const void *table,
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key)
+{
+ const unsigned char *base = table;
+ const unsigned char *hi_key, *lo_key;
+ unsigned ofs_0;
+ static int debug_lookup = -1;
+
+ if (debug_lookup < 0)
+ debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
+
+ if (!nr || lo >= hi)
+ return -1;
+
+ if (nr == hi)
+ hi_key = NULL;
+ else
+ hi_key = base + elem_size * hi + key_offset;
+ lo_key = base + elem_size * lo + key_offset;
+
+ ofs_0 = 0;
+ do {
+ int cmp;
+ unsigned ofs, mi, range;
+ unsigned lov, hiv, kyv;
+ const unsigned char *mi_key;
+
+ range = hi - lo;
+ if (hi_key) {
+ for (ofs = ofs_0; ofs < 20; ofs++)
+ if (lo_key[ofs] != hi_key[ofs])
+ break;
+ ofs_0 = ofs;
+ /*
+ * byte 0 thru (ofs-1) are the same between
+ * lo and hi; ofs is the first byte that is
+ * different.
+ */
+ hiv = hi_key[ofs_0];
+ if (ofs_0 < 19)
+ hiv = (hiv << 8) | hi_key[ofs_0+1];
+ } else {
+ hiv = 256;
+ if (ofs_0 < 19)
+ hiv <<= 8;
+ }
+ lov = lo_key[ofs_0];
+ kyv = key[ofs_0];
+ if (ofs_0 < 19) {
+ lov = (lov << 8) | lo_key[ofs_0+1];
+ kyv = (kyv << 8) | key[ofs_0+1];
+ }
+ assert(lov < hiv);
+
+ if (kyv < lov)
+ return -1 - lo;
+ if (hiv < kyv)
+ return -1 - hi;
+
+ /*
+ * Even if we know the target is much closer to 'hi'
+ * than 'lo', if we pick too precisely and overshoot
+ * (e.g. when we know 'mi' is closer to 'hi' than to
+ * 'lo', pick 'mi' that is higher than the target), we
+ * end up narrowing the search space by a smaller
+ * amount (i.e. the distance between 'mi' and 'hi')
+ * than what we would have (i.e. about half of 'lo'
+ * and 'hi'). Hedge our bets to pick 'mi' less
+ * aggressively, i.e. make 'mi' a bit closer to the
+ * middle than we would otherwise pick.
+ */
+ kyv = (kyv * 6 + lov + hiv) / 8;
+ if (lov < hiv - 1) {
+ if (kyv == lov)
+ kyv++;
+ else if (kyv == hiv)
+ kyv--;
+ }
+ mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo;
+
+ if (debug_lookup) {
+ printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi);
+ printf("ofs %u lov %x, hiv %x, kyv %x\n",
+ ofs_0, lov, hiv, kyv);
+ }
+ if (!(lo <= mi && mi < hi))
+ die("assertion failure lo %u mi %u hi %u %s",
+ lo, mi, hi, sha1_to_hex(key));
+
+ mi_key = base + elem_size * mi + key_offset;
+ cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0);
+ if (!cmp)
+ return mi;
+ if (cmp > 0) {
+ hi = mi;
+ hi_key = mi_key;
+ } else {
+ lo = mi + 1;
+ lo_key = mi_key + elem_size;
+ }
+ } while (lo < hi);
+ return -lo-1;
+}
diff --git a/sha1-lookup.h b/sha1-lookup.h
new file mode 100644
index 000000000..3249a81b3
--- /dev/null
+++ b/sha1-lookup.h
@@ -0,0 +1,9 @@
+#ifndef SHA1_LOOKUP_H
+#define SHA1_LOOKUP_H
+
+extern int sha1_entry_pos(const void *table,
+ size_t elem_size,
+ size_t key_offset,
+ unsigned lo, unsigned hi, unsigned nr,
+ const unsigned char *key);
+#endif
diff --git a/sha1_file.c b/sha1_file.c
index 66a4e00fa..32e4664b1 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -14,6 +14,8 @@
#include "tag.h"
#include "tree.h"
#include "refs.h"
+#include "pack-revindex.h"
+#include "sha1-lookup.h"
#ifndef O_NOATIME
#if defined(__linux__) && (defined(__i386__) || defined(__PPC__))
@@ -33,8 +35,6 @@ static size_t sz_fmt(size_t s) { return s; }
const unsigned char null_sha1[20];
-static unsigned int sha1_file_open_flag = O_NOATIME;
-
const signed char hexval_table[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */
-1, -1, -1, -1, -1, -1, -1, -1, /* 08-0f */
@@ -83,14 +83,18 @@ int get_sha1_hex(const char *hex, unsigned char *sha1)
return 0;
}
+static inline int offset_1st_component(const char *path)
+{
+ if (has_dos_drive_prefix(path))
+ return 2 + (path[2] == '/');
+ return *path == '/';
+}
+
int safe_create_leading_directories(char *path)
{
- char *pos = path;
+ char *pos = path + offset_1st_component(path);
struct stat st;
- if (is_absolute_path(path))
- pos++;
-
while (pos) {
pos = strchr(pos, '/');
if (!pos)
@@ -116,7 +120,16 @@ int safe_create_leading_directories(char *path)
return 0;
}
-char * sha1_to_hex(const unsigned char *sha1)
+int safe_create_leading_directories_const(const char *path)
+{
+ /* path points to cache entries, so xstrdup before messing with it */
+ char *buf = xstrdup(path);
+ int result = safe_create_leading_directories(buf);
+ free(buf);
+ return result;
+}
+
+char *sha1_to_hex(const unsigned char *sha1)
{
static int bufno;
static char hexbuffer[4][50];
@@ -174,21 +187,23 @@ char *sha1_file_name(const unsigned char *sha1)
return base;
}
-char *sha1_pack_name(const unsigned char *sha1)
+static char *sha1_get_pack_name(const unsigned char *sha1,
+ char **name, char **base, const char *which)
{
static const char hex[] = "0123456789abcdef";
- static char *name, *base, *buf;
+ char *buf;
int i;
- if (!base) {
+ if (!*base) {
const char *sha1_file_directory = get_object_directory();
int len = strlen(sha1_file_directory);
- base = xmalloc(len + 60);
- sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.pack", sha1_file_directory);
- name = base + len + 11;
+ *base = xmalloc(len + 60);
+ sprintf(*base, "%s/pack/pack-1234567890123456789012345678901234567890.%s",
+ sha1_file_directory, which);
+ *name = *base + len + 11;
}
- buf = name;
+ buf = *name;
for (i = 0; i < 20; i++) {
unsigned int val = *sha1++;
@@ -196,32 +211,21 @@ char *sha1_pack_name(const unsigned char *sha1)
*buf++ = hex[val & 0xf];
}
- return base;
+ return *base;
}
-char *sha1_pack_index_name(const unsigned char *sha1)
+char *sha1_pack_name(const unsigned char *sha1)
{
- static const char hex[] = "0123456789abcdef";
- static char *name, *base, *buf;
- int i;
-
- if (!base) {
- const char *sha1_file_directory = get_object_directory();
- int len = strlen(sha1_file_directory);
- base = xmalloc(len + 60);
- sprintf(base, "%s/pack/pack-1234567890123456789012345678901234567890.idx", sha1_file_directory);
- name = base + len + 11;
- }
+ static char *name, *base;
- buf = name;
+ return sha1_get_pack_name(sha1, &name, &base, "pack");
+}
- for (i = 0; i < 20; i++) {
- unsigned int val = *sha1++;
- *buf++ = hex[val >> 4];
- *buf++ = hex[val & 0xf];
- }
+char *sha1_pack_index_name(const unsigned char *sha1)
+{
+ static char *name, *base;
- return base;
+ return sha1_get_pack_name(sha1, &name, &base, "idx");
}
struct alternate_object_database *alt_odb_list;
@@ -378,6 +382,18 @@ static void read_info_alternates(const char * relative_base, int depth)
munmap(map, mapsz);
}
+void add_to_alternates_file(const char *reference)
+{
+ struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+ int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), 1);
+ char *alt = mkpath("%s/objects\n", reference);
+ write_or_die(fd, alt, strlen(alt));
+ if (commit_lock_file(lock))
+ die("could not close alternates file");
+ if (alt_odb_tail)
+ link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0);
+}
+
void prepare_alt_odb(void)
{
const char *alt;
@@ -389,26 +405,26 @@ void prepare_alt_odb(void)
if (!alt) alt = "";
alt_odb_tail = &alt_odb_list;
- link_alt_odb_entries(alt, alt + strlen(alt), ':', NULL, 0);
+ link_alt_odb_entries(alt, alt + strlen(alt), PATH_SEP, NULL, 0);
read_info_alternates(get_object_directory(), 0);
}
-static char *find_sha1_file(const unsigned char *sha1, struct stat *st)
+static int has_loose_object(const unsigned char *sha1)
{
char *name = sha1_file_name(sha1);
struct alternate_object_database *alt;
- if (!stat(name, st))
- return name;
+ if (!access(name, F_OK))
+ return 1;
prepare_alt_odb();
for (alt = alt_odb_list; alt; alt = alt->next) {
name = alt->name;
fill_sha1_path(name, sha1);
- if (!stat(alt->base, st))
- return alt->base;
+ if (!access(alt->base, F_OK))
+ return 1;
}
- return NULL;
+ return 0;
}
static unsigned int pack_used_ctr;
@@ -468,7 +484,7 @@ static int check_packed_git_idx(const char *path, struct packed_git *p)
version = ntohl(hdr->idx_version);
if (version < 2 || version > 2) {
munmap(idx_map, idx_size);
- return error("index file %s is version %d"
+ return error("index file %s is version %"PRIu32
" and is not supported by this binary"
" (try upgrading GIT to a newer version)",
path, version);
@@ -679,14 +695,14 @@ static int open_packed_git_1(struct packed_git *p)
if (hdr.hdr_signature != htonl(PACK_SIGNATURE))
return error("file %s is not a GIT packfile", p->pack_name);
if (!pack_version_ok(hdr.hdr_version))
- return error("packfile %s is version %u and not supported"
- " (try upgrading GIT to a newer version)",
+ return error("packfile %s is version %"PRIu32" and not"
+ " supported (try upgrading GIT to a newer version)",
p->pack_name, ntohl(hdr.hdr_version));
/* Verify the pack matches its index. */
if (p->num_objects != ntohl(hdr.hdr_entries))
- return error("packfile %s claims to have %u objects"
- " while index indicates %u objects",
+ return error("packfile %s claims to have %"PRIu32" objects"
+ " while index indicates %"PRIu32" objects",
p->pack_name, ntohl(hdr.hdr_entries),
p->num_objects);
if (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1)
@@ -789,18 +805,28 @@ unsigned char* use_pack(struct packed_git *p,
return win->base + offset;
}
+static struct packed_git *alloc_packed_git(int extra)
+{
+ struct packed_git *p = xmalloc(sizeof(*p) + extra);
+ memset(p, 0, sizeof(*p));
+ p->pack_fd = -1;
+ return p;
+}
+
struct packed_git *add_packed_git(const char *path, int path_len, int local)
{
struct stat st;
- struct packed_git *p = xmalloc(sizeof(*p) + path_len + 2);
+ struct packed_git *p = alloc_packed_git(path_len + 2);
/*
* Make sure a corresponding .pack file exists and that
* the index looks sane.
*/
path_len -= strlen(".idx");
- if (path_len < 1)
+ if (path_len < 1) {
+ free(p);
return NULL;
+ }
memcpy(p->pack_name, path, path_len);
strcpy(p->pack_name + path_len, ".pack");
if (stat(p->pack_name, &st) || !S_ISREG(st.st_mode)) {
@@ -811,14 +837,7 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
/* ok, it looks sane as far as we can check without
* actually mapping the pack file.
*/
- p->index_version = 0;
- p->index_data = NULL;
- p->index_size = 0;
- p->num_objects = 0;
p->pack_size = st.st_size;
- p->next = NULL;
- p->windows = NULL;
- p->pack_fd = -1;
p->pack_local = local;
p->mtime = st.st_mtime;
if (path_len < 40 || get_sha1_hex(path + path_len - 40, p->sha1))
@@ -828,27 +847,17 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local)
struct packed_git *parse_pack_index(unsigned char *sha1)
{
- char *path = sha1_pack_index_name(sha1);
- return parse_pack_index_file(sha1, path);
-}
-
-struct packed_git *parse_pack_index_file(const unsigned char *sha1,
- const char *idx_path)
-{
+ const char *idx_path = sha1_pack_index_name(sha1);
const char *path = sha1_pack_name(sha1);
- struct packed_git *p = xmalloc(sizeof(*p) + strlen(path) + 2);
+ struct packed_git *p = alloc_packed_git(strlen(path) + 1);
+ strcpy(p->pack_name, path);
+ hashcpy(p->sha1, sha1);
if (check_packed_git_idx(idx_path, p)) {
free(p);
return NULL;
}
- strcpy(p->pack_name, path);
- p->pack_size = 0;
- p->next = NULL;
- p->windows = NULL;
- p->pack_fd = -1;
- hashcpy(p->sha1, sha1);
return p;
}
@@ -985,6 +994,30 @@ void reprepare_packed_git(void)
prepare_packed_git();
}
+static void mark_bad_packed_object(struct packed_git *p,
+ const unsigned char *sha1)
+{
+ unsigned i;
+ for (i = 0; i < p->num_bad_objects; i++)
+ if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
+ return;
+ p->bad_object_sha1 = xrealloc(p->bad_object_sha1, 20 * (p->num_bad_objects + 1));
+ hashcpy(p->bad_object_sha1 + 20 * p->num_bad_objects, sha1);
+ p->num_bad_objects++;
+}
+
+static int has_packed_and_bad(const unsigned char *sha1)
+{
+ struct packed_git *p;
+ unsigned i;
+
+ for (p = packed_git; p; p = p->next)
+ for (i = 0; i < p->num_bad_objects; i++)
+ if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
+ return 1;
+ return 0;
+}
+
int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long size, const char *type)
{
unsigned char real_sha1[20];
@@ -992,38 +1025,58 @@ int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long siz
return hashcmp(sha1, real_sha1) ? -1 : 0;
}
+static int git_open_noatime(const char *name)
+{
+ static int sha1_file_open_flag = O_NOATIME;
+ int fd = open(name, O_RDONLY | sha1_file_open_flag);
+
+ /* Might the failure be due to O_NOATIME? */
+ if (fd < 0 && errno != ENOENT && sha1_file_open_flag) {
+ fd = open(name, O_RDONLY);
+ if (fd >= 0)
+ sha1_file_open_flag = 0;
+ }
+ return fd;
+}
+
+static int open_sha1_file(const unsigned char *sha1)
+{
+ int fd;
+ char *name = sha1_file_name(sha1);
+ struct alternate_object_database *alt;
+
+ fd = git_open_noatime(name);
+ if (fd >= 0)
+ return fd;
+
+ prepare_alt_odb();
+ errno = ENOENT;
+ for (alt = alt_odb_list; alt; alt = alt->next) {
+ name = alt->name;
+ fill_sha1_path(name, sha1);
+ fd = git_open_noatime(alt->base);
+ if (fd >= 0)
+ return fd;
+ }
+ return -1;
+}
+
static void *map_sha1_file(const unsigned char *sha1, unsigned long *size)
{
- struct stat st;
void *map;
int fd;
- char *filename = find_sha1_file(sha1, &st);
- if (!filename) {
- return NULL;
- }
+ fd = open_sha1_file(sha1);
+ map = NULL;
+ if (fd >= 0) {
+ struct stat st;
- fd = open(filename, O_RDONLY | sha1_file_open_flag);
- if (fd < 0) {
- /* See if it works without O_NOATIME */
- switch (sha1_file_open_flag) {
- default:
- fd = open(filename, O_RDONLY);
- if (fd >= 0)
- break;
- /* Fallthrough */
- case 0:
- return NULL;
+ if (!fstat(fd, &st)) {
+ *size = xsize_t(st.st_size);
+ map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
}
-
- /* If it failed once, it will probably fail again.
- * Stop using O_NOATIME
- */
- sha1_file_open_flag = 0;
+ close(fd);
}
- *size = xsize_t(st.st_size);
- map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
- close(fd);
return map;
}
@@ -1283,20 +1336,17 @@ static off_t get_delta_base(struct packed_git *p,
while (c & 128) {
base_offset += 1;
if (!base_offset || MSB(base_offset, 7))
- die("offset value overflow for delta base object");
+ return 0; /* overflow */
c = base_info[used++];
base_offset = (base_offset << 7) + (c & 127);
}
base_offset = delta_obj_offset - base_offset;
if (base_offset >= delta_obj_offset)
- die("delta base offset out of bound");
+ return 0; /* out of bound */
*curpos += used;
} else if (type == OBJ_REF_DELTA) {
/* The base entry _must_ be in the same pack */
base_offset = find_pack_entry_one(base_info, p);
- if (!base_offset)
- die("failed to find delta-pack base object %s",
- sha1_to_hex(base_info));
*curpos += 20;
} else
die("I am totally screwed");
@@ -1367,11 +1417,15 @@ const char *packed_object_info_detail(struct packed_git *p,
unsigned long dummy;
unsigned char *next_sha1;
enum object_type type;
+ struct revindex_entry *revidx;
*delta_chain_length = 0;
curpos = obj_offset;
type = unpack_object_header(p, &w_curs, &curpos, size);
+ revidx = find_pack_revindex(p, obj_offset);
+ *store_size = revidx[1].offset - obj_offset;
+
for (;;) {
switch (type) {
default:
@@ -1381,14 +1435,16 @@ const char *packed_object_info_detail(struct packed_git *p,
case OBJ_TREE:
case OBJ_BLOB:
case OBJ_TAG:
- *store_size = 0; /* notyet */
unuse_pack(&w_curs);
return typename(type);
case OBJ_OFS_DELTA:
obj_offset = get_delta_base(p, &w_curs, &curpos, type, obj_offset);
+ if (!obj_offset)
+ die("pack %s contains bad delta base reference of type %s",
+ p->pack_name, typename(type));
if (*delta_chain_length == 0) {
- /* TODO: find base_sha1 as pointed by curpos */
- hashclr(base_sha1);
+ revidx = find_pack_revindex(p, obj_offset);
+ hashcpy(base_sha1, nth_packed_object_sha1(p, revidx->nr));
}
break;
case OBJ_REF_DELTA:
@@ -1580,17 +1636,42 @@ static void *unpack_delta_entry(struct packed_git *p,
off_t base_offset;
base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset);
+ if (!base_offset) {
+ error("failed to validate delta base reference "
+ "at offset %"PRIuMAX" from %s",
+ (uintmax_t)curpos, p->pack_name);
+ return NULL;
+ }
+ unuse_pack(w_curs);
base = cache_or_unpack_entry(p, base_offset, &base_size, type, 0);
- if (!base)
- die("failed to read delta base object"
- " at %"PRIuMAX" from %s",
- (uintmax_t)base_offset, p->pack_name);
+ if (!base) {
+ /*
+ * We're probably in deep shit, but let's try to fetch
+ * the required base anyway from another pack or loose.
+ * This is costly but should happen only in the presence
+ * of a corrupted pack, and is better than failing outright.
+ */
+ struct revindex_entry *revidx = find_pack_revindex(p, base_offset);
+ const unsigned char *base_sha1 =
+ nth_packed_object_sha1(p, revidx->nr);
+ error("failed to read delta base object %s"
+ " at offset %"PRIuMAX" from %s",
+ sha1_to_hex(base_sha1), (uintmax_t)base_offset,
+ p->pack_name);
+ mark_bad_packed_object(p, base_sha1);
+ base = read_object(base_sha1, type, &base_size);
+ if (!base)
+ return NULL;
+ }
delta_data = unpack_compressed_entry(p, w_curs, curpos, delta_size);
- if (!delta_data)
- die("failed to unpack compressed delta"
- " at %"PRIuMAX" from %s",
- (uintmax_t)curpos, p->pack_name);
+ if (!delta_data) {
+ error("failed to unpack compressed delta "
+ "at offset %"PRIuMAX" from %s",
+ (uintmax_t)curpos, p->pack_name);
+ free(base);
+ return NULL;
+ }
result = patch_delta(base, base_size,
delta_data, delta_size,
sizep);
@@ -1622,7 +1703,9 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
data = unpack_compressed_entry(p, &w_curs, curpos, *sizep);
break;
default:
- die("unknown object type %i in %s", *type, p->pack_name);
+ data = NULL;
+ error("unknown object type %i at offset %"PRIuMAX" in %s",
+ *type, (uintmax_t)obj_offset, p->pack_name);
}
unuse_pack(&w_curs);
return data;
@@ -1648,7 +1731,7 @@ const unsigned char *nth_packed_object_sha1(struct packed_git *p,
}
}
-static off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
+off_t nth_packed_object_offset(const struct packed_git *p, uint32_t n)
{
const unsigned char *index = p->index_data;
index += 4 * 256;
@@ -1671,7 +1754,12 @@ off_t find_pack_entry_one(const unsigned char *sha1,
{
const uint32_t *level1_ofs = p->index_data;
const unsigned char *index = p->index_data;
- unsigned hi, lo;
+ unsigned hi, lo, stride;
+ static int use_lookup = -1;
+ static int debug_lookup = -1;
+
+ if (debug_lookup < 0)
+ debug_lookup = !!getenv("GIT_DEBUG_LOOKUP");
if (!index) {
if (open_pack_index(p))
@@ -1686,11 +1774,34 @@ off_t find_pack_entry_one(const unsigned char *sha1,
index += 4 * 256;
hi = ntohl(level1_ofs[*sha1]);
lo = ((*sha1 == 0x0) ? 0 : ntohl(level1_ofs[*sha1 - 1]));
+ if (p->index_version > 1) {
+ stride = 20;
+ } else {
+ stride = 24;
+ index += 4;
+ }
+
+ if (debug_lookup)
+ printf("%02x%02x%02x... lo %u hi %u nr %"PRIu32"\n",
+ sha1[0], sha1[1], sha1[2], lo, hi, p->num_objects);
+
+ if (use_lookup < 0)
+ use_lookup = !!getenv("GIT_USE_LOOKUP");
+ if (use_lookup) {
+ int pos = sha1_entry_pos(index, stride, 0,
+ lo, hi, p->num_objects, sha1);
+ if (pos < 0)
+ return 0;
+ return nth_packed_object_offset(p, pos);
+ }
do {
unsigned mi = (lo + hi) / 2;
- unsigned x = (p->index_version > 1) ? (mi * 20) : (mi * 24 + 4);
- int cmp = hashcmp(index + x, sha1);
+ int cmp = hashcmp(index + mi * stride, sha1);
+
+ if (debug_lookup)
+ printf("lo %u hi %u rg %u mi %u\n",
+ lo, hi, hi - lo, mi);
if (!cmp)
return nth_packed_object_offset(p, mi);
if (cmp > 0)
@@ -1740,6 +1851,13 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
goto next;
}
+ if (p->num_bad_objects) {
+ unsigned i;
+ for (i = 0; i < p->num_bad_objects; i++)
+ if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
+ goto next;
+ }
+
offset = find_pack_entry_one(sha1, p);
if (offset) {
/*
@@ -1811,11 +1929,18 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size
int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
{
struct pack_entry e;
+ int status;
if (!find_pack_entry(sha1, &e, NULL)) {
+ /* Most likely it's a loose object. */
+ status = sha1_loose_object_info(sha1, sizep);
+ if (status >= 0)
+ return status;
+
+ /* Not a loose object; someone else may have just packed it. */
reprepare_packed_git();
if (!find_pack_entry(sha1, &e, NULL))
- return sha1_loose_object_info(sha1, sizep);
+ return status;
}
return packed_object_info(e.p, e.offset, sizep);
}
@@ -1824,11 +1949,24 @@ static void *read_packed_sha1(const unsigned char *sha1,
enum object_type *type, unsigned long *size)
{
struct pack_entry e;
+ void *data;
if (!find_pack_entry(sha1, &e, NULL))
return NULL;
- else
- return cache_or_unpack_entry(e.p, e.offset, size, type, 1);
+ data = cache_or_unpack_entry(e.p, e.offset, size, type, 1);
+ if (!data) {
+ /*
+ * We're probably in deep shit, but let's try to fetch
+ * the required object anyway from another pack or loose.
+ * This should happen only in the presence of a corrupted
+ * pack, and is better than failing outright.
+ */
+ error("failed to read object %s at offset %"PRIuMAX" from %s",
+ sha1_to_hex(sha1), (uintmax_t)e.offset, e.p->pack_name);
+ mark_bad_packed_object(e.p, sha1);
+ data = read_object(sha1, type, size);
+ }
+ return data;
}
/*
@@ -1845,6 +1983,15 @@ static struct cached_object {
} *cached_objects;
static int cached_object_nr, cached_object_alloc;
+static struct cached_object empty_tree = {
+ /* empty tree sha1: 4b825dc642cb6eb9a060e54bf8d69288fbee4904 */
+ "\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60"
+ "\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04",
+ OBJ_TREE,
+ "",
+ 0
+};
+
static struct cached_object *find_cached_object(const unsigned char *sha1)
{
int i;
@@ -1854,6 +2001,8 @@ static struct cached_object *find_cached_object(const unsigned char *sha1)
if (!hashcmp(co->sha1, sha1))
return co;
}
+ if (!hashcmp(sha1, empty_tree.sha1))
+ return &empty_tree;
return NULL;
}
@@ -1880,8 +2029,8 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
return 0;
}
-void *read_sha1_file(const unsigned char *sha1, enum object_type *type,
- unsigned long *size)
+void *read_object(const unsigned char *sha1, enum object_type *type,
+ unsigned long *size)
{
unsigned long mapsize;
void *map, *buf;
@@ -1907,6 +2056,16 @@ void *read_sha1_file(const unsigned char *sha1, enum object_type *type,
return read_packed_sha1(sha1, type, size);
}
+void *read_sha1_file(const unsigned char *sha1, enum object_type *type,
+ unsigned long *size)
+{
+ void *data = read_object(sha1, type, size);
+ /* legacy behavior is to die on corrupted objects */
+ if (!data && (has_loose_object(sha1) || has_packed_and_bad(sha1)))
+ die("object %s is corrupted", sha1_to_hex(sha1));
+ return data;
+}
+
void *read_object_with_reference(const unsigned char *sha1,
const char *required_type_name,
unsigned long *size,
@@ -1943,7 +2102,8 @@ void *read_object_with_reference(const unsigned char *sha1,
}
ref_length = strlen(ref_type);
- if (memcmp(buffer, ref_type, ref_length) ||
+ if (ref_length + 40 > isize ||
+ memcmp(buffer, ref_type, ref_length) ||
get_sha1_hex((char *) buffer + ref_length, actual_sha1)) {
free(buffer);
return NULL;
@@ -1971,48 +2131,11 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
}
/*
- * Link the tempfile to the final place, possibly creating the
- * last directory level as you do so.
- *
- * Returns the errno on failure, 0 on success.
- */
-static int link_temp_to_file(const char *tmpfile, const char *filename)
-{
- int ret;
- char *dir;
-
- if (!link(tmpfile, filename))
- return 0;
-
- /*
- * Try to mkdir the last path component if that failed.
- *
- * Re-try the "link()" regardless of whether the mkdir
- * succeeds, since a race might mean that somebody
- * else succeeded.
- */
- ret = errno;
- dir = strrchr(filename, '/');
- if (dir) {
- *dir = 0;
- if (!mkdir(filename, 0777) && adjust_shared_perm(filename)) {
- *dir = '/';
- return -2;
- }
- *dir = '/';
- if (!link(tmpfile, filename))
- return 0;
- ret = errno;
- }
- return ret;
-}
-
-/*
* Move the just written object into its final resting place
*/
int move_temp_to_file(const char *tmpfile, const char *filename)
{
- int ret = link_temp_to_file(tmpfile, filename);
+ int ret = link(tmpfile, filename);
/*
* Coda hack - coda doesn't like cross-directory links,
@@ -2057,43 +2180,68 @@ int hash_sha1_file(const void *buf, unsigned long len, const char *type,
return 0;
}
-int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *returnsha1)
+/* Finalize a file on disk, and close it. */
+static void close_sha1_file(int fd)
{
- int size, ret;
- unsigned char *compressed;
- z_stream stream;
- unsigned char sha1[20];
- char *filename;
- static char tmpfile[PATH_MAX];
- char hdr[32];
- int fd, hdrlen;
+ if (fsync_object_files)
+ fsync_or_die(fd, "sha1 file");
+ fchmod(fd, 0444);
+ if (close(fd) != 0)
+ die("unable to write sha1 file");
+}
- /* Normally if we have it in the pack then we do not bother writing
- * it out into .git/objects/??/?{38} file.
- */
- write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen);
- filename = sha1_file_name(sha1);
- if (returnsha1)
- hashcpy(returnsha1, sha1);
- if (has_sha1_file(sha1))
- return 0;
- fd = open(filename, O_RDONLY);
- if (fd >= 0) {
- /*
- * FIXME!!! We might do collision checking here, but we'd
- * need to uncompress the old file and check it. Later.
- */
- close(fd);
+/* Size of directory component, including the ending '/' */
+static inline int directory_size(const char *filename)
+{
+ const char *s = strrchr(filename, '/');
+ if (!s)
return 0;
+ return s - filename + 1;
+}
+
+/*
+ * This creates a temporary file in the same directory as the final
+ * 'filename'
+ *
+ * We want to avoid cross-directory filename renames, because those
+ * can have problems on various filesystems (FAT, NFS, Coda).
+ */
+static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
+{
+ int fd, dirlen = directory_size(filename);
+
+ if (dirlen + 20 > bufsiz) {
+ errno = ENAMETOOLONG;
+ return -1;
}
+ memcpy(buffer, filename, dirlen);
+ strcpy(buffer + dirlen, "tmp_obj_XXXXXX");
+ fd = mkstemp(buffer);
+ if (fd < 0 && dirlen) {
+ /* Make sure the directory exists */
+ memcpy(buffer, filename, dirlen);
+ buffer[dirlen-1] = 0;
+ if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
+ return -1;
- if (errno != ENOENT) {
- return error("sha1 file %s: %s\n", filename, strerror(errno));
+ /* Try again */
+ strcpy(buffer + dirlen - 1, "/tmp_obj_XXXXXX");
+ fd = mkstemp(buffer);
}
+ return fd;
+}
- snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
+static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
+ void *buf, unsigned long len, time_t mtime)
+{
+ int fd, size, ret;
+ unsigned char *compressed;
+ z_stream stream;
+ char *filename;
+ static char tmpfile[PATH_MAX];
- fd = mkstemp(tmpfile);
+ filename = sha1_file_name(sha1);
+ fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
if (fd < 0) {
if (errno == EPERM)
return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
@@ -2132,156 +2280,53 @@ int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned cha
if (write_buffer(fd, compressed, size) < 0)
die("unable to write sha1 file");
- fchmod(fd, 0444);
- if (close(fd))
- die("unable to write sha1 file");
+ close_sha1_file(fd);
free(compressed);
+ if (mtime) {
+ struct utimbuf utb;
+ utb.actime = mtime;
+ utb.modtime = mtime;
+ if (utime(tmpfile, &utb) < 0)
+ warning("failed utime() on %s: %s",
+ tmpfile, strerror(errno));
+ }
+
return move_temp_to_file(tmpfile, filename);
}
-/*
- * We need to unpack and recompress the object for writing
- * it out to a different file.
- */
-static void *repack_object(const unsigned char *sha1, unsigned long *objsize)
+int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *returnsha1)
{
- size_t size;
- z_stream stream;
- unsigned char *unpacked;
- unsigned long len;
- enum object_type type;
+ unsigned char sha1[20];
char hdr[32];
int hdrlen;
- void *buf;
- /* need to unpack and recompress it by itself */
- unpacked = read_packed_sha1(sha1, &type, &len);
- if (!unpacked)
- error("cannot read sha1_file for %s", sha1_to_hex(sha1));
-
- hdrlen = sprintf(hdr, "%s %lu", typename(type), len) + 1;
-
- /* Set it up */
- memset(&stream, 0, sizeof(stream));
- deflateInit(&stream, zlib_compression_level);
- size = deflateBound(&stream, len + hdrlen);
- buf = xmalloc(size);
-
- /* Compress it */
- stream.next_out = buf;
- stream.avail_out = size;
-
- /* First header.. */
- stream.next_in = (void *)hdr;
- stream.avail_in = hdrlen;
- while (deflate(&stream, 0) == Z_OK)
- /* nothing */;
-
- /* Then the data itself.. */
- stream.next_in = unpacked;
- stream.avail_in = len;
- while (deflate(&stream, Z_FINISH) == Z_OK)
- /* nothing */;
- deflateEnd(&stream);
- free(unpacked);
-
- *objsize = stream.total_out;
- return buf;
-}
-
-int write_sha1_to_fd(int fd, const unsigned char *sha1)
-{
- int retval;
- unsigned long objsize;
- void *buf = map_sha1_file(sha1, &objsize);
-
- if (buf) {
- retval = write_buffer(fd, buf, objsize);
- munmap(buf, objsize);
- return retval;
- }
-
- buf = repack_object(sha1, &objsize);
- retval = write_buffer(fd, buf, objsize);
- free(buf);
- return retval;
+ /* Normally if we have it in the pack then we do not bother writing
+ * it out into .git/objects/??/?{38} file.
+ */
+ write_sha1_file_prepare(buf, len, type, sha1, hdr, &hdrlen);
+ if (returnsha1)
+ hashcpy(returnsha1, sha1);
+ if (has_sha1_file(sha1))
+ return 0;
+ return write_loose_object(sha1, hdr, hdrlen, buf, len, 0);
}
-int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
- size_t bufsize, size_t *bufposn)
+int force_object_loose(const unsigned char *sha1, time_t mtime)
{
- char tmpfile[PATH_MAX];
- int local;
- z_stream stream;
- unsigned char real_sha1[20];
- unsigned char discard[4096];
- int ret;
- SHA_CTX c;
-
- snprintf(tmpfile, sizeof(tmpfile), "%s/tmp_obj_XXXXXX", get_object_directory());
-
- local = mkstemp(tmpfile);
- if (local < 0) {
- if (errno == EPERM)
- return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
- else
- return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
- }
-
- memset(&stream, 0, sizeof(stream));
-
- inflateInit(&stream);
-
- SHA1_Init(&c);
-
- do {
- ssize_t size;
- if (*bufposn) {
- stream.avail_in = *bufposn;
- stream.next_in = (unsigned char *) buffer;
- do {
- stream.next_out = discard;
- stream.avail_out = sizeof(discard);
- ret = inflate(&stream, Z_SYNC_FLUSH);
- SHA1_Update(&c, discard, sizeof(discard) -
- stream.avail_out);
- } while (stream.avail_in && ret == Z_OK);
- if (write_buffer(local, buffer, *bufposn - stream.avail_in) < 0)
- die("unable to write sha1 file");
- memmove(buffer, buffer + *bufposn - stream.avail_in,
- stream.avail_in);
- *bufposn = stream.avail_in;
- if (ret != Z_OK)
- break;
- }
- size = xread(fd, buffer + *bufposn, bufsize - *bufposn);
- if (size <= 0) {
- close(local);
- unlink(tmpfile);
- if (!size)
- return error("Connection closed?");
- perror("Reading from connection");
- return -1;
- }
- *bufposn += size;
- } while (1);
- inflateEnd(&stream);
-
- fchmod(local, 0444);
- if (close(local) != 0)
- die("unable to write sha1 file");
- SHA1_Final(real_sha1, &c);
- if (ret != Z_STREAM_END) {
- unlink(tmpfile);
- return error("File %s corrupted", sha1_to_hex(sha1));
- }
- if (hashcmp(sha1, real_sha1)) {
- unlink(tmpfile);
- return error("File %s has bad hash", sha1_to_hex(sha1));
- }
+ void *buf;
+ unsigned long len;
+ enum object_type type;
+ char hdr[32];
+ int hdrlen;
- return move_temp_to_file(tmpfile, sha1_file_name(sha1));
+ if (has_loose_object(sha1))
+ return 0;
+ buf = read_packed_sha1(sha1, &type, &len);
+ if (!buf)
+ return error("cannot read sha1_file for %s", sha1_to_hex(sha1));
+ hdrlen = sprintf(hdr, "%s %lu", typename(type), len) + 1;
+ return write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);
}
int has_pack_index(const unsigned char *sha1)
@@ -2308,12 +2353,11 @@ int has_sha1_pack(const unsigned char *sha1, const char **ignore_packed)
int has_sha1_file(const unsigned char *sha1)
{
- struct stat st;
struct pack_entry e;
if (find_pack_entry(sha1, &e, NULL))
return 1;
- return find_sha1_file(sha1, &st) ? 1 : 0;
+ return has_loose_object(sha1);
}
int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
@@ -2358,7 +2402,8 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
if ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {
struct strbuf nbuf;
strbuf_init(&nbuf, 0);
- if (convert_to_git(path, buf, size, &nbuf)) {
+ if (convert_to_git(path, buf, size, &nbuf,
+ write_object ? safe_crlf : 0)) {
munmap(buf, size);
buf = strbuf_detach(&nbuf, &size);
re_allocated = 1;
@@ -2420,16 +2465,10 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
int read_pack_header(int fd, struct pack_header *header)
{
- char *c = (char*)header;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(fd, c, remaining);
- if (r <= 0)
- /* "eof before pack header was fully read" */
- return PH_ERROR_EOF;
- remaining -= r;
- c += r;
- } while (remaining > 0);
+ if (read_in_full(fd, header, sizeof(*header)) < sizeof(*header))
+ /* "eof before pack header was fully read" */
+ return PH_ERROR_EOF;
+
if (header->hdr_signature != htonl(PACK_SIGNATURE))
/* "protocol error (pack signature mismatch detected)" */
return PH_ERROR_PACK_SIGNATURE;
diff --git a/sha1_name.c b/sha1_name.c
index be8489e4e..4fb77f886 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -192,26 +192,25 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
const char *find_unique_abbrev(const unsigned char *sha1, int len)
{
- int status, is_null;
+ int status, exists;
static char hex[41];
- is_null = is_null_sha1(sha1);
+ exists = has_sha1_file(sha1);
memcpy(hex, sha1_to_hex(sha1), 40);
if (len == 40 || !len)
return hex;
while (len < 40) {
unsigned char sha1_ret[20];
status = get_short_sha1(hex, len, sha1_ret, 1);
- if (!status ||
- (is_null && status != SHORT_NAME_AMBIGUOUS)) {
+ if (exists
+ ? !status
+ : status == SHORT_NAME_NOT_FOUND) {
hex[len] = 0;
return hex;
}
- if (status != SHORT_NAME_AMBIGUOUS)
- return NULL;
len++;
}
- return NULL;
+ return hex;
}
static int ambiguous_path(const char *path, int len)
@@ -274,7 +273,7 @@ int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
const char *ref, *it;
strcpy(path, mkpath(*p, len, str));
- ref = resolve_ref(path, hash, 0, NULL);
+ ref = resolve_ref(path, hash, 1, NULL);
if (!ref)
continue;
if (!stat(git_path("logs/%s", path), &st) &&
@@ -352,8 +351,11 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
}
if (0 <= nth)
at_time = 0;
- else
- at_time = approxidate(str + at + 2);
+ else {
+ char *tmp = xstrndup(str + at + 2, reflog_len);
+ at_time = approxidate(tmp);
+ free(tmp);
+ }
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
&co_time, &co_tz, &co_cnt)) {
if (at_time)
@@ -408,21 +410,56 @@ static int get_nth_ancestor(const char *name, int len,
unsigned char *result, int generation)
{
unsigned char sha1[20];
- int ret = get_sha1_1(name, len, sha1);
+ struct commit *commit;
+ int ret;
+
+ ret = get_sha1_1(name, len, sha1);
if (ret)
return ret;
+ commit = lookup_commit_reference(sha1);
+ if (!commit)
+ return -1;
while (generation--) {
- struct commit *commit = lookup_commit_reference(sha1);
-
- if (!commit || parse_commit(commit) || !commit->parents)
+ if (parse_commit(commit) || !commit->parents)
return -1;
- hashcpy(sha1, commit->parents->item->object.sha1);
+ commit = commit->parents->item;
}
- hashcpy(result, sha1);
+ hashcpy(result, commit->object.sha1);
return 0;
}
+struct object *peel_to_type(const char *name, int namelen,
+ struct object *o, enum object_type expected_type)
+{
+ if (name && !namelen)
+ namelen = strlen(name);
+ if (!o) {
+ unsigned char sha1[20];
+ if (get_sha1_1(name, namelen, sha1))
+ return NULL;
+ o = parse_object(sha1);
+ }
+ while (1) {
+ if (!o || (!o->parsed && !parse_object(o->sha1)))
+ return NULL;
+ if (o->type == expected_type)
+ return o;
+ if (o->type == OBJ_TAG)
+ o = ((struct tag*) o)->tagged;
+ else if (o->type == OBJ_COMMIT)
+ o = &(((struct commit *) o)->tree->object);
+ else {
+ if (name)
+ error("%.*s: expected %s type, but the object "
+ "dereferences to %s type",
+ namelen, name, typename(expected_type),
+ typename(o->type));
+ return NULL;
+ }
+ }
+}
+
static int peel_onion(const char *name, int len, unsigned char *sha1)
{
unsigned char outer[20];
@@ -474,29 +511,17 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
hashcpy(sha1, o->sha1);
}
else {
- /* At this point, the syntax look correct, so
+ /*
+ * At this point, the syntax look correct, so
* if we do not get the needed object, we should
* barf.
*/
-
- while (1) {
- if (!o || (!o->parsed && !parse_object(o->sha1)))
- return -1;
- if (o->type == expected_type) {
- hashcpy(sha1, o->sha1);
- return 0;
- }
- if (o->type == OBJ_TAG)
- o = ((struct tag*) o)->tagged;
- else if (o->type == OBJ_COMMIT)
- o = &(((struct commit *) o)->tree->object);
- else
- return error("%.*s: expected %s type, but the object dereferences to %s type",
- len, name, typename(expected_type),
- typename(o->type));
- if (!o->parsed)
- parse_object(o->sha1);
+ o = peel_to_type(name, len, o, expected_type);
+ if (o) {
+ hashcpy(sha1, o->sha1);
+ return 0;
}
+ return -1;
}
return 0;
}
@@ -526,9 +551,8 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1)
int ret, has_suffix;
const char *cp;
- /* "name~3" is "name^^^",
- * "name~" and "name~0" are name -- not "name^0"!
- * "name^" is not "name^0"; it is "name^1".
+ /*
+ * "name~3" is "name^^^", "name~" is "name~1", and "name^" is "name^1".
*/
has_suffix = 0;
for (cp = name + len - 1; name <= cp; cp--) {
@@ -546,11 +570,10 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1)
cp++;
while (cp < name + len)
num = num * 10 + *cp++ - '0';
- if (has_suffix == '^') {
- if (!num && len1 == len - 1)
- num = 1;
+ if (!num && len1 == len - 1)
+ num = 1;
+ if (has_suffix == '^')
return get_parent(name, len1, sha1, num);
- }
/* else if (has_suffix == '~') -- goes without saying */
return get_nth_ancestor(name, len1, sha1, num);
}
@@ -578,8 +601,11 @@ static int handle_one_ref(const char *path,
struct object *object = parse_object(sha1);
if (!object)
return 0;
- if (object->type == OBJ_TAG)
+ if (object->type == OBJ_TAG) {
object = deref_tag(object, path, strlen(path));
+ if (!object)
+ return 0;
+ }
if (object->type != OBJ_COMMIT)
return 0;
insert_by_date((struct commit *)object, list);
@@ -617,9 +643,9 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
unsigned long size;
commit = pop_most_recent_commit(&list, ONELINE_SEEN);
- parse_object(commit->object.sha1);
- if (temp_commit_buffer)
- free(temp_commit_buffer);
+ if (!parse_object(commit->object.sha1))
+ continue;
+ free(temp_commit_buffer);
if (commit->buffer)
p = commit->buffer;
else {
@@ -636,8 +662,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1)
break;
}
}
- if (temp_commit_buffer)
- free(temp_commit_buffer);
+ free(temp_commit_buffer);
free_commit_list(list);
for (l = backup; l; l = l->next)
clear_commit_marks(l->item, ONELINE_SEEN);
diff --git a/shallow.c b/shallow.c
index dbd9f5ad0..4d90eda19 100644
--- a/shallow.c
+++ b/shallow.c
@@ -56,7 +56,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
if (i < heads->nr) {
commit = (struct commit *)
deref_tag(heads->objects[i++].item, NULL, 0);
- if (commit->object.type != OBJ_COMMIT) {
+ if (!commit || commit->object.type != OBJ_COMMIT) {
commit = NULL;
continue;
}
@@ -70,7 +70,8 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
cur_depth = *(int *)commit->util;
}
}
- parse_commit(commit);
+ if (parse_commit(commit))
+ die("invalid commit");
commit->object.flags |= not_shallow_flag;
cur_depth++;
for (p = commit->parents, commit = NULL; p; p = p->next) {
diff --git a/shell.c b/shell.c
index 9826109d5..6a48de05f 100644
--- a/shell.c
+++ b/shell.c
@@ -3,10 +3,19 @@
#include "exec_cmd.h"
#include "strbuf.h"
+/* Stubs for functions that make no sense for git-shell. These stubs
+ * are provided here to avoid linking in external redundant modules.
+ */
+void release_pack_memory(size_t need, int fd){}
+void trace_argv_printf(const char **argv, const char *fmt, ...){}
+void trace_printf(const char *fmt, ...){}
+
+
static int do_generic_cmd(const char *me, char *arg)
{
const char *my_argv[4];
+ setup_path();
if (!arg || !(arg = sq_dequote(arg)))
die("bad argument");
if (prefixcmp(me, "git-"))
@@ -28,8 +37,7 @@ static int do_cvs_cmd(const char *me, char *arg)
if (!arg || strcmp(arg, "server"))
die("git-cvsserver only handles server: %s", arg);
- setup_path(NULL);
-
+ setup_path();
return execv_git_cmd(cvsserver_argv);
}
@@ -49,15 +57,24 @@ int main(int argc, char **argv)
char *prog;
struct commands *cmd;
+ /*
+ * Special hack to pretend to be a CVS server
+ */
if (argc == 2 && !strcmp(argv[1], "cvs server"))
argv--;
- /* We want to see "-c cmd args", and nothing else */
+
+ /*
+ * We do not accept anything but "-c" followed by "cmd arg",
+ * where "cmd" is a very limited subset of git commands.
+ */
else if (argc != 3 || strcmp(argv[1], "-c"))
die("What do you think I am? A shell?");
prog = argv[2];
- argv += 2;
- argc -= 2;
+ if (!strncmp(prog, "git", 3) && isspace(prog[3]))
+ /* Accept "git foo" as if the caller said "git-foo". */
+ prog[3] = '-';
+
for (cmd = cmd_list ; cmd->name ; cmd++) {
int len = strlen(cmd->name);
char *arg;
diff --git a/shortlog.h b/shortlog.h
new file mode 100644
index 000000000..bc02cc29e
--- /dev/null
+++ b/shortlog.h
@@ -0,0 +1,27 @@
+#ifndef SHORTLOG_H
+#define SHORTLOG_H
+
+#include "string-list.h"
+
+struct shortlog {
+ struct string_list list;
+ int summary;
+ int wrap_lines;
+ int sort_by_number;
+ int wrap;
+ int in1;
+ int in2;
+ int user_format;
+
+ char *common_repo_prefix;
+ int email;
+ struct string_list mailmap;
+};
+
+void shortlog_init(struct shortlog *log);
+
+void shortlog_add_commit(struct shortlog *log, struct commit *commit);
+
+void shortlog_output(struct shortlog *log);
+
+#endif
diff --git a/show-index.c b/show-index.c
index 7253991ff..45bb53577 100644
--- a/show-index.c
+++ b/show-index.c
@@ -68,7 +68,8 @@ int main(int argc, char **argv)
ntohl(off64[1]);
off64_nr++;
}
- printf("%" PRIuMAX " %s (%08x)\n", (uintmax_t) offset,
+ printf("%" PRIuMAX " %s (%08"PRIx32")\n",
+ (uintmax_t) offset,
sha1_to_hex(entries[i].sha1),
ntohl(entries[i].crc));
}
diff --git a/strbuf.c b/strbuf.c
index 5efcfc886..720737d85 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -60,6 +60,18 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
ALLOC_GROW(sb->buf, sb->len + extra + 1, sb->alloc);
}
+void strbuf_trim(struct strbuf *sb)
+{
+ char *b = sb->buf;
+ while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
+ sb->len--;
+ while (sb->len > 0 && isspace(*b)) {
+ b++;
+ sb->len--;
+ }
+ memmove(sb->buf, b, sb->len);
+ sb->buf[sb->len] = '\0';
+}
void strbuf_rtrim(struct strbuf *sb)
{
while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
@@ -67,7 +79,65 @@ void strbuf_rtrim(struct strbuf *sb)
sb->buf[sb->len] = '\0';
}
-int strbuf_cmp(struct strbuf *a, struct strbuf *b)
+void strbuf_ltrim(struct strbuf *sb)
+{
+ char *b = sb->buf;
+ while (sb->len > 0 && isspace(*b)) {
+ b++;
+ sb->len--;
+ }
+ memmove(sb->buf, b, sb->len);
+ sb->buf[sb->len] = '\0';
+}
+
+void strbuf_tolower(struct strbuf *sb)
+{
+ int i;
+ for (i = 0; i < sb->len; i++)
+ sb->buf[i] = tolower(sb->buf[i]);
+}
+
+struct strbuf **strbuf_split(const struct strbuf *sb, int delim)
+{
+ int alloc = 2, pos = 0;
+ char *n, *p;
+ struct strbuf **ret;
+ struct strbuf *t;
+
+ ret = xcalloc(alloc, sizeof(struct strbuf *));
+ p = n = sb->buf;
+ while (n < sb->buf + sb->len) {
+ int len;
+ n = memchr(n, delim, sb->len - (n - sb->buf));
+ if (pos + 1 >= alloc) {
+ alloc = alloc * 2;
+ ret = xrealloc(ret, sizeof(struct strbuf *) * alloc);
+ }
+ if (!n)
+ n = sb->buf + sb->len - 1;
+ len = n - p + 1;
+ t = xmalloc(sizeof(struct strbuf));
+ strbuf_init(t, len);
+ strbuf_add(t, p, len);
+ ret[pos] = t;
+ ret[++pos] = NULL;
+ p = ++n;
+ }
+ return ret;
+}
+
+void strbuf_list_free(struct strbuf **sbs)
+{
+ struct strbuf **s = sbs;
+
+ while (*s) {
+ strbuf_release(*s);
+ free(*s++);
+ }
+ free(sbs);
+}
+
+int strbuf_cmp(const struct strbuf *a, const struct strbuf *b)
{
int cmp;
if (a->len < b->len) {
@@ -146,11 +216,12 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...)
strbuf_setlen(sb, sb->len + len);
}
-void strbuf_expand(struct strbuf *sb, const char *format,
- const char **placeholders, expand_fn_t fn, void *context)
+void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn,
+ void *context)
{
for (;;) {
- const char *percent, **p;
+ const char *percent;
+ size_t consumed;
percent = strchrnul(format, '%');
strbuf_add(sb, format, percent - format);
@@ -158,14 +229,10 @@ void strbuf_expand(struct strbuf *sb, const char *format,
break;
format = percent + 1;
- for (p = placeholders; *p; p++) {
- if (!prefixcmp(format, *p))
- break;
- }
- if (*p) {
- fn(sb, *p, context);
- format += strlen(*p);
- } else
+ consumed = fn(sb, format, context);
+ if (consumed)
+ format += consumed;
+ else
strbuf_addch(sb, '%');
}
}
diff --git a/strbuf.h b/strbuf.h
index 36d61db65..eba7ba423 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -61,7 +61,7 @@ static inline void strbuf_swap(struct strbuf *a, struct strbuf *b) {
}
/*----- strbuf size related -----*/
-static inline size_t strbuf_avail(struct strbuf *sb) {
+static inline size_t strbuf_avail(const struct strbuf *sb) {
return sb->alloc ? sb->alloc - sb->len - 1 : 0;
}
@@ -77,8 +77,14 @@ static inline void strbuf_setlen(struct strbuf *sb, size_t len) {
#define strbuf_reset(sb) strbuf_setlen(sb, 0)
/*----- content related -----*/
+extern void strbuf_trim(struct strbuf *);
extern void strbuf_rtrim(struct strbuf *);
-extern int strbuf_cmp(struct strbuf *, struct strbuf *);
+extern void strbuf_ltrim(struct strbuf *);
+extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
+extern void strbuf_tolower(struct strbuf *);
+
+extern struct strbuf **strbuf_split(const struct strbuf *, int delim);
+extern void strbuf_list_free(struct strbuf **);
/*----- add data in your buffer -----*/
static inline void strbuf_addch(struct strbuf *sb, int c) {
@@ -98,13 +104,13 @@ 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));
}
-static inline void strbuf_addbuf(struct strbuf *sb, struct strbuf *sb2) {
+static inline void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2) {
strbuf_add(sb, sb2->buf, sb2->len);
}
extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
-typedef void (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
-extern void strbuf_expand(struct strbuf *sb, const char *format, const char **placeholders, expand_fn_t fn, void *context);
+typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
+extern void strbuf_expand(struct strbuf *sb, const char *format, expand_fn_t fn, void *context);
__attribute__((format(printf,2,3)))
extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
@@ -117,6 +123,6 @@ extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
extern int strbuf_getline(struct strbuf *, FILE *, int);
extern void stripspace(struct strbuf *buf, int skip_comments);
-extern void launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
+extern int launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
#endif /* STRBUF_H */
diff --git a/string-list.c b/string-list.c
new file mode 100644
index 000000000..ddd83c8c7
--- /dev/null
+++ b/string-list.c
@@ -0,0 +1,134 @@
+#include "cache.h"
+#include "string-list.h"
+
+/* if there is no exact match, point to the index where the entry could be
+ * inserted */
+static int get_entry_index(const struct string_list *list, const char *string,
+ int *exact_match)
+{
+ int left = -1, right = list->nr;
+
+ while (left + 1 < right) {
+ int middle = (left + right) / 2;
+ int compare = strcmp(string, list->items[middle].string);
+ if (compare < 0)
+ right = middle;
+ else if (compare > 0)
+ left = middle;
+ else {
+ *exact_match = 1;
+ return middle;
+ }
+ }
+
+ *exact_match = 0;
+ return right;
+}
+
+/* returns -1-index if already exists */
+static int add_entry(struct string_list *list, const char *string)
+{
+ int exact_match;
+ int index = get_entry_index(list, string, &exact_match);
+
+ if (exact_match)
+ return -1 - index;
+
+ if (list->nr + 1 >= list->alloc) {
+ list->alloc += 32;
+ list->items = xrealloc(list->items, list->alloc
+ * sizeof(struct string_list_item));
+ }
+ if (index < list->nr)
+ memmove(list->items + index + 1, list->items + index,
+ (list->nr - index)
+ * sizeof(struct string_list_item));
+ list->items[index].string = list->strdup_strings ?
+ xstrdup(string) : (char *)string;
+ list->items[index].util = NULL;
+ list->nr++;
+
+ return index;
+}
+
+struct string_list_item *string_list_insert(const char *string, struct string_list *list)
+{
+ int index = add_entry(list, string);
+
+ if (index < 0)
+ index = -1 - index;
+
+ return list->items + index;
+}
+
+int string_list_has_string(const struct string_list *list, const char *string)
+{
+ int exact_match;
+ get_entry_index(list, string, &exact_match);
+ return exact_match;
+}
+
+struct string_list_item *string_list_lookup(const char *string, struct string_list *list)
+{
+ int exact_match, i = get_entry_index(list, string, &exact_match);
+ if (!exact_match)
+ return NULL;
+ return list->items + i;
+}
+
+void string_list_clear(struct string_list *list, int free_util)
+{
+ if (list->items) {
+ int i;
+ if (list->strdup_strings) {
+ for (i = 0; i < list->nr; i++)
+ free(list->items[i].string);
+ }
+ if (free_util) {
+ for (i = 0; i < list->nr; i++)
+ free(list->items[i].util);
+ }
+ free(list->items);
+ }
+ list->items = NULL;
+ list->nr = list->alloc = 0;
+}
+
+void print_string_list(const char *text, const struct string_list *p)
+{
+ int i;
+ if ( text )
+ printf("%s\n", text);
+ for (i = 0; i < p->nr; i++)
+ printf("%s:%p\n", p->items[i].string, p->items[i].util);
+}
+
+struct string_list_item *string_list_append(const char *string, struct string_list *list)
+{
+ ALLOC_GROW(list->items, list->nr + 1, list->alloc);
+ list->items[list->nr].string =
+ list->strdup_strings ? xstrdup(string) : (char *)string;
+ return list->items + list->nr++;
+}
+
+static int cmp_items(const void *a, const void *b)
+{
+ const struct string_list_item *one = a;
+ const struct string_list_item *two = b;
+ return strcmp(one->string, two->string);
+}
+
+void sort_string_list(struct string_list *list)
+{
+ qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
+}
+
+int unsorted_string_list_has_string(struct string_list *list, const char *string)
+{
+ int i;
+ for (i = 0; i < list->nr; i++)
+ if (!strcmp(string, list->items[i].string))
+ return 1;
+ return 0;
+}
+
diff --git a/string-list.h b/string-list.h
new file mode 100644
index 000000000..4d6a7051f
--- /dev/null
+++ b/string-list.h
@@ -0,0 +1,28 @@
+#ifndef PATH_LIST_H
+#define PATH_LIST_H
+
+struct string_list_item {
+ char *string;
+ void *util;
+};
+struct string_list
+{
+ struct string_list_item *items;
+ unsigned int nr, alloc;
+ unsigned int strdup_strings:1;
+};
+
+void print_string_list(const char *text, const struct string_list *p);
+void string_list_clear(struct string_list *list, int free_util);
+
+/* Use these functions only on sorted lists: */
+int string_list_has_string(const struct string_list *list, const char *string);
+struct string_list_item *string_list_insert(const char *string, struct string_list *list);
+struct string_list_item *string_list_lookup(const char *string, struct string_list *list);
+
+/* Use these functions only on unsorted lists: */
+struct string_list_item *string_list_append(const char *string, struct string_list *list);
+void sort_string_list(struct string_list *list);
+int unsorted_string_list_has_string(struct string_list *list, const char *string);
+
+#endif /* PATH_LIST_H */
diff --git a/symlinks.c b/symlinks.c
index be9ace6c0..5a5e781a1 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -1,48 +1,64 @@
#include "cache.h"
-int has_symlink_leading_path(const char *name, char *last_symlink)
-{
+struct pathname {
+ int len;
char path[PATH_MAX];
- const char *sp, *ep;
- char *dp;
-
- sp = name;
- dp = path;
-
- if (last_symlink && *last_symlink) {
- size_t last_len = strlen(last_symlink);
- size_t len = strlen(name);
- if (last_len < len &&
- !strncmp(name, last_symlink, last_len) &&
- name[last_len] == '/')
- return 1;
- *last_symlink = '\0';
+};
+
+/* Return matching pathname prefix length, or zero if not matching */
+static inline int match_pathname(int len, const char *name, struct pathname *match)
+{
+ int match_len = match->len;
+ return (len > match_len &&
+ name[match_len] == '/' &&
+ !memcmp(name, match->path, match_len)) ? match_len : 0;
+}
+
+static inline void set_pathname(int len, const char *name, struct pathname *match)
+{
+ if (len < PATH_MAX) {
+ match->len = len;
+ memcpy(match->path, name, len);
+ match->path[len] = 0;
}
+}
+
+int has_symlink_leading_path(int len, const char *name)
+{
+ static struct pathname link, nonlink;
+ char path[PATH_MAX];
+ struct stat st;
+ char *sp;
+ int known_dir;
- while (1) {
- size_t len;
- struct stat st;
+ /*
+ * See if the last known symlink cache matches.
+ */
+ if (match_pathname(len, name, &link))
+ return 1;
- ep = strchr(sp, '/');
- if (!ep)
- break;
- len = ep - sp;
- if (PATH_MAX <= dp + len - path + 2)
- return 0; /* new name is longer than that??? */
- memcpy(dp, sp, len);
- dp[len] = 0;
+ /*
+ * Get rid of the last known directory part
+ */
+ known_dir = match_pathname(len, name, &nonlink);
+
+ while ((sp = strchr(name + known_dir + 1, '/')) != NULL) {
+ int thislen = sp - name ;
+ memcpy(path, name, thislen);
+ path[thislen] = 0;
if (lstat(path, &st))
return 0;
+ if (S_ISDIR(st.st_mode)) {
+ set_pathname(thislen, path, &nonlink);
+ known_dir = thislen;
+ continue;
+ }
if (S_ISLNK(st.st_mode)) {
- if (last_symlink)
- strcpy(last_symlink, path);
+ set_pathname(thislen, path, &link);
return 1;
}
-
- dp[len++] = '/';
- dp = dp + len;
- sp = ep + 1;
+ break;
}
return 0;
}
diff --git a/t/.gitattributes b/t/.gitattributes
new file mode 100644
index 000000000..1b97c5465
--- /dev/null
+++ b/t/.gitattributes
@@ -0,0 +1 @@
+t[0-9][0-9][0-9][0-9]/* -whitespace
diff --git a/t/.gitignore b/t/.gitignore
index fad67c097..b27e28008 100644
--- a/t/.gitignore
+++ b/t/.gitignore
@@ -1 +1,2 @@
-trash
+/trash directory
+/test-results
diff --git a/t/Makefile b/t/Makefile
index 72d788423..0d65cedaa 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -14,18 +14,24 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
TSVN = $(wildcard t91[0-9][0-9]-*.sh)
-all: $(T) clean
+all: pre-clean $(T) aggregate-results clean
$(T):
@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
+pre-clean:
+ $(RM) -r test-results
+
clean:
- $(RM) -r trash
+ $(RM) -r 'trash directory' test-results
+
+aggregate-results:
+ '$(SHELL_PATH_SQ)' ./aggregate-results.sh test-results/t*-*
# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
full-svn-test:
$(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
$(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
-.PHONY: $(T) clean
+.PHONY: pre-clean $(T) aggregate-results clean
.NOTPARALLEL:
diff --git a/t/README b/t/README
index 36f251761..8f12d48fe 100644
--- a/t/README
+++ b/t/README
@@ -54,6 +54,38 @@ You can pass --verbose (or -v), --debug (or -d), and --immediate
This causes the test to immediately exit upon the first
failed test.
+--long-tests::
+ This causes additional long-running tests to be run (where
+ available), for more exhaustive testing.
+
+
+Skipping Tests
+--------------
+
+In some environments, certain tests have no way of succeeding
+due to platform limitation, such as lack of 'unzip' program, or
+filesystem that do not allow arbitrary sequence of non-NUL bytes
+as pathnames.
+
+You should be able to say something like
+
+ $ GIT_SKIP_TESTS=t9200.8 sh ./t9200-git-cvsexport-commit.sh
+
+and even:
+
+ $ GIT_SKIP_TESTS='t[0-4]??? t91?? t9200.8' make
+
+to omit such tests. The value of the environment variable is a
+SP separated list of patterns that tells which tests to skip,
+and either can match the "t[0-9]{4}" part to skip the whole
+test, or t[0-9]{4} followed by ".$number" to say which
+particular test to skip.
+
+Note that some tests in the existing test suite rely on previous
+test item, so you cannot arbitrarily disable one and expect the
+remainder of test to check what the test originally was intended
+to check.
+
Naming Tests
------------
@@ -123,7 +155,7 @@ This test harness library does the following things:
(or -h), it shows the test_description and exits.
- Creates an empty test directory with an empty .git/objects
- database and chdir(2) into it. This directory is 't/trash'
+ database and chdir(2) into it. This directory is 't/trash directory'
if you must know, but I do not think you care.
- Defines standard test helper functions for your scripts to
@@ -160,14 +192,12 @@ library for your script to use.
- test_expect_failure <message> <script>
- This is the opposite of test_expect_success. If <script>
- yields success, test is considered a failure.
-
- Example:
-
- test_expect_failure \
- 'git-update-index without --add should fail adding.' \
- 'git-update-index should-be-empty'
+ This is NOT the opposite of test_expect_success, but is used
+ to mark a test that demonstrates a known breakage. Unlike
+ the usual test_expect_success tests, which say "ok" on
+ success and "FAIL" on failure, this will say "FIXED" on
+ success and "still broken" on failure. Failures from these
+ tests won't cause -i (immediate) to stop.
- test_debug <script>
diff --git a/t/aggregate-results.sh b/t/aggregate-results.sh
new file mode 100755
index 000000000..d5bab75d7
--- /dev/null
+++ b/t/aggregate-results.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+fixed=0
+success=0
+failed=0
+broken=0
+total=0
+
+for file
+do
+ while read type value
+ do
+ case $type in
+ '')
+ continue ;;
+ fixed)
+ fixed=$(($fixed + $value)) ;;
+ success)
+ success=$(($success + $value)) ;;
+ failed)
+ failed=$(($failed + $value)) ;;
+ broken)
+ broken=$(($broken + $value)) ;;
+ total)
+ total=$(($total + $value)) ;;
+ esac
+ done <"$file"
+done
+
+printf "%-8s%d\n" fixed $fixed
+printf "%-8s%d\n" success $success
+printf "%-8s%d\n" failed $failed
+printf "%-8s%d\n" broken $broken
+printf "%-8s%d\n" total $total
diff --git a/t/diff-lib.sh b/t/diff-lib.sh
index 7dc6d7eb1..4bddeb591 100644
--- a/t/diff-lib.sh
+++ b/t/diff-lib.sh
@@ -11,7 +11,7 @@ compare_diff_raw () {
sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
- git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+ test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
@@ -21,9 +21,9 @@ compare_diff_raw_z () {
# Also we do not check SHA1 hash generation in this test, which
# is a job for t0000-basic.sh
- tr '\000' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
- tr '\000' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
- git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+ perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
+ perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
+ test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
compare_diff_patch () {
@@ -37,5 +37,5 @@ compare_diff_patch () {
/^[dis]*imilarity index [0-9]*%$/d
/^index [0-9a-f]*\.\.[0-9a-f]/d
' <"$2" >.tmp-2
- git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+ test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 9ee35e790..a841df2a9 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -20,12 +20,13 @@ then
fi
svnrepo=$PWD/svnrepo
+export svnrepo
perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
-system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
+system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41);
" >&3 2>&4
x=$?
if test $x -ne 0
@@ -49,15 +50,40 @@ poke() {
test-chmtime +1 "$1"
}
-SVN_HTTPD_MODULE_PATH=${SVN_HTTPD_MODULE_PATH-'/usr/lib/apache2/modules'}
-SVN_HTTPD_PATH=${SVN_HTTPD_PATH-'/usr/sbin/apache2'}
+for d in \
+ "$SVN_HTTPD_PATH" \
+ /usr/sbin/apache2 \
+ /usr/sbin/httpd \
+; do
+ if test -f "$d"
+ then
+ SVN_HTTPD_PATH="$d"
+ break
+ fi
+done
+for d in \
+ "$SVN_HTTPD_MODULE_PATH" \
+ /usr/lib/apache2/modules \
+ /usr/libexec/apache2 \
+; do
+ if test -d "$d"
+ then
+ SVN_HTTPD_MODULE_PATH="$d"
+ break
+ fi
+done
start_httpd () {
+ repo_base_path="$1"
if test -z "$SVN_HTTPD_PORT"
then
echo >&2 'SVN_HTTPD_PORT is not defined!'
return
fi
+ if test -z "$repo_base_path"
+ then
+ repo_base_path=svn
+ fi
mkdir "$GIT_DIR"/logs
@@ -66,16 +92,17 @@ ServerName "git-svn test"
ServerRoot "$GIT_DIR"
DocumentRoot "$GIT_DIR"
PidFile "$GIT_DIR/httpd.pid"
+LockFile logs/accept.lock
Listen 127.0.0.1:$SVN_HTTPD_PORT
LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so
LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so
-<Location /svn>
+<Location /$repo_base_path>
DAV svn
- SVNPath $rawsvnrepo
+ SVNPath "$rawsvnrepo"
</Location>
EOF
"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start
- svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn
+ svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path"
}
stop_httpd () {
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
new file mode 100644
index 000000000..dc473dfb5
--- /dev/null
+++ b/t/lib-httpd.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+if test -z "$GIT_TEST_HTTPD"
+then
+ say "skipping test, network testing disabled by default"
+ say "(define GIT_TEST_HTTPD to enable)"
+ test_done
+ exit
+fi
+
+LIB_HTTPD_PATH=${LIB_HTTPD_PATH-'/usr/sbin/apache2'}
+LIB_HTTPD_PORT=${LIB_HTTPD_PORT-'8111'}
+
+TEST_PATH="$PWD"/../lib-httpd
+HTTPD_ROOT_PATH="$PWD"/httpd
+HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www
+
+if ! test -x "$LIB_HTTPD_PATH"
+then
+ say "skipping test, no web server found at '$LIB_HTTPD_PATH'"
+ test_done
+ exit
+fi
+
+HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
+ sed -n 's/^Server version: Apache\/\([0-9]*\)\..*$/\1/p; q'`
+
+if test -n "$HTTPD_VERSION"
+then
+ if test -z "$LIB_HTTPD_MODULE_PATH"
+ then
+ if ! test $HTTPD_VERSION -ge 2
+ then
+ say "skipping test, at least Apache version 2 is required"
+ test_done
+ exit
+ fi
+
+ LIB_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
+ fi
+else
+ error "Could not identify web server at '$LIB_HTTPD_PATH'"
+fi
+
+HTTPD_PARA=""
+
+prepare_httpd() {
+ mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
+
+ ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
+
+ if test -n "$LIB_HTTPD_SSL"
+ then
+ HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
+
+ RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
+ -config "$TEST_PATH/ssl.cnf" \
+ -new -x509 -nodes \
+ -out "$HTTPD_ROOT_PATH/httpd.pem" \
+ -keyout "$HTTPD_ROOT_PATH/httpd.pem"
+ GIT_SSL_NO_VERIFY=t
+ export GIT_SSL_NO_VERIFY
+ HTTPD_PARA="$HTTPD_PARA -DSSL"
+ else
+ HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
+ fi
+
+ if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
+ then
+ HTTPD_PARA="$HTTPD_PARA -DDAV"
+
+ if test -n "$LIB_HTTPD_SVN"
+ then
+ HTTPD_PARA="$HTTPD_PARA -DSVN"
+ rawsvnrepo="$HTTPD_ROOT_PATH/svnrepo"
+ svnrepo="http://127.0.0.1:$LIB_HTTPD_PORT/svn"
+ fi
+ fi
+}
+
+start_httpd() {
+ prepare_httpd
+
+ trap 'stop_httpd; die' exit
+
+ "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
+ -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
+ -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start
+}
+
+stop_httpd() {
+ trap 'die' exit
+
+ "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
+ -f "$TEST_PATH/apache.conf" -k stop
+}
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
new file mode 100644
index 000000000..4717c2d33
--- /dev/null
+++ b/t/lib-httpd/apache.conf
@@ -0,0 +1,35 @@
+ServerName dummy
+PidFile httpd.pid
+DocumentRoot www
+ErrorLog error.log
+
+<IfDefine SSL>
+LoadModule ssl_module modules/mod_ssl.so
+
+SSLCertificateFile httpd.pem
+SSLCertificateKeyFile httpd.pem
+SSLRandomSeed startup file:/dev/urandom 512
+SSLRandomSeed connect file:/dev/urandom 512
+SSLSessionCache none
+SSLMutex file:ssl_mutex
+SSLEngine On
+</IfDefine>
+
+<IfDefine DAV>
+ LoadModule dav_module modules/mod_dav.so
+ LoadModule dav_fs_module modules/mod_dav_fs.so
+
+ DAVLockDB DAVLock
+ <Location />
+ Dav on
+ </Location>
+</IfDefine>
+
+<IfDefine SVN>
+ LoadModule dav_svn_module modules/mod_dav_svn.so
+
+ <Location /svn>
+ DAV svn
+ SVNPath svnrepo
+ </Location>
+</IfDefine>
diff --git a/t/lib-httpd/ssl.cnf b/t/lib-httpd/ssl.cnf
new file mode 100644
index 000000000..6dab2579c
--- /dev/null
+++ b/t/lib-httpd/ssl.cnf
@@ -0,0 +1,8 @@
+RANDFILE = $ENV::RANDFILE_PATH
+
+[ req ]
+default_bits = 1024
+distinguished_name = req_distinguished_name
+prompt = no
+[ req_distinguished_name ]
+commonName = 127.0.0.1
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 9f84b8d3a..70df15cbd 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -47,12 +47,24 @@ test_expect_success \
'test $(wc -l < full-of-directories) = 3'
################################################################
+# Test harness
+test_expect_success 'success is reported like this' '
+ :
+'
+test_expect_failure 'pretend we have a known breakage' '
+ false
+'
+test_expect_failure 'pretend we have fixed a known breakage' '
+ :
+'
+
+################################################################
# Basics of the basics
# updating a new file without --add should fail.
-test_expect_failure \
- 'git update-index without --add should fail adding.' \
- 'git update-index should-be-empty'
+test_expect_success 'git update-index without --add should fail adding.' '
+ test_must_fail git update-index should-be-empty
+'
# and with --add it should succeed, even if it is empty (it used to fail).
test_expect_success \
@@ -70,9 +82,9 @@ test_expect_success \
# Removing paths.
rm -f should-be-empty full-of-directories
-test_expect_failure \
- 'git update-index without --remove should fail removing.' \
- 'git update-index should-be-empty'
+test_expect_success 'git update-index without --remove should fail removing.' '
+ test_must_fail git update-index should-be-empty
+'
test_expect_success \
'git update-index with --remove should be able to remove.' \
@@ -204,9 +216,9 @@ test_expect_success \
'put invalid objects into the index.' \
'git update-index --index-info < badobjects'
-test_expect_failure \
- 'writing this tree without --missing-ok.' \
- 'git write-tree'
+test_expect_success 'writing this tree without --missing-ok.' '
+ test_must_fail git write-tree
+'
test_expect_success \
'writing this tree with --missing-ok.' \
@@ -289,12 +301,14 @@ test_expect_success 'absolute path works as expected' '
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
- test "$dir" = "$(test-absolute-path $dir2)" &&
+ test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&
file="$dir"/index &&
- test "$file" = "$(test-absolute-path $dir2/index)" &&
+ test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&
+ basename=blub &&
+ test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
- test "$sym" = "$(test-absolute-path $dir2/syml)"
+ test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"
'
test_expect_success 'very long name in the index handled sanely' '
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index c015405f1..620da5b32 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -79,6 +79,17 @@ test_expect_success 'GIT_DIR bare' '
check_config git-dir-bare.git true unset
'
+test_expect_success 'init --bare' '
+
+ (
+ unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+ mkdir init-bare.git &&
+ cd init-bare.git &&
+ git init --bare
+ ) &&
+ check_config init-bare.git true unset
+'
+
test_expect_success 'GIT_DIR non-bare' '
(
@@ -113,4 +124,47 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
fi
'
+test_expect_success 'reinit' '
+
+ (
+ unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG
+
+ mkdir again &&
+ cd again &&
+ git init >out1 2>err1 &&
+ git init >out2 2>err2
+ ) &&
+ grep "Initialized empty" again/out1 &&
+ grep "Reinitialized existing" again/out2 &&
+ >again/empty &&
+ test_cmp again/empty again/err1 &&
+ test_cmp again/empty again/err2
+'
+
+test_expect_success 'init with --template' '
+ mkdir template-source &&
+ echo content >template-source/file &&
+ (
+ mkdir template-custom &&
+ cd template-custom &&
+ git init --template=../template-source
+ ) &&
+ test_cmp template-source/file template-custom/.git/file
+'
+
+test_expect_success 'init with --template (blank)' '
+ (
+ mkdir template-plain &&
+ cd template-plain &&
+ git init
+ ) &&
+ test -f template-plain/.git/info/exclude &&
+ (
+ mkdir template-blank &&
+ cd template-blank &&
+ git init --template=
+ ) &&
+ ! test -f template-blank/.git/info/exclude
+'
+
test_done
diff --git a/t/t0002-gitfile.sh b/t/t0002-gitfile.sh
new file mode 100755
index 000000000..4db4ac44c
--- /dev/null
+++ b/t/t0002-gitfile.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+test_description='.git file
+
+Verify that plumbing commands work when .git is a file
+'
+. ./test-lib.sh
+
+objpath() {
+ echo "$1" | sed -e 's|\(..\)|\1/|'
+}
+
+objck() {
+ p=$(objpath "$1")
+ if test ! -f "$REAL/objects/$p"
+ then
+ echo "Object not found: $REAL/objects/$p"
+ false
+ fi
+}
+
+
+test_expect_success 'initial setup' '
+ REAL="$(pwd)/.real" &&
+ mv .git "$REAL"
+'
+
+test_expect_success 'bad setup: invalid .git file format' '
+ echo "gitdir $REAL" >.git &&
+ if git rev-parse 2>.err
+ then
+ echo "git rev-parse accepted an invalid .git file"
+ false
+ fi &&
+ if ! grep -qe "Invalid gitfile format" .err
+ then
+ echo "git rev-parse returned wrong error"
+ false
+ fi
+'
+
+test_expect_success 'bad setup: invalid .git file path' '
+ echo "gitdir: $REAL.not" >.git &&
+ if git rev-parse 2>.err
+ then
+ echo "git rev-parse accepted an invalid .git file path"
+ false
+ fi &&
+ if ! grep -qe "Not a git repository" .err
+ then
+ echo "git rev-parse returned wrong error"
+ false
+ fi
+'
+
+test_expect_success 'final setup + check rev-parse --git-dir' '
+ echo "gitdir: $REAL" >.git &&
+ test "$REAL" = "$(git rev-parse --git-dir)"
+'
+
+test_expect_success 'check hash-object' '
+ echo "foo" >bar &&
+ SHA=$(cat bar | git hash-object -w --stdin) &&
+ objck $SHA
+'
+
+test_expect_success 'check cat-file' '
+ git cat-file blob $SHA >actual &&
+ test_cmp bar actual
+'
+
+test_expect_success 'check update-index' '
+ if test -f "$REAL/index"
+ then
+ echo "Hmm, $REAL/index exists?"
+ false
+ fi &&
+ rm -f "$REAL/objects/$(objpath $SHA)" &&
+ git update-index --add bar &&
+ if ! test -f "$REAL/index"
+ then
+ echo "$REAL/index not found"
+ false
+ fi &&
+ objck $SHA
+'
+
+test_expect_success 'check write-tree' '
+ SHA=$(git write-tree) &&
+ objck $SHA
+'
+
+test_expect_success 'check commit-tree' '
+ SHA=$(echo "commit bar" | git commit-tree $SHA) &&
+ objck $SHA
+'
+
+test_expect_success 'check rev-list' '
+ echo $SHA >"$REAL/HEAD" &&
+ test "$SHA" = "$(git rev-list HEAD)"
+'
+
+test_done
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
new file mode 100755
index 000000000..3d8e06a20
--- /dev/null
+++ b/t/t0003-attributes.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+test_description=gitattributes
+
+. ./test-lib.sh
+
+attr_check () {
+
+ path="$1"
+ expect="$2"
+
+ git check-attr test -- "$path" >actual &&
+ echo "$path: test: $2" >expect &&
+ test_cmp expect actual
+
+}
+
+
+test_expect_success 'setup' '
+
+ mkdir -p a/b/d a/c &&
+ (
+ echo "f test=f"
+ echo "a/i test=a/i"
+ ) >.gitattributes &&
+ (
+ echo "g test=a/g" &&
+ echo "b/g test=a/b/g"
+ ) >a/.gitattributes &&
+ (
+ echo "h test=a/b/h" &&
+ echo "d/* test=a/b/d/*"
+ ) >a/b/.gitattributes
+
+'
+
+test_expect_success 'attribute test' '
+
+ attr_check f f &&
+ attr_check a/f f &&
+ attr_check a/c/f f &&
+ attr_check a/g a/g &&
+ attr_check a/b/g a/b/g &&
+ attr_check b/g unspecified &&
+ attr_check a/b/h a/b/h &&
+ attr_check a/b/d/g "a/b/d/*"
+
+'
+
+test_expect_success 'root subdir attribute test' '
+
+ attr_check a/i a/i &&
+ attr_check subdir/a/i unspecified
+
+'
+
+test_expect_success 'setup bare' '
+
+ git clone --bare . bare.git &&
+ cd bare.git
+
+'
+
+test_expect_success 'bare repository: check that .gitattribute is ignored' '
+
+ (
+ echo "f test=f"
+ echo "a/i test=a/i"
+ ) >.gitattributes &&
+ attr_check f unspecified &&
+ attr_check a/f unspecified &&
+ attr_check a/c/f unspecified &&
+ attr_check a/i unspecified &&
+ attr_check subdir/a/i unspecified
+
+'
+
+test_expect_success 'bare repository: test info/attributes' '
+
+ (
+ echo "f test=f"
+ echo "a/i test=a/i"
+ ) >info/attributes &&
+ attr_check f f &&
+ attr_check a/f f &&
+ attr_check a/c/f f &&
+ attr_check a/i a/i &&
+ attr_check subdir/a/i unspecified
+
+'
+
+test_done
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
new file mode 100755
index 000000000..63e1217e7
--- /dev/null
+++ b/t/t0004-unwritable.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+test_description='detect unwritable repository and fail correctly'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ >file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ echo >file &&
+ git add file
+
+'
+
+test_expect_success 'write-tree should notice unwritable repository' '
+
+ (
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git write-tree
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success 'commit should notice unwritable repository' '
+
+ (
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git commit -m second
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success 'update-index should notice unwritable repository' '
+
+ (
+ echo 6O >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git update-index file
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_expect_success 'add should notice unwritable repository' '
+
+ (
+ echo b >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git add file
+ )
+ status=$?
+ chmod 775 .git/objects .git/objects/??
+ (exit $status)
+
+'
+
+test_done
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 8b27aa892..1be7446d8 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -5,7 +5,11 @@ test_description='CRLF conversion'
. ./test-lib.sh
q_to_nul () {
- tr Q '\000'
+ perl -pe 'y/Q/\000/'
+}
+
+q_to_cr () {
+ tr Q '\015'
}
append_cr () {
@@ -42,6 +46,60 @@ test_expect_success setup '
echo happy.
'
+test_expect_success 'safecrlf: autocrlf=input, all CRLF' '
+
+ git config core.autocrlf input &&
+ git config core.safecrlf true &&
+
+ for w in I am all CRLF; do echo $w; done | append_cr >allcrlf &&
+ test_must_fail git add allcrlf
+'
+
+test_expect_success 'safecrlf: autocrlf=input, mixed LF/CRLF' '
+
+ git config core.autocrlf input &&
+ git config core.safecrlf true &&
+
+ for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed &&
+ test_must_fail git add mixed
+'
+
+test_expect_success 'safecrlf: autocrlf=true, all LF' '
+
+ git config core.autocrlf true &&
+ git config core.safecrlf true &&
+
+ for w in I am all LF; do echo $w; done >alllf &&
+ test_must_fail git add alllf
+'
+
+test_expect_success 'safecrlf: autocrlf=true mixed LF/CRLF' '
+
+ git config core.autocrlf true &&
+ git config core.safecrlf true &&
+
+ for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >mixed &&
+ test_must_fail git add mixed
+'
+
+test_expect_success 'safecrlf: print warning only once' '
+
+ git config core.autocrlf input &&
+ git config core.safecrlf warn &&
+
+ for w in I am all LF; do echo $w; done >doublewarn &&
+ git add doublewarn &&
+ git commit -m "nowarn" &&
+ for w in Oh here is CRLFQ in text; do echo $w; done | q_to_cr >doublewarn &&
+ test $(git add doublewarn 2>&1 | grep "CRLF will be replaced by LF" | wc -l) = 1
+'
+
+test_expect_success 'switch off autocrlf, safecrlf, reset HEAD' '
+ git config core.autocrlf false &&
+ git config core.safecrlf false &&
+ git reset --hard HEAD^
+'
+
test_expect_success 'update with autocrlf=input' '
rm -f tmp one dir/two three &&
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index cb860296e..8fc39d77c 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -5,7 +5,9 @@ test_description='blob conversion via gitattributes'
. ./test-lib.sh
cat <<\EOF >rot13.sh
-tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
+tr \
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
+ 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
EOF
chmod +x rot13.sh
diff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh
index 430a1d1d3..7d1ce2d05 100755
--- a/t/t0022-crlf-rename.sh
+++ b/t/t0022-crlf-rename.sh
@@ -26,7 +26,7 @@ test_expect_success 'diff -M' '
git diff-tree -M -r --name-status HEAD^ HEAD |
sed -e "s/R[0-9]*/RNUM/" >actual &&
echo "RNUM sample elpmas" >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t0023-crlf-am.sh b/t/t0023-crlf-am.sh
index 6f8a4347d..aaed72540 100755
--- a/t/t0023-crlf-am.sh
+++ b/t/t0023-crlf-am.sh
@@ -36,7 +36,7 @@ test_expect_success 'setup' '
test_expect_success 'am' '
- git am --binary -3 <patchfile &&
+ git am -3 <patchfile &&
git diff-files --name-status --exit-code
'
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index cad95f35a..ccb0a3cb6 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -16,96 +16,96 @@ test_expect_success \
'long lines without spaces should be unchanged' '
echo "$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt$ttt$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'lines with spaces at the beginning should be unchanged' '
echo "$sss$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'lines with intermediate spaces should be unchanged' '
echo "$ttt$sss$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$sss$sss$ttt" >expect &&
git stripspace <expect >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'consecutive blank lines should be unified' '
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
printf "$ttt\n\t\n \n\n \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
@@ -113,114 +113,114 @@ test_expect_success \
> expect &&
printf "\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'consecutive blank lines at the beginning should be removed' '
printf "$ttt\n" > expect &&
printf "\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'consecutive blank lines at the end should be removed' '
printf "$ttt\n" > expect &&
printf "$ttt\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$ttt\n\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n" > expect &&
printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt$ttt\n" > expect &&
printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" > expect &&
printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
@@ -243,78 +243,78 @@ test_expect_success \
test `printf "$ttt$sss$sss$sss" | git stripspace | wc -l` -gt 0
'
-test_expect_failure \
+test_expect_success \
'text plus spaces without newline at end should not show spaces' '
- printf "$ttt$sss" | git stripspace | grep -q " " ||
- printf "$ttt$ttt$sss" | git stripspace | grep -q " " ||
- printf "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " ||
- printf "$ttt$sss$sss" | git stripspace | grep -q " " ||
- printf "$ttt$ttt$sss$sss" | git stripspace | grep -q " " ||
- printf "$ttt$sss$sss$sss" | git stripspace | grep -q " "
+ ! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
'
test_expect_success \
'text plus spaces without newline should show the correct lines' '
printf "$ttt\n" >expect &&
printf "$ttt$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" >expect &&
printf "$ttt$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n" >expect &&
printf "$ttt$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n" >expect &&
printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt$ttt\n" >expect &&
printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
-test_expect_failure \
+test_expect_success \
'text plus spaces at end should not show spaces' '
- echo "$ttt$sss" | git stripspace | grep -q " " ||
- echo "$ttt$ttt$sss" | git stripspace | grep -q " " ||
- echo "$ttt$ttt$ttt$sss" | git stripspace | grep -q " " ||
- echo "$ttt$sss$sss" | git stripspace | grep -q " " ||
- echo "$ttt$ttt$sss$sss" | git stripspace | grep -q " " ||
- echo "$ttt$sss$sss$sss" | git stripspace | grep -q " "
+ ! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
'
test_expect_success \
'text plus spaces at end should be cleaned and newline must remain' '
echo "$ttt" >expect &&
echo "$ttt$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt" >expect &&
echo "$ttt$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt" >expect &&
echo "$ttt$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt" >expect &&
echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$ttt$ttt$ttt" >expect &&
echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
# spaces only:
@@ -324,28 +324,28 @@ test_expect_success \
printf "" >expect &&
echo | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "$sss$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
-test_expect_failure \
+test_expect_success \
'spaces without newline at end should not show spaces' '
- printf "" | git stripspace | grep -q " " ||
- printf "$sss" | git stripspace | grep -q " " ||
- printf "$sss$sss" | git stripspace | grep -q " " ||
- printf "$sss$sss$sss" | git stripspace | grep -q " " ||
- printf "$sss$sss$sss$sss" | git stripspace | grep -q " "
+ ! (printf "" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
+ ! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
'
test_expect_success \
@@ -353,43 +353,43 @@ test_expect_success \
printf "" >expect &&
printf "" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$sss$sss$sss$sss" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'consecutive text lines should be unchanged' '
printf "$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect &&
printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect &&
printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect &&
printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect &&
printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success 'strip comments, too' '
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 462fdf262..e38241c80 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -11,51 +11,91 @@ cat > expect.err << EOF
usage: test-parse-options <options>
-b, --boolean get a boolean
+ -4, --or4 bitwise-or boolean with ...0100
+
-i, --integer <n> get a integer
-j <n> get a integer, too
+ --set23 set integer to 23
+ -t <time> get timestamp of <time>
+ -L, --length <str> get length of <str>
-string options
+String options
-s, --string <string>
get a string
--string2 <str> get another string
--st <st> get another string (pervert ordering)
+ -o <str> get another string
+ --default-string set string to default
+
+Magic arguments
+ --quux means --quux
+
+Standard options
+ --abbrev[=<n>] use <n> digits to display SHA-1s
+ -v, --verbose be verbose
+ -n, --dry-run dry run
+ -q, --quiet be quiet
EOF
test_expect_success 'test help' '
- ! test-parse-options -h > output 2> output.err &&
+ test_must_fail test-parse-options -h > output 2> output.err &&
test ! -s output &&
- git diff expect.err output.err
+ test_cmp expect.err output.err
'
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 123
+abbrev: 7
+verbose: 2
+quiet: no
+dry run: yes
EOF
test_expect_success 'short options' '
- test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
- git diff expect output &&
+ test-parse-options -s123 -b -i 1729 -b -vv -n > output 2> output.err &&
+ test_cmp expect output &&
test ! -s output.err
'
+
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 321
+abbrev: 10
+verbose: 2
+quiet: no
+dry run: no
EOF
test_expect_success 'long options' '
test-parse-options --boolean --integer 1729 --boolean --string2=321 \
+ --verbose --verbose --no-dry-run --abbrev=10 \
> output 2> output.err &&
test ! -s output.err &&
- git diff expect output
+ test_cmp expect output
+'
+
+test_expect_success 'missing required value' '
+ test-parse-options -s;
+ test $? = 129 &&
+ test-parse-options --string;
+ test $? = 129
'
cat > expect << EOF
boolean: 1
integer: 13
+timestamp: 0
string: 123
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
arg 00: a1
arg 01: b1
arg 02: --boolean
@@ -65,42 +105,147 @@ test_expect_success 'intermingled arguments' '
test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
> output 2> output.err &&
test ! -s output.err &&
- git diff expect output
+ test_cmp expect output
'
cat > expect << EOF
boolean: 0
integer: 2
+timestamp: 0
string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
EOF
test_expect_success 'unambiguously abbreviated option' '
test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
test ! -s output.err &&
- git diff expect output
+ test_cmp expect output
'
test_expect_success 'unambiguously abbreviated option with "="' '
test-parse-options --int=2 > output 2> output.err &&
test ! -s output.err &&
- git diff expect output
+ test_cmp expect output
'
-test_expect_failure 'ambiguously abbreviated option' '
+test_expect_success 'ambiguously abbreviated option' '
test-parse-options --strin 123;
- test $? != 129
+ test $? = 129
'
cat > expect << EOF
boolean: 0
integer: 0
+timestamp: 0
string: 123
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
EOF
test_expect_success 'non ambiguous option (after two options it abbreviates)' '
test-parse-options --st 123 > output 2> output.err &&
test ! -s output.err &&
- git diff expect output
+ test_cmp expect output
+'
+
+cat > typo.err << EOF
+error: did you mean \`--boolean\` (with two dashes ?)
+EOF
+
+test_expect_success 'detect possible typos' '
+ test_must_fail test-parse-options -boolean > output 2> output.err &&
+ test ! -s output &&
+ test_cmp typo.err output.err
'
+cat > expect <<EOF
+boolean: 0
+integer: 0
+timestamp: 0
+string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
+arg 00: --quux
+EOF
+
+test_expect_success 'keep some options as arguments' '
+ test-parse-options --quux > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+boolean: 0
+integer: 0
+timestamp: 1
+string: default
+abbrev: 7
+verbose: 0
+quiet: yes
+dry run: no
+arg 00: foo
+EOF
+
+test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
+ test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
+ foo -q > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+Callback: "four", 0
+boolean: 5
+integer: 4
+timestamp: 0
+string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
+EOF
+
+test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
+ test-parse-options --length=four -b -4 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+Callback: "not set", 1
+EOF
+
+test_expect_success 'OPT_CALLBACK() and callback errors work' '
+ test_must_fail test-parse-options --no-length > output 2> output.err &&
+ test_cmp expect output &&
+ test_cmp expect.err output.err
+'
+
+cat > expect <<EOF
+boolean: 1
+integer: 23
+timestamp: 0
+string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
+EOF
+
+test_expect_success 'OPT_BIT() and OPT_SET_INT() work' '
+ test-parse-options --set23 -bbbbb --no-or4 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+# --or4
+# --no-or4
+
test_done
diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
new file mode 100755
index 000000000..b177174ef
--- /dev/null
+++ b/t/t0050-filesystem.sh
@@ -0,0 +1,122 @@
+#!/bin/sh
+
+test_description='Various filesystem issues'
+
+. ./test-lib.sh
+
+auml=`printf '\xc3\xa4'`
+aumlcdiar=`printf '\x61\xcc\x88'`
+
+case_insensitive=
+test_expect_success 'see if we expect ' '
+
+ test_case=test_expect_success
+ test_unicode=test_expect_success
+ mkdir junk &&
+ echo good >junk/CamelCase &&
+ echo bad >junk/camelcase &&
+ if test "$(cat junk/CamelCase)" != good
+ then
+ test_case=test_expect_failure
+ case_insensitive=t
+ say "will test on a case insensitive filesystem"
+ fi &&
+ rm -fr junk &&
+ mkdir junk &&
+ >junk/"$auml" &&
+ case "$(cd junk && echo *)" in
+ "$aumlcdiar")
+ test_unicode=test_expect_failure
+ say "will test on a unicode corrupting filesystem"
+ ;;
+ *) ;;
+ esac &&
+ rm -fr junk
+'
+
+if test "$case_insensitive"
+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
+'
+fi
+
+test_expect_success "setup case tests" '
+
+ git config core.ignorecase true &&
+ touch camelcase &&
+ git add camelcase &&
+ git commit -m "initial" &&
+ git tag initial &&
+ git checkout -b topic &&
+ git mv camelcase tmp &&
+ 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)' '
+
+ rm -f CamelCase &&
+ rm -f camelcase &&
+ git reset --hard initial &&
+ git merge topic
+
+'
+
+$test_case 'add (with different case)' '
+
+ git reset --hard initial &&
+ rm camelcase &&
+ echo 1 >CamelCase &&
+ git add CamelCase &&
+ test $(git-ls-files | grep -i camelcase | wc -l) = 1
+
+'
+
+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_unicode 'rename (silent unicode normalization)' '
+
+ git mv "$aumlcdiar" "$auml" &&
+ git commit -m rename
+
+'
+
+$test_unicode 'merge (silent unicode normalization)' '
+
+ git reset --hard initial &&
+ git merge topic
+
+'
+
+test_done
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
new file mode 100755
index 000000000..6e7501f35
--- /dev/null
+++ b/t/t0060-path-utils.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 David Reiss
+#
+
+test_description='Test various path utilities'
+
+. ./test-lib.sh
+
+norm_abs() {
+ test_expect_success "normalize absolute" \
+ "test \$(test-path-utils normalize_absolute_path '$1') = '$2'"
+}
+
+ancestor() {
+ test_expect_success "longest ancestor" \
+ "test \$(test-path-utils longest_ancestor_length '$1' '$2') = '$3'"
+}
+
+norm_abs "" /
+norm_abs / /
+norm_abs // /
+norm_abs /// /
+norm_abs /. /
+norm_abs /./ /
+norm_abs /./.. /
+norm_abs /../. /
+norm_abs /./../.// /
+norm_abs /dir/.. /
+norm_abs /dir/sub/../.. /
+norm_abs /dir /dir
+norm_abs /dir// /dir
+norm_abs /./dir /dir
+norm_abs /dir/. /dir
+norm_abs /dir///./ /dir
+norm_abs /dir//sub/.. /dir
+norm_abs /dir/sub/../ /dir
+norm_abs //dir/sub/../. /dir
+norm_abs /dir/s1/../s2/ /dir/s2
+norm_abs /d1/s1///s2/..//../s3/ /d1/s3
+norm_abs /d1/s1//../s2/../../d2 /d2
+norm_abs /d1/.../d2 /d1/.../d2
+norm_abs /d1/..././../d2 /d1/d2
+
+ancestor / "" -1
+ancestor / / -1
+ancestor /foo "" -1
+ancestor /foo : -1
+ancestor /foo ::. -1
+ancestor /foo ::..:: -1
+ancestor /foo / 0
+ancestor /foo /fo -1
+ancestor /foo /foo -1
+ancestor /foo /foo/ -1
+ancestor /foo /bar -1
+ancestor /foo /bar/ -1
+ancestor /foo /foo/bar -1
+ancestor /foo /foo:/bar/ -1
+ancestor /foo /foo/:/bar/ -1
+ancestor /foo /foo::/bar/ -1
+ancestor /foo /:/foo:/bar/ 0
+ancestor /foo /foo:/:/bar/ 0
+ancestor /foo /:/bar/:/foo 0
+ancestor /foo/bar "" -1
+ancestor /foo/bar / 0
+ancestor /foo/bar /fo -1
+ancestor /foo/bar foo -1
+ancestor /foo/bar /foo 4
+ancestor /foo/bar /foo/ 4
+ancestor /foo/bar /foo/ba -1
+ancestor /foo/bar /:/fo 0
+ancestor /foo/bar /foo:/foo/ba 4
+ancestor /foo/bar /bar -1
+ancestor /foo/bar /bar/ -1
+ancestor /foo/bar /fo: -1
+ancestor /foo/bar :/fo -1
+ancestor /foo/bar /foo:/bar/ 4
+ancestor /foo/bar /:/foo:/bar/ 4
+ancestor /foo/bar /foo:/:/bar/ 4
+ancestor /foo/bar /:/bar/:/fo 0
+ancestor /foo/bar /:/bar/ 0
+ancestor /foo/bar :://foo/. 4
+ancestor /foo/bar :://foo/.:: 4
+ancestor /foo/bar //foo/./::/bar 4
+ancestor /foo/bar ::/bar -1
+
+test_done
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
index 37add1b50..807fb83af 100755
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
check_result () {
git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
- git diff expected current
+ test_cmp expected current
}
# This is done on an empty work directory, which is the normal
@@ -210,12 +210,12 @@ DF (file) when tree B require DF to be a directory by having DF/DF
END_OF_CASE_TABLE
-test_expect_failure \
- '1 - must not have an entry not in A.' \
- "rm -f .git/index XX &&
+test_expect_success '1 - must not have an entry not in A.' "
+ rm -f .git/index XX &&
echo XX >XX &&
git update-index --add XX &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'2 - must match B in !O && !A && B case.' \
@@ -248,13 +248,14 @@ test_expect_success \
echo extra >>AN &&
git read-tree -m $tree_O $tree_A $tree_B"
-test_expect_failure \
- '3 (fail) - must match A in !O && A && !B case.' \
- "rm -f .git/index AN &&
+test_expect_success \
+ '3 (fail) - must match A in !O && A && !B case.' "
+ rm -f .git/index AN &&
cp .orig-A/AN AN &&
echo extra >>AN &&
git update-index --add AN &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'4 - must match and be up-to-date in !O && A && B && A!=B case.' \
@@ -264,21 +265,23 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
- "rm -f .git/index AA &&
+test_expect_success \
+ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' "
+ rm -f .git/index AA &&
cp .orig-A/AA AA &&
git update-index --add AA &&
echo extra >>AA &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' \
- "rm -f .git/index AA &&
+test_expect_success \
+ '4 (fail) - must match and be up-to-date in !O && A && B && A!=B case.' "
+ rm -f .git/index AA &&
cp .orig-A/AA AA &&
echo extra >>AA &&
git update-index --add AA &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'5 - must match in !O && A && B && A==B case.' \
@@ -297,34 +300,38 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '5 (fail) - must match A in !O && A && B && A==B case.' \
- "rm -f .git/index LL &&
+test_expect_success \
+ '5 (fail) - must match A in !O && A && B && A==B case.' "
+ rm -f .git/index LL &&
cp .orig-A/LL LL &&
echo extra >>LL &&
git update-index --add LL &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '6 - must not exist in O && !A && !B case' \
- "rm -f .git/index DD &&
+test_expect_success \
+ '6 - must not exist in O && !A && !B case' "
+ rm -f .git/index DD &&
echo DD >DD
git update-index --add DD &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '7 - must not exist in O && !A && B && O!=B case' \
- "rm -f .git/index DM &&
+test_expect_success \
+ '7 - must not exist in O && !A && B && O!=B case' "
+ rm -f .git/index DM &&
cp .orig-B/DM DM &&
git update-index --add DM &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '8 - must not exist in O && !A && B && O==B case' \
- "rm -f .git/index DN &&
+test_expect_success \
+ '8 - must not exist in O && !A && B && O==B case' "
+ rm -f .git/index DN &&
cp .orig-B/DN DN &&
git update-index --add DN &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'9 - must match and be up-to-date in O && A && !B && O!=A case' \
@@ -334,21 +341,23 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
- "rm -f .git/index MD &&
+test_expect_success \
+ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' "
+ rm -f .git/index MD &&
cp .orig-A/MD MD &&
git update-index --add MD &&
echo extra >>MD &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' \
- "rm -f .git/index MD &&
+test_expect_success \
+ '9 (fail) - must match and be up-to-date in O && A && !B && O!=A case' "
+ rm -f .git/index MD &&
cp .orig-A/MD MD &&
echo extra >>MD &&
git update-index --add MD &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'10 - must match and be up-to-date in O && A && !B && O==A case' \
@@ -358,21 +367,23 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
- "rm -f .git/index ND &&
+test_expect_success \
+ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' "
+ rm -f .git/index ND &&
cp .orig-A/ND ND &&
git update-index --add ND &&
echo extra >>ND &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' \
- "rm -f .git/index ND &&
+test_expect_success \
+ '10 (fail) - must match and be up-to-date in O && A && !B && O==A case' "
+ rm -f .git/index ND &&
cp .orig-A/ND ND &&
echo extra >>ND &&
git update-index --add ND &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'11 - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
@@ -382,21 +393,23 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
- "rm -f .git/index MM &&
+test_expect_success \
+ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' "
+ rm -f .git/index MM &&
cp .orig-A/MM MM &&
git update-index --add MM &&
echo extra >>MM &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' \
- "rm -f .git/index MM &&
+test_expect_success \
+ '11 (fail) - must match and be up-to-date in O && A && B && O!=A && O!=B && A!=B case' "
+ rm -f .git/index MM &&
cp .orig-A/MM MM &&
echo extra >>MM &&
git update-index --add MM &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'12 - must match A in O && A && B && O!=A && A==B case' \
@@ -415,13 +428,14 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '12 (fail) - must match A in O && A && B && O!=A && A==B case' \
- "rm -f .git/index SS &&
+test_expect_success \
+ '12 (fail) - must match A in O && A && B && O!=A && A==B case' "
+ rm -f .git/index SS &&
cp .orig-A/SS SS &&
echo extra >>SS &&
git update-index --add SS &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'13 - must match A in O && A && B && O!=A && O==B case' \
@@ -457,21 +471,23 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
- "rm -f .git/index NM &&
+test_expect_success \
+ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' "
+ rm -f .git/index NM &&
cp .orig-A/NM NM &&
git update-index --add NM &&
echo extra >>NM &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
-test_expect_failure \
- '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' \
- "rm -f .git/index NM &&
+test_expect_success \
+ '14 (fail) - must match and be up-to-date in O && A && B && O==A && O!=B case' "
+ rm -f .git/index NM &&
cp .orig-A/NM NM &&
echo extra >>NM &&
git update-index --add NM &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
test_expect_success \
'15 - must match A in O && A && B && O==A && O==B case' \
@@ -490,13 +506,14 @@ test_expect_success \
git read-tree -m $tree_O $tree_A $tree_B &&
check_result"
-test_expect_failure \
- '15 (fail) - must match A in O && A && B && O==A && O==B case' \
- "rm -f .git/index NN &&
+test_expect_success \
+ '15 (fail) - must match A in O && A && B && O==A && O==B case' "
+ rm -f .git/index NN &&
cp .orig-A/NN NN &&
echo extra >>NN &&
git update-index --add NN &&
- git read-tree -m $tree_O $tree_A $tree_B"
+ test_must_fail git read-tree -m $tree_O $tree_A $tree_B
+"
# #16
test_expect_success \
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index b01b0037a..4b44e131b 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -33,7 +33,7 @@ compare_change () {
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
"$1"
- git diff expected current
+ test_cmp expected current
}
check_cache_at () {
@@ -86,7 +86,7 @@ test_expect_success \
'rm -f .git/index &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >1-3.out &&
- git diff M.out 1-3.out &&
+ test_cmp M.out 1-3.out &&
check_cache_at bozbar dirty &&
check_cache_at frotz dirty &&
check_cache_at nitfol dirty'
@@ -101,7 +101,7 @@ test_expect_success \
git update-index --add yomin &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >4.out || return 1
- git diff M.out 4.out >4diff.out
+ git diff --no-index M.out 4.out >4diff.out
compare_change 4diff.out expected &&
check_cache_at yomin clean'
@@ -115,7 +115,7 @@ test_expect_success \
echo yomin yomin >yomin &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >5.out || return 1
- git diff M.out 5.out >5diff.out
+ git diff --no-index M.out 5.out >5diff.out
compare_change 5diff.out expected &&
check_cache_at yomin dirty'
@@ -127,7 +127,7 @@ test_expect_success \
git update-index --add frotz &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >6.out &&
- git diff M.out 6.out &&
+ test_cmp M.out 6.out &&
check_cache_at frotz clean'
test_expect_success \
@@ -140,7 +140,7 @@ test_expect_success \
echo frotz frotz >frotz &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >7.out &&
- git diff M.out 7.out &&
+ test_cmp M.out 7.out &&
check_cache_at frotz dirty'
test_expect_success \
@@ -171,7 +171,7 @@ test_expect_success \
git update-index --add rezrov &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >10.out &&
- git diff M.out 10.out'
+ test_cmp M.out 10.out'
test_expect_success \
'11 - dirty path removed.' \
@@ -216,7 +216,7 @@ test_expect_success \
git update-index --add nitfol &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >14.out || return 1
- git diff M.out 14.out >14diff.out
+ git diff --no-index M.out 14.out >14diff.out
compare_change 14diff.out expected &&
check_cache_at nitfol clean'
@@ -230,7 +230,7 @@ test_expect_success \
echo nitfol nitfol nitfol >nitfol &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >15.out || return 1
- git diff M.out 15.out >15diff.out
+ git diff --no-index M.out 15.out >15diff.out
compare_change 15diff.out expected &&
check_cache_at nitfol dirty'
@@ -262,7 +262,7 @@ test_expect_success \
git update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >18.out &&
- git diff M.out 18.out &&
+ test_cmp M.out 18.out &&
check_cache_at bozbar clean'
test_expect_success \
@@ -275,7 +275,7 @@ test_expect_success \
echo gnusto gnusto >bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >19.out &&
- git diff M.out 19.out &&
+ test_cmp M.out 19.out &&
check_cache_at bozbar dirty'
test_expect_success \
@@ -287,7 +287,7 @@ test_expect_success \
git update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git ls-files --stage >20.out &&
- git diff M.out 20.out &&
+ test_cmp M.out 20.out &&
check_cache_at bozbar dirty'
test_expect_success \
@@ -337,7 +337,7 @@ test_expect_success \
git update-index --add DF &&
read_tree_twoway $treeDF $treeDFDF &&
git ls-files --stage >DFDFcheck.out &&
- git diff DFDF.out DFDFcheck.out &&
+ test_cmp DFDF.out DFDFcheck.out &&
check_cache_at DF/DF dirty &&
:'
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index 42e5cf818..aa9dd580a 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -16,7 +16,7 @@ compare_change () {
sed >current \
-e '/^--- /d; /^+++ /d; /^@@ /d;' \
-e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
- git diff expected current
+ test_cmp expected current
}
check_cache_at () {
@@ -112,7 +112,7 @@ test_expect_success \
git update-index --add frotz &&
git read-tree -m -u $treeH $treeM &&
git ls-files --stage >6.out &&
- diff -U0 M.out 6.out &&
+ test_cmp M.out 6.out &&
check_cache_at frotz clean &&
sum bozbar frotz nitfol >actual3.sum &&
cmp M.sum actual3.sum &&
@@ -129,7 +129,7 @@ test_expect_success \
echo frotz frotz >frotz &&
git read-tree -m -u $treeH $treeM &&
git ls-files --stage >7.out &&
- diff -U0 M.out 7.out &&
+ test_cmp M.out 7.out &&
check_cache_at frotz dirty &&
sum bozbar frotz nitfol >actual7.sum &&
if cmp M.sum actual7.sum; then false; else :; fi &&
@@ -264,7 +264,7 @@ test_expect_success \
git update-index --add bozbar &&
git read-tree -m -u $treeH $treeM &&
git ls-files --stage >18.out &&
- diff -U0 M.out 18.out &&
+ test_cmp M.out 18.out &&
check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual18.sum &&
cmp M.sum actual18.sum'
@@ -278,7 +278,7 @@ test_expect_success \
echo gnusto gnusto >bozbar &&
git read-tree -m -u $treeH $treeM &&
git ls-files --stage >19.out &&
- diff -U0 M.out 19.out &&
+ test_cmp M.out 19.out &&
check_cache_at bozbar dirty &&
sum frotz nitfol >actual19.sum &&
grep -v bozbar M.sum > expected19.sum &&
@@ -297,7 +297,7 @@ test_expect_success \
git update-index --add bozbar &&
git read-tree -m -u $treeH $treeM &&
git ls-files --stage >20.out &&
- diff -U0 M.out 20.out &&
+ test_cmp M.out 20.out &&
check_cache_at bozbar clean &&
sum bozbar frotz nitfol >actual20.sum &&
cmp M.sum actual20.sum'
@@ -338,7 +338,7 @@ test_expect_success \
git update-index --add DF &&
git read-tree -m -u $treeDF $treeDFDF &&
git ls-files --stage >DFDFcheck.out &&
- diff -U0 DFDF.out DFDFcheck.out &&
+ test_cmp DFDF.out DFDFcheck.out &&
check_cache_at DF/DF clean'
test_done
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index d609a551a..570d3729b 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -116,4 +116,126 @@ test_expect_success 'three-way not complaining on an untracked file' '
git read-tree -m -u --exclude-per-directory=.gitignore branch-point master side
'
+test_expect_success '3-way not overwriting local changes (setup)' '
+
+ git reset --hard &&
+ git checkout -b side-a branch-point &&
+ echo >>file1 "new line to be kept in the merge result" &&
+ git commit -a -m "side-a changes file1" &&
+ git checkout -b side-b branch-point &&
+ echo >>file2 "new line to be kept in the merge result" &&
+ git commit -a -m "side-b changes file2" &&
+ git checkout side-a
+
+'
+
+test_expect_success '3-way not overwriting local changes (our side)' '
+
+ # At this point, file1 from side-a should be kept as side-b
+ # did not touch it.
+
+ git reset --hard &&
+
+ echo >>file1 "local changes" &&
+ git read-tree -m -u branch-point side-a side-b &&
+ grep "new line to be kept" file1 &&
+ grep "local changes" file1
+
+'
+
+test_expect_success '3-way not overwriting local changes (their side)' '
+
+ # At this point, file2 from side-b should be taken as side-a
+ # did not touch it.
+
+ git reset --hard &&
+
+ echo >>file2 "local changes" &&
+ test_must_fail git read-tree -m -u branch-point side-a side-b &&
+ ! grep "new line to be kept" file2 &&
+ grep "local changes" file2
+
+'
+
+test_expect_success 'funny symlink in work tree' '
+
+ git reset --hard &&
+ git checkout -b sym-b side-b &&
+ mkdir -p a &&
+ >a/b &&
+ git add a/b &&
+ git commit -m "side adds a/b" &&
+
+ rm -fr a &&
+ git checkout -b sym-a side-a &&
+ mkdir -p a &&
+ ln -s ../b a/b &&
+ git add a/b &&
+ git commit -m "we add a/b" &&
+
+ git read-tree -m -u sym-a sym-a sym-b
+
+'
+
+test_expect_success 'funny symlink in work tree, un-unlink-able' '
+
+ rm -fr a b &&
+ git reset --hard &&
+
+ git checkout sym-a &&
+ chmod a-w a &&
+ test_must_fail git read-tree -m -u sym-a sym-a sym-b
+
+'
+
+# clean-up from the above test
+chmod a+w a
+rm -fr a b
+
+test_expect_success 'D/F setup' '
+
+ git reset --hard &&
+
+ git checkout side-a &&
+ rm -f subdir/file2 &&
+ mkdir subdir/file2 &&
+ echo qfwfq >subdir/file2/another &&
+ git add subdir/file2/another &&
+ test_tick &&
+ git commit -m "side-a changes file2 to directory"
+
+'
+
+test_expect_success 'D/F' '
+
+ git checkout side-b &&
+ git read-tree -m -u branch-point side-b side-a &&
+ git ls-files -u >actual &&
+ (
+ a=$(git rev-parse branch-point:subdir/file2)
+ b=$(git rev-parse side-a:subdir/file2/another)
+ echo "100644 $a 1 subdir/file2"
+ echo "100644 $a 2 subdir/file2"
+ echo "100644 $b 3 subdir/file2/another"
+ ) >expect &&
+ test_cmp actual expect
+
+'
+
+test_expect_success 'D/F resolve' '
+
+ git reset --hard &&
+ git checkout side-b &&
+ git merge-resolve branch-point -- side-b side-a
+
+'
+
+test_expect_success 'D/F recursive' '
+
+ git reset --hard &&
+ git checkout side-b &&
+ git merge-recursive branch-point -- side-b side-a
+
+'
+
test_done
diff --git a/t/t1005-read-tree-reset.sh b/t/t1005-read-tree-reset.sh
new file mode 100755
index 000000000..b0d31f5a9
--- /dev/null
+++ b/t/t1005-read-tree-reset.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='read-tree -u --reset'
+
+. ./test-lib.sh
+
+# two-tree test
+
+test_expect_success 'setup' '
+ git init &&
+ mkdir df &&
+ echo content >df/file &&
+ git add df/file &&
+ git commit -m one &&
+ git ls-files >expect &&
+ rm -rf df &&
+ echo content >df &&
+ git add df &&
+ echo content >new &&
+ git add new &&
+ git commit -m two
+'
+
+test_expect_success 'reset should work' '
+ git read-tree -u --reset HEAD^ &&
+ git ls-files >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
new file mode 100755
index 000000000..d8b7f2ffb
--- /dev/null
+++ b/t/t1006-cat-file.sh
@@ -0,0 +1,244 @@
+#!/bin/sh
+
+test_description='git cat-file'
+
+. ./test-lib.sh
+
+echo_without_newline () {
+ printf '%s' "$*"
+}
+
+strlen () {
+ echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
+}
+
+maybe_remove_timestamp () {
+ if test -z "$2"; then
+ echo_without_newline "$1"
+ else
+ echo_without_newline "$(printf '%s\n' "$1" | sed -e 's/ [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$//')"
+ fi
+}
+
+run_tests () {
+ type=$1
+ sha1=$2
+ size=$3
+ content=$4
+ pretty_content=$5
+ no_ts=$6
+
+ batch_output="$sha1 $type $size
+$content"
+
+ test_expect_success "$type exists" '
+ git cat-file -e $sha1
+ '
+
+ test_expect_success "Type of $type is correct" '
+ test $type = "$(git cat-file -t $sha1)"
+ '
+
+ test_expect_success "Size of $type is correct" '
+ test $size = "$(git cat-file -s $sha1)"
+ '
+
+ test -z "$content" ||
+ test_expect_success "Content of $type is correct" '
+ expect="$(maybe_remove_timestamp "$content" $no_ts)"
+ actual="$(maybe_remove_timestamp "$(git cat-file $type $sha1)" $no_ts)"
+
+ if test "z$expect" = "z$actual"
+ then
+ : happy
+ else
+ echo "Oops: expected $expect"
+ echo "but got $actual"
+ false
+ fi
+ '
+
+ test_expect_success "Pretty content of $type is correct" '
+ expect="$(maybe_remove_timestamp "$pretty_content" $no_ts)"
+ actual="$(maybe_remove_timestamp "$(git cat-file -p $sha1)" $no_ts)"
+ if test "z$expect" = "z$actual"
+ then
+ : happy
+ else
+ echo "Oops: expected $expect"
+ echo "but got $actual"
+ false
+ fi
+ '
+
+ test -z "$content" ||
+ test_expect_success "--batch output of $type is correct" '
+ expect="$(maybe_remove_timestamp "$batch_output" $no_ts)"
+ actual="$(maybe_remove_timestamp "$(echo $sha1 | git cat-file --batch)" $no_ts)"
+ if test "z$expect" = "z$actual"
+ then
+ : happy
+ else
+ echo "Oops: expected $expect"
+ echo "but got $actual"
+ false
+ fi
+ '
+
+ test_expect_success "--batch-check output of $type is correct" '
+ expect="$sha1 $type $size"
+ actual="$(echo_without_newline $sha1 | git cat-file --batch-check)"
+ if test "z$expect" = "z$actual"
+ then
+ : happy
+ else
+ echo "Oops: expected $expect"
+ echo "but got $actual"
+ false
+ fi
+ '
+}
+
+hello_content="Hello World"
+hello_size=$(strlen "$hello_content")
+hello_sha1=$(echo_without_newline "$hello_content" | git hash-object --stdin)
+
+test_expect_success "setup" '
+ echo_without_newline "$hello_content" > hello &&
+ git update-index --add hello
+'
+
+run_tests 'blob' $hello_sha1 $hello_size "$hello_content" "$hello_content"
+
+tree_sha1=$(git write-tree)
+tree_size=33
+tree_pretty_content="100644 blob $hello_sha1 hello"
+
+run_tests 'tree' $tree_sha1 $tree_size "" "$tree_pretty_content"
+
+commit_message="Intial commit"
+commit_sha1=$(echo_without_newline "$commit_message" | git commit-tree $tree_sha1)
+commit_size=176
+commit_content="tree $tree_sha1
+author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 0000000000 +0000
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 0000000000 +0000
+
+$commit_message"
+
+run_tests 'commit' $commit_sha1 $commit_size "$commit_content" "$commit_content" 1
+
+tag_header_without_timestamp="object $hello_sha1
+type blob
+tag hellotag
+tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+tag_description="This is a tag"
+tag_content="$tag_header_without_timestamp 0000000000 +0000
+
+$tag_description"
+tag_pretty_content="$tag_header_without_timestamp Thu Jan 1 00:00:00 1970 +0000
+
+$tag_description"
+
+tag_sha1=$(echo_without_newline "$tag_content" | git mktag)
+tag_size=$(strlen "$tag_content")
+
+run_tests 'tag' $tag_sha1 $tag_size "$tag_content" "$tag_pretty_content" 1
+
+test_expect_success \
+ "Reach a blob from a tag pointing to it" \
+ "test '$hello_content' = \"\$(git cat-file blob $tag_sha1)\""
+
+for batch in batch batch-check
+do
+ for opt in t s e p
+ do
+ test_expect_success "Passing -$opt with --$batch fails" '
+ test_must_fail git cat-file --$batch -$opt $hello_sha1
+ '
+
+ test_expect_success "Passing --$batch with -$opt fails" '
+ test_must_fail git cat-file -$opt --$batch $hello_sha1
+ '
+ done
+
+ test_expect_success "Passing <type> with --$batch fails" '
+ test_must_fail git cat-file --$batch blob $hello_sha1
+ '
+
+ test_expect_success "Passing --$batch with <type> fails" '
+ test_must_fail git cat-file blob --$batch $hello_sha1
+ '
+
+ test_expect_success "Passing sha1 with --$batch fails" '
+ test_must_fail git cat-file --$batch $hello_sha1
+ '
+done
+
+test_expect_success "--batch-check for a non-existent named object" '
+ test "foobar42 missing
+foobar84 missing" = \
+ "$( ( echo foobar42; echo_without_newline foobar84; ) | git cat-file --batch-check)"
+'
+
+test_expect_success "--batch-check for a non-existent hash" '
+ test "0000000000000000000000000000000000000042 missing
+0000000000000000000000000000000000000084 missing" = \
+ "$( ( echo 0000000000000000000000000000000000000042;
+ echo_without_newline 0000000000000000000000000000000000000084; ) \
+ | git cat-file --batch-check)"
+'
+
+test_expect_success "--batch for an existent and a non-existent hash" '
+ test "$tag_sha1 tag $tag_size
+$tag_content
+0000000000000000000000000000000000000000 missing" = \
+ "$( ( echo $tag_sha1;
+ echo_without_newline 0000000000000000000000000000000000000000; ) \
+ | git cat-file --batch)"
+'
+
+test_expect_success "--batch-check for an emtpy line" '
+ test " missing" = "$(echo | git cat-file --batch-check)"
+'
+
+batch_input="$hello_sha1
+$commit_sha1
+$tag_sha1
+deadbeef
+
+"
+
+batch_output="$hello_sha1 blob $hello_size
+$hello_content
+$commit_sha1 commit $commit_size
+$commit_content
+$tag_sha1 tag $tag_size
+$tag_content
+deadbeef missing
+ missing"
+
+test_expect_success '--batch with multiple sha1s gives correct format' '
+ test "$(maybe_remove_timestamp "$batch_output" 1)" = "$(maybe_remove_timestamp "$(echo_without_newline "$batch_input" | git cat-file --batch)" 1)"
+'
+
+batch_check_input="$hello_sha1
+$tree_sha1
+$commit_sha1
+$tag_sha1
+deadbeef
+
+"
+
+batch_check_output="$hello_sha1 blob $hello_size
+$tree_sha1 tree $tree_size
+$commit_sha1 commit $commit_size
+$tag_sha1 tag $tag_size
+deadbeef missing
+ missing"
+
+test_expect_success "--batch-check with multiple sha1s gives correct format" '
+ test "$batch_check_output" = \
+ "$(echo_without_newline "$batch_check_input" | git cat-file --batch-check)"
+'
+
+test_done
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
new file mode 100755
index 000000000..1ec053513
--- /dev/null
+++ b/t/t1007-hash-object.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+test_description="git-hash-object"
+
+. ./test-lib.sh
+
+echo_without_newline() {
+ printf '%s' "$*"
+}
+
+test_blob_does_not_exist() {
+ test_expect_success 'blob does not exist in database' "
+ test_must_fail git cat-file blob $1
+ "
+}
+
+test_blob_exists() {
+ test_expect_success 'blob exists in database' "
+ git cat-file blob $1
+ "
+}
+
+hello_content="Hello World"
+hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
+
+example_content="This is an example"
+example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399
+
+setup_repo() {
+ echo_without_newline "$hello_content" > hello
+ echo_without_newline "$example_content" > example
+}
+
+test_repo=test
+push_repo() {
+ test_create_repo $test_repo
+ cd $test_repo
+
+ setup_repo
+}
+
+pop_repo() {
+ cd ..
+ rm -rf $test_repo
+}
+
+setup_repo
+
+# Argument checking
+
+test_expect_success "multiple '--stdin's are rejected" '
+ test_must_fail git hash-object --stdin --stdin < example
+'
+
+test_expect_success "Can't use --stdin and --stdin-paths together" '
+ test_must_fail git hash-object --stdin --stdin-paths &&
+ test_must_fail git hash-object --stdin-paths --stdin
+'
+
+test_expect_success "Can't pass filenames as arguments with --stdin-paths" '
+ test_must_fail git hash-object --stdin-paths hello < example
+'
+
+# Behavior
+
+push_repo
+
+test_expect_success 'hash a file' '
+ test $hello_sha1 = $(git hash-object hello)
+'
+
+test_blob_does_not_exist $hello_sha1
+
+test_expect_success 'hash from stdin' '
+ test $example_sha1 = $(git hash-object --stdin < example)
+'
+
+test_blob_does_not_exist $example_sha1
+
+test_expect_success 'hash a file and write to database' '
+ test $hello_sha1 = $(git hash-object -w hello)
+'
+
+test_blob_exists $hello_sha1
+
+test_expect_success 'git hash-object --stdin file1 <file0 first operates on file0, then file1' '
+ echo foo > file1 &&
+ obname0=$(echo bar | git hash-object --stdin) &&
+ obname1=$(git hash-object file1) &&
+ obname0new=$(echo bar | git hash-object --stdin file1 | sed -n -e 1p) &&
+ obname1new=$(echo bar | git hash-object --stdin file1 | sed -n -e 2p) &&
+ test "$obname0" = "$obname0new" &&
+ test "$obname1" = "$obname1new"
+'
+
+pop_repo
+
+for args in "-w --stdin" "--stdin -w"; do
+ push_repo
+
+ test_expect_success "hash from stdin and write to database ($args)" '
+ test $example_sha1 = $(git hash-object $args < example)
+ '
+
+ test_blob_exists $example_sha1
+
+ pop_repo
+done
+
+filenames="hello
+example"
+
+sha1s="$hello_sha1
+$example_sha1"
+
+test_expect_success "hash two files with names on stdin" '
+ test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
+'
+
+for args in "-w --stdin-paths" "--stdin-paths -w"; do
+ push_repo
+
+ test_expect_success "hash two files with names on stdin and write to database ($args)" '
+ test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object $args)"
+ '
+
+ test_blob_exists $hello_sha1
+ test_blob_exists $example_sha1
+
+ pop_repo
+done
+
+test_done
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index b9cef3422..fc386ba03 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -21,7 +21,7 @@ LF='
'
test_expect_success 'update-index and ls-files' '
- cd $HERE &&
+ cd "$HERE" &&
git update-index --add one &&
case "`git ls-files`" in
one) echo ok one ;;
@@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' '
'
test_expect_success 'cat-file' '
- cd $HERE &&
+ cd "$HERE" &&
two=`git ls-files -s dir/two` &&
two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
echo "$two" &&
@@ -54,7 +54,7 @@ test_expect_success 'cat-file' '
rm -f actual dir/actual
test_expect_success 'diff-files' '
- cd $HERE &&
+ cd "$HERE" &&
echo a >>one &&
echo d >>dir/two &&
case "`git diff-files --name-only`" in
@@ -74,7 +74,7 @@ test_expect_success 'diff-files' '
'
test_expect_success 'write-tree' '
- cd $HERE &&
+ cd "$HERE" &&
top=`git write-tree` &&
echo $top &&
cd dir &&
@@ -84,7 +84,7 @@ test_expect_success 'write-tree' '
'
test_expect_success 'checkout-index' '
- cd $HERE &&
+ cd "$HERE" &&
git checkout-index -f -u one &&
cmp one original.one &&
cd dir &&
@@ -93,7 +93,7 @@ test_expect_success 'checkout-index' '
'
test_expect_success 'read-tree' '
- cd $HERE &&
+ cd "$HERE" &&
rm -f one dir/two &&
tree=`git write-tree` &&
git read-tree --reset -u "$tree" &&
@@ -107,27 +107,27 @@ test_expect_success 'read-tree' '
'
test_expect_success 'no file/rev ambiguity check inside .git' '
- cd $HERE &&
+ cd "$HERE" &&
git commit -a -m 1 &&
- cd $HERE/.git &&
+ cd "$HERE"/.git &&
git show -s HEAD
'
test_expect_success 'no file/rev ambiguity check inside a bare repo' '
- cd $HERE &&
+ cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && GIT_DIR=. git show -s HEAD
'
# This still does not work as it should...
: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
- cd $HERE &&
+ cd "$HERE" &&
git clone -s --bare .git foo.git &&
cd foo.git && git show -s HEAD
'
test_expect_success 'detection should not be fooled by a symlink' '
- cd $HERE &&
+ cd "$HERE" &&
rm -fr foo.git &&
git clone -s .git another &&
ln -s another yetanother &&
diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh
index 991d3c5e9..09a819933 100755
--- a/t/t1200-tutorial.sh
+++ b/t/t1200-tutorial.sh
@@ -101,8 +101,8 @@ echo "Play, play, play" >>hello
echo "Lots of fun" >>example
git commit -m 'Some fun.' -i hello example
-test_expect_failure 'git resolve now fails' '
- git merge -m "Merge work in mybranch" mybranch
+test_expect_success 'git resolve now fails' '
+ test_must_fail git merge -m "Merge work in mybranch" mybranch
'
cat > hello << EOF
@@ -156,6 +156,8 @@ test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.outp
test_expect_success 'git repack' 'git repack'
test_expect_success 'git prune-packed' 'git prune-packed'
-test_expect_failure '-> only packed objects' 'find -type f .git/objects/[0-9a-f][0-9a-f]'
+test_expect_success '-> only packed objects' '
+ ! find -type f .git/objects/[0-9a-f][0-9a-f]
+'
test_done
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 42eac2a7c..64567fb94 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -71,6 +71,25 @@ EOF
test_expect_success 'non-match result' 'cmp .git/config expect'
+cat > .git/config <<\EOF
+[alpha]
+bar = foo
+[beta]
+baz = multiple \
+lines
+EOF
+
+test_expect_success 'unset with cont. lines' \
+ 'git config --unset beta.baz'
+
+cat > expect <<\EOF
+[alpha]
+bar = foo
+[beta]
+EOF
+
+test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'
+
cat > .git/config << EOF
[beta] ; silly comment # another comment
noIndent= sillyValue ; 'nother silly comment
@@ -181,8 +200,9 @@ test_expect_success 'non-match' \
test_expect_success 'non-match value' \
'test wow = $(git config --get nextsection.nonewline !for)'
-test_expect_failure 'ambiguous get' \
- 'git config --get nextsection.nonewline'
+test_expect_success 'ambiguous get' '
+ test_must_fail git config --get nextsection.nonewline
+'
test_expect_success 'get multivar' \
'git config --get-all nextsection.nonewline'
@@ -202,13 +222,17 @@ EOF
test_expect_success 'multivar replace' 'cmp .git/config expect'
-test_expect_failure 'ambiguous value' 'git config nextsection.nonewline'
+test_expect_success 'ambiguous value' '
+ test_must_fail git config nextsection.nonewline
+'
-test_expect_failure 'ambiguous unset' \
- 'git config --unset nextsection.nonewline'
+test_expect_success 'ambiguous unset' '
+ test_must_fail git config --unset nextsection.nonewline
+'
-test_expect_failure 'invalid unset' \
- 'git config --unset somesection.nonewline'
+test_expect_success 'invalid unset' '
+ test_must_fail git config --unset somesection.nonewline
+'
git config --unset nextsection.nonewline "wow3$"
@@ -224,7 +248,7 @@ EOF
test_expect_success 'multivar unset' 'cmp .git/config expect'
-test_expect_failure 'invalid key' 'git config inval.2key blabla'
+test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
test_expect_success 'correct key' 'git config 123456.a123 987'
@@ -278,17 +302,40 @@ test_expect_success '--add' \
cat > .git/config << EOF
[novalue]
variable
+[emptyvalue]
+ variable =
EOF
test_expect_success 'get variable with no value' \
'git config --get novalue.variable ^$'
+test_expect_success 'get variable with empty value' \
+ 'git config --get emptyvalue.variable ^$'
+
echo novalue.variable > expect
test_expect_success 'get-regexp variable with no value' \
'git config --get-regexp novalue > output &&
cmp output expect'
+echo 'emptyvalue.variable ' > expect
+
+test_expect_success 'get-regexp variable with empty value' \
+ 'git config --get-regexp emptyvalue > output &&
+ cmp output expect'
+
+echo true > expect
+
+test_expect_success 'get bool variable with no value' \
+ 'git config --bool novalue.variable > output &&
+ cmp output expect'
+
+echo false > expect
+
+test_expect_success 'get bool variable with empty value' \
+ 'git config --bool emptyvalue.variable > output &&
+ cmp output expect'
+
git config > output 2>&1
test_expect_success 'no arguments, but no crash' \
@@ -380,12 +427,14 @@ cat > expect << EOF
weird
EOF
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
-test_expect_failure "rename non-existing section" \
- 'git config --rename-section branch."world domination" branch.drei'
+test_expect_success "rename non-existing section" '
+ test_must_fail git config --rename-section \
+ branch."world domination" branch.drei
+'
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
test_expect_success "rename another section" \
'git config --rename-section branch."1 234 blabl/a" branch.drei'
@@ -401,7 +450,7 @@ cat > expect << EOF
weird
EOF
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
cat >> .git/config << EOF
[branch "zwei"] a = 1 [branch "vier"]
@@ -417,7 +466,7 @@ weird
EOF
test_expect_success "section was removed properly" \
- "git diff -u expect .git/config"
+ "test_cmp expect .git/config"
rm .git/config
@@ -494,14 +543,14 @@ test_expect_success bool '
done &&
cmp expect result'
-test_expect_failure 'invalid bool (--get)' '
+test_expect_success 'invalid bool (--get)' '
git config bool.nobool foobar &&
- git config --bool --get bool.nobool'
+ test_must_fail git config --bool --get bool.nobool'
-test_expect_failure 'invalid bool (set)' '
+test_expect_success 'invalid bool (set)' '
- git config --bool bool.nobool foobar'
+ test_must_fail git config --bool bool.nobool foobar'
rm .git/config
@@ -547,6 +596,64 @@ test_expect_success 'set --int' '
rm .git/config
+cat >expect <<\EOF
+[bool]
+ true1 = true
+ true2 = true
+ false1 = false
+ false2 = false
+[int]
+ int1 = 0
+ int2 = 1
+ int3 = -1
+EOF
+
+test_expect_success 'get --bool-or-int' '
+ (
+ echo "[bool]"
+ echo true1
+ echo true2 = true
+ echo false = false
+ echo "[int]"
+ echo int1 = 0
+ echo int2 = 1
+ echo int3 = -1
+ ) >>.git/config &&
+ test $(git config --bool-or-int bool.true1) = true &&
+ test $(git config --bool-or-int bool.true2) = true &&
+ test $(git config --bool-or-int bool.false) = false &&
+ test $(git config --bool-or-int int.int1) = 0 &&
+ test $(git config --bool-or-int int.int2) = 1 &&
+ test $(git config --bool-or-int int.int3) = -1
+
+'
+
+rm .git/config
+cat >expect <<\EOF
+[bool]
+ true1 = true
+ false1 = false
+ true2 = true
+ false2 = false
+[int]
+ int1 = 0
+ int2 = 1
+ int3 = -1
+EOF
+
+test_expect_success 'set --bool-or-int' '
+ git config --bool-or-int bool.true1 true &&
+ git config --bool-or-int bool.false1 false &&
+ git config --bool-or-int bool.true2 yes &&
+ git config --bool-or-int bool.false2 no &&
+ git config --bool-or-int int.int1 0 &&
+ git config --bool-or-int int.int2 1 &&
+ git config --bool-or-int int.int3 -1 &&
+ test_cmp expect .git/config
+'
+
+rm .git/config
+
git config quote.leading " test"
git config quote.ending "test "
git config quote.semicolon "test;test"
@@ -562,8 +669,9 @@ EOF
test_expect_success 'quoting' 'cmp .git/config expect'
-test_expect_failure 'key with newline' 'git config key.with\\\
-newline 123'
+test_expect_success 'key with newline' '
+ test_must_fail git config "key.with
+newline" 123'
test_expect_success 'value with newline' 'git config key.sub value.with\\\
newline'
@@ -608,12 +716,12 @@ Qsection.sub=section.val4
Qsection.sub=section.val5Q
EOF
-git config --null --list | tr '\000' 'Q' > result
+git config --null --list | perl -pe 'y/\000/Q/' > result
echo >>result
test_expect_success '--null --list' 'cmp result expect'
-git config --null --get-regexp 'val[0-9]' | tr '\000' 'Q' > result
+git config --null --get-regexp 'val[0-9]' | perl -pe 'y/\000/Q/' > result
echo >>result
test_expect_success '--null --get-regexp' 'cmp result expect'
diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh
index 6bfe19a4e..dc85e8b60 100755
--- a/t/t1301-shared-repo.sh
+++ b/t/t1301-shared-repo.sh
@@ -7,6 +7,39 @@ test_description='Test shared repository initialization'
. ./test-lib.sh
+# User must have read permissions to the repo -> failure on --shared=0400
+test_expect_success 'shared = 0400 (faulty permission u-w)' '
+ mkdir sub && (
+ cd sub && git init --shared=0400
+ )
+ ret="$?"
+ rm -rf sub
+ test $ret != "0"
+'
+
+for u in 002 022
+do
+ test_expect_success "shared=1 does not clear bits preset by umask $u" '
+ mkdir sub && (
+ cd sub &&
+ umask $u &&
+ git init --shared=1 &&
+ test 1 = "$(git config core.sharedrepository)"
+ ) &&
+ actual=$(ls -l sub/.git/HEAD)
+ case "$actual" in
+ -rw-rw-r--*)
+ : happy
+ ;;
+ *)
+ echo Oops, .git/HEAD is not 0664 but $actual
+ false
+ ;;
+ esac
+ '
+ rm -rf sub
+done
+
test_expect_success 'shared=all' '
mkdir sub &&
cd sub &&
@@ -33,4 +66,59 @@ test_expect_success 'update-server-info honors core.sharedRepository' '
esac
'
+for u in 0660:rw-rw---- \
+ 0640:rw-r----- \
+ 0600:rw------- \
+ 0666:rw-rw-rw- \
+ 0664:rw-rw-r--
+do
+ x=$(expr "$u" : ".*:\([rw-]*\)") &&
+ y=$(echo "$x" | sed -e "s/w/-/g") &&
+ u=$(expr "$u" : "\([0-7]*\)") &&
+ git config core.sharedrepository "$u" &&
+ umask 0277 &&
+
+ test_expect_success "shared = $u ($y) ro" '
+
+ rm -f .git/info/refs &&
+ git update-server-info &&
+ actual="$(ls -l .git/info/refs)" &&
+ actual=${actual%% *} &&
+ test "x$actual" = "x-$y" || {
+ ls -lt .git/info
+ false
+ }
+ '
+
+ umask 077 &&
+ test_expect_success "shared = $u ($x) rw" '
+
+ rm -f .git/info/refs &&
+ git update-server-info &&
+ actual="$(ls -l .git/info/refs)" &&
+ actual=${actual%% *} &&
+ test "x$actual" = "x-$x" || {
+ ls -lt .git/info
+ false
+ }
+
+ '
+
+done
+
+test_expect_success 'git reflog expire honors core.sharedRepository' '
+ git config core.sharedRepository group &&
+ git reflog expire --all &&
+ actual="$(ls -l .git/logs/refs/heads/master)" &&
+ case "$actual" in
+ -rw-rw-*)
+ : happy
+ ;;
+ *)
+ echo Ooops, .git/logs/refs/heads/master is not 0662 [$actual]
+ false
+ ;;
+ esac
+'
+
test_done
diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
index 37fc1c8d3..8d305b437 100755
--- a/t/t1302-repo-version.sh
+++ b/t/t1302-repo-version.sh
@@ -40,7 +40,8 @@ test_expect_success 'gitdir required mode on normal repos' '
(git apply --check --index test.patch &&
cd test && git apply --check --index ../test.patch)'
-test_expect_failure 'gitdir required mode on unsupported repo' '
- (cd test2 && git apply --check --index ../test.patch)'
+test_expect_success 'gitdir required mode on unsupported repo' '
+ (cd test2 && test_must_fail git apply --check --index ../test.patch)
+'
test_done
diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh
index 99985dcd7..f98f4c517 100755
--- a/t/t1303-wacky-config.sh
+++ b/t/t1303-wacky-config.sh
@@ -11,7 +11,7 @@ setup() {
check() {
echo "$2" >expected
git config --get "$1" >actual
- git diff actual expected
+ test_cmp actual expected
}
test_expect_success 'modify same key' '
@@ -34,4 +34,10 @@ test_expect_success 'add key in different section' '
check section2.key bar
'
+SECTION="test.q\"s\\sq'sp e.key"
+test_expect_success 'make sure git-config escapes section names properly' '
+ git config "$SECTION" bar &&
+ check "$SECTION" bar
+'
+
test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 71ab2dd0e..b31e4b1ac 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -32,6 +32,22 @@ test_expect_success \
"create $m" \
"git update-ref $m $B $A &&
test $B"' = $(cat .git/'"$m"')'
+test_expect_success "fail to delete $m with stale ref" '
+ test_must_fail git update-ref -d $m $A &&
+ test $B = "$(cat .git/$m)"
+'
+test_expect_success "delete $m" '
+ git update-ref -d $m $B &&
+ ! test -f .git/$m
+'
+rm -f .git/$m
+
+test_expect_success "delete $m without oldvalue verification" "
+ git update-ref $m $A &&
+ test $A = \$(cat .git/$m) &&
+ git update-ref -d $m &&
+ ! test -f .git/$m
+"
rm -f .git/$m
test_expect_success \
@@ -49,25 +65,33 @@ test_expect_success \
"create $m (by HEAD)" \
"git update-ref HEAD $B $A &&
test $B"' = $(cat .git/'"$m"')'
+test_expect_success "fail to delete $m (by HEAD) with stale ref" '
+ test_must_fail git update-ref -d HEAD $A &&
+ test $B = $(cat .git/$m)
+'
+test_expect_success "delete $m (by HEAD)" '
+ git update-ref -d HEAD $B &&
+ ! test -f .git/$m
+'
rm -f .git/$m
-test_expect_failure \
- '(not) create HEAD with old sha1' \
- "git update-ref HEAD $A $B"
-test_expect_failure \
- "(not) prior created .git/$m" \
- "test -f .git/$m"
+test_expect_success '(not) create HEAD with old sha1' "
+ test_must_fail git update-ref HEAD $A $B
+"
+test_expect_success "(not) prior created .git/$m" "
+ ! test -f .git/$m
+"
rm -f .git/$m
test_expect_success \
"create HEAD" \
"git update-ref HEAD $A"
-test_expect_failure \
- '(not) change HEAD with wrong SHA1' \
- "git update-ref HEAD $B $Z"
-test_expect_failure \
- "(not) changed .git/$m" \
- "test $B"' = $(cat .git/'"$m"')'
+test_expect_success '(not) change HEAD with wrong SHA1' "
+ test_must_fail git update-ref HEAD $B $Z
+"
+test_expect_success "(not) changed .git/$m" "
+ ! test $B"' = $(cat .git/'"$m"')
+'
rm -f .git/$m
: a repository with working tree always has reflog these days...
@@ -131,7 +155,8 @@ rm -f .git/$m .git/logs/$m expect
git update-ref $m $D
cat >.git/logs/$m <<EOF
-$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
+0000000000000000000000000000000000000000 $C $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
+$C $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150350 -0500
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
$F $Z $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
$Z $E $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 -0500
@@ -162,6 +187,12 @@ test_expect_success \
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
+ test '"$C"' = $(cat o) &&
+ test "" = "$(cat e)"'
+test_expect_success \
+ 'Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
+ 'rm -f o e
+ git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
test '"$A"' = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index f959aae84..5b24f0557 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -175,21 +175,44 @@ test_expect_success 'recover and check' '
'
-test_expect_success 'prune --expire' '
-
- before=$(git count-objects | sed "s/ .*//") &&
- BLOB=$(echo aleph | git hash-object -w --stdin) &&
- BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
- test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
- test -f $BLOB_FILE &&
- git reset --hard &&
- git prune --expire=1.hour.ago &&
- test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
- test -f $BLOB_FILE &&
- test-chmtime -86500 $BLOB_FILE &&
- git prune --expire 1.day &&
- test $before = $(git count-objects | sed "s/ .*//") &&
- ! test -f $BLOB_FILE
+test_expect_success 'delete' '
+ echo 1 > C &&
+ test_tick &&
+ git commit -m rat C &&
+
+ echo 2 > C &&
+ test_tick &&
+ git commit -m ox C &&
+
+ echo 3 > C &&
+ test_tick &&
+ git commit -m tiger C &&
+
+ HEAD_entry_count=$(git reflog | wc -l)
+ master_entry_count=$(git reflog show master | wc -l)
+
+ test $HEAD_entry_count = 5 &&
+ test $master_entry_count = 5 &&
+
+
+ git reflog delete master@{1} &&
+ git reflog show master > output &&
+ test $(($master_entry_count - 1)) = $(wc -l < output) &&
+ test $HEAD_entry_count = $(git reflog | wc -l) &&
+ ! grep ox < output &&
+
+ master_entry_count=$(wc -l < output)
+
+ git reflog delete HEAD@{1} &&
+ test $(($HEAD_entry_count -1)) = $(git reflog | wc -l) &&
+ test $master_entry_count = $(git reflog show master | wc -l) &&
+
+ HEAD_entry_count=$(git reflog | wc -l)
+
+ git reflog delete master@{07.04.2005.15:15:00.-0700} &&
+ git reflog show master > output &&
+ test $(($master_entry_count - 1)) = $(wc -l < output) &&
+ ! grep dragon < output
'
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index e474b3f1d..85da4caa7 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -33,9 +33,9 @@ test_rev_parse() {
test_rev_parse toplevel false false true ''
cd .git || exit 1
-test_rev_parse .git/ true true false ''
+test_rev_parse .git/ false true false ''
cd objects || exit 1
-test_rev_parse .git/objects/ true true false ''
+test_rev_parse .git/objects/ false true false ''
cd ../.. || exit 1
mkdir -p sub/dir || exit 1
@@ -51,8 +51,9 @@ test_rev_parse 'core.bare undefined' false false true
mkdir work || exit 1
cd work || exit 1
-export GIT_DIR=../.git
-export GIT_CONFIG="$(pwd)"/../.git/config
+GIT_DIR=../.git
+GIT_CONFIG="$(pwd)"/../.git/config
+export GIT_DIR GIT_CONFIG
git config core.bare false
test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true ''
@@ -64,8 +65,8 @@ git config --unset core.bare
test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
mv ../.git ../repo.git || exit 1
-export GIT_DIR=../repo.git
-export GIT_CONFIG="$(pwd)"/../repo.git/config
+GIT_DIR=../repo.git
+GIT_CONFIG="$(pwd)"/../repo.git/config
git config core.bare false
test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true ''
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 7ee3820ce..2ee88d8a0 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -32,24 +32,25 @@ mkdir -p work/sub/dir || exit 1
mv .git repo.git || exit 1
say "core.worktree = relative path"
-export GIT_DIR=repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+export GIT_DIR GIT_CONFIG
unset GIT_WORK_TREE
git config core.worktree ../work
test_rev_parse 'outside' false false false
cd work || exit 1
-export GIT_DIR=../repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=../repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
-export GIT_DIR=../../../repo.git
-export GIT_CONFIG="$(pwd)"/$GIT_DIR/config
+GIT_DIR=../../../repo.git
+GIT_CONFIG="$(pwd)"/$GIT_DIR/config
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
say "core.worktree = absolute path"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
git config core.worktree "$(pwd)/work"
test_rev_parse 'outside' false false false
cd work || exit 1
@@ -59,25 +60,26 @@ test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
say "GIT_WORK_TREE=relative path (override core.worktree)"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
git config core.worktree non-existent
-export GIT_WORK_TREE=work
+GIT_WORK_TREE=work
+export GIT_WORK_TREE
test_rev_parse 'outside' false false false
cd work || exit 1
-export GIT_WORK_TREE=.
+GIT_WORK_TREE=.
test_rev_parse 'inside' false false true ''
cd sub/dir || exit 1
-export GIT_WORK_TREE=../..
+GIT_WORK_TREE=../..
test_rev_parse 'subdirectory' false false true sub/dir/
cd ../../.. || exit 1
mv work repo.git/work
say "GIT_WORK_TREE=absolute path, work tree below git dir"
-export GIT_DIR=$(pwd)/repo.git
-export GIT_CONFIG=$GIT_DIR/config
-export GIT_WORK_TREE=$(pwd)/repo.git/work
+GIT_DIR=$(pwd)/repo.git
+GIT_CONFIG=$GIT_DIR/config
+GIT_WORK_TREE=$(pwd)/repo.git/work
test_rev_parse 'outside' false false false
cd repo.git || exit 1
test_rev_parse 'in repo.git' false true false
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
new file mode 100755
index 000000000..997002d4c
--- /dev/null
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='test git rev-parse --parseopt'
+. ./test-lib.sh
+
+cat > expect.err <<EOF
+usage: some-command [options] <args>...
+
+ some-command does foo and bar!
+
+ -h, --help show the help
+ --foo some nifty option --foo
+ --bar ... some cool option --bar with an argument
+
+An option group Header
+ -C[...] option C with an optional argument
+
+Extras
+ --extra1 line above used to cause a segfault but no longer does
+
+EOF
+
+test_expect_success 'test --parseopt help output' '
+ git rev-parse --parseopt -- -h 2> output.err <<EOF
+some-command [options] <args>...
+
+some-command does foo and bar!
+--
+h,help show the help
+
+foo some nifty option --foo
+bar= some cool option --bar with an argument
+
+ An option group Header
+C? option C with an optional argument
+
+Extras
+extra1 line above used to cause a segfault but no longer does
+EOF
+ test_cmp expect.err output.err
+'
+
+test_done
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
new file mode 100755
index 000000000..95244c9bc
--- /dev/null
+++ b/t/t1503-rev-parse-verify.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Christian Couder
+#
+test_description='test git rev-parse --verify'
+
+exec </dev/null
+
+. ./test-lib.sh
+
+add_line_into_file()
+{
+ _line=$1
+ _file=$2
+
+ if [ -f "$_file" ]; then
+ echo "$_line" >> $_file || return $?
+ MSG="Add <$_line> into <$_file>."
+ else
+ echo "$_line" > $_file || return $?
+ git add $_file || return $?
+ MSG="Create file <$_file> with <$_line> inside."
+ fi
+
+ test_tick
+ git-commit --quiet -m "$MSG" $_file
+}
+
+HASH1=
+HASH2=
+HASH3=
+HASH4=
+
+test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '
+ add_line_into_file "1: Hello World" hello &&
+ HASH1=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "2: A new day for git" hello &&
+ HASH2=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "3: Another new day for git" hello &&
+ HASH3=$(git rev-parse --verify HEAD) &&
+ add_line_into_file "4: Ciao for now" hello &&
+ HASH4=$(git rev-parse --verify HEAD)
+'
+
+test_expect_success 'works with one good rev' '
+ rev_hash1=$(git rev-parse --verify $HASH1) &&
+ test "$rev_hash1" = "$HASH1" &&
+ rev_hash2=$(git rev-parse --verify $HASH2) &&
+ test "$rev_hash2" = "$HASH2" &&
+ rev_hash3=$(git rev-parse --verify $HASH3) &&
+ test "$rev_hash3" = "$HASH3" &&
+ rev_hash4=$(git rev-parse --verify $HASH4) &&
+ test "$rev_hash4" = "$HASH4" &&
+ rev_master=$(git rev-parse --verify master) &&
+ test "$rev_master" = "$HASH4" &&
+ rev_head=$(git rev-parse --verify HEAD) &&
+ test "$rev_head" = "$HASH4"
+'
+
+test_expect_success 'fails with any bad rev or many good revs' '
+ test_must_fail git rev-parse --verify 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify foo 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify HEAD bar 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify baz HEAD 2>error &&
+ grep "single revision" error &&
+ test_must_fail git rev-parse --verify $HASH2 HEAD 2>error &&
+ grep "single revision" error
+'
+
+test_expect_success 'fails silently when using -q' '
+ test_must_fail git rev-parse --verify --quiet 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse -q --verify foo 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse --verify -q HEAD bar 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse --quiet --verify baz HEAD 2>error &&
+ test -z "$(cat error)" &&
+ test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error &&
+ test -z "$(cat error)"
+'
+
+test_expect_success 'no stdout output on error' '
+ test -z "$(git rev-parse --verify)" &&
+ test -z "$(git rev-parse --verify foo)" &&
+ test -z "$(git rev-parse --verify baz HEAD)" &&
+ test -z "$(git rev-parse --verify HEAD bar)" &&
+ test -z "$(git rev-parse --verify $HASH2 HEAD)"
+'
+
+test_expect_success 'use --default' '
+ git rev-parse --verify --default master &&
+ git rev-parse --verify --default master HEAD &&
+ git rev-parse --default master --verify &&
+ git rev-parse --default master --verify HEAD &&
+ git rev-parse --verify HEAD --default master &&
+ test_must_fail git rev-parse --verify foo --default master &&
+ test_must_fail git rev-parse --default HEAD --verify bar &&
+ test_must_fail git rev-parse --verify --default HEAD baz &&
+ test_must_fail git rev-parse --default foo --verify &&
+ test_must_fail git rev-parse --verify --default bar
+'
+
+test_done
diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh
new file mode 100755
index 000000000..91b704a3a
--- /dev/null
+++ b/t/t1504-ceiling-dirs.sh
@@ -0,0 +1,163 @@
+#!/bin/sh
+
+test_description='test GIT_CEILING_DIRECTORIES'
+. ./test-lib.sh
+
+test_prefix() {
+ test_expect_success "$1" \
+ "test '$2' = \"\$(git rev-parse --show-prefix)\""
+}
+
+test_fail() {
+ test_expect_code 128 "$1: prefix" \
+ "git rev-parse --show-prefix"
+}
+
+TRASH_ROOT="$(pwd)"
+ROOT_PARENT=$(dirname "$TRASH_ROOT")
+
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix no_ceil ""
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix ceil_empty ""
+
+GIT_CEILING_DIRECTORIES="$ROOT_PARENT"
+test_prefix ceil_at_parent ""
+
+GIT_CEILING_DIRECTORIES="$ROOT_PARENT/"
+test_prefix ceil_at_parent_slash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_prefix ceil_at_trash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_prefix ceil_at_trash_slash ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+test_prefix ceil_at_sub ""
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
+test_prefix ceil_at_sub_slash ""
+
+
+mkdir -p sub/dir || exit 1
+cd sub/dir || exit 1
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix subdir_no_ceil "sub/dir/"
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix subdir_ceil_empty "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_fail subdir_ceil_at_trash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_fail subdir_ceil_at_trash_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+test_fail subdir_ceil_at_sub
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
+test_fail subdir_ceil_at_sub_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
+test_prefix subdir_ceil_at_subdir "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir/"
+test_prefix subdir_ceil_at_subdir_slash "sub/dir/"
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
+test_prefix subdir_ceil_at_su "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
+test_prefix subdir_ceil_at_su_slash "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
+test_prefix subdir_ceil_at_sub_di "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/di"
+test_prefix subdir_ceil_at_sub_di_slash "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
+test_prefix subdir_ceil_at_subdi "sub/dir/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/subdi"
+test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
+
+
+GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub"
+test_fail second_of_two
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub:bar"
+test_fail first_of_two
+
+GIT_CEILING_DIRECTORIES="foo:$TRASH_ROOT/sub:bar"
+test_fail second_of_three
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub"
+GIT_DIR=../../.git
+export GIT_DIR
+test_prefix git_dir_specified ""
+unset GIT_DIR
+
+
+cd ../.. || exit 1
+mkdir -p s/d || exit 1
+cd s/d || exit 1
+
+unset GIT_CEILING_DIRECTORIES
+test_prefix sd_no_ceil "s/d/"
+
+export GIT_CEILING_DIRECTORIES
+
+GIT_CEILING_DIRECTORIES=""
+test_prefix sd_ceil_empty "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT"
+test_fail sd_ceil_at_trash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/"
+test_fail sd_ceil_at_trash_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s"
+test_fail sd_ceil_at_s
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/"
+test_fail sd_ceil_at_s_slash
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d"
+test_prefix sd_ceil_at_sd "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/d/"
+test_prefix sd_ceil_at_sd_slash "s/d/"
+
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su"
+test_prefix sd_ceil_at_su "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/su/"
+test_prefix sd_ceil_at_su_slash "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
+test_prefix sd_ceil_at_s_di "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/s/di"
+test_prefix sd_ceil_at_s_di_slash "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
+test_prefix sd_ceil_at_sdi "s/d/"
+
+GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sdi"
+test_prefix sd_ceil_at_sdi_slash "s/d/"
+
+
+test_done
diff --git a/t/t2000-checkout-cache-clash.sh b/t/t2000-checkout-cache-clash.sh
index ac84335b0..f7e1a735e 100755
--- a/t/t2000-checkout-cache-clash.sh
+++ b/t/t2000-checkout-cache-clash.sh
@@ -36,9 +36,9 @@ mkdir path0
date >path0/file0
date >path1
-test_expect_failure \
+test_expect_success \
'git checkout-index without -f should fail on conflicting work tree.' \
- 'git checkout-index -a'
+ 'test_must_fail git checkout-index -a'
test_expect_success \
'git checkout-index with -f should succeed.' \
diff --git a/t/t2002-checkout-cache-u.sh b/t/t2002-checkout-cache-u.sh
index f7a005592..70361c806 100755
--- a/t/t2002-checkout-cache-u.sh
+++ b/t/t2002-checkout-cache-u.sh
@@ -16,18 +16,18 @@ echo frotz >path0 &&
git update-index --add path0 &&
t=$(git write-tree)'
-test_expect_failure \
+test_expect_success \
'without -u, git checkout-index smudges stat information.' '
rm -f path0 &&
git read-tree $t &&
git checkout-index -f -a &&
-git diff-files | diff - /dev/null'
+test_must_fail git diff-files --exit-code'
test_expect_success \
'with -u, git checkout-index picks up stat information from new files.' '
rm -f path0 &&
git read-tree $t &&
git checkout-index -u -f -a &&
-git diff-files | diff - /dev/null'
+git diff-files --exit-code'
test_done
diff --git a/t/t2008-checkout-subdir.sh b/t/t2008-checkout-subdir.sh
index f78945ed8..3e098ab31 100755
--- a/t/t2008-checkout-subdir.sh
+++ b/t/t2008-checkout-subdir.sh
@@ -67,16 +67,16 @@ test_expect_success 'checkout with simple prefix' '
'
-test_expect_failure 'relative path outside tree should fail' \
- 'git checkout HEAD -- ../../Makefile'
+test_expect_success 'relative path outside tree should fail' \
+ 'test_must_fail git checkout HEAD -- ../../Makefile'
-test_expect_failure 'incorrect relative path to file should fail (1)' \
- 'git checkout HEAD -- ../file0'
+test_expect_success 'incorrect relative path to file should fail (1)' \
+ 'test_must_fail git checkout HEAD -- ../file0'
-test_expect_failure 'incorrect relative path should fail (2)' \
- '( cd dir1 && git checkout HEAD -- ./file0 )'
+test_expect_success 'incorrect relative path should fail (2)' \
+ '( cd dir1 && test_must_fail git checkout HEAD -- ./file0 )'
-test_expect_failure 'incorrect relative path should fail (3)' \
- '( cd dir1 && git checkout HEAD -- ../../file0 )'
+test_expect_success 'incorrect relative path should fail (3)' \
+ '( cd dir1 && test_must_fail git checkout HEAD -- ../../file0 )'
test_done
diff --git a/t/t2009-checkout-statinfo.sh b/t/t2009-checkout-statinfo.sh
new file mode 100755
index 000000000..f3c215208
--- /dev/null
+++ b/t/t2009-checkout-statinfo.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='checkout should leave clean stat info'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ echo hello >world &&
+ git update-index --add world &&
+ git commit -m initial &&
+ git branch side &&
+ echo goodbye >world &&
+ git update-index --add world &&
+ git commit -m second
+
+'
+
+test_expect_success 'branch switching' '
+
+ git reset --hard &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout master &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout side &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout master &&
+ test "$(git diff-files --raw)" = ""
+
+'
+
+test_expect_success 'path checkout' '
+
+ git reset --hard &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout master world &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout side world &&
+ test "$(git diff-files --raw)" = "" &&
+
+ git checkout master world &&
+ test "$(git diff-files --raw)" = ""
+
+'
+
+test_done
+
diff --git a/t/t2010-checkout-ambiguous.sh b/t/t2010-checkout-ambiguous.sh
new file mode 100755
index 000000000..7cc0a3582
--- /dev/null
+++ b/t/t2010-checkout-ambiguous.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='checkout and pathspecs/refspecs ambiguities'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo hello >world &&
+ echo hello >all &&
+ git add all world &&
+ git commit -m initial &&
+ git branch world
+'
+
+test_expect_success 'reference must be a tree' '
+ test_must_fail git checkout $(git hash-object ./all) --
+'
+
+test_expect_success 'branch switching' '
+ test "refs/heads/master" = "$(git symbolic-ref HEAD)" &&
+ git checkout world -- &&
+ test "refs/heads/world" = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success 'checkout world from the index' '
+ echo bye > world &&
+ git checkout -- world &&
+ git diff --exit-code --quiet
+'
+
+test_expect_success 'non ambiguous call' '
+ git checkout all
+'
+
+test_expect_success 'allow the most common case' '
+ git checkout world &&
+ test "refs/heads/world" = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success 'check ambiguity' '
+ test_must_fail git checkout world all
+'
+
+test_expect_success 'disambiguate checking out from a tree-ish' '
+ echo bye > world &&
+ git checkout world -- world &&
+ git diff --exit-code --quiet
+'
+
+test_done
diff --git a/t/t2100-update-cache-badpath.sh b/t/t2100-update-cache-badpath.sh
index 04a1ed1a6..6ef2dcfd8 100755
--- a/t/t2100-update-cache-badpath.sh
+++ b/t/t2100-update-cache-badpath.sh
@@ -44,8 +44,8 @@ date >path1/file1
for p in path0/file0 path1/file1 path2 path3
do
- test_expect_failure \
+ test_expect_success \
"git update-index to add conflicting path $p should fail." \
- "git update-index --add -- $p"
+ "test_must_fail git update-index --add -- $p"
done
test_done
diff --git a/t/t2103-update-index-ignore-missing.sh b/t/t2103-update-index-ignore-missing.sh
new file mode 100755
index 000000000..332694e7d
--- /dev/null
+++ b/t/t2103-update-index-ignore-missing.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+test_description='update-index with options'
+
+. ./test-lib.sh
+
+test_expect_success basics '
+ >one &&
+ >two &&
+ >three &&
+
+ # need --add when adding
+ test_must_fail git update-index one &&
+ test -z "$(git ls-files)" &&
+ git update-index --add one &&
+ test zone = "z$(git ls-files)" &&
+
+ # update-index is atomic
+ echo 1 >one &&
+ test_must_fail git update-index one two &&
+ echo "M one" >expect &&
+ git diff-files --name-status >actual &&
+ test_cmp expect actual &&
+
+ git update-index --add one two three &&
+ for i in one three two; do echo $i; done >expect &&
+ git ls-files >actual &&
+ test_cmp expect actual &&
+
+ test_tick &&
+ (
+ test_create_repo xyzzy &&
+ cd xyzzy &&
+ >file &&
+ git add file
+ git commit -m "sub initial"
+ ) &&
+ git add xyzzy &&
+
+ test_tick &&
+ git commit -m initial &&
+ git tag initial
+'
+
+test_expect_success '--ignore-missing --refresh' '
+ git reset --hard initial &&
+ echo 2 >one &&
+ test_must_fail git update-index --refresh &&
+ echo 1 >one &&
+ git update-index --refresh &&
+ rm -f two &&
+ test_must_fail git update-index --refresh &&
+ git update-index --ignore-missing --refresh
+
+'
+
+test_expect_success '--unmerged --refresh' '
+ git reset --hard initial &&
+ info=$(git ls-files -s one | sed -e "s/ 0 / 1 /") &&
+ git rm --cached one &&
+ echo "$info" | git update-index --index-info &&
+ test_must_fail git update-index --refresh &&
+ git update-index --unmerged --refresh &&
+ echo 2 >two &&
+ test_must_fail git update-index --unmerged --refresh >actual &&
+ grep two actual &&
+ ! grep one actual &&
+ ! grep three actual
+'
+
+test_expect_success '--ignore-submodules --refresh (1)' '
+ git reset --hard initial &&
+ rm -f two &&
+ test_must_fail git update-index --ignore-submodules --refresh
+'
+
+test_expect_success '--ignore-submodules --refresh (2)' '
+ git reset --hard initial &&
+ test_tick &&
+ (
+ cd xyzzy &&
+ git commit -m "sub second" --allow-empty
+ ) &&
+ test_must_fail git update-index --refresh &&
+ test_must_fail git update-index --ignore-missing --refresh &&
+ git update-index --ignore-submodules --refresh
+'
+
+test_done
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 24f892f79..f57a6e077 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -62,7 +62,7 @@ test_expect_success 'cache tree has not been corrupted' '
sed -e "s/ 0 / /" >expect &&
git ls-tree -r $(git write-tree) |
sed -e "s/ blob / /" >current &&
- diff -u expect current
+ test_cmp expect current
'
@@ -111,4 +111,21 @@ test_expect_success 'touch and then add explicitly' '
'
+test_expect_success 'add -n -u should not add but just report' '
+
+ (
+ echo "add '\''check'\''" &&
+ echo "remove '\''top'\''"
+ ) >expect &&
+ before=$(git ls-files -s check top) &&
+ echo changed >>check &&
+ rm -f top &&
+ git add -n -u >actual &&
+ after=$(git ls-files -s check top) &&
+
+ test "$before" = "$after" &&
+ test_cmp expect actual
+
+'
+
test_done
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
new file mode 100755
index 000000000..d24c7d9e5
--- /dev/null
+++ b/t/t2201-add-update-typechange.sh
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+test_description='more git add -u'
+
+. ./test-lib.sh
+
+_z40=0000000000000000000000000000000000000000
+
+test_expect_success setup '
+ >xyzzy &&
+ _empty=$(git hash-object --stdin <xyzzy) &&
+ >yomin &&
+ >caskly &&
+ ln -s frotz nitfol &&
+ mkdir rezrov &&
+ >rezrov/bozbar &&
+ git add caskly xyzzy yomin nitfol rezrov/bozbar &&
+
+ test_tick &&
+ git commit -m initial
+
+'
+
+test_expect_success modify '
+ rm -f xyzzy yomin nitfol caskly &&
+ # caskly disappears (not a submodule)
+ mkdir caskly &&
+ # nitfol changes from symlink to regular
+ >nitfol &&
+ # rezrov/bozbar disappears
+ rm -fr rezrov &&
+ ln -s xyzzy rezrov &&
+ # xyzzy disappears (not a submodule)
+ mkdir xyzzy &&
+ echo gnusto >xyzzy/bozbar &&
+ # yomin gets replaced with a submodule
+ mkdir yomin &&
+ >yomin/yomin &&
+ (
+ cd yomin &&
+ git init &&
+ git add yomin &&
+ git commit -m "sub initial"
+ ) &&
+ yomin=$(GIT_DIR=yomin/.git git rev-parse HEAD) &&
+ # yonk is added and then turned into a submodule
+ # this should appear as T in diff-files and as A in diff-index
+ >yonk &&
+ git add yonk &&
+ rm -f yonk &&
+ mkdir yonk &&
+ >yonk/yonk &&
+ (
+ cd yonk &&
+ git init &&
+ git add yonk &&
+ git commit -m "sub initial"
+ ) &&
+ yonk=$(GIT_DIR=yonk/.git git rev-parse HEAD) &&
+ # zifmia is added and then removed
+ # this should appear in diff-files but not in diff-index.
+ >zifmia &&
+ git add zifmia &&
+ rm -f zifmia &&
+ mkdir zifmia &&
+ {
+ git ls-tree -r HEAD |
+ sed -e "s/^/:/" -e "
+ / caskly/{
+ s/ caskly/ $_z40 D&/
+ s/blob/000000/
+ }
+ / nitfol/{
+ s/ nitfol/ $_z40 T&/
+ s/blob/100644/
+ }
+ / rezrov.bozbar/{
+ s/ rezrov.bozbar/ $_z40 D&/
+ s/blob/000000/
+ }
+ / xyzzy/{
+ s/ xyzzy/ $_z40 D&/
+ s/blob/000000/
+ }
+ / yomin/{
+ s/ yomin/ $_z40 T&/
+ s/blob/160000/
+ }
+ "
+ } >expect &&
+ {
+ cat expect
+ echo ":100644 160000 $_empty $_z40 T yonk"
+ echo ":100644 000000 $_empty $_z40 D zifmia"
+ } >expect-files &&
+ {
+ cat expect
+ echo ":000000 160000 $_z40 $_z40 A yonk"
+ } >expect-index &&
+ {
+ echo "100644 $_empty 0 nitfol"
+ echo "160000 $yomin 0 yomin"
+ echo "160000 $yonk 0 yonk"
+ } >expect-final
+'
+
+test_expect_success diff-files '
+ git diff-files --raw >actual &&
+ test_cmp expect-files actual
+'
+
+test_expect_success diff-index '
+ git diff-index --raw HEAD -- >actual &&
+ test_cmp expect-index actual
+'
+
+test_expect_success 'add -u' '
+ rm -f ".git/saved-index" &&
+ cp -p ".git/index" ".git/saved-index" &&
+ git add -u &&
+ git ls-files -s >actual &&
+ test_cmp expect-final actual
+'
+
+test_expect_success 'commit -a' '
+ if test -f ".git/saved-index"
+ then
+ rm -f ".git/index" &&
+ mv ".git/saved-index" ".git/index"
+ fi &&
+ git commit -m "second" -a &&
+ git ls-files -s >actual &&
+ test_cmp expect-final actual &&
+ rm -f .git/index &&
+ git read-tree HEAD &&
+ git ls-files -s >actual &&
+ test_cmp expect-final actual
+'
+
+test_done
diff --git a/t/t2202-add-addremove.sh b/t/t2202-add-addremove.sh
new file mode 100755
index 000000000..6a8151064
--- /dev/null
+++ b/t/t2202-add-addremove.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+test_description='git add --all'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ (
+ echo .gitignore
+ echo will-remove
+ ) >expect &&
+ (
+ echo actual
+ echo expect
+ echo ignored
+ ) >.gitignore &&
+ >will-remove &&
+ git add --all &&
+ test_tick &&
+ git commit -m initial &&
+ git ls-files >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git add --all' '
+ (
+ echo .gitignore
+ echo not-ignored
+ echo "M .gitignore"
+ echo "A not-ignored"
+ echo "D will-remove"
+ ) >expect &&
+ >ignored &&
+ >not-ignored &&
+ echo modification >>.gitignore &&
+ rm -f will-remove &&
+ git add --all &&
+ git update-index --refresh &&
+ git ls-files >actual &&
+ git diff-index --name-status --cached HEAD >>actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh
index e25b25568..1caeacafa 100755
--- a/t/t3001-ls-files-others-exclude.sh
+++ b/t/t3001-ls-files-others-exclude.sh
@@ -65,7 +65,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
- git diff expect output'
+ test_cmp expect output'
# Test \r\n (MSDOS-like systems)
printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
@@ -77,7 +77,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
- git diff expect output'
+ test_cmp expect output'
cat > excludes-file << EOF
*.[1-8]
@@ -97,6 +97,47 @@ cat > expect << EOF
EOF
test_expect_success 'git-status honours core.excludesfile' \
- 'diff -u expect output'
+ 'test_cmp expect output'
+
+test_expect_success 'trailing slash in exclude allows directory match(1)' '
+
+ git ls-files --others --exclude=one/ >output &&
+ if grep "^one/" output
+ then
+ echo Ooops
+ false
+ else
+ : happy
+ fi
+
+'
+
+test_expect_success 'trailing slash in exclude allows directory match (2)' '
+
+ git ls-files --others --exclude=one/two/ >output &&
+ if grep "^one/two/" output
+ then
+ echo Ooops
+ false
+ else
+ : happy
+ fi
+
+'
+
+test_expect_success 'trailing slash in exclude forces directory match (1)' '
+
+ >two
+ git ls-files --others --exclude=two/ >output &&
+ grep "^two" output
+
+'
+
+test_expect_success 'trailing slash in exclude forces directory match (2)' '
+
+ git ls-files --others --exclude=one/a.1/ >output &&
+ grep "^one/a.1" output
+
+'
test_done
diff --git a/t/t3002-ls-files-dashpath.sh b/t/t3002-ls-files-dashpath.sh
index 8687a01d2..8704b04e1 100755
--- a/t/t3002-ls-files-dashpath.sh
+++ b/t/t3002-ls-files-dashpath.sh
@@ -23,7 +23,7 @@ test_expect_success \
test_expect_success \
'git ls-files without path restriction.' \
'git ls-files --others >output &&
- git diff output - <<EOF
+ test_cmp output - <<EOF
--
-foo
output
@@ -34,7 +34,7 @@ EOF
test_expect_success \
'git ls-files with path restriction.' \
'git ls-files --others path0 >output &&
- git diff output - <<EOF
+ test_cmp output - <<EOF
path0
EOF
'
@@ -42,7 +42,7 @@ EOF
test_expect_success \
'git ls-files with path restriction with --.' \
'git ls-files --others -- path0 >output &&
- git diff output - <<EOF
+ test_cmp output - <<EOF
path0
EOF
'
@@ -50,7 +50,7 @@ EOF
test_expect_success \
'git ls-files with path restriction with -- --.' \
'git ls-files --others -- -- >output &&
- git diff output - <<EOF
+ test_cmp output - <<EOF
--
EOF
'
@@ -58,7 +58,7 @@ EOF
test_expect_success \
'git ls-files with no path restriction.' \
'git ls-files --others -- >output &&
- git diff output - <<EOF
+ test_cmp output - <<EOF
--
-foo
output
diff --git a/t/t3020-ls-files-error-unmatch.sh b/t/t3020-ls-files-error-unmatch.sh
index c83f820ad..af8c4121a 100755
--- a/t/t3020-ls-files-error-unmatch.sh
+++ b/t/t3020-ls-files-error-unmatch.sh
@@ -15,9 +15,9 @@ touch foo bar
git update-index --add foo bar
git-commit -m "add foo bar"
-test_expect_failure \
+test_expect_success \
'git ls-files --error-unmatch should fail with unmatched path.' \
- 'git ls-files --error-unmatch foo bar-does-not-match'
+ 'test_must_fail git ls-files --error-unmatch foo bar-does-not-match'
test_expect_success \
'git ls-files --error-unmatch should succeed eith matched paths.' \
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index 607f57ff9..aff360303 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -43,7 +43,7 @@ test_expect_success 'setup 1' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
test_expect_success 'setup 2' '
@@ -61,7 +61,7 @@ test_expect_success 'setup 2' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
echo goodbye >>a &&
o2=$(git hash-object a) &&
@@ -82,7 +82,7 @@ test_expect_success 'setup 2' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
test_expect_success 'setup 3' '
@@ -100,7 +100,7 @@ test_expect_success 'setup 3' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
o3=$(git hash-object b/c) &&
@@ -119,7 +119,7 @@ test_expect_success 'setup 3' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
test_expect_success 'setup 4' '
@@ -137,7 +137,7 @@ test_expect_success 'setup 4' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
o4=$(git hash-object a/c) &&
@@ -156,7 +156,7 @@ test_expect_success 'setup 4' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
test_expect_success 'setup 5' '
@@ -174,7 +174,7 @@ test_expect_success 'setup 5' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
rm -f b &&
echo remove-conflict >a &&
@@ -195,7 +195,7 @@ test_expect_success 'setup 5' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -214,7 +214,7 @@ test_expect_success 'setup 6' '
echo "100644 $o0 0 c"
echo "100644 $o0 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
rm -fr d && echo df-3 >d && git add d &&
o6=$(git hash-object d) &&
@@ -233,7 +233,7 @@ test_expect_success 'setup 6' '
echo "100644 $o0 0 c"
echo "100644 $o6 0 d"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
test_expect_success 'merge-recursive simple' '
@@ -265,7 +265,7 @@ test_expect_success 'merge-recursive result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -297,7 +297,7 @@ test_expect_success 'merge-recursive remove conflict' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -318,7 +318,7 @@ test_expect_success 'merge-recursive result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -352,7 +352,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -386,7 +386,7 @@ test_expect_success 'merge-recursive d/f conflict result the other way' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -420,7 +420,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 1 d/e"
echo "100644 $o1 2 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -454,7 +454,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
echo "100644 $o0 1 d/e"
echo "100644 $o1 3 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
@@ -480,7 +480,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual &&
+ test_cmp expected actual &&
git read-tree --prefix=a1/ master &&
git ls-files -s >actual &&
@@ -498,7 +498,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 c"
echo "100644 $o1 0 d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
git read-tree --prefix=z/ master &&
git ls-files -s >actual &&
@@ -520,7 +520,7 @@ test_expect_success 'reset and bind merge' '
echo "100644 $o0 0 z/c"
echo "100644 $o1 0 z/d/e"
) >expected &&
- git diff -u expected actual
+ test_cmp expected actual
'
diff --git a/t/t3040-subprojects-basic.sh b/t/t3040-subprojects-basic.sh
index 79b9f2365..f6973e96a 100755
--- a/t/t3040-subprojects-basic.sh
+++ b/t/t3040-subprojects-basic.sh
@@ -24,7 +24,7 @@ test_expect_success 'create subprojects' \
git add sub2 &&
git commit -q -m "subprojects added" &&
git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
- git diff expected current'
+ test_cmp expected current'
git branch save HEAD
@@ -62,7 +62,7 @@ test_expect_success 'check if clone works' \
'git ls-files -s >expected &&
git clone -l -s . cloned &&
( cd cloned && git ls-files -s ) >current &&
- git diff expected current'
+ test_cmp expected current'
test_expect_success 'removing and adding subproject' \
'git update-index --force-remove -- sub2 &&
diff --git a/t/t3050-subprojects-fetch.sh b/t/t3050-subprojects-fetch.sh
index 34f26a8d9..4261e9641 100755
--- a/t/t3050-subprojects-fetch.sh
+++ b/t/t3050-subprojects-fetch.sh
@@ -20,13 +20,13 @@ test_expect_success setup '
'
test_expect_success clone '
- git clone file://`pwd`/.git cloned &&
+ git clone "file://$(pwd)/.git" cloned &&
(git rev-parse HEAD; git ls-files -s) >expected &&
(
cd cloned &&
(git rev-parse HEAD; git ls-files -s) >../actual
) &&
- diff -u expected actual
+ test_cmp expected actual
'
test_expect_success advance '
@@ -46,7 +46,7 @@ test_expect_success fetch '
git pull &&
(git rev-parse HEAD; git ls-files -s) >../actual
) &&
- diff -u expected actual
+ test_cmp expected actual
'
test_done
diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh
index 68eb266d7..3ce501bb9 100755
--- a/t/t3060-ls-files-with-tree.sh
+++ b/t/t3060-ls-files-with-tree.sh
@@ -66,6 +66,6 @@ test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
cd ..
test_expect_success \
'git -ls-files --with-tree should add entries from named tree.' \
- 'diff -u expected output'
+ 'test_cmp expected output'
test_done
diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh
index 46427e3f3..6e6a2542a 100755
--- a/t/t3100-ls-tree-restrict.sh
+++ b/t/t3100-ls-tree-restrict.sh
@@ -35,7 +35,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
test_output () {
sed -e "s/ $_x40 / X /" <current >check
- git diff expected check
+ test_cmp expected check
}
test_expect_success \
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 39fe2676d..4dd7d12ba 100755
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -43,7 +43,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
test_output () {
sed -e "s/ $_x40 / X /" <current >check
- git diff expected check
+ test_cmp expected check
}
test_expect_success \
@@ -120,7 +120,7 @@ EOF
# having 1.txt and path3
test_expect_success \
'ls-tree filter odd names' \
- 'git ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current &&
+ 'git ls-tree $tree 1.txt ./1.txt .//1.txt path3/1.txt path3/./1.txt path3 path3// >current &&
cat >expected <<\EOF &&
100644 blob X 1.txt
100644 blob X path3/1.txt
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index ef1eeb7d8..7a83fbfe4 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -15,12 +15,16 @@ test_expect_success \
'echo Hello > A &&
git update-index --add A &&
git-commit -m "Initial commit." &&
+ echo World >> A &&
+ git update-index --add A &&
+ git-commit -m "Second commit." &&
HEAD=$(git rev-parse --verify HEAD)'
-test_expect_failure \
- 'git branch --help should not have created a bogus branch' \
- 'git branch --help </dev/null >/dev/null 2>/dev/null || :
- test -f .git/refs/heads/--help'
+test_expect_success \
+ 'git branch --help should not have created a bogus branch' '
+ git branch --help </dev/null >/dev/null 2>/dev/null;
+ ! test -f .git/refs/heads/--help
+'
test_expect_success \
'git branch abc should create a branch' \
@@ -71,17 +75,17 @@ test_expect_success \
git branch -m n/n n
test -f .git/logs/refs/heads/n'
-test_expect_failure \
- 'git branch -m o/o o should fail when o/p exists' \
- 'git branch o/o &&
+test_expect_success 'git branch -m o/o o should fail when o/p exists' '
+ git branch o/o &&
git branch o/p &&
- git branch -m o/o o'
+ test_must_fail git branch -m o/o o
+'
-test_expect_failure \
- 'git branch -m q r/q should fail when r exists' \
- 'git branch q &&
- git branch r &&
- git branch -m q r/q'
+test_expect_success 'git branch -m q r/q should fail when r exists' '
+ git branch q &&
+ git branch r &&
+ test_must_fail git branch -m q r/q
+'
mv .git/config .git/config-saved
@@ -106,14 +110,15 @@ test_expect_success \
test_expect_success 'config information was renamed, too' \
"test $(git config branch.s.dummy) = Hello &&
- ! git config branch.s/s/dummy"
+ test_must_fail git config branch.s/s/dummy"
-test_expect_failure \
- 'git branch -m u v should fail when the reflog for u is a symlink' \
- 'git branch -l u &&
+test_expect_success \
+ 'git branch -m u v should fail when the reflog for u is a symlink' '
+ git branch -l u &&
mv .git/logs/refs/heads/u real-u &&
ln -s real-u .git/logs/refs/heads/u &&
- git branch -m u v'
+ test_must_fail git branch -m u v
+'
test_expect_success 'test tracking setup via --track' \
'git config remote.local.url . &&
@@ -148,16 +153,6 @@ test_expect_success 'test tracking setup via config' \
test $(git config branch.my3.remote) = local &&
test $(git config branch.my3.merge) = refs/heads/master'
-test_expect_success 'avoid ambiguous track' '
- git config branch.autosetupmerge true &&
- git config remote.ambi1.url = lalala &&
- git config remote.ambi1.fetch = refs/heads/lalala:refs/heads/master &&
- git config remote.ambi2.url = lilili &&
- git config remote.ambi2.fetch = refs/heads/lilili:refs/heads/master &&
- git branch all1 master &&
- test -z "$(git config branch.all1.merge)"
-'
-
test_expect_success 'test overriding tracking setup via --no-track' \
'git config branch.autosetupmerge true &&
git config remote.local.url . &&
@@ -169,7 +164,9 @@ test_expect_success 'test overriding tracking setup via --no-track' \
! test "$(git config branch.my2.merge)" = refs/heads/master'
test_expect_success 'no tracking without .fetch entries' \
- 'git branch --track my6 s &&
+ 'git config branch.autosetupmerge true &&
+ git branch my6 s &&
+ git config branch.automsetupmerge false &&
test -z "$(git config branch.my6.remote)" &&
test -z "$(git config branch.my6.merge)"'
@@ -190,6 +187,21 @@ test_expect_success 'test deleting branch without config' \
'git branch my7 s &&
test "$(git branch -d my7 2>&1)" = "Deleted branch my7."'
+test_expect_success 'test --track without .fetch entries' \
+ 'git branch --track my8 &&
+ test "$(git config branch.my8.remote)" &&
+ test "$(git config branch.my8.merge)"'
+
+test_expect_success \
+ 'branch from non-branch HEAD w/autosetupmerge=always' \
+ 'git config branch.autosetupmerge always &&
+ git branch my9 HEAD^ &&
+ git config branch.autosetupmerge false'
+
+test_expect_success \
+ 'branch from non-branch HEAD w/--track causes failure' \
+ 'test_must_fail git branch --track my10 HEAD^'
+
# Keep this test last, as it changes the current branch
cat >expect <<EOF
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
@@ -202,4 +214,248 @@ test_expect_success \
test -f .git/logs/refs/heads/g/h/i &&
diff expect .git/logs/refs/heads/g/h/i'
+test_expect_success 'avoid ambiguous track' '
+ git config branch.autosetupmerge true &&
+ git config remote.ambi1.url lalala &&
+ git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
+ git config remote.ambi2.url lilili &&
+ git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
+ git branch all1 master &&
+ test -z "$(git config branch.all1.merge)"
+'
+
+test_expect_success 'autosetuprebase local on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase local &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase &&
+ git branch --track myr1 mybase &&
+ test "$(git config branch.myr1.remote)" = . &&
+ test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
+ test "$(git config branch.myr1.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase always on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase always &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase2 &&
+ git branch --track myr2 mybase &&
+ test "$(git config branch.myr2.remote)" = . &&
+ test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
+ test "$(git config branch.myr2.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase remote on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase3 &&
+ git branch --track myr3 mybase2 &&
+ test "$(git config branch.myr3.remote)" = . &&
+ test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
+ ! test "$(git config branch.myr3.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase never on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase never &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase4 &&
+ git branch --track myr4 mybase2 &&
+ test "$(git config branch.myr4.remote)" = . &&
+ test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
+ ! test "$(git config branch.myr4.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase local on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase local &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr5 local/master &&
+ test "$(git config branch.myr5.remote)" = local &&
+ test "$(git config branch.myr5.merge)" = refs/heads/master &&
+ ! test "$(git config branch.myr5.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase never on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase never &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr6 local/master &&
+ test "$(git config branch.myr6.remote)" = local &&
+ test "$(git config branch.myr6.merge)" = refs/heads/master &&
+ ! test "$(git config branch.myr6.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase remote on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr7 local/master &&
+ test "$(git config branch.myr7.remote)" = local &&
+ test "$(git config branch.myr7.merge)" = refs/heads/master &&
+ test "$(git config branch.myr7.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase always on a tracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ git config branch.autosetuprebase remote &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr8 local/master &&
+ test "$(git config branch.myr8.remote)" = local &&
+ test "$(git config branch.myr8.merge)" = refs/heads/master &&
+ test "$(git config branch.myr8.rebase)" = true
+'
+
+test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
+ git config --unset branch.autosetuprebase &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --track myr9 local/master &&
+ test "$(git config branch.myr9.remote)" = local &&
+ test "$(git config branch.myr9.merge)" = refs/heads/master &&
+ test "z$(git config branch.myr9.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/o || git-fetch local) &&
+ git branch mybase10 &&
+ git branch --track myr10 mybase2 &&
+ test "$(git config branch.myr10.remote)" = . &&
+ test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
+ test "z$(git config branch.myr10.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr11 mybase2 &&
+ test "z$(git config branch.myr11.remote)" = z &&
+ test "z$(git config branch.myr11.merge)" = z &&
+ test "z$(git config branch.myr11.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr12 local/master &&
+ test "z$(git config branch.myr12.remote)" = z &&
+ test "z$(git config branch.myr12.merge)" = z &&
+ test "z$(git config branch.myr12.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase never on an untracked local branch' '
+ git config branch.autosetuprebase never &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr13 mybase2 &&
+ test "z$(git config branch.myr13.remote)" = z &&
+ test "z$(git config branch.myr13.merge)" = z &&
+ test "z$(git config branch.myr13.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase local on an untracked local branch' '
+ git config branch.autosetuprebase local &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr14 mybase2 &&
+ test "z$(git config branch.myr14.remote)" = z &&
+ test "z$(git config branch.myr14.merge)" = z &&
+ test "z$(git config branch.myr14.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase remote on an untracked local branch' '
+ git config branch.autosetuprebase remote &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr15 mybase2 &&
+ test "z$(git config branch.myr15.remote)" = z &&
+ test "z$(git config branch.myr15.merge)" = z &&
+ test "z$(git config branch.myr15.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase always on an untracked local branch' '
+ git config branch.autosetuprebase always &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr16 mybase2 &&
+ test "z$(git config branch.myr16.remote)" = z &&
+ test "z$(git config branch.myr16.merge)" = z &&
+ test "z$(git config branch.myr16.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase never on an untracked remote branch' '
+ git config branch.autosetuprebase never &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr17 local/master &&
+ test "z$(git config branch.myr17.remote)" = z &&
+ test "z$(git config branch.myr17.merge)" = z &&
+ test "z$(git config branch.myr17.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase local on an untracked remote branch' '
+ git config branch.autosetuprebase local &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr18 local/master &&
+ test "z$(git config branch.myr18.remote)" = z &&
+ test "z$(git config branch.myr18.merge)" = z &&
+ test "z$(git config branch.myr18.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase remote on an untracked remote branch' '
+ git config branch.autosetuprebase remote &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr19 local/master &&
+ test "z$(git config branch.myr19.remote)" = z &&
+ test "z$(git config branch.myr19.merge)" = z &&
+ test "z$(git config branch.myr19.rebase)" = z
+'
+
+test_expect_success 'autosetuprebase always on an untracked remote branch' '
+ git config branch.autosetuprebase always &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git-fetch local) &&
+ git branch --no-track myr20 local/master &&
+ test "z$(git config branch.myr20.remote)" = z &&
+ test "z$(git config branch.myr20.merge)" = z &&
+ test "z$(git config branch.myr20.rebase)" = z
+'
+
+test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
+ git config branch.autosetuprebase garbage &&
+ test_must_fail git branch
+'
+
+test_expect_success 'detect misconfigured autosetuprebase (no value)' '
+ git config --unset branch.autosetuprebase &&
+ echo "[branch] autosetuprebase" >> .git/config &&
+ test_must_fail git branch &&
+ git config --unset branch.autosetuprebase
+'
+
test_done
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index 9ef593f0e..f86f4bc5e 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='branch --contains <commit>'
+test_description='branch --contains <commit>, --merged, and --no-merged'
. ./test-lib.sh
@@ -31,7 +31,7 @@ test_expect_success 'branch --contains=master' '
{
echo " master" && echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -41,7 +41,7 @@ test_expect_success 'branch --contains master' '
{
echo " master" && echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -51,7 +51,47 @@ test_expect_success 'branch --contains=side' '
{
echo "* side"
} >expect &&
- diff -u expect actual
+ test_cmp expect actual
+
+'
+
+test_expect_success 'side: branch --merged' '
+
+ git branch --merged >actual &&
+ {
+ echo " master" &&
+ echo "* side"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'side: branch --no-merged' '
+
+ git branch --no-merged >actual &&
+ >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'master: branch --merged' '
+
+ git checkout master &&
+ git branch --merged >actual &&
+ {
+ echo "* master"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'master: branch --no-merged' '
+
+ git branch --no-merged >actual &&
+ {
+ echo " side"
+ } >expect &&
+ test_cmp expect actual
'
diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch-octopus.sh
new file mode 100755
index 000000000..7fe4a6ecb
--- /dev/null
+++ b/t/t3202-show-branch-octopus.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='test show-branch with more than 8 heads'
+
+. ./test-lib.sh
+
+numbers="1 2 3 4 5 6 7 8 9 10"
+
+test_expect_success 'setup' '
+
+ > file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+
+ for i in $numbers
+ do
+ git checkout -b branch$i master &&
+ > file$i &&
+ git add file$i &&
+ test_tick &&
+ git commit -m branch$i || break
+ done
+
+'
+
+cat > expect << EOF
+! [branch1] branch1
+ ! [branch2] branch2
+ ! [branch3] branch3
+ ! [branch4] branch4
+ ! [branch5] branch5
+ ! [branch6] branch6
+ ! [branch7] branch7
+ ! [branch8] branch8
+ ! [branch9] branch9
+ * [branch10] branch10
+----------
+ * [branch10] branch10
+ + [branch9] branch9
+ + [branch8] branch8
+ + [branch7] branch7
+ + [branch6] branch6
+ + [branch5] branch5
+ + [branch4] branch4
+ + [branch3] branch3
+ + [branch2] branch2
++ [branch1] branch1
++++++++++* [branch10^] initial
+EOF
+
+test_expect_success 'show-branch with more than 8 branches' '
+
+ git show-branch $(for i in $numbers; do echo branch$i; done) > out &&
+ test_cmp expect out
+
+'
+
+test_done
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 4ddc6342a..c2dec1c63 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -39,12 +39,12 @@ test_expect_success \
git show-ref b >result &&
diff expect result'
-test_expect_failure \
- 'git branch c/d should barf if branch c exists' \
- 'git branch c &&
+test_expect_success 'git branch c/d should barf if branch c exists' '
+ git branch c &&
git pack-refs --all &&
- rm .git/refs/heads/c &&
- git branch c/d'
+ rm -f .git/refs/heads/c &&
+ test_must_fail git branch c/d
+'
test_expect_success \
'see if a branch still exists after git pack-refs --prune' \
@@ -54,11 +54,11 @@ test_expect_success \
git show-ref e >result &&
diff expect result'
-test_expect_failure \
- 'see if git pack-refs --prune remove ref files' \
- 'git branch f &&
+test_expect_success 'see if git pack-refs --prune remove ref files' '
+ git branch f &&
git pack-refs --all --prune &&
- ls .git/refs/heads/f'
+ ! test -f .git/refs/heads/f
+'
test_expect_success \
'git branch g should work when git branch g/h has been deleted' \
@@ -69,11 +69,11 @@ test_expect_success \
git pack-refs --all &&
git branch -d g'
-test_expect_failure \
- 'git branch i/j/k should barf if branch i exists' \
- 'git branch i &&
+test_expect_success 'git branch i/j/k should barf if branch i exists' '
+ git branch i &&
git pack-refs --all --prune &&
- git branch i/j/k'
+ test_must_fail git branch i/j/k
+'
test_expect_success \
'test git branch k after branch k/l/m and k/lm have been deleted' \
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 98c133db5..0574ef1f1 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -35,7 +35,7 @@ no-funny' >expected
test_expect_success 'git ls-files no-funny' \
'git update-index --add "$p0" "$p2" &&
git ls-files >current &&
- git diff expected current'
+ test_cmp expected current'
t0=`git write-tree`
echo "$t0" >t0
@@ -48,14 +48,14 @@ EOF
test_expect_success 'git ls-files with-funny' \
'git update-index --add "$p1" &&
git ls-files >current &&
- git diff expected current'
+ test_cmp expected current'
echo 'just space
no-funny
tabs ," (dq) and spaces' >expected
test_expect_success 'git ls-files -z with-funny' \
- 'git ls-files -z | tr \\000 \\012 >current &&
- git diff expected current'
+ 'git ls-files -z | perl -pe y/\\000/\\012/ >current &&
+ test_cmp expected current'
t1=`git write-tree`
echo "$t1" >t1
@@ -67,28 +67,28 @@ no-funny
EOF
test_expect_success 'git ls-tree with funny' \
'git ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
- git diff expected current'
+ test_cmp expected current'
cat > expected <<\EOF
A "tabs\t,\" (dq) and spaces"
EOF
test_expect_success 'git diff-index with-funny' \
'git diff-index --name-status $t0 >current &&
- git diff expected current'
+ test_cmp expected current'
test_expect_success 'git diff-tree with-funny' \
'git diff-tree --name-status $t0 $t1 >current &&
- git diff expected current'
+ test_cmp expected current'
echo 'A
tabs ," (dq) and spaces' >expected
test_expect_success 'git diff-index -z with-funny' \
- 'git diff-index -z --name-status $t0 | tr \\000 \\012 >current &&
- git diff expected current'
+ 'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current &&
+ test_cmp expected current'
test_expect_success 'git diff-tree -z with-funny' \
- 'git diff-tree -z --name-status $t0 $t1 | tr \\000 \\012 >current &&
- git diff expected current'
+ 'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current &&
+ test_cmp expected current'
cat > expected <<\EOF
CNUM no-funny "tabs\t,\" (dq) and spaces"
@@ -96,7 +96,7 @@ EOF
test_expect_success 'git diff-tree -C with-funny' \
'git diff-tree -C --find-copies-harder --name-status \
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
- git diff expected current'
+ test_cmp expected current'
cat > expected <<\EOF
RNUM no-funny "tabs\t,\" (dq) and spaces"
@@ -105,7 +105,7 @@ test_expect_success 'git diff-tree delete with-funny' \
'git update-index --force-remove "$p0" &&
git diff-index -M --name-status \
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
- git diff expected current'
+ test_cmp expected current'
cat > expected <<\EOF
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
@@ -116,7 +116,7 @@ EOF
test_expect_success 'git diff-tree delete with-funny' \
'git diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
- git diff expected current'
+ test_cmp expected current'
chmod +x "$p1"
cat > expected <<\EOF
@@ -130,7 +130,7 @@ EOF
test_expect_success 'git diff-tree delete with-funny' \
'git diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
- git diff expected current'
+ test_cmp expected current'
cat >expected <<\EOF
"tabs\t,\" (dq) and spaces"
@@ -139,7 +139,7 @@ EOF
test_expect_success 'git diff-tree rename with-funny applied' \
'git diff-index -M -p $t0 |
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
- git diff expected current'
+ test_cmp expected current'
cat > expected <<\EOF
no-funny
@@ -149,12 +149,12 @@ EOF
test_expect_success 'git diff-tree delete with-funny applied' \
'git diff-index -p $t0 |
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
- git diff expected current'
+ test_cmp expected current'
test_expect_success 'git apply non-git diff' \
'git diff-index -p $t0 |
sed -ne "/^[-+@]/p" |
git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
- git diff expected current'
+ test_cmp expected current'
test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 95e33b521..91bb5e1d9 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -9,7 +9,8 @@ This test runs git rebase and checks that the author information is not lost.
'
. ./test-lib.sh
-export GIT_AUTHOR_EMAIL=bogus_email_address
+GIT_AUTHOR_EMAIL=bogus_email_address
+export GIT_AUTHOR_EMAIL
test_expect_success \
'prepare repository with topic branches' \
@@ -42,15 +43,15 @@ test_expect_success \
test_expect_success 'rebase against master' '
git rebase master'
-test_expect_failure \
+test_expect_success \
'the rebase operation should not have destroyed author information' \
- 'git log | grep "Author:" | grep "<>"'
+ '! (git log | grep "Author:" | grep "<>")'
test_expect_success 'rebase after merge master' '
git reset --hard topic &&
git merge master &&
git rebase master &&
- ! git show | grep "^Merge:"
+ ! (git show | grep "^Merge:")
'
test_expect_success 'rebase of history with merges is linearized' '
diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh
index 4934a4e01..166ddb144 100755
--- a/t/t3401-rebase-partial.sh
+++ b/t/t3401-rebase-partial.sh
@@ -50,12 +50,12 @@ test_debug \
test_expect_success \
'rebase topic branch against new master and check git-am did not get halted' \
- 'git-rebase master && test ! -d .dotest'
+ 'git-rebase master && test ! -d .git/rebase-apply'
test_expect_success \
'rebase --merge topic branch that was partially merged upstream' \
'git-checkout -f my-topic-branch-merge &&
git-rebase --merge master-merge &&
- test ! -d .git/.dotest-merge'
+ test ! -d .git/rebase-merge'
test_done
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
index 657f68104..0d33c71da 100755
--- a/t/t3403-rebase-skip.sh
+++ b/t/t3403-rebase-skip.sh
@@ -31,8 +31,8 @@ test_expect_success setup '
git branch skip-merge skip-reference
'
-test_expect_failure 'rebase with git am -3 (default)' '
- git rebase master
+test_expect_success 'rebase with git am -3 (default)' '
+ test_must_fail git rebase master
'
test_expect_success 'rebase --skip with am -3' '
@@ -43,7 +43,7 @@ test_expect_success 'rebase moves back to skip-reference' '
test refs/heads/skip-reference = $(git symbolic-ref HEAD) &&
git branch post-rebase &&
git reset --hard pre-rebase &&
- ! git rebase master &&
+ test_must_fail git rebase master &&
echo "hello" > hello &&
git add hello &&
git rebase --continue &&
@@ -53,7 +53,9 @@ test_expect_success 'rebase moves back to skip-reference' '
test_expect_success 'checkout skip-merge' 'git checkout -f skip-merge'
-test_expect_failure 'rebase with --merge' 'git rebase --merge master'
+test_expect_success 'rebase with --merge' '
+ test_must_fail git rebase --merge master
+'
test_expect_success 'rebase --skip with --merge' '
git rebase --skip
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 74a7eb30f..5aa487ac0 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -61,8 +61,8 @@ test_expect_success 'setup' '
git tag I
'
-cat > fake-editor.sh <<\EOF
-#!/bin/sh
+echo "#!$SHELL_PATH" >fake-editor.sh
+cat >> fake-editor.sh <<\EOF
case "$1" in
*/COMMIT_EDITMSG)
test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
@@ -91,12 +91,12 @@ for line in $FAKE_LINES; do
done
EOF
+test_set_editor "$(pwd)/fake-editor.sh"
chmod a+x fake-editor.sh
-VISUAL="$(pwd)/fake-editor.sh"
-export VISUAL
test_expect_success 'no changes are a nop' '
git rebase -i F &&
+ test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
test $(git rev-parse I) = $(git rev-parse HEAD)
'
@@ -105,14 +105,26 @@ test_expect_success 'test the [branch] option' '
git rm file6 &&
git commit -m "stop here" &&
git rebase -i F branch2 &&
+ test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
+ test $(git rev-parse I) = $(git rev-parse branch2) &&
test $(git rev-parse I) = $(git rev-parse HEAD)
'
+test_expect_success 'test --onto <branch>' '
+ git checkout -b test-onto branch2 &&
+ git rebase -i --onto branch1 F &&
+ test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
+ test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
+ test $(git rev-parse I) = $(git rev-parse branch2)
+'
+
test_expect_success 'rebase on top of a non-conflicting commit' '
git checkout branch1 &&
git tag original-branch1 &&
git rebase -i branch2 &&
test file6 = $(git diff --name-only original-branch1) &&
+ test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
+ test $(git rev-parse I) = $(git rev-parse branch2) &&
test $(git rev-parse I) = $(git rev-parse HEAD~2)
'
@@ -122,8 +134,8 @@ test_expect_success 'reflog for the branch shows state before rebase' '
test_expect_success 'exchange two commits' '
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
- test H = $(git cat-file commit HEAD^ | tail -n 1) &&
- test G = $(git cat-file commit HEAD | tail -n 1)
+ test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
+ test G = $(git cat-file commit HEAD | sed -ne \$p)
'
cat > expect << EOF
@@ -145,18 +157,21 @@ EOF
test_expect_success 'stop on conflicting pick' '
git tag new-branch1 &&
- ! git rebase -i master &&
- diff -u expect .git/.dotest-merge/patch &&
- diff -u expect2 file1 &&
- test 4 = $(grep -v "^#" < .git/.dotest-merge/done | wc -l) &&
- test 0 = $(grep -ve "^#" -e "^$" < .git/.dotest-merge/git-rebase-todo |
- wc -l)
+ test_must_fail git rebase -i master &&
+ test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" &&
+ test_cmp expect .git/rebase-merge/patch &&
+ test_cmp expect2 file1 &&
+ test "$(git-diff --name-status |
+ sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
+ test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
+ test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
'
test_expect_success 'abort' '
git rebase --abort &&
test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
- ! test -d .git/.dotest-merge
+ test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
+ ! test -d .git/rebase-merge
'
test_expect_success 'retain authorship' '
@@ -187,6 +202,9 @@ test_expect_success 'retain authorship when squashing' '
test_expect_success '-p handles "no changes" gracefully' '
HEAD=$(git rev-parse HEAD) &&
git rebase -i -p HEAD^ &&
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD -- &&
test $HEAD = $(git rev-parse HEAD)
'
@@ -196,7 +214,7 @@ test_expect_success 'preserve merges with -p' '
git add unrelated-file &&
test_tick &&
git commit -m "unrelated" &&
- git checkout -b to-be-rebased master &&
+ git checkout -b another-branch master &&
echo B > file1 &&
test_tick &&
git commit -m J file1 &&
@@ -205,17 +223,48 @@ test_expect_success 'preserve merges with -p' '
echo C > file1 &&
test_tick &&
git commit -m K file1 &&
+ echo D > file1 &&
+ test_tick &&
+ git commit -m L1 file1 &&
+ git checkout HEAD^ &&
+ echo 1 > unrelated-file &&
+ test_tick &&
+ git commit -m L2 unrelated-file &&
+ test_tick &&
+ git merge another-branch &&
+ echo E > file1 &&
+ test_tick &&
+ git commit -m M file1 &&
+ git checkout -b to-be-rebased &&
test_tick &&
git rebase -i -p --onto branch1 master &&
- test $(git rev-parse HEAD^^2) = $(git rev-parse to-be-preserved) &&
- test $(git rev-parse HEAD~3) = $(git rev-parse branch1) &&
- test $(git show HEAD:file1) = C &&
- test $(git show HEAD~2:file1) = B
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD -- &&
+ test $(git rev-parse HEAD~6) = $(git rev-parse branch1) &&
+ test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) &&
+ test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) &&
+ test $(git show HEAD~5:file1) = B &&
+ test $(git show HEAD~3:file1) = C &&
+ test $(git show HEAD:file1) = E &&
+ test $(git show HEAD:unrelated-file) = 1
+'
+
+test_expect_success 'edit ancestor with -p' '
+ FAKE_LINES="1 edit 2 3 4" git rebase -i -p HEAD~3 &&
+ echo 2 > unrelated-file &&
+ test_tick &&
+ git commit -m L2-modified --amend unrelated-file &&
+ git rebase --continue &&
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD -- &&
+ test $(git show HEAD:unrelated-file) = 2
'
test_expect_success '--continue tries to commit' '
test_tick &&
- ! git rebase -i --onto new-branch1 HEAD^ &&
+ test_must_fail git rebase -i --onto new-branch1 HEAD^ &&
echo resolved > file1 &&
git add file1 &&
FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
@@ -226,7 +275,7 @@ test_expect_success '--continue tries to commit' '
test_expect_success 'verbose flag is heeded, even after --continue' '
git reset --hard HEAD@{1} &&
test_tick &&
- ! git rebase -v -i --onto new-branch1 HEAD^ &&
+ test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
echo resolved > file1 &&
git add file1 &&
git rebase --continue > output &&
@@ -261,10 +310,14 @@ test_expect_success 'interrupted squash works as expected' '
git commit -m $n
done &&
one=$(git rev-parse HEAD~3) &&
- ! FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
+ (
+ FAKE_LINES="1 squash 3 2" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i HEAD~3
+ ) &&
(echo one; echo two; echo four) > conflict &&
git add conflict &&
- ! git rebase --continue &&
+ test_must_fail git rebase --continue &&
echo resolved > conflict &&
git add conflict &&
git rebase --continue &&
@@ -279,13 +332,17 @@ test_expect_success 'interrupted squash works as expected (case 2)' '
git commit -m $n
done &&
one=$(git rev-parse HEAD~3) &&
- ! FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
+ (
+ FAKE_LINES="3 squash 1 2" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i HEAD~3
+ ) &&
(echo one; echo four) > conflict &&
git add conflict &&
- ! git rebase --continue &&
+ test_must_fail git rebase --continue &&
(echo one; echo two; echo four) > conflict &&
git add conflict &&
- ! git rebase --continue &&
+ test_must_fail git rebase --continue &&
echo resolved > conflict &&
git add conflict &&
git rebase --continue &&
@@ -324,4 +381,42 @@ test_expect_success 'rebase a detached HEAD' '
test $grandparent = $(git rev-parse HEAD~2)
'
+test_expect_success 'rebase a commit violating pre-commit' '
+
+ mkdir -p .git/hooks &&
+ PRE_COMMIT=.git/hooks/pre-commit &&
+ echo "#!/bin/sh" > $PRE_COMMIT &&
+ echo "test -z \"\$(git diff --cached --check)\"" >> $PRE_COMMIT &&
+ chmod a+x $PRE_COMMIT &&
+ echo "monde! " >> file1 &&
+ test_tick &&
+ test_must_fail git commit -m doesnt-verify file1 &&
+ git commit -m doesnt-verify --no-verify file1 &&
+ test_tick &&
+ FAKE_LINES=2 git rebase -i HEAD~2
+
+'
+
+test_expect_success 'rebase with a file named HEAD in worktree' '
+
+ rm -fr .git/hooks &&
+ git reset --hard &&
+ git checkout -b branch3 A &&
+
+ (
+ GIT_AUTHOR_NAME="Squashed Away" &&
+ export GIT_AUTHOR_NAME &&
+ >HEAD &&
+ git add HEAD &&
+ git commit -m "Add head" &&
+ >BODY &&
+ git add BODY &&
+ git commit -m "Add body"
+ ) &&
+
+ FAKE_LINES="1 squash 2" git rebase -i to-be-rebased &&
+ test "$(git show -s --pretty=format:%an)" = "Squashed Away"
+
+'
+
test_done
diff --git a/t/t3405-rebase-malformed.sh b/t/t3405-rebase-malformed.sh
index e4e2e649e..e5ad67c64 100755
--- a/t/t3405-rebase-malformed.sh
+++ b/t/t3405-rebase-malformed.sh
@@ -41,8 +41,8 @@ test_expect_success rebase '
git rebase master side &&
git cat-file commit HEAD | sed -e "1,/^\$/d" >F1 &&
- diff -u F0 F1 &&
- diff -u F F0
+ test_cmp F0 F1 &&
+ test_cmp F F0
'
test_done
diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh
index 332b2b2fe..539108094 100755
--- a/t/t3406-rebase-message.sh
+++ b/t/t3406-rebase-message.sh
@@ -37,7 +37,7 @@ test_expect_success 'rebase -m' '
git rebase -m master >report &&
sed -n -e "/^Already applied: /p" \
-e "/^Committed: /p" report >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
new file mode 100755
index 000000000..4de550a63
--- /dev/null
+++ b/t/t3407-rebase-abort.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+test_description='git rebase --abort tests'
+
+. ./test-lib.sh
+
+### Test that we handle space characters properly
+work_dir="$(pwd)/test dir"
+
+test_expect_success setup '
+ mkdir -p "$work_dir" &&
+ cd "$work_dir" &&
+ git init &&
+ echo a > a &&
+ git add a &&
+ git commit -m a &&
+ git branch to-rebase &&
+
+ echo b > a &&
+ git commit -a -m b &&
+ echo c > a &&
+ git commit -a -m c &&
+
+ git checkout to-rebase &&
+ echo d > a &&
+ git commit -a -m "merge should fail on this" &&
+ echo e > a &&
+ git commit -a -m "merge should fail on this, too" &&
+ git branch pre-rebase
+'
+
+testrebase() {
+ type=$1
+ dotest=$2
+
+ test_expect_success "rebase$type --abort" '
+ cd "$work_dir" &&
+ # Clean up the state from the previous one
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
+ git rebase --abort &&
+ test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+ test ! -d "$dotest"
+ '
+
+ test_expect_success "rebase$type --abort after --skip" '
+ cd "$work_dir" &&
+ # Clean up the state from the previous one
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
+ test_must_fail git rebase --skip &&
+ test $(git rev-parse HEAD) = $(git rev-parse master) &&
+ git-rebase --abort &&
+ test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+ test ! -d "$dotest"
+ '
+
+ test_expect_success "rebase$type --abort after --continue" '
+ cd "$work_dir" &&
+ # Clean up the state from the previous one
+ git reset --hard pre-rebase &&
+ test_must_fail git rebase$type master &&
+ test -d "$dotest" &&
+ echo c > a &&
+ echo d >> a &&
+ git add a &&
+ test_must_fail git rebase --continue &&
+ test $(git rev-parse HEAD) != $(git rev-parse master) &&
+ git rebase --abort &&
+ test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+ test ! -d "$dotest"
+ '
+}
+
+testrebase "" .git/rebase-apply
+testrebase " --merge" .git/rebase-merge
+
+test_done
diff --git a/t/t3408-rebase-multi-line.sh b/t/t3408-rebase-multi-line.sh
new file mode 100755
index 000000000..e12cd578e
--- /dev/null
+++ b/t/t3408-rebase-multi-line.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='rebasing a commit with multi-line first paragraph.'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ >file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+
+ echo hello >file &&
+ test_tick &&
+ git commit -a -m "A sample commit log message that has a long
+summary that spills over multiple lines.
+
+But otherwise with a sane description."
+
+ git branch side &&
+
+ git reset --hard HEAD^ &&
+ >elif &&
+ git add elif &&
+ test_tick &&
+ git commit -m second
+
+'
+
+test_expect_success rebase '
+
+ git checkout side &&
+ git rebase master &&
+ git cat-file commit HEAD | sed -e "1,/^$/d" >actual &&
+ git cat-file commit side@{1} | sed -e "1,/^$/d" >expect &&
+ test_cmp expect actual
+
+'
+
+test_done
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
index d0a440feb..4911c4837 100755
--- a/t/t3500-cherry.sh
+++ b/t/t3500-cherry.sh
@@ -10,7 +10,8 @@ checks that git cherry only returns the second patch in the local branch
'
. ./test-lib.sh
-export GIT_AUTHOR_EMAIL=bogus_email_address
+GIT_AUTHOR_EMAIL=bogus_email_address
+export GIT_AUTHOR_EMAIL
test_expect_success \
'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 2dbe04fb2..6da212825 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -59,4 +59,13 @@ test_expect_success 'revert after renaming branch' '
'
+test_expect_success 'revert forbidden on dirty working tree' '
+
+ echo content >extra_file &&
+ git add extra_file &&
+ test_must_fail git revert HEAD 2>errors &&
+ grep "Dirty index" errors
+
+'
+
test_done
diff --git a/t/t3502-cherry-pick-merge.sh b/t/t3502-cherry-pick-merge.sh
index 7c92e261f..0ab52da90 100755
--- a/t/t3502-cherry-pick-merge.sh
+++ b/t/t3502-cherry-pick-merge.sh
@@ -35,7 +35,7 @@ test_expect_success 'cherry-pick a non-merge with -m should fail' '
git reset --hard &&
git checkout a^0 &&
- ! git cherry-pick -m 1 b &&
+ test_must_fail git cherry-pick -m 1 b &&
git diff --exit-code a --
'
@@ -44,7 +44,7 @@ test_expect_success 'cherry pick a merge without -m should fail' '
git reset --hard &&
git checkout a^0 &&
- ! git cherry-pick c &&
+ test_must_fail git cherry-pick c &&
git diff --exit-code a --
'
@@ -71,7 +71,7 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent should f
git reset --hard &&
git checkout b^0 &&
- ! git cherry-pick -m 3 c
+ test_must_fail git cherry-pick -m 3 c
'
@@ -79,7 +79,7 @@ test_expect_success 'revert a non-merge with -m should fail' '
git reset --hard &&
git checkout c^0 &&
- ! git revert -m 1 b &&
+ test_must_fail git revert -m 1 b &&
git diff --exit-code c
'
@@ -88,7 +88,7 @@ test_expect_success 'revert a merge without -m should fail' '
git reset --hard &&
git checkout c^0 &&
- ! git revert c &&
+ test_must_fail git revert c &&
git diff --exit-code c
'
@@ -115,7 +115,7 @@ test_expect_success 'revert a merge relative to nonexistent parent should fail'
git reset --hard &&
git checkout c^0 &&
- ! git revert -m 3 c &&
+ test_must_fail git revert -m 3 c &&
git diff --exit-code c
'
diff --git a/t/t3503-cherry-pick-root.sh b/t/t3503-cherry-pick-root.sh
new file mode 100755
index 000000000..b0faa2991
--- /dev/null
+++ b/t/t3503-cherry-pick-root.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='test cherry-picking a root commit'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ echo first > file1 &&
+ git add file1 &&
+ test_tick &&
+ git commit -m "first" &&
+
+ git symbolic-ref HEAD refs/heads/second &&
+ rm .git/index file1 &&
+ echo second > file2 &&
+ git add file2 &&
+ test_tick &&
+ git commit -m "second"
+
+'
+
+test_expect_success 'cherry-pick a root commit' '
+
+ git cherry-pick master &&
+ test first = $(cat file1)
+
+'
+
+test_done
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index b1ee622ef..79c06adf1 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -59,15 +59,16 @@ test_expect_success \
echo "other content" > foo
git rm --cached foo'
-test_expect_failure \
- 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' \
- 'echo content > foo
+test_expect_success \
+ 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' '
+ echo content > foo
git add foo
git commit -m foo
echo "other content" > foo
git add foo
echo "yet another content" > foo
- git rm --cached foo'
+ test_must_fail git rm --cached foo
+'
test_expect_success \
'Test that git rm --cached -f foo works in case where --cached only did not' \
@@ -81,7 +82,7 @@ test_expect_success \
test_expect_success \
'Post-check that foo exists but is not in index after git rm foo' \
- '[ -f foo ] && ! git ls-files --error-unmatch foo'
+ '[ -f foo ] && test_must_fail git ls-files --error-unmatch foo'
test_expect_success \
'Pre-check that bar exists and is in index before "git rm bar"' \
@@ -93,7 +94,7 @@ test_expect_success \
test_expect_success \
'Post-check that bar does not exist and is not in index after "git rm -f bar"' \
- '! [ -f bar ] && ! git ls-files --error-unmatch bar'
+ '! [ -f bar ] && test_must_fail git ls-files --error-unmatch bar'
test_expect_success \
'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \
@@ -106,9 +107,9 @@ embedded'"
if test "$test_failed_remove" = y; then
chmod a-w .
-test_expect_failure \
+test_expect_success \
'Test that "git rm -f" fails if its rm fails' \
- 'git rm -f baz'
+ 'test_must_fail git rm -f baz'
chmod 775 .
else
test_expect_success 'skipping removal failure (perhaps running as root?)' :
@@ -150,7 +151,7 @@ test_expect_success 'Re-add foo and baz' '
test_expect_success 'Modify foo -- rm should refuse' '
echo >>foo &&
- ! git rm foo baz &&
+ test_must_fail git rm foo baz &&
test -f foo &&
test -f baz &&
git ls-files --error-unmatch foo baz
@@ -160,8 +161,8 @@ test_expect_success 'Modified foo -- rm -f should work' '
git rm -f foo baz &&
test ! -f foo &&
test ! -f baz &&
- ! git ls-files --error-unmatch foo &&
- ! git ls-files --error-unmatch bar
+ test_must_fail git ls-files --error-unmatch foo &&
+ test_must_fail git ls-files --error-unmatch bar
'
test_expect_success 'Re-add foo and baz for HEAD tests' '
@@ -172,7 +173,7 @@ test_expect_success 'Re-add foo and baz for HEAD tests' '
'
test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
- ! git rm foo baz &&
+ test_must_fail git rm foo baz &&
test -f foo &&
test -f baz &&
git ls-files --error-unmatch foo baz
@@ -182,8 +183,8 @@ test_expect_success 'but with -f it should work.' '
git rm -f foo baz &&
test ! -f foo &&
test ! -f baz &&
- ! git ls-files --error-unmatch foo
- ! git ls-files --error-unmatch baz
+ test_must_fail git ls-files --error-unmatch foo
+ test_must_fail git ls-files --error-unmatch baz
'
test_expect_success 'Recursive test setup' '
@@ -194,14 +195,14 @@ test_expect_success 'Recursive test setup' '
'
test_expect_success 'Recursive without -r fails' '
- ! git rm frotz &&
+ test_must_fail git rm frotz &&
test -d frotz &&
test -f frotz/nitfol
'
test_expect_success 'Recursive with -r but dirty' '
echo qfwfq >>frotz/nitfol
- ! git rm -r frotz &&
+ test_must_fail git rm -r frotz &&
test -d frotz &&
test -f frotz/nitfol
'
@@ -212,8 +213,20 @@ test_expect_success 'Recursive with -r -f' '
! test -d frotz
'
-test_expect_failure 'Remove nonexistent file returns nonzero exit status' '
- git rm nonexistent
+test_expect_success 'Remove nonexistent file returns nonzero exit status' '
+ test_must_fail git rm nonexistent
+'
+
+test_expect_success 'Call "rm" from outside the work tree' '
+ mkdir repo &&
+ cd repo &&
+ git init &&
+ echo something > somefile &&
+ git add somefile &&
+ git commit -m "add a file" &&
+ (cd .. &&
+ git --git-dir=repo/.git --work-tree=repo rm somefile) &&
+ test_must_fail git ls-files --error-unmatch somefile
'
test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 287e058e3..2ac93a346 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -81,17 +81,17 @@ test_expect_success '.gitignore test setup' '
test_expect_success '.gitignore is honored' '
git add . &&
- ! git ls-files | grep "\\.ig"
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'error out when attempting to add ignored ones without -f' '
- ! git add a.?? &&
- ! git ls-files | grep "\\.ig"
+ test_must_fail git add a.?? &&
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'error out when attempting to add ignored ones without -f' '
- ! git add d.?? &&
- ! git ls-files | grep "\\.ig"
+ test_must_fail git add d.?? &&
+ ! (git ls-files | grep "\\.ig")
'
test_expect_success 'add ignored ones with -f' '
@@ -179,4 +179,55 @@ test_expect_success 'git add --refresh' '
test -z "`git diff-index HEAD -- foo`"
'
+test_expect_success 'git add should fail atomically upon an unreadable file' '
+ git reset --hard &&
+ date >foo1 &&
+ date >foo2 &&
+ chmod 0 foo2 &&
+ test_must_fail git add --verbose . &&
+ ! ( git ls-files foo1 | grep foo1 )
+'
+
+rm -f foo2
+
+test_expect_success 'git add --ignore-errors' '
+ git reset --hard &&
+ date >foo1 &&
+ date >foo2 &&
+ chmod 0 foo2 &&
+ test_must_fail git add --verbose --ignore-errors . &&
+ git ls-files foo1 | grep foo1
+'
+
+rm -f foo2
+
+test_expect_success 'git add (add.ignore-errors)' '
+ git config add.ignore-errors 1 &&
+ git reset --hard &&
+ date >foo1 &&
+ date >foo2 &&
+ chmod 0 foo2 &&
+ test_must_fail git add --verbose . &&
+ git ls-files foo1 | grep foo1
+'
+rm -f foo2
+
+test_expect_success 'git add (add.ignore-errors = false)' '
+ git config add.ignore-errors 0 &&
+ git reset --hard &&
+ date >foo1 &&
+ date >foo2 &&
+ chmod 0 foo2 &&
+ test_must_fail git add --verbose . &&
+ ! ( git ls-files foo1 | grep foo1 )
+'
+
+test_expect_success 'git add '\''fo\[ou\]bar'\'' ignores foobar' '
+ git reset --hard &&
+ touch fo\[ou\]bar foobar &&
+ git add '\''fo\[ou\]bar'\'' &&
+ git ls-files fo\[ou\]bar | grep -F fo\[ou\]bar &&
+ ! ( git ls-files foobar | grep foobar )
+'
+
test_done
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
new file mode 100755
index 000000000..e95663d8e
--- /dev/null
+++ b/t/t3701-add-interactive.sh
@@ -0,0 +1,162 @@
+#!/bin/sh
+
+test_description='add -i basic tests'
+. ./test-lib.sh
+
+test_expect_success 'setup (initial)' '
+ echo content >file &&
+ git add file &&
+ echo more >>file &&
+ echo lines >>file
+'
+test_expect_success 'status works (initial)' '
+ git add -i </dev/null >output &&
+ grep "+1/-0 *+2/-0 file" output
+'
+cat >expected <<EOF
+new file mode 100644
+index 0000000..d95f3ad
+--- /dev/null
++++ b/file
+@@ -0,0 +1 @@
++content
+EOF
+test_expect_success 'diff works (initial)' '
+ (echo d; echo 1) | git add -i >output &&
+ sed -ne "/new file/,/content/p" <output >diff &&
+ test_cmp expected diff
+'
+test_expect_success 'revert works (initial)' '
+ git add file &&
+ (echo r; echo 1) | git add -i &&
+ git ls-files >output &&
+ ! grep . output
+'
+
+test_expect_success 'setup (commit)' '
+ echo baseline >file &&
+ git add file &&
+ git commit -m commit &&
+ echo content >>file &&
+ git add file &&
+ echo more >>file &&
+ echo lines >>file
+'
+test_expect_success 'status works (commit)' '
+ git add -i </dev/null >output &&
+ grep "+1/-0 *+2/-0 file" output
+'
+cat >expected <<EOF
+index 180b47c..b6f2c08 100644
+--- a/file
++++ b/file
+@@ -1 +1,2 @@
+ baseline
++content
+EOF
+test_expect_success 'diff works (commit)' '
+ (echo d; echo 1) | git add -i >output &&
+ sed -ne "/^index/,/content/p" <output >diff &&
+ test_cmp expected diff
+'
+test_expect_success 'revert works (commit)' '
+ git add file &&
+ (echo r; echo 1) | git add -i &&
+ git add -i </dev/null >output &&
+ grep "unchanged *+3/-0 file" output
+'
+
+cat >expected <<EOF
+EOF
+cat >fake_editor.sh <<EOF
+EOF
+chmod a+x fake_editor.sh
+test_set_editor "$(pwd)/fake_editor.sh"
+test_expect_success 'dummy edit works' '
+ (echo e; echo a) | git add -p &&
+ git diff > diff &&
+ test_cmp expected diff
+'
+
+cat >patch <<EOF
+@@ -1,1 +1,4 @@
+ this
++patch
+-doesn't
+ apply
+EOF
+echo "#!$SHELL_PATH" >fake_editor.sh
+cat >>fake_editor.sh <<\EOF
+mv -f "$1" oldpatch &&
+mv -f patch "$1"
+EOF
+chmod a+x fake_editor.sh
+test_set_editor "$(pwd)/fake_editor.sh"
+test_expect_success 'bad edit rejected' '
+ git reset &&
+ (echo e; echo n; echo d) | git add -p >output &&
+ grep "hunk does not apply" output
+'
+
+cat >patch <<EOF
+this patch
+is garbage
+EOF
+test_expect_success 'garbage edit rejected' '
+ git reset &&
+ (echo e; echo n; echo d) | git add -p >output &&
+ grep "hunk does not apply" output
+'
+
+cat >patch <<EOF
+@@ -1,0 +1,0 @@
+ baseline
++content
++newcontent
++lines
+EOF
+cat >expected <<EOF
+diff --git a/file b/file
+index b5dd6c9..f910ae9 100644
+--- a/file
++++ b/file
+@@ -1,4 +1,4 @@
+ baseline
+ content
+-newcontent
++more
+ lines
+EOF
+test_expect_success 'real edit works' '
+ (echo e; echo n; echo d) | git add -p &&
+ git diff >output &&
+ test_cmp expected output
+'
+
+if test "$(git config --bool core.filemode)" = false
+then
+ say 'skipping filemode tests (filesystem does not properly support modes)'
+else
+
+test_expect_success 'patch does not affect mode' '
+ git reset --hard &&
+ echo content >>file &&
+ chmod +x file &&
+ printf "n\\ny\\n" | git add -p &&
+ git show :file | grep content &&
+ git diff file | grep "new mode"
+'
+
+test_expect_success 'stage mode but not hunk' '
+ git reset --hard &&
+ echo content >>file &&
+ chmod +x file &&
+ printf "y\\nn\\n" | git add -p &&
+ git diff --cached file | grep "new mode" &&
+ git diff file | grep "+content"
+'
+
+fi
+# end of tests disabled when filemode is not usable
+
+test_done
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index f2803206f..c851db8ca 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -14,8 +14,8 @@ test_description='git-mktag: tag object verify test'
check_verify_failure () {
expect="$2"
test_expect_success "$1" '
- ( ! git-mktag <tag.sig 2>message ) &&
- grep -q "$expect" message
+ ( test_must_fail git-mktag <tag.sig 2>message ) &&
+ grep "$expect" message
'
}
@@ -44,6 +44,8 @@ cat >tag.sig <<EOF
xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
type tag
tag mytag
+tagger . <> 0 +0000
+
EOF
check_verify_failure '"object" line label check' '^error: char0: .*"object "$'
@@ -55,6 +57,8 @@ cat >tag.sig <<EOF
object zz9e9b33986b1c2670fff52c5067603117b3e895
type tag
tag mytag
+tagger . <> 0 +0000
+
EOF
check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
@@ -66,6 +70,8 @@ cat >tag.sig <<EOF
object 779e9b33986b1c2670fff52c5067603117b3e895
xxxx tag
tag mytag
+tagger . <> 0 +0000
+
EOF
check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$'
@@ -85,6 +91,8 @@ cat >tag.sig <<EOF
object 779e9b33986b1c2670fff52c5067603117b3e895
type tag
xxx mytag
+tagger . <> 0 +0000
+
EOF
check_verify_failure '"tag" line label check #1' \
@@ -121,6 +129,8 @@ cat >tag.sig <<EOF
object 779e9b33986b1c2670fff52c5067603117b3e895
type tagggg
tag mytag
+tagger . <> 0 +0000
+
EOF
check_verify_failure 'verify object (SHA1/type) check' \
@@ -133,6 +143,8 @@ cat >tag.sig <<EOF
object $head
type commit
tag my tag
+tagger . <> 0 +0000
+
EOF
check_verify_failure 'verify tag-name check' \
@@ -145,10 +157,12 @@ cat >tag.sig <<EOF
object $head
type commit
tag mytag
+
+This is filler
EOF
check_verify_failure '"tagger" line label check #1' \
- '^error: char70: could not find "tagger"$'
+ '^error: char70: could not find "tagger "$'
############################################################
# 12. tagger line label check #2
@@ -158,19 +172,180 @@ object $head
type commit
tag mytag
tagger
+
+This is filler
EOF
check_verify_failure '"tagger" line label check #2' \
- '^error: char70: could not find "tagger"$'
+ '^error: char70: could not find "tagger "$'
+
+############################################################
+# 13. disallow missing tag author name
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger <> 0 +0000
+
+This is filler
+EOF
+
+check_verify_failure 'disallow missing tag author name' \
+ '^error: char77: missing tagger name$'
+
+############################################################
+# 14. disallow missing tag author name
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <
+ > 0 +0000
+
+EOF
+
+check_verify_failure 'disallow malformed tagger' \
+ '^error: char77: malformed tagger field$'
+
+############################################################
+# 15. allow empty tag email
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <> 0 +0000
+
+EOF
+
+test_expect_success \
+ 'allow empty tag email' \
+ 'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
+
+############################################################
+# 16. disallow spaces in tag email
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tag ger@example.com> 0 +0000
+
+EOF
+
+check_verify_failure 'disallow spaces in tag email' \
+ '^error: char77: malformed tagger field$'
+
+############################################################
+# 17. disallow missing tag timestamp
+
+tr '_' ' ' >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com>__
+
+EOF
+
+check_verify_failure 'disallow missing tag timestamp' \
+ '^error: char107: missing tag timestamp$'
+
+############################################################
+# 18. detect invalid tag timestamp1
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
+
+EOF
+
+check_verify_failure 'detect invalid tag timestamp1' \
+ '^error: char107: missing tag timestamp$'
+
+############################################################
+# 19. detect invalid tag timestamp2
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
+
+EOF
+
+check_verify_failure 'detect invalid tag timestamp2' \
+ '^error: char111: malformed tag timestamp$'
+
+############################################################
+# 20. detect invalid tag timezone1
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 GMT
+
+EOF
+
+check_verify_failure 'detect invalid tag timezone1' \
+ '^error: char118: malformed tag timezone$'
+
+############################################################
+# 21. detect invalid tag timezone2
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 + 30
+
+EOF
+
+check_verify_failure 'detect invalid tag timezone2' \
+ '^error: char118: malformed tag timezone$'
+
+############################################################
+# 22. detect invalid tag timezone3
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 -1430
+
+EOF
+
+check_verify_failure 'detect invalid tag timezone3' \
+ '^error: char118: malformed tag timezone$'
############################################################
-# 13. create valid tag
+# 23. detect invalid header entry
cat >tag.sig <<EOF
object $head
type commit
tag mytag
-tagger another@example.com
+tagger T A Gger <tagger@example.com> 1206478233 -0500
+this line should not be here
+
+EOF
+
+check_verify_failure 'detect invalid header entry' \
+ '^error: char124: trailing garbage in tag header$'
+
+############################################################
+# 24. create valid tag
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger T A Gger <tagger@example.com> 1206478233 -0500
+
EOF
test_expect_success \
@@ -178,7 +353,7 @@ test_expect_success \
'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
############################################################
-# 14. check mytag
+# 25. check mytag
test_expect_success \
'check mytag' \
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index 94b1c24b0..883281dbd 100755
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
@@ -9,7 +9,7 @@ test_description='commit and log output encodings'
compare_with () {
git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
- git diff current "$2"
+ test_cmp current "$2"
}
test_expect_success setup '
diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh
index 73da45f18..fe4fb5116 100755
--- a/t/t3902-quoted.sh
+++ b/t/t3902-quoted.sh
@@ -78,28 +78,28 @@ EOF
test_expect_success 'check fully quoted output from ls-files' '
- git ls-files >current && diff -u expect.quoted current
+ git ls-files >current && test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current &&
- diff -u expect.quoted current
+ test_cmp expect.quoted current
'
@@ -111,28 +111,28 @@ test_expect_success 'setting core.quotepath' '
test_expect_success 'check fully quoted output from ls-files' '
- git ls-files >current && diff -u expect.raw current
+ git ls-files >current && test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-files' '
git diff --name-only >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-index' '
git diff --name-only HEAD >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
test_expect_success 'check fully quoted output from diff-tree' '
git diff --name-only HEAD^ HEAD >current &&
- diff -u expect.raw current
+ test_cmp expect.raw current
'
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 9a9a250d2..8d4804b65 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -34,14 +34,14 @@ EOF
test_expect_success 'parents of stash' '
test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
git diff stash^2..stash > output &&
- diff -u output expect
+ test_cmp output expect
'
test_expect_success 'apply needs clean working directory' '
echo 4 > other-file &&
git add other-file &&
- echo 5 > other-file
- ! git stash apply
+ echo 5 > other-file &&
+ test_must_fail git stash apply
'
test_expect_success 'apply stashed changes' '
@@ -70,7 +70,111 @@ test_expect_success 'unstashing in a subdirectory' '
git reset --hard HEAD &&
mkdir subdir &&
cd subdir &&
- git stash apply
+ git stash apply &&
+ cd ..
+'
+
+test_expect_success 'drop top stash' '
+ git reset --hard &&
+ git stash list > stashlist1 &&
+ echo 7 > file &&
+ git stash &&
+ git stash drop &&
+ git stash list > stashlist2 &&
+ diff stashlist1 stashlist2 &&
+ git stash apply &&
+ test 3 = $(cat file) &&
+ test 1 = $(git show :file) &&
+ test 1 = $(git show HEAD:file)
+'
+
+test_expect_success 'drop middle stash' '
+ git reset --hard &&
+ echo 8 > file &&
+ git stash &&
+ echo 9 > file &&
+ git stash &&
+ git stash drop stash@{1} &&
+ test 2 = $(git stash list | wc -l) &&
+ git stash apply &&
+ test 9 = $(cat file) &&
+ test 1 = $(git show :file) &&
+ test 1 = $(git show HEAD:file) &&
+ git reset --hard &&
+ git stash drop &&
+ git stash apply &&
+ test 3 = $(cat file) &&
+ test 1 = $(git show :file) &&
+ test 1 = $(git show HEAD:file)
+'
+
+test_expect_success 'stash pop' '
+ git reset --hard &&
+ git stash pop &&
+ test 3 = $(cat file) &&
+ test 1 = $(git show :file) &&
+ test 1 = $(git show HEAD:file) &&
+ test 0 = $(git stash list | wc -l)
+'
+
+cat > expect << EOF
+diff --git a/file2 b/file2
+new file mode 100644
+index 0000000..1fe912c
+--- /dev/null
++++ b/file2
+@@ -0,0 +1 @@
++bar2
+EOF
+
+cat > expect1 << EOF
+diff --git a/file b/file
+index 257cc56..5716ca5 100644
+--- a/file
++++ b/file
+@@ -1 +1 @@
+-foo
++bar
+EOF
+
+cat > expect2 << EOF
+diff --git a/file b/file
+index 7601807..5716ca5 100644
+--- a/file
++++ b/file
+@@ -1 +1 @@
+-baz
++bar
+diff --git a/file2 b/file2
+new file mode 100644
+index 0000000..1fe912c
+--- /dev/null
++++ b/file2
+@@ -0,0 +1 @@
++bar2
+EOF
+
+test_expect_success 'stash branch' '
+ echo foo > file &&
+ git commit file -m first
+ echo bar > file &&
+ echo bar2 > file2 &&
+ git add file2 &&
+ git stash &&
+ echo baz > file &&
+ git commit file -m second &&
+ git stash branch stashbranch &&
+ test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
+ test $(git rev-parse HEAD) = $(git rev-parse master^) &&
+ git diff --cached > output &&
+ test_cmp output expect &&
+ git diff > output &&
+ test_cmp output expect1 &&
+ git add file &&
+ git commit -m alternate\ second &&
+ git diff master..stashbranch > output &&
+ test_cmp output expect2 &&
+ test 0 = $(git stash list | wc -l)
'
test_done
diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh
index ab5406dd9..4e92fce1d 100755
--- a/t/t4006-diff-mode.sh
+++ b/t/t4006-diff-mode.sh
@@ -38,6 +38,6 @@ echo ":100644 100755 X X M rezrov" >expected
test_expect_success \
'verify' \
- 'git diff expected check'
+ 'test_cmp expected check'
test_done
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 9eec75422..9337b8106 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -112,7 +112,7 @@ do
} >"$actual" &&
if test -f "$expect"
then
- git diff "$expect" "$actual" &&
+ test_cmp "$expect" "$actual" &&
rm -f "$actual"
else
# this is to help developing new tests.
@@ -245,6 +245,7 @@ format-patch --inline --stdout initial..master
format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
config format.subjectprefix DIFFERENT_PREFIX
format-patch --inline --stdout initial..master^^
+format-patch --stdout --cover-letter -n initial..master^
diff --abbrev initial..side
diff -r initial..side
@@ -256,6 +257,7 @@ diff --patch-with-raw initial..side
diff --patch-with-stat -r initial..side
diff --patch-with-raw -r initial..side
diff --name-status dir2 dir
+diff --no-index --name-status dir2 dir
EOF
test_done
diff --git a/t/t4013/diff.diff_--name-status_dir2_dir b/t/t4013/diff.diff_--name-status_dir2_dir
index ef7fdb733..d0d96aaa9 100644
--- a/t/t4013/diff.diff_--name-status_dir2_dir
+++ b/t/t4013/diff.diff_--name-status_dir2_dir
@@ -1,3 +1,2 @@
$ git diff --name-status dir2 dir
-A dir/sub
$
diff --git a/t/t4013/diff.diff_--no-index_--name-status_dir2_dir b/t/t4013/diff.diff_--no-index_--name-status_dir2_dir
new file mode 100644
index 000000000..6a4758477
--- /dev/null
+++ b/t/t4013/diff.diff_--no-index_--name-status_dir2_dir
@@ -0,0 +1,3 @@
+$ git diff --no-index --name-status dir2 dir
+A dir/sub
+$
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master
index cf6891f74..43346b9ba 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit
@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
index fe0258720..d7490a9fd 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..side b/t/t4013/diff.format-patch_--attach_--stdout_initial..side
index 9ff828ee9..38f790290 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..side
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..side
@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master
index a8093be7c..fca5cce37 100644
--- a/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master
+++ b/t/t4013/diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit
@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master b/t/t4013/diff.format-patch_--inline_--stdout_initial..master
index aa110c0e7..6d6fac390 100644
--- a/t/t4013/diff.format-patch_--inline_--stdout_initial..master
+++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit
@@ -122,6 +126,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^
index 95e9ea4c5..18a1110de 100644
--- a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^
+++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
@@ -75,6 +77,8 @@ Content-Transfer-Encoding: 8bit
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
create mode 100644 file1
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^
index b8e81e155..4f258b885 100644
--- a/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^
+++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..master^^
@@ -19,6 +19,8 @@ This is the second commit.
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
delete mode 100644 file2
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--inline_--stdout_initial..side b/t/t4013/diff.format-patch_--inline_--stdout_initial..side
index 86ae923d7..e86dce69a 100644
--- a/t/t4013/diff.format-patch_--inline_--stdout_initial..side
+++ b/t/t4013/diff.format-patch_--inline_--stdout_initial..side
@@ -17,6 +17,8 @@ Content-Transfer-Encoding: 8bit
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 file3
+
+
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch; name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
Content-Transfer-Encoding: 8bit
diff --git a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
new file mode 100644
index 000000000..8dab4bf93
--- /dev/null
+++ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
@@ -0,0 +1,100 @@
+$ git format-patch --stdout --cover-letter -n initial..master^
+From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001
+From: C O Mitter <committer@example.com>
+Date: Mon, 26 Jun 2006 00:05:00 +0000
+Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
+
+*** BLURB HERE ***
+
+A U Thor (2):
+ Second
+ Third
+
+ dir/sub | 4 ++++
+ file0 | 3 +++
+ file1 | 3 +++
+ file2 | 3 ---
+ 4 files changed, 10 insertions(+), 3 deletions(-)
+ create mode 100644 file1
+ delete mode 100644 file2
+
+From 1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44 Mon Sep 17 00:00:00 2001
+From: A U Thor <author@example.com>
+Date: Mon, 26 Jun 2006 00:01:00 +0000
+Subject: [DIFFERENT_PREFIX 1/2] Second
+
+This is the second commit.
+---
+ dir/sub | 2 ++
+ file0 | 3 +++
+ file2 | 3 ---
+ 3 files changed, 5 insertions(+), 3 deletions(-)
+ delete mode 100644 file2
+
+diff --git a/dir/sub b/dir/sub
+index 35d242b..8422d40 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -1,2 +1,4 @@
+ A
+ B
++C
++D
+diff --git a/file0 b/file0
+index 01e79c3..b414108 100644
+--- a/file0
++++ b/file0
+@@ -1,3 +1,6 @@
+ 1
+ 2
+ 3
++4
++5
++6
+diff --git a/file2 b/file2
+deleted file mode 100644
+index 01e79c3..0000000
+--- a/file2
++++ /dev/null
+@@ -1,3 +0,0 @@
+-1
+-2
+-3
+--
+g-i-t--v-e-r-s-i-o-n
+
+
+From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001
+From: A U Thor <author@example.com>
+Date: Mon, 26 Jun 2006 00:02:00 +0000
+Subject: [DIFFERENT_PREFIX 2/2] Third
+
+---
+ dir/sub | 2 ++
+ file1 | 3 +++
+ 2 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 file1
+
+diff --git a/dir/sub b/dir/sub
+index 8422d40..cead32e 100644
+--- a/dir/sub
++++ b/dir/sub
+@@ -2,3 +2,5 @@ A
+ B
+ C
+ D
++E
++F
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
+--
+g-i-t--v-e-r-s-i-o-n
+
+$
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 0a6fe5337..7fe853c20 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -88,4 +88,146 @@ test_expect_success 'replay did not screw up the log message' '
'
+test_expect_success 'extra headers' '
+
+ git config format.headers "To: R. E. Cipient <rcipient@example.com>
+" &&
+ git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>
+" &&
+ git format-patch --stdout master..side > patch2 &&
+ sed -e "/^$/q" patch2 > hdrs2 &&
+ grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs2 &&
+ grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs2
+
+'
+
+test_expect_success 'extra headers without newlines' '
+
+ git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" &&
+ git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>" &&
+ git format-patch --stdout master..side >patch3 &&
+ sed -e "/^$/q" patch3 > hdrs3 &&
+ grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs3 &&
+ grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs3
+
+'
+
+test_expect_success 'extra headers with multiple To:s' '
+
+ git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" &&
+ git config --add format.headers "To: S. E. Cipient <scipient@example.com>" &&
+ git format-patch --stdout master..side > patch4 &&
+ sed -e "/^$/q" patch4 > hdrs4 &&
+ grep "^To: R. E. Cipient <rcipient@example.com>,$" hdrs4 &&
+ grep "^ *S. E. Cipient <scipient@example.com>$" hdrs4
+'
+
+test_expect_success 'additional command line cc' '
+
+ git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" &&
+ git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch5 &&
+ grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch5 &&
+ grep "^ *S. E. Cipient <scipient@example.com>$" patch5
+'
+
+test_expect_success 'multiple files' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ git format-patch -o patches/ master &&
+ ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch
+'
+
+test_expect_success 'thread' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ git format-patch --thread -o patches/ master &&
+ FIRST_MID=$(grep "Message-Id:" patches/0001-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") &&
+ for i in patches/0002-* patches/0003-*
+ do
+ grep "References: $FIRST_MID" $i &&
+ grep "In-Reply-To: $FIRST_MID" $i || break
+ done
+'
+
+test_expect_success 'thread in-reply-to' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ git format-patch --in-reply-to="<test.message>" --thread -o patches/ master &&
+ FIRST_MID="<test.message>" &&
+ for i in patches/*
+ do
+ grep "References: $FIRST_MID" $i &&
+ grep "In-Reply-To: $FIRST_MID" $i || break
+ done
+'
+
+test_expect_success 'thread cover-letter' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ git format-patch --cover-letter --thread -o patches/ master &&
+ FIRST_MID=$(grep "Message-Id:" patches/0000-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") &&
+ for i in patches/0001-* patches/0002-* patches/0003-*
+ do
+ grep "References: $FIRST_MID" $i &&
+ grep "In-Reply-To: $FIRST_MID" $i || break
+ done
+'
+
+test_expect_success 'thread cover-letter in-reply-to' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ git format-patch --cover-letter --in-reply-to="<test.message>" --thread -o patches/ master &&
+ FIRST_MID="<test.message>" &&
+ for i in patches/*
+ do
+ grep "References: $FIRST_MID" $i &&
+ grep "In-Reply-To: $FIRST_MID" $i || break
+ done
+'
+
+test_expect_success 'excessive subject' '
+
+ rm -rf patches/ &&
+ git checkout side &&
+ for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&
+ git update-index file &&
+ git commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." &&
+ git format-patch -o patches/ master..side &&
+ ls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch
+'
+
+test_expect_success 'cover-letter inherits diff options' '
+
+ git mv file foo &&
+ git commit -m foo &&
+ git format-patch --cover-letter -1 &&
+ ! grep "file => foo .* 0 *$" 0000-cover-letter.patch &&
+ git format-patch --cover-letter -1 -M &&
+ grep "file => foo .* 0 *$" 0000-cover-letter.patch
+
+'
+
+cat > expect << EOF
+ This is an excessively long subject line for a message due to the
+ habit some projects have of not having a short, one-line subject at
+ the start of the commit message, but rather sticking a whole
+ paragraph right at the start as the only thing in the commit
+ message. It had better not become the filename for the patch.
+ foo
+
+EOF
+
+test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
+
+ git format-patch --cover-letter -2 &&
+ sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output &&
+ test_cmp expect output
+
+'
+
test_done
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index d30169fbd..a27fccc8d 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -43,13 +43,13 @@ index adf3937..6edc172 100644
EOF
git diff > out
-test_expect_success "Ray's example without options" 'git diff expect out'
+test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
-test_expect_success "Ray's example with -w" 'git diff expect out'
+test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
-test_expect_success "Ray's example with -b" 'git diff expect out'
+test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
@@ -62,16 +62,16 @@ EOF
git update-index x
-cat << EOF > x
+tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
-whitespace at end
+whitespace at end__
unchanged line
CR at end
EOF
-tr 'Q' '\015' << EOF > expect
+tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
@@ -84,20 +84,20 @@ index d99af23..8b32fb5 100644
+ whitespace at beginning
+whitespace change
+white space in the middle
-+whitespace at end
++whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
-test_expect_success 'another test, without options' 'git diff expect out'
+test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
-test_expect_success 'another test, with -w' 'git diff expect out'
+test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
@@ -115,7 +115,7 @@ index d99af23..8b32fb5 100644
CR at endQ
EOF
git diff -b > out
-test_expect_success 'another test, with -b' 'git diff expect out'
+test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
@@ -144,7 +144,7 @@ test_expect_success 'check with no whitespace errors' '
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
@@ -152,7 +152,7 @@ test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
@@ -181,7 +181,7 @@ test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
- ! git diff --cached --check
+ test_must_fail git diff --cached --check
'
@@ -190,7 +190,7 @@ test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff --cached --check
+ test_must_fail git diff --cached --check
'
@@ -206,7 +206,7 @@ test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
- ! git diff-index --check HEAD
+ test_must_fail git diff-index --check HEAD
'
@@ -215,7 +215,7 @@ test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff-index --check HEAD
+ test_must_fail git diff-index --check HEAD
'
@@ -231,7 +231,7 @@ test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
- ! git diff-index --cached --check HEAD
+ test_must_fail git diff-index --cached --check HEAD
'
@@ -240,7 +240,7 @@ test_expect_success 'check staged with space before tab in indent (diff-index)'
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff-index --cached --check HEAD
+ test_must_fail git diff-index --cached --check HEAD
'
@@ -256,7 +256,7 @@ test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
- ! git diff-tree --check HEAD^ HEAD
+ test_must_fail git diff-tree --check HEAD^ HEAD
'
@@ -265,7 +265,7 @@ test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
- ! git diff-tree --check HEAD^ HEAD
+ test_must_fail git diff-tree --check HEAD^ HEAD
'
@@ -281,7 +281,7 @@ test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
@@ -299,7 +299,7 @@ test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
@@ -315,7 +315,7 @@ test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
@@ -323,7 +323,22 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
+
+test_expect_success 'line numbers in --check output are correct' '
+
+ echo "" > x &&
+ echo "foo(); " >> x &&
+ git diff --check | grep "x:2:"
+
+'
+
+test_expect_success 'checkdiff detects trailing blank lines' '
+ echo "foo();" >x &&
+ echo "" >>x &&
+ git diff --check | grep "ends with blank"
+'
+
test_done
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
index 5dbdc0c9f..f07035ab7 100755
--- a/t/t4016-diff-quote.sh
+++ b/t/t4016-diff-quote.sh
@@ -49,22 +49,22 @@ cat >expect <<\EOF
EOF
test_expect_success 'git diff --summary -M HEAD' '
git diff --summary -M HEAD >actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<\EOF
- pathname.1 => "Rpathname\twith HT.0" | 0
- pathname.3 => "Rpathname\nwith LF.0" | 0
- "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
- pathname.2 => Rpathname with SP.0 | 0
- "pathname\twith HT.2" => Rpathname with SP.1 | 0
- pathname.0 => Rpathname.0 | 0
- "pathname\twith HT.0" => Rpathname.1 | 0
+ pathname.1 => "Rpathname\twith HT.0" | 0
+ pathname.3 => "Rpathname\nwith LF.0" | 0
+ "pathname\twith HT.3" => "Rpathname\nwith LF.1" | 0
+ pathname.2 => Rpathname with SP.0 | 0
+ "pathname\twith HT.2" => Rpathname with SP.1 | 0
+ pathname.0 => Rpathname.0 | 0
+ "pathname\twith HT.0" => Rpathname.1 | 0
7 files changed, 0 insertions(+), 0 deletions(-)
EOF
test_expect_success 'git diff --stat -M HEAD' '
git diff --stat -M HEAD >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_done
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index dc0b7126c..60dd2014d 100755
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
@@ -105,4 +105,26 @@ test_expect_success '--check with --no-pager returns 2 for dirty difference' '
'
+
+test_expect_success 'check should test not just the last line' '
+ echo "" >>a &&
+ git --no-pager diff --check
+ test $? = 2
+
+'
+
+test_expect_success 'check detects leftover conflict markers' '
+ git reset --hard &&
+ git checkout HEAD^ &&
+ echo binary >>b &&
+ git commit -m "side" b &&
+ test_must_fail git merge master &&
+ git add b && (
+ git --no-pager diff --cached --check >test.out
+ test $? = 2
+ ) &&
+ test 3 = $(grep "conflict marker" test.out | wc -l) &&
+ git reset --hard
+'
+
test_done
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index f9db81d3a..833d6cbcf 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -33,13 +33,13 @@ EOF
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
test_expect_success 'default behaviour' '
- git diff Beer.java Beer-correct.java |
+ git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ public class Beer"
'
test_expect_success 'preset java pattern' '
echo "*.java diff=java" >.gitattributes &&
- git diff Beer.java Beer-correct.java |
+ git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ public static void main("
'
@@ -48,13 +48,13 @@ git config diff.java.funcname '!static
[^ ].*s.*'
test_expect_success 'custom pattern' '
- git diff Beer.java Beer-correct.java |
+ git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ int special;$"
'
test_expect_success 'last regexp must not be negated' '
git config diff.java.funcname "!static" &&
- ! git diff Beer.java Beer-correct.java
+ test_must_fail git diff --no-index Beer.java Beer-correct.java
'
test_done
diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh
index 67e080bdb..7eae1f450 100755
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
@@ -12,7 +12,9 @@ test_expect_success setup '
echo " Eight SP indent" >>F &&
echo " HT and SP indent" >>F &&
echo "With trailing SP " >>F &&
- echo "No problem" >>F
+ echo "Carriage ReturnQ" | tr Q "\015" >>F &&
+ echo "No problem" >>F &&
+ echo >>F
'
@@ -27,6 +29,7 @@ test_expect_success default '
grep Eight normal >/dev/null &&
grep HT error >/dev/null &&
grep With error >/dev/null &&
+ grep Return error >/dev/null &&
grep No normal >/dev/null
'
@@ -41,6 +44,7 @@ test_expect_success 'without -trail' '
grep Eight normal >/dev/null &&
grep HT error >/dev/null &&
grep With normal >/dev/null &&
+ grep Return normal >/dev/null &&
grep No normal >/dev/null
'
@@ -56,6 +60,7 @@ test_expect_success 'without -trail (attribute)' '
grep Eight normal >/dev/null &&
grep HT error >/dev/null &&
grep With normal >/dev/null &&
+ grep Return normal >/dev/null &&
grep No normal >/dev/null
'
@@ -71,6 +76,7 @@ test_expect_success 'without -space' '
grep Eight normal >/dev/null &&
grep HT normal >/dev/null &&
grep With error >/dev/null &&
+ grep Return error >/dev/null &&
grep No normal >/dev/null
'
@@ -86,6 +92,7 @@ test_expect_success 'without -space (attribute)' '
grep Eight normal >/dev/null &&
grep HT normal >/dev/null &&
grep With error >/dev/null &&
+ grep Return error >/dev/null &&
grep No normal >/dev/null
'
@@ -101,6 +108,7 @@ test_expect_success 'with indent-non-tab only' '
grep Eight error >/dev/null &&
grep HT normal >/dev/null &&
grep With normal >/dev/null &&
+ grep Return normal >/dev/null &&
grep No normal >/dev/null
'
@@ -116,8 +124,58 @@ test_expect_success 'with indent-non-tab only (attribute)' '
grep Eight error >/dev/null &&
grep HT normal >/dev/null &&
grep With normal >/dev/null &&
+ grep Return normal >/dev/null &&
grep No normal >/dev/null
'
+test_expect_success 'with cr-at-eol' '
+
+ rm -f .gitattributes
+ git config core.whitespace cr-at-eol
+ git diff --color >output
+ grep "$blue_grep" output >error
+ grep -v "$blue_grep" output >normal
+
+ grep Eight normal >/dev/null &&
+ grep HT error >/dev/null &&
+ grep With error >/dev/null &&
+ grep Return normal >/dev/null &&
+ grep No normal >/dev/null
+
+'
+
+test_expect_success 'with cr-at-eol (attribute)' '
+
+ git config --unset core.whitespace
+ echo "F whitespace=trailing,cr-at-eol" >.gitattributes
+ git diff --color >output
+ grep "$blue_grep" output >error
+ grep -v "$blue_grep" output >normal
+
+ grep Eight normal >/dev/null &&
+ grep HT error >/dev/null &&
+ grep With error >/dev/null &&
+ grep Return normal >/dev/null &&
+ grep No normal >/dev/null
+
+'
+
+test_expect_success 'trailing empty lines (1)' '
+
+ rm -f .gitattributes &&
+ test_must_fail git diff --check >output &&
+ grep "ends with blank lines." output &&
+ grep "trailing whitespace" output
+
+'
+
+test_expect_success 'trailing empty lines (2)' '
+
+ echo "F -whitespace" >.gitattributes &&
+ git diff --check >output &&
+ ! test -s output
+
+'
+
test_done
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 888293361..637b4e19d 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -99,11 +99,12 @@ test_expect_success 'no diff with -diff' '
git diff | grep Binary
'
-echo NULZbetweenZwords | tr Z '\000' > file
+echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
test_expect_success 'force diff with "diff"' '
echo >.gitattributes "file diff" &&
- git diff | grep -a second
+ git diff >actual &&
+ test_cmp ../t4020/diff.NUL actual
'
test_done
diff --git a/t/t4020/diff.NUL b/t/t4020/diff.NUL
new file mode 100644
index 000000000..db2f89090
--- /dev/null
+++ b/t/t4020/diff.NUL
Binary files differ
diff --git a/t/t4021-format-patch-signer-mime.sh b/t/t4021-format-patch-signer-mime.sh
index 67a70fada..ba43f1854 100755
--- a/t/t4021-format-patch-signer-mime.sh
+++ b/t/t4021-format-patch-signer-mime.sh
@@ -32,11 +32,19 @@ test_expect_success 'format with signoff without funny signer name' '
test_expect_success 'format with non ASCII signer name' '
- GIT_COMMITTER_NAME="$B$O$^$N(B $B$U$K$*$&(B" \
+ GIT_COMMITTER_NAME="ã¯ã¾ã® ãµã«ãŠã†" \
git format-patch -s --stdout -1 >output &&
grep Content-Type output
'
+test_expect_success 'attach and signoff do not duplicate mime headers' '
+
+ GIT_COMMITTER_NAME="ã¯ã¾ã® ãµã«ãŠã†" \
+ git format-patch -s --stdout -1 --attach >output &&
+ test `grep -ci ^MIME-Version: output` = 1
+
+'
+
test_done
diff --git a/t/t4022-diff-rewrite.sh b/t/t4022-diff-rewrite.sh
index 6de4acbd4..bf996fc41 100755
--- a/t/t4022-diff-rewrite.sh
+++ b/t/t4022-diff-rewrite.sh
@@ -8,7 +8,10 @@ test_expect_success setup '
cat ../../COPYING >test &&
git add test &&
- tr 'a-zA-Z' 'n-za-mN-ZA-M' <../../COPYING >test
+ tr \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
+ "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
+ <../../COPYING >test
'
diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh
index 255604eff..4dbfc6e8b 100755
--- a/t/t4023-diff-rename-typechange.sh
+++ b/t/t4023-diff-rename-typechange.sh
@@ -57,7 +57,7 @@ test_expect_success 'cross renames to be detected for regular files' '
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -68,7 +68,7 @@ test_expect_success 'cross renames to be detected for typechange' '
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -79,7 +79,7 @@ test_expect_success 'moves and renames' '
echo "R100 foo bar"
echo "T100 foo"
} | sort >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t4024-diff-optimize-common.sh b/t/t4024-diff-optimize-common.sh
index 3c66102f7..c4d733f5d 100755
--- a/t/t4024-diff-optimize-common.sh
+++ b/t/t4024-diff-optimize-common.sh
@@ -150,7 +150,7 @@ test_expect_success 'diff -U0' '
do
git diff -U0 file-?$n
done | zc >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
diff --git a/t/t4025-hunk-header.sh b/t/t4025-hunk-header.sh
index 9ba06b74c..7a3dbc1ea 100755
--- a/t/t4025-hunk-header.sh
+++ b/t/t4025-hunk-header.sh
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
echo " A $N$N$N$N$N$N$N$N$N2"
echo " L $N$N$N$N$N$N$N$N$N1"
) >expected &&
- diff -u actual expected
+ test_cmp actual expected
'
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
new file mode 100755
index 000000000..b61e5169f
--- /dev/null
+++ b/t/t4026-color.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Timo Hirvonen
+#
+
+test_description='Test diff/status color escape codes'
+. ./test-lib.sh
+
+color()
+{
+ git config diff.color.new "$1" &&
+ test "`git config --get-color diff.color.new`" = "$2"
+}
+
+invalid_color()
+{
+ git config diff.color.new "$1" &&
+ test -z "`git config --get-color diff.color.new 2>/dev/null`"
+}
+
+test_expect_success 'reset' '
+ color "reset" "[m"
+'
+
+test_expect_success 'attribute before color name' '
+ color "bold red" "[1;31m"
+'
+
+test_expect_success 'color name before attribute' '
+ color "red bold" "[1;31m"
+'
+
+test_expect_success 'attr fg bg' '
+ color "ul blue red" "[4;34;41m"
+'
+
+test_expect_success 'fg attr bg' '
+ color "blue ul red" "[4;34;41m"
+'
+
+test_expect_success 'fg bg attr' '
+ color "blue red ul" "[4;34;41m"
+'
+
+test_expect_success '256 colors' '
+ color "254 bold 255" "[1;38;5;254;48;5;255m"
+'
+
+test_expect_success 'color too small' '
+ invalid_color "-2"
+'
+
+test_expect_success 'color too big' '
+ invalid_color "256"
+'
+
+test_expect_success 'extra character after color number' '
+ invalid_color "3X"
+'
+
+test_expect_success 'extra character after color name' '
+ invalid_color "redX"
+'
+
+test_expect_success 'extra character after attribute' '
+ invalid_color "dimX"
+'
+
+test_done
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
new file mode 100755
index 000000000..ba6679c6e
--- /dev/null
+++ b/t/t4027-diff-submodule.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='difference in submodules'
+
+. ./test-lib.sh
+. ../diff-lib.sh
+
+_z40=0000000000000000000000000000000000000000
+test_expect_success setup '
+ test_tick &&
+ test_create_repo sub &&
+ (
+ cd sub &&
+ echo hello >world &&
+ git add world &&
+ git commit -m submodule
+ ) &&
+
+ test_tick &&
+ echo frotz >nitfol &&
+ git add nitfol sub &&
+ git commit -m superproject &&
+
+ (
+ cd sub &&
+ echo goodbye >world &&
+ git add world &&
+ git commit -m "submodule #2"
+ ) &&
+
+ set x $(
+ cd sub &&
+ git rev-list HEAD
+ ) &&
+ echo ":160000 160000 $3 $_z40 M sub" >expect
+'
+
+test_expect_success 'git diff --raw HEAD' '
+ git diff --raw --abbrev=40 HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'git diff-index --raw HEAD' '
+ git diff-index --raw HEAD >actual.index &&
+ test_cmp expect actual.index
+'
+
+test_expect_success 'git diff-files --raw' '
+ git diff-files --raw >actual.files &&
+ test_cmp expect actual.files
+'
+
+test_expect_success 'git diff (empty submodule dir)' '
+ : >empty &&
+ rm -rf sub/* sub/.git &&
+ git diff > actual.empty &&
+ test_cmp empty actual.empty
+'
+
+test_done
diff --git a/t/t4028-format-patch-mime-headers.sh b/t/t4028-format-patch-mime-headers.sh
new file mode 100755
index 000000000..204ba673c
--- /dev/null
+++ b/t/t4028-format-patch-mime-headers.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='format-patch mime headers and extra headers do not conflict'
+. ./test-lib.sh
+
+test_expect_success 'create commit with utf-8 body' '
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+ echo more >>file &&
+ git commit -a -m "two
+
+ utf-8 body: ñ"
+'
+
+test_expect_success 'patch has mime headers' '
+ rm -f 0001-two.patch &&
+ git format-patch HEAD^ &&
+ grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch
+'
+
+test_expect_success 'patch has mime and extra headers' '
+ rm -f 0001-two.patch &&
+ git config format.headers "x-foo: bar" &&
+ git format-patch HEAD^ &&
+ grep -i "x-foo: bar" 0001-two.patch &&
+ grep -i "content-type: text/plain; charset=utf-8" 0001-two.patch
+'
+
+test_done
diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
index 435f65b37..e0c67740a 100755
--- a/t/t4100-apply-stat.sh
+++ b/t/t4100-apply-stat.sh
@@ -3,44 +3,38 @@
# Copyright (c) 2005 Junio C Hamano
#
-test_description='git apply --stat --summary test.
+test_description='git apply --stat --summary test, with --recount
'
. ./test-lib.sh
-test_expect_success \
- 'rename' \
- 'git apply --stat --summary <../t4100/t-apply-1.patch >current &&
- git diff ../t4100/t-apply-1.expect current'
-
-test_expect_success \
- 'copy' \
- 'git apply --stat --summary <../t4100/t-apply-2.patch >current &&
- git diff ../t4100/t-apply-2.expect current'
-
-test_expect_success \
- 'rewrite' \
- 'git apply --stat --summary <../t4100/t-apply-3.patch >current &&
- git diff ../t4100/t-apply-3.expect current'
-
-test_expect_success \
- 'mode' \
- 'git apply --stat --summary <../t4100/t-apply-4.patch >current &&
- git diff ../t4100/t-apply-4.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-5.patch >current &&
- git diff ../t4100/t-apply-5.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-6.patch >current &&
- git diff ../t4100/t-apply-6.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-7.patch >current &&
- git diff ../t4100/t-apply-7.expect current'
+UNC='s/^\(@@ -[1-9][0-9]*\),[0-9]* \(+[1-9][0-9]*\),[0-9]* @@/\1,999 \2,999 @@/'
+
+num=0
+while read title
+do
+ num=$(( $num + 1 ))
+ test_expect_success "$title" '
+ git apply --stat --summary \
+ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current &&
+ test_cmp ../t4100/t-apply-$num.expect current
+ '
+
+ test_expect_success "$title with recount" '
+ sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" |
+ git apply --recount --stat --summary >current &&
+ test_cmp ../t4100/t-apply-$num.expect current
+ '
+done <<\EOF
+rename
+copy
+rewrite
+mode
+non git (1)
+non git (2)
+non git (3)
+incomplete (1)
+incomplete (2)
+EOF
test_done
diff --git a/t/t4100/t-apply-8.expect b/t/t4100/t-apply-8.expect
new file mode 100644
index 000000000..eef7f2e65
--- /dev/null
+++ b/t/t4100/t-apply-8.expect
@@ -0,0 +1,2 @@
+ t/t4100-apply-stat.sh | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t4100/t-apply-8.patch b/t/t4100/t-apply-8.patch
new file mode 100644
index 000000000..5ca13e659
--- /dev/null
+++ b/t/t4100/t-apply-8.patch
@@ -0,0 +1,11 @@
+diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
+index be837bb..0798c64 100755
+--- a/t/t4100-apply-stat.sh
++++ b/t/t4100-apply-stat.sh
+@@ -35,4 +35,4 @@ non git (2)
+ non git (3)
+ EOF
+
+-test_done
++test_done
+\ No newline at end of file
diff --git a/t/t4100/t-apply-9.expect b/t/t4100/t-apply-9.expect
new file mode 100644
index 000000000..eef7f2e65
--- /dev/null
+++ b/t/t4100/t-apply-9.expect
@@ -0,0 +1,2 @@
+ t/t4100-apply-stat.sh | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/t4100/t-apply-9.patch b/t/t4100/t-apply-9.patch
new file mode 100644
index 000000000..875d57d56
--- /dev/null
+++ b/t/t4100/t-apply-9.patch
@@ -0,0 +1,11 @@
+diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
+index 0798c64..be837bb 100755
+--- a/t/t4100-apply-stat.sh
++++ b/t/t4100-apply-stat.sh
+@@ -35,4 +35,4 @@ non git (2)
+ non git (3)
+ EOF
+
+-test_done
+\ No newline at end of file
++test_done
diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh
index 74f06ec73..7da0b4bb8 100755
--- a/t/t4103-apply-binary.sh
+++ b/t/t4103-apply-binary.sh
@@ -24,10 +24,10 @@ git update-index --add --remove file1 file2 file4
git-commit -m 'Initial Version' 2>/dev/null
git-checkout -b binary
-tr 'x' '\000' <file1 >file3
+perl -pe 'y/x/\000/' <file1 >file3
cat file3 >file4
git add file2
-tr '\000' 'v' <file3 >file1
+perl -pe 'y/\000/v/' <file3 >file1
rm -f file2
git update-index --add --remove file1 file2 file3 file4
git-commit -m 'Second Version'
@@ -46,21 +46,25 @@ test_expect_success 'stat binary diff (copy) -- should not fail.' \
'git-checkout master
git apply --stat --summary C.diff'
-test_expect_failure 'check binary diff -- should fail.' \
- 'git-checkout master
- git apply --check B.diff'
+test_expect_success 'check binary diff -- should fail.' \
+ 'git-checkout master &&
+ test_must_fail git apply --check B.diff'
-test_expect_failure 'check binary diff (copy) -- should fail.' \
- 'git-checkout master
- git apply --check C.diff'
+test_expect_success 'check binary diff (copy) -- should fail.' \
+ 'git-checkout master &&
+ test_must_fail git apply --check C.diff'
-test_expect_failure 'check incomplete binary diff with replacement -- should fail.' \
- 'git-checkout master
- git apply --check --allow-binary-replacement B.diff'
+test_expect_success \
+ 'check incomplete binary diff with replacement -- should fail.' '
+ git-checkout master &&
+ test_must_fail git apply --check --allow-binary-replacement B.diff
+'
-test_expect_failure 'check incomplete binary diff with replacement (copy) -- should fail.' \
- 'git-checkout master
- git apply --check --allow-binary-replacement C.diff'
+test_expect_success \
+ 'check incomplete binary diff with replacement (copy) -- should fail.' '
+ git-checkout master &&
+ test_must_fail git apply --check --allow-binary-replacement C.diff
+'
test_expect_success 'check binary diff with replacement.' \
'git-checkout master
@@ -73,42 +77,42 @@ test_expect_success 'check binary diff with replacement (copy).' \
# Now we start applying them.
do_reset () {
- rm -f file?
- git-reset --hard
+ rm -f file? &&
+ git-reset --hard &&
git-checkout -f master
}
-test_expect_failure 'apply binary diff -- should fail.' \
- 'do_reset
- git apply B.diff'
+test_expect_success 'apply binary diff -- should fail.' \
+ 'do_reset &&
+ test_must_fail git apply B.diff'
-test_expect_failure 'apply binary diff -- should fail.' \
- 'do_reset
- git apply --index B.diff'
+test_expect_success 'apply binary diff -- should fail.' \
+ 'do_reset &&
+ test_must_fail git apply --index B.diff'
-test_expect_failure 'apply binary diff (copy) -- should fail.' \
- 'do_reset
- git apply C.diff'
+test_expect_success 'apply binary diff (copy) -- should fail.' \
+ 'do_reset &&
+ test_must_fail git apply C.diff'
-test_expect_failure 'apply binary diff (copy) -- should fail.' \
- 'do_reset
- git apply --index C.diff'
+test_expect_success 'apply binary diff (copy) -- should fail.' \
+ 'do_reset &&
+ test_must_fail git apply --index C.diff'
test_expect_success 'apply binary diff without replacement.' \
- 'do_reset
+ 'do_reset &&
git apply BF.diff'
test_expect_success 'apply binary diff without replacement (copy).' \
- 'do_reset
+ 'do_reset &&
git apply CF.diff'
test_expect_success 'apply binary diff.' \
- 'do_reset
+ 'do_reset &&
git apply --allow-binary-replacement --index BF.diff &&
test -z "$(git diff --name-status binary)"'
test_expect_success 'apply binary diff (copy).' \
- 'do_reset
+ 'do_reset &&
git apply --allow-binary-replacement --index CF.diff &&
test -z "$(git diff --name-status binary)"'
diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh
index 64f34e329..e7e2913de 100755
--- a/t/t4104-apply-boundary.sh
+++ b/t/t4104-apply-boundary.sh
@@ -90,7 +90,7 @@ do
cat '"$kind-patch.$with"'
(exit 1)
} &&
- git diff '"$kind"'-expect victim
+ test_cmp '"$kind"'-expect victim
'
done
done
@@ -108,8 +108,21 @@ do
cat '"$kind-ng.without"'
(exit 1)
} &&
- git diff '"$kind"'-expect victim
+ test_cmp '"$kind"'-expect victim
'
done
+test_expect_success 'two lines' '
+
+ >file &&
+ git add file &&
+ echo aaa >file &&
+ git diff >patch &&
+ git add file &&
+ echo bbb >file &&
+ git add file &&
+ test_must_fail git apply --check patch
+
+'
+
test_done
diff --git a/t/t4105-apply-fuzz.sh b/t/t4105-apply-fuzz.sh
new file mode 100755
index 000000000..3266e3940
--- /dev/null
+++ b/t/t4105-apply-fuzz.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='apply with fuzz and offset'
+
+. ./test-lib.sh
+
+dotest () {
+ name="$1" && shift &&
+ test_expect_success "$name" "
+ git checkout-index -f -q -u file &&
+ git apply $* &&
+ test_cmp expect file
+ "
+}
+
+test_expect_success setup '
+
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12
+ do
+ echo $i
+ done >file &&
+ git update-index --add file &&
+ for i in 1 2 3 4 5 6 7 a b c d e 8 9 10 11 12
+ do
+ echo $i
+ done >file &&
+ cat file >expect &&
+ git diff >O0.diff &&
+
+ sed -e "s/@@ -5,6 +5,11 @@/@@ -2,6 +2,11 @@/" >O1.diff O0.diff &&
+ sed -e "s/@@ -5,6 +5,11 @@/@@ -7,6 +7,11 @@/" >O2.diff O0.diff &&
+ sed -e "s/@@ -5,6 +5,11 @@/@@ -19,6 +19,11 @@/" >O3.diff O0.diff &&
+
+ sed -e "s/^ 5/ S/" >F0.diff O0.diff &&
+ sed -e "s/^ 5/ S/" >F1.diff O1.diff &&
+ sed -e "s/^ 5/ S/" >F2.diff O2.diff &&
+ sed -e "s/^ 5/ S/" >F3.diff O3.diff
+
+'
+
+dotest 'unmodified patch' O0.diff
+
+dotest 'minus offset' O1.diff
+
+dotest 'plus offset' O2.diff
+
+dotest 'big offset' O3.diff
+
+dotest 'fuzz with no offset' -C2 F0.diff
+
+dotest 'fuzz with minus offset' -C2 F1.diff
+
+dotest 'fuzz with plus offset' -C2 F2.diff
+
+dotest 'fuzz with big offset' -C2 F3.diff
+
+test_done
diff --git a/t/t4109-apply-multifrag.sh b/t/t4109-apply-multifrag.sh
index bd40a218c..ac58083fe 100755
--- a/t/t4109-apply-multifrag.sh
+++ b/t/t4109-apply-multifrag.sh
@@ -4,173 +4,32 @@
# Copyright (c) 2005 Robert Fitzsimons
#
-test_description='git apply test patches with multiple fragments.
+test_description='git apply test patches with multiple fragments.'
-'
. ./test-lib.sh
-# setup
-
-cat > patch1.patch <<\EOF
-diff --git a/main.c b/main.c
-new file mode 100644
---- /dev/null
-+++ b/main.c
-@@ -0,0 +1,23 @@
-+#include <stdio.h>
-+
-+int func(int num);
-+void print_int(int num);
-+
-+int main() {
-+ int i;
-+
-+ for (i = 0; i < 10; i++) {
-+ print_int(func(i));
-+ }
-+
-+ return 0;
-+}
-+
-+int func(int num) {
-+ return num * num;
-+}
-+
-+void print_int(int num) {
-+ printf("%d", num);
-+}
-+
-EOF
-cat > patch2.patch <<\EOF
-diff --git a/main.c b/main.c
---- a/main.c
-+++ b/main.c
-@@ -1,7 +1,9 @@
-+#include <stdlib.h>
- #include <stdio.h>
-
- int func(int num);
- void print_int(int num);
-+void print_ln();
-
- int main() {
- int i;
-@@ -10,6 +12,8 @@
- print_int(func(i));
- }
-
-+ print_ln();
-+
- return 0;
- }
-
-@@ -21,3 +25,7 @@
- printf("%d", num);
- }
-
-+void print_ln() {
-+ printf("\n");
-+}
-+
-EOF
-cat > patch3.patch <<\EOF
-diff --git a/main.c b/main.c
---- a/main.c
-+++ b/main.c
-@@ -1,9 +1,7 @@
--#include <stdlib.h>
- #include <stdio.h>
-
- int func(int num);
- void print_int(int num);
--void print_ln();
-
- int main() {
- int i;
-@@ -12,8 +10,6 @@
- print_int(func(i));
- }
-
-- print_ln();
--
- return 0;
- }
-
-@@ -25,7 +21,3 @@
- printf("%d", num);
- }
-
--void print_ln() {
-- printf("\n");
--}
--
-EOF
-cat > patch4.patch <<\EOF
-diff --git a/main.c b/main.c
---- a/main.c
-+++ b/main.c
-@@ -1,13 +1,14 @@
- #include <stdio.h>
-
- int func(int num);
--void print_int(int num);
-+int func2(int num);
-
- int main() {
- int i;
-
- for (i = 0; i < 10; i++) {
-- print_int(func(i));
-+ printf("%d", func(i));
-+ printf("%d", func3(i));
- }
-
- return 0;
-@@ -17,7 +18,7 @@
- return num * num;
- }
-
--void print_int(int num) {
-- printf("%d", num);
-+int func2(int num) {
-+ return num * num * num;
- }
-
-EOF
-
-test_expect_success "S = git apply (1)" \
- 'git apply patch1.patch patch2.patch'
-mv main.c main.c.git
-
-test_expect_success "S = patch (1)" \
- 'cat patch1.patch patch2.patch | patch -p1'
-
-test_expect_success "S = cmp (1)" \
- 'cmp main.c.git main.c'
+cp "$TEST_DIRECTORY/t4109/patch1.patch" .
+cp "$TEST_DIRECTORY/t4109/patch2.patch" .
+cp "$TEST_DIRECTORY/t4109/patch3.patch" .
+cp "$TEST_DIRECTORY/t4109/patch4.patch" .
-rm -f main.c main.c.git
-
-test_expect_success "S = git apply (2)" \
- 'git apply patch1.patch patch2.patch patch3.patch'
-mv main.c main.c.git
-
-test_expect_success "S = patch (2)" \
- 'cat patch1.patch patch2.patch patch3.patch | patch -p1'
-
-test_expect_success "S = cmp (2)" \
- 'cmp main.c.git main.c'
+test_expect_success 'git apply (1)' '
+ git apply patch1.patch patch2.patch &&
+ test_cmp "$TEST_DIRECTORY/t4109/expect-1" main.c
+'
+rm -f main.c
-rm -f main.c main.c.git
+test_expect_success 'git apply (2)' '
+ git apply patch1.patch patch2.patch patch3.patch &&
+ test_cmp "$TEST_DIRECTORY/t4109/expect-2" main.c
+'
+rm -f main.c
-test_expect_success "S = git apply (3)" \
- 'git apply patch1.patch patch4.patch'
+test_expect_success 'git apply (3)' '
+ git apply patch1.patch patch4.patch &&
+ test_cmp "$TEST_DIRECTORY/t4109/expect-3" main.c
+'
mv main.c main.c.git
-test_expect_success "S = patch (3)" \
- 'cat patch1.patch patch4.patch | patch -p1'
-
-test_expect_success "S = cmp (3)" \
- 'cmp main.c.git main.c'
-
test_done
diff --git a/t/t4109/expect-1 b/t/t4109/expect-1
new file mode 100644
index 000000000..1db5ff105
--- /dev/null
+++ b/t/t4109/expect-1
@@ -0,0 +1,31 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int func(int num);
+void print_int(int num);
+void print_ln();
+
+int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ print_int(func(i));
+ }
+
+ print_ln();
+
+ return 0;
+}
+
+int func(int num) {
+ return num * num;
+}
+
+void print_int(int num) {
+ printf("%d", num);
+}
+
+void print_ln() {
+ printf("\n");
+}
+
diff --git a/t/t4109/expect-2 b/t/t4109/expect-2
new file mode 100644
index 000000000..bc5292411
--- /dev/null
+++ b/t/t4109/expect-2
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+int func(int num);
+void print_int(int num);
+
+int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ print_int(func(i));
+ }
+
+ return 0;
+}
+
+int func(int num) {
+ return num * num;
+}
+
+void print_int(int num) {
+ printf("%d", num);
+}
+
diff --git a/t/t4109/expect-3 b/t/t4109/expect-3
new file mode 100644
index 000000000..cd2a475fe
--- /dev/null
+++ b/t/t4109/expect-3
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+int func(int num);
+int func2(int num);
+
+int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+ printf("%d", func(i));
+ printf("%d", func3(i));
+ }
+
+ return 0;
+}
+
+int func(int num) {
+ return num * num;
+}
+
+int func2(int num) {
+ return num * num * num;
+}
+
diff --git a/t/t4109/patch1.patch b/t/t4109/patch1.patch
new file mode 100644
index 000000000..1d411fc3c
--- /dev/null
+++ b/t/t4109/patch1.patch
@@ -0,0 +1,28 @@
+diff --git a/main.c b/main.c
+new file mode 100644
+--- /dev/null
++++ b/main.c
+@@ -0,0 +1,23 @@
++#include <stdio.h>
++
++int func(int num);
++void print_int(int num);
++
++int main() {
++ int i;
++
++ for (i = 0; i < 10; i++) {
++ print_int(func(i));
++ }
++
++ return 0;
++}
++
++int func(int num) {
++ return num * num;
++}
++
++void print_int(int num) {
++ printf("%d", num);
++}
++
diff --git a/t/t4109/patch2.patch b/t/t4109/patch2.patch
new file mode 100644
index 000000000..8c6b06d53
--- /dev/null
+++ b/t/t4109/patch2.patch
@@ -0,0 +1,30 @@
+diff --git a/main.c b/main.c
+--- a/main.c
++++ b/main.c
+@@ -1,7 +1,9 @@
++#include <stdlib.h>
+ #include <stdio.h>
+
+ int func(int num);
+ void print_int(int num);
++void print_ln();
+
+ int main() {
+ int i;
+@@ -10,6 +12,8 @@
+ print_int(func(i));
+ }
+
++ print_ln();
++
+ return 0;
+ }
+
+@@ -21,3 +25,7 @@
+ printf("%d", num);
+ }
+
++void print_ln() {
++ printf("\n");
++}
++
diff --git a/t/t4109/patch3.patch b/t/t4109/patch3.patch
new file mode 100644
index 000000000..d696c55a7
--- /dev/null
+++ b/t/t4109/patch3.patch
@@ -0,0 +1,31 @@
+cat > patch3.patch <<\EOF
+diff --git a/main.c b/main.c
+--- a/main.c
++++ b/main.c
+@@ -1,9 +1,7 @@
+-#include <stdlib.h>
+ #include <stdio.h>
+
+ int func(int num);
+ void print_int(int num);
+-void print_ln();
+
+ int main() {
+ int i;
+@@ -12,8 +10,6 @@
+ print_int(func(i));
+ }
+
+- print_ln();
+-
+ return 0;
+ }
+
+@@ -25,7 +21,3 @@
+ printf("%d", num);
+ }
+
+-void print_ln() {
+- printf("\n");
+-}
+-
diff --git a/t/t4109/patch4.patch b/t/t4109/patch4.patch
new file mode 100644
index 000000000..4b085909b
--- /dev/null
+++ b/t/t4109/patch4.patch
@@ -0,0 +1,30 @@
+diff --git a/main.c b/main.c
+--- a/main.c
++++ b/main.c
+@@ -1,13 +1,14 @@
+ #include <stdio.h>
+
+ int func(int num);
+-void print_int(int num);
++int func2(int num);
+
+ int main() {
+ int i;
+
+ for (i = 0; i < 10; i++) {
+- print_int(func(i));
++ printf("%d", func(i));
++ printf("%d", func3(i));
+ }
+
+ return 0;
+@@ -17,7 +18,7 @@
+ return num * num;
+ }
+
+-void print_int(int num) {
+- printf("%d", num);
++int func2(int num) {
++ return num * num * num;
+ }
+
diff --git a/t/t4110-apply-scan.sh b/t/t4110-apply-scan.sh
index db60652a3..09f58112e 100755
--- a/t/t4110-apply-scan.sh
+++ b/t/t4110-apply-scan.sh
@@ -9,92 +9,14 @@ test_description='git apply test for patches which require scanning forwards and
'
. ./test-lib.sh
-# setup
-
-cat > patch1.patch <<\EOF
-diff --git a/new.txt b/new.txt
-new file mode 100644
---- /dev/null
-+++ b/new.txt
-@@ -0,0 +1,12 @@
-+a1
-+a11
-+a111
-+a1111
-+b1
-+b11
-+b111
-+b1111
-+c1
-+c11
-+c111
-+c1111
-EOF
-cat > patch2.patch <<\EOF
-diff --git a/new.txt b/new.txt
---- a/new.txt
-+++ b/new.txt
-@@ -1,7 +1,3 @@
--a1
--a11
--a111
--a1111
- b1
- b11
- b111
-EOF
-cat > patch3.patch <<\EOF
-diff --git a/new.txt b/new.txt
---- a/new.txt
-+++ b/new.txt
-@@ -6,6 +6,10 @@
- b11
- b111
- b1111
-+b2
-+b22
-+b222
-+b2222
- c1
- c11
- c111
-EOF
-cat > patch4.patch <<\EOF
-diff --git a/new.txt b/new.txt
---- a/new.txt
-+++ b/new.txt
-@@ -1,3 +1,7 @@
-+a1
-+a11
-+a111
-+a1111
- b1
- b11
- b111
-EOF
-cat > patch5.patch <<\EOF
-diff --git a/new.txt b/new.txt
---- a/new.txt
-+++ b/new.txt
-@@ -10,3 +10,7 @@
- c11
- c111
- c1111
-+c2
-+c22
-+c222
-+c2222
-EOF
-
-test_expect_success "S = git apply scan" \
- 'git apply patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch'
-mv new.txt apply.txt
-
-test_expect_success "S = patch scan" \
- 'cat patch1.patch patch2.patch patch3.patch patch4.patch patch5.patch | patch'
-mv new.txt patch.txt
-
-test_expect_success "S = cmp" \
- 'cmp apply.txt patch.txt'
+test_expect_success 'git apply scan' '
+ git apply \
+ "$TEST_DIRECTORY/t4110/patch1.patch" \
+ "$TEST_DIRECTORY/t4110/patch2.patch" \
+ "$TEST_DIRECTORY/t4110/patch3.patch" \
+ "$TEST_DIRECTORY/t4110/patch4.patch" \
+ "$TEST_DIRECTORY/t4110/patch5.patch" &&
+ test_cmp new.txt "$TEST_DIRECTORY/t4110/expect"
+'
test_done
diff --git a/t/t4110/expect b/t/t4110/expect
new file mode 100644
index 000000000..87cc493ec
--- /dev/null
+++ b/t/t4110/expect
@@ -0,0 +1,20 @@
+a1
+a11
+a111
+a1111
+b1
+b11
+b111
+b1111
+b2
+b22
+b222
+b2222
+c1
+c11
+c111
+c1111
+c2
+c22
+c222
+c2222
diff --git a/t/t4110/patch1.patch b/t/t4110/patch1.patch
new file mode 100644
index 000000000..56139080d
--- /dev/null
+++ b/t/t4110/patch1.patch
@@ -0,0 +1,17 @@
+diff --git a/new.txt b/new.txt
+new file mode 100644
+--- /dev/null
++++ b/new.txt
+@@ -0,0 +1,12 @@
++a1
++a11
++a111
++a1111
++b1
++b11
++b111
++b1111
++c1
++c11
++c111
++c1111
diff --git a/t/t4110/patch2.patch b/t/t4110/patch2.patch
new file mode 100644
index 000000000..04974247e
--- /dev/null
+++ b/t/t4110/patch2.patch
@@ -0,0 +1,11 @@
+diff --git a/new.txt b/new.txt
+--- a/new.txt
++++ b/new.txt
+@@ -1,7 +1,3 @@
+-a1
+-a11
+-a111
+-a1111
+ b1
+ b11
+ b111
diff --git a/t/t4110/patch3.patch b/t/t4110/patch3.patch
new file mode 100644
index 000000000..26bd4427f
--- /dev/null
+++ b/t/t4110/patch3.patch
@@ -0,0 +1,14 @@
+diff --git a/new.txt b/new.txt
+--- a/new.txt
++++ b/new.txt
+@@ -6,6 +6,10 @@
+ b11
+ b111
+ b1111
++b2
++b22
++b222
++b2222
+ c1
+ c11
+ c111
diff --git a/t/t4110/patch4.patch b/t/t4110/patch4.patch
new file mode 100644
index 000000000..9ffb9c2d7
--- /dev/null
+++ b/t/t4110/patch4.patch
@@ -0,0 +1,11 @@
+diff --git a/new.txt b/new.txt
+--- a/new.txt
++++ b/new.txt
+@@ -1,3 +1,7 @@
++a1
++a11
++a111
++a1111
+ b1
+ b11
+ b111
diff --git a/t/t4110/patch5.patch b/t/t4110/patch5.patch
new file mode 100644
index 000000000..c5ac6914f
--- /dev/null
+++ b/t/t4110/patch5.patch
@@ -0,0 +1,11 @@
+diff --git a/new.txt b/new.txt
+--- a/new.txt
++++ b/new.txt
+@@ -10,3 +10,7 @@
+ c11
+ c111
+ c1111
++c2
++c22
++c222
++c2222
diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh
index 70a185950..f9ad18375 100755
--- a/t/t4112-apply-renames.sh
+++ b/t/t4112-apply-renames.sh
@@ -36,6 +36,9 @@ typedef struct __jmp_buf jmp_buf[1];
#endif /* _SETJMP_H */
EOF
+cat >klibc/README <<\EOF
+This is a simple readme file.
+EOF
cat >patch <<\EOF
diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h b/include/arch/cris/klibc/archsetjmp.h
@@ -113,6 +116,23 @@ rename to include/arch/m32r/klibc/archsetjmp.h
-#endif /* _SETJMP_H */
+#endif /* _KLIBC_ARCHSETJMP_H */
+diff --git a/klibc/README b/klibc/README
+--- a/klibc/README
++++ b/klibc/README
+@@ -1,1 +1,4 @@
+ This is a simple readme file.
++And we add a few
++lines at the
++end of it.
+diff --git a/klibc/README b/klibc/arch/README
+copy from klibc/README
+copy to klibc/arch/README
+--- a/klibc/README
++++ b/klibc/arch/README
+@@ -1,1 +1,3 @@
+ This is a simple readme file.
++And we copy it to one level down, and
++add a few lines at the end of it.
EOF
find klibc -type f -print | xargs git update-index --add --
diff --git a/t/t4113-apply-ending.sh b/t/t4113-apply-ending.sh
index 1c6bec044..66fa51591 100755
--- a/t/t4113-apply-ending.sh
+++ b/t/t4113-apply-ending.sh
@@ -29,8 +29,8 @@ test_expect_success setup \
# test
-test_expect_failure 'apply at the end' \
- 'git apply --index test-patch'
+test_expect_success 'apply at the end' \
+ 'test_must_fail git apply --index test-patch'
cat >test-patch <<\EOF
diff a/file b/file
@@ -47,7 +47,7 @@ b
c'
git update-index file
-test_expect_failure 'apply at the beginning' \
- 'git apply --index test-patch'
+test_expect_success 'apply at the beginning' \
+ 'test_must_fail git apply --index test-patch'
test_done
diff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh
index a07ff42c2..9ace578f1 100755
--- a/t/t4115-apply-symlink.sh
+++ b/t/t4115-apply-symlink.sh
@@ -33,7 +33,7 @@ test_expect_success 'apply symlink patch' '
git checkout side &&
git apply patch &&
git diff-files -p >patched &&
- git diff patch patched
+ test_cmp patch patched
'
@@ -42,7 +42,7 @@ test_expect_success 'apply --index symlink patch' '
git checkout -f side &&
git apply --index patch &&
git diff-index --cached -p HEAD >patched &&
- git diff patch patched
+ test_cmp patch patched
'
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index b1d35ab04..2298ece80 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -12,14 +12,14 @@ test_description='git apply in reverse
test_expect_success setup '
for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
- tr "ijk" '\''\000\001\002'\'' <file1 >file2 &&
+ perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
git add file1 file2 &&
git commit -m initial &&
git tag initial &&
for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
- tr "mon" '\''\000\001\002'\'' <file1 >file2 &&
+ perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
git commit -a -m second &&
git tag second &&
@@ -42,18 +42,18 @@ test_expect_success 'apply in reverse' '
git reset --hard second &&
git apply --reverse --binary --index patch &&
git diff >diff &&
- git diff /dev/null diff
+ test_cmp /dev/null diff
'
test_expect_success 'setup separate repository lacking postimage' '
- git tar-tree initial initial | tar xf - &&
+ git tar-tree initial initial | $TAR xf - &&
(
cd initial && git init && git add .
) &&
- git tar-tree second second | tar xf - &&
+ git tar-tree second second | $TAR xf - &&
(
cd second && git init && git add .
)
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
index 659e17c92..e9ccd161e 100755
--- a/t/t4117-apply-reject.sh
+++ b/t/t4117-apply-reject.sh
@@ -54,7 +54,7 @@ test_expect_success 'apply without --reject should fail' '
exit 1
fi
- git diff file1 saved.file1
+ test_cmp file1 saved.file1
'
test_expect_success 'apply without --reject should fail' '
@@ -65,7 +65,7 @@ test_expect_success 'apply without --reject should fail' '
exit 1
fi
- git diff file1 saved.file1
+ test_cmp file1 saved.file1
'
test_expect_success 'apply with --reject should fail but update the file' '
@@ -79,7 +79,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
exit 1
fi
- git diff file1 expected &&
+ test_cmp file1 expected &&
cat file1.rej &&
@@ -105,7 +105,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
echo "file1 still exists?"
exit 1
}
- git diff file2 expected &&
+ test_cmp file2 expected &&
cat file2.rej &&
@@ -132,7 +132,7 @@ test_expect_success 'the same test with --verbose' '
echo "file1 still exists?"
exit 1
}
- git diff file2 expected &&
+ test_cmp file2 expected &&
cat file2.rej &&
@@ -151,7 +151,7 @@ test_expect_success 'apply cleanly with --verbose' '
git apply --verbose patch.1 &&
- git diff file1 clean
+ test_cmp file1 clean
'
test_done
diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh
index 1d531caf7..f92e259cc 100755
--- a/t/t4118-apply-empty-context.sh
+++ b/t/t4118-apply-empty-context.sh
@@ -38,7 +38,7 @@ test_expect_success 'apply --numstat' '
echo "0 1 file1" &&
echo "0 1 file2"
} >expect &&
- git diff expect actual
+ test_cmp expect actual
'
@@ -48,8 +48,8 @@ test_expect_success 'apply --apply' '
cat file2.orig >file2 &&
git update-index file1 file2 &&
git apply --index diff.output &&
- git diff file1.mods file1 &&
- git diff file2.mods file2
+ test_cmp file1.mods file1 &&
+ test_cmp file2.mods file2
'
test_done
diff --git a/t/t4119-apply-config.sh b/t/t4119-apply-config.sh
index b540f7295..3c73a783a 100755
--- a/t/t4119-apply-config.sh
+++ b/t/t4119-apply-config.sh
@@ -19,12 +19,12 @@ test_expect_success setup '
'
# Also handcraft GNU diff output; note this has trailing whitespace.
-cat >gpatch.file <<\EOF &&
+tr '_' ' ' >gpatch.file <<\EOF &&
--- file1 2007-02-21 01:04:24.000000000 -0800
+++ file1+ 2007-02-21 01:07:44.000000000 -0800
@@ -1 +1 @@
-A
-+B
++B_
EOF
sed -e 's|file1|sub/&|' gpatch.file >gpatch-sub.file &&
diff --git a/t/t4125-apply-ws-fuzz.sh b/t/t4125-apply-ws-fuzz.sh
new file mode 100755
index 000000000..3b471b641
--- /dev/null
+++ b/t/t4125-apply-ws-fuzz.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+test_description='applying patch that has broken whitespaces in context'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ >file &&
+ git add file &&
+
+ # file-0 is full of whitespace breakages
+ for l in a bb c d eeee f ggg h
+ do
+ echo "$l "
+ done >file-0 &&
+
+ # patch-0 creates a whitespace broken file
+ cat file-0 >file &&
+ git diff >patch-0 &&
+ git add file &&
+
+ # file-1 is still full of whitespace breakages,
+ # but has one line updated, without fixing any
+ # whitespaces.
+ # patch-1 records that change.
+ sed -e "s/d/D/" file-0 >file-1 &&
+ cat file-1 >file &&
+ git diff >patch-1 &&
+
+ # patch-all is the effect of both patch-0 and patch-1
+ >file &&
+ git add file &&
+ cat file-1 >file &&
+ git diff >patch-all &&
+
+ # patch-2 is the same as patch-1 but is based
+ # on a version that already has whitespace fixed,
+ # and does not introduce whitespace breakages.
+ sed -e "s/ $//" patch-1 >patch-2 &&
+
+ # If all whitespace breakages are fixed the contents
+ # should look like file-fixed
+ sed -e "s/ $//" file-1 >file-fixed
+
+'
+
+test_expect_success nofix '
+
+ >file &&
+ git add file &&
+
+ # Baseline. Applying without fixing any whitespace
+ # breakages.
+ git apply --whitespace=nowarn patch-0 &&
+ git apply --whitespace=nowarn patch-1 &&
+
+ # The result should obviously match.
+ test_cmp file-1 file
+'
+
+test_expect_success 'withfix (forward)' '
+
+ >file &&
+ git add file &&
+
+ # The first application will munge the context lines
+ # the second patch depends on. We should be able to
+ # adjust and still apply.
+ git apply --whitespace=fix patch-0 &&
+ git apply --whitespace=fix patch-1 &&
+
+ test_cmp file-fixed file
+'
+
+test_expect_success 'withfix (backward)' '
+
+ >file &&
+ git add file &&
+
+ # Now we have a whitespace breakages on our side.
+ git apply --whitespace=nowarn patch-0 &&
+
+ # And somebody sends in a patch based on image
+ # with whitespace already fixed.
+ git apply --whitespace=fix patch-2 &&
+
+ # The result should accept the whitespace fixed
+ # postimage. But the line with "h" is beyond context
+ # horizon and left unfixed.
+
+ sed -e /h/d file-fixed >fixed-head &&
+ sed -e /h/d file >file-head &&
+ test_cmp fixed-head file-head &&
+
+ sed -n -e /h/p file-fixed >fixed-tail &&
+ sed -n -e /h/p file >file-tail &&
+
+ ! test_cmp fixed-tail file-tail
+
+'
+
+test_done
diff --git a/t/t4126-apply-empty.sh b/t/t4126-apply-empty.sh
new file mode 100755
index 000000000..ceb6a79fe
--- /dev/null
+++ b/t/t4126-apply-empty.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='apply empty'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ >empty &&
+ git add empty &&
+ test_tick &&
+ git commit -m initial &&
+ for i in a b c d e
+ do
+ echo $i
+ done >empty &&
+ cat empty >expect &&
+ git diff |
+ sed -e "/^diff --git/d" \
+ -e "/^index /d" \
+ -e "s|a/empty|empty.orig|" \
+ -e "s|b/empty|empty|" >patch0 &&
+ sed -e "s|empty|missing|" patch0 >patch1 &&
+ >empty &&
+ git update-index --refresh
+'
+
+test_expect_success 'apply empty' '
+ git reset --hard &&
+ rm -f missing &&
+ git apply patch0 &&
+ test_cmp expect empty
+'
+
+test_expect_success 'apply --index empty' '
+ git reset --hard &&
+ rm -f missing &&
+ git apply --index patch0 &&
+ test_cmp expect empty &&
+ git diff --exit-code
+'
+
+test_expect_success 'apply create' '
+ git reset --hard &&
+ rm -f missing &&
+ git apply patch1 &&
+ test_cmp expect missing
+'
+
+test_expect_success 'apply --index create' '
+ git reset --hard &&
+ rm -f missing &&
+ git apply --index patch1 &&
+ test_cmp expect missing &&
+ git diff --exit-code
+'
+
+test_done
diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh
new file mode 100755
index 000000000..1f859dd90
--- /dev/null
+++ b/t/t4127-apply-same-fn.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+test_description='apply same filename'
+
+. ./test-lib.sh
+
+modify () {
+ sed -e "$1" < "$2" > "$2".x &&
+ mv "$2".x "$2"
+}
+
+test_expect_success setup '
+ for i in a b c d e f g h i j k l m
+ do
+ echo $i
+ done >same_fn &&
+ cp same_fn other_fn &&
+ git add same_fn other_fn &&
+ git commit -m initial
+'
+test_expect_success 'apply same filename with independent changes' '
+ modify "s/^d/z/" same_fn &&
+ git diff > patch0 &&
+ git add same_fn &&
+ modify "s/^i/y/" same_fn &&
+ git diff >> patch0 &&
+ cp same_fn same_fn2 &&
+ git reset --hard &&
+ git-apply patch0 &&
+ diff same_fn same_fn2
+'
+
+test_expect_success 'apply same filename with overlapping changes' '
+ git reset --hard
+ modify "s/^d/z/" same_fn &&
+ git diff > patch0 &&
+ git add same_fn &&
+ modify "s/^e/y/" same_fn &&
+ git diff >> patch0 &&
+ cp same_fn same_fn2 &&
+ git reset --hard &&
+ git-apply patch0 &&
+ diff same_fn same_fn2
+'
+
+test_expect_success 'apply same new filename after rename' '
+ git reset --hard
+ git mv same_fn new_fn
+ modify "s/^d/z/" new_fn &&
+ git add new_fn &&
+ git diff -M --cached > patch1 &&
+ modify "s/^e/y/" new_fn &&
+ git diff >> patch1 &&
+ cp new_fn new_fn2 &&
+ git reset --hard &&
+ git apply --index patch1 &&
+ diff new_fn new_fn2
+'
+
+test_expect_success 'apply same old filename after rename -- should fail.' '
+ git reset --hard
+ git mv same_fn new_fn
+ modify "s/^d/z/" new_fn &&
+ git add new_fn &&
+ git diff -M --cached > patch1 &&
+ git mv new_fn same_fn
+ modify "s/^e/y/" same_fn &&
+ git diff >> patch1 &&
+ git reset --hard &&
+ test_must_fail git apply patch1
+'
+
+test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
+ git reset --hard
+ git mv same_fn new_fn
+ modify "s/^d/z/" new_fn &&
+ git add new_fn &&
+ git diff -M --cached > patch1 &&
+ git commit -m "a rename" &&
+ git mv other_fn same_fn
+ modify "s/^e/y/" same_fn &&
+ git add same_fn &&
+ git diff -M --cached >> patch1 &&
+ modify "s/^g/x/" same_fn &&
+ git diff >> patch1 &&
+ git reset --hard HEAD^ &&
+ git apply patch1
+'
+
+test_done
diff --git a/t/t4128-apply-root.sh b/t/t4128-apply-root.sh
new file mode 100755
index 000000000..2dd0c75f9
--- /dev/null
+++ b/t/t4128-apply-root.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='apply same filename'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ mkdir -p some/sub/dir &&
+ echo Hello > some/sub/dir/file &&
+ git add some/sub/dir/file &&
+ git commit -m initial &&
+ git tag initial
+
+'
+
+cat > patch << EOF
+diff a/bla/blub/dir/file b/bla/blub/dir/file
+--- a/bla/blub/dir/file
++++ b/bla/blub/dir/file
+@@ -1,1 +1,1 @@
+-Hello
++Bello
+EOF
+
+test_expect_success 'apply --directory -p (1)' '
+
+ git apply --directory=some/sub -p3 --index patch &&
+ test Bello = $(git show :some/sub/dir/file) &&
+ test Bello = $(cat some/sub/dir/file)
+
+'
+
+test_expect_success 'apply --directory -p (2) ' '
+
+ git reset --hard initial &&
+ git apply --directory=some/sub/ -p3 --index patch &&
+ test Bello = $(git show :some/sub/dir/file) &&
+ test Bello = $(cat some/sub/dir/file)
+
+'
+
+test_done
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
new file mode 100755
index 000000000..6e6aaf593
--- /dev/null
+++ b/t/t4150-am.sh
@@ -0,0 +1,260 @@
+#!/bin/sh
+
+test_description='git am running'
+
+. ./test-lib.sh
+
+cat >msg <<EOF
+second
+
+Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy
+eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
+kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
+ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
+tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
+vero eos et accusam et justo duo dolores et ea rebum.
+
+ Duis autem vel eum iriure dolor in hendrerit in vulputate velit
+ esse molestie consequat, vel illum dolore eu feugiat nulla facilisis
+ at vero eros et accumsan et iusto odio dignissim qui blandit
+ praesent luptatum zzril delenit augue duis dolore te feugait nulla
+ facilisi.
+
+
+Lorem ipsum dolor sit amet,
+consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
+laoreet dolore magna aliquam erat volutpat.
+
+ git
+ ---
+ +++
+
+Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
+lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
+dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
+dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
+dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
+feugait nulla facilisi.
+EOF
+
+cat >failmail <<EOF
+From foo@example.com Fri May 23 10:43:49 2008
+From: foo@example.com
+To: bar@example.com
+Subject: Re: [RFC/PATCH] git-foo.sh
+Date: Fri, 23 May 2008 05:23:42 +0200
+
+Sometimes we have to find out that there's nothing left.
+
+EOF
+
+cat >pine <<EOF
+From MAILER-DAEMON Fri May 23 10:43:49 2008
+Date: 23 May 2008 05:23:42 +0200
+From: Mail System Internal Data <MAILER-DAEMON@example.com>
+Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
+Message-ID: <foo-0001@example.com>
+
+This text is part of the internal format of your mail folder, and is not
+a real message. It is created automatically by the mail system software.
+If deleted, important folder data will be lost, and it will be re-created
+with the data reset to initial values.
+
+EOF
+
+echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected
+
+test_expect_success setup '
+ echo hello >file &&
+ git add file &&
+ test_tick &&
+ git commit -m first &&
+ git tag first &&
+ echo world >>file &&
+ git add file &&
+ test_tick &&
+ git commit -s -F msg &&
+ git tag second &&
+ git format-patch --stdout first >patch1 &&
+ sed -n -e "3,\$p" msg >file &&
+ git add file &&
+ test_tick &&
+ git commit -m third &&
+ git format-patch --stdout first >patch2 &&
+ git checkout -b lorem &&
+ sed -n -e "11,\$p" msg >file &&
+ head -n 9 msg >>file &&
+ test_tick &&
+ git commit -a -m "moved stuff" &&
+ echo goodbye >another &&
+ git add another &&
+ test_tick &&
+ git commit -m "added another file" &&
+ git format-patch --stdout master >lorem-move.patch
+'
+
+# reset time
+unset test_tick
+test_tick
+
+test_expect_success 'am applies patch correctly' '
+ git checkout first &&
+ test_tick &&
+ git am <patch1 &&
+ ! test -d .git/rebase-apply &&
+ test -z "$(git diff second)" &&
+ test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
+ test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
+'
+
+GIT_AUTHOR_NAME="Another Thor"
+GIT_AUTHOR_EMAIL="a.thor@example.com"
+GIT_COMMITTER_NAME="Co M Miter"
+GIT_COMMITTER_EMAIL="c.miter@example.com"
+export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
+
+compare () {
+ test "$(git cat-file commit "$2" | grep "^$1 ")" = \
+ "$(git cat-file commit "$3" | grep "^$1 ")"
+}
+
+test_expect_success 'am changes committer and keeps author' '
+ test_tick &&
+ git checkout first &&
+ git am patch2 &&
+ ! test -d .git/rebase-apply &&
+ test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
+ test -z "$(git diff master..HEAD)" &&
+ test -z "$(git diff master^..HEAD^)" &&
+ compare author master HEAD &&
+ compare author master^ HEAD^ &&
+ test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \
+ "$(git log -1 --pretty=format:"%cn <%ce>" HEAD)"
+'
+
+test_expect_success 'am --signoff adds Signed-off-by: line' '
+ git checkout -b master2 first &&
+ git am --signoff <patch2 &&
+ echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected &&
+ git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
+ test_cmp actual expected &&
+ echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
+ git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
+ test_cmp actual expected
+'
+
+test_expect_success 'am stays in branch' '
+ test "refs/heads/master2" = "$(git symbolic-ref HEAD)"
+'
+
+test_expect_success 'am --signoff does not add Signed-off-by: line if already there' '
+ git format-patch --stdout HEAD^ >patch3 &&
+ sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4
+ git checkout HEAD^ &&
+ git am --signoff patch4 &&
+ test "$(git cat-file commit HEAD | grep -c "^Signed-off-by:")" -eq 1
+'
+
+test_expect_success 'am without --keep removes Re: and [PATCH] stuff' '
+ test "$(git rev-parse HEAD)" = "$(git rev-parse master2)"
+'
+
+test_expect_success 'am --keep really keeps the subject' '
+ git checkout HEAD^ &&
+ git am --keep patch4 &&
+ ! test -d .git/rebase-apply &&
+ git-cat-file commit HEAD |
+ grep -q -F "Re: Re: Re: [PATCH 1/5 v2] third"
+'
+
+test_expect_success 'am -3 falls back to 3-way merge' '
+ git checkout -b lorem2 master2 &&
+ sed -n -e "3,\$p" msg >file &&
+ head -n 9 msg >>file &&
+ git add file &&
+ test_tick &&
+ git commit -m "copied stuff" &&
+ git am -3 lorem-move.patch &&
+ ! test -d .git/rebase-apply &&
+ test -z "$(git diff lorem)"
+'
+
+test_expect_success 'am pauses on conflict' '
+ git checkout lorem2^^ &&
+ test_must_fail git am lorem-move.patch &&
+ test -d .git/rebase-apply
+'
+
+test_expect_success 'am --skip works' '
+ git am --skip &&
+ ! test -d .git/rebase-apply &&
+ test -z "$(git diff lorem2^^ -- file)" &&
+ test goodbye = "$(cat another)"
+'
+
+test_expect_success 'am --resolved works' '
+ git checkout lorem2^^ &&
+ test_must_fail git am lorem-move.patch &&
+ test -d .git/rebase-apply &&
+ echo resolved >>file &&
+ git add file &&
+ git am --resolved &&
+ ! test -d .git/rebase-apply &&
+ test goodbye = "$(cat another)"
+'
+
+test_expect_success 'am takes patches from a Pine mailbox' '
+ git checkout first &&
+ cat pine patch1 | git am &&
+ ! test -d .git/rebase-apply &&
+ test -z "$(git diff master^..HEAD)"
+'
+
+test_expect_success 'am fails on mail without patch' '
+ test_must_fail git am <failmail &&
+ rm -r .git/rebase-apply/
+'
+
+test_expect_success 'am fails on empty patch' '
+ echo "---" >>failmail &&
+ test_must_fail git am <failmail &&
+ git am --skip &&
+ ! test -d .git/rebase-apply
+'
+
+test_expect_success 'am works from stdin in subdirectory' '
+ rm -fr subdir &&
+ git checkout first &&
+ (
+ mkdir -p subdir &&
+ cd subdir &&
+ git am <../patch1
+ ) &&
+ test -z "$(git diff second)"
+'
+
+test_expect_success 'am works from file (relative path given) in subdirectory' '
+ rm -fr subdir &&
+ git checkout first &&
+ (
+ mkdir -p subdir &&
+ cd subdir &&
+ git am ../patch1
+ ) &&
+ test -z "$(git diff second)"
+'
+
+test_expect_success 'am works from file (absolute path given) in subdirectory' '
+ rm -fr subdir &&
+ git checkout first &&
+ P=$(pwd) &&
+ (
+ mkdir -p subdir &&
+ cd subdir &&
+ git am "$P/patch1"
+ ) &&
+ test -z "$(git diff second)"
+'
+
+test_done
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
new file mode 100755
index 000000000..7d86cdff6
--- /dev/null
+++ b/t/t4151-am-abort.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+test_description='am --abort'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ for i in a b c d e f g
+ do
+ echo $i
+ done >file-1 &&
+ cp file-1 file-2 &&
+ test_tick &&
+ git add file-1 file-2 &&
+ git commit -m initial &&
+ git tag initial &&
+ for i in 2 3 4 5 6
+ do
+ echo $i >>file-1 &&
+ echo $i >otherfile-$i &&
+ git add otherfile-$i &&
+ test_tick &&
+ git commit -a -m $i || break
+ done &&
+ git format-patch initial &&
+ git checkout -b side initial &&
+ echo local change >file-2-expect
+'
+
+for with3 in '' ' -3'
+do
+ test_expect_success "am$with3 stops at a patch that does not apply" '
+
+ git reset --hard initial &&
+ cp file-2-expect file-2 &&
+
+ test_must_fail git am$with3 000[1245]-*.patch &&
+ git log --pretty=tformat:%s >actual &&
+ for i in 3 2 initial
+ do
+ echo $i
+ done >expect &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "am$with3 --skip continue after failed am$with3" '
+ test_must_fail git-am$with3 --skip >output &&
+ test "$(grep "^Applying" output)" = "Applying: 6" &&
+ test_cmp file-2-expect file-2 &&
+ test ! -f .git/rr-cache/MERGE_RR
+ '
+
+ test_expect_success "am --abort goes back after failed am$with3" '
+ git-am --abort &&
+ git rev-parse HEAD >actual &&
+ git rev-parse initial >expect &&
+ test_cmp expect actual &&
+ test_cmp file-2-expect file-2 &&
+ git diff-index --exit-code --cached HEAD &&
+ test ! -f .git/rr-cache/MERGE_RR
+ '
+
+done
+
+test_done
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index eeff3c9c0..b68ab11f2 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -9,6 +9,8 @@ test_description='git rerere
. ./test-lib.sh
cat > a1 << EOF
+Some title
+==========
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
@@ -24,6 +26,8 @@ git commit -q -a -m initial
git checkout -b first
cat >> a1 << EOF
+Some title
+==========
To die, to sleep;
To sleep: perchance to dream: ay, there's the rub;
For in that sleep of death what dreams may come
@@ -35,13 +39,13 @@ git commit -q -a -m first
git checkout -b second master
git show first:a1 |
-sed -e 's/To die, t/To die! T/' > a1
+sed -e 's/To die, t/To die! T/' -e 's/Some title/Some Title/' > a1
echo "* END *" >>a1
git commit -q -a -m second
test_expect_success 'nothing recorded without rerere' '
(rm -rf .git/rr-cache; git config rerere.enabled false) &&
- ! git merge first &&
+ test_must_fail git merge first &&
! test -d .git/rr-cache
'
@@ -50,19 +54,19 @@ test_expect_success 'conflicting merge' '
git reset --hard &&
mkdir .git/rr-cache &&
git config --unset rerere.enabled &&
- ! git merge first
+ test_must_fail git merge first
'
-sha1=$(sed -e 's/ .*//' .git/rr-cache/MERGE_RR)
+sha1=$(sed -e 's/ .*//' .git/MERGE_RR)
rr=.git/rr-cache/$sha1
-test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
test_expect_success 'rerere.enabled works, too' '
rm -rf .git/rr-cache &&
git config rerere.enabled true &&
git reset --hard &&
- ! git merge first &&
- grep ======= $rr/preimage
+ test_must_fail git merge first &&
+ grep ^=======$ $rr/preimage
'
test_expect_success 'no postimage or thisimage yet' \
@@ -71,7 +75,7 @@ test_expect_success 'no postimage or thisimage yet' \
test_expect_success 'preimage has right number of lines' '
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
- test $cnt = 9
+ test $cnt = 13
'
@@ -80,13 +84,23 @@ git show first:a1 > a1
cat > expect << EOF
--- a/a1
+++ b/a1
-@@ -6,17 +6,9 @@
+@@ -1,4 +1,4 @@
+-Some Title
++Some title
+ ==========
+ Whether 'tis nobler in the mind to suffer
+ The slings and arrows of outrageous fortune,
+@@ -8,21 +8,11 @@
The heart-ache and the thousand natural shocks
That flesh is heir to, 'tis a consummation
Devoutly to be wish'd.
-<<<<<<<
+-Some Title
+-==========
-To die! To sleep;
-=======
+ Some title
+ ==========
To die, to sleep;
->>>>>>>
To sleep: perchance to dream: ay, there's the rub;
@@ -101,7 +115,7 @@ cat > expect << EOF
EOF
git rerere diff > out
-test_expect_success 'rerere diff' 'git diff expect out'
+test_expect_success 'rerere diff' 'test_cmp expect out'
cat > expect << EOF
a1
@@ -109,7 +123,7 @@ EOF
git rerere status > out
-test_expect_success 'rerere status' 'git diff expect out'
+test_expect_success 'rerere status' 'test_cmp expect out'
test_expect_success 'commit succeeds' \
"git commit -q -a -m 'prefer first over second'"
@@ -120,16 +134,16 @@ test_expect_success 'another conflicting merge' '
git checkout -b third master &&
git show second^:a1 | sed "s/To die: t/To die! T/" > a1 &&
git commit -q -a -m third &&
- ! git pull . first
+ test_must_fail git pull . first
'
git show first:a1 | sed 's/To die: t/To die! T/' > expect
-test_expect_success 'rerere kicked in' "! grep ======= a1"
+test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
-test_expect_success 'rerere prefers first change' 'git diff a1 expect'
+test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
rm $rr/postimage
-echo "$sha1 a1" | tr '\012' '\000' > .git/rr-cache/MERGE_RR
+echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
test_expect_success 'rerere clear' 'git rerere clear'
@@ -175,8 +189,8 @@ test_expect_success 'file2 added differently in two branches' '
echo Bello > file2 &&
git add file2 &&
git commit -m version2 &&
- ! git merge fourth &&
- sha1=$(sed -e "s/ .*//" .git/rr-cache/MERGE_RR) &&
+ test_must_fail git merge fourth &&
+ sha1=$(sed -e "s/ .*//" .git/MERGE_RR) &&
rr=.git/rr-cache/$sha1 &&
echo Cello > file2 &&
git add file2 &&
@@ -193,9 +207,19 @@ test_expect_success 'resolution was recorded properly' '
echo Bello > file3 &&
git add file3 &&
git commit -m version2 &&
- ! git merge fifth &&
- git diff-files -q &&
- test Cello = "$(cat file3)"
+ git tag version2 &&
+ test_must_fail git merge fifth &&
+ test Cello = "$(cat file3)" &&
+ test 0 != $(git ls-files -u | wc -l)
+'
+
+test_expect_success 'rerere.autoupdate' '
+ git config rerere.autoupdate true
+ git reset --hard &&
+ git checkout version2 &&
+ test_must_fail git merge fifth &&
+ test 0 = $(git ls-files -u | wc -l)
+
'
test_done
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6d12efb74..405b97119 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -45,6 +45,11 @@ A U Thor (5):
EOF
-test_expect_success 'shortlog wrapping' 'diff -u expect out'
+test_expect_success 'shortlog wrapping' 'test_cmp expect out'
+
+git log HEAD > log
+GIT_DIR=non-existing git shortlog -w < log > out
+
+test_expect_success 'shortlog from non-git directory' 'test_cmp expect out'
test_done
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index b53645417..4c8af45f8 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -71,4 +71,5 @@ test_expect_success 'diff-filter=D' '
-test_done \ No newline at end of file
+test_done
+
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index dca2067b2..e395ff4e3 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -25,7 +25,6 @@ commit id embedding:
'
. ./test-lib.sh
-TAR=${TAR:-tar}
UNZIP=${UNZIP:-unzip}
SUBSTFORMAT=%H%n
@@ -45,6 +44,11 @@ test_expect_success \
(cd a && find .) | sort >a.lst'
test_expect_success \
+ 'add ignored file' \
+ 'echo ignore me >a/ignored &&
+ echo ignored export-ignore >.gitattributes'
+
+test_expect_success \
'add files to repository' \
'find a -type f | xargs git update-index --add &&
find a -type l | xargs git update-index --add &&
@@ -54,6 +58,10 @@ test_expect_success \
git commit-tree $treeid </dev/null)'
test_expect_success \
+ 'remove ignored file' \
+ 'rm a/ignored'
+
+test_expect_success \
'git archive' \
'git archive HEAD >b.tar'
@@ -67,10 +75,10 @@ test_expect_success \
test_expect_success \
'validate file modification time' \
- 'TZ=GMT $TAR tvf b.tar a/a |
- awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \
- >b.mtime &&
- echo "2005-05-27 22:00:00" >expected.mtime &&
+ 'mkdir extract &&
+ "$TAR" xf b.tar -C extract a/a &&
+ perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
+ echo "1117231200" >expected.mtime &&
diff expected.mtime b.mtime'
test_expect_success \
@@ -80,7 +88,7 @@ test_expect_success \
test_expect_success \
'extract tar archive' \
- '(cd b && $TAR xf -) <b.tar'
+ '(cd b && "$TAR" xf -) <b.tar'
test_expect_success \
'validate filenames' \
@@ -97,7 +105,7 @@ test_expect_success \
test_expect_success \
'extract tar archive with prefix' \
- '(cd c && $TAR xf -) <c.tar'
+ '(cd c && "$TAR" xf -) <c.tar'
test_expect_success \
'validate filenames with prefix' \
@@ -109,14 +117,15 @@ test_expect_success \
'diff -r a c/prefix/a'
test_expect_success \
- 'create an archive with a substfiles' \
+ 'create archives with substfiles' \
'echo "substfile?" export-subst >a/.gitattributes &&
git archive HEAD >f.tar &&
+ git archive --prefix=prefix/ HEAD >g.tar &&
rm a/.gitattributes'
test_expect_success \
'extract substfiles' \
- '(mkdir f && cd f && $TAR xf -) <f.tar'
+ '(mkdir f && cd f && "$TAR" xf -) <f.tar'
test_expect_success \
'validate substfile contents' \
@@ -127,6 +136,18 @@ test_expect_success \
'
test_expect_success \
+ 'extract substfiles from archive with prefix' \
+ '(mkdir g && cd g && "$TAR" xf -) <g.tar'
+
+test_expect_success \
+ 'validate substfile contents from archive with prefix' \
+ 'git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
+ >g/prefix/a/substfile1.expected &&
+ diff g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&
+ diff a/substfile2 g/prefix/a/substfile2
+'
+
+test_expect_success \
'git archive --format=zip' \
'git archive --format=zip HEAD >d.zip'
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh
index 9b1a74542..8dfaddda9 100755
--- a/t/t5100-mailinfo.sh
+++ b/t/t5100-mailinfo.sh
@@ -11,7 +11,7 @@ test_expect_success 'split sample box' \
'git mailsplit -o. ../t5100/sample.mbox >last &&
last=`cat last` &&
echo total is $last &&
- test `cat last` = 8'
+ test `cat last` = 11'
for mail in `echo 00*`
do
@@ -25,4 +25,22 @@ do
diff ../t5100/info$mail info$mail"
done
+test_expect_success 'respect NULs' '
+
+ git mailsplit -d3 -o. ../t5100/nul-plain &&
+ cmp ../t5100/nul-plain 001 &&
+ (cat 001 | git mailinfo msg patch) &&
+ test 4 = $(wc -l < patch)
+
+'
+
+test_expect_success 'Preserve NULs out of MIME encoded message' '
+
+ git mailsplit -d5 -o. ../t5100/nul-b64.in &&
+ cmp ../t5100/nul-b64.in 00001 &&
+ git mailinfo msg patch <00001 &&
+ cmp ../t5100/nul-b64.expect patch
+
+'
+
test_done
diff --git a/t/t5100/0010 b/t/t5100/0010
new file mode 100644
index 000000000..f5892c9da
--- /dev/null
+++ b/t/t5100/0010
@@ -0,0 +1,35 @@
+From b9704a518e21158433baa2cc2d591fea687967f6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Lukas=20Sandstr=C3=B6m?= <lukass@etek.chalmers.se>
+Date: Thu, 10 Jul 2008 23:41:33 +0200
+Subject: Re: discussion that lead to this patch
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+[PATCH] git-mailinfo: Fix getting the subject from the body
+
+"Subject: " isn't in the static array "header", and thus
+memcmp("Subject: ", header[i], 7) will never match.
+
+Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
+Signed-off-by: Junio C Hamano <gitster@pobox.com>
+---
+ builtin-mailinfo.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 962aa34..2d1520f 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over
+ return 1;
+ if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
+ for (i = 0; header[i]; i++) {
+- if (!memcmp("Subject: ", header[i], 9)) {
++ if (!memcmp("Subject", header[i], 7)) {
+ if (! handle_header(line, hdr_data[i], 0)) {
+ return 1;
+ }
+--
+1.5.6.2.455.g1efb2
+
diff --git a/t/t5100/info0009 b/t/t5100/info0009
new file mode 100644
index 000000000..2a66321c8
--- /dev/null
+++ b/t/t5100/info0009
@@ -0,0 +1,5 @@
+Author: F U Bar
+Email: f.u.bar@example.com
+Subject: updates
+Date: Mon, 17 Sep 2001 00:00:00 +0900
+
diff --git a/t/t5100/info0010 b/t/t5100/info0010
new file mode 100644
index 000000000..1791241e4
--- /dev/null
+++ b/t/t5100/info0010
@@ -0,0 +1,5 @@
+Author: Lukas Sandström
+Email: lukass@etek.chalmers.se
+Subject: git-mailinfo: Fix getting the subject from the body
+Date: Thu, 10 Jul 2008 23:41:33 +0200
+
diff --git a/t/t5100/info0011 b/t/t5100/info0011
new file mode 100644
index 000000000..da5a605a1
--- /dev/null
+++ b/t/t5100/info0011
@@ -0,0 +1,5 @@
+Author: A U Thor
+Email: a.u.thor@example.com
+Subject: Xyzzy
+Date: Fri, 8 Aug 2008 13:08:37 +0200 (CEST)
+
diff --git a/t/t5100/msg0009 b/t/t5100/msg0009
new file mode 100644
index 000000000..9ffe13148
--- /dev/null
+++ b/t/t5100/msg0009
@@ -0,0 +1,2 @@
+This is to fix diff-format documentation.
+
diff --git a/t/t5100/msg0010 b/t/t5100/msg0010
new file mode 100644
index 000000000..a96c23009
--- /dev/null
+++ b/t/t5100/msg0010
@@ -0,0 +1,5 @@
+"Subject: " isn't in the static array "header", and thus
+memcmp("Subject: ", header[i], 7) will never match.
+
+Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
+Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/t/t5100/msg0011 b/t/t5100/msg0011
new file mode 100644
index 000000000..4667f2100
--- /dev/null
+++ b/t/t5100/msg0011
@@ -0,0 +1,2 @@
+Here comes a commit log message, and
+its second line is here.
diff --git a/t/t5100/nul-b64.expect b/t/t5100/nul-b64.expect
new file mode 100644
index 000000000..d7d680f63
--- /dev/null
+++ b/t/t5100/nul-b64.expect
Binary files differ
diff --git a/t/t5100/nul-b64.in b/t/t5100/nul-b64.in
new file mode 100644
index 000000000..16540d961
--- /dev/null
+++ b/t/t5100/nul-b64.in
@@ -0,0 +1,37 @@
+From 667d8940e719cddee1cfe237cbbe215e20270b09 Mon Sep 17 00:00:00 2001
+From: Junio C Hamano <gitster@pobox.com>
+Date: Sun, 25 May 2008 00:38:18 -0700
+Subject: [PATCH] second
+Content-Transfer-Encoding: base64
+
+LS0tCiBmaWxlIHwgIEJpbiAxMzU3IC0+IDEzNTcgYnl0ZXMKIDEgZmlsZXMgY2hhbmdlZCwg
+MCBpbnNlcnRpb25zKCspLCAwIGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2ZpbGUgYi9m
+aWxlCmluZGV4IDc3MzYxZDguLjllMDJiZTYgMTAwNjQ0Ci0tLSBhL2ZpbGUKKysrIGIvZmls
+ZQpAQCAtMSwxMiArMSwxMiBAQAogTG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl
+Y3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIFN1c3BlbmRpc3NlCiBzaXQgYW1ldCB0dXJwaXMg
+ZWdldCBlc3QgY3Vyc3VzIGxhb3JlZXQuIEFsaXF1YW0gbWF1cmlzLiBQcmFlc2VudAotdm9s
+dXRwYXQuIFByb2luIGluIHB1cnVzLiBOdWxsYSB1cm5hIHNhcGllbiwgZGFwaWJ1cyBzaXQg
+YW1ldCwKK3ZvbHV0cGF0LiBQcm9pbiBpbiBwdXJ1cy4gTnVsbGEgdXJuYSBzYXBpZW4sIGRh
+cGkAdXMgc2l0IGFtZXQsCiBoZW5kcmVyaXQgbmVjLCB0ZW1wdXMgZXUsIG1pLiBVdCBwb3J0
+YSwgbGVvIGlkIHRpbmNpZHVudCB1bGxhbWNvcnBlciwKLXZlbGl0IGZlbGlzIHRyaXN0aXF1
+ZSBhbnRlLCBhdCBsb2JvcnRpcyBkaWFtIHBlZGUgdXQgZHVpLiBQcm9pbiBhYwordmVsaXQg
+ZmVsaXMgdHJpc3RpcXVlIGFudGUsIGF0IGxvAG9ydGlzIGRpYW0gcGVkZSB1dCBkdWkuIFBy
+b2luIGFjCiBsZWN0dXMuIERvbmVjIGF0IG1hc3NhIGFjIGlwc3VtIGhlbmRyZXJpdCBzb2xs
+aWNpdHVkaW4uIE5hbSBkaWN0dW0KIG5pc2kgc2VkIG1pLiBEdWlzIHNlZCBhbnRlLiBVdCB2
+aXRhZSBlc3QgdXQgZHVpIHVsdHJpY2llcyBkaWduaXNzaW0uCiAKLUluIHZlbCBvZGlvIGVn
+ZXQgbmlzbCBjb252YWxsaXMgdm9sdXRwYXQuIE1vcmJpIHZpdGFlIG5pYmguIE51bGxhbQor
+SW4gdmVsIG9kaW8gZWdldCBuaXNsIGNvbnZhbGxpcyB2b2x1dHBhdC4gTW9yAGkgdml0YWUg
+bmkAaC4gTnVsbGFtCiBhY2N1bXNhbiwgZG9sb3IgcXVpcyBhbGlxdWFtIHNjZWxlcmlzcXVl
+LCBlbGl0IGVuaW0gY29uZGltZW50dW0KIG1hdXJpcywgbm9uIHRyaXN0aXF1ZSBtYXVyaXMg
+dHVycGlzIGV0IG1hdXJpcy4gVXQgbm9uIG5pc2wuIE5hbSBkaWFtCiBtaSwgc2VtcGVyIHBv
+c3VlcmUsIGVsZWlmZW5kIHV0LCBhdWN0b3IgdmVsLCBlcmF0LiBTZWQgcG9zdWVyZQpAQCAt
+MTYsNyArMTYsNyBAQCBzZWQgZXN0LiBFdGlhbSBkaWFtIGZlbGlzLCBmZXJtZW50dW0gZWdl
+dCwgYWRpcGlzY2luZyBhdCwgcG9zdWVyZSBpbiwKIGR1aS4gRXRpYW0gbHVjdHVzLgogCiBO
+dWxsYSBpZCBhdWd1ZS4gTmFtIGlhY3VsaXMgYWNjdW1zYW4gbmlzaS4gU3VzcGVuZGlzc2Ug
+cG90ZW50aS4gTnVuYwotdmFyaXVzIGF1Z3VlIG5lYyBvcmNpLiBVdCBjb25kaW1lbnR1bSBk
+b2xvciBzYWdpdHRpcyBuaWJoLiBTdXNwZW5kaXNzZQordmFyaXVzIGF1Z3VlIG5lYyBvcmNp
+LiBVdCBjb25kaW1lbnR1bSBkb2xvciBzYWdpdHRpcyBuaQBoLiBTdXNwZW5kaXNzZQogdGVt
+cG9yIGxlY3R1cyBzZWQgbWFnbmEuIFN1c3BlbmRpc3NlIHBvdGVudGkuIE51bGxhbSB0ZW1w
+b3IgaXBzdW0uIFNlZAogbW9sZXN0aWUgdGVsbHVzLiBQaGFzZWxsdXMgbGlndWxhLiBJbiB2
+ZWhpY3VsYSB1bHRyaWNlcwogbmlzaS4gU3VzcGVuZGlzc2UgZmVsaXMgYXVndWUsIHBlbGxl
+bnRlc3F1ZSBhdCwgZGljdHVtIHZpdmVycmEsCi0tIAoxLjUuNS4xLjU0MC5nNTc3ODAKCg==
diff --git a/t/t5100/nul-plain b/t/t5100/nul-plain
new file mode 100644
index 000000000..3d4069178
--- /dev/null
+++ b/t/t5100/nul-plain
Binary files differ
diff --git a/t/t5100/patch0009 b/t/t5100/patch0009
new file mode 100644
index 000000000..65615c34a
--- /dev/null
+++ b/t/t5100/patch0009
@@ -0,0 +1,13 @@
+diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
+index b426a14..97756ec 100644
+--- a/Documentation/diff-format.txt
++++ b/Documentation/diff-format.txt
+@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
+ environment variable 'GIT_DIFF_OPTS'. For example, if you
+ prefer context diff:
+
+- GIT_DIFF_OPTS=-c git-diff-index -p $(cat .git/HEAD)
++ GIT_DIFF_OPTS=-c git-diff-index -p HEAD
+
+
+ 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
diff --git a/t/t5100/patch0010 b/t/t5100/patch0010
new file mode 100644
index 000000000..f055481d5
--- /dev/null
+++ b/t/t5100/patch0010
@@ -0,0 +1,20 @@
+---
+ builtin-mailinfo.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 962aa34..2d1520f 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over
+ return 1;
+ if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
+ for (i = 0; header[i]; i++) {
+- if (!memcmp("Subject: ", header[i], 9)) {
++ if (!memcmp("Subject", header[i], 7)) {
+ if (! handle_header(line, hdr_data[i], 0)) {
+ return 1;
+ }
+--
+1.5.6.2.455.g1efb2
+
diff --git a/t/t5100/patch0011 b/t/t5100/patch0011
new file mode 100644
index 000000000..8841d3c13
--- /dev/null
+++ b/t/t5100/patch0011
@@ -0,0 +1,22 @@
+---
+ builtin-mailinfo.c | 4 ++--
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 3e5fe51..aabfe5c 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -758,8 +758,8 @@ static void handle_body(void)
+ /* process any boundary lines */
+ if (*content_top && is_multipart_boundary(&line)) {
+ /* flush any leftover */
+- if (line.len)
+- handle_filter(&line);
++ if (prev.len)
++ handle_filter(&prev);
+
+ if (!handle_boundary())
+ goto handle_body_out;
+--
+1.6.0.rc2
+
+
diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox
index 070c1661b..d7ca79b1f 100644
--- a/t/t5100/sample.mbox
+++ b/t/t5100/sample.mbox
@@ -407,3 +407,96 @@ Subject: [PATCH] another patch
Hey you forgot the patch!
+From nobody Mon Sep 17 00:00:00 2001
+From: A U Thor <a.u.thor@example.com>
+Date: Mon, 17 Sep 2001 00:00:00 +0900
+Mime-Version: 1.0
+Content-Type: Text/Plain; charset=us-ascii
+Content-Transfer-Encoding: Quoted-Printable
+
+=0A=0AFrom: F U Bar <f.u.bar@example.com>
+Subject: [PATCH] updates=0A=0AThis is to fix diff-format documentation.
+
+diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
+index b426a14..97756ec 100644
+--- a/Documentation/diff-format.txt
++++ b/Documentation/diff-format.txt
+@@ -81,7 +81,7 @@ The "diff" formatting options can be customized via the
+ environment variable 'GIT_DIFF_OPTS'. For example, if you
+ prefer context diff:
+=20
+- GIT_DIFF_OPTS=3D-c git-diff-index -p $(cat .git/HEAD)
++ GIT_DIFF_OPTS=3D-c git-diff-index -p HEAD
+=20
+=20
+ 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
+From b9704a518e21158433baa2cc2d591fea687967f6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Lukas=20Sandstr=C3=B6m?= <lukass@etek.chalmers.se>
+Date: Thu, 10 Jul 2008 23:41:33 +0200
+Subject: Re: discussion that lead to this patch
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+[PATCH] git-mailinfo: Fix getting the subject from the body
+
+"Subject: " isn't in the static array "header", and thus
+memcmp("Subject: ", header[i], 7) will never match.
+
+Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>
+Signed-off-by: Junio C Hamano <gitster@pobox.com>
+---
+ builtin-mailinfo.c | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 962aa34..2d1520f 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -334,7 +334,7 @@ static int check_header(char *line, unsigned linesize, char **hdr_data, int over
+ return 1;
+ if (!memcmp("[PATCH]", line, 7) && isspace(line[7])) {
+ for (i = 0; header[i]; i++) {
+- if (!memcmp("Subject: ", header[i], 9)) {
++ if (!memcmp("Subject", header[i], 7)) {
+ if (! handle_header(line, hdr_data[i], 0)) {
+ return 1;
+ }
+--
+1.5.6.2.455.g1efb2
+
+From nobody Fri Aug 8 22:24:03 2008
+Date: Fri, 8 Aug 2008 13:08:37 +0200 (CEST)
+From: A U Thor <a.u.thor@example.com>
+Subject: [PATCH 3/3 v2] Xyzzy
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="=-=-="
+
+--=-=-=
+Content-Type: text/plain; charset=iso-8859-15
+Content-Transfer-Encoding: quoted-printable
+
+Here comes a commit log message, and
+its second line is here.
+---
+ builtin-mailinfo.c | 4 ++--
+
+diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
+index 3e5fe51..aabfe5c 100644
+--- a/builtin-mailinfo.c
++++ b/builtin-mailinfo.c
+@@ -758,8 +758,8 @@ static void handle_body(void)
+ /* process any boundary lines */
+ if (*content_top && is_multipart_boundary(&line)) {
+ /* flush any leftover */
+- if (line.len)
+- handle_filter(&line);
++ if (prev.len)
++ handle_filter(&prev);
+=20
+ if (!handle_boundary())
+ goto handle_body_out;
+--=20
+1.6.0.rc2
+
+--=-=-=--
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index 6e594bf1e..645583f9d 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -15,7 +15,7 @@ test_expect_success \
'rm -f .git/index*
for i in a b c
do
- dd if=/dev/zero bs=4k count=1 | tr "\\000" $i >$i &&
+ dd if=/dev/zero bs=4k count=1 | perl -pe "y/\\000/$i/" >$i &&
git update-index --add $i || return 1
done &&
cat c >d && echo foo >>d && git update-index --add d &&
@@ -264,8 +264,109 @@ test_expect_success \
cp -f .git/objects/9d/235ed07cd19811a6ceb342de82f190e49c9f68 \
.git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67'
-test_expect_failure \
+test_expect_success \
'make sure index-pack detects the SHA1 collision' \
- 'git-index-pack -o bad.idx test-3.pack'
+ 'test_must_fail git-index-pack -o bad.idx test-3.pack'
+
+test_expect_success \
+ 'honor pack.packSizeLimit' \
+ 'git config pack.packSizeLimit 200 &&
+ packname_4=$(git pack-objects test-4 <obj-list) &&
+ test 3 = $(ls test-4-*.pack | wc -l)'
+
+test_expect_success 'unpacking with --strict' '
+
+ git config --unset pack.packsizelimit &&
+ for j in a b c d e f g
+ do
+ for i in 0 1 2 3 4 5 6 7 8 9
+ do
+ o=$(echo $j$i | git hash-object -w --stdin) &&
+ echo "100644 $o 0 $j$i"
+ done
+ done >LIST &&
+ rm -f .git/index &&
+ git update-index --index-info <LIST &&
+ LIST=$(git write-tree) &&
+ rm -f .git/index &&
+ head -n 10 LIST | git update-index --index-info &&
+ LI=$(git write-tree) &&
+ rm -f .git/index &&
+ tail -n 10 LIST | git update-index --index-info &&
+ ST=$(git write-tree) &&
+ PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+ git pack-objects test-5 ) &&
+ PACK6=$( (
+ echo "$LIST"
+ echo "$LI"
+ echo "$ST"
+ ) | git pack-objects test-6 ) &&
+ test_create_repo test-5 &&
+ (
+ cd test-5 &&
+ git unpack-objects --strict <../test-5-$PACK5.pack &&
+ git ls-tree -r $LIST &&
+ git ls-tree -r $LI &&
+ git ls-tree -r $ST
+ ) &&
+ test_create_repo test-6 &&
+ (
+ # tree-only into empty repo -- many unreachables
+ cd test-6 &&
+ test_must_fail git unpack-objects --strict <../test-6-$PACK6.pack
+ ) &&
+ (
+ # already populated -- no unreachables
+ cd test-5 &&
+ git unpack-objects --strict <../test-6-$PACK6.pack
+ )
+'
+
+test_expect_success 'index-pack with --strict' '
+
+ for j in a b c d e f g
+ do
+ for i in 0 1 2 3 4 5 6 7 8 9
+ do
+ o=$(echo $j$i | git hash-object -w --stdin) &&
+ echo "100644 $o 0 $j$i"
+ done
+ done >LIST &&
+ rm -f .git/index &&
+ git update-index --index-info <LIST &&
+ LIST=$(git write-tree) &&
+ rm -f .git/index &&
+ head -n 10 LIST | git update-index --index-info &&
+ LI=$(git write-tree) &&
+ rm -f .git/index &&
+ tail -n 10 LIST | git update-index --index-info &&
+ ST=$(git write-tree) &&
+ PACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \
+ git pack-objects test-5 ) &&
+ PACK6=$( (
+ echo "$LIST"
+ echo "$LI"
+ echo "$ST"
+ ) | git pack-objects test-6 ) &&
+ test_create_repo test-7 &&
+ (
+ cd test-7 &&
+ git index-pack --strict --stdin <../test-5-$PACK5.pack &&
+ git ls-tree -r $LIST &&
+ git ls-tree -r $LI &&
+ git ls-tree -r $ST
+ ) &&
+ test_create_repo test-8 &&
+ (
+ # tree-only into empty repo -- many unreachables
+ cd test-8 &&
+ test_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack
+ ) &&
+ (
+ # already populated -- no unreachables
+ cd test-7 &&
+ git index-pack --strict --stdin <../test-6-$PACK6.pack
+ )
+'
test_done
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 2a2878b57..0639772ac 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -42,9 +42,9 @@ test_expect_success \
'both packs should be identical' \
'cmp "test-1-${pack1}.pack" "test-2-${pack2}.pack"'
-test_expect_failure \
+test_expect_success \
'index v1 and index v2 should be different' \
- 'cmp "test-1-${pack1}.idx" "test-2-${pack2}.idx"'
+ '! cmp "test-1-${pack1}.idx" "test-2-${pack2}.idx"'
test_expect_success \
'index-pack with index version 1' \
@@ -65,7 +65,7 @@ test_expect_success \
have_64bits=
if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) ||
- ! echo "$msg" | grep "pack too large .* off_t"
+ ! (echo "$msg" | grep "pack too large .* off_t")
then
have_64bits=t
else
@@ -78,9 +78,9 @@ test_expect_success \
'git verify-pack -v "test-3-${pack3}.pack"'
test "$have_64bits" &&
-test_expect_failure \
+test_expect_success \
'64-bit offsets: should be different from previous index v2 results' \
- 'cmp "test-2-${pack2}.idx" "test-3-${pack3}.idx"'
+ '! cmp "test-2-${pack2}.idx" "test-3-${pack3}.idx"'
test "$have_64bits" &&
test_expect_success \
@@ -103,7 +103,7 @@ test_expect_success \
test_expect_success \
'[index v1] 2) create a stealth corruption in a delta base reference' \
'# this test assumes a delta smaller than 16 bytes at the end of the pack
- git show-index <1.idx | sort -n | tail -n 1 | (
+ git show-index <1.idx | sort -n | sed -ne \$p | (
read delta_offs delta_sha1 &&
git cat-file blob "$delta_sha1" > blob_1 &&
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
@@ -112,22 +112,22 @@ test_expect_success \
bs=1 count=20 conv=notrunc &&
git cat-file blob "$delta_sha1" > blob_2 )'
-test_expect_failure \
+test_expect_success \
'[index v1] 3) corrupted delta happily returned wrong data' \
- 'cmp blob_1 blob_2'
+ '! cmp blob_1 blob_2'
-test_expect_failure \
+test_expect_success \
'[index v1] 4) confirm that the pack is actually corrupted' \
- 'git fsck --full $commit'
+ 'test_must_fail git fsck --full $commit'
test_expect_success \
'[index v1] 5) pack-objects happily reuses corrupted data' \
'pack4=$(git pack-objects test-4 <obj-list) &&
test -f "test-4-${pack1}.pack"'
-test_expect_failure \
+test_expect_success \
'[index v1] 6) newly created pack is BAD !' \
- 'git verify-pack -v "test-4-${pack1}.pack"'
+ 'test_must_fail git verify-pack -v "test-4-${pack1}.pack"'
test_expect_success \
'[index v2] 1) stream pack to repository' \
@@ -141,7 +141,7 @@ test_expect_success \
test_expect_success \
'[index v2] 2) create a stealth corruption in a delta base reference' \
'# this test assumes a delta smaller than 16 bytes at the end of the pack
- git show-index <1.idx | sort -n | tail -n 1 | (
+ git show-index <1.idx | sort -n | sed -ne \$p | (
read delta_offs delta_sha1 delta_crc &&
git cat-file blob "$delta_sha1" > blob_3 &&
chmod +w ".git/objects/pack/pack-${pack1}.pack" &&
@@ -150,16 +150,31 @@ test_expect_success \
bs=1 count=20 conv=notrunc &&
git cat-file blob "$delta_sha1" > blob_4 )'
-test_expect_failure \
+test_expect_success \
'[index v2] 3) corrupted delta happily returned wrong data' \
- 'cmp blob_3 blob_4'
+ '! cmp blob_3 blob_4'
-test_expect_failure \
+test_expect_success \
'[index v2] 4) confirm that the pack is actually corrupted' \
- 'git fsck --full $commit'
+ 'test_must_fail git fsck --full $commit'
-test_expect_failure \
+test_expect_success \
'[index v2] 5) pack-objects refuses to reuse corrupted data' \
- 'git pack-objects test-5 <obj-list'
+ 'test_must_fail git pack-objects test-5 <obj-list'
+
+test_expect_success \
+ '[index v2] 6) verify-pack detects CRC mismatch' \
+ 'rm -f .git/objects/pack/* &&
+ git-index-pack --index-version=2 --stdin < "test-1-${pack1}.pack" &&
+ git verify-pack ".git/objects/pack/pack-${pack1}.pack" &&
+ chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
+ dd if=/dev/zero of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \
+ bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + 0)) &&
+ ( while read obj
+ do git cat-file -p $obj >/dev/null || exit 1
+ done <obj-list ) &&
+ err=$(test_must_fail git verify-pack \
+ ".git/objects/pack/pack-${pack1}.pack" 2>&1) &&
+ echo "$err" | grep "CRC mismatch"'
test_done
diff --git a/t/t5303-pack-corruption-resilience.sh b/t/t5303-pack-corruption-resilience.sh
new file mode 100755
index 000000000..31b20b21d
--- /dev/null
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -0,0 +1,194 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Nicolas Pitre
+#
+
+test_description='resilience to pack corruptions with redundant objects'
+. ./test-lib.sh
+
+# Note: the test objects are created with knowledge of their pack encoding
+# to ensure good code path coverage, and to facilitate direct alteration
+# later on. The assumed characteristics are:
+#
+# 1) blob_2 is a delta with blob_1 for base and blob_3 is a delta with blob2
+# for base, such that blob_3 delta depth is 2;
+#
+# 2) the bulk of object data is uncompressible so the text part remains
+# visible;
+#
+# 3) object header is always 2 bytes.
+
+create_test_files() {
+ test-genrandom "foo" 2000 > file_1 &&
+ test-genrandom "foo" 1800 > file_2 &&
+ test-genrandom "foo" 1800 > file_3 &&
+ echo " base " >> file_1 &&
+ echo " delta1 " >> file_2 &&
+ echo " delta delta2 " >> file_3 &&
+ test-genrandom "bar" 150 >> file_2 &&
+ test-genrandom "baz" 100 >> file_3
+}
+
+create_new_pack() {
+ rm -rf .git &&
+ git init &&
+ blob_1=`git hash-object -t blob -w file_1` &&
+ blob_2=`git hash-object -t blob -w file_2` &&
+ blob_3=`git hash-object -t blob -w file_3` &&
+ pack=`printf "$blob_1\n$blob_2\n$blob_3\n" |
+ git pack-objects $@ .git/objects/pack/pack` &&
+ pack=".git/objects/pack/pack-${pack}" &&
+ git verify-pack -v ${pack}.pack
+}
+
+do_corrupt_object() {
+ ofs=`git show-index < ${pack}.idx | grep $1 | cut -f1 -d" "` &&
+ ofs=$(($ofs + $2)) &&
+ chmod +w ${pack}.pack &&
+ dd if=/dev/zero of=${pack}.pack count=1 bs=1 conv=notrunc seek=$ofs &&
+ test_must_fail git verify-pack ${pack}.pack
+}
+
+test_expect_success \
+ 'initial setup validation' \
+ 'create_test_files &&
+ create_new_pack &&
+ git prune-packed &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'create corruption in header of first object' \
+ 'do_corrupt_object $blob_1 0 &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... but having a loose copy allows for full recovery' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... and loose copy of first delta allows for partial recovery' \
+ 'git prune-packed &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'create corruption in data of first object' \
+ 'create_new_pack &&
+ git prune-packed &&
+ chmod +w ${pack}.pack &&
+ perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... but having a loose copy allows for full recovery' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... and loose copy of second object allows for partial recovery' \
+ 'git prune-packed &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ test_must_fail git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'create corruption in header of first delta' \
+ 'create_new_pack &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 0 &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... but having a loose copy allows for full recovery' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'create corruption in data of first delta' \
+ 'create_new_pack &&
+ git prune-packed &&
+ chmod +w ${pack}.pack &&
+ perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... but having a loose copy allows for full recovery' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \
+ 'create_new_pack &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 2 &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... but having a loose copy allows for full recovery' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_2 &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ 'corruption in delta base reference of first delta (OBJ_OFS_DELTA)' \
+ 'create_new_pack --delta-base-offset &&
+ git prune-packed &&
+ do_corrupt_object $blob_2 2 &&
+ git cat-file blob $blob_1 > /dev/null &&
+ test_must_fail git cat-file blob $blob_2 > /dev/null &&
+ test_must_fail git cat-file blob $blob_3 > /dev/null'
+
+test_expect_success \
+ '... and a redundant pack allows for full recovery too' \
+ 'mv ${pack}.idx tmp &&
+ git hash-object -t blob -w file_1 &&
+ git hash-object -t blob -w file_2 &&
+ printf "$blob_1\n$blob_2\n" | git pack-objects .git/objects/pack/pack &&
+ git prune-packed &&
+ mv tmp ${pack}.idx &&
+ git cat-file blob $blob_1 > /dev/null &&
+ git cat-file blob $blob_2 > /dev/null &&
+ git cat-file blob $blob_3 > /dev/null'
+
+test_done
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
new file mode 100755
index 000000000..771c0a06a
--- /dev/null
+++ b/t/t5304-prune.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Johannes E. Schindelin
+#
+
+test_description='prune'
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ : > file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ git gc
+
+'
+
+test_expect_success 'prune stale packs' '
+
+ orig_pack=$(echo .git/objects/pack/*.pack) &&
+ : > .git/objects/tmp_1.pack &&
+ : > .git/objects/tmp_2.pack &&
+ test-chmtime =-86501 .git/objects/tmp_1.pack &&
+ git prune --expire 1.day &&
+ test -f $orig_pack &&
+ test -f .git/objects/tmp_2.pack &&
+ ! test -f .git/objects/tmp_1.pack
+
+'
+
+test_expect_success 'prune --expire' '
+
+ before=$(git count-objects | sed "s/ .*//") &&
+ BLOB=$(echo aleph | git hash-object -w --stdin) &&
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ git prune --expire=1.hour.ago &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime =-86500 $BLOB_FILE &&
+ git prune --expire 1.day &&
+ test $before = $(git count-objects | sed "s/ .*//") &&
+ ! test -f $BLOB_FILE
+
+'
+
+test_expect_success 'gc: implicit prune --expire' '
+
+ before=$(git count-objects | sed "s/ .*//") &&
+ BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
+ BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime =-$((86400*14-30)) $BLOB_FILE &&
+ git gc &&
+ test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
+ test -f $BLOB_FILE &&
+ test-chmtime =-$((86400*14+1)) $BLOB_FILE &&
+ git gc &&
+ test $before = $(git count-objects | sed "s/ .*//") &&
+ ! test -f $BLOB_FILE
+
+'
+
+test_expect_success 'gc: refuse to start with invalid gc.pruneExpire' '
+
+ git config gc.pruneExpire invalid &&
+ test_must_fail git gc
+
+'
+
+test_expect_success 'gc: start with ok gc.pruneExpire' '
+
+ git config gc.pruneExpire 2.days.ago &&
+ git gc
+
+'
+
+test_expect_success 'prune: prune nonsense parameters' '
+
+ test_must_fail git prune garbage &&
+ test_must_fail git prune --- &&
+ test_must_fail git prune --no-such-option
+
+'
+
+test_expect_success 'prune: prune unreachable heads' '
+
+ git config core.logAllRefUpdates false &&
+ mv .git/logs .git/logs.old &&
+ : > file2 &&
+ git add file2 &&
+ git commit -m temporary &&
+ tmp_head=$(git rev-list -1 HEAD) &&
+ git reset HEAD^ &&
+ git prune &&
+ test_must_fail git reset $tmp_head --
+
+'
+
+test_expect_success 'prune: do not prune heads listed as an argument' '
+
+ : > file2 &&
+ git add file2 &&
+ git commit -m temporary &&
+ tmp_head=$(git rev-list -1 HEAD) &&
+ git reset HEAD^ &&
+ git prune -- $tmp_head &&
+ git reset $tmp_head --
+
+'
+
+test_done
diff --git a/t/t5305-include-tag.sh b/t/t5305-include-tag.sh
new file mode 100755
index 000000000..fb471a08c
--- /dev/null
+++ b/t/t5305-include-tag.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+test_description='git-pack-object --include-tag'
+. ./test-lib.sh
+
+TRASH=`pwd`
+
+test_expect_success setup '
+ echo c >d &&
+ git update-index --add d &&
+ tree=`git write-tree` &&
+ commit=`git commit-tree $tree </dev/null` &&
+ echo "object $commit" >sig &&
+ echo "type commit" >>sig &&
+ echo "tag mytag" >>sig &&
+ echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
+ echo >>sig &&
+ echo "our test tag" >>sig &&
+ tag=`git mktag <sig` &&
+ rm d sig &&
+ git update-ref refs/tags/mytag $tag && {
+ echo $tree &&
+ echo $commit &&
+ git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
+ } >obj-list
+'
+
+rm -rf clone.git
+test_expect_success 'pack without --include-tag' '
+ packname_1=$(git pack-objects \
+ --window=0 \
+ test-1 <obj-list)
+'
+
+test_expect_success 'unpack objects' '
+ (
+ GIT_DIR=clone.git &&
+ export GIT_DIR &&
+ git init &&
+ git unpack-objects -n <test-1-${packname_1}.pack &&
+ git unpack-objects <test-1-${packname_1}.pack
+ )
+'
+
+test_expect_success 'check unpacked result (have commit, no tag)' '
+ git rev-list --objects $commit >list.expect &&
+ (
+ GIT_DIR=clone.git &&
+ export GIT_DIR &&
+ test_must_fail git cat-file -e $tag &&
+ git rev-list --objects $commit
+ ) >list.actual &&
+ test_cmp list.expect list.actual
+'
+
+rm -rf clone.git
+test_expect_success 'pack with --include-tag' '
+ packname_1=$(git pack-objects \
+ --window=0 \
+ --include-tag \
+ test-2 <obj-list)
+'
+
+test_expect_success 'unpack objects' '
+ (
+ GIT_DIR=clone.git &&
+ export GIT_DIR &&
+ git init &&
+ git unpack-objects -n <test-2-${packname_1}.pack &&
+ git unpack-objects <test-2-${packname_1}.pack
+ )
+'
+
+test_expect_success 'check unpacked result (have commit, have tag)' '
+ git rev-list --objects mytag >list.expect &&
+ (
+ GIT_DIR=clone.git &&
+ export GIT_DIR &&
+ git rev-list --objects $tag
+ ) >list.actual &&
+ test_cmp list.expect list.actual
+'
+
+test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 2d0c07fd6..68c2ae688 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -110,7 +110,7 @@ test_expect_success \
cd .. &&
git update-ref refs/heads/master master^ || return 1
git-send-pack --force ./victim/.git/ master && return 1
- ! git diff .git/refs/heads/master victim/.git/refs/heads/master
+ ! test_cmp .git/refs/heads/master victim/.git/refs/heads/master
'
test_expect_success \
@@ -120,7 +120,7 @@ test_expect_success \
cd .. &&
git-clone parent child && cd child && git-push --all &&
cd ../parent &&
- git-branch -a >branches && ! grep -q origin/master branches
+ git-branch -a >branches && ! grep origin/master branches
'
rewound_push_setup() {
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index 3eea3069e..ee769d669 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -25,7 +25,7 @@ test_expect_success setup '
cat >victim/.git/hooks/pre-receive <<'EOF'
#!/bin/sh
-printf "$@" >>$GIT_DIR/pre-receive.args
+printf %s "$@" >>$GIT_DIR/pre-receive.args
cat - >$GIT_DIR/pre-receive.stdin
echo STDOUT pre-receive
echo STDERR pre-receive >&2
@@ -35,7 +35,7 @@ chmod u+x victim/.git/hooks/pre-receive
cat >victim/.git/hooks/update <<'EOF'
#!/bin/sh
echo "$@" >>$GIT_DIR/update.args
-read x; printf "$x" >$GIT_DIR/update.stdin
+read x; printf %s "$x" >$GIT_DIR/update.stdin
echo STDOUT update $1
echo STDERR update $1 >&2
test "$1" = refs/heads/master || exit
@@ -44,7 +44,7 @@ chmod u+x victim/.git/hooks/update
cat >victim/.git/hooks/post-receive <<'EOF'
#!/bin/sh
-printf "$@" >>$GIT_DIR/post-receive.args
+printf %s "$@" >>$GIT_DIR/post-receive.args
cat - >$GIT_DIR/post-receive.stdin
echo STDOUT post-receive
echo STDERR post-receive >&2
@@ -54,14 +54,15 @@ chmod u+x victim/.git/hooks/post-receive
cat >victim/.git/hooks/post-update <<'EOF'
#!/bin/sh
echo "$@" >>$GIT_DIR/post-update.args
-read x; printf "$x" >$GIT_DIR/post-update.stdin
+read x; printf %s "$x" >$GIT_DIR/post-update.stdin
echo STDOUT post-update
echo STDERR post-update >&2
EOF
chmod u+x victim/.git/hooks/post-update
-test_expect_failure push '
- git-send-pack --force ./victim/.git master tofail >send.out 2>send.err
+test_expect_success push '
+ test_must_fail git-send-pack --force ./victim/.git \
+ master tofail >send.out 2>send.err
'
test_expect_success 'updated as expected' '
@@ -83,23 +84,23 @@ test_expect_success 'hooks ran' '
test_expect_success 'pre-receive hook input' '
(echo $commit0 $commit1 refs/heads/master;
echo $commit1 $commit0 refs/heads/tofail
- ) | git diff - victim/.git/pre-receive.stdin
+ ) | test_cmp - victim/.git/pre-receive.stdin
'
test_expect_success 'update hook arguments' '
(echo refs/heads/master $commit0 $commit1;
echo refs/heads/tofail $commit1 $commit0
- ) | git diff - victim/.git/update.args
+ ) | test_cmp - victim/.git/update.args
'
test_expect_success 'post-receive hook input' '
echo $commit0 $commit1 refs/heads/master |
- git diff - victim/.git/post-receive.stdin
+ test_cmp - victim/.git/post-receive.stdin
'
test_expect_success 'post-update hook arguments' '
echo refs/heads/master |
- git diff - victim/.git/post-update.args
+ test_cmp - victim/.git/post-update.args
'
test_expect_success 'all hook stdin is /dev/null' '
@@ -112,8 +113,8 @@ test_expect_success 'all *-receive hook args are empty' '
! test -s victim/.git/post-receive.args
'
-test_expect_failure 'send-pack produced no output' '
- test -s send.out
+test_expect_success 'send-pack produced no output' '
+ ! test -s send.out
'
cat <<EOF >expect
@@ -130,7 +131,7 @@ STDERR post-update
EOF
test_expect_success 'send-pack stderr contains hook messages' '
grep ^STD send.err >actual &&
- git diff - actual <expect
+ test_cmp - actual <expect
'
test_done
diff --git a/t/t5402-post-merge-hook.sh b/t/t5402-post-merge-hook.sh
index 1c4b0b32a..1394047a8 100755
--- a/t/t5402-post-merge-hook.sh
+++ b/t/t5402-post-merge-hook.sh
@@ -30,9 +30,9 @@ EOF
chmod u+x clone${clone}/.git/hooks/post-merge
done
-test_expect_failure 'post-merge does not run for up-to-date ' '
+test_expect_success 'post-merge does not run for up-to-date ' '
GIT_DIR=clone1/.git git merge $commit0 &&
- test -e clone1/.git/post-merge.args
+ ! test -f clone1/.git/post-merge.args
'
test_expect_success 'post-merge runs as expected ' '
diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh
index 1493a92c0..c24003565 100755
--- a/t/t5404-tracking-branches.sh
+++ b/t/t5404-tracking-branches.sh
@@ -10,6 +10,7 @@ test_expect_success 'setup' '
git commit -m 1 &&
git branch b1 &&
git branch b2 &&
+ git branch b3 &&
git clone . aa &&
git checkout b1 &&
echo b1 >>file &&
@@ -34,7 +35,9 @@ test_expect_success 'prepare pushable branches' '
git commit -a -m aa-master
'
-test_expect_success 'mixed-success push returns error' '! git push'
+test_expect_success 'mixed-success push returns error' '
+ test_must_fail git push
+'
test_expect_success 'check tracking branches updated correctly after push' '
test "$(git rev-parse origin/master)" = "$(git rev-parse master)"
@@ -50,4 +53,10 @@ test_expect_success 'deleted branches have their tracking branches removed' '
test "$(git rev-parse origin/b1)" = "origin/b1"
'
+test_expect_success 'already deleted tracking branches ignored' '
+ git branch -d -r origin/b3 &&
+ git push origin :b3 >output 2>&1 &&
+ ! grep error output
+'
+
test_done
diff --git a/t/t5406-remote-rejects.sh b/t/t5406-remote-rejects.sh
index 46b2cb4e4..59e80a5ea 100755
--- a/t/t5406-remote-rejects.sh
+++ b/t/t5406-remote-rejects.sh
@@ -17,7 +17,7 @@ test_expect_success 'setup' '
git commit -a -m 2
'
-test_expect_success 'push reports error' '! git push 2>stderr'
+test_expect_success 'push reports error' 'test_must_fail git push 2>stderr'
test_expect_success 'individual ref reports error' 'grep rejected stderr'
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 7b6798d8b..362cf7e92 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -31,7 +31,7 @@ add () {
sec=$(($sec+1))
commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \
git commit-tree $tree $parents 2>>log2.txt)
- export $name=$commit
+ eval "$name=$commit; export $name"
echo $commit > .git/refs/heads/$branch
eval ${branch}TIP=$commit
}
@@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3))
pull_to_client 3rd "A" $((1*3)) # old fails
-test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow"
+test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow'
(cd shallow; git count-objects -v) > count.shallow
@@ -176,7 +176,7 @@ test_expect_success "deepening fetch in shallow repo" \
test_expect_success "clone shallow object count" \
"test \"count: 18\" = \"$(grep count count.shallow)\""
-test_expect_failure "pull in shallow repo with missing merge base" \
- "(cd shallow; git pull --depth 4 .. A)"
+test_expect_success "pull in shallow repo with missing merge base" \
+ "(cd shallow && test_must_fail git pull --depth 4 .. A)"
test_done
diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh
new file mode 100755
index 000000000..4074e23ff
--- /dev/null
+++ b/t/t5503-tagfollow.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+
+test_description='test automatic tag following'
+
+. ./test-lib.sh
+
+# End state of the repository:
+#
+# T - tag1 S - tag2
+# / /
+# L - A ------ O ------ B
+# \ \ \
+# \ C - origin/cat \
+# origin/master master
+
+test_expect_success setup '
+ test_tick &&
+ echo ichi >file &&
+ git add file &&
+ git commit -m L &&
+ L=$(git rev-parse --verify HEAD) &&
+
+ (
+ mkdir cloned &&
+ cd cloned &&
+ git init-db &&
+ git remote add -f origin ..
+ ) &&
+
+ test_tick &&
+ echo A >file &&
+ git add file &&
+ git commit -m A &&
+ A=$(git rev-parse --verify HEAD)
+'
+
+U=UPLOAD_LOG
+
+cat - <<EOF >expect
+#S
+want $A
+#E
+EOF
+test_expect_success 'fetch A (new commit : 1 connection)' '
+ rm -f $U
+ (
+ cd cloned &&
+ GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ test $A = $(git rev-parse --verify origin/master)
+ ) &&
+ test -s $U &&
+ cut -d" " -f1,2 $U >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success "create tag T on A, create C on branch cat" '
+ git tag -a -m tag1 tag1 $A &&
+ T=$(git rev-parse --verify tag1) &&
+
+ git checkout -b cat &&
+ echo C >file &&
+ git add file &&
+ git commit -m C &&
+ C=$(git rev-parse --verify HEAD) &&
+ git checkout master
+'
+
+cat - <<EOF >expect
+#S
+want $C
+want $T
+#E
+EOF
+test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
+ rm -f $U
+ (
+ cd cloned &&
+ GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ test $C = $(git rev-parse --verify origin/cat) &&
+ test $T = $(git rev-parse --verify tag1) &&
+ test $A = $(git rev-parse --verify tag1^0)
+ ) &&
+ test -s $U &&
+ cut -d" " -f1,2 $U >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success "create commits O, B, tag S on B" '
+ test_tick &&
+ echo O >file &&
+ git add file &&
+ git commit -m O &&
+
+ test_tick &&
+ echo B >file &&
+ git add file &&
+ git commit -m B &&
+ B=$(git rev-parse --verify HEAD) &&
+
+ git tag -a -m tag2 tag2 $B &&
+ S=$(git rev-parse --verify tag2)
+'
+
+cat - <<EOF >expect
+#S
+want $B
+want $S
+#E
+EOF
+test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
+ rm -f $U
+ (
+ cd cloned &&
+ GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ test $B = $(git rev-parse --verify origin/master) &&
+ test $B = $(git rev-parse --verify tag2^0) &&
+ test $S = $(git rev-parse --verify tag2)
+ ) &&
+ test -s $U &&
+ cut -d" " -f1,2 $U >actual &&
+ test_cmp expect actual
+'
+
+cat - <<EOF >expect
+#S
+want $B
+want $S
+#E
+EOF
+test_expect_success 'new clone fetch master and tags' '
+ git branch -D cat
+ rm -f $U
+ (
+ mkdir clone2 &&
+ cd clone2 &&
+ git init &&
+ git remote add origin .. &&
+ GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ test $B = $(git rev-parse --verify origin/master) &&
+ test $S = $(git rev-parse --verify tag2) &&
+ test $B = $(git rev-parse --verify tag2^0) &&
+ test $T = $(git rev-parse --verify tag1) &&
+ test $A = $(git rev-parse --verify tag1^0)
+ ) &&
+ test -s $U &&
+ cut -d" " -f1,2 $U >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 636aec2f7..be9ee9326 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -4,19 +4,18 @@ test_description='git remote porcelain-ish'
. ./test-lib.sh
-GIT_CONFIG=.git/config
-export GIT_CONFIG
-
setup_repository () {
mkdir "$1" && (
cd "$1" &&
git init &&
>file &&
git add file &&
+ test_tick &&
git commit -m "Initial" &&
git checkout -b side &&
>elif &&
git add elif &&
+ test_tick &&
git commit -m "Second" &&
git checkout master
)
@@ -25,7 +24,7 @@ setup_repository () {
tokens_match () {
echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
- diff -u expect actual
+ test_cmp expect actual
}
check_remote_track () {
@@ -74,13 +73,24 @@ test_expect_success 'add another remote' '
sed -e "/^refs\/remotes\/origin\//d" \
-e "/^refs\/remotes\/second\//d" >actual &&
>expect &&
- diff -u expect actual
+ test_cmp expect actual
+)
+'
+
+test_expect_success 'remote forces tracking branches' '
+(
+ cd test &&
+ case `git config remote.second.fetch` in
+ +*) true ;;
+ *) false ;;
+ esac
)
'
test_expect_success 'remove remote' '
(
cd test &&
+ git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
git remote rm second
)
'
@@ -93,8 +103,225 @@ test_expect_success 'remove remote' '
git for-each-ref "--format=%(refname)" refs/remotes |
sed -e "/^refs\/remotes\/origin\//d" >actual &&
>expect &&
- diff -u expect actual
+ test_cmp expect actual
)
'
+cat > test/expect << EOF
+* remote origin
+ URL: $(pwd)/one/.git
+ Remote branch merged with 'git pull' while on branch master
+ master
+ New remote branch (next fetch will store in remotes/origin)
+ master
+ Tracked remote branches
+ side master
+ Local branches pushed with 'git push'
+ master:upstream +refs/tags/lastbackup
+EOF
+
+test_expect_success 'show' '
+ (cd test &&
+ git config --add remote.origin.fetch \
+ refs/heads/master:refs/heads/upstream &&
+ git fetch &&
+ git branch -d -r origin/master &&
+ (cd ../one &&
+ echo 1 > file &&
+ test_tick &&
+ git commit -m update file) &&
+ git config remote.origin.push \
+ refs/heads/master:refs/heads/upstream &&
+ git config --add remote.origin.push \
+ +refs/tags/lastbackup &&
+ git remote show origin > output &&
+ test_cmp expect output)
+'
+
+cat > test/expect << EOF
+* remote origin
+ URL: $(pwd)/one/.git
+ Remote branch merged with 'git pull' while on branch master
+ master
+ Tracked remote branches
+ master side
+ Local branches pushed with 'git push'
+ master:upstream +refs/tags/lastbackup
+EOF
+
+test_expect_success 'show -n' '
+ (mv one one.unreachable &&
+ cd test &&
+ git remote show -n origin > output &&
+ mv ../one.unreachable ../one &&
+ test_cmp expect output)
+'
+
+test_expect_success 'prune' '
+ (cd one &&
+ git branch -m side side2) &&
+ (cd test &&
+ git fetch origin &&
+ git remote prune origin &&
+ git rev-parse refs/remotes/origin/side2 &&
+ test_must_fail git rev-parse refs/remotes/origin/side)
+'
+
+cat > test/expect << EOF
+Pruning origin
+URL: $(pwd)/one/.git
+ * [would prune] origin/side2
+EOF
+
+test_expect_success 'prune --dry-run' '
+ (cd one &&
+ git branch -m side2 side) &&
+ (cd test &&
+ git remote prune --dry-run origin > output &&
+ git rev-parse refs/remotes/origin/side2 &&
+ test_must_fail git rev-parse refs/remotes/origin/side &&
+ (cd ../one &&
+ git branch -m side side2) &&
+ test_cmp expect output)
+'
+
+test_expect_success 'add --mirror && prune' '
+ (mkdir mirror &&
+ cd mirror &&
+ git init &&
+ git remote add --mirror -f origin ../one) &&
+ (cd one &&
+ git branch -m side2 side) &&
+ (cd mirror &&
+ git rev-parse --verify refs/heads/side2 &&
+ test_must_fail git rev-parse --verify refs/heads/side &&
+ git fetch origin &&
+ git remote prune origin &&
+ test_must_fail git rev-parse --verify refs/heads/side2 &&
+ git rev-parse --verify refs/heads/side)
+'
+
+test_expect_success 'add alt && prune' '
+ (mkdir alttst &&
+ cd alttst &&
+ git init &&
+ git remote add -f origin ../one &&
+ git config remote.alt.url ../one &&
+ git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
+ (cd one &&
+ git branch -m side side2) &&
+ (cd alttst &&
+ git rev-parse --verify refs/remotes/origin/side &&
+ test_must_fail git rev-parse --verify refs/remotes/origin/side2 &&
+ git fetch alt &&
+ git remote prune alt &&
+ test_must_fail git rev-parse --verify refs/remotes/origin/side &&
+ git rev-parse --verify refs/remotes/origin/side2)
+'
+
+cat > one/expect << EOF
+ apis/master
+ apis/side
+ drosophila/another
+ drosophila/master
+ drosophila/side
+EOF
+
+test_expect_success 'update' '
+
+ (cd one &&
+ git remote add drosophila ../two &&
+ git remote add apis ../mirror &&
+ git remote update &&
+ git branch -r > output &&
+ test_cmp expect output)
+
+'
+
+cat > one/expect << EOF
+ drosophila/another
+ drosophila/master
+ drosophila/side
+ manduca/master
+ manduca/side
+ megaloprepus/master
+ megaloprepus/side
+EOF
+
+test_expect_success 'update with arguments' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git remote add manduca ../mirror &&
+ git remote add megaloprepus ../mirror &&
+ git config remotes.phobaeticus "drosophila megaloprepus" &&
+ git config remotes.titanus manduca &&
+ git remote update phobaeticus titanus &&
+ git branch -r > output &&
+ test_cmp expect output)
+
+'
+
+cat > one/expect << EOF
+ apis/master
+ apis/side
+ manduca/master
+ manduca/side
+ megaloprepus/master
+ megaloprepus/side
+EOF
+
+test_expect_success 'update default' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git config remote.drosophila.skipDefaultUpdate true &&
+ git remote update default &&
+ git branch -r > output &&
+ test_cmp expect output)
+
+'
+
+cat > one/expect << EOF
+ drosophila/another
+ drosophila/master
+ drosophila/side
+EOF
+
+test_expect_success 'update default (overridden, with funny whitespace)' '
+
+ (cd one &&
+ for b in $(git branch -r)
+ do
+ git branch -r -d $b || break
+ done &&
+ git config remotes.default "$(printf "\t drosophila \n")" &&
+ git remote update default &&
+ git branch -r > output &&
+ test_cmp expect output)
+
+'
+
+test_expect_success '"remote show" does not show symbolic refs' '
+
+ git clone one three &&
+ (cd three &&
+ git remote show origin > output &&
+ ! grep HEAD < output &&
+ ! grep -i stale < output)
+
+'
+
+test_expect_success 'reject adding remote with an invalid name' '
+
+ test_must_fail git remote add some:url desired-name
+
+'
+
test_done
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 02882c1e4..13d1d826c 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -37,7 +37,8 @@ test_expect_success "clone and setup child repos" '
echo "Pull: refs/heads/one:refs/heads/one"
} >.git/remotes/two &&
cd .. &&
- git clone . bundle
+ git clone . bundle &&
+ git clone . seven
'
test_expect_success "fetch test" '
@@ -95,7 +96,7 @@ test_expect_success 'fetch following tags' '
'
-test_expect_failure 'fetch must not resolve short tag name' '
+test_expect_success 'fetch must not resolve short tag name' '
cd "$D" &&
@@ -103,11 +104,11 @@ test_expect_failure 'fetch must not resolve short tag name' '
cd five &&
git init &&
- git fetch .. anno:five
+ test_must_fail git fetch .. anno:five
'
-test_expect_failure 'fetch must not resolve short remote name' '
+test_expect_success 'fetch must not resolve short remote name' '
cd "$D" &&
git-update-ref refs/remotes/six/HEAD HEAD
@@ -116,7 +117,7 @@ test_expect_failure 'fetch must not resolve short remote name' '
cd six &&
git init &&
- git fetch .. six:six
+ test_must_fail git fetch .. six:six
'
@@ -139,10 +140,10 @@ test_expect_success 'create bundle 2' '
git bundle create bundle2 master~2..master
'
-test_expect_failure 'unbundle 1' '
+test_expect_success 'unbundle 1' '
cd "$D/bundle" &&
git checkout -b some-branch &&
- git fetch "$D/bundle1" master:master
+ test_must_fail git fetch "$D/bundle1" master:master
'
test_expect_success 'bundle 1 has only 3 files ' '
@@ -235,7 +236,7 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '
# the strange name is: a\!'b
test_expect_success 'quoting of a strangely named repo' '
- ! git fetch "a\\!'\''b" > result 2>&1 &&
+ test_must_fail git fetch "a\\!'\''b" > result 2>&1 &&
cat result &&
grep "fatal: '\''a\\\\!'\''b'\''" result
'
@@ -249,7 +250,7 @@ test_expect_success 'bundle should record HEAD correctly' '
do
echo "$(git rev-parse --verify $h) $h"
done >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -263,7 +264,7 @@ test_expect_success 'explicit fetch should not update tracking' '
git fetch origin master &&
n=$(git rev-parse --verify refs/remotes/origin/master) &&
test "$o" = "$n" &&
- ! git rev-parse --verify refs/remotes/origin/side
+ test_must_fail git rev-parse --verify refs/remotes/origin/side
)
'
@@ -277,7 +278,7 @@ test_expect_success 'explicit pull should not update tracking' '
git pull origin master &&
n=$(git rev-parse --verify refs/remotes/origin/master) &&
test "$o" = "$n" &&
- ! git rev-parse --verify refs/remotes/origin/side
+ test_must_fail git rev-parse --verify refs/remotes/origin/side
)
'
@@ -295,4 +296,11 @@ test_expect_success 'configured fetch updates tracking' '
)
'
+test_expect_success 'pushing nonexistent branch by mistake should not segv' '
+
+ cd "$D" &&
+ test_must_fail git push seven no:no
+
+'
+
test_done
diff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh
new file mode 100755
index 000000000..22ba38003
--- /dev/null
+++ b/t/t5511-refspec.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+test_description='refspec parsing'
+
+. ./test-lib.sh
+
+test_refspec () {
+
+ kind=$1 refspec=$2 expect=$3
+ git config remote.frotz.url "." &&
+ git config --remove-section remote.frotz &&
+ git config remote.frotz.url "." &&
+ git config "remote.frotz.$kind" "$refspec" &&
+ if test "$expect" != invalid
+ then
+ title="$kind $refspec"
+ test='git ls-remote frotz'
+ else
+ title="$kind $refspec (invalid)"
+ test='test_must_fail git ls-remote frotz'
+ fi
+ test_expect_success "$title" "$test"
+}
+
+test_refspec push '' invalid
+test_refspec push ':'
+test_refspec push '::' invalid
+test_refspec push '+:'
+
+test_refspec fetch ''
+test_refspec fetch ':'
+test_refspec fetch '::' invalid
+
+test_refspec push 'refs/heads/*:refs/remotes/frotz/*'
+test_refspec push 'refs/heads/*:refs/remotes/frotz' invalid
+test_refspec push 'refs/heads:refs/remotes/frotz/*' invalid
+test_refspec push 'refs/heads/master:refs/remotes/frotz/xyzzy'
+
+
+# These have invalid LHS, but we do not have a formal "valid sha-1
+# expression syntax checker" so they are not checked with the current
+# code. They will be caught downstream anyway, but we may want to
+# have tighter check later...
+
+: test_refspec push 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid
+: test_refspec push 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
+
+test_refspec fetch 'refs/heads/*:refs/remotes/frotz/*'
+test_refspec fetch 'refs/heads/*:refs/remotes/frotz' invalid
+test_refspec fetch 'refs/heads:refs/remotes/frotz/*' invalid
+test_refspec fetch 'refs/heads/master:refs/remotes/frotz/xyzzy'
+test_refspec fetch 'refs/heads/master::refs/remotes/frotz/xyzzy' invalid
+test_refspec fetch 'refs/heads/maste :refs/remotes/frotz/xyzzy' invalid
+
+test_refspec push 'master~1:refs/remotes/frotz/backup'
+test_refspec fetch 'master~1:refs/remotes/frotz/backup' invalid
+test_refspec push 'HEAD~4:refs/remotes/frotz/new'
+test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid
+
+test_refspec push 'HEAD'
+test_refspec fetch 'HEAD'
+test_refspec push 'refs/heads/ nitfol' invalid
+test_refspec fetch 'refs/heads/ nitfol' invalid
+
+test_refspec push 'HEAD:' invalid
+test_refspec fetch 'HEAD:'
+test_refspec push 'refs/heads/ nitfol:' invalid
+test_refspec fetch 'refs/heads/ nitfol:' invalid
+
+test_refspec push ':refs/remotes/frotz/deleteme'
+test_refspec fetch ':refs/remotes/frotz/HEAD-to-me'
+test_refspec push ':refs/remotes/frotz/delete me' invalid
+test_refspec fetch ':refs/remotes/frotz/HEAD to me' invalid
+
+test_done
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 6ec5f7c48..1dd8eed5b 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -17,35 +17,35 @@ test_expect_success setup '
git show-ref -d | sed -e "s/ / /"
) >expected.all &&
- git remote add self $(pwd)/.git
+ git remote add self "$(pwd)/.git"
'
test_expect_success 'ls-remote --tags .git' '
git ls-remote --tags .git >actual &&
- diff -u expected.tag actual
+ test_cmp expected.tag actual
'
test_expect_success 'ls-remote .git' '
git ls-remote .git >actual &&
- diff -u expected.all actual
+ test_cmp expected.all actual
'
test_expect_success 'ls-remote --tags self' '
git ls-remote --tags self >actual &&
- diff -u expected.tag actual
+ test_cmp expected.tag actual
'
test_expect_success 'ls-remote self' '
git ls-remote self >actual &&
- diff -u expected.all actual
+ test_cmp expected.all actual
'
diff --git a/t/t5513-fetch-track.sh b/t/t5513-fetch-track.sh
new file mode 100755
index 000000000..9e7486274
--- /dev/null
+++ b/t/t5513-fetch-track.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+test_description='fetch follows remote tracking branches correctly'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ >file &&
+ git add . &&
+ test_tick &&
+ git commit -m Initial &&
+ git branch b-0 &&
+ git branch b1 &&
+ git branch b/one &&
+ test_create_repo other &&
+ (
+ cd other &&
+ git config remote.origin.url .. &&
+ git config remote.origin.fetch "+refs/heads/b/*:refs/remotes/b/*"
+ )
+'
+
+test_expect_success fetch '
+ (
+ cd other && git fetch origin &&
+ test "$(git for-each-ref --format="%(refname)")" = refs/remotes/b/one
+ )
+'
+
+test_done
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 31c108161..8becbc3f3 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -131,8 +131,10 @@ do
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
cnt=`expr $test_count + 1`
pfx=`printf "%04d" $cnt`
- expect="../../t5515/fetch.$test"
- actual="$pfx-fetch.$test"
+ expect_f="../../t5515/fetch.$test"
+ actual_f="$pfx-fetch.$test"
+ expect_r="../../t5515/refs.$test"
+ actual_r="$pfx-refs.$test"
test_expect_success "$cmd" '
{
@@ -140,19 +142,32 @@ do
set x $cmd; shift
git symbolic-ref HEAD refs/heads/$1 ; shift
rm -f .git/FETCH_HEAD
- rm -f .git/refs/heads/*
- rm -f .git/refs/remotes/rem/*
- rm -f .git/refs/tags/*
+ git for-each-ref \
+ refs/heads refs/remotes/rem refs/tags |
+ while read val type refname
+ do
+ git update-ref -d "$refname" "$val"
+ done
git fetch "$@" >/dev/null
cat .git/FETCH_HEAD
- } >"$actual" &&
- if test -f "$expect"
+ } >"$actual_f" &&
+ git show-ref >"$actual_r" &&
+ if test -f "$expect_f"
then
- git diff -u "$expect" "$actual" &&
- rm -f "$actual"
+ test_cmp "$expect_f" "$actual_f" &&
+ rm -f "$actual_f"
else
# this is to help developing new tests.
- cp "$actual" "$expect"
+ cp "$actual_f" "$expect_f"
+ false
+ fi &&
+ if test -f "$expect_r"
+ then
+ test_cmp "$expect_r" "$actual_r" &&
+ rm -f "$actual_r"
+ else
+ # this is to help developing new tests.
+ cp "$actual_r" "$expect_r"
false
fi
'
diff --git a/t/t5515/refs.br-branches-default b/t/t5515/refs.br-branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-default-merge b/t/t5515/refs.br-branches-default-merge
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default-merge
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-default-merge_branches-default b/t/t5515/refs.br-branches-default-merge_branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default-merge_branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-default-octopus b/t/t5515/refs.br-branches-default-octopus
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default-octopus
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-default-octopus_branches-default b/t/t5515/refs.br-branches-default-octopus_branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default-octopus_branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-default_branches-default b/t/t5515/refs.br-branches-default_branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-branches-default_branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one b/t/t5515/refs.br-branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one-merge b/t/t5515/refs.br-branches-one-merge
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one-merge
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one-merge_branches-one b/t/t5515/refs.br-branches-one-merge_branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one-merge_branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one-octopus b/t/t5515/refs.br-branches-one-octopus
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one-octopus
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one-octopus_branches-one b/t/t5515/refs.br-branches-one-octopus_branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one-octopus_branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-branches-one_branches-one b/t/t5515/refs.br-branches-one_branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-branches-one_branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit b/t/t5515/refs.br-config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit-merge b/t/t5515/refs.br-config-explicit-merge
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit-merge
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit-merge_config-explicit b/t/t5515/refs.br-config-explicit-merge_config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit-merge_config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit-octopus b/t/t5515/refs.br-config-explicit-octopus
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit-octopus
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit-octopus_config-explicit b/t/t5515/refs.br-config-explicit-octopus_config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit-octopus_config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-explicit_config-explicit b/t/t5515/refs.br-config-explicit_config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-explicit_config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob b/t/t5515/refs.br-config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob-merge b/t/t5515/refs.br-config-glob-merge
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob-merge
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob-merge_config-glob b/t/t5515/refs.br-config-glob-merge_config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob-merge_config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob-octopus b/t/t5515/refs.br-config-glob-octopus
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob-octopus
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob-octopus_config-glob b/t/t5515/refs.br-config-glob-octopus_config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob-octopus_config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-config-glob_config-glob b/t/t5515/refs.br-config-glob_config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-config-glob_config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit b/t/t5515/refs.br-remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit-merge b/t/t5515/refs.br-remote-explicit-merge
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit-merge
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit-merge_remote-explicit b/t/t5515/refs.br-remote-explicit-merge_remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit-merge_remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit-octopus b/t/t5515/refs.br-remote-explicit-octopus
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit-octopus
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit-octopus_remote-explicit b/t/t5515/refs.br-remote-explicit-octopus_remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit-octopus_remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-explicit_remote-explicit b/t/t5515/refs.br-remote-explicit_remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-explicit_remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob b/t/t5515/refs.br-remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob-merge b/t/t5515/refs.br-remote-glob-merge
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob-merge
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob-merge_remote-glob b/t/t5515/refs.br-remote-glob-merge_remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob-merge_remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob-octopus b/t/t5515/refs.br-remote-glob-octopus
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob-octopus
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob-octopus_remote-glob b/t/t5515/refs.br-remote-glob-octopus_remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob-octopus_remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-remote-glob_remote-glob b/t/t5515/refs.br-remote-glob_remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-remote-glob_remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig b/t/t5515/refs.br-unconfig
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.br-unconfig
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_--tags_.._.git b/t/t5515/refs.br-unconfig_--tags_.._.git
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_--tags_.._.git
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_.._.git b/t/t5515/refs.br-unconfig_.._.git
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.br-unconfig_.._.git_one b/t/t5515/refs.br-unconfig_.._.git_one
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git_one
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file b/t/t5515/refs.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git_one_tag_tag-one_tag_tag-three-file
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_.._.git_one_two b/t/t5515/refs.br-unconfig_.._.git_one_two
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git_one_two
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file b/t/t5515/refs.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git_tag_tag-one-tree_tag_tag-three-file
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_.._.git_tag_tag-one_tag_tag-three b/t/t5515/refs.br-unconfig_.._.git_tag_tag-one_tag_tag-three
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_.._.git_tag_tag-one_tag_tag-three
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_branches-default b/t/t5515/refs.br-unconfig_branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_branches-one b/t/t5515/refs.br-unconfig_branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_config-explicit b/t/t5515/refs.br-unconfig_config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_config-glob b/t/t5515/refs.br-unconfig_config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_remote-explicit b/t/t5515/refs.br-unconfig_remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.br-unconfig_remote-glob b/t/t5515/refs.br-unconfig_remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.br-unconfig_remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master b/t/t5515/refs.master
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.master
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_--tags_.._.git b/t/t5515/refs.master_--tags_.._.git
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.master_--tags_.._.git
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_.._.git b/t/t5515/refs.master_.._.git
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.master_.._.git
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.master_.._.git_one b/t/t5515/refs.master_.._.git_one
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.master_.._.git_one
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.master_.._.git_one_tag_tag-one_tag_tag-three-file b/t/t5515/refs.master_.._.git_one_tag_tag-one_tag_tag-three-file
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.master_.._.git_one_tag_tag-one_tag_tag-three-file
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_.._.git_one_two b/t/t5515/refs.master_.._.git_one_two
new file mode 100644
index 000000000..70962eaac
--- /dev/null
+++ b/t/t5515/refs.master_.._.git_one_two
@@ -0,0 +1,5 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
diff --git a/t/t5515/refs.master_.._.git_tag_tag-one-tree_tag_tag-three-file b/t/t5515/refs.master_.._.git_tag_tag-one-tree_tag_tag-three-file
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.master_.._.git_tag_tag-one-tree_tag_tag-three-file
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_.._.git_tag_tag-one_tag_tag-three b/t/t5515/refs.master_.._.git_tag_tag-one_tag_tag-three
new file mode 100644
index 000000000..13e4ad2e4
--- /dev/null
+++ b/t/t5515/refs.master_.._.git_tag_tag-one_tag_tag-three
@@ -0,0 +1,11 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_branches-default b/t/t5515/refs.master_branches-default
new file mode 100644
index 000000000..21917c1e5
--- /dev/null
+++ b/t/t5515/refs.master_branches-default
@@ -0,0 +1,12 @@
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/heads/branches-default
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_branches-one b/t/t5515/refs.master_branches-one
new file mode 100644
index 000000000..8a705a5df
--- /dev/null
+++ b/t/t5515/refs.master_branches-one
@@ -0,0 +1,12 @@
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/heads/branches-one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_config-explicit b/t/t5515/refs.master_config-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.master_config-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_config-glob b/t/t5515/refs.master_config-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.master_config-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_remote-explicit b/t/t5515/refs.master_remote-explicit
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.master_remote-explicit
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5515/refs.master_remote-glob b/t/t5515/refs.master_remote-glob
new file mode 100644
index 000000000..9bbbfd9fc
--- /dev/null
+++ b/t/t5515/refs.master_remote-glob
@@ -0,0 +1,15 @@
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/HEAD
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/origin/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/origin/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/origin/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/origin/two
+754b754407bf032e9a2f9d5a9ad05ca79a6b228f refs/remotes/rem/master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/remotes/rem/one
+0567da4d5edd2ff4bb292a465ba9e64dcad9536b refs/remotes/rem/three
+6134ee8f857693b96ff1cc98d3e2fd62b199e5a8 refs/remotes/rem/two
+6c9dec2b923228c9ff994c6cfe4ae16c12408dc5 refs/tags/tag-master
+8e32a6d901327a23ef831511badce7bf3bf46689 refs/tags/tag-one
+22feea448b023a2d864ef94b013735af34d238ba refs/tags/tag-one-tree
+c61a82b60967180544e3c19f819ddbd0c9f89899 refs/tags/tag-three
+0e3b14047d3ee365f4f2a1b673db059c3972589c refs/tags/tag-three-file
+525b7fb068d59950d185a8779dc957c77eed73ba refs/tags/tag-two
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 9d2dc33cb..f0030ad00 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -100,6 +100,23 @@ test_expect_success 'fetch with wildcard' '
)
'
+test_expect_success 'fetch with insteadOf' '
+ mk_empty &&
+ (
+ TRASH=$(pwd)/ &&
+ cd testrepo &&
+ git config "url.$TRASH.insteadOf" trash/ &&
+ git config remote.up.url trash/. &&
+ git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
+ git fetch up &&
+
+ r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+ test "z$r" = "z$the_commit" &&
+
+ test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+ )
+'
+
test_expect_success 'push without wildcard' '
mk_empty &&
@@ -126,6 +143,20 @@ test_expect_success 'push with wildcard' '
)
'
+test_expect_success 'push with insteadOf' '
+ mk_empty &&
+ TRASH="$(pwd)/" &&
+ git config "url.$TRASH.insteadOf" trash/ &&
+ git push trash/testrepo refs/heads/master:refs/remotes/origin/master &&
+ (
+ cd testrepo &&
+ r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+ test "z$r" = "z$the_commit" &&
+
+ test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+ )
+'
+
test_expect_success 'push with matching heads' '
mk_test heads/master &&
@@ -134,6 +165,47 @@ test_expect_success 'push with matching heads' '
'
+test_expect_success 'push with matching heads on the command line' '
+
+ mk_test heads/master &&
+ git push testrepo : &&
+ check_push_result $the_commit heads/master
+
+'
+
+test_expect_success 'failed (non-fast-forward) push with matching heads' '
+
+ mk_test heads/master &&
+ git push testrepo : &&
+ git commit --amend -massaged &&
+ test_must_fail git push testrepo &&
+ check_push_result $the_commit heads/master &&
+ git reset --hard $the_commit
+
+'
+
+test_expect_success 'push --force with matching heads' '
+
+ mk_test heads/master &&
+ git push testrepo : &&
+ git commit --amend -massaged &&
+ git push --force testrepo &&
+ ! check_push_result $the_commit heads/master &&
+ git reset --hard $the_commit
+
+'
+
+test_expect_success 'push with matching heads and forced update' '
+
+ mk_test heads/master &&
+ git push testrepo : &&
+ git commit --amend -massaged &&
+ git push testrepo +: &&
+ ! check_push_result $the_commit heads/master &&
+ git reset --hard $the_commit
+
+'
+
test_expect_success 'push with no ambiguity (1)' '
mk_test heads/master &&
@@ -178,19 +250,7 @@ test_expect_success 'push with weak ambiguity (2)' '
'
-test_expect_success 'push with ambiguity (1)' '
-
- mk_test remotes/origin/master remotes/frotz/master &&
- if git push testrepo master:master
- then
- echo "Oops, should have failed"
- false
- else
- check_push_result $the_first_commit remotes/origin/master remotes/frotz/master
- fi
-'
-
-test_expect_success 'push with ambiguity (2)' '
+test_expect_success 'push with ambiguity' '
mk_test heads/frotz tags/frotz &&
if git push testrepo master:frotz
@@ -254,6 +314,37 @@ test_expect_success 'push with colon-less refspec (4)' '
'
+test_expect_success 'push head with non-existant, incomplete dest' '
+
+ mk_test &&
+ git push testrepo master:branch &&
+ check_push_result $the_commit heads/branch
+
+'
+
+test_expect_success 'push tag with non-existant, incomplete dest' '
+
+ mk_test &&
+ git tag -f v1.0 &&
+ git push testrepo v1.0:tag &&
+ check_push_result $the_commit tags/tag
+
+'
+
+test_expect_success 'push sha1 with non-existant, incomplete dest' '
+
+ mk_test &&
+ test_must_fail git push testrepo `git rev-parse master`:foo
+
+'
+
+test_expect_success 'push ref expression with non-existant, incomplete dest' '
+
+ mk_test &&
+ test_must_fail git push testrepo master^:branch
+
+'
+
test_expect_success 'push with HEAD' '
mk_test heads/master &&
@@ -271,6 +362,58 @@ test_expect_success 'push with HEAD nonexisting at remote' '
check_push_result $the_commit heads/local
'
+test_expect_success 'push with +HEAD' '
+
+ mk_test heads/master &&
+ git checkout master &&
+ git branch -D local &&
+ git checkout -b local &&
+ git push testrepo master local &&
+ check_push_result $the_commit heads/master &&
+ check_push_result $the_commit heads/local &&
+
+ # Without force rewinding should fail
+ git reset --hard HEAD^ &&
+ test_must_fail git push testrepo HEAD &&
+ check_push_result $the_commit heads/local &&
+
+ # With force rewinding should succeed
+ git push testrepo +HEAD &&
+ check_push_result $the_first_commit heads/local
+
+'
+
+test_expect_success 'push HEAD with non-existant, incomplete dest' '
+
+ mk_test &&
+ git checkout master &&
+ git push testrepo HEAD:branch &&
+ check_push_result $the_commit heads/branch
+
+'
+
+test_expect_success 'push with config remote.*.push = HEAD' '
+
+ mk_test heads/local &&
+ git checkout master &&
+ git branch -f local $the_commit &&
+ (
+ cd testrepo &&
+ git checkout local &&
+ git reset --hard $the_first_commit
+ ) &&
+ git config remote.there.url testrepo &&
+ git config remote.there.push HEAD &&
+ git config branch.master.remote there &&
+ git push &&
+ check_push_result $the_commit heads/master &&
+ check_push_result $the_first_commit heads/local
+'
+
+# clean up the cruft left with the previous one
+git config --remove-section remote.there
+git config --remove-section branch.master
+
test_expect_success 'push with dry-run' '
mk_test heads/master &&
@@ -305,7 +448,7 @@ test_expect_success 'push does not update local refs on failure' '
git clone parent child &&
(cd child &&
echo two >foo && git commit -a -m two &&
- ! git push &&
+ test_must_fail git push &&
test $(git rev-parse master) != \
$(git rev-parse remotes/origin/master))
@@ -316,7 +459,7 @@ test_expect_success 'allow deleting an invalid remote ref' '
pwd &&
rm -f testrepo/.git/objects/??/* &&
git push testrepo :refs/heads/master &&
- (cd testrepo && ! git rev-parse --verify refs/heads/master)
+ (cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)
'
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
index ed3fec192..ea49dedbf 100755
--- a/t/t5517-push-mirror.sh
+++ b/t/t5517-push-mirror.sh
@@ -25,7 +25,7 @@ mk_repo_pair () {
(
cd master &&
git init &&
- git config remote.up.url ../mirror
+ git remote add $1 up ../mirror
)
}
@@ -225,4 +225,43 @@ test_expect_success 'push mirror adds, updates and removes tags together' '
'
+test_expect_success 'remote.foo.mirror adds and removes branches' '
+
+ mk_repo_pair --mirror &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch keep master &&
+ git branch remove master &&
+ git push up &&
+ git branch -D remove
+ git push up
+ ) &&
+ (
+ cd mirror &&
+ git show-ref -s --verify refs/heads/keep &&
+ invert git show-ref -s --verify refs/heads/remove
+ )
+
+'
+
+test_expect_success 'remote.foo.mirror=no has no effect' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git config --add remote.up.mirror no &&
+ git branch keep master &&
+ git push --mirror up &&
+ git branch -D keep &&
+ git push up
+ ) &&
+ (
+ cd mirror &&
+ git show-ref -s --verify refs/heads/keep
+ )
+
+'
+
test_done
diff --git a/t/t5518-fetch-exit-status.sh b/t/t5518-fetch-exit-status.sh
new file mode 100755
index 000000000..c6bc65faa
--- /dev/null
+++ b/t/t5518-fetch-exit-status.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Dmitry V. Levin
+#
+
+test_description='fetch exit status test'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ >file &&
+ git add file &&
+ git commit -m initial &&
+
+ git checkout -b side &&
+ echo side >file &&
+ git commit -a -m side &&
+
+ git checkout master &&
+ echo next >file &&
+ git commit -a -m next
+'
+
+test_expect_success 'non fast forward fetch' '
+
+ test_must_fail git fetch . master:side
+
+'
+
+test_expect_success 'forced update' '
+
+ git fetch . +master:side
+
+'
+
+test_done
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 52b3a0c6d..997b2db82 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -71,8 +71,43 @@ test_expect_success 'branch.to-rebase.rebase' '
git reset --hard before-rebase &&
git config branch.to-rebase.rebase 1 &&
git pull . copy &&
+ git config branch.to-rebase.rebase 0 &&
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
'
+test_expect_success '--rebase with rebased upstream' '
+
+ git remote add -f me . &&
+ git checkout copy &&
+ git reset --hard HEAD^ &&
+ echo conflicting modification > file &&
+ git commit -m conflict file &&
+ git checkout to-rebase &&
+ echo file > file2 &&
+ git commit -m to-rebase file2 &&
+ git pull --rebase me copy &&
+ test "conflicting modification" = "$(cat file)" &&
+ test file = $(cat file2)
+
+'
+
+test_expect_success 'pull --rebase dies early with dirty working directory' '
+
+ git update-ref refs/remotes/me/copy copy^ &&
+ COPY=$(git rev-parse --verify me/copy) &&
+ git rebase --onto $COPY copy &&
+ git config branch.to-rebase.remote me &&
+ git config branch.to-rebase.merge refs/heads/copy &&
+ git config branch.to-rebase.rebase true &&
+ echo dirty >> file &&
+ git add file &&
+ test_must_fail git pull &&
+ test $COPY = $(git rev-parse --verify me/copy) &&
+ git checkout HEAD -- file &&
+ git pull &&
+ test $COPY != $(git rev-parse --verify me/copy)
+
+'
+
test_done
diff --git a/t/t5530-upload-pack-error.sh b/t/t5530-upload-pack-error.sh
index cc8949e3e..1a15817cd 100755
--- a/t/t5530-upload-pack-error.sh
+++ b/t/t5530-upload-pack-error.sh
@@ -26,9 +26,8 @@ test_expect_success 'setup and corrupt repository' '
'
-test_expect_failure 'fsck fails' '
-
- git fsck
+test_expect_success 'fsck fails' '
+ test_must_fail git fsck
'
test_expect_success 'upload-pack fails due to error in pack-objects' '
@@ -46,9 +45,8 @@ test_expect_success 'corrupt repo differently' '
'
-test_expect_failure 'fsck fails' '
-
- git fsck
+test_expect_success 'fsck fails' '
+ test_must_fail git fsck
'
test_expect_success 'upload-pack fails due to error in rev-list' '
@@ -66,9 +64,9 @@ test_expect_success 'create empty repository' '
'
-test_expect_failure 'fetch fails' '
+test_expect_success 'fetch fails' '
- git fetch .. master
+ test_must_fail git fetch .. master
'
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
new file mode 100755
index 000000000..b0d242e3e
--- /dev/null
+++ b/t/t5540-http-push.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
+#
+
+test_description='test http-push
+
+This test runs various sanity checks on http-push.'
+
+. ./test-lib.sh
+
+ROOT_PATH="$PWD"
+LIB_HTTPD_DAV=t
+
+if git http-push > /dev/null 2>&1 || [ $? -eq 128 ]
+then
+ say "skipping test, USE_CURL_MULTI is not defined"
+ test_done
+ exit
+fi
+
+. ../lib-httpd.sh
+
+if ! start_httpd >&3 2>&4
+then
+ say "skipping test, web server setup failed"
+ test_done
+ exit
+fi
+
+test_expect_success 'setup remote repository' '
+ cd "$ROOT_PATH" &&
+ mkdir test_repo &&
+ cd test_repo &&
+ git init &&
+ : >path1 &&
+ git add path1 &&
+ test_tick &&
+ git commit -m initial &&
+ cd - &&
+ git clone --bare test_repo test_repo.git &&
+ cd test_repo.git &&
+ git --bare update-server-info &&
+ mv hooks/post-update.sample hooks/post-update &&
+ cd - &&
+ mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
+'
+
+test_expect_success 'clone remote repository' '
+ cd "$ROOT_PATH" &&
+ git clone $HTTPD_URL/test_repo.git test_repo_clone
+'
+
+test_expect_failure 'push to remote repository' '
+ cd "$ROOT_PATH"/test_repo_clone &&
+ : >path2 &&
+ git add path2 &&
+ test_tick &&
+ git commit -m path2 &&
+ git push &&
+ [ -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/refs/heads/master" ]
+'
+
+test_expect_failure 'create and delete remote branch' '
+ cd "$ROOT_PATH"/test_repo_clone &&
+ git checkout -b dev &&
+ : >path3 &&
+ git add path3 &&
+ test_tick &&
+ git commit -m dev &&
+ git push origin dev &&
+ git fetch &&
+ git push origin :dev &&
+ git branch -d -r origin/dev &&
+ git fetch &&
+ test_must_fail git show-ref --verify refs/remotes/origin/dev
+'
+
+stop_httpd
+
+test_done
diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh
index 1776b377f..3c013e2b6 100755
--- a/t/t5600-clone-fail-cleanup.sh
+++ b/t/t5600-clone-fail-cleanup.sh
@@ -11,13 +11,13 @@ remove the directory before attempting a clone again.'
. ./test-lib.sh
-test_expect_failure \
+test_expect_success \
'clone of non-existent source should fail' \
- 'git-clone foo bar'
+ 'test_must_fail git-clone foo bar'
-test_expect_failure \
+test_expect_success \
'failed clone should not leave a directory' \
- 'cd bar'
+ '! test -d bar'
# Need a repo to clone
test_create_repo foo
@@ -27,9 +27,9 @@ test_create_repo foo
# source repository given to git-clone should be relative to the
# current path not to the target dir
-test_expect_failure \
+test_expect_success \
'clone of non-existent (relative to $PWD) source should fail' \
- 'git-clone ../foo baz'
+ 'test_must_fail git-clone ../foo baz'
test_expect_success \
'clone should work now that source exists' \
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
new file mode 100755
index 000000000..59c65fef2
--- /dev/null
+++ b/t/t5601-clone.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+
+test_description=clone
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ rm -fr .git &&
+ test_create_repo src &&
+ (
+ cd src
+ >file
+ git add file
+ git commit -m initial
+ )
+
+'
+
+test_expect_success 'clone with excess parameters (1)' '
+
+ rm -fr dst &&
+ test_must_fail git clone -n src dst junk
+
+'
+
+test_expect_success 'clone with excess parameters (2)' '
+
+ rm -fr dst &&
+ test_must_fail git clone -n "file://$(pwd)/src" dst junk
+
+'
+
+test_expect_success 'output from clone' '
+ rm -fr dst &&
+ git clone -n "file://$(pwd)/src" dst >output &&
+ test $(grep Initialized output | wc -l) = 1
+'
+
+test_expect_success 'clone does not keep pack' '
+
+ rm -fr dst &&
+ git clone -n "file://$(pwd)/src" dst &&
+ ! test -f dst/file &&
+ ! (echo dst/.git/objects/pack/pack-* | grep "\.keep")
+
+'
+
+test_expect_success 'clone checks out files' '
+
+ rm -fr dst &&
+ git clone src dst &&
+ test -f dst/file
+
+'
+
+test_expect_success 'clone respects GIT_WORK_TREE' '
+
+ GIT_WORK_TREE=worktree git clone src bare &&
+ test -f bare/config &&
+ test -f worktree/file
+
+'
+
+test_expect_success 'clone creates intermediate directories' '
+
+ git clone src long/path/to/dst &&
+ test -f long/path/to/dst/file
+
+'
+
+test_expect_success 'clone creates intermediate directories for bare repo' '
+
+ git clone --bare src long/path/to/bare/dst &&
+ test -f long/path/to/bare/dst/config
+
+'
+
+test_expect_success 'clone --mirror' '
+
+ git clone --mirror src mirror &&
+ test -f mirror/HEAD &&
+ test ! -f mirror/file &&
+ FETCH="$(cd mirror && git config remote.origin.fetch)" &&
+ test "+refs/*:refs/*" = "$FETCH" &&
+ MIRROR="$(cd mirror && git config --bool remote.origin.mirror)" &&
+ test "$MIRROR" = true
+
+'
+
+test_expect_success 'clone --bare names the local repository <name>.git' '
+
+ git clone --bare src &&
+ test -d src.git
+
+'
+
+test_expect_success 'clone --mirror does not repeat tags' '
+
+ (cd src &&
+ git tag some-tag HEAD) &&
+ git clone --mirror src mirror2 &&
+ (cd mirror2 &&
+ git show-ref 2> clone.err > clone.out) &&
+ test_must_fail grep Duplicate mirror2/clone.err &&
+ grep some-tag mirror2/clone.out
+
+'
+
+test_done
diff --git a/t/t5602-clone-remote-exec.sh b/t/t5602-clone-remote-exec.sh
new file mode 100755
index 000000000..8367a6845
--- /dev/null
+++ b/t/t5602-clone-remote-exec.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+test_description=clone
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo "#!/bin/sh" > not_ssh
+ echo "echo \"\$*\" > not_ssh_output" >> not_ssh
+ echo "exit 1" >> not_ssh
+ chmod +x not_ssh
+'
+
+test_expect_success 'clone calls git-upload-pack unqualified with no -u option' '
+ GIT_SSH=./not_ssh git clone localhost:/path/to/repo junk
+ echo "localhost git-upload-pack '\''/path/to/repo'\''" >expected
+ test_cmp expected not_ssh_output
+'
+
+test_expect_success 'clone calls specified git-upload-pack with -u option' '
+ GIT_SSH=./not_ssh git clone -u /something/bin/git-upload-pack localhost:/path/to/repo junk
+ echo "localhost /something/bin/git-upload-pack '\''/path/to/repo'\''" >expected
+ test_cmp expected not_ssh_output
+'
+
+test_done
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index b6a54867b..1c1091606 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -8,6 +8,8 @@ test_description='test clone --reference'
base_dir=`pwd`
+U=$base_dir/UPLOAD_LOG
+
test_expect_success 'preparing first repository' \
'test_create_repo A && cd A &&
echo first > file1 &&
@@ -50,8 +52,13 @@ diff expected current'
cd "$base_dir"
+rm -f "$U"
+
test_expect_success 'cloning with reference (no -l -s)' \
-'git clone --reference B file://`pwd`/A D'
+'GIT_DEBUG_SEND_PACK=3 git clone --reference B "file://$(pwd)/A" D 3>"$U"'
+
+test_expect_success 'fetched no objects' \
+'! grep "^want" "$U"'
cd "$base_dir"
@@ -113,4 +120,30 @@ diff expected current'
cd "$base_dir"
+test_expect_success 'preparing alternate repository #1' \
+'test_create_repo F && cd F &&
+echo first > file1 &&
+git add file1 &&
+git commit -m initial'
+
+cd "$base_dir"
+
+test_expect_success 'cloning alternate repo #2 and adding changes to repo #1' \
+'git clone F G && cd F &&
+echo second > file2 &&
+git add file2 &&
+git commit -m addition'
+
+cd "$base_dir"
+
+test_expect_success 'cloning alternate repo #1, using #2 as reference' \
+'git clone --reference G F H'
+
+cd "$base_dir"
+
+test_expect_success 'cloning with reference being subset of source (-l -s)' \
+'git clone -l -s --reference A B E'
+
+cd "$base_dir"
+
test_done
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 822ac8c28..8dfaaa456 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -11,6 +11,11 @@ test_expect_success 'preparing origin repository' '
git clone --bare . x &&
test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true
+ git bundle create b1.bundle --all HEAD &&
+ git bundle create b2.bundle --all &&
+ mkdir dir &&
+ cp b1.bundle dir/b3
+ cp b1.bundle b4
'
test_expect_success 'local clone without .git suffix' '
@@ -63,4 +68,52 @@ test_expect_success 'Even without -l, local will make a hardlink' '
test 0 = $copied
'
+test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
+ cd "$D" &&
+ echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
+ git clone a d &&
+ cd d &&
+ git fetch &&
+ test ! -e .git/refs/remotes/origin/HEAD'
+
+test_expect_success 'bundle clone without .bundle suffix' '
+ cd "$D" &&
+ git clone dir/b3 &&
+ cd b3 &&
+ git fetch
+'
+
+test_expect_success 'bundle clone with .bundle suffix' '
+ cd "$D" &&
+ git clone b1.bundle &&
+ cd b1 &&
+ git fetch
+'
+
+test_expect_success 'bundle clone from b4' '
+ cd "$D" &&
+ git clone b4 bdl &&
+ cd bdl &&
+ git fetch
+'
+
+test_expect_success 'bundle clone from b4.bundle that does not exist' '
+ cd "$D" &&
+ if git clone b4.bundle bb
+ then
+ echo "Oops, should have failed"
+ false
+ else
+ echo happy
+ fi
+'
+
+test_expect_success 'bundle clone with nonexistent HEAD' '
+ cd "$D" &&
+ git clone b2.bundle b2 &&
+ cd b2 &&
+ git fetch
+ test ! -e .git/refs/heads/master
+'
+
test_done
diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh
index 699df6ebd..ef7127c1b 100755
--- a/t/t5710-info-alternate.sh
+++ b/t/t5710-info-alternate.sh
@@ -53,14 +53,18 @@ git prune'
cd "$base_dir"
-test_expect_failure 'creating too deep nesting' \
+test_expect_success 'creating too deep nesting' \
'git clone -l -s C D &&
git clone -l -s D E &&
git clone -l -s E F &&
git clone -l -s F G &&
-git clone -l -s G H &&
-cd H &&
-test_valid_repo'
+git clone -l -s G H'
+
+test_expect_success 'invalidity of deepest repository' \
+'cd H && {
+ test_valid_repo
+ test $? -ne 0
+}'
cd "$base_dir"
@@ -77,16 +81,16 @@ test_valid_repo'
cd "$base_dir"
test_expect_success 'breaking of loops' \
-"echo '$base_dir/B/.git/objects' >> '$base_dir'/A/.git/objects/info/alternates&&
+'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
cd C &&
-test_valid_repo"
+test_valid_repo'
cd "$base_dir"
-test_expect_failure 'that info/alternates is necessary' \
+test_expect_success 'that info/alternates is necessary' \
'cd C &&
-rm .git/objects/info/alternates &&
-test_valid_repo'
+rm -f .git/objects/info/alternates &&
+! (test_valid_repo)'
cd "$base_dir"
@@ -97,9 +101,11 @@ test_valid_repo'
cd "$base_dir"
-test_expect_failure 'that relative alternate is only possible for current dir' \
-'cd D &&
-test_valid_repo'
+test_expect_success \
+ 'that relative alternate is only possible for current dir' '
+ cd D &&
+ ! (test_valid_repo)
+'
cd "$base_dir"
diff --git a/t/t6000lib.sh b/t/t6000lib.sh
index 180633e1e..f55627b64 100755
--- a/t/t6000lib.sh
+++ b/t/t6000lib.sh
@@ -49,13 +49,15 @@ as_author()
shift 1
_save=$GIT_AUTHOR_EMAIL
- export GIT_AUTHOR_EMAIL="$_author"
+ GIT_AUTHOR_EMAIL="$_author"
+ export GIT_AUTHOR_EMAIL
"$@"
if test -z "$_save"
then
unset GIT_AUTHOR_EMAIL
else
- export GIT_AUTHOR_EMAIL="$_save"
+ GIT_AUTHOR_EMAIL="$_save"
+ export GIT_AUTHOR_EMAIL
fi
}
@@ -69,7 +71,8 @@ on_committer_date()
{
_date=$1
shift 1
- export GIT_COMMITTER_DATE="$_date"
+ GIT_COMMITTER_DATE="$_date"
+ export GIT_COMMITTER_DATE
"$@"
unset GIT_COMMITTER_DATE
}
@@ -97,7 +100,13 @@ check_output()
# from front and back.
name_from_description()
{
- tr "'" '-' | tr '~`!@#$%^&*()_+={}[]|\;:"<>,/? ' '-' | tr -s '-' | tr '[A-Z]' '[a-z]' | sed "s/^-*//;s/-*\$//"
+ perl -pe '
+ s/[^A-Za-z0-9.]/-/g;
+ s/-+/-/g;
+ s/-$//;
+ s/^-//;
+ y/A-Z/a-z/;
+ '
}
diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh
index 80d71988b..5dabf1c5e 100755
--- a/t/t6004-rev-list-path-optim.sh
+++ b/t/t6004-rev-list-path-optim.sh
@@ -45,7 +45,7 @@ test_expect_success 'further setup' '
test_expect_success 'path optimization 2' '
( echo "$side"; echo "$initial" ) >expected &&
git rev-list HEAD -- a >actual &&
- diff -u expected actual
+ test_cmp expected actual
'
test_done
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 0dc915ea6..9176484db 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -15,7 +15,7 @@ test_format() {
cat >expect.$1
test_expect_success "format $1" "
git rev-list --pretty=format:$2 master >output.$1 &&
-git diff expect.$1 output.$1
+test_cmp expect.$1 output.$1
"
}
diff --git a/t/t6008-rev-list-submodule.sh b/t/t6008-rev-list-submodule.sh
index 88e96fb91..c4af9ca0a 100755
--- a/t/t6008-rev-list-submodule.sh
+++ b/t/t6008-rev-list-submodule.sh
@@ -23,7 +23,7 @@ test_expect_success 'setup' '
: > super-file &&
git add super-file &&
- git submodule add . sub &&
+ git submodule add "$(pwd)" sub &&
git symbolic-ref HEAD refs/heads/super &&
test_tick &&
git commit -m super-initial &&
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
new file mode 100755
index 000000000..c8a96a9a9
--- /dev/null
+++ b/t/t6009-rev-list-parent.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='properly cull all ancestors'
+
+. ./test-lib.sh
+
+commit () {
+ test_tick &&
+ echo $1 >file &&
+ git commit -a -m $1 &&
+ git tag $1
+}
+
+test_expect_success setup '
+
+ touch file &&
+ git add file &&
+
+ commit one &&
+
+ test_tick=$(($test_tick - 2400))
+
+ commit two &&
+ commit three &&
+ commit four &&
+
+ git log --pretty=oneline --abbrev-commit
+'
+
+test_expect_success 'one is ancestor of others and should not be shown' '
+
+ git rev-list one --not four >result &&
+ >expect &&
+ test_cmp expect result
+
+'
+
+test_done
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index 96f3d3553..b6e57b242 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -13,10 +13,11 @@ T=$(git write-tree)
M=1130000000
Z=+0000
-export GIT_COMMITTER_EMAIL=git@comm.iter.xz
-export GIT_COMMITTER_NAME='C O Mmiter'
-export GIT_AUTHOR_NAME='A U Thor'
-export GIT_AUTHOR_EMAIL=git@au.thor.xz
+GIT_COMMITTER_EMAIL=git@comm.iter.xz
+GIT_COMMITTER_NAME='C O Mmiter'
+GIT_AUTHOR_NAME='A U Thor'
+GIT_AUTHOR_EMAIL=git@au.thor.xz
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
doit() {
OFFSET=$1; shift
diff --git a/t/t6011-rev-list-with-bad-commit.sh b/t/t6011-rev-list-with-bad-commit.sh
new file mode 100755
index 000000000..e51eb41f4
--- /dev/null
+++ b/t/t6011-rev-list-with-bad-commit.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+test_description='git rev-list should notice bad commits'
+
+. ./test-lib.sh
+
+# Note:
+# - compression level is set to zero to make "corruptions" easier to perform
+# - reflog is disabled to avoid extra references which would twart the test
+
+test_expect_success 'setup' \
+ '
+ git init &&
+ git config core.compression 0 &&
+ git config core.logallrefupdates false &&
+ echo "foo" > foo &&
+ git add foo &&
+ git commit -m "first commit" &&
+ echo "bar" > bar &&
+ git add bar &&
+ git commit -m "second commit" &&
+ echo "baz" > baz &&
+ git add baz &&
+ git commit -m "third commit" &&
+ echo "foo again" >> foo &&
+ git add foo &&
+ git commit -m "fourth commit" &&
+ git repack -a -f -d
+ '
+
+test_expect_success 'verify number of revisions' \
+ '
+ revs=$(git rev-list --all | wc -l) &&
+ test $revs -eq 4 &&
+ first_commit=$(git rev-parse HEAD~3)
+ '
+
+test_expect_success 'corrupt second commit object' \
+ '
+ perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
+ test_must_fail git fsck --full
+ '
+
+test_expect_success 'rev-list should fail' \
+ '
+ test_must_fail git rev-list --all > /dev/null
+ '
+
+test_expect_success 'git repack _MUST_ fail' \
+ '
+ test_must_fail git repack -a -f -d
+ '
+
+test_expect_success 'first commit is still available' \
+ '
+ git log $first_commit
+ '
+
+test_done
+
diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh
index 0ab14a6e8..331b9b07d 100755
--- a/t/t6021-merge-criss-cross.sh
+++ b/t/t6021-merge-criss-cross.sh
@@ -89,4 +89,8 @@ EOF
test_expect_success 'Criss-cross merge result' 'cmp file file-expect'
+test_expect_success 'Criss-cross merge fails (-s resolve)' \
+'git reset --hard A^ &&
+test_must_fail git merge -s resolve -m "final merge" B'
+
test_done
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index ae3b6f283..f674c48ca 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -63,11 +63,11 @@ test_expect_success "merge without conflict (missing LF at EOF)" \
"git merge-file test2.txt orig.txt new2.txt"
test_expect_success "merge result added missing LF" \
- "git diff test.txt test2.txt"
+ "test_cmp test.txt test2.txt"
cp test.txt backup.txt
-test_expect_failure "merge with conflicts" \
- "git merge-file test.txt orig.txt new3.txt"
+test_expect_success "merge with conflicts" \
+ "test_must_fail git merge-file test.txt orig.txt new3.txt"
cat > expect.txt << EOF
<<<<<<< test.txt
@@ -86,11 +86,11 @@ non timebo mala, quoniam tu mecum es:
virga tua et baculus tuus ipsa me consolata sunt.
EOF
-test_expect_success "expected conflict markers" "git diff test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
cp backup.txt test.txt
-test_expect_failure "merge with conflicts, using -L" \
- "git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
+test_expect_success "merge with conflicts, using -L" \
+ "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
cat > expect.txt << EOF
<<<<<<< 1
@@ -110,11 +110,11 @@ virga tua et baculus tuus ipsa me consolata sunt.
EOF
test_expect_success "expected conflict markers, with -L" \
- "git diff test.txt expect.txt"
+ "test_cmp test.txt expect.txt"
sed "s/ tu / TU /" < new1.txt > new5.txt
-test_expect_failure "conflict in removed tail" \
- "git merge-file -p orig.txt new1.txt new5.txt > out"
+test_expect_success "conflict in removed tail" \
+ "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out"
cat > expect << EOF
Dominus regit me,
@@ -132,11 +132,33 @@ virga tua et baculus tuus ipsa me consolata sunt.
>>>>>>> new5.txt
EOF
-test_expect_success "expected conflict markers" "git diff expect out"
+test_expect_success "expected conflict markers" "test_cmp expect out"
test_expect_success 'binary files cannot be merged' '
- ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err &&
+ test_must_fail git merge-file -p \
+ orig.txt ../test4012.png new1.txt 2> merge.err &&
grep "Cannot merge binary files" merge.err
'
+sed -e "s/deerit.$/deerit;/" -e "s/me;$/me./" < new5.txt > new6.txt
+sed -e "s/deerit.$/deerit,/" -e "s/me;$/me,/" < new5.txt > new7.txt
+
+test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' '
+
+ test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output &&
+ test 1 = $(grep ======= < output | wc -l)
+
+'
+
+sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit;/" < new6.txt > new8.txt
+sed -e 's/deerit./&\n\n\n\n/' -e "s/locavit,/locavit --/" < new7.txt > new9.txt
+
+test_expect_success 'ZEALOUS_ALNUM' '
+
+ test_must_fail git merge-file -p \
+ new8.txt new5.txt new9.txt > merge.out &&
+ test 1 = $(grep ======= < merge.out | wc -l)
+
+'
+
test_done
diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
index c154f03cf..802d0d06e 100755
--- a/t/t6024-recursive-merge.sh
+++ b/t/t6024-recursive-merge.sh
@@ -60,7 +60,9 @@ git update-index a1 &&
GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
'
-test_expect_failure "combined merge conflicts" "git merge -m final G"
+test_expect_success "combined merge conflicts" "
+ test_must_fail git merge -m final G
+"
cat > expect << EOF
<<<<<<< HEAD:a1
@@ -70,7 +72,7 @@ G
>>>>>>> G:a1
EOF
-test_expect_success "result contains a conflict" "git diff expect a1"
+test_expect_success "result contains a conflict" "test_cmp expect a1"
git ls-files --stage > out
cat > expect << EOF
@@ -79,10 +81,10 @@ cat > expect << EOF
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
EOF
-test_expect_success "virtual trees were processed" "git diff expect out"
+test_expect_success "virtual trees were processed" "test_cmp expect out"
-git reset --hard
test_expect_success 'refuse to merge binary files' '
+ git reset --hard &&
printf "\0" > binary-file &&
git add binary-file &&
git commit -m binary &&
@@ -90,7 +92,7 @@ test_expect_success 'refuse to merge binary files' '
printf "\0\0" > binary-file &&
git add binary-file &&
git commit -m binary2 &&
- ! git merge F > merge.out 2> merge.err &&
+ test_must_fail git merge F > merge.out 2> merge.err &&
grep "Cannot merge binary files: HEAD:binary-file vs. F:binary-file" \
merge.err
'
diff --git a/t/t6025-merge-symlinks.sh b/t/t6025-merge-symlinks.sh
index 950c2e9b6..fc58456a1 100755
--- a/t/t6025-merge-symlinks.sh
+++ b/t/t6025-merge-symlinks.sh
@@ -30,30 +30,29 @@ echo plain-file > symlink &&
git add symlink &&
git-commit -m b-file'
-test_expect_failure \
+test_expect_success \
'merge master into b-symlink, which has a different symbolic link' '
-! git-checkout b-symlink ||
-git-merge master'
+git-checkout b-symlink &&
+test_must_fail git-merge master'
test_expect_success \
'the merge result must be a file' '
test -f symlink'
-test_expect_failure \
+test_expect_success \
'merge master into b-file, which has a file instead of a symbolic link' '
-! (git-reset --hard &&
-git-checkout b-file) ||
-git-merge master'
+git-reset --hard && git-checkout b-file &&
+test_must_fail git-merge master'
test_expect_success \
'the merge result must be a file' '
test -f symlink'
-test_expect_failure \
+test_expect_success \
'merge b-file, which has a file instead of a symbolic link, into master' '
-! (git-reset --hard &&
-git-checkout master) ||
-git-merge b-file'
+git-reset --hard &&
+git-checkout master &&
+test_must_fail git-merge b-file'
test_expect_success \
'the merge result must be a file' '
diff --git a/t/t6027-merge-binary.sh b/t/t6027-merge-binary.sh
index a7358f75b..92ca1f0f8 100755
--- a/t/t6027-merge-binary.sh
+++ b/t/t6027-merge-binary.sh
@@ -45,7 +45,7 @@ test_expect_success resolve '
false
else
git ls-files -s >current
- diff -u current expect
+ test_cmp current expect
fi
'
@@ -60,7 +60,7 @@ test_expect_success recursive '
false
else
git ls-files -s >current
- diff -u current expect
+ test_cmp current expect
fi
'
diff --git a/t/t6029-merge-subtree.sh b/t/t6029-merge-subtree.sh
new file mode 100755
index 000000000..5bbfa44e8
--- /dev/null
+++ b/t/t6029-merge-subtree.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+test_description='subtree merge strategy'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ s="1 2 3 4 5 6 7 8"
+ for i in $s; do echo $i; done >hello &&
+ git add hello &&
+ git commit -m initial &&
+ git checkout -b side &&
+ echo >>hello world &&
+ git add hello &&
+ git commit -m second &&
+ git checkout master &&
+ for i in mundo $s; do echo $i; done >hello &&
+ git add hello &&
+ git commit -m master
+
+'
+
+test_expect_success 'subtree available and works like recursive' '
+
+ git merge -s subtree side &&
+ for i in mundo $s world; do echo $i; done >expect &&
+ test_cmp expect hello
+
+'
+
+test_expect_success 'setup' '
+ mkdir git-gui &&
+ cd git-gui &&
+ git init &&
+ echo git-gui > git-gui.sh &&
+ o1=$(git hash-object git-gui.sh) &&
+ git add git-gui.sh &&
+ git commit -m "initial git-gui" &&
+ cd .. &&
+ mkdir git &&
+ cd git &&
+ git init &&
+ echo git >git.c &&
+ o2=$(git hash-object git.c) &&
+ git add git.c &&
+ git commit -m "initial git"
+'
+
+test_expect_success 'initial merge' '
+ git remote add -f gui ../git-gui &&
+ git merge -s ours --no-commit gui/master &&
+ git read-tree --prefix=git-gui/ -u gui/master &&
+ git commit -m "Merge git-gui as our subdirectory" &&
+ git ls-files -s >actual &&
+ (
+ echo "100644 $o1 0 git-gui/git-gui.sh"
+ echo "100644 $o2 0 git.c"
+ ) >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success 'merge update' '
+ cd ../git-gui &&
+ echo git-gui2 > git-gui.sh &&
+ o3=$(git hash-object git-gui.sh) &&
+ git add git-gui.sh &&
+ git commit -m "update git-gui" &&
+ cd ../git &&
+ git pull -s subtree gui master &&
+ git ls-files -s >actual &&
+ (
+ echo "100644 $o3 0 git-gui/git-gui.sh"
+ echo "100644 $o2 0 git.c"
+ ) >expected &&
+ test_cmp expected actual
+'
+
+test_done
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 2ba4b00e5..244fda62a 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -71,6 +71,24 @@ test_expect_success 'bisect start with one bad and good' '
git bisect next
'
+test_expect_success 'bisect fails if given any junk instead of revs' '
+ git bisect reset &&
+ test_must_fail git bisect start foo $HASH1 -- &&
+ test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
+ test -z "$(git for-each-ref "refs/bisect/*")" &&
+ test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
+ git bisect start &&
+ test_must_fail git bisect good foo $HASH1 &&
+ test_must_fail git bisect good $HASH1 bar &&
+ test_must_fail git bisect bad frotz &&
+ test_must_fail git bisect bad $HASH3 $HASH4 &&
+ test_must_fail git bisect skip bar $HASH3 &&
+ test_must_fail git bisect skip $HASH1 foo &&
+ test -z "$(git for-each-ref "refs/bisect/*")" &&
+ git bisect good $HASH1 &&
+ git bisect bad $HASH4
+'
+
test_expect_success 'bisect reset: back in the master branch' '
git bisect reset &&
echo "* master" > branch.expect &&
@@ -108,6 +126,47 @@ test_expect_success 'bisect reset removes packed refs' '
test -z "$(git for-each-ref "refs/heads/bisect")"
'
+test_expect_success 'bisect start: back in good branch' '
+ git branch > branch.output &&
+ grep "* other" branch.output > /dev/null &&
+ git bisect start $HASH4 $HASH1 -- &&
+ git bisect good &&
+ git bisect start $HASH4 $HASH1 -- &&
+ git bisect bad &&
+ git bisect reset &&
+ git branch > branch.output &&
+ grep "* other" branch.output > /dev/null
+'
+
+test_expect_success 'bisect start: no ".git/BISECT_START" if junk rev' '
+ git bisect start $HASH4 $HASH1 -- &&
+ git bisect good &&
+ test_must_fail git bisect start $HASH4 foo -- &&
+ git branch > branch.output &&
+ grep "* other" branch.output > /dev/null &&
+ test_must_fail test -e .git/BISECT_START
+'
+
+test_expect_success 'bisect start: no ".git/BISECT_START" if mistaken rev' '
+ git bisect start $HASH4 $HASH1 -- &&
+ git bisect good &&
+ test_must_fail git bisect start $HASH1 $HASH4 -- &&
+ git branch > branch.output &&
+ grep "* other" branch.output > /dev/null &&
+ test_must_fail test -e .git/BISECT_START
+'
+
+test_expect_success 'bisect start: no ".git/BISECT_START" if checkout error' '
+ echo "temp stuff" > hello &&
+ test_must_fail git bisect start $HASH4 $HASH1 -- &&
+ git branch &&
+ git branch > branch.output &&
+ grep "* other" branch.output > /dev/null &&
+ test_must_fail test -e .git/BISECT_START &&
+ test -z "$(git for-each-ref "refs/bisect/*")" &&
+ git checkout HEAD hello
+'
+
# $HASH1 is good, $HASH4 is bad, we skip $HASH3
# but $HASH2 is bad,
# so we should find $HASH2 as the first bad commit
@@ -219,7 +278,7 @@ test_expect_success 'bisect run & skip: cannot tell between 2' '
add_line_into_file "6: Yet a line." hello &&
HASH6=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh &&
- echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+ echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
echo "grep line hello > /dev/null" >> test_script.sh &&
echo "test \$? -ne 0" >> test_script.sh &&
chmod +x test_script.sh &&
@@ -244,8 +303,8 @@ test_expect_success 'bisect run & skip: find first bad' '
add_line_into_file "7: Should be the last line." hello &&
HASH7=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh &&
- echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
- echo "tail -1 hello | grep day > /dev/null && exit 125" >> test_script.sh &&
+ echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+ echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh &&
echo "grep Yet hello > /dev/null" >> test_script.sh &&
echo "test \$? -ne 0" >> test_script.sh &&
chmod +x test_script.sh &&
@@ -254,6 +313,43 @@ test_expect_success 'bisect run & skip: find first bad' '
grep "$HASH6 is first bad commit" my_bisect_log.txt
'
+test_expect_success 'bisect starting with a detached HEAD' '
+
+ git bisect reset &&
+ git checkout master^ &&
+ HEAD=$(git rev-parse --verify HEAD) &&
+ git bisect start &&
+ test $HEAD = $(cat .git/BISECT_START) &&
+ git bisect reset &&
+ test $HEAD = $(git rev-parse --verify HEAD)
+'
+
+test_expect_success 'bisect errors out if bad and good are mistaken' '
+ git bisect reset &&
+ test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
+ grep "mistake good and bad" rev_list_error &&
+ git bisect reset
+'
+
+test_expect_success 'bisect does not create a "bisect" branch' '
+ git bisect reset &&
+ git bisect start $HASH7 $HASH1 &&
+ git branch bisect &&
+ rev_hash4=$(git rev-parse --verify HEAD) &&
+ test "$rev_hash4" = "$HASH4" &&
+ git branch -D bisect &&
+ git bisect good &&
+ git branch bisect &&
+ rev_hash6=$(git rev-parse --verify HEAD) &&
+ test "$rev_hash6" = "$HASH6" &&
+ git bisect good > my_bisect_log.txt &&
+ grep "$HASH7 is first bad commit" my_bisect_log.txt &&
+ git bisect reset &&
+ rev_hash6=$(git rev-parse --verify bisect) &&
+ test "$rev_hash6" = "$HASH6" &&
+ git branch -D bisect
+'
+
#
#
test_done
diff --git a/t/t6031-merge-recursive.sh b/t/t6031-merge-recursive.sh
new file mode 100755
index 000000000..8073e0c3e
--- /dev/null
+++ b/t/t6031-merge-recursive.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='merge-recursive: handle file mode'
+. ./test-lib.sh
+
+# Note that we follow "chmod +x F" with "update-index --chmod=+x F" to
+# help filesystems that do not have the executable bit.
+
+test_expect_success 'mode change in one branch: keep changed version' '
+ : >file1 &&
+ git add file1 &&
+ git commit -m initial &&
+ git checkout -b a1 master &&
+ : >dummy &&
+ git add dummy &&
+ git commit -m a &&
+ git checkout -b b1 master &&
+ chmod +x file1 &&
+ git update-index --chmod=+x file1 &&
+ git commit -m b1 &&
+ git checkout a1 &&
+ git merge-recursive master -- a1 b1 &&
+ test -x file1
+'
+
+test_expect_success 'mode change in both branches: expect conflict' '
+ git reset --hard HEAD &&
+ git checkout -b a2 master &&
+ : >file2 &&
+ H=$(git hash-object file2) &&
+ chmod +x file2 &&
+ git update-index --add --chmod=+x file2 &&
+ git commit -m a2 &&
+ git checkout -b b2 master &&
+ : >file2 &&
+ git add file2 &&
+ git commit -m b2 &&
+ git checkout a2 &&
+ (
+ git merge-recursive master -- a2 b2
+ test $? = 1
+ ) &&
+ git ls-files -u >actual &&
+ (
+ echo "100755 $H 2 file2"
+ echo "100644 $H 3 file2"
+ ) >expect &&
+ test_cmp actual expect &&
+ test -x file2
+'
+
+test_done
diff --git a/t/t6032-merge-large-rename.sh b/t/t6032-merge-large-rename.sh
new file mode 100755
index 000000000..eac5ebac2
--- /dev/null
+++ b/t/t6032-merge-large-rename.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+test_description='merging with large rename matrix'
+. ./test-lib.sh
+
+count() {
+ i=1
+ while test $i -le $1; do
+ echo $i
+ i=$(($i + 1))
+ done
+}
+
+test_expect_success 'setup (initial)' '
+ touch file &&
+ git add . &&
+ git commit -m initial &&
+ git tag initial
+'
+
+make_text() {
+ echo $1: $2
+ for i in `count 20`; do
+ echo $1: $i
+ done
+ echo $1: $3
+}
+
+test_rename() {
+ test_expect_success "rename ($1, $2)" '
+ n='$1'
+ expect='$2'
+ git checkout -f master &&
+ git branch -D test$n || true &&
+ git reset --hard initial &&
+ for i in $(count $n); do
+ make_text $i initial initial >$i
+ done &&
+ git add . &&
+ git commit -m add=$n &&
+ for i in $(count $n); do
+ make_text $i changed initial >$i
+ done &&
+ git commit -a -m change=$n &&
+ git checkout -b test$n HEAD^ &&
+ for i in $(count $n); do
+ git rm $i
+ make_text $i initial changed >$i.moved
+ done &&
+ git add . &&
+ git commit -m change+rename=$n &&
+ case "$expect" in
+ ok) git merge master ;;
+ *) test_must_fail git merge master ;;
+ esac
+ '
+}
+
+test_rename 5 ok
+
+test_expect_success 'set diff.renamelimit to 4' '
+ git config diff.renamelimit 4
+'
+test_rename 4 ok
+test_rename 5 fail
+
+test_expect_success 'set merge.renamelimit to 5' '
+ git config merge.renamelimit 5
+'
+test_rename 5 ok
+test_rename 6 fail
+
+test_done
diff --git a/t/t6033-merge-crlf.sh b/t/t6033-merge-crlf.sh
new file mode 100755
index 000000000..75d9602de
--- /dev/null
+++ b/t/t6033-merge-crlf.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+append_cr () {
+ sed -e 's/$/Q/' | tr Q '\015'
+}
+
+remove_cr () {
+ tr '\015' Q | sed -e 's/Q$//'
+}
+
+test_description='merge conflict in crlf repo
+
+ b---M
+ / /
+ initial---a
+
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ git config core.autocrlf true &&
+ echo foo | append_cr >file &&
+ git add file &&
+ git commit -m "Initial" &&
+ git tag initial &&
+ git branch side &&
+ echo line from a | append_cr >file &&
+ git commit -m "add line from a" file &&
+ git tag a &&
+ git checkout side &&
+ echo line from b | append_cr >file &&
+ git commit -m "add line from b" file &&
+ git tag b &&
+ git checkout master
+'
+
+test_expect_success 'Check "ours" is CRLF' '
+ git reset --hard initial &&
+ git merge side -s ours &&
+ cat file | remove_cr | append_cr >file.temp &&
+ test_cmp file file.temp
+'
+
+test_expect_success 'Check that conflict file is CRLF' '
+ git reset --hard a &&
+ test_must_fail git merge side &&
+ cat file | remove_cr | append_cr >file.temp &&
+ test_cmp file file.temp
+'
+
+test_done
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
new file mode 100755
index 000000000..aac212e93
--- /dev/null
+++ b/t/t6040-tracking-info.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+test_description='remote tracking stats'
+
+. ./test-lib.sh
+
+advance () {
+ echo "$1" >"$1" &&
+ git add "$1" &&
+ test_tick &&
+ git commit -m "$1"
+}
+
+test_expect_success setup '
+ for i in a b c;
+ do
+ advance $i || break
+ done &&
+ git clone . test &&
+ (
+ cd test &&
+ git checkout -b b1 origin &&
+ git reset --hard HEAD^ &&
+ advance d &&
+ git checkout -b b2 origin &&
+ git reset --hard b1 &&
+ git checkout -b b3 origin &&
+ git reset --hard HEAD^ &&
+ git checkout -b b4 origin &&
+ advance e &&
+ advance f
+ )
+'
+
+script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
+cat >expect <<\EOF
+b1 ahead 1, behind 1
+b2 ahead 1, behind 1
+b3 behind 1
+b4 ahead 2
+EOF
+
+test_expect_success 'branch -v' '
+ (
+ cd test &&
+ git branch -v
+ ) |
+ sed -n -e "$script" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'checkout' '
+ (
+ cd test && git checkout b1
+ ) >actual &&
+ grep -e "have 1 and 1 different" actual
+'
+
+test_expect_success 'status' '
+ (
+ cd test &&
+ git checkout b1 >/dev/null &&
+ # reports nothing to commit
+ test_must_fail git status
+ ) >actual &&
+ grep -e "have 1 and 1 different" actual
+'
+
+
+test_done
diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh
index 0724864e5..919552a2f 100755
--- a/t/t6101-rev-parse-parents.sh
+++ b/t/t6101-rev-parse-parents.sh
@@ -26,8 +26,10 @@ test_expect_success 'final^1^1^1 = final^^^' "test $(git rev-parse final^1^1^1)
test_expect_success 'final^1^2' "test $(git rev-parse start2) = $(git rev-parse final^1^2)"
test_expect_success 'final^1^2 != final^1^1' "test $(git rev-parse final^1^2) != $(git rev-parse final^1^1)"
test_expect_success 'final^1^3 not valid' "if git rev-parse --verify final^1^3; then false; else :; fi"
-test_expect_failure '--verify start2^1' 'git rev-parse --verify start2^1'
+test_expect_success '--verify start2^1' 'test_must_fail git rev-parse --verify start2^1'
test_expect_success '--verify start2^0' 'git rev-parse --verify start2^0'
+test_expect_success 'final^1^@ = final^1^1 final^1^2' "test \"$(git rev-parse final^1^@)\" = \"$(git rev-parse final^1^1 final^1^2)\""
+test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' "test \"$(git rev-parse final^1^\!)\" = \"$(git rev-parse final^1 ^final^1^1 ^final^1^2)\""
test_expect_success 'repack for next test' 'git repack -a -d'
test_expect_success 'short SHA-1 works' '
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index ae8ee1118..2fb672c3b 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -15,8 +15,11 @@ test_description='test describe
check_describe () {
expect="$1"
shift
- R=$(git describe "$@") &&
+ R=$(git describe "$@" 2>err.actual)
+ S=$?
+ cat err.actual >&3
test_expect_success "describe $*" '
+ test $S = 0 &&
case "$R" in
$expect) echo happy ;;
*) echo "Oops - $R is not $expect";
@@ -94,4 +97,48 @@ check_describe D-* --tags HEAD^^
check_describe A-* --tags HEAD^^2
check_describe B --tags HEAD^^2^
+check_describe B-0-* --long HEAD^^2^
+check_describe A-3-* --long HEAD^^2
+
+test_expect_success 'rename tag A to Q locally' '
+ mv .git/refs/tags/A .git/refs/tags/Q
+'
+cat - >err.expect <<EOF
+warning: tag 'A' is really 'Q' here
+EOF
+check_describe A-* HEAD
+test_expect_success 'warning was displayed for Q' '
+ test_cmp err.expect err.actual
+'
+test_expect_success 'rename tag Q back to A' '
+ mv .git/refs/tags/Q .git/refs/tags/A
+'
+
+test_expect_success 'pack tag refs' 'git pack-refs'
+check_describe A-* HEAD
+
+test_expect_success 'set-up matching pattern tests' '
+ git tag -a -m test-annotated test-annotated &&
+ echo >>file &&
+ test_tick &&
+ git commit -a -m "one more" &&
+ git tag test1-lightweight &&
+ echo >>file &&
+ test_tick &&
+ git commit -a -m "yet another" &&
+ git tag test2-lightweight &&
+ echo >>file &&
+ test_tick &&
+ git commit -a -m "even more"
+
+'
+
+check_describe "test-annotated-*" --match="test-*"
+
+check_describe "test1-lightweight-*" --tags --match="test1-*"
+
+check_describe "test2-lightweight-*" --tags --match="test2-*"
+
+check_describe "test2-lightweight-*" --long --tags --match="test2-*" HEAD^
+
test_done
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 526d7d1c4..bc7434941 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -79,20 +79,20 @@ test_expect_success 'merge-msg test #1' '
git fetch . left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- git diff actual expected
+ test_cmp expected actual
'
-cat >expected <<\EOF
-Merge branch 'left' of ../trash
+cat >expected <<EOF
+Merge branch 'left' of ../$test
EOF
test_expect_success 'merge-msg test #2' '
git checkout master &&
- git fetch ../trash left &&
+ git fetch ../"$test" left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- git diff actual expected
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -106,8 +106,24 @@ Merge branch 'left'
Common #1
EOF
-test_expect_success 'merge-msg test #3' '
+test_expect_success 'merge-msg test #3-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log true &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left &&
+
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ test_cmp expected actual
+'
+test_expect_success 'merge-msg test #3-2' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
@@ -115,7 +131,7 @@ test_expect_success 'merge-msg test #3' '
git fetch . left &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- git diff actual expected
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -136,8 +152,24 @@ Merge branches 'left' and 'right'
Common #1
EOF
-test_expect_success 'merge-msg test #4' '
+test_expect_success 'merge-msg test #4-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log true &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left right &&
+
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ test_cmp expected actual
+'
+test_expect_success 'merge-msg test #4-2' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary true &&
git checkout master &&
@@ -145,11 +177,27 @@ test_expect_success 'merge-msg test #4' '
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- git diff actual expected
+ test_cmp expected actual
+'
+
+test_expect_success 'merge-msg test #5-1' '
+
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
+ git config merge.log yes &&
+
+ git checkout master &&
+ setdate &&
+ git fetch . left right &&
+
+ git fmt-merge-msg <.git/FETCH_HEAD >actual &&
+ test_cmp expected actual
'
-test_expect_success 'merge-msg test #5' '
+test_expect_success 'merge-msg test #5-2' '
+ git config --unset-all merge.log
+ git config --unset-all merge.summary
git config merge.summary yes &&
git checkout master &&
@@ -157,7 +205,7 @@ test_expect_success 'merge-msg test #5' '
git fetch . left right &&
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- git diff actual expected
+ test_cmp expected actual
'
test_done
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 8a23aaf21..a3c8941c7 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -26,25 +26,78 @@ test_expect_success 'Create sample commit with known timestamp' '
git tag -a -m "Tagging at $datestamp" testtag
'
-test_expect_success 'Check atom names are valid' '
- bad=
- for token in \
- refname objecttype objectsize objectname tree parent \
- numparent object type author authorname authoremail \
- authordate committer committername committeremail \
- committerdate tag tagger taggername taggeremail \
- taggerdate creator creatordate subject body contents
- do
- git for-each-ref --format="$token=%($token)" refs/heads || {
- bad=$token
- break
- }
- done
- test -z "$bad"
-'
-
-test_expect_failure 'Check invalid atoms names are errors' '
- git-for-each-ref --format="%(INVALID)" refs/heads
+test_atom() {
+ case "$1" in
+ head) ref=refs/heads/master ;;
+ tag) ref=refs/tags/testtag ;;
+ esac
+ printf '%s\n' "$3" >expected
+ test_expect_${4:-success} "basic atom: $1 $2" "
+ git for-each-ref --format='%($2)' $ref >actual &&
+ test_cmp expected actual
+ "
+}
+
+test_atom head refname refs/heads/master
+test_atom head objecttype commit
+test_atom head objectsize 171
+test_atom head objectname 67a36f10722846e891fbada1ba48ed035de75581
+test_atom head tree 0e51c00fcb93dffc755546f27593d511e1bdb46f
+test_atom head parent ''
+test_atom head numparent 0
+test_atom head object ''
+test_atom head type ''
+test_atom head author 'A U Thor <author@example.com> 1151939924 +0200'
+test_atom head authorname 'A U Thor'
+test_atom head authoremail '<author@example.com>'
+test_atom head authordate 'Mon Jul 3 17:18:44 2006 +0200'
+test_atom head committer 'C O Mitter <committer@example.com> 1151939923 +0200'
+test_atom head committername 'C O Mitter'
+test_atom head committeremail '<committer@example.com>'
+test_atom head committerdate 'Mon Jul 3 17:18:43 2006 +0200'
+test_atom head tag ''
+test_atom head tagger ''
+test_atom head taggername ''
+test_atom head taggeremail ''
+test_atom head taggerdate ''
+test_atom head creator 'C O Mitter <committer@example.com> 1151939923 +0200'
+test_atom head creatordate 'Mon Jul 3 17:18:43 2006 +0200'
+test_atom head subject 'Initial'
+test_atom head body ''
+test_atom head contents 'Initial
+'
+
+test_atom tag refname refs/tags/testtag
+test_atom tag objecttype tag
+test_atom tag objectsize 154
+test_atom tag objectname 98b46b1d36e5b07909de1b3886224e3e81e87322
+test_atom tag tree ''
+test_atom tag parent ''
+test_atom tag numparent ''
+test_atom tag object '67a36f10722846e891fbada1ba48ed035de75581'
+test_atom tag type 'commit'
+test_atom tag author ''
+test_atom tag authorname ''
+test_atom tag authoremail ''
+test_atom tag authordate ''
+test_atom tag committer ''
+test_atom tag committername ''
+test_atom tag committeremail ''
+test_atom tag committerdate ''
+test_atom tag tag 'testtag'
+test_atom tag tagger 'C O Mitter <committer@example.com> 1151939925 +0200'
+test_atom tag taggername 'C O Mitter'
+test_atom tag taggeremail '<committer@example.com>'
+test_atom tag taggerdate 'Mon Jul 3 17:18:45 2006 +0200'
+test_atom tag creator 'C O Mitter <committer@example.com> 1151939925 +0200'
+test_atom tag creatordate 'Mon Jul 3 17:18:45 2006 +0200'
+test_atom tag subject 'Tagging at 1151939927'
+test_atom tag body ''
+test_atom tag contents 'Tagging at 1151939927
+'
+
+test_expect_success 'Check invalid atoms names are errors' '
+ test_must_fail git-for-each-ref --format="%(INVALID)" refs/heads
'
test_expect_success 'Check format specifiers are ignored in naming date atoms' '
@@ -63,8 +116,8 @@ test_expect_success 'Check valid format specifiers for date fields' '
git-for-each-ref --format="%(authordate:rfc2822)" refs/heads
'
-test_expect_failure 'Check invalid format specifiers are errors' '
- git-for-each-ref --format="%(authordate:INVALID)" refs/heads
+test_expect_success 'Check invalid format specifiers are errors' '
+ test_must_fail git-for-each-ref --format="%(authordate:INVALID)" refs/heads
'
cat >expected <<\EOF
@@ -75,14 +128,14 @@ EOF
test_expect_success 'Check unformatted date fields output' '
(git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
test_expect_success 'Check format "default" formatted date fields output' '
f=default &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
# Don't know how to do relative check because I can't know when this script
@@ -109,7 +162,7 @@ test_expect_success 'Check format "short" date fields output' '
f=short &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -121,7 +174,7 @@ test_expect_success 'Check format "local" date fields output' '
f=local &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -133,7 +186,7 @@ test_expect_success 'Check format "iso8601" date fields output' '
f=iso8601 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -145,7 +198,7 @@ test_expect_success 'Check format "rfc2822" date fields output' '
f=rfc2822 &&
(git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -155,7 +208,7 @@ EOF
test_expect_success 'Verify ascending sort' '
git-for-each-ref --format="%(refname)" --sort=refname >actual &&
- git diff expected actual
+ test_cmp expected actual
'
@@ -166,7 +219,7 @@ EOF
test_expect_success 'Verify descending sort' '
git-for-each-ref --format="%(refname)" --sort=-refname >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -176,17 +229,17 @@ EOF
test_expect_success 'Quoting style: shell' '
git for-each-ref --shell --format="%(refname)" >actual &&
- git diff expected actual
+ test_cmp expected actual
'
test_expect_success 'Quoting style: perl' '
git for-each-ref --perl --format="%(refname)" >actual &&
- git diff expected actual
+ test_cmp expected actual
'
test_expect_success 'Quoting style: python' '
git for-each-ref --python --format="%(refname)" >actual &&
- git diff expected actual
+ test_cmp expected actual
'
cat >expected <<\EOF
@@ -196,7 +249,7 @@ EOF
test_expect_success 'Quoting style: tcl' '
git for-each-ref --tcl --format="%(refname)" >actual &&
- git diff expected actual
+ test_cmp expected actual
'
for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index b730c900b..910a28c7e 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -78,9 +78,9 @@ test_expect_success \
git diff-tree -r -M --name-status HEAD^ HEAD | \
grep "^R100..*path2/README..*path1/path2/README"'
-test_expect_failure \
+test_expect_success \
'do not move directory over existing directory' \
- 'mkdir path0 && mkdir path0/path2 && git mv path2 path0'
+ 'mkdir path0 && mkdir path0/path2 && test_must_fail git mv path2 path0'
test_expect_success \
'move into "."' \
@@ -118,4 +118,96 @@ test_expect_success "Sergey Vlasov's test case" '
git mv ab a
'
+test_expect_success 'absolute pathname' '(
+
+ rm -fr mine &&
+ mkdir mine &&
+ cd mine &&
+ test_create_repo one &&
+ cd one &&
+ mkdir sub &&
+ >sub/file &&
+ git add sub/file &&
+
+ git mv sub "$(pwd)/in" &&
+ ! test -d sub &&
+ test -d in &&
+ git ls-files --error-unmatch in/file
+
+
+)'
+
+test_expect_success 'absolute pathname outside should fail' '(
+
+ rm -fr mine &&
+ mkdir mine &&
+ cd mine &&
+ out=$(pwd) &&
+ test_create_repo one &&
+ cd one &&
+ mkdir sub &&
+ >sub/file &&
+ git add sub/file &&
+
+ test_must_fail git mv sub "$out/out" &&
+ test -d sub &&
+ ! test -d ../in &&
+ git ls-files --error-unmatch sub/file
+
+)'
+
+test_expect_success 'git mv should not change sha1 of moved cache entry' '
+
+ rm -fr .git &&
+ git init &&
+ echo 1 >dirty &&
+ git add dirty &&
+ entry="$(git ls-files --stage dirty | cut -f 1)"
+ git mv dirty dirty2 &&
+ [ "$entry" = "$(git ls-files --stage dirty2 | cut -f 1)" ] &&
+ echo 2 >dirty2 &&
+ git mv dirty2 dirty &&
+ [ "$entry" = "$(git ls-files --stage dirty | cut -f 1)" ]
+
+'
+
+rm -f dirty dirty2
+
+test_expect_success 'git mv should overwrite symlink to a file' '
+
+ rm -fr .git &&
+ git init &&
+ echo 1 >moved &&
+ ln -s moved symlink &&
+ git add moved symlink &&
+ test_must_fail git mv moved symlink &&
+ git mv -f moved symlink &&
+ ! test -e moved &&
+ test -f symlink &&
+ test "$(cat symlink)" = 1 &&
+ git update-index --refresh &&
+ git diff-files --quiet
+
+'
+
+rm -f moved symlink
+
+test_expect_success 'git mv should overwrite file with a symlink' '
+
+ rm -fr .git &&
+ git init &&
+ echo 1 >moved &&
+ ln -s moved symlink &&
+ git add moved symlink &&
+ test_must_fail git mv symlink moved &&
+ git mv -f symlink moved &&
+ ! test -e symlink &&
+ test -h moved &&
+ git update-index --refresh &&
+ git diff-files --quiet
+
+'
+
+rm -f moved symlink
+
test_done
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 68b2b9287..c8b4f65f3 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -107,8 +107,8 @@ do
diff expected actual
'
- test_expect_failure "grep -c $L (no /dev/null)" '
- git grep -c test $H | grep -q "/dev/null"
+ test_expect_success "grep -c $L (no /dev/null)" '
+ ! git grep -c test $H | grep -q /dev/null
'
done
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index 5f60b22d8..a0ab096c8 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -4,7 +4,7 @@ test_description='git-filter-branch'
. ./test-lib.sh
make_commit () {
- lower=$(echo $1 | tr A-Z a-z)
+ lower=$(echo $1 | tr '[A-Z]' '[a-z]')
echo $lower > $lower
git add $lower
test_tick
@@ -17,6 +17,8 @@ test_expect_success 'setup' '
make_commit B
git checkout -b branch B
make_commit D
+ mkdir dir
+ make_commit dir/D
make_commit E
git checkout master
make_commit C
@@ -36,14 +38,36 @@ test_expect_success 'result is really identical' '
test $H = $(git rev-parse HEAD)
'
+test_expect_success 'rewrite bare repository identically' '
+ (git config core.bare true && cd .git && git-filter-branch branch)
+'
+git config core.bare false
+test_expect_success 'result is really identical' '
+ test $H = $(git rev-parse HEAD)
+'
+
test_expect_success 'rewrite, renaming a specific file' '
git-filter-branch -f --tree-filter "mv d doh || :" HEAD
'
test_expect_success 'test that the file was renamed' '
- test d = $(git show HEAD:doh) &&
+ test d = "$(git show HEAD:doh --)" &&
+ ! test -f d &&
test -f doh &&
- test d = $(cat doh)
+ test d = "$(cat doh)"
+'
+
+test_expect_success 'rewrite, renaming a specific directory' '
+ git-filter-branch -f --tree-filter "mv dir diroh || :" HEAD
+'
+
+test_expect_success 'test that the directory was renamed' '
+ test dir/d = "$(git show HEAD:diroh/d --)" &&
+ ! test -d dir &&
+ test -d diroh &&
+ ! test -d diroh/dir &&
+ test -f diroh/d &&
+ test dir/d = "$(cat diroh/d)"
'
git tag oldD HEAD~4
@@ -78,10 +102,10 @@ test_expect_success 'filter subdirectory only' '
test_expect_success 'subdirectory filter result looks okay' '
test 2 = $(git rev-list sub | wc -l) &&
git show sub:new &&
- ! git show sub:subdir
+ test_must_fail git show sub:subdir
'
-test_expect_success 'setup and filter history that requires --full-history' '
+test_expect_success 'more setup' '
git checkout master &&
mkdir subdir &&
echo A > subdir/new &&
@@ -91,16 +115,7 @@ test_expect_success 'setup and filter history that requires --full-history' '
git rm a &&
test_tick &&
git commit -m "again subdir on master" &&
- git merge branch &&
- git branch sub-master &&
- git-filter-branch -f --subdirectory-filter subdir sub-master
-'
-
-test_expect_success 'subdirectory filter result looks okay' '
- test 3 = $(git rev-list -1 --parents sub-master | wc -w) &&
- git show sub-master^:new &&
- git show sub-master^2:new &&
- ! git show sub:subdir
+ git merge branch
'
test_expect_success 'use index-filter to move into a subdirectory' '
@@ -109,12 +124,12 @@ test_expect_success 'use index-filter to move into a subdirectory' '
"git ls-files -s | sed \"s-\\t-&newsubdir/-\" |
GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \
git update-index --index-info &&
- mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved &&
+ mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved &&
test -z "$(git diff HEAD directorymoved:newsubdir)"'
test_expect_success 'stops when msg filter fails' '
old=$(git rev-parse HEAD) &&
- ! git-filter-branch -f --msg-filter false HEAD &&
+ test_must_fail git-filter-branch -f --msg-filter false HEAD &&
test $old = $(git rev-parse HEAD) &&
rm -rf .git-rewrite
'
@@ -151,8 +166,8 @@ test_expect_success "remove a certain author's commits" '
'
test_expect_success 'barf on invalid name' '
- ! git filter-branch -f master xy-problem &&
- ! git filter-branch -f HEAD^
+ test_must_fail git filter-branch -f master xy-problem &&
+ test_must_fail git filter-branch -f HEAD^
'
test_expect_success '"map" works in commit filter' '
@@ -165,4 +180,74 @@ test_expect_success '"map" works in commit filter' '
git rev-parse --verify master
'
+test_expect_success 'Name needing quotes' '
+
+ git checkout -b rerere A &&
+ mkdir foo &&
+ name="れれれ" &&
+ >foo/$name &&
+ git add foo &&
+ git commit -m "Adding a file" &&
+ git filter-branch --tree-filter "rm -fr foo" &&
+ test_must_fail git ls-files --error-unmatch "foo/$name" &&
+ test $(git rev-parse --verify rerere) != $(git rev-parse --verify A)
+
+'
+
+test_expect_success 'Subdirectory filter with disappearing trees' '
+ git reset --hard &&
+ git checkout master &&
+
+ mkdir foo &&
+ touch foo/bar &&
+ git add foo &&
+ test_tick &&
+ git commit -m "Adding foo" &&
+
+ git rm -r foo &&
+ test_tick &&
+ git commit -m "Removing foo" &&
+
+ mkdir foo &&
+ touch foo/bar &&
+ git add foo &&
+ test_tick &&
+ git commit -m "Re-adding foo" &&
+
+ git filter-branch -f --subdirectory-filter foo &&
+ test $(git rev-list master | wc -l) = 3
+'
+
+test_expect_success 'Tag name filtering retains tag message' '
+ git tag -m atag T &&
+ git cat-file tag T > expect &&
+ git filter-branch -f --tag-name-filter cat &&
+ git cat-file tag T > actual &&
+ test_cmp expect actual
+'
+
+faux_gpg_tag='object XXXXXX
+type commit
+tag S
+tagger T A Gger <tagger@example.com> 1206026339 -0500
+
+This is a faux gpg signed tag.
+-----BEGIN PGP SIGNATURE-----
+Version: FauxGPG v0.0.0 (FAUX/Linux)
+
+gdsfoewhxu/6l06f1kxyxhKdZkrcbaiOMtkJUA9ITAc1mlamh0ooasxkH1XwMbYQ
+acmwXaWET20H0GeAGP+7vow=
+=agpO
+-----END PGP SIGNATURE-----
+'
+test_expect_success 'Tag name filtering strips gpg signature' '
+ sha1=$(git rev-parse HEAD) &&
+ sha1t=$(echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | git mktag) &&
+ git update-ref "refs/tags/S" "$sha1t" &&
+ echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | head -n 6 > expect &&
+ git filter-branch -f --tag-name-filter cat &&
+ git cat-file tag S > actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index df496a95f..8d44c2ed1 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -26,21 +26,21 @@ test_expect_success 'listing all tags in an empty tree should output nothing' '
test `git-tag | wc -l` -eq 0
'
-test_expect_failure 'looking for a tag in an empty tree should fail' \
- 'tag_exists mytag'
+test_expect_success 'looking for a tag in an empty tree should fail' \
+ '! (tag_exists mytag)'
test_expect_success 'creating a tag in an empty tree should fail' '
- ! git-tag mynotag &&
+ test_must_fail git-tag mynotag &&
! tag_exists mynotag
'
test_expect_success 'creating a tag for HEAD in an empty tree should fail' '
- ! git-tag mytaghead HEAD &&
+ test_must_fail git-tag mytaghead HEAD &&
! tag_exists mytaghead
'
test_expect_success 'creating a tag for an unknown revision should fail' '
- ! git-tag mytagnorev aaaaaaaaaaa &&
+ test_must_fail git-tag mytagnorev aaaaaaaaaaa &&
! tag_exists mytagnorev
'
@@ -83,18 +83,18 @@ test_expect_success \
# special cases for creating tags:
-test_expect_failure \
+test_expect_success \
'trying to create a tag with the name of one existing should fail' \
- 'git tag mytag'
+ 'test_must_fail git tag mytag'
test_expect_success \
'trying to create a tag with a non-valid name should fail' '
test `git-tag -l | wc -l` -eq 1 &&
- ! git tag "" &&
- ! git tag .othertag &&
- ! git tag "other tag" &&
- ! git tag "othertag^" &&
- ! git tag "other~tag" &&
+ test_must_fail git tag "" &&
+ test_must_fail git tag .othertag &&
+ test_must_fail git tag "other tag" &&
+ test_must_fail git tag "othertag^" &&
+ test_must_fail git tag "other~tag" &&
test `git-tag -l | wc -l` -eq 1
'
@@ -107,7 +107,7 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
test_expect_success 'trying to delete an unknown tag should fail' '
! tag_exists unknown-tag &&
- ! git-tag -d unknown-tag
+ test_must_fail git-tag -d unknown-tag
'
cat >expect <<EOF
@@ -116,9 +116,9 @@ mytag
EOF
test_expect_success \
'trying to delete tags without params should succeed and do nothing' '
- git tag -l > actual && git diff expect actual &&
+ git tag -l > actual && test_cmp expect actual &&
git-tag -d &&
- git tag -l > actual && git diff expect actual
+ git tag -l > actual && test_cmp expect actual
'
test_expect_success \
@@ -141,13 +141,13 @@ test_expect_success \
'trying to delete two tags, existing and not, should fail in the 2nd' '
tag_exists mytag &&
! tag_exists myhead &&
- ! git-tag -d mytag anothertag &&
+ test_must_fail git-tag -d mytag anothertag &&
! tag_exists mytag &&
! tag_exists myhead
'
-test_expect_failure 'trying to delete an already deleted tag should fail' \
- 'git-tag -d mytag'
+test_expect_success 'trying to delete an already deleted tag should fail' \
+ 'test_must_fail git-tag -d mytag'
# listing various tags with pattern matching:
@@ -173,9 +173,9 @@ test_expect_success 'listing all tags should print them ordered' '
git tag v1.0 &&
git tag t210 &&
git tag -l > actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git tag > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -186,7 +186,7 @@ EOF
test_expect_success \
'listing tags with substring as pattern must print those matching' '
git-tag -l "*a*" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -196,7 +196,7 @@ EOF
test_expect_success \
'listing tags with a suffix as pattern must print those matching' '
git-tag -l "*.1" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -206,7 +206,7 @@ EOF
test_expect_success \
'listing tags with a prefix as pattern must print those matching' '
git-tag -l "t21*" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -215,7 +215,7 @@ EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
git-tag -l a1 > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -224,7 +224,7 @@ EOF
test_expect_success \
'listing tags using a name as pattern must print that one matching' '
git-tag -l v1.0 > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -234,14 +234,14 @@ EOF
test_expect_success \
'listing tags with ? in the pattern should print those matching' '
git-tag -l "v1.?.?" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
>expect
test_expect_success \
'listing tags using v.* should print nothing because none have v.' '
git-tag -l "v.*" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >expect <<EOF
@@ -253,7 +253,7 @@ EOF
test_expect_success \
'listing tags using v* should print only those having v' '
git-tag -l "v*" > actual &&
- git diff expect actual
+ test_cmp expect actual
'
# creating and verifying lightweight tags:
@@ -265,16 +265,16 @@ test_expect_success \
test $(git rev-parse non-annotated-tag) = $(git rev-parse HEAD)
'
-test_expect_failure 'trying to verify an unknown tag should fail' \
- 'git-tag -v unknown-tag'
+test_expect_success 'trying to verify an unknown tag should fail' \
+ 'test_must_fail git-tag -v unknown-tag'
-test_expect_failure \
+test_expect_success \
'trying to verify a non-annotated and non-signed tag should fail' \
- 'git-tag -v non-annotated-tag'
+ 'test_must_fail git-tag -v non-annotated-tag'
-test_expect_failure \
+test_expect_success \
'trying to verify many non-annotated or unknown tags, should fail' \
- 'git-tag -v unknown-tag1 non-annotated-tag unknown-tag2'
+ 'test_must_fail git-tag -v unknown-tag1 non-annotated-tag unknown-tag2'
# creating annotated tags:
@@ -302,7 +302,7 @@ test_expect_success \
'creating an annotated tag with -m message should succeed' '
git-tag -m "A message" annotated-tag &&
get_tag_msg annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >msgfile <<EOF
@@ -315,7 +315,7 @@ test_expect_success \
'creating an annotated tag with -F messagefile should succeed' '
git-tag -F msgfile file-annotated-tag &&
get_tag_msg file-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >inputmsg <<EOF
@@ -327,14 +327,14 @@ cat inputmsg >>expect
test_expect_success 'creating an annotated tag with -F - should succeed' '
git-tag -F - stdin-annotated-tag <inputmsg &&
get_tag_msg stdin-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'trying to create a tag with a non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists notag &&
- ! git-tag -F nonexistingfile notag &&
+ test_must_fail git-tag -F nonexistingfile notag &&
! tag_exists notag
'
@@ -343,11 +343,12 @@ test_expect_success \
echo "message file 1" >msgfile1 &&
echo "message file 2" >msgfile2 &&
! tag_exists msgtag &&
- ! git-tag -m "message 1" -F msgfile1 msgtag &&
+ test_must_fail git-tag -m "message 1" -F msgfile1 msgtag &&
! tag_exists msgtag &&
- ! git-tag -F msgfile1 -m "message 1" msgtag &&
+ test_must_fail git-tag -F msgfile1 -m "message 1" msgtag &&
! tag_exists msgtag &&
- ! git-tag -m "message 1" -F msgfile1 -m "message 2" msgtag &&
+ test_must_fail git-tag -m "message 1" -F msgfile1 \
+ -m "message 2" msgtag &&
! tag_exists msgtag
'
@@ -358,7 +359,7 @@ test_expect_success \
'creating a tag with an empty -m message should succeed' '
git-tag -m "" empty-annotated-tag &&
get_tag_msg empty-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
>emptyfile
@@ -367,7 +368,7 @@ test_expect_success \
'creating a tag with an empty -F messagefile should succeed' '
git-tag -F emptyfile emptyfile-annotated-tag &&
get_tag_msg emptyfile-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
printf '\n\n \n\t\nLeading blank lines\n' >blanksfile
@@ -388,7 +389,7 @@ test_expect_success \
'extra blanks in the message for an annotated tag should be removed' '
git-tag -F blanksfile blanks-annotated-tag &&
get_tag_msg blanks-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header blank-annotated-tag $commit commit $time >expect
@@ -396,7 +397,7 @@ test_expect_success \
'creating a tag with blank -m message with spaces should succeed' '
git-tag -m " " blank-annotated-tag &&
get_tag_msg blank-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
echo ' ' >blankfile
@@ -407,7 +408,7 @@ test_expect_success \
'creating a tag with blank -F messagefile with spaces should succeed' '
git-tag -F blankfile blankfile-annotated-tag &&
get_tag_msg blankfile-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
printf ' ' >blanknonlfile
@@ -416,7 +417,7 @@ test_expect_success \
'creating a tag with -F file of spaces and no newline should succeed' '
git-tag -F blanknonlfile blanknonlfile-annotated-tag &&
get_tag_msg blanknonlfile-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
# messages with commented lines:
@@ -451,7 +452,7 @@ test_expect_success \
'creating a tag using a -F messagefile with #comments should succeed' '
git-tag -F commentsfile comments-annotated-tag &&
get_tag_msg comments-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header comment-annotated-tag $commit commit $time >expect
@@ -459,7 +460,7 @@ test_expect_success \
'creating a tag with a #comment in the -m message should succeed' '
git-tag -m "#comment" comment-annotated-tag &&
get_tag_msg comment-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
echo '#comment' >commentfile
@@ -470,7 +471,7 @@ test_expect_success \
'creating a tag with #comments in the -F messagefile should succeed' '
git-tag -F commentfile commentfile-annotated-tag &&
get_tag_msg commentfile-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
printf '#comment' >commentnonlfile
@@ -479,7 +480,7 @@ test_expect_success \
'creating a tag with a file of #comment and no newline should succeed' '
git-tag -F commentnonlfile commentnonlfile-annotated-tag &&
get_tag_msg commentnonlfile-annotated-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
# listing messages for annotated non-signed tags:
@@ -490,23 +491,23 @@ test_expect_success \
echo "tag-one-line" >expect &&
git-tag -l | grep "^tag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^tag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l tag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "tag-one-line A msg" >expect &&
git-tag -n1 -l | grep "^tag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^tag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l tag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l tag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n999 -l tag-one-line >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
@@ -515,23 +516,23 @@ test_expect_success \
echo "tag-zero-lines" >expect &&
git-tag -l | grep "^tag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^tag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l tag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "tag-zero-lines " >expect &&
git-tag -n1 -l | grep "^tag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^tag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l tag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l tag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n999 -l tag-zero-lines >actual &&
- git diff expect actual
+ test_cmp expect actual
'
echo 'tag line one' >annotagmsg
@@ -543,70 +544,71 @@ test_expect_success \
echo "tag-lines" >expect &&
git-tag -l | grep "^tag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^tag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l tag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "tag-lines tag line one" >expect &&
git-tag -n1 -l | grep "^tag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^tag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l tag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo " tag line two" >>expect &&
git-tag -n2 -l | grep "^ *tag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l tag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo " tag line three" >>expect &&
git-tag -n3 -l | grep "^ *tag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n3 -l tag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n4 -l | grep "^ *tag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n4 -l tag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n99 -l | grep "^ *tag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n99 -l tag-lines >actual &&
- git diff expect actual
+ test_cmp expect actual
'
+# subsequent tests require gpg; check if it is available
+gpg --version >/dev/null
+if [ $? -eq 127 ]; then
+ echo "gpg not found - skipping tag signing and verification tests"
+ test_done
+ exit
+fi
+
# trying to verify annotated non-signed tags:
test_expect_success \
'trying to verify an annotated non-signed tag should fail' '
tag_exists annotated-tag &&
- ! git-tag -v annotated-tag
+ test_must_fail git-tag -v annotated-tag
'
test_expect_success \
'trying to verify a file-annotated non-signed tag should fail' '
tag_exists file-annotated-tag &&
- ! git-tag -v file-annotated-tag
+ test_must_fail git-tag -v file-annotated-tag
'
test_expect_success \
'trying to verify two annotated non-signed tags should fail' '
tag_exists annotated-tag file-annotated-tag &&
- ! git-tag -v annotated-tag file-annotated-tag
+ test_must_fail git-tag -v annotated-tag file-annotated-tag
'
# creating and verifying signed tags:
-gpg --version >/dev/null
-if [ $? -eq 127 ]; then
- echo "Skipping signed tags tests, because gpg was not found"
- test_done
- exit
-fi
-
# As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
# the gpg version 1.0.6 didn't parse trust packets correctly, so for
# that version, creation of signed tags using the generated key fails.
@@ -625,7 +627,8 @@ esac
cp -R ../t7004 ./gpghome
chmod 0700 gpghome
-export GNUPGHOME="$(pwd)/gpghome"
+GNUPGHOME="$(pwd)/gpghome"
+export GNUPGHOME
get_tag_header signed-tag $commit commit $time >expect
echo 'A signed tag message' >>expect
@@ -633,7 +636,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success 'creating a signed tag with -m message should succeed' '
git-tag -s -m "A signed tag message" signed-tag &&
get_tag_msg signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header u-signed-tag $commit commit $time >expect
@@ -643,19 +646,20 @@ test_expect_success 'sign with a given key id' '
git tag -u committer@example.com -m "Another message" u-signed-tag &&
get_tag_msg u-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success 'sign with an unknown id (1)' '
- ! git tag -u author@example.com -m "Another message" o-signed-tag
+ test_must_fail git tag -u author@example.com \
+ -m "Another message" o-signed-tag
'
test_expect_success 'sign with an unknown id (2)' '
- ! git tag -u DEADBEEF -m "Another message" o-signed-tag
+ test_must_fail git tag -u DEADBEEF -m "Another message" o-signed-tag
'
@@ -673,7 +677,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success '-u implies signed tag' '
GIT_EDITOR=./fakeeditor git-tag -u CDDE430D implied-sign &&
get_tag_msg implied-sign >actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >sigmsgfile <<EOF
@@ -687,7 +691,7 @@ test_expect_success \
'creating a signed tag with -F messagefile should succeed' '
git-tag -s -F sigmsgfile file-signed-tag &&
get_tag_msg file-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
cat >siginputmsg <<EOF
@@ -700,7 +704,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success 'creating a signed tag with -F - should succeed' '
git-tag -s -F - stdin-signed-tag <siginputmsg &&
get_tag_msg stdin-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header implied-annotate $commit commit $time >expect
@@ -709,14 +713,14 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
test_expect_success '-s implies annotated tag' '
GIT_EDITOR=./fakeeditor git-tag -s implied-annotate &&
get_tag_msg implied-annotate >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
'trying to create a signed tag with non-existing -F file should fail' '
! test -f nonexistingfile &&
! tag_exists nosigtag &&
- ! git-tag -s -F nonexistingfile nosigtag &&
+ test_must_fail git-tag -s -F nonexistingfile nosigtag &&
! tag_exists nosigtag
'
@@ -728,10 +732,11 @@ test_expect_success 'verifying two signed tags in one command should succeed' \
test_expect_success \
'verifying many signed and non-signed tags should fail' '
- ! git-tag -v signed-tag annotated-tag &&
- ! git-tag -v file-annotated-tag file-signed-tag &&
- ! git-tag -v annotated-tag file-signed-tag file-annotated-tag &&
- ! git-tag -v signed-tag annotated-tag file-signed-tag
+ test_must_fail git-tag -v signed-tag annotated-tag &&
+ test_must_fail git-tag -v file-annotated-tag file-signed-tag &&
+ test_must_fail git-tag -v annotated-tag \
+ file-signed-tag file-annotated-tag &&
+ test_must_fail git-tag -v signed-tag annotated-tag file-signed-tag
'
test_expect_success 'verifying a forged tag should fail' '
@@ -739,7 +744,7 @@ test_expect_success 'verifying a forged tag should fail' '
sed -e "s/signed-tag/forged-tag/" |
git mktag) &&
git tag forged-tag $forged &&
- ! git-tag -v forged-tag
+ test_must_fail git-tag -v forged-tag
'
# blank and empty messages for signed tags:
@@ -750,7 +755,7 @@ test_expect_success \
'creating a signed tag with an empty -m message should succeed' '
git-tag -s -m "" empty-signed-tag &&
get_tag_msg empty-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v empty-signed-tag
'
@@ -761,7 +766,7 @@ test_expect_success \
'creating a signed tag with an empty -F messagefile should succeed' '
git-tag -s -F sigemptyfile emptyfile-signed-tag &&
get_tag_msg emptyfile-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v emptyfile-signed-tag
'
@@ -784,7 +789,7 @@ test_expect_success \
'extra blanks in the message for a signed tag should be removed' '
git-tag -s -F sigblanksfile blanks-signed-tag &&
get_tag_msg blanks-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v blanks-signed-tag
'
@@ -794,7 +799,7 @@ test_expect_success \
'creating a signed tag with a blank -m message should succeed' '
git-tag -s -m " " blank-signed-tag &&
get_tag_msg blank-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v blank-signed-tag
'
@@ -807,7 +812,7 @@ test_expect_success \
'creating a signed tag with blank -F file with spaces should succeed' '
git-tag -s -F sigblankfile blankfile-signed-tag &&
get_tag_msg blankfile-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v blankfile-signed-tag
'
@@ -818,7 +823,7 @@ test_expect_success \
'creating a signed tag with spaces and no newline should succeed' '
git-tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
get_tag_msg blanknonlfile-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v signed-tag
'
@@ -855,7 +860,7 @@ test_expect_success \
'creating a signed tag with a -F file with #comments should succeed' '
git-tag -s -F sigcommentsfile comments-signed-tag &&
get_tag_msg comments-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v comments-signed-tag
'
@@ -865,7 +870,7 @@ test_expect_success \
'creating a signed tag with #commented -m message should succeed' '
git-tag -s -m "#comment" comment-signed-tag &&
get_tag_msg comment-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v comment-signed-tag
'
@@ -878,7 +883,7 @@ test_expect_success \
'creating a signed tag with #commented -F messagefile should succeed' '
git-tag -s -F sigcommentfile commentfile-signed-tag &&
get_tag_msg commentfile-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v commentfile-signed-tag
'
@@ -889,7 +894,7 @@ test_expect_success \
'creating a signed tag with a #comment and no newline should succeed' '
git-tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
get_tag_msg commentnonlfile-signed-tag >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -v commentnonlfile-signed-tag
'
@@ -901,23 +906,23 @@ test_expect_success \
echo "stag-one-line" >expect &&
git-tag -l | grep "^stag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^stag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l stag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "stag-one-line A message line signed" >expect &&
git-tag -n1 -l | grep "^stag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^stag-one-line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l stag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l stag-one-line >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n999 -l stag-one-line >actual &&
- git diff expect actual
+ test_cmp expect actual
'
test_expect_success \
@@ -926,23 +931,23 @@ test_expect_success \
echo "stag-zero-lines" >expect &&
git-tag -l | grep "^stag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^stag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l stag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "stag-zero-lines " >expect &&
git-tag -n1 -l | grep "^stag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^stag-zero-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l stag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l stag-zero-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n999 -l stag-zero-lines >actual &&
- git diff expect actual
+ test_cmp expect actual
'
echo 'stag line one' >sigtagmsg
@@ -954,39 +959,39 @@ test_expect_success \
echo "stag-lines" >expect &&
git-tag -l | grep "^stag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l | grep "^stag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n0 -l stag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo "stag-lines stag line one" >expect &&
git-tag -n1 -l | grep "^stag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n -l | grep "^stag-lines" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n1 -l stag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo " stag line two" >>expect &&
git-tag -n2 -l | grep "^ *stag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n2 -l stag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
echo " stag line three" >>expect &&
git-tag -n3 -l | grep "^ *stag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n3 -l stag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n4 -l | grep "^ *stag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n4 -l stag-lines >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n99 -l | grep "^ *stag.line" >actual &&
- git diff expect actual &&
+ test_cmp expect actual &&
git-tag -n99 -l stag-lines >actual &&
- git diff expect actual
+ test_cmp expect actual
'
# tags pointing to objects different from commits:
@@ -1002,7 +1007,7 @@ test_expect_success \
'creating a signed tag pointing to a tree should succeed' '
git-tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
get_tag_msg tree-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header blob-signed-tag $blob blob $time >expect
@@ -1012,7 +1017,7 @@ test_expect_success \
'creating a signed tag pointing to a blob should succeed' '
git-tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
get_tag_msg blob-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
get_tag_header tag-signed-tag $tag tag $time >expect
@@ -1022,26 +1027,26 @@ test_expect_success \
'creating a signed tag pointing to another tag should succeed' '
git-tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
get_tag_msg tag-signed-tag >actual &&
- git diff expect actual
+ test_cmp expect actual
'
# try to sign with bad user.signingkey
git config user.signingkey BobTheMouse
-test_expect_failure \
+test_expect_success \
'git-tag -s fails if gpg is misconfigured' \
- 'git tag -s -m tail tag-gpg-failure'
+ 'test_must_fail git tag -s -m tail tag-gpg-failure'
git config --unset user.signingkey
# try to verify without gpg:
rm -rf gpghome
-test_expect_failure \
+test_expect_success \
'verify signed tag fails when public key is not present' \
- 'git-tag -v signed-tag'
+ 'test_must_fail git-tag -v signed-tag'
-test_expect_failure \
+test_expect_success \
'git-tag -a fails if tag annotation is empty' '
- GIT_EDITOR=cat git tag -a initial-comment
+ ! (GIT_EDITOR=cat git tag -a initial-comment)
'
test_expect_success \
@@ -1062,7 +1067,27 @@ test_expect_success \
git tag -a -m "An annotation to be reused" reuse &&
GIT_EDITOR=true git tag -f -a reuse &&
get_tag_msg reuse >actual &&
- git diff expect actual
+ test_cmp expect actual
+'
+
+test_expect_success 'filename for the message is relative to cwd' '
+ mkdir subdir &&
+ echo "Tag message in top directory" >msgfile-5 &&
+ echo "Tag message in sub directory" >subdir/msgfile-5 &&
+ (
+ cd subdir &&
+ git tag -a -F msgfile-5 tag-from-subdir
+ ) &&
+ git cat-file tag tag-from-subdir | grep "in sub directory"
+'
+
+test_expect_success 'filename for the message is relative to cwd' '
+ echo "Tag message in sub directory" >subdir/msgfile-6 &&
+ (
+ cd subdir &&
+ git tag -a -F msgfile-6 tag-from-subdir-2
+ ) &&
+ git cat-file tag tag-from-subdir-2 | grep "in sub directory"
'
test_done
diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
index c1cec5530..2d919d69e 100755
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -4,8 +4,6 @@ test_description='GIT_EDITOR, core.editor, and stuff'
. ./test-lib.sh
-OLD_TERM="$TERM"
-
for i in GIT_EDITOR core_editor EDITOR VISUAL vi
do
cat >e-$i.sh <<-EOF
@@ -89,6 +87,31 @@ do
'
done
-TERM="$OLD_TERM"
+test_expect_success 'editor with a space' '
+
+ if echo "echo space > \"\$1\"" > "e space.sh"
+ then
+ chmod a+x "e space.sh" &&
+ GIT_EDITOR="./e\ space.sh" git commit --amend &&
+ test space = "$(git show -s --pretty=format:%s)"
+ else
+ say "Skipping; FS does not support spaces in filenames"
+ fi
+
+'
+
+unset GIT_EDITOR
+test_expect_success 'core.editor with a space' '
+
+ if test -f "e space.sh"
+ then
+ git config core.editor \"./e\ space.sh\" &&
+ git commit --amend &&
+ test space = "$(git show -s --pretty=format:%s)"
+ else
+ say "Skipping; FS does not support spaces in filenames"
+ fi
+
+'
test_done
diff --git a/t/t7010-setup.sh b/t/t7010-setup.sh
new file mode 100755
index 000000000..d8a7c7985
--- /dev/null
+++ b/t/t7010-setup.sh
@@ -0,0 +1,165 @@
+#!/bin/sh
+
+test_description='setup taking and sanitizing funny paths'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ mkdir -p a/b/c a/e &&
+ D=$(pwd) &&
+ >a/b/c/d &&
+ >a/e/f
+
+'
+
+test_expect_success 'git add (absolute)' '
+
+ git add "$D/a/b/c/d" &&
+ git ls-files >current &&
+ echo a/b/c/d >expect &&
+ test_cmp expect current
+
+'
+
+
+test_expect_success 'git add (funny relative)' '
+
+ rm -f .git/index &&
+ (
+ cd a/b &&
+ git add "../e/./f"
+ ) &&
+ git ls-files >current &&
+ echo a/e/f >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git rm (absolute)' '
+
+ rm -f .git/index &&
+ git add a &&
+ git rm -f --cached "$D/a/b/c/d" &&
+ git ls-files >current &&
+ echo a/e/f >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git rm (funny relative)' '
+
+ rm -f .git/index &&
+ git add a &&
+ (
+ cd a/b &&
+ git rm -f --cached "../e/./f"
+ ) &&
+ git ls-files >current &&
+ echo a/b/c/d >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git ls-files (absolute)' '
+
+ rm -f .git/index &&
+ git add a &&
+ git ls-files "$D/a/e/../b" >current &&
+ echo a/b/c/d >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git ls-files (relative #1)' '
+
+ rm -f .git/index &&
+ git add a &&
+ (
+ cd a/b &&
+ git ls-files "../b/c"
+ ) >current &&
+ echo c/d >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git ls-files (relative #2)' '
+
+ rm -f .git/index &&
+ git add a &&
+ (
+ cd a/b &&
+ git ls-files --full-name "../e/f"
+ ) >current &&
+ echo a/e/f >expect &&
+ test_cmp expect current
+
+'
+
+test_expect_success 'git ls-files (relative #3)' '
+
+ rm -f .git/index &&
+ git add a &&
+ (
+ cd a/b &&
+ if git ls-files "../e/f"
+ then
+ echo Gaah, should have failed
+ exit 1
+ else
+ : happy
+ fi
+ )
+
+'
+
+test_expect_success 'commit using absolute path names' '
+ git commit -m "foo" &&
+ echo aa >>a/b/c/d &&
+ git commit -m "aa" "$(pwd)/a/b/c/d"
+'
+
+test_expect_success 'log using absolute path names' '
+ echo bb >>a/b/c/d &&
+ git commit -m "bb" "$(pwd)/a/b/c/d" &&
+
+ git log a/b/c/d >f1.txt &&
+ git log "$(pwd)/a/b/c/d" >f2.txt &&
+ test_cmp f1.txt f2.txt
+'
+
+test_expect_success 'blame using absolute path names' '
+ git blame a/b/c/d >f1.txt &&
+ git blame "$(pwd)/a/b/c/d" >f2.txt &&
+ test_cmp f1.txt f2.txt
+'
+
+test_expect_success 'setup deeper work tree' '
+ test_create_repo tester
+'
+
+test_expect_success 'add a directory outside the work tree' '(
+ cd tester &&
+ d1="$(cd .. ; pwd)" &&
+ test_must_fail git add "$d1"
+)'
+
+
+test_expect_success 'add a file outside the work tree, nasty case 1' '(
+ cd tester &&
+ f="$(pwd)x" &&
+ echo "$f" &&
+ touch "$f" &&
+ test_must_fail git add "$f"
+)'
+
+test_expect_success 'add a file outside the work tree, nasty case 2' '(
+ cd tester &&
+ f="$(pwd | sed "s/.$//")x" &&
+ echo "$f" &&
+ touch "$f" &&
+ test_must_fail git add "$f"
+)'
+
+test_done
diff --git a/t/t7101-reset.sh b/t/t7101-reset.sh
index 66d40430b..0d9874bfd 100755
--- a/t/t7101-reset.sh
+++ b/t/t7101-reset.sh
@@ -36,28 +36,28 @@ test_expect_success \
'test -d path0 &&
test -f path0/COPYING'
-test_expect_failure \
+test_expect_success \
'checking lack of path1/path2/COPYING' \
- 'test -f path1/path2/COPYING'
+ '! test -f path1/path2/COPYING'
-test_expect_failure \
+test_expect_success \
'checking lack of path1/COPYING' \
- 'test -f path1/COPYING'
+ '! test -f path1/COPYING'
-test_expect_failure \
+test_expect_success \
'checking lack of COPYING' \
- 'test -f COPYING'
+ '! test -f COPYING'
-test_expect_failure \
+test_expect_success \
'checking checking lack of path1/COPYING-TOO' \
- 'test -f path0/COPYING-TOO'
+ '! test -f path0/COPYING-TOO'
-test_expect_failure \
+test_expect_success \
'checking lack of path1/path2' \
- 'test -d path1/path2'
+ '! test -d path1/path2'
-test_expect_failure \
+test_expect_success \
'checking lack of path1' \
- 'test -d path1'
+ '! test -d path1'
test_done
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index e5c9f30c7..29f5678b4 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -34,13 +34,13 @@ test_expect_success 'creating initial files and commits' '
check_changes () {
test "$(git rev-parse HEAD)" = "$1" &&
- git diff | git diff .diff_expect - &&
- git diff --cached | git diff .cached_expect - &&
+ git diff | test_cmp .diff_expect - &&
+ git diff --cached | test_cmp .cached_expect - &&
for FILE in *
do
echo $FILE':'
cat $FILE || return
- done | git diff .cat_expect -
+ done | test_cmp .cat_expect -
}
>.diff_expect
@@ -52,10 +52,10 @@ secondfile:
EOF
test_expect_success 'giving a non existing revision should fail' '
- ! git reset aaaaaa &&
- ! git reset --mixed aaaaaa &&
- ! git reset --soft aaaaaa &&
- ! git reset --hard aaaaaa &&
+ test_must_fail git reset aaaaaa &&
+ test_must_fail git reset --mixed aaaaaa &&
+ test_must_fail git reset --soft aaaaaa &&
+ test_must_fail git reset --hard aaaaaa &&
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
'
@@ -63,29 +63,29 @@ test_expect_success 'reset --soft with unmerged index should fail' '
touch .git/MERGE_HEAD &&
echo "100644 44c5b5884550c17758737edcced463447b91d42b 1 un" |
git update-index --index-info &&
- ! git reset --soft HEAD &&
+ test_must_fail git reset --soft HEAD &&
rm .git/MERGE_HEAD &&
git rm --cached -- un
'
test_expect_success \
'giving paths with options different than --mixed should fail' '
- ! git reset --soft -- first &&
- ! git reset --hard -- first &&
- ! git reset --soft HEAD^ -- first &&
- ! git reset --hard HEAD^ -- first &&
+ test_must_fail git reset --soft -- first &&
+ 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
'
test_expect_success 'giving unrecognized options should fail' '
- ! git reset --other &&
- ! git reset -o &&
- ! git reset --mixed --other &&
- ! git reset --mixed -o &&
- ! git reset --soft --other &&
- ! git reset --soft -o &&
- ! git reset --hard --other &&
- ! git reset --hard -o &&
+ test_must_fail git reset --other &&
+ test_must_fail git reset -o &&
+ test_must_fail git reset --mixed --other &&
+ test_must_fail git reset --mixed -o &&
+ test_must_fail git reset --soft --other &&
+ test_must_fail git reset --soft -o &&
+ test_must_fail git reset --hard --other &&
+ test_must_fail git reset --hard -o &&
check_changes 3ec39651e7f44ea531a5de18a9fa791c0fd370fc
'
@@ -102,8 +102,8 @@ test_expect_success \
echo "3rd line in branch2" >>secondfile &&
git commit -a -m "change in branch2" &&
- ! git merge branch1 &&
- ! git reset --soft &&
+ test_must_fail git merge branch1 &&
+ test_must_fail git reset --soft &&
printf "1st line 2nd file\n2nd line 2nd file\n3rd line" >secondfile &&
git commit -a -m "the change in branch2" &&
@@ -126,7 +126,7 @@ test_expect_success \
echo "3rd line in branch4" >>secondfile &&
git checkout -m branch3 &&
- ! git reset --soft &&
+ test_must_fail git reset --soft &&
printf "1st line 2nd file\n2nd line 2nd file\n3rd line" >secondfile &&
git commit -a -m "the line in branch3" &&
@@ -326,7 +326,7 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
echo "3rd line in branch2" >>secondfile &&
git commit -a -m "change in branch2" &&
- ! git pull . branch1 &&
+ test_must_fail git pull . branch1 &&
git reset --hard &&
check_changes 77abb337073fb4369a7ad69ff6f5ec0e4d6b54bb
'
@@ -388,11 +388,11 @@ test_expect_success 'test --mixed <paths>' '
echo 4 > file4 &&
echo 5 > file1 &&
git add file1 file3 file4 &&
- ! git reset HEAD -- file1 file2 file3 &&
+ test_must_fail git reset HEAD -- file1 file2 file3 &&
git diff > output &&
- git diff output expect &&
+ test_cmp output expect &&
git diff --cached > output &&
- git diff output cached_expect
+ test_cmp output cached_expect
'
test_expect_success 'test resetting the index at give paths' '
@@ -402,11 +402,11 @@ test_expect_success 'test resetting the index at give paths' '
>sub/file2 &&
git update-index --add sub/file1 sub/file2 &&
T=$(git write-tree) &&
- ! git reset HEAD sub/file2 &&
+ test_must_fail git reset HEAD sub/file2 &&
U=$(git write-tree) &&
echo "$T" &&
echo "$U" &&
- ! git diff-index --cached --exit-code "$T" &&
+ test_must_fail git diff-index --cached --exit-code "$T" &&
test "$T" != "$U"
'
@@ -419,13 +419,60 @@ test_expect_success 'resetting an unmodified path is a no-op' '
'
cat > expect << EOF
-file2: needs update
+file2: locally modified
EOF
test_expect_success '--mixed refreshes the index' '
echo 123 >> file2 &&
git reset --mixed HEAD > output &&
- git diff --exit-code expect output
+ test_cmp expect output
+'
+
+test_expect_success 'disambiguation (1)' '
+
+ git reset --hard &&
+ >secondfile &&
+ git add secondfile &&
+ test_must_fail git reset secondfile &&
+ test -z "$(git diff --cached --name-only)" &&
+ test -f secondfile &&
+ test ! -s secondfile
+
+'
+
+test_expect_success 'disambiguation (2)' '
+
+ git reset --hard &&
+ >secondfile &&
+ git add secondfile &&
+ rm -f secondfile &&
+ test_must_fail git reset secondfile &&
+ test -n "$(git diff --cached --name-only -- secondfile)" &&
+ test ! -f secondfile
+
+'
+
+test_expect_success 'disambiguation (3)' '
+
+ git reset --hard &&
+ >secondfile &&
+ git add secondfile &&
+ rm -f secondfile &&
+ test_must_fail git reset HEAD secondfile &&
+ test -z "$(git diff --cached --name-only)" &&
+ test ! -f secondfile
+
+'
+
+test_expect_success 'disambiguation (4)' '
+
+ git reset --hard &&
+ >secondfile &&
+ git add secondfile &&
+ rm -f secondfile &&
+ test_must_fail git reset -- secondfile &&
+ test -z "$(git diff --cached --name-only)" &&
+ test ! -f secondfile
'
test_done
diff --git a/t/t7103-reset-bare.sh b/t/t7103-reset-bare.sh
index b25a77f91..cdecebe45 100755
--- a/t/t7103-reset-bare.sh
+++ b/t/t7103-reset-bare.sh
@@ -17,7 +17,7 @@ test_expect_success 'setup bare' '
'
test_expect_success 'hard reset is not allowed' '
- ! git reset --hard HEAD^
+ test_must_fail git reset --hard HEAD^
'
test_expect_success 'soft reset is allowed' '
diff --git a/t/t7104-reset.sh b/t/t7104-reset.sh
new file mode 100755
index 000000000..f136ee7bb
--- /dev/null
+++ b/t/t7104-reset.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+test_description='reset --hard unmerged'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ mkdir before later &&
+ >before/1 &&
+ >before/2 &&
+ >hello &&
+ >later/3 &&
+ git add before hello later &&
+ git commit -m world &&
+
+ H=$(git rev-parse :hello) &&
+ git rm --cached hello &&
+ echo "100644 $H 2 hello" | git update-index --index-info &&
+
+ rm -f hello &&
+ mkdir -p hello &&
+ >hello/world &&
+ test "$(git ls-files -o)" = hello/world
+
+'
+
+test_expect_success 'reset --hard should restore unmerged ones' '
+
+ git reset --hard &&
+ git ls-files --error-unmatch before/1 before/2 hello later/3 &&
+ test -f hello
+
+'
+
+test_expect_success 'reset --hard did not corrupt index nor cached-tree' '
+
+ T=$(git write-tree) &&
+ rm -f .git/index &&
+ git add before hello later &&
+ U=$(git write-tree) &&
+ test "$T" = "$U"
+
+'
+
+test_done
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 5492f21c7..9ad5d635a 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -83,13 +83,13 @@ test_expect_success "checkout with unrelated dirty tree without -m" '
fill 0 1 2 3 4 5 6 7 8 >same &&
cp same kept
git checkout side >messages &&
- diff -u same kept
+ test_cmp same kept
(cat > messages.expect <<EOF
M same
EOF
) &&
touch messages.expect &&
- diff -u messages.expect messages
+ test_cmp messages.expect messages
'
test_expect_success "checkout -m with dirty tree" '
@@ -106,19 +106,19 @@ test_expect_success "checkout -m with dirty tree" '
M one
EOF
) &&
- diff -u expect.messages messages &&
+ test_cmp expect.messages messages &&
fill "M one" "A three" "D two" >expect.master &&
git diff --name-status master >current.master &&
- diff -u expect.master current.master &&
+ test_cmp expect.master current.master &&
fill "M one" >expect.side &&
git diff --name-status side >current.side &&
- diff -u expect.side current.side &&
+ test_cmp expect.side current.side &&
: >expect.index &&
git diff --cached >current.index &&
- diff -u expect.index current.index
+ test_cmp expect.index current.index
'
test_expect_success "checkout -m with dirty tree, renamed" '
@@ -136,7 +136,7 @@ test_expect_success "checkout -m with dirty tree, renamed" '
git checkout -m renamer &&
fill 1 3 4 5 7 8 >expect &&
- diff -u expect uno &&
+ test_cmp expect uno &&
! test -f one &&
git diff --cached >current &&
! test -s current
@@ -161,7 +161,7 @@ test_expect_success 'checkout -m with merge conflict' '
git diff master:one :3:uno |
sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
fill d2 aT d7 aS >expect &&
- diff -u current expect &&
+ test_cmp current expect &&
git diff --cached two >current &&
! test -s current
'
@@ -178,7 +178,7 @@ If you want to create a new branch from this checkout, you may do so
HEAD is now at 7329388... Initial A one, A two
EOF
) &&
- diff -u messages.expect messages &&
+ test_cmp messages.expect messages &&
H=$(git rev-parse --verify HEAD) &&
M=$(git show-ref -s --verify refs/heads/master) &&
test "z$H" = "z$M" &&
@@ -207,6 +207,22 @@ test_expect_success 'checkout to detach HEAD with branchname^' '
fi
'
+test_expect_success 'checkout to detach HEAD with :/message' '
+
+ git checkout -f master && git clean -f &&
+ git checkout ":/Initial" &&
+ H=$(git rev-parse --verify HEAD) &&
+ M=$(git show-ref -s --verify refs/heads/master) &&
+ test "z$H" = "z$M" &&
+ if git symbolic-ref HEAD >/dev/null 2>&1
+ then
+ echo "OOPS, HEAD is still symbolic???"
+ false
+ else
+ : happy
+ fi
+'
+
test_expect_success 'checkout to detach HEAD with HEAD^0' '
git checkout -f master && git clean -f &&
@@ -263,4 +279,62 @@ test_expect_success 'checkout with ambiguous tag/branch names' '
'
+test_expect_success 'switch branches while in subdirectory' '
+
+ git reset --hard &&
+ git checkout master &&
+
+ mkdir subs &&
+ (
+ cd subs &&
+ git checkout side
+ ) &&
+ ! test -f subs/one &&
+ rm -fr subs
+
+'
+
+test_expect_success 'checkout specific path while in subdirectory' '
+
+ git reset --hard &&
+ git checkout side &&
+ mkdir subs &&
+ >subs/bero &&
+ git add subs/bero &&
+ git commit -m "add subs/bero" &&
+
+ git checkout master &&
+ mkdir -p subs &&
+ (
+ cd subs &&
+ git checkout side -- bero
+ ) &&
+ test -f subs/bero
+
+'
+
+test_expect_success \
+ 'checkout w/--track sets up tracking' '
+ git config branch.autosetupmerge false &&
+ git checkout master &&
+ git checkout --track -b track1 &&
+ test "$(git config branch.track1.remote)" &&
+ test "$(git config branch.track1.merge)"'
+
+test_expect_success \
+ 'checkout w/autosetupmerge=always sets up tracking' '
+ git config branch.autosetupmerge always &&
+ git checkout master &&
+ git checkout -b track2 &&
+ test "$(git config branch.track2.remote)" &&
+ test "$(git config branch.track2.merge)"
+ git config branch.autosetupmerge false'
+
+test_expect_success \
+ 'checkout w/--track from non-branch HEAD fails' '
+ git checkout -b delete-me master &&
+ rm .git/refs/heads/delete-me &&
+ test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
+ test_must_fail git checkout --track -b track'
+
test_done
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index dfd118878..2b51c0d7d 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -75,8 +75,8 @@ test_expect_success 'git-clean src/ src/' '
test_expect_success 'git-clean with prefix' '
- mkdir -p build docs &&
- touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ mkdir -p build docs src/test &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so src/test/1.c &&
(cd src/ && git-clean) &&
test -f Makefile &&
test -f README &&
@@ -84,11 +84,64 @@ test_expect_success 'git-clean with prefix' '
test -f src/part2.c &&
test -f a.out &&
test ! -f src/part3.c &&
+ test -f src/test/1.c &&
test -f docs/manual.txt &&
test -f obj.o &&
test -f build/lib.so
'
+
+test_expect_success 'git-clean with relative prefix' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ would_clean=$(
+ cd docs &&
+ git clean -n ../src |
+ sed -n -e "s|^Would remove ||p"
+ ) &&
+ test "$would_clean" = ../src/part3.c || {
+ echo "OOps <$would_clean>"
+ false
+ }
+'
+
+test_expect_success 'git-clean with absolute path' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ would_clean=$(
+ cd docs &&
+ git clean -n "$(pwd)/../src" |
+ sed -n -e "s|^Would remove ||p"
+ ) &&
+ test "$would_clean" = ../src/part3.c || {
+ echo "OOps <$would_clean>"
+ false
+ }
+'
+
+test_expect_success 'git-clean with out of work tree relative path' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ (
+ cd docs &&
+ test_must_fail git clean -n ../..
+ )
+'
+
+test_expect_success 'git-clean with out of work tree absolute path' '
+
+ mkdir -p build docs &&
+ touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+ dd=$(cd .. && pwd) &&
+ (
+ cd docs &&
+ test_must_fail git clean -n $dd
+ )
+'
+
test_expect_success 'git-clean -d with prefix and path' '
mkdir -p build docs src/feature &&
@@ -263,14 +316,14 @@ test_expect_success 'git-clean -d -X' '
test_expect_success 'clean.requireForce defaults to true' '
git config --unset clean.requireForce &&
- ! git-clean
+ test_must_fail git clean
'
test_expect_success 'clean.requireForce' '
git config clean.requireForce true &&
- ! git-clean
+ test_must_fail git clean
'
@@ -316,4 +369,15 @@ test_expect_success 'core.excludesfile' '
'
+test_expect_success 'removal failure' '
+
+ mkdir foo &&
+ touch foo/bar &&
+ exec <foo/bar &&
+ chmod 0 foo &&
+ test_must_fail git clean -f -d
+
+'
+chmod 755 foo
+
test_done
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 4fe3a41f0..cbc0c34ce 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -13,11 +13,11 @@ subcommands of git-submodule.
#
# Test setup:
-# -create a repository in directory lib
+# -create a repository in directory init
# -add a couple of files
-# -add directory lib to 'superproject', this creates a DIRLINK entry
+# -add directory init to 'superproject', this creates a DIRLINK entry
# -add a couple of regular files to enable testing of submodule filtering
-# -mv lib subrepo
+# -mv init subrepo
# -add an entry to .gitmodules for submodule 'example'
#
test_expect_success 'Prepare submodule testing' '
@@ -25,8 +25,8 @@ test_expect_success 'Prepare submodule testing' '
git-add t &&
git-commit -m "initial commit" &&
git branch initial HEAD &&
- mkdir lib &&
- cd lib &&
+ mkdir init &&
+ cd init &&
git init &&
echo a >a &&
git add a &&
@@ -41,10 +41,10 @@ test_expect_success 'Prepare submodule testing' '
cd .. &&
echo a >a &&
echo z >z &&
- git add a lib z &&
+ git add a init z &&
git-commit -m "super commit 1" &&
- mv lib .subrepo &&
- GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/lib.git
+ mv init .subrepo &&
+ GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
'
test_expect_success 'status should fail for unmapped paths' '
@@ -52,7 +52,7 @@ test_expect_success 'status should fail for unmapped paths' '
then
echo "[OOPS] submodule status succeeded"
false
- elif ! GIT_CONFIG=.gitmodules git config submodule.example.path lib
+ elif ! GIT_CONFIG=.gitmodules git config submodule.example.path init
then
echo "[OOPS] git config failed to update .gitmodules"
false
@@ -71,11 +71,11 @@ test_expect_success 'status should initially be "missing"' '
test_expect_success 'init should register submodule url in .git/config' '
git-submodule init &&
url=$(git config submodule.example.url) &&
- if test "$url" != "git://example.com/lib.git"
+ if test "$url" != "git://example.com/init.git"
then
echo "[OOPS] init succeeded but submodule url is wrong"
false
- elif ! git config submodule.example.url ./.subrepo
+ elif test_must_fail git config submodule.example.url ./.subrepo
then
echo "[OOPS] init succeeded but update of url failed"
false
@@ -83,41 +83,41 @@ test_expect_success 'init should register submodule url in .git/config' '
'
test_expect_success 'update should fail when path is used by a file' '
- echo "hello" >lib &&
+ echo "hello" >init &&
if git-submodule update
then
echo "[OOPS] update should have failed"
false
- elif test "$(cat lib)" != "hello"
+ elif test "$(cat init)" != "hello"
then
- echo "[OOPS] update failed but lib file was molested"
+ echo "[OOPS] update failed but init file was molested"
false
else
- rm lib
+ rm init
fi
'
test_expect_success 'update should fail when path is used by a nonempty directory' '
- mkdir lib &&
- echo "hello" >lib/a &&
+ mkdir init &&
+ echo "hello" >init/a &&
if git-submodule update
then
echo "[OOPS] update should have failed"
false
- elif test "$(cat lib/a)" != "hello"
+ elif test "$(cat init/a)" != "hello"
then
- echo "[OOPS] update failed but lib/a was molested"
+ echo "[OOPS] update failed but init/a was molested"
false
else
- rm lib/a
+ rm init/a
fi
'
test_expect_success 'update should work when path is an empty dir' '
- rm -rf lib &&
- mkdir lib &&
+ rm -rf init &&
+ mkdir init &&
git-submodule update &&
- head=$(cd lib && git rev-parse HEAD) &&
+ head=$(cd init && git rev-parse HEAD) &&
if test -z "$head"
then
echo "[OOPS] Failed to obtain submodule head"
@@ -134,7 +134,7 @@ test_expect_success 'status should be "up-to-date" after update' '
'
test_expect_success 'status should be "modified" after submodule commit' '
- cd lib &&
+ cd init &&
echo b >b &&
git add b &&
git-commit -m "submodule commit 2" &&
@@ -157,8 +157,8 @@ test_expect_success 'git diff should report the SHA1 of the new submodule commit
'
test_expect_success 'update should checkout rev1' '
- git-submodule update &&
- head=$(cd lib && git rev-parse HEAD) &&
+ git-submodule update init &&
+ head=$(cd init && git rev-parse HEAD) &&
if test -z "$head"
then
echo "[OOPS] submodule git rev-parse returned nothing"
@@ -182,13 +182,13 @@ test_expect_success 'checkout superproject with subproject already present' '
test_expect_success 'apply submodule diff' '
git branch second &&
(
- cd lib &&
+ cd init &&
echo s >s &&
git add s &&
git commit -m "change subproject"
) &&
- git update-index --add lib &&
- git-commit -m "change lib" &&
+ git update-index --add init &&
+ git-commit -m "change init" &&
git-format-patch -1 --stdout >P.diff &&
git checkout second &&
git apply --index P.diff &&
@@ -196,4 +196,17 @@ test_expect_success 'apply submodule diff' '
test -z "$D"
'
+test_expect_success 'update --init' '
+
+ mv init init2 &&
+ git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
+ git config --remove-section submodule.example
+ git submodule update init > update.out &&
+ grep "not initialized" update.out &&
+ test ! -d init/.git &&
+ git submodule update --init init &&
+ test -d init/.git
+
+'
+
test_done
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
new file mode 100755
index 000000000..bf12dbdee
--- /dev/null
+++ b/t/t7401-submodule-summary.sh
@@ -0,0 +1,208 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Ping Yin
+#
+
+test_description='Summary support for submodules
+
+This test tries to verify the sanity of summary subcommand of git-submodule.
+'
+
+. ./test-lib.sh
+
+add_file () {
+ sm=$1
+ shift
+ owd=$(pwd)
+ cd "$sm"
+ for name; do
+ echo "$name" > "$name" &&
+ git add "$name" &&
+ test_tick &&
+ git commit -m "Add $name"
+ done >/dev/null
+ git rev-parse --verify HEAD | cut -c1-7
+ cd "$owd"
+}
+commit_file () {
+ test_tick &&
+ git commit "$@" -m "Commit $*" >/dev/null
+}
+
+test_create_repo sm1 &&
+add_file . foo >/dev/null
+
+head1=$(add_file sm1 foo1 foo2)
+
+test_expect_success 'added submodule' "
+ git add sm1 &&
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 0000000...$head1 (2):
+ > Add foo2
+
+EOF
+"
+
+commit_file sm1 &&
+head2=$(add_file sm1 foo3)
+
+test_expect_success 'modified submodule(forward)' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head1...$head2 (1):
+ > Add foo3
+
+EOF
+"
+
+commit_file sm1 &&
+cd sm1 &&
+git reset --hard HEAD~2 >/dev/null &&
+head3=$(git rev-parse --verify HEAD | cut -c1-7) &&
+cd ..
+
+test_expect_success 'modified submodule(backward)' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head2...$head3 (2):
+ < Add foo3
+ < Add foo2
+
+EOF
+"
+
+head4=$(add_file sm1 foo4 foo5) &&
+head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
+test_expect_success 'modified submodule(backward and forward)' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head2...$head4 (4):
+ > Add foo5
+ > Add foo4
+ < Add foo3
+ < Add foo2
+
+EOF
+"
+
+test_expect_success '--summary-limit' "
+ git submodule summary -n 3 >actual &&
+ diff actual - <<-EOF
+* sm1 $head2...$head4 (4):
+ > Add foo5
+ > Add foo4
+ < Add foo3
+
+EOF
+"
+
+commit_file sm1 &&
+mv sm1 sm1-bak &&
+echo sm1 >sm1 &&
+head5=$(git hash-object sm1 | cut -c1-7) &&
+git add sm1 &&
+rm -f sm1 &&
+mv sm1-bak sm1
+
+test_expect_success 'typechanged submodule(submodule->blob), --cached' "
+ git submodule summary --cached >actual &&
+ diff actual - <<-EOF
+* sm1 $head4(submodule)->$head5(blob) (3):
+ < Add foo5
+
+EOF
+"
+
+rm -rf sm1 &&
+git checkout-index sm1
+test_expect_success 'typechanged submodule(submodule->blob)' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head4(submodule)->$head5(blob):
+
+EOF
+"
+
+rm -f sm1 &&
+test_create_repo sm1 &&
+head6=$(add_file sm1 foo6 foo7)
+test_expect_success 'nonexistent commit' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head4...$head6:
+ Warn: sm1 doesn't contain commit $head4_full
+
+EOF
+"
+
+commit_file
+test_expect_success 'typechanged submodule(blob->submodule)' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head5(blob)->$head6(submodule) (2):
+ > Add foo7
+
+EOF
+"
+
+commit_file sm1 &&
+rm -rf sm1
+test_expect_success 'deleted submodule' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+EOF
+"
+
+test_create_repo sm2 &&
+head7=$(add_file sm2 foo8 foo9) &&
+git add sm2
+
+test_expect_success 'multiple submodules' "
+ git submodule summary >actual &&
+ diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+ > Add foo9
+
+EOF
+"
+
+test_expect_success 'path filter' "
+ git submodule summary sm2 >actual &&
+ diff actual - <<-EOF
+* sm2 0000000...$head7 (2):
+ > Add foo9
+
+EOF
+"
+
+commit_file sm2
+test_expect_success 'given commit' "
+ git submodule summary HEAD^ >actual &&
+ diff actual - <<-EOF
+* sm1 $head6...0000000:
+
+* sm2 0000000...$head7 (2):
+ > Add foo9
+
+EOF
+"
+
+test_expect_success '--for-status' "
+ git submodule summary --for-status HEAD^ >actual &&
+ test_cmp actual - <<EOF
+# Modified submodules:
+#
+# * sm1 $head6...0000000:
+#
+# * sm2 0000000...$head7 (2):
+# > Add foo9
+#
+EOF
+"
+
+test_done
diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh
new file mode 100755
index 000000000..f919c8d34
--- /dev/null
+++ b/t/t7402-submodule-rebase.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Johannes Schindelin
+#
+
+test_description='Test rebasing and stashing with dirty submodules'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ echo file > file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ git clone . submodule &&
+ git add submodule &&
+ test_tick &&
+ git commit -m submodule &&
+ echo second line >> file &&
+ (cd submodule && git pull) &&
+ test_tick &&
+ git commit -m file-and-submodule -a
+
+'
+
+test_expect_success 'rebase with a dirty submodule' '
+
+ (cd submodule &&
+ echo 3rd line >> file &&
+ test_tick &&
+ git commit -m fork -a) &&
+ echo unrelated >> file2 &&
+ git add file2 &&
+ test_tick &&
+ git commit -m unrelated file2 &&
+ echo other line >> file &&
+ test_tick &&
+ git commit -m update file &&
+ CURRENT=$(cd submodule && git rev-parse HEAD) &&
+ EXPECTED=$(git rev-parse HEAD~2:submodule) &&
+ GIT_TRACE=1 git rebase --onto HEAD~2 HEAD^ &&
+ STORED=$(git rev-parse HEAD:submodule) &&
+ test $EXPECTED = $STORED &&
+ test $CURRENT = $(cd submodule && git rev-parse HEAD)
+
+'
+
+cat > fake-editor.sh << \EOF
+#!/bin/sh
+echo $EDITOR_TEXT
+EOF
+chmod a+x fake-editor.sh
+
+test_expect_success 'interactive rebase with a dirty submodule' '
+
+ test submodule = $(git diff --name-only) &&
+ HEAD=$(git rev-parse HEAD) &&
+ GIT_EDITOR="\"$(pwd)/fake-editor.sh\"" EDITOR_TEXT="pick $HEAD" \
+ git rebase -i HEAD^ &&
+ test submodule = $(git diff --name-only)
+
+'
+
+test_expect_success 'rebase with dirty file and submodule fails' '
+
+ echo yet another line >> file &&
+ test_tick &&
+ git commit -m next file &&
+ echo rewrite > file &&
+ test_tick &&
+ git commit -m rewrite file &&
+ echo dirty > file &&
+ test_must_fail git rebase --onto HEAD~2 HEAD^
+
+'
+
+test_expect_success 'stash with a dirty submodule' '
+
+ echo new > file &&
+ CURRENT=$(cd submodule && git rev-parse HEAD) &&
+ git stash &&
+ test new != $(cat file) &&
+ test submodule = $(git diff --name-only) &&
+ test $CURRENT = $(cd submodule && git rev-parse HEAD) &&
+ git stash apply &&
+ test new = $(cat file) &&
+ test $CURRENT = $(cd submodule && git rev-parse HEAD)
+
+'
+
+test_done
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index baed6ce96..809bdba63 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -23,12 +23,12 @@ test_expect_success 'a basic commit in an empty tree should succeed' '
test_expect_success 'nonexistent template file should return error' '
echo changes >> foo &&
git add foo &&
- ! git commit --template "$PWD"/notexist
+ test_must_fail git commit --template "$PWD"/notexist
'
test_expect_success 'nonexistent template file in config should return error' '
git config commit.template "$PWD"/notexist &&
- ! git commit &&
+ test_must_fail git commit &&
git config --unset commit.template
'
@@ -37,12 +37,12 @@ TEMPLATE="$PWD"/template
test_expect_success 'unedited template should not commit' '
echo "template line" > "$TEMPLATE" &&
- ! git commit --template "$TEMPLATE"
+ test_must_fail git commit --template "$TEMPLATE"
'
test_expect_success 'unedited template with comments should not commit' '
echo "# comment in template" >> "$TEMPLATE" &&
- ! git commit --template "$TEMPLATE"
+ test_must_fail git commit --template "$TEMPLATE"
'
test_expect_success 'a Signed-off-by line by itself should not commit' '
@@ -138,4 +138,33 @@ test_expect_success '--signoff' '
diff expect output
'
+test_expect_success 'commit message from file (1)' '
+ mkdir subdir &&
+ echo "Log in top directory" >log &&
+ echo "Log in sub directory" >subdir/log &&
+ (
+ cd subdir &&
+ git commit --allow-empty -F log
+ ) &&
+ commit_msg_is "Log in sub directory"
+'
+
+test_expect_success 'commit message from file (2)' '
+ rm -f log &&
+ echo "Log in sub directory" >subdir/log &&
+ (
+ cd subdir &&
+ git commit --allow-empty -F log
+ ) &&
+ commit_msg_is "Log in sub directory"
+'
+
+test_expect_success 'commit message from stdin' '
+ (
+ cd subdir &&
+ echo "Log with foo word" | git commit --allow-empty -F -
+ ) &&
+ commit_msg_is "Log with foo word"
+'
+
test_done
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index d1a415a12..0edd9ddf7 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -17,49 +17,49 @@ test_expect_success \
git-add file && \
git-status | grep 'Initial commit'"
-test_expect_failure \
+test_expect_success \
"fail initial amend" \
- "git-commit --amend"
+ "test_must_fail git-commit --amend"
test_expect_success \
"initial commit" \
"git-commit -m initial"
-test_expect_failure \
+test_expect_success \
"invalid options 1" \
- "git-commit -m foo -m bar -F file"
+ "test_must_fail git-commit -m foo -m bar -F file"
-test_expect_failure \
+test_expect_success \
"invalid options 2" \
- "git-commit -C HEAD -m illegal"
+ "test_must_fail git-commit -C HEAD -m illegal"
-test_expect_failure \
+test_expect_success \
"using paths with -a" \
"echo King of the bongo >file &&
- git-commit -m foo -a file"
+ test_must_fail git-commit -m foo -a file"
-test_expect_failure \
+test_expect_success \
"using paths with --interactive" \
"echo bong-o-bong >file &&
- echo 7 | git-commit -m foo --interactive file"
+ ! (echo 7 | git-commit -m foo --interactive file)"
-test_expect_failure \
+test_expect_success \
"using invalid commit with -C" \
- "git-commit -C bogus"
+ "test_must_fail git-commit -C bogus"
-test_expect_failure \
+test_expect_success \
"testing nothing to commit" \
- "git-commit -m initial"
+ "test_must_fail git-commit -m initial"
test_expect_success \
"next commit" \
"echo 'bongo bongo bongo' >file \
git-commit -m next -a"
-test_expect_failure \
+test_expect_success \
"commit message from non-existing file" \
"echo 'more bongo: bongo bongo bongo bongo' >file && \
- git-commit -F gah -a"
+ test_must_fail git-commit -F gah -a"
# Empty except stray tabs and spaces on a few lines.
sed -e 's/@$//' >msg <<EOF
@@ -68,9 +68,9 @@ sed -e 's/@$//' >msg <<EOF
@
Signed-off-by: hula
EOF
-test_expect_failure \
+test_expect_success \
"empty commit message" \
- "git-commit -F msg -a"
+ "test_must_fail git-commit -F msg -a"
test_expect_success \
"commit message from file" \
@@ -79,8 +79,8 @@ test_expect_success \
cat >editor <<\EOF
#!/bin/sh
-sed -e "s/a file/an amend commit/g" < $1 > $1-
-mv $1- $1
+sed -e "s/a file/an amend commit/g" < "$1" > "$1-"
+mv "$1-" "$1"
EOF
chmod 755 editor
@@ -88,10 +88,10 @@ test_expect_success \
"amend commit" \
"VISUAL=./editor git-commit --amend"
-test_expect_failure \
+test_expect_success \
"passing -m and -F" \
"echo 'enough with the bongos' >file && \
- git-commit -F msg -m amending ."
+ test_must_fail git-commit -F msg -m amending ."
test_expect_success \
"using message from other commit" \
@@ -99,8 +99,8 @@ test_expect_success \
cat >editor <<\EOF
#!/bin/sh
-sed -e "s/amend/older/g" < $1 > $1-
-mv $1- $1
+sed -e "s/amend/older/g" < "$1" > "$1-"
+mv "$1-" "$1"
EOF
chmod 755 editor
@@ -203,7 +203,7 @@ test_expect_success 'sign off (1)' '
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
@@ -223,7 +223,7 @@ $existing" &&
git var GIT_COMMITTER_IDENT |
sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
@@ -240,7 +240,7 @@ test_expect_success 'multiple -m' '
echo
echo three
) >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
@@ -301,12 +301,12 @@ test_expect_success 'same tree (merge and amend merge)' '
git merge -s ours side -m "empty ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
- diff -u expected actual &&
+ test_cmp expected actual &&
git commit --amend -m "empty really ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
- diff -u expected actual
+ test_cmp expected actual
'
@@ -323,7 +323,25 @@ test_expect_success 'amend using the message from another commit' '
git commit --allow-empty --amend -C "$old" &&
git show --pretty="format:%ad %s" "$old" >expected &&
git show --pretty="format:%ad %s" HEAD >actual &&
- diff -u expected actual
+ test_cmp expected actual
+
+'
+
+test_expect_success 'amend using the message from a commit named with tag' '
+
+ git reset --hard &&
+ test_tick &&
+ git commit --allow-empty -m "old commit" &&
+ old=$(git rev-parse --verify HEAD) &&
+ git tag -a -m "tag on old" tagged-old HEAD &&
+ test_tick &&
+ git commit --allow-empty -m "new commit" &&
+ new=$(git rev-parse --verify HEAD) &&
+ test_tick &&
+ git commit --allow-empty --amend -C tagged-old &&
+ git show --pretty="format:%ad %s" "$old" >expected &&
+ git show --pretty="format:%ad %s" HEAD >actual &&
+ test_cmp expected actual
'
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index aaf497e6a..3eb9faedc 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -85,7 +85,7 @@ test_expect_success 'verbose' '
git add negative &&
git status -v | sed -ne "/^diff --git /p" >actual &&
echo "diff --git a/negative b/negative" >expect &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -95,7 +95,7 @@ test_expect_success 'cleanup commit messages (verbatim,-t)' '
{ echo;echo "# text";echo; } >expect &&
git commit --cleanup=verbatim -t expect -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -104,7 +104,7 @@ test_expect_success 'cleanup commit messages (verbatim,-F)' '
echo >>negative &&
git commit --cleanup=verbatim -F expect -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -113,7 +113,7 @@ test_expect_success 'cleanup commit messages (verbatim,-m)' '
echo >>negative &&
git commit --cleanup=verbatim -m "$(cat expect)" -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -124,7 +124,7 @@ test_expect_success 'cleanup commit messages (whitespace,-F)' '
echo "# text" >expect &&
git commit --cleanup=whitespace -F text -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
@@ -135,14 +135,14 @@ test_expect_success 'cleanup commit messages (strip,-F)' '
echo sample >expect &&
git commit --cleanup=strip -F text -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
- diff -u expect actual
+ test_cmp expect actual
'
echo "sample
-# Please enter the commit message for your changes.
-# (Comment lines starting with '#' will not be included)" >expect
+# Please enter the commit message for your changes. Lines starting
+# with '#' will be ignored, and an empty message aborts the commit." >expect
test_expect_success 'cleanup commit messages (strip,-F,-e)' '
@@ -150,7 +150,103 @@ test_expect_success 'cleanup commit messages (strip,-F,-e)' '
{ echo;echo sample;echo; } >text &&
git commit -e -F text -a &&
head -n 4 .git/COMMIT_EDITMSG >actual &&
- diff -u expect actual
+ test_cmp expect actual
+
+'
+
+echo "#
+# Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
+#" >> expect
+
+test_expect_success 'author different from committer' '
+
+ echo >>negative &&
+ git commit -e -m "sample"
+ head -n 7 .git/COMMIT_EDITMSG >actual &&
+ test_cmp expect actual
+'
+
+mv expect expect.tmp
+sed '$d' < expect.tmp > expect
+rm -f expect.tmp
+echo "# Committer:
+#" >> expect
+
+test_expect_success 'committer is automatic' '
+
+ echo >>negative &&
+ (
+ unset GIT_COMMITTER_EMAIL
+ unset GIT_COMMITTER_NAME
+ # must fail because there is no change
+ test_must_fail git commit -e -m "sample"
+ ) &&
+ head -n 8 .git/COMMIT_EDITMSG | \
+ sed "s/^# Committer: .*/# Committer:/" >actual &&
+ test_cmp expect actual
+'
+
+pwd=`pwd`
+cat >> .git/FAKE_EDITOR << EOF
+#! /bin/sh
+echo editor started > "$pwd/.git/result"
+exit 0
+EOF
+chmod +x .git/FAKE_EDITOR
+
+test_expect_success 'do not fire editor in the presence of conflicts' '
+
+ git clean -f &&
+ echo f >g &&
+ git add g &&
+ git commit -m "add g" &&
+ git branch second &&
+ echo master >g &&
+ echo g >h &&
+ git add g h &&
+ git commit -m "modify g and add h" &&
+ git checkout second &&
+ echo second >g &&
+ git add g &&
+ git commit -m second &&
+ # Must fail due to conflict
+ test_must_fail git cherry-pick -n master &&
+ echo "editor not started" >.git/result &&
+ (
+ GIT_EDITOR="$(pwd)/.git/FAKE_EDITOR" &&
+ export GIT_EDITOR &&
+ test_must_fail git commit
+ ) &&
+ test "$(cat .git/result)" = "editor not started"
+'
+
+pwd=`pwd`
+cat >.git/FAKE_EDITOR <<EOF
+#! $SHELL_PATH
+# kill -TERM command added below.
+EOF
+
+test_expect_success 'a SIGTERM should break locks' '
+ echo >>negative &&
+ ! "$SHELL_PATH" -c '\''
+ echo kill -TERM $$ >> .git/FAKE_EDITOR
+ GIT_EDITOR=.git/FAKE_EDITOR
+ export GIT_EDITOR
+ exec git commit -a'\'' &&
+ test ! -f .git/index.lock
+'
+
+rm -f .git/MERGE_MSG .git/COMMIT_EDITMSG
+git reset -q --hard
+
+test_expect_success 'Hand committing of a redundant merge removes dups' '
+
+ git rev-parse second master >expect &&
+ test_must_fail git merge second master &&
+ git checkout master g &&
+ EDITOR=: git commit -a &&
+ git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q" >actual &&
+ test_cmp expect actual
'
diff --git a/t/t7502-status.sh b/t/t7502-status.sh
index 9ce50cade..38a48b57c 100755
--- a/t/t7502-status.sh
+++ b/t/t7502-status.sh
@@ -17,6 +17,9 @@ test_expect_success 'setup' '
: > dir1/tracked &&
: > dir1/modified &&
git add . &&
+
+ git status >output &&
+
test_tick &&
git commit -m initial &&
: > untracked &&
@@ -28,6 +31,12 @@ test_expect_success 'setup' '
git add dir2/added
'
+test_expect_success 'status (1)' '
+
+ grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
+
+'
+
cat > expect << \EOF
# On branch master
# Changes to be committed:
@@ -51,11 +60,109 @@ cat > expect << \EOF
# untracked
EOF
-test_expect_success 'status' '
+test_expect_success 'status (2)' '
git status > output &&
- git diff expect output
+ test_cmp expect output
+
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files not listed (use -u option to show untracked files)
+EOF
+test_expect_success 'status -uno' '
+ mkdir dir3 &&
+ : > dir3/untracked1 &&
+ : > dir3/untracked2 &&
+ git status -uno >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'status (status.showUntrackedFiles no)' '
+ git config status.showuntrackedfiles no
+ git status >output &&
+ test_cmp expect output
+'
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# dir3/
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status -unormal' '
+ git status -unormal >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'status (status.showUntrackedFiles normal)' '
+ git config status.showuntrackedfiles normal
+ git status >output &&
+ test_cmp expect output
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# dir3/untracked1
+# dir3/untracked2
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status -uall' '
+ git status -uall >output &&
+ test_cmp expect output
+'
+test_expect_success 'status (status.showUntrackedFiles all)' '
+ git config status.showuntrackedfiles all
+ git status >output &&
+ rm -rf dir3 &&
+ git config --unset status.showuntrackedfiles &&
+ test_cmp expect output
'
cat > expect << \EOF
@@ -84,7 +191,7 @@ EOF
test_expect_success 'status with relative paths' '
(cd dir1 && git status) > output &&
- git diff expect output
+ test_cmp expect output
'
@@ -115,8 +222,163 @@ test_expect_success 'status without relative paths' '
git config status.relativePaths false
(cd dir1 && git status) > output &&
- git diff expect output
+ test_cmp expect output
+
+'
+
+cat <<EOF >expect
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status of partial commit excluding new file in index' '
+ git status dir1/modified >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'setup status submodule summary' '
+ test_create_repo sm && (
+ cd sm &&
+ >foo &&
+ git add foo &&
+ git commit -m "Add foo"
+ ) &&
+ git add sm
+'
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary is disabled by default' '
+ git status >output &&
+ test_cmp expect output
+'
+
+head=$(cd sm && git rev-parse --short=7 --verify HEAD)
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+# > Add foo
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary' '
+ git config status.submodulesummary 10 &&
+ git status >output &&
+ test_cmp expect output
+'
+
+
+cat >expect <<EOF
+# On branch master
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+no changes added to commit (use "git add" and/or "git commit -a")
+EOF
+test_expect_success 'status submodule summary (clean submodule)' '
+ git commit -m "commit submodule" &&
+ git config status.submodulesummary 10 &&
+ test_must_fail git status >output &&
+ test_cmp expect output
+'
+
+cat >expect <<EOF
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD^1 <file>..." to unstage)
+#
+# new file: dir2/added
+# new file: sm
+#
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
+#
+# modified: dir1/modified
+#
+# Modified submodules:
+#
+# * sm 0000000...$head (1):
+# > Add foo
+#
+# Untracked files:
+# (use "git add <file>..." to include in what will be committed)
+#
+# dir1/untracked
+# dir2/modified
+# dir2/untracked
+# expect
+# output
+# untracked
+EOF
+test_expect_success 'status submodule summary (--amend)' '
+ git config status.submodulesummary 10 &&
+ git status --amend >output &&
+ test_cmp expect output
'
test_done
diff --git a/t/t7503-pre-commit-hook.sh b/t/t7503-pre-commit-hook.sh
index d787cac2f..b06909599 100755
--- a/t/t7503-pre-commit-hook.sh
+++ b/t/t7503-pre-commit-hook.sh
@@ -52,11 +52,11 @@ cat > "$HOOK" <<EOF
exit 1
EOF
-test_expect_failure 'with failing hook' '
+test_expect_success 'with failing hook' '
echo "another" >> file &&
git add file &&
- git commit -m "another"
+ test_must_fail git commit -m "another"
'
diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh
index 751b11300..47680e6df 100755
--- a/t/t7504-commit-msg-hook.sh
+++ b/t/t7504-commit-msg-hook.sh
@@ -19,6 +19,9 @@ cp FAKE_MSG "$1"
exit 0
EOF
chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
FAKE_EDITOR="$(pwd)/fake-editor"
export FAKE_EDITOR
@@ -27,7 +30,7 @@ test_expect_success 'with no hook (editor)' '
echo "more foo" >> file &&
git add file &&
echo "more foo" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
'
@@ -44,7 +47,7 @@ test_expect_success '--no-verify with no hook (editor)' '
echo "more bar" > file &&
git add file &&
echo "more bar" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -71,7 +74,7 @@ test_expect_success 'with succeeding hook (editor)' '
echo "more more" >> file &&
git add file &&
echo "more more" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit
'
@@ -88,7 +91,7 @@ test_expect_success '--no-verify with succeeding hook (editor)' '
echo "even more more" >> file &&
git add file &&
echo "even more more" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -98,20 +101,20 @@ cat > "$HOOK" <<EOF
exit 1
EOF
-test_expect_failure 'with failing hook' '
+test_expect_success 'with failing hook' '
echo "another" >> file &&
git add file &&
- git commit -m "another"
+ test_must_fail git commit -m "another"
'
-test_expect_failure 'with failing hook (editor)' '
+test_expect_success 'with failing hook (editor)' '
echo "more another" >> file &&
git add file &&
echo "more another" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit
+ ! (GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit)
'
@@ -128,7 +131,7 @@ test_expect_success '--no-verify with failing hook (editor)' '
echo "more stuff" >> file &&
git add file &&
echo "more stuff" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -146,7 +149,7 @@ test_expect_success 'with non-executable hook (editor)' '
echo "content again" >> file &&
git add file &&
echo "content again" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit -m "content again"
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -m "content again"
'
@@ -163,7 +166,7 @@ test_expect_success '--no-verify with non-executable hook (editor)' '
echo "even more content" >> file &&
git add file &&
echo "even more content" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify
'
@@ -193,7 +196,7 @@ test_expect_success 'hook edits commit message (editor)' '
echo "additional content" >> file &&
git add file &&
echo "additional content" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
commit_msg_is "new message"
'
@@ -212,7 +215,7 @@ test_expect_success "hook doesn't edit commit message (editor)" '
echo "more plus" >> file &&
git add file &&
echo "more plus" > FAKE_MSG &&
- GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify &&
commit_msg_is "more plus"
'
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
new file mode 100755
index 000000000..cd6c7c834
--- /dev/null
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -0,0 +1,159 @@
+#!/bin/sh
+
+test_description='prepare-commit-msg hook'
+
+. ./test-lib.sh
+
+test_expect_success 'with no hook' '
+
+ echo "foo" > file &&
+ git add file &&
+ git commit -m "first"
+
+'
+
+# set up fake editor for interactive editing
+cat > fake-editor <<'EOF'
+#!/bin/sh
+exit 0
+EOF
+chmod +x fake-editor
+
+## Not using test_set_editor here so we can easily ensure the editor variable
+## is only set for the editor tests
+FAKE_EDITOR="$(pwd)/fake-editor"
+export FAKE_EDITOR
+
+# now install hook that always succeeds and adds a message
+HOOKDIR="$(git rev-parse --git-dir)/hooks"
+HOOK="$HOOKDIR/prepare-commit-msg"
+mkdir -p "$HOOKDIR"
+echo "#!$SHELL_PATH" > "$HOOK"
+cat >> "$HOOK" <<'EOF'
+
+if test "$2" = commit; then
+ source=$(git-rev-parse "$3")
+else
+ source=${2-default}
+fi
+if test "$GIT_EDITOR" = :; then
+ sed -e "1s/.*/$source (no editor)/" "$1" > msg.tmp
+else
+ sed -e "1s/.*/$source/" "$1" > msg.tmp
+fi
+mv msg.tmp "$1"
+exit 0
+EOF
+chmod +x "$HOOK"
+
+echo dummy template > "$(git rev-parse --git-dir)/template"
+
+test_expect_success 'with hook (-m)' '
+
+ echo "more" >> file &&
+ git add file &&
+ git commit -m "more" &&
+ test "`git log -1 --pretty=format:%s`" = "message (no editor)"
+
+'
+
+test_expect_success 'with hook (-m editor)' '
+
+ echo "more" >> file &&
+ git add file &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -m "more more" &&
+ test "`git log -1 --pretty=format:%s`" = message
+
+'
+
+test_expect_success 'with hook (-t)' '
+
+ echo "more" >> file &&
+ git add file &&
+ git commit -t "$(git rev-parse --git-dir)/template" &&
+ test "`git log -1 --pretty=format:%s`" = template
+
+'
+
+test_expect_success 'with hook (-F)' '
+
+ echo "more" >> file &&
+ git add file &&
+ (echo more | git commit -F -) &&
+ test "`git log -1 --pretty=format:%s`" = "message (no editor)"
+
+'
+
+test_expect_success 'with hook (-F editor)' '
+
+ echo "more" >> file &&
+ git add file &&
+ (echo more more | GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -F -) &&
+ test "`git log -1 --pretty=format:%s`" = message
+
+'
+
+test_expect_success 'with hook (-C)' '
+
+ head=`git rev-parse HEAD` &&
+ echo "more" >> file &&
+ git add file &&
+ git commit -C $head &&
+ test "`git log -1 --pretty=format:%s`" = "$head (no editor)"
+
+'
+
+test_expect_success 'with hook (editor)' '
+
+ echo "more more" >> file &&
+ git add file &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit &&
+ test "`git log -1 --pretty=format:%s`" = default
+
+'
+
+test_expect_success 'with hook (--amend)' '
+
+ head=`git rev-parse HEAD` &&
+ echo "more" >> file &&
+ git add file &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --amend &&
+ test "`git log -1 --pretty=format:%s`" = "$head"
+
+'
+
+test_expect_success 'with hook (-c)' '
+
+ head=`git rev-parse HEAD` &&
+ echo "more" >> file &&
+ git add file &&
+ GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head &&
+ test "`git log -1 --pretty=format:%s`" = "$head"
+
+'
+
+cat > "$HOOK" <<'EOF'
+#!/bin/sh
+exit 1
+EOF
+
+test_expect_success 'with failing hook' '
+
+ head=`git rev-parse HEAD` &&
+ echo "more" >> file &&
+ git add file &&
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head
+
+'
+
+test_expect_success 'with failing hook (--no-verify)' '
+
+ head=`git rev-parse HEAD` &&
+ echo "more" >> file &&
+ git add file &&
+ ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify -c $head
+
+'
+
+
+test_done
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
new file mode 100755
index 000000000..a75130cdb
--- /dev/null
+++ b/t/t7506-status-submodule.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='git-status for submodule'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_create_repo sub
+ cd sub &&
+ : >bar &&
+ git add bar &&
+ git commit -m " Add bar" &&
+ cd .. &&
+ git add sub &&
+ git commit -m "Add submodule sub"
+'
+
+test_expect_success 'status clean' '
+ git status |
+ grep "nothing to commit"
+'
+test_expect_success 'status -a clean' '
+ git status -a |
+ grep "nothing to commit"
+'
+test_expect_success 'rm submodule contents' '
+ rm -rf sub/* sub/.git
+'
+test_expect_success 'status clean (empty submodule dir)' '
+ git status |
+ grep "nothing to commit"
+'
+test_expect_success 'status -a clean (empty submodule dir)' '
+ git status -a |
+ grep "nothing to commit"
+'
+
+test_done
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 50c51c82f..5eeb6c2b2 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -104,11 +104,15 @@ create_merge_msgs() {
git log --no-merges ^HEAD c2 >>squash.1-5 &&
echo "Squashed commit of the following:" >squash.1-5-9 &&
echo >>squash.1-5-9 &&
- git log --no-merges ^HEAD c2 c3 >>squash.1-5-9
+ git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 &&
+ echo > msg.nolog &&
+ echo "* commit 'c3':" >msg.log &&
+ echo " commit 3" >>msg.log &&
+ echo >>msg.log
}
verify_diff() {
- if ! diff -u "$1" "$2"
+ if ! test_cmp "$1" "$2"
then
echo "$3"
false
@@ -122,7 +126,7 @@ verify_merge() {
echo "[OOPS] unmerged files"
false
fi &&
- if ! git diff --exit-code
+ if test_must_fail git diff --exit-code
then
echo "[OOPS] working tree != index"
false
@@ -165,7 +169,7 @@ verify_mergeheads() {
fi &&
while test $# -gt 0
do
- head=$(head -n $i .git/MERGE_HEAD | tail -n 1)
+ head=$(head -n $i .git/MERGE_HEAD | sed -ne \$p)
if test "$1" != "$head"
then
echo "[OOPS] MERGE_HEAD $i != $1"
@@ -218,36 +222,12 @@ test_expect_success 'setup' '
test_debug 'gitk --all'
test_expect_success 'test option parsing' '
- if git merge -$ c1
- then
- echo "[OOPS] -$ accepted"
- false
- fi &&
- if git merge --no-such c1
- then
- echo "[OOPS] --no-such accepted"
- false
- fi &&
- if git merge -s foobar c1
- then
- echo "[OOPS] -s foobar accepted"
- false
- fi &&
- if git merge -s=foobar c1
- then
- echo "[OOPS] -s=foobar accepted"
- false
- fi &&
- if git merge -m
- then
- echo "[OOPS] missing commit msg accepted"
- false
- fi &&
- if git merge
- then
- echo "[OOPS] missing commit references accepted"
- false
- fi
+ test_must_fail git merge -$ c1 &&
+ test_must_fail git merge --no-such c1 &&
+ test_must_fail git merge -s foobar c1 &&
+ test_must_fail git merge -s=foobar c1 &&
+ test_must_fail git merge -m &&
+ test_must_fail git merge
'
test_expect_success 'merge c0 with c1' '
@@ -364,29 +344,44 @@ test_expect_success 'merge c1 with c2 (squash in config)' '
test_debug 'gitk --all'
-test_expect_success 'override config option -n' '
+test_expect_success 'override config option -n with --summary' '
git reset --hard c1 &&
git config branch.master.mergeoptions "-n" &&
test_tick &&
git merge --summary c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
verify_parents $c1 $c2 &&
- if ! grep -e "^ file | *2 +-$" diffstat.txt
+ if ! grep "^ file | *2 +-$" diffstat.txt
+ then
+ echo "[OOPS] diffstat was not generated with --summary"
+ false
+ fi
+'
+
+test_expect_success 'override config option -n with --stat' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "-n" &&
+ test_tick &&
+ git merge --stat c2 >diffstat.txt &&
+ verify_merge file result.1-5 msg.1-5 &&
+ verify_parents $c1 $c2 &&
+ if ! grep "^ file | *2 +-$" diffstat.txt
then
- echo "[OOPS] diffstat was not generated"
+ echo "[OOPS] diffstat was not generated with --stat"
+ false
fi
'
test_debug 'gitk --all'
-test_expect_success 'override config option --summary' '
+test_expect_success 'override config option --stat' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--summary" &&
+ git config branch.master.mergeoptions "--stat" &&
test_tick &&
git merge -n c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
verify_parents $c1 $c2 &&
- if grep -e "^ file | *2 +-$" diffstat.txt
+ if grep "^ file | *2 +-$" diffstat.txt
then
echo "[OOPS] diffstat was generated"
false
@@ -419,6 +414,7 @@ test_debug 'gitk --all'
test_expect_success 'merge c0 with c1 (no-ff)' '
git reset --hard c0 &&
+ git config branch.master.mergeoptions "" &&
test_tick &&
git merge --no-ff c1 &&
verify_merge file result.1 &&
@@ -427,6 +423,11 @@ test_expect_success 'merge c0 with c1 (no-ff)' '
test_debug 'gitk --all'
+test_expect_success 'combining --squash and --no-ff is refused' '
+ test_must_fail git merge --squash --no-ff c1 &&
+ test_must_fail git merge --no-ff --squash c1
+'
+
test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
git reset --hard c0 &&
git config branch.master.mergeoptions "--no-ff" &&
@@ -435,6 +436,56 @@ test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
verify_head $c1
'
+test_expect_success 'merge log message' '
+ git reset --hard c0 &&
+ git merge --no-log c2 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ verify_diff msg.nolog msg.act "[OOPS] bad merge log message" &&
+
+ git merge --log c3 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ verify_diff msg.log msg.act "[OOPS] bad merge log message" &&
+
+ git reset --hard HEAD^ &&
+ git config merge.log yes &&
+ git merge c3 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ verify_diff msg.log msg.act "[OOPS] bad merge log message"
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c0, c2, c0, and c1' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c0 c2 c0 c1 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c0, c2, c0, and c1' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c0 c2 c0 c1 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c1 and c2' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c1 c2 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
+'
+
test_debug 'gitk --all'
test_done
diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
new file mode 100755
index 000000000..55aa6b5f2
--- /dev/null
+++ b/t/t7601-merge-pull-config.sh
@@ -0,0 +1,156 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing pull.* configuration parsing.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo c0 >c0.c &&
+ git add c0.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ echo c1 >c1.c &&
+ git add c1.c &&
+ git commit -m c1 &&
+ git tag c1 &&
+ git reset --hard c0 &&
+ echo c2 >c2.c &&
+ git add c2.c &&
+ git commit -m c2 &&
+ git tag c2 &&
+ git reset --hard c0 &&
+ echo c3 >c3.c &&
+ git add c3.c &&
+ git commit -m c3 &&
+ git tag c3
+'
+
+test_expect_success 'merge c1 with c2' '
+ git reset --hard c1 &&
+ test -f c0.c &&
+ test -f c1.c &&
+ test ! -f c2.c &&
+ test ! -f c3.c &&
+ git merge c2 &&
+ test -f c1.c &&
+ test -f c2.c
+'
+
+test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
+ git reset --hard c1 &&
+ git config pull.twohead ours &&
+ git merge c2 &&
+ test -f c1.c &&
+ ! test -f c2.c
+'
+
+test_expect_success 'merge c1 with c2 and c3 (recursive in pull.octopus)' '
+ git reset --hard c1 &&
+ git config pull.octopus "recursive" &&
+ test_must_fail git merge c2 c3 &&
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD)"
+'
+
+test_expect_success 'merge c1 with c2 and c3 (recursive and octopus in pull.octopus)' '
+ git reset --hard c1 &&
+ git config pull.octopus "recursive octopus" &&
+ git merge c2 c3 &&
+ test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
+ test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
+ test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
+ git diff --exit-code &&
+ test -f c0.c &&
+ test -f c1.c &&
+ test -f c2.c &&
+ test -f c3.c
+'
+
+conflict_count()
+{
+ {
+ git diff-files --name-only
+ git ls-files --unmerged
+ } | wc -l
+}
+
+# c4 - c5
+# \ c6
+#
+# There are two conflicts here:
+#
+# 1) Because foo.c is renamed to bar.c, recursive will handle this,
+# resolve won't.
+#
+# 2) One in conflict.c and that will always fail.
+
+test_expect_success 'setup conflicted merge' '
+ git reset --hard c0 &&
+ echo A >conflict.c &&
+ git add conflict.c &&
+ echo contents >foo.c &&
+ git add foo.c &&
+ git commit -m c4 &&
+ git tag c4 &&
+ echo B >conflict.c &&
+ git add conflict.c &&
+ git mv foo.c bar.c &&
+ git commit -m c5 &&
+ git tag c5 &&
+ git reset --hard c4 &&
+ echo C >conflict.c &&
+ git add conflict.c &&
+ echo secondline >> foo.c &&
+ git add foo.c &&
+ git commit -m c6 &&
+ git tag c6
+'
+
+# First do the merge with resolve and recursive then verify that
+# recusive is choosen.
+
+test_expect_success 'merge picks up the best result' '
+ git config --unset-all pull.twohead &&
+ git reset --hard c5 &&
+ git merge -s resolve c6
+ resolve_count=$(conflict_count) &&
+ git reset --hard c5 &&
+ git merge -s recursive c6
+ recursive_count=$(conflict_count) &&
+ git reset --hard c5 &&
+ git merge -s recursive -s resolve c6
+ auto_count=$(conflict_count) &&
+ test $auto_count = $recursive_count &&
+ test $auto_count != $resolve_count
+'
+
+test_expect_success 'merge picks up the best result (from config)' '
+ git config pull.twohead "recursive resolve" &&
+ git reset --hard c5 &&
+ git merge -s resolve c6
+ resolve_count=$(conflict_count) &&
+ git reset --hard c5 &&
+ git merge -s recursive c6
+ recursive_count=$(conflict_count) &&
+ git reset --hard c5 &&
+ git merge c6
+ auto_count=$(conflict_count) &&
+ test $auto_count = $recursive_count &&
+ test $auto_count != $resolve_count
+'
+
+test_expect_success 'merge errors out on invalid strategy' '
+ git config pull.twohead "foobar" &&
+ git reset --hard c5 &&
+ test_must_fail git merge c6
+'
+
+test_expect_success 'merge errors out on invalid strategy' '
+ git config --unset-all pull.twohead &&
+ git reset --hard c5 &&
+ test_must_fail git merge -s "resolve recursive" c6
+'
+
+test_done
diff --git a/t/t7602-merge-octopus-many.sh b/t/t7602-merge-octopus-many.sh
new file mode 100755
index 000000000..fcb828574
--- /dev/null
+++ b/t/t7602-merge-octopus-many.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing octopus merge with more than 25 refs.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo c0 > c0.c &&
+ git add c0.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ i=1 &&
+ while test $i -le 30
+ do
+ git reset --hard c0 &&
+ echo c$i > c$i.c &&
+ git add c$i.c &&
+ git commit -m c$i &&
+ git tag c$i &&
+ i=`expr $i + 1` || return 1
+ done
+'
+
+test_expect_success 'merge c1 with c2, c3, c4, ... c29' '
+ git reset --hard c1 &&
+ i=2 &&
+ refs="" &&
+ while test $i -le 30
+ do
+ refs="$refs c$i"
+ i=`expr $i + 1`
+ done
+ git merge $refs &&
+ test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
+ i=1 &&
+ while test $i -le 30
+ do
+ test "$(git rev-parse c$i)" = "$(git rev-parse HEAD^$i)" &&
+ i=`expr $i + 1` || return 1
+ done &&
+ git diff --exit-code &&
+ i=1 &&
+ while test $i -le 30
+ do
+ test -f c$i.c &&
+ i=`expr $i + 1` || return 1
+ done
+'
+
+test_done
diff --git a/t/t7603-merge-reduce-heads.sh b/t/t7603-merge-reduce-heads.sh
new file mode 100755
index 000000000..17b19dc11
--- /dev/null
+++ b/t/t7603-merge-reduce-heads.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing octopus merge when reducing parents to independent branches.'
+
+. ./test-lib.sh
+
+# 0 - 1
+# \ 2
+# \ 3
+# \ 4 - 5
+#
+# So 1, 2, 3 and 5 should be kept, 4 should be avoided.
+
+test_expect_success 'setup' '
+ echo c0 > c0.c &&
+ git add c0.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ echo c1 > c1.c &&
+ git add c1.c &&
+ git commit -m c1 &&
+ git tag c1 &&
+ git reset --hard c0 &&
+ echo c2 > c2.c &&
+ git add c2.c &&
+ git commit -m c2 &&
+ git tag c2 &&
+ git reset --hard c0 &&
+ echo c3 > c3.c &&
+ git add c3.c &&
+ git commit -m c3 &&
+ git tag c3 &&
+ git reset --hard c0 &&
+ echo c4 > c4.c &&
+ git add c4.c &&
+ git commit -m c4 &&
+ git tag c4 &&
+ echo c5 > c5.c &&
+ git add c5.c &&
+ git commit -m c5 &&
+ git tag c5
+'
+
+test_expect_success 'merge c1 with c2, c3, c4, c5' '
+ git reset --hard c1 &&
+ git merge c2 c3 c4 c5 &&
+ test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
+ test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
+ test "$(git rev-parse c3)" = "$(git rev-parse HEAD^3)" &&
+ test "$(git rev-parse c5)" = "$(git rev-parse HEAD^4)" &&
+ git diff --exit-code &&
+ test -f c0.c &&
+ test -f c1.c &&
+ test -f c2.c &&
+ test -f c3.c &&
+ test -f c4.c &&
+ test -f c5.c
+'
+
+test_done
diff --git a/t/t7604-merge-custom-message.sh b/t/t7604-merge-custom-message.sh
new file mode 100755
index 000000000..6081677d2
--- /dev/null
+++ b/t/t7604-merge-custom-message.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing merge when using a custom message for the merge commit.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo c0 > c0.c &&
+ git add c0.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ echo c1 > c1.c &&
+ git add c1.c &&
+ git commit -m c1 &&
+ git tag c1 &&
+ git reset --hard c0 &&
+ echo c2 > c2.c &&
+ git add c2.c &&
+ git commit -m c2 &&
+ git tag c2
+'
+
+cat >expected <<\EOF
+custom message
+
+Merge commit 'c2'
+EOF
+test_expect_success 'merge c2 with a custom message' '
+ git reset --hard c1 &&
+ git merge -m "custom message" c2 &&
+ git cat-file commit HEAD | sed -e "1,/^$/d" > actual &&
+ test_cmp expected actual
+'
+
+test_done
diff --git a/t/t7605-merge-resolve.sh b/t/t7605-merge-resolve.sh
new file mode 100755
index 000000000..ee21a107f
--- /dev/null
+++ b/t/t7605-merge-resolve.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+test_description='git-merge
+
+Testing the resolve strategy.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo c0 > c0.c &&
+ git add c0.c &&
+ git commit -m c0 &&
+ git tag c0 &&
+ echo c1 > c1.c &&
+ git add c1.c &&
+ git commit -m c1 &&
+ git tag c1 &&
+ git reset --hard c0 &&
+ echo c2 > c2.c &&
+ git add c2.c &&
+ git commit -m c2 &&
+ git tag c2 &&
+ git reset --hard c0 &&
+ echo c3 > c2.c &&
+ git add c2.c &&
+ git commit -m c3 &&
+ git tag c3
+'
+
+test_expect_success 'merge c1 to c2' '
+ git reset --hard c1 &&
+ git merge -s resolve c2 &&
+ test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
+ test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
+ test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
+ git diff --exit-code &&
+ test -f c0.c &&
+ test -f c1.c &&
+ test -f c2.c
+'
+
+test_expect_success 'merge c2 to c3 (fails)' '
+ git reset --hard c2 &&
+ test_must_fail git merge -s resolve c3
+'
+test_done
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
new file mode 100755
index 000000000..9285071c4
--- /dev/null
+++ b/t/t7610-mergetool.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Charles Bailey
+#
+
+test_description='git-mergetool
+
+Testing basic merge tool invocation'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo master >file1 &&
+ git add file1 &&
+ git commit -m "added file1" &&
+ git checkout -b branch1 master &&
+ echo branch1 change >file1 &&
+ echo branch1 newfile >file2 &&
+ git add file1 file2 &&
+ git commit -m "branch1 changes" &&
+ git checkout -b branch2 master &&
+ echo branch2 change >file1 &&
+ echo branch2 newfile >file2 &&
+ git add file1 file2 &&
+ git commit -m "branch2 changes" &&
+ git checkout master &&
+ echo master updated >file1 &&
+ echo master new >file2 &&
+ git add file1 file2 &&
+ git commit -m "master updates"
+'
+
+test_expect_success 'custom mergetool' '
+ git config merge.tool mytool &&
+ git config mergetool.mytool.cmd "cat \"\$REMOTE\" >\"\$MERGED\"" &&
+ git config mergetool.mytool.trustExitCode true &&
+ git checkout branch1 &&
+ test_must_fail git merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool file1>/dev/null 2>&1 ) &&
+ ( yes "" | git mergetool file2>/dev/null 2>&1 ) &&
+ test "$(cat file1)" = "master updated" &&
+ test "$(cat file2)" = "master new" &&
+ git commit -m "branch1 resolved with mergetool"
+'
+
+test_done
diff --git a/t/t7701-repack-unpack-unreachable.sh b/t/t7701-repack-unpack-unreachable.sh
new file mode 100755
index 000000000..31c340fd3
--- /dev/null
+++ b/t/t7701-repack-unpack-unreachable.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+
+test_description='git-repack works correctly'
+
+. ./test-lib.sh
+
+fsha1=
+csha1=
+tsha1=
+
+test_expect_success '-A option leaves unreachable objects unpacked' '
+ echo content > file1 &&
+ git add . &&
+ git commit -m initial_commit &&
+ # create a transient branch with unique content
+ git checkout -b transient_branch &&
+ echo more content >> file1 &&
+ # record the objects created in the database for file, commit, tree
+ fsha1=$(git hash-object file1) &&
+ git commit -a -m more_content &&
+ csha1=$(git rev-parse HEAD^{commit}) &&
+ tsha1=$(git rev-parse HEAD^{tree}) &&
+ git checkout master &&
+ echo even more content >> file1 &&
+ git commit -a -m even_more_content &&
+ # delete the transient branch
+ git branch -D transient_branch &&
+ # pack the repo
+ git repack -A -d -l &&
+ # verify objects are packed in repository
+ test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+ grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+ sort | uniq | wc -l) &&
+ git show $fsha1 &&
+ git show $csha1 &&
+ git show $tsha1 &&
+ # now expire the reflog
+ sleep 1 &&
+ git reflog expire --expire-unreachable=now --all &&
+ # and repack
+ git repack -A -d -l &&
+ # verify objects are retained unpacked
+ test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
+ grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
+ sort | uniq | wc -l) &&
+ git show $fsha1 &&
+ git show $csha1 &&
+ git show $tsha1
+'
+
+compare_mtimes ()
+{
+ perl -e 'my $reference = shift;
+ foreach my $file (@ARGV) {
+ exit(1) unless(-f $file && -M $file == -M $reference);
+ }
+ exit(0);
+ ' -- "$@"
+}
+
+test_expect_success 'unpacked objects receive timestamp of pack file' '
+ fsha1path=$(echo "$fsha1" | sed -e "s|\(..\)|\1/|") &&
+ fsha1path=".git/objects/$fsha1path" &&
+ csha1path=$(echo "$csha1" | sed -e "s|\(..\)|\1/|") &&
+ csha1path=".git/objects/$csha1path" &&
+ tsha1path=$(echo "$tsha1" | sed -e "s|\(..\)|\1/|") &&
+ tsha1path=".git/objects/$tsha1path" &&
+ git branch transient_branch $csha1 &&
+ git repack -a -d -l &&
+ test ! -f "$fsha1path" &&
+ test ! -f "$csha1path" &&
+ test ! -f "$tsha1path" &&
+ test 1 = $(ls -1 .git/objects/pack/pack-*.pack | wc -l) &&
+ packfile=$(ls .git/objects/pack/pack-*.pack) &&
+ git branch -D transient_branch &&
+ sleep 1 &&
+ git repack -A -l &&
+ compare_mtimes "$packfile" "$fsha1path" "$csha1path" "$tsha1path"
+'
+
+test_done
diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh
index db51b3a6b..966bb0a61 100755
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
@@ -112,7 +112,7 @@ test_expect_success 'blame wholesale copy' '
echo mouse-Second
echo mouse-Third
} >expected &&
- diff -u expected current
+ test_cmp expected current
'
@@ -125,7 +125,7 @@ test_expect_success 'blame wholesale copy and more' '
echo cow-Fifth
echo mouse-Third
} >expected &&
- diff -u expected current
+ test_cmp expected current
'
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 4f6822f2c..1c857cf4a 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -8,23 +8,29 @@ test_expect_success \
'prepare reference tree' \
'echo "1A quick brown fox jumps over the" >file &&
echo "lazy dog" >>file &&
- git add file
+ git add file &&
GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
test_expect_success \
'Setup helper tool' \
- '(echo "#!/bin/sh"
+ '(echo "#!$SHELL_PATH"
echo shift
+ echo output=1
+ echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
echo for a
echo do
echo " echo \"!\$a!\""
- echo "done >commandline"
- echo "cat > msgtxt"
- ) >fake.sendmail
- chmod +x ./fake.sendmail
- git add fake.sendmail
+ echo "done >commandline\$output"
+ echo "cat > msgtxt\$output"
+ ) >fake.sendmail &&
+ chmod +x ./fake.sendmail &&
+ git add fake.sendmail &&
GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
+clean_fake_sendmail() {
+ rm -f commandline* msgtxt*
+}
+
test_expect_success 'Extract patches' '
patches=`git format-patch -n HEAD^1`
'
@@ -39,7 +45,7 @@ cat >expected <<\EOF
EOF
test_expect_success \
'Verify commandline' \
- 'diff commandline expected'
+ 'diff commandline1 expected'
cat >expected-show-all-headers <<\EOF
0001-Second.patch
@@ -75,17 +81,17 @@ test_expect_success 'Show all headers' '
-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
>actual-show-all-headers &&
- diff -u expected-show-all-headers actual-show-all-headers
+ test_cmp expected-show-all-headers actual-show-all-headers
'
z8=zzzzzzzz
z64=$z8$z8$z8$z8$z8$z8$z8$z8
z512=$z64$z64$z64$z64$z64$z64$z64$z64
test_expect_success 'reject long lines' '
- rm -f commandline &&
+ clean_fake_sendmail &&
cp $patches longline.patch &&
echo $z512$z512 >>longline.patch &&
- ! git send-email \
+ test_must_fail git send-email \
--from="Example <nobody@example.com>" \
--to=nobody@example.com \
--smtp-server="$(pwd)/fake.sendmail" \
@@ -95,7 +101,7 @@ test_expect_success 'reject long lines' '
'
test_expect_success 'no patch was sent' '
- ! test -e commandline
+ ! test -e commandline1
'
test_expect_success 'allow long lines with --no-validate' '
@@ -108,4 +114,182 @@ test_expect_success 'allow long lines with --no-validate' '
2>errors
'
+test_expect_success 'Invalid In-Reply-To' '
+ clean_fake_sendmail &&
+ git send-email \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --in-reply-to=" " \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches
+ 2>errors
+ ! grep "^In-Reply-To: < *>" msgtxt1
+'
+
+test_expect_success 'Valid In-Reply-To when prompting' '
+ clean_fake_sendmail &&
+ (echo "From Example <from@example.com>"
+ echo "To Example <to@example.com>"
+ echo ""
+ ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches 2>errors &&
+ ! grep "^In-Reply-To: < *>" msgtxt1
+'
+
+test_expect_success 'setup fake editor' '
+ (echo "#!$SHELL_PATH" &&
+ echo "echo fake edit >>\"\$1\""
+ ) >fake-editor &&
+ chmod +x fake-editor
+'
+
+test_set_editor "$(pwd)/fake-editor"
+
+test_expect_success '--compose works' '
+ clean_fake_sendmail &&
+ echo y | \
+ GIT_SEND_EMAIL_NOTTY=1 \
+ git send-email \
+ --compose --subject foo \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches \
+ 2>errors
+'
+
+test_expect_success 'first message is compose text' '
+ grep "^fake edit" msgtxt1
+'
+
+test_expect_success 'second message is patch' '
+ grep "Subject:.*Second" msgtxt2
+'
+
+cat >expected-show-all-headers <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@example.com>
+RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com>
+From: Example <from@example.com>
+To: to@example.com
+Cc: cc@example.com, A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc set' '
+ git config sendemail.cc cc@example.com &&
+ git send-email \
+ --dry-run \
+ --from="Example <from@example.com>" \
+ --to=to@example.com \
+ --smtp-server relay.example.com \
+ $patches |
+ sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+ >actual-show-all-headers &&
+ test_cmp expected-show-all-headers actual-show-all-headers
+'
+
+cat >expected-show-all-headers <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@example.com>
+RCPT TO:<to@example.com>,<author@example.com>
+From: Example <from@example.com>
+To: to@example.com
+Cc: A <author@example.com>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cc unset' '
+ git config --unset sendemail.cc &&
+ git send-email \
+ --dry-run \
+ --from="Example <from@example.com>" \
+ --to=to@example.com \
+ --smtp-server relay.example.com \
+ $patches |
+ sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \
+ -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+ -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+ >actual-show-all-headers &&
+ test_cmp expected-show-all-headers actual-show-all-headers
+'
+
+test_expect_success '--compose adds MIME for utf8 body' '
+ clean_fake_sendmail &&
+ (echo "#!$SHELL_PATH" &&
+ echo "echo utf8 body: àéìöú >>\"\$1\""
+ ) >fake-editor-utf8 &&
+ chmod +x fake-editor-utf8 &&
+ echo y | \
+ GIT_EDITOR="\"$(pwd)/fake-editor-utf8\"" \
+ GIT_SEND_EMAIL_NOTTY=1 \
+ git send-email \
+ --compose --subject foo \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches &&
+ grep "^utf8 body" msgtxt1 &&
+ grep "^Content-Type: text/plain; charset=utf-8" msgtxt1
+'
+
+test_expect_success '--compose respects user mime type' '
+ clean_fake_sendmail &&
+ (echo "#!$SHELL_PATH" &&
+ echo "(echo MIME-Version: 1.0"
+ echo " echo Content-Type: text/plain\\; charset=iso-8859-1"
+ echo " echo Content-Transfer-Encoding: 8bit"
+ echo " echo Subject: foo"
+ echo " echo "
+ echo " echo utf8 body: àéìöú) >\"\$1\""
+ ) >fake-editor-utf8-mime &&
+ chmod +x fake-editor-utf8-mime &&
+ echo y | \
+ GIT_EDITOR="\"$(pwd)/fake-editor-utf8-mime\"" \
+ GIT_SEND_EMAIL_NOTTY=1 \
+ git send-email \
+ --compose --subject foo \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches &&
+ grep "^utf8 body" msgtxt1 &&
+ grep "^Content-Type: text/plain; charset=iso-8859-1" msgtxt1 &&
+ ! grep "^Content-Type: text/plain; charset=utf-8" msgtxt1
+'
+
+test_expect_success '--compose adds MIME for utf8 subject' '
+ clean_fake_sendmail &&
+ echo y | \
+ GIT_EDITOR="\"$(pwd)/fake-editor\"" \
+ GIT_SEND_EMAIL_NOTTY=1 \
+ git send-email \
+ --compose --subject utf8-sübjëct \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ $patches &&
+ grep "^fake edit" msgtxt1 &&
+ grep "^Subject: =?utf-8?q?utf8-s=C3=BCbj=C3=ABct?=" msgtxt1
+'
+
test_done
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 614cf50d1..843a5013b 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -4,9 +4,9 @@
#
test_description='git-svn basic tests'
-GIT_SVN_LC_ALL=$LC_ALL
+GIT_SVN_LC_ALL=${LC_ALL:-$LANG}
-case "$LC_ALL" in
+case "$GIT_SVN_LC_ALL" in
*.UTF-8)
have_utf8=t
;;
@@ -17,159 +17,159 @@ esac
. ./lib-git-svn.sh
-echo 'define NO_SVN_TESTS to skip git-svn tests'
+say 'define NO_SVN_TESTS to skip git-svn tests'
test_expect_success \
- 'initialize git-svn' "
+ 'initialize git-svn' '
mkdir import &&
cd import &&
echo foo > foo &&
ln -s foo foo.link
mkdir -p dir/a/b/c/d/e &&
- echo 'deep dir' > dir/a/b/c/d/e/file &&
+ echo "deep dir" > dir/a/b/c/d/e/file &&
mkdir bar &&
- echo 'zzz' > bar/zzz &&
- echo '#!/bin/sh' > exec.sh &&
+ echo "zzz" > bar/zzz &&
+ echo "#!/bin/sh" > exec.sh &&
chmod +x exec.sh &&
- svn import -m 'import for git-svn' . $svnrepo >/dev/null &&
+ svn import -m "import for git-svn" . "$svnrepo" >/dev/null &&
cd .. &&
rm -rf import &&
- git-svn init $svnrepo"
+ git-svn init "$svnrepo"'
test_expect_success \
'import an SVN revision into git' \
'git-svn fetch'
-test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'"
+test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"'
name='try a deep --rmdir with a commit'
-test_expect_success "$name" "
+test_expect_success "$name" '
git checkout -f -b mybranch remotes/git-svn &&
mv dir/a/b/c/d/e/file dir/file &&
cp dir/file file &&
git update-index --add --remove dir/a/b/c/d/e/file dir/file file &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch &&
- svn up '$SVN_TREE' &&
- test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a"
+ svn up "$SVN_TREE" &&
+ test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a'
name='detect node change from file to directory #1'
-test_expect_failure "$name" "
+test_expect_success "$name" "
mkdir dir/new_file &&
mv dir/file dir/new_file/file &&
mv dir/new_file dir/file &&
git update-index --remove dir/file &&
git update-index --add dir/file/file &&
- git commit -m '$name' &&
- git-svn set-tree --find-copies-harder --rmdir \
+ git commit -m '$name' &&
+ test_must_fail git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch" || true
name='detect node change from directory to file #1'
-test_expect_failure "$name" "
- rm -rf dir '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -rf dir "$GIT_DIR"/index &&
git checkout -f -b mybranch2 remotes/git-svn &&
mv bar/zzz zzz &&
rm -rf bar &&
mv zzz bar &&
git update-index --remove -- bar/zzz &&
git update-index --add -- bar &&
- git commit -m '$name' &&
- git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch2" || true
+ git commit -m "$name" &&
+ test_must_fail git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch2' || true
name='detect node change from file to directory #2'
-test_expect_failure "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch3 remotes/git-svn &&
rm bar/zzz &&
git update-index --remove bar/zzz &&
mkdir bar/zzz &&
echo yyy > bar/zzz/yyy &&
git update-index --add bar/zzz/yyy &&
- git commit -m '$name' &&
- git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch3" || true
+ git commit -m "$name" &&
+ test_must_fail git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch3' || true
name='detect node change from directory to file #2'
-test_expect_failure "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch4 remotes/git-svn &&
rm -rf dir &&
git update-index --remove -- dir/file &&
touch dir &&
echo asdf > dir &&
git update-index --add -- dir &&
- git commit -m '$name' &&
- git-svn set-tree --find-copies-harder --rmdir \
- remotes/git-svn..mybranch4" || true
+ git commit -m "$name" &&
+ test_must_fail git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch4' || true
name='remove executable bit from a file'
-test_expect_success "$name" "
- rm -f '$GIT_DIR'/index &&
+test_expect_success "$name" '
+ rm -f "$GIT_DIR"/index &&
git checkout -f -b mybranch5 remotes/git-svn &&
chmod -x exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test ! -x '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test ! -x "$SVN_TREE"/exec.sh'
name='add executable bit back file'
-test_expect_success "$name" "
+test_expect_success "$name" '
chmod +x exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -x '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test -x "$SVN_TREE"/exec.sh'
name='executable file becomes a symlink to bar/zzz (file)'
-test_expect_success "$name" "
+test_expect_success "$name" '
rm exec.sh &&
ln -s bar/zzz exec.sh &&
git update-index exec.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -L '$SVN_TREE'/exec.sh"
+ svn up "$SVN_TREE" &&
+ test -L "$SVN_TREE"/exec.sh'
name='new symlink is added to a file that was also just made executable'
-test_expect_success "$name" "
+test_expect_success "$name" '
chmod +x bar/zzz &&
ln -s bar/zzz exec-2.sh &&
git update-index --add bar/zzz exec-2.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -x '$SVN_TREE'/bar/zzz &&
- test -L '$SVN_TREE'/exec-2.sh"
+ svn up "$SVN_TREE" &&
+ test -x "$SVN_TREE"/bar/zzz &&
+ test -L "$SVN_TREE"/exec-2.sh'
name='modify a symlink to become a file'
-test_expect_success "$name" "
+test_expect_success "$name" '
echo git help > help || true &&
rm exec-2.sh &&
cp help exec-2.sh &&
git update-index exec-2.sh &&
- git commit -m '$name' &&
+ git commit -m "$name" &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
- svn up '$SVN_TREE' &&
- test -f '$SVN_TREE'/exec-2.sh &&
- test ! -L '$SVN_TREE'/exec-2.sh &&
- git diff help $SVN_TREE/exec-2.sh"
+ svn up "$SVN_TREE" &&
+ test -f "$SVN_TREE"/exec-2.sh &&
+ test ! -L "$SVN_TREE"/exec-2.sh &&
+ test_cmp help "$SVN_TREE"/exec-2.sh'
if test "$have_utf8" = t
then
@@ -183,17 +183,17 @@ then
git-svn set-tree HEAD"
unset LC_ALL
else
- echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
+ say "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
fi
name='test fetch functionality (svn => git) with alternate GIT_SVN_ID'
GIT_SVN_ID=alt
export GIT_SVN_ID
test_expect_success "$name" \
- "git-svn init $svnrepo && git-svn fetch &&
+ 'git-svn init "$svnrepo" && git-svn fetch &&
git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
- git diff a b"
+ test_cmp a b'
name='check imported tree checksums expected tree checksums'
rm -f expected
@@ -211,30 +211,30 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
EOF
-test_expect_success "$name" "git diff a expected"
+test_expect_success "$name" "test_cmp a expected"
-test_expect_failure 'exit if remote refs are ambigious' "
+test_expect_success 'exit if remote refs are ambigious' "
git config --add svn-remote.svn.fetch \
bar:refs/remotes/git-svn &&
- git-svn migrate
- "
+ test_must_fail git-svn migrate
+"
-test_expect_failure 'exit if init-ing a would clobber a URL' "
- svnadmin create ${PWD}/svnrepo2 &&
- svn mkdir -m 'mkdir bar' ${svnrepo}2/bar &&
+test_expect_success 'exit if init-ing a would clobber a URL' '
+ svnadmin create "${PWD}/svnrepo2" &&
+ svn mkdir -m "mkdir bar" "${svnrepo}2/bar" &&
git config --unset svn-remote.svn.fetch \
- '^bar:refs/remotes/git-svn$' &&
- git-svn init ${svnrepo}2/bar
- "
+ "^bar:refs/remotes/git-svn$" &&
+ test_must_fail git-svn init "${svnrepo}2/bar"
+ '
test_expect_success \
- 'init allows us to connect to another directory in the same repo' "
- git-svn init --minimize-url -i bar $svnrepo/bar &&
+ 'init allows us to connect to another directory in the same repo' '
+ git-svn init --minimize-url -i bar "$svnrepo/bar" &&
git config --get svn-remote.svn.fetch \
- '^bar:refs/remotes/bar$' &&
+ "^bar:refs/remotes/bar$" &&
git config --get svn-remote.svn.fetch \
- '^:refs/remotes/git-svn$'
- "
+ "^:refs/remotes/git-svn$"
+ '
test_expect_success 'able to dcommit to a subdirectory' "
git-svn fetch -i bar &&
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index d7a704754..f420796c3 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -52,7 +52,7 @@ EOF
cd ..
rm -rf import
-test_expect_success 'checkout working copy from svn' "svn co $svnrepo test_wc"
+test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
test_expect_success 'setup some commits to svn' \
'cd test_wc &&
echo Greetings >> kw.c &&
@@ -66,7 +66,7 @@ test_expect_success 'setup some commits to svn' \
svn commit -m "Propset Id" &&
cd ..'
-test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
+test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"'
test_expect_success 'fetch revisions from svn' 'git-svn fetch'
name='test svn:keywords ignoring'
@@ -90,9 +90,9 @@ test_expect_success "propset CR on crlf files" \
cd ..'
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
- "git-svn fetch &&
+ 'git-svn fetch &&
git pull . remotes/git-svn &&
- svn co $svnrepo new_wc"
+ svn co "$svnrepo" new_wc'
for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf
do
diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh
index 4e0808380..0e7ce34b9 100755
--- a/t/t9102-git-svn-deep-rmdir.sh
+++ b/t/t9102-git-svn-deep-rmdir.sh
@@ -2,29 +2,29 @@
test_description='git-svn rmdir'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
mkdir -p deeply/nested/directory/number/1 &&
mkdir -p deeply/nested/directory/number/2 &&
echo foo > deeply/nested/directory/number/1/file &&
echo foo > deeply/nested/directory/number/2/another &&
- svn import -m 'import for git-svn' . $svnrepo &&
+ svn import -m "import for git-svn" . "$svnrepo" &&
cd ..
- "
+ '
-test_expect_success 'mirror via git-svn' "
- git-svn init $svnrepo &&
+test_expect_success 'mirror via git-svn' '
+ git-svn init "$svnrepo" &&
git-svn fetch &&
git checkout -f -b test-rmdir remotes/git-svn
- "
+ '
-test_expect_success 'Try a commit on rmdir' "
+test_expect_success 'Try a commit on rmdir' '
git rm -f deeply/nested/directory/number/2/another &&
- git commit -a -m 'remove another' &&
+ git commit -a -m "remove another" &&
git-svn set-tree --rmdir HEAD &&
- svn ls -R $svnrepo | grep ^deeply/nested/directory/number/1
- "
+ svn ls -R "$svnrepo" | grep ^deeply/nested/directory/number/1
+ '
test_done
diff --git a/t/t9103-git-svn-tracked-directory-removed.sh b/t/t9103-git-svn-tracked-directory-removed.sh
index 0f0b0fd2c..9ffd8458e 100755
--- a/t/t9103-git-svn-tracked-directory-removed.sh
+++ b/t/t9103-git-svn-tracked-directory-removed.sh
@@ -10,30 +10,30 @@ test_expect_success 'make history for tracking' '
mkdir import &&
mkdir import/trunk &&
echo hello >> import/trunk/README &&
- svn import -m initial import $svnrepo &&
+ svn import -m initial import "$svnrepo" &&
rm -rf import &&
- svn co $svnrepo/trunk trunk &&
+ svn co "$svnrepo"/trunk trunk &&
echo bye bye >> trunk/README &&
- svn rm -m "gone" $svnrepo/trunk &&
+ svn rm -m "gone" "$svnrepo"/trunk &&
rm -rf trunk &&
mkdir trunk &&
echo "new" > trunk/FOLLOWME &&
- svn import -m "new trunk" trunk $svnrepo/trunk
+ svn import -m "new trunk" trunk "$svnrepo"/trunk
'
test_expect_success 'clone repo with git' '
- git svn clone -s $svnrepo x &&
+ git svn clone -s "$svnrepo" x &&
test -f x/FOLLOWME &&
test ! -f x/README
'
-test_expect_success 'make sure r2 still has old file' '
+test_expect_success 'make sure r2 still has old file' "
cd x &&
- test -n "$(git svn find-rev r1)" &&
- git reset --hard $(git svn find-rev r1) &&
+ test -n \"\$(git svn find-rev r1)\" &&
+ git reset --hard \$(git svn find-rev r1) &&
test -f README &&
test ! -f FOLLOWME &&
- test x$(git svn find-rev r2) = x
-'
+ test x\$(git svn find-rev r2) = x
+"
test_done
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 7ba76309a..4d964e2db 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -6,165 +6,165 @@
test_description='git-svn fetching'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
mkdir -p trunk &&
echo hello > trunk/readme &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
- svn co $svnrepo wc &&
+ svn co "$svnrepo" wc &&
cd wc &&
echo world >> trunk/readme &&
poke trunk/readme &&
- svn commit -m 'another commit' &&
+ svn commit -m "another commit" &&
svn up &&
svn mv trunk thunk &&
echo goodbye >> thunk/readme &&
poke thunk/readme &&
- svn commit -m 'bye now' &&
+ svn commit -m "bye now" &&
cd ..
- "
+ '
-test_expect_success 'init and fetch a moved directory' "
- git-svn init --minimize-url -i thunk $svnrepo/thunk &&
+test_expect_success 'init and fetch a moved directory' '
+ git-svn init --minimize-url -i thunk "$svnrepo"/thunk &&
git-svn fetch -i thunk &&
- test \"\`git rev-parse --verify refs/remotes/thunk@2\`\" \
- = \"\`git rev-parse --verify refs/remotes/thunk~1\`\" &&
- test \"\`git cat-file blob refs/remotes/thunk:readme |\
- sed -n -e '3p'\`\" = goodbye &&
- test -z \"\`git config --get svn-remote.svn.fetch \
- '^trunk:refs/remotes/thunk@2$'\`\"
- "
+ test "`git rev-parse --verify refs/remotes/thunk@2`" \
+ = "`git rev-parse --verify refs/remotes/thunk~1`" &&
+ test "`git cat-file blob refs/remotes/thunk:readme |\
+ sed -n -e "3p"`" = goodbye &&
+ test -z "`git config --get svn-remote.svn.fetch \
+ "^trunk:refs/remotes/thunk@2$"`"
+ '
-test_expect_success 'init and fetch from one svn-remote' "
- git config svn-remote.svn.url $svnrepo &&
+test_expect_success 'init and fetch from one svn-remote' '
+ git config svn-remote.svn.url "$svnrepo" &&
git config --add svn-remote.svn.fetch \
trunk:refs/remotes/svn/trunk &&
git config --add svn-remote.svn.fetch \
thunk:refs/remotes/svn/thunk &&
git-svn fetch -i svn/thunk &&
- test \"\`git rev-parse --verify refs/remotes/svn/trunk\`\" \
- = \"\`git rev-parse --verify refs/remotes/svn/thunk~1\`\" &&
- test \"\`git cat-file blob refs/remotes/svn/thunk:readme |\
- sed -n -e '3p'\`\" = goodbye
- "
+ test "`git rev-parse --verify refs/remotes/svn/trunk`" \
+ = "`git rev-parse --verify refs/remotes/svn/thunk~1`" &&
+ test "`git cat-file blob refs/remotes/svn/thunk:readme |\
+ sed -n -e "3p"`" = goodbye
+ '
-test_expect_success 'follow deleted parent' "
- (svn cp -m 'resurrecting trunk as junk' \
- $svnrepo/trunk@2 $svnrepo/junk ||
- svn cp -m 'resurrecting trunk as junk' \
- -r2 $svnrepo/trunk $svnrepo/junk) &&
+test_expect_success 'follow deleted parent' '
+ (svn cp -m "resurrecting trunk as junk" \
+ "$svnrepo"/trunk@2 "$svnrepo"/junk ||
+ svn cp -m "resurrecting trunk as junk" \
+ -r2 "$svnrepo"/trunk "$svnrepo"/junk) &&
git config --add svn-remote.svn.fetch \
junk:refs/remotes/svn/junk &&
git-svn fetch -i svn/thunk &&
git-svn fetch -i svn/junk &&
- test -z \"\`git diff svn/junk svn/trunk\`\" &&
- test \"\`git merge-base svn/junk svn/trunk\`\" \
- = \"\`git rev-parse svn/trunk\`\"
- "
+ test -z "`git diff svn/junk svn/trunk`" &&
+ test "`git merge-base svn/junk svn/trunk`" \
+ = "`git rev-parse svn/trunk`"
+ '
-test_expect_success 'follow larger parent' "
+test_expect_success 'follow larger parent' '
mkdir -p import/trunk/thunk/bump/thud &&
echo hi > import/trunk/thunk/bump/thud/file &&
- svn import -m 'import a larger parent' import $svnrepo/larger-parent &&
- svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger &&
+ svn import -m "import a larger parent" import "$svnrepo"/larger-parent &&
+ svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger &&
git-svn init --minimize-url -i larger \
- $svnrepo/another-larger/trunk/thunk/bump/thud &&
+ "$svnrepo"/another-larger/trunk/thunk/bump/thud &&
git-svn fetch -i larger &&
git rev-parse --verify refs/remotes/larger &&
git rev-parse --verify \
refs/remotes/larger-parent/trunk/thunk/bump/thud &&
- test \"\`git merge-base \
+ test "`git merge-base \
refs/remotes/larger-parent/trunk/thunk/bump/thud \
- refs/remotes/larger\`\" = \
- \"\`git rev-parse refs/remotes/larger\`\"
+ refs/remotes/larger`" = \
+ "`git rev-parse refs/remotes/larger`"
true
- "
+ '
-test_expect_success 'follow higher-level parent' "
- svn mkdir -m 'follow higher-level parent' $svnrepo/blob &&
- svn co $svnrepo/blob blob &&
+test_expect_success 'follow higher-level parent' '
+ svn mkdir -m "follow higher-level parent" "$svnrepo"/blob &&
+ svn co "$svnrepo"/blob blob &&
cd blob &&
echo hi > hi &&
svn add hi &&
- svn commit -m 'hihi' &&
+ svn commit -m "hihi" &&
cd ..
- svn mkdir -m 'new glob at top level' $svnrepo/glob &&
- svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob &&
- git-svn init --minimize-url -i blob $svnrepo/glob/blob &&
+ svn mkdir -m "new glob at top level" "$svnrepo"/glob &&
+ svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob &&
+ git-svn init --minimize-url -i blob "$svnrepo"/glob/blob &&
git-svn fetch -i blob
- "
+ '
-test_expect_success 'follow deleted directory' "
- svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye &&
- svn rm -m 'remove glob' $svnrepo/glob &&
- git-svn init --minimize-url -i glob $svnrepo/glob &&
+test_expect_success 'follow deleted directory' '
+ svn mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye &&
+ svn rm -m "remove glob" "$svnrepo"/glob &&
+ git-svn init --minimize-url -i glob "$svnrepo"/glob &&
git-svn fetch -i glob &&
- test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi &&
- test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1
- "
+ test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi &&
+ test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1
+ '
# ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn)
# in trunk/subversion/bindings/swig/perl
-test_expect_success 'follow-parent avoids deleting relevant info' "
+test_expect_success 'follow-parent avoids deleting relevant info' '
mkdir -p import/trunk/subversion/bindings/swig/perl/t &&
for i in a b c ; do \
- echo \$i > import/trunk/subversion/bindings/swig/perl/\$i.pm &&
- echo _\$i > import/trunk/subversion/bindings/swig/perl/t/\$i.t; \
+ echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm &&
+ echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \
done &&
- echo 'bad delete test' > \
+ echo "bad delete test" > \
import/trunk/subversion/bindings/swig/perl/t/larger-parent &&
- echo 'bad delete test 2' > \
+ echo "bad delete test 2" > \
import/trunk/subversion/bindings/swig/perl/another-larger &&
cd import &&
- svn import -m 'r9270 test' . $svnrepo/r9270 &&
+ svn import -m "r9270 test" . "$svnrepo"/r9270 &&
cd .. &&
- svn co $svnrepo/r9270/trunk/subversion/bindings/swig/perl r9270 &&
+ svn co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 &&
cd r9270 &&
svn mkdir native &&
svn mv t native/t &&
- for i in a b c; do svn mv \$i.pm native/\$i.pm; done &&
+ for i in a b c; do svn mv $i.pm native/$i.pm; done &&
echo z >> native/t/c.t &&
poke native/t/c.t &&
- svn commit -m 'reorg test' &&
+ svn commit -m "reorg test" &&
cd .. &&
git-svn init --minimize-url -i r9270-t \
- $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t &&
+ "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t &&
git-svn fetch -i r9270-t &&
- test \`git rev-list r9270-t | wc -l\` -eq 2 &&
- test \"\`git ls-tree --name-only r9270-t~1\`\" = \
- \"\`git ls-tree --name-only r9270-t\`\"
- "
+ test `git rev-list r9270-t | wc -l` -eq 2 &&
+ test "`git ls-tree --name-only r9270-t~1`" = \
+ "`git ls-tree --name-only r9270-t`"
+ '
-test_expect_success "track initial change if it was only made to parent" "
- svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk &&
+test_expect_success "track initial change if it was only made to parent" '
+ svn cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk &&
git-svn init --minimize-url -i r9270-d \
- $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t &&
+ "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t &&
git-svn fetch -i r9270-d &&
- test \`git rev-list r9270-d | wc -l\` -eq 3 &&
- test \"\`git ls-tree --name-only r9270-t\`\" = \
- \"\`git ls-tree --name-only r9270-d\`\" &&
- test \"\`git rev-parse r9270-t\`\" = \
- \"\`git rev-parse r9270-d~1\`\"
- "
+ test `git rev-list r9270-d | wc -l` -eq 3 &&
+ test "`git ls-tree --name-only r9270-t`" = \
+ "`git ls-tree --name-only r9270-d`" &&
+ test "`git rev-parse r9270-t`" = \
+ "`git rev-parse r9270-d~1`"
+ '
-test_expect_success "track multi-parent paths" "
- svn cp -m 'resurrect /glob' $svnrepo/r9270 $svnrepo/glob &&
+test_expect_success "track multi-parent paths" '
+ svn cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
git-svn multi-fetch &&
- test \`git cat-file commit refs/remotes/glob | \
- grep '^parent ' | wc -l\` -eq 2
- "
+ test `git cat-file commit refs/remotes/glob | \
+ grep "^parent " | wc -l` -eq 2
+ '
test_expect_success "multi-fetch continues to work" "
git-svn multi-fetch
"
-test_expect_success "multi-fetch works off a 'clean' repository" "
- rm -r $GIT_DIR/svn $GIT_DIR/refs/remotes $GIT_DIR/logs &&
- mkdir $GIT_DIR/svn &&
+test_expect_success "multi-fetch works off a 'clean' repository" '
+ rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
+ mkdir "$GIT_DIR/svn" &&
git-svn multi-fetch
- "
+ '
test_debug 'gitk --all &'
diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh
index 318e172ef..63230367b 100755
--- a/t/t9105-git-svn-commit-diff.sh
+++ b/t/t9105-git-svn-commit-diff.sh
@@ -4,18 +4,18 @@
test_description='git-svn commit-diff'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
echo hello > readme &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
echo hello > readme &&
git update-index --add readme &&
- git commit -a -m 'initial' &&
+ git commit -a -m "initial" &&
echo world >> readme &&
- git commit -a -m 'another'
- "
+ git commit -a -m "another"
+ '
head=`git rev-parse --verify HEAD^0`
prev=`git rev-parse --verify HEAD^1`
@@ -24,20 +24,20 @@ prev=`git rev-parse --verify HEAD^1`
# commit, so only a basic test of functionality is needed since we've
# already tested commit extensively elsewhere
-test_expect_success 'test the commit-diff command' "
- test -n '$prev' && test -n '$head' &&
- git-svn commit-diff -r1 '$prev' '$head' '$svnrepo' &&
- svn co $svnrepo wc &&
+test_expect_success 'test the commit-diff command' '
+ test -n "$prev" && test -n "$head" &&
+ git-svn commit-diff -r1 "$prev" "$head" "$svnrepo" &&
+ svn co "$svnrepo" wc &&
cmp readme wc/readme
- "
+ '
-test_expect_success 'commit-diff to a sub-directory (with git-svn config)' "
- svn import -m 'sub-directory' import $svnrepo/subdir &&
- git-svn init --minimize-url $svnrepo/subdir &&
+test_expect_success 'commit-diff to a sub-directory (with git-svn config)' '
+ svn import -m "sub-directory" import "$svnrepo"/subdir &&
+ git-svn init --minimize-url "$svnrepo"/subdir &&
git-svn fetch &&
- git-svn commit-diff -r3 '$prev' '$head' &&
- svn cat $svnrepo/subdir/readme > readme.2 &&
+ git-svn commit-diff -r3 "$prev" "$head" &&
+ svn cat "$svnrepo"/subdir/readme > readme.2 &&
cmp readme readme.2
- "
+ '
test_done
diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh
index 79b7968ea..83896e968 100755
--- a/t/t9106-git-svn-commit-diff-clobber.sh
+++ b/t/t9106-git-svn-commit-diff-clobber.sh
@@ -4,56 +4,56 @@
test_description='git-svn commit-diff clobber'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
echo initial > file &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
echo initial > file &&
git update-index --add file &&
- git commit -a -m 'initial'
- "
-test_expect_success 'commit change from svn side' "
- svn co $svnrepo t.svn &&
+ git commit -a -m "initial"
+ '
+test_expect_success 'commit change from svn side' '
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo second line from svn >> file &&
poke file &&
- svn commit -m 'second line from svn' &&
+ svn commit -m "second line from svn" &&
cd .. &&
rm -rf t.svn
- "
+ '
-test_expect_failure 'commit conflicting change from git' "
+test_expect_success 'commit conflicting change from git' '
echo second line from git >> file &&
- git commit -a -m 'second line from git' &&
- git-svn commit-diff -r1 HEAD~1 HEAD $svnrepo
- " || true
+ git commit -a -m "second line from git" &&
+ test_must_fail git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo"
+'
-test_expect_success 'commit complementing change from git' "
+test_expect_success 'commit complementing change from git' '
git reset --hard HEAD~1 &&
echo second line from svn >> file &&
- git commit -a -m 'second line from svn' &&
+ git commit -a -m "second line from svn" &&
echo third line from git >> file &&
- git commit -a -m 'third line from git' &&
- git-svn commit-diff -r2 HEAD~1 HEAD $svnrepo
- "
+ git commit -a -m "third line from git" &&
+ git-svn commit-diff -r2 HEAD~1 HEAD "$svnrepo"
+ '
-test_expect_failure 'dcommit fails to commit because of conflict' "
- git-svn init $svnrepo &&
+test_expect_success 'dcommit fails to commit because of conflict' '
+ git-svn init "$svnrepo" &&
git-svn fetch &&
git reset --hard refs/remotes/git-svn &&
- svn co $svnrepo t.svn &&
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo fourth line from svn >> file &&
poke file &&
- svn commit -m 'fourth line from svn' &&
+ svn commit -m "fourth line from svn" &&
cd .. &&
rm -rf t.svn &&
- echo 'fourth line from git' >> file &&
- git commit -a -m 'fourth line from git' &&
- git-svn dcommit
- " || true
+ echo "fourth line from git" >> file &&
+ git commit -a -m "fourth line from git" &&
+ test_must_fail git-svn dcommit
+ '
test_expect_success 'dcommit does the svn equivalent of an index merge' "
git reset --hard refs/remotes/git-svn &&
@@ -66,28 +66,30 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' "
git-svn dcommit
"
-test_expect_success 'commit another change from svn side' "
- svn co $svnrepo t.svn &&
+test_expect_success 'commit another change from svn side' '
+ svn co "$svnrepo" t.svn &&
cd t.svn &&
echo third line from svn >> file &&
poke file &&
- svn commit -m 'third line from svn' &&
+ svn commit -m "third line from svn" &&
cd .. &&
rm -rf t.svn
- "
+ '
-test_expect_failure 'multiple dcommit from git-svn will not clobber svn' "
+test_expect_success 'multiple dcommit from git-svn will not clobber svn' "
git reset --hard refs/remotes/git-svn &&
echo new file >> new-file &&
git update-index --add new-file &&
git commit -a -m 'new file' &&
echo clobber > file &&
git commit -a -m 'clobber' &&
- git svn dcommit
- " || true
+ test_must_fail git svn dcommit
+ "
-test_expect_success 'check that rebase really failed' 'test -d .dotest'
+test_expect_success 'check that rebase really failed' '
+ test -d .git/rebase-apply
+'
test_expect_success 'resolve, continue the rebase and dcommit' "
echo clobber and I really mean it > file &&
diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh
index 745254665..bc37db9d6 100755
--- a/t/t9106-git-svn-dcommit-clobber-series.sh
+++ b/t/t9106-git-svn-dcommit-clobber-series.sh
@@ -4,30 +4,30 @@
test_description='git-svn dcommit clobber series'
. ./lib-git-svn.sh
-test_expect_success 'initialize repo' "
+test_expect_success 'initialize repo' '
mkdir import &&
cd import &&
- awk 'BEGIN { for (i = 1; i < 64; i++) { print i } }' > file
- svn import -m 'initial' . $svnrepo &&
+ awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
- git svn init $svnrepo &&
+ git svn init "$svnrepo" &&
git svn fetch &&
test -e file
- "
+ '
-test_expect_success '(supposedly) non-conflicting change from SVN' "
- test x\"\`sed -n -e 58p < file\`\" = x58 &&
- test x\"\`sed -n -e 61p < file\`\" = x61 &&
- svn co $svnrepo tmp &&
+test_expect_success '(supposedly) non-conflicting change from SVN' '
+ test x"`sed -n -e 58p < file`" = x58 &&
+ test x"`sed -n -e 61p < file`" = x61 &&
+ svn co "$svnrepo" tmp &&
cd tmp &&
- perl -i -p -e 's/^58\$/5588/' file &&
- perl -i -p -e 's/^61\$/6611/' file &&
+ perl -i.bak -p -e "s/^58$/5588/" file &&
+ perl -i.bak -p -e "s/^61$/6611/" file &&
poke file &&
- test x\"\`sed -n -e 58p < file\`\" = x5588 &&
- test x\"\`sed -n -e 61p < file\`\" = x6611 &&
- svn commit -m '58 => 5588, 61 => 6611' &&
+ test x"`sed -n -e 58p < file`" = x5588 &&
+ test x"`sed -n -e 61p < file`" = x6611 &&
+ svn commit -m "58 => 5588, 61 => 6611" &&
cd ..
- "
+ '
test_expect_success 'some unrelated changes to git' "
echo hi > life &&
@@ -40,8 +40,8 @@ test_expect_success 'some unrelated changes to git' "
test_expect_success 'change file but in unrelated area' "
test x\"\`sed -n -e 4p < file\`\" = x4 &&
test x\"\`sed -n -e 7p < file\`\" = x7 &&
- perl -i -p -e 's/^4\$/4444/' file &&
- perl -i -p -e 's/^7\$/7777/' file &&
+ perl -i.bak -p -e 's/^4\$/4444/' file &&
+ perl -i.bak -p -e 's/^7\$/7777/' file &&
test x\"\`sed -n -e 4p < file\`\" = x4444 &&
test x\"\`sed -n -e 7p < file\`\" = x7777 &&
git commit -m '4 => 4444, 7 => 7777' file &&
@@ -54,10 +54,10 @@ test_expect_success 'change file but in unrelated area' "
test x\"\`sed -n -e 61p < file\`\" = x6611
"
-test_expect_failure 'attempt to dcommit with a dirty index' '
+test_expect_success 'attempt to dcommit with a dirty index' '
echo foo >>file &&
git add file &&
- git svn dcommit
+ test_must_fail git svn dcommit
'
test_done
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
index 0a41d52c7..d9b553ad5 100755
--- a/t/t9107-git-svn-migrate.sh
+++ b/t/t9107-git-svn-migrate.sh
@@ -3,61 +3,61 @@
test_description='git-svn metadata migrations from previous versions'
. ./lib-git-svn.sh
-test_expect_success 'setup old-looking metadata' "
- cp $GIT_DIR/config $GIT_DIR/config-old-git-svn &&
+test_expect_success 'setup old-looking metadata' '
+ cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn &&
mkdir import &&
cd import &&
for i in trunk branches/a branches/b \
tags/0.1 tags/0.2 tags/0.3; do
- mkdir -p \$i && \
- echo hello >> \$i/README || exit 1
+ mkdir -p $i && \
+ echo hello >> $i/README || exit 1
done && \
- svn import -m test . $svnrepo
+ svn import -m test . "$svnrepo"
cd .. &&
- git-svn init $svnrepo &&
+ git-svn init "$svnrepo" &&
git-svn fetch &&
- mv $GIT_DIR/svn/* $GIT_DIR/ &&
- mv $GIT_DIR/svn/.metadata $GIT_DIR/ &&
- rmdir $GIT_DIR/svn &&
+ mv "$GIT_DIR"/svn/* "$GIT_DIR"/ &&
+ mv "$GIT_DIR"/svn/.metadata "$GIT_DIR"/ &&
+ rmdir "$GIT_DIR"/svn &&
git update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn &&
git update-ref refs/heads/svn-HEAD refs/remotes/git-svn &&
git update-ref -d refs/remotes/git-svn refs/remotes/git-svn
- "
+ '
head=`git rev-parse --verify refs/heads/git-svn-HEAD^0`
test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'"
-test_expect_success 'initialize old-style (v0) git-svn layout' "
- mkdir -p $GIT_DIR/git-svn/info $GIT_DIR/svn/info &&
- echo $svnrepo > $GIT_DIR/git-svn/info/url &&
- echo $svnrepo > $GIT_DIR/svn/info/url &&
+test_expect_success 'initialize old-style (v0) git-svn layout' '
+ mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info &&
+ echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url &&
+ echo "$svnrepo" > "$GIT_DIR"/svn/info/url &&
git-svn migrate &&
- ! test -d $GIT_DIR/git-svn &&
+ ! test -d "$GIT_DIR"/git-svn &&
git rev-parse --verify refs/remotes/git-svn^0 &&
git rev-parse --verify refs/remotes/svn^0 &&
- test \`git config --get svn-remote.svn.url\` = '$svnrepo' &&
- test \`git config --get svn-remote.svn.fetch\` = \
- ':refs/remotes/git-svn'
- "
+ test "$(git config --get svn-remote.svn.url)" = "$svnrepo" &&
+ test `git config --get svn-remote.svn.fetch` = \
+ ":refs/remotes/git-svn"
+ '
-test_expect_success 'initialize a multi-repository repo' "
- git-svn init $svnrepo -T trunk -t tags -b branches &&
+test_expect_success 'initialize a multi-repository repo' '
+ git-svn init "$svnrepo" -T trunk -t tags -b branches &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep '^trunk:refs/remotes/trunk$' fetch.out &&
- test -n \"\`git config --get svn-remote.svn.branches \
- '^branches/\*:refs/remotes/\*$'\`\" &&
- test -n \"\`git config --get svn-remote.svn.tags \
- '^tags/\*:refs/remotes/tags/\*$'\`\" &&
+ grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ test -n "`git config --get svn-remote.svn.branches \
+ "^branches/\*:refs/remotes/\*$"`" &&
+ test -n "`git config --get svn-remote.svn.tags \
+ "^tags/\*:refs/remotes/tags/\*$"`" &&
git config --unset svn-remote.svn.branches \
- '^branches/\*:refs/remotes/\*$' &&
+ "^branches/\*:refs/remotes/\*$" &&
git config --unset svn-remote.svn.tags \
- '^tags/\*:refs/remotes/tags/\*$' &&
- git config --add svn-remote.svn.fetch 'branches/a:refs/remotes/a' &&
- git config --add svn-remote.svn.fetch 'branches/b:refs/remotes/b' &&
+ "^tags/\*:refs/remotes/tags/\*$" &&
+ git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
+ git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
for i in tags/0.1 tags/0.2 tags/0.3; do
git config --add svn-remote.svn.fetch \
- \$i:refs/remotes/\$i || exit 1; done
- "
+ $i:refs/remotes/$i || exit 1; done
+ '
# refs should all be different, but the trees should all be the same:
test_expect_success 'multi-fetch works on partial urls + paths' "
@@ -73,43 +73,43 @@ test_expect_success 'multi-fetch works on partial urls + paths' "
refs/remotes/\$j\`\" ||exit 1; done; done
"
-test_expect_success 'migrate --minimize on old inited layout' "
+test_expect_success 'migrate --minimize on old inited layout' '
git config --unset-all svn-remote.svn.fetch &&
git config --unset-all svn-remote.svn.url &&
- rm -rf $GIT_DIR/svn &&
- for i in \`cat fetch.out\`; do
- path=\`expr \$i : '\\([^:]*\\):.*$'\`
- ref=\`expr \$i : '[^:]*:refs/remotes/\\(.*\\)$'\`
- if test -z \"\$ref\"; then continue; fi
- if test -n \"\$path\"; then path=\"/\$path\"; fi
- ( mkdir -p $GIT_DIR/svn/\$ref/info/ &&
- echo $svnrepo\$path > $GIT_DIR/svn/\$ref/info/url ) || exit 1;
+ rm -rf "$GIT_DIR"/svn &&
+ for i in `cat fetch.out`; do
+ path=`expr $i : "\([^:]*\):.*$"`
+ ref=`expr $i : "[^:]*:refs/remotes/\(.*\)$"`
+ if test -z "$ref"; then continue; fi
+ if test -n "$path"; then path="/$path"; fi
+ ( mkdir -p "$GIT_DIR"/svn/$ref/info/ &&
+ echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
done &&
git-svn migrate --minimize &&
- test -z \"\`git config -l |grep -v '^svn-remote\.git-svn\.'\`\" &&
+ test -z "`git config -l |grep -v "^svn-remote\.git-svn\."`" &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep '^trunk:refs/remotes/trunk$' fetch.out &&
- grep '^branches/a:refs/remotes/a$' fetch.out &&
- grep '^branches/b:refs/remotes/b$' fetch.out &&
- grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out &&
- grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out &&
- grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out
- grep '^:refs/remotes/git-svn' fetch.out
- "
+ grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ grep "^branches/a:refs/remotes/a$" fetch.out &&
+ grep "^branches/b:refs/remotes/b$" fetch.out &&
+ grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
+ grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
+ grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out
+ grep "^:refs/remotes/git-svn" fetch.out
+ '
-test_expect_success ".rev_db auto-converted to .rev_map.UUID" "
+test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
git-svn fetch -i trunk &&
- test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" &&
- expect=\"\$(ls $GIT_DIR/svn/trunk/.rev_map.*)\" &&
- test -n \"\$expect\" &&
- rev_db=\$(echo \$expect | sed -e 's,_map,_db,') &&
- convert_to_rev_db \$expect \$rev_db &&
- rm -f \$expect &&
- test -f \$rev_db &&
+ test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
+ expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" &&
+ test -n "$expect" &&
+ rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
+ convert_to_rev_db "$expect" "$rev_db" &&
+ rm -f "$expect" &&
+ test -f "$rev_db" &&
git-svn fetch -i trunk &&
- test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" &&
- test ! -e $GIT_DIR/svn/trunk/.rev_db &&
- test -f \$expect
- "
+ test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" &&
+ test ! -e "$GIT_DIR"/svn/trunk/.rev_db &&
+ test -f "$expect"
+ '
test_done
diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh
index db4344cc8..8b792a137 100755
--- a/t/t9108-git-svn-glob.sh
+++ b/t/t9108-git-svn-glob.sh
@@ -10,77 +10,102 @@ start a new branch
initial
EOF
-test_expect_success 'test refspec globbing' "
+test_expect_success 'test refspec globbing' '
mkdir -p trunk/src/a trunk/src/b trunk/doc &&
- echo 'hello world' > trunk/src/a/readme &&
- echo 'goodbye world' > trunk/src/b/readme &&
- svn import -m 'initial' trunk $svnrepo/trunk &&
- svn co $svnrepo tmp &&
- cd tmp &&
+ echo "hello world" > trunk/src/a/readme &&
+ echo "goodbye world" > trunk/src/b/readme &&
+ svn import -m "initial" trunk "$svnrepo"/trunk &&
+ svn co "$svnrepo" tmp &&
+ (
+ cd tmp &&
mkdir branches tags &&
svn add branches tags &&
svn cp trunk branches/start &&
- svn commit -m 'start a new branch' &&
+ svn commit -m "start a new branch" &&
svn up &&
- echo 'hi' >> branches/start/src/b/readme &&
+ echo "hi" >> branches/start/src/b/readme &&
poke branches/start/src/b/readme &&
- echo 'hey' >> branches/start/src/a/readme &&
+ echo "hey" >> branches/start/src/a/readme &&
poke branches/start/src/a/readme &&
- svn commit -m 'hi' &&
+ svn commit -m "hi" &&
svn up &&
svn cp branches/start tags/end &&
- echo 'bye' >> tags/end/src/b/readme &&
+ echo "bye" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- echo 'aye' >> tags/end/src/a/readme &&
+ echo "aye" >> tags/end/src/a/readme &&
poke tags/end/src/a/readme &&
- svn commit -m 'the end' &&
- echo 'byebye' >> tags/end/src/b/readme &&
+ svn commit -m "the end" &&
+ echo "byebye" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- svn commit -m 'nothing to see here'
- cd .. &&
- git config --add svn-remote.svn.url $svnrepo &&
+ svn commit -m "nothing to see here"
+ ) &&
+ git config --add svn-remote.svn.url "$svnrepo" &&
git config --add svn-remote.svn.fetch \
- 'trunk/src/a:refs/remotes/trunk' &&
+ "trunk/src/a:refs/remotes/trunk" &&
git config --add svn-remote.svn.branches \
- 'branches/*/src/a:refs/remotes/branches/*' &&
+ "branches/*/src/a:refs/remotes/branches/*" &&
git config --add svn-remote.svn.tags\
- 'tags/*/src/a:refs/remotes/tags/*' &&
+ "tags/*/src/a:refs/remotes/tags/*" &&
git-svn multi-fetch &&
git log --pretty=oneline refs/remotes/tags/end | \
- sed -e 's/^.\{41\}//' > output.end &&
- cmp expect.end output.end &&
- test \"\`git rev-parse refs/remotes/tags/end~1\`\" = \
- \"\`git rev-parse refs/remotes/branches/start\`\" &&
- test \"\`git rev-parse refs/remotes/branches/start~2\`\" = \
- \"\`git rev-parse refs/remotes/trunk\`\"
- "
+ sed -e "s/^.\{41\}//" > output.end &&
+ test_cmp expect.end output.end &&
+ test "`git rev-parse refs/remotes/tags/end~1`" = \
+ "`git rev-parse refs/remotes/branches/start`" &&
+ test "`git rev-parse refs/remotes/branches/start~2`" = \
+ "`git rev-parse refs/remotes/trunk`" &&
+ test_must_fail git rev-parse refs/remotes/tags/end@3
+ '
echo try to try > expect.two
echo nothing to see here >> expect.two
cat expect.end >> expect.two
-test_expect_success 'test left-hand-side only globbing' "
- git config --add svn-remote.two.url $svnrepo &&
+test_expect_success 'test left-hand-side only globbing' '
+ git config --add svn-remote.two.url "$svnrepo" &&
git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
git config --add svn-remote.two.branches \
- 'branches/*:refs/remotes/two/branches/*' &&
+ "branches/*:refs/remotes/two/branches/*" &&
git config --add svn-remote.two.tags \
- 'tags/*:refs/remotes/two/tags/*' &&
- cd tmp &&
- echo 'try try' >> tags/end/src/b/readme &&
+ "tags/*:refs/remotes/two/tags/*" &&
+ (
+ cd tmp &&
+ echo "try try" >> tags/end/src/b/readme &&
poke tags/end/src/b/readme &&
- svn commit -m 'try to try'
- cd .. &&
+ svn commit -m "try to try"
+ ) &&
git-svn fetch two &&
- test \`git rev-list refs/remotes/two/tags/end | wc -l\` -eq 6 &&
- test \`git rev-list refs/remotes/two/branches/start | wc -l\` -eq 3 &&
- test \`git rev-parse refs/remotes/two/branches/start~2\` = \
- \`git rev-parse refs/remotes/two/trunk\` &&
- test \`git rev-parse refs/remotes/two/tags/end~3\` = \
- \`git rev-parse refs/remotes/two/branches/start\` &&
+ test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
+ test `git rev-list refs/remotes/two/branches/start | wc -l` -eq 3 &&
+ test `git rev-parse refs/remotes/two/branches/start~2` = \
+ `git rev-parse refs/remotes/two/trunk` &&
+ test `git rev-parse refs/remotes/two/tags/end~3` = \
+ `git rev-parse refs/remotes/two/branches/start` &&
git log --pretty=oneline refs/remotes/two/tags/end | \
- sed -e 's/^.\{41\}//' > output.two &&
- cmp expect.two output.two
- "
+ sed -e "s/^.\{41\}//" > output.two &&
+ test_cmp expect.two output.two
+ '
+
+echo "Only one set of wildcard directories" \
+ "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multi-globs' '
+ git config --add svn-remote.three.url "$svnrepo" &&
+ git config --add svn-remote.three.fetch \
+ trunk:refs/remotes/three/trunk &&
+ git config --add svn-remote.three.branches \
+ "branches/*/t/*:refs/remotes/three/branches/*" &&
+ git config --add svn-remote.three.tags \
+ "tags/*/*:refs/remotes/three/tags/*" &&
+ (
+ cd tmp &&
+ echo "try try" >> tags/end/src/b/readme &&
+ poke tags/end/src/b/readme &&
+ svn commit -m "try to try"
+ ) &&
+ test_must_fail git-svn fetch three 2> stderr.three &&
+ test_cmp expect.three stderr.three
+ '
test_done
diff --git a/t/t9108-git-svn-multi-glob.sh b/t/t9108-git-svn-multi-glob.sh
new file mode 100755
index 000000000..358372165
--- /dev/null
+++ b/t/t9108-git-svn-multi-glob.sh
@@ -0,0 +1,160 @@
+#!/bin/sh
+# Copyright (c) 2007 Eric Wong
+test_description='git-svn globbing refspecs'
+. ./lib-git-svn.sh
+
+cat > expect.end <<EOF
+the end
+hi
+start a new branch
+initial
+EOF
+
+test_expect_success 'test refspec globbing' '
+ mkdir -p trunk/src/a trunk/src/b trunk/doc &&
+ echo "hello world" > trunk/src/a/readme &&
+ echo "goodbye world" > trunk/src/b/readme &&
+ svn import -m "initial" trunk "$svnrepo"/trunk &&
+ svn co "$svnrepo" tmp &&
+ (
+ cd tmp &&
+ mkdir branches branches/v1 tags &&
+ svn add branches tags &&
+ svn cp trunk branches/v1/start &&
+ svn commit -m "start a new branch" &&
+ svn up &&
+ echo "hi" >> branches/v1/start/src/b/readme &&
+ poke branches/v1/start/src/b/readme &&
+ echo "hey" >> branches/v1/start/src/a/readme &&
+ poke branches/v1/start/src/a/readme &&
+ svn commit -m "hi" &&
+ svn up &&
+ svn cp branches/v1/start tags/end &&
+ echo "bye" >> tags/end/src/b/readme &&
+ poke tags/end/src/b/readme &&
+ echo "aye" >> tags/end/src/a/readme &&
+ poke tags/end/src/a/readme &&
+ svn commit -m "the end" &&
+ echo "byebye" >> tags/end/src/b/readme &&
+ poke tags/end/src/b/readme &&
+ svn commit -m "nothing to see here"
+ ) &&
+ git config --add svn-remote.svn.url "$svnrepo" &&
+ git config --add svn-remote.svn.fetch \
+ "trunk/src/a:refs/remotes/trunk" &&
+ git config --add svn-remote.svn.branches \
+ "branches/*/*/src/a:refs/remotes/branches/*/*" &&
+ git config --add svn-remote.svn.tags\
+ "tags/*/src/a:refs/remotes/tags/*" &&
+ git-svn multi-fetch &&
+ git log --pretty=oneline refs/remotes/tags/end | \
+ sed -e "s/^.\{41\}//" > output.end &&
+ test_cmp expect.end output.end &&
+ test "`git rev-parse refs/remotes/tags/end~1`" = \
+ "`git rev-parse refs/remotes/branches/v1/start`" &&
+ test "`git rev-parse refs/remotes/branches/v1/start~2`" = \
+ "`git rev-parse refs/remotes/trunk`" &&
+ test_must_fail git rev-parse refs/remotes/tags/end@3
+ '
+
+echo try to try > expect.two
+echo nothing to see here >> expect.two
+cat expect.end >> expect.two
+
+test_expect_success 'test left-hand-side only globbing' '
+ git config --add svn-remote.two.url "$svnrepo" &&
+ git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&
+ git config --add svn-remote.two.branches \
+ "branches/*/*:refs/remotes/two/branches/*/*" &&
+ git config --add svn-remote.two.tags \
+ "tags/*:refs/remotes/two/tags/*" &&
+ (
+ cd tmp &&
+ echo "try try" >> tags/end/src/b/readme &&
+ poke tags/end/src/b/readme &&
+ svn commit -m "try to try"
+ ) &&
+ git-svn fetch two &&
+ test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 &&
+ test `git rev-list refs/remotes/two/branches/v1/start | wc -l` -eq 3 &&
+ test `git rev-parse refs/remotes/two/branches/v1/start~2` = \
+ `git rev-parse refs/remotes/two/trunk` &&
+ test `git rev-parse refs/remotes/two/tags/end~3` = \
+ `git rev-parse refs/remotes/two/branches/v1/start` &&
+ git log --pretty=oneline refs/remotes/two/tags/end | \
+ sed -e "s/^.\{41\}//" > output.two &&
+ test_cmp expect.two output.two
+ '
+cat > expect.four <<EOF
+adios
+adding more
+Changed 2 in v2/start
+Another versioned branch
+initial
+EOF
+
+test_expect_success 'test another branch' '
+ (
+ cd tmp &&
+ mkdir branches/v2 &&
+ svn add branches/v2 &&
+ svn cp trunk branches/v2/start &&
+ svn commit -m "Another versioned branch" &&
+ svn up &&
+ echo "hello" >> branches/v2/start/src/b/readme &&
+ poke branches/v2/start/src/b/readme &&
+ echo "howdy" >> branches/v2/start/src/a/readme &&
+ poke branches/v2/start/src/a/readme &&
+ svn commit -m "Changed 2 in v2/start" &&
+ svn up &&
+ svn cp branches/v2/start tags/next &&
+ echo "bye" >> tags/next/src/b/readme &&
+ poke tags/next/src/b/readme &&
+ echo "aye" >> tags/next/src/a/readme &&
+ poke tags/next/src/a/readme &&
+ svn commit -m "adding more" &&
+ echo "byebye" >> tags/next/src/b/readme &&
+ poke tags/next/src/b/readme &&
+ svn commit -m "adios"
+ ) &&
+ git config --add svn-remote.four.url "$svnrepo" &&
+ git config --add svn-remote.four.fetch trunk:refs/remotes/four/trunk &&
+ git config --add svn-remote.four.branches \
+ "branches/*/*:refs/remotes/four/branches/*/*" &&
+ git config --add svn-remote.four.tags \
+ "tags/*:refs/remotes/four/tags/*" &&
+ git-svn fetch four &&
+ test `git rev-list refs/remotes/four/tags/next | wc -l` -eq 5 &&
+ test `git rev-list refs/remotes/four/branches/v2/start | wc -l` -eq 3 &&
+ test `git rev-parse refs/remotes/four/branches/v2/start~2` = \
+ `git rev-parse refs/remotes/four/trunk` &&
+ test `git rev-parse refs/remotes/four/tags/next~2` = \
+ `git rev-parse refs/remotes/four/branches/v2/start` &&
+ git log --pretty=oneline refs/remotes/four/tags/next | \
+ sed -e "s/^.\{41\}//" > output.four &&
+ test_cmp expect.four output.four
+ '
+
+echo "Only one set of wildcard directories" \
+ "(e.g. '*' or '*/*/*') is supported: 'branches/*/t/*'" > expect.three
+echo "" >> expect.three
+
+test_expect_success 'test disallow multiple globs' '
+ git config --add svn-remote.three.url "$svnrepo" &&
+ git config --add svn-remote.three.fetch \
+ trunk:refs/remotes/three/trunk &&
+ git config --add svn-remote.three.branches \
+ "branches/*/t/*:refs/remotes/three/branches/*/*" &&
+ git config --add svn-remote.three.tags \
+ "tags/*:refs/remotes/three/tags/*" &&
+ (
+ cd tmp &&
+ echo "try try" >> tags/end/src/b/readme &&
+ poke tags/end/src/b/readme &&
+ svn commit -m "try to try"
+ ) &&
+ test_must_fail git-svn fetch three 2> stderr.three &&
+ test_cmp expect.three stderr.three
+ '
+
+test_done
diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh
index 6235af4db..04d2a65c0 100755
--- a/t/t9110-git-svn-use-svm-props.sh
+++ b/t/t9110-git-svn-use-svm-props.sh
@@ -7,15 +7,15 @@ test_description='git-svn useSvmProps test'
. ./lib-git-svn.sh
-test_expect_success 'load svm repo' "
- svnadmin load -q $rawsvnrepo < ../t9110/svm.dump &&
- git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr &&
- git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh &&
+test_expect_success 'load svm repo' '
+ svnadmin load -q "$rawsvnrepo" < ../t9110/svm.dump &&
+ git-svn init --minimize-url -R arr -i bar "$svnrepo"/mirror/arr &&
+ git-svn init --minimize-url -R argh -i dir "$svnrepo"/mirror/argh &&
git-svn init --minimize-url -R argh -i e \
- $svnrepo/mirror/argh/a/b/c/d/e &&
+ "$svnrepo"/mirror/argh/a/b/c/d/e &&
git config svn.useSvmProps true &&
git-svn fetch --all
- "
+ '
uuid=161ce429-a9dd-4828-af4a-52023f968c89
@@ -49,4 +49,13 @@ test_expect_success 'verify metadata for /dir' "
grep '^git-svn-id: $dir_url@1 $uuid$'
"
+test_expect_success 'find commit based on SVN revision number' "
+ git-svn find-rev r12 |
+ grep `git rev-parse HEAD`
+ "
+
+test_expect_success 'empty rebase' "
+ git-svn rebase
+ "
+
test_done
diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh
index ec7dedd48..a8d74dcd3 100755
--- a/t/t9111-git-svn-use-svnsync-props.sh
+++ b/t/t9111-git-svn-use-svnsync-props.sh
@@ -7,14 +7,14 @@ test_description='git-svn useSvnsyncProps test'
. ./lib-git-svn.sh
-test_expect_success 'load svnsync repo' "
- svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump &&
- git-svn init --minimize-url -R arr -i bar $svnrepo/bar &&
- git-svn init --minimize-url -R argh -i dir $svnrepo/dir &&
- git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e &&
+test_expect_success 'load svnsync repo' '
+ svnadmin load -q "$rawsvnrepo" < ../t9111/svnsync.dump &&
+ git-svn init --minimize-url -R arr -i bar "$svnrepo"/bar &&
+ git-svn init --minimize-url -R argh -i dir "$svnrepo"/dir &&
+ git-svn init --minimize-url -R argh -i e "$svnrepo"/dir/a/b/c/d/e &&
git config svn.useSvnsyncProps true &&
git-svn fetch --all
- "
+ '
uuid=161ce429-a9dd-4828-af4a-52023f968c89
diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh
index 08313bb54..d470a920e 100755
--- a/t/t9112-git-svn-md5less-file.sh
+++ b/t/t9112-git-svn-md5less-file.sh
@@ -1,3 +1,5 @@
+#!/bin/sh
+
test_description='test that git handles an svn repository with missing md5sums'
. ./lib-git-svn.sh
@@ -38,8 +40,8 @@ PROPS-END
EOF
-test_expect_success 'load svn dumpfile' "svnadmin load $rawsvnrepo < dumpfile.svn"
+test_expect_success 'load svn dumpfile' 'svnadmin load "$rawsvnrepo" < dumpfile.svn'
-test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
+test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"'
test_expect_success 'fetch revisions from svn' 'git-svn fetch'
test_done
diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh
index 9ef0db904..ae78e334a 100755
--- a/t/t9113-git-svn-dcommit-new-file.sh
+++ b/t/t9113-git-svn-dcommit-new-file.sh
@@ -7,26 +7,33 @@
# I don't like the idea of taking a port and possibly leaving a
# daemon running on a users system if the test fails.
# Not all git users will need to interact with SVN.
-test -z "$SVNSERVE_PORT" && exit 0
test_description='git-svn dcommit new files over svn:// test'
. ./lib-git-svn.sh
+if test -z "$SVNSERVE_PORT"
+then
+ say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)'
+ test_done
+ exit
+fi
+
start_svnserve () {
svnserve --listen-port $SVNSERVE_PORT \
- --root $rawsvnrepo \
+ --root "$rawsvnrepo" \
--listen-once \
--listen-host 127.0.0.1 &
}
-test_expect_success 'start tracking an empty repo' "
- svn mkdir -m 'empty dir' $svnrepo/empty-dir &&
- echo anon-access = write >> $rawsvnrepo/conf/svnserve.conf &&
+test_expect_success 'start tracking an empty repo' '
+ svn mkdir -m "empty dir" "$svnrepo"/empty-dir &&
+ echo "[general]" > "$rawsvnrepo"/conf/svnserve.conf &&
+ echo anon-access = write >> "$rawsvnrepo"/conf/svnserve.conf &&
start_svnserve &&
git svn init svn://127.0.0.1:$SVNSERVE_PORT &&
git svn fetch
- "
+ '
test_expect_success 'create files in new directory with dcommit' "
mkdir git-new-dir &&
diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh
index 225060b88..61d778161 100755
--- a/t/t9114-git-svn-dcommit-merge.sh
+++ b/t/t9114-git-svn-dcommit-merge.sh
@@ -34,35 +34,35 @@ cat << EOF
EOF
}
-test_expect_success 'setup svn repository' "
- svn co $svnrepo mysvnwork &&
+test_expect_success 'setup svn repository' '
+ svn co "$svnrepo" mysvnwork &&
mkdir -p mysvnwork/trunk &&
cd mysvnwork &&
big_text_block >> trunk/README &&
svn add trunk &&
- svn ci -m 'first commit' trunk &&
+ svn ci -m "first commit" trunk &&
cd ..
- "
+ '
-test_expect_success 'setup git mirror and merge' "
- git svn init $svnrepo -t tags -T trunk -b branches &&
+test_expect_success 'setup git mirror and merge' '
+ git svn init "$svnrepo" -t tags -T trunk -b branches &&
git svn fetch &&
git checkout --track -b svn remotes/trunk &&
git checkout -b merge &&
echo new file > new_file &&
git add new_file &&
- git commit -a -m 'New file' &&
+ git commit -a -m "New file" &&
echo hello >> README &&
- git commit -a -m 'hello' &&
+ git commit -a -m "hello" &&
echo add some stuff >> new_file &&
- git commit -a -m 'add some stuff' &&
+ git commit -a -m "add some stuff" &&
git checkout svn &&
mv -f README tmp &&
echo friend > README &&
cat tmp >> README &&
- git commit -a -m 'friend' &&
+ git commit -a -m "friend" &&
git pull . merge
- "
+ '
test_debug 'gitk --all & sleep 1'
diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh
index 182299cbb..f0fbd3aff 100755
--- a/t/t9115-git-svn-dcommit-funky-renames.sh
+++ b/t/t9115-git-svn-dcommit-funky-renames.sh
@@ -7,16 +7,16 @@ test_description='git-svn dcommit can commit renames of files with ugly names'
. ./lib-git-svn.sh
-test_expect_success 'load repository with strange names' "
- svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump &&
- start_httpd
- "
+test_expect_success 'load repository with strange names' '
+ svnadmin load -q "$rawsvnrepo" < ../t9115/funky-names.dump &&
+ start_httpd gtk+
+ '
-test_expect_success 'init and fetch repository' "
- git svn init $svnrepo &&
+test_expect_success 'init and fetch repository' '
+ git svn init "$svnrepo" &&
git svn fetch &&
git reset --hard git-svn
- "
+ '
test_expect_success 'create file in existing ugly and empty dir' '
mkdir "#{bad_directory_name}" &&
@@ -49,6 +49,39 @@ test_expect_success 'rename pretty file into ugly one' '
git svn dcommit
'
+test_expect_success 'add a file with plus signs' '
+ echo .. > +_+ &&
+ git update-index --add +_+ &&
+ git commit -m plus &&
+ mkdir gtk+ &&
+ git mv +_+ gtk+/_+_ &&
+ git commit -m plus_dir &&
+ git svn dcommit
+ '
+
+test_expect_success 'clone the repository to test rebase' '
+ git svn clone "$svnrepo" test-rebase &&
+ cd test-rebase &&
+ echo test-rebase > test-rebase &&
+ git add test-rebase &&
+ git commit -m test-rebase &&
+ cd ..
+ '
+
+test_expect_success 'make a commit to test rebase' '
+ echo test-rebase-main > test-rebase-main &&
+ git add test-rebase-main &&
+ git commit -m test-rebase-main &&
+ git svn dcommit
+ '
+
+test_expect_success 'git-svn rebase works inside a fresh-cloned repository' '
+ cd test-rebase &&
+ git svn rebase &&
+ test -e test-rebase-main &&
+ test -e test-rebase
+ '
+
stop_httpd
test_done
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index 902ed4145..4b2cc878f 100755
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
@@ -6,17 +6,17 @@
test_description='git-svn log tests'
. ./lib-git-svn.sh
-test_expect_success 'setup repository and import' "
+test_expect_success 'setup repository and import' '
mkdir import &&
cd import &&
for i in trunk branches/a branches/b \
tags/0.1 tags/0.2 tags/0.3; do
- mkdir -p \$i && \
- echo hello >> \$i/README || exit 1
+ mkdir -p $i && \
+ echo hello >> $i/README || exit 1
done && \
- svn import -m test . $svnrepo
+ svn import -m test . "$svnrepo"
cd .. &&
- git-svn init $svnrepo -T trunk -b branches -t tags &&
+ git-svn init "$svnrepo" -T trunk -b branches -t tags &&
git-svn fetch &&
git reset --hard trunk &&
echo bye >> README &&
@@ -37,7 +37,7 @@ test_expect_success 'setup repository and import' "
echo try >> README &&
git commit -a -m try &&
git svn dcommit
- "
+ '
test_expect_success 'run log' "
git reset --hard a &&
@@ -55,74 +55,74 @@ printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
test_expect_success 'test ascending revision range' "
git reset --hard trunk &&
- git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r1-r2-r4 -
+ git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
"
printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
test_expect_success 'test descending revision range' "
git reset --hard trunk &&
- git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4-r2-r1 -
+ git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
"
printf 'r1 \nr2 \n' > expected-range-r1-r2
test_expect_success 'test ascending revision range with unreachable revision' "
git reset --hard trunk &&
- git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r1-r2 -
+ git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
"
printf 'r2 \nr1 \n' > expected-range-r2-r1
test_expect_success 'test descending revision range with unreachable revision' "
git reset --hard trunk &&
- git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2-r1 -
+ git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
"
printf 'r2 \n' > expected-range-r2
test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2 -
+ git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r2 -
+ git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
printf 'r4 \n' > expected-range-r4
test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
git reset --hard trunk &&
- git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
printf -- '------------------------------------------------------------------------\n' > expected-separator
test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
git reset --hard trunk &&
- git svn log -r 5:6 | diff -u expected-separator -
+ git svn log -r 5:6 | test_cmp expected-separator -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
git reset --hard trunk &&
- git svn log -r 6:5 | diff -u expected-separator -
+ git svn log -r 6:5 | test_cmp expected-separator -
"
test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
git reset --hard trunk &&
- git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
git reset --hard trunk &&
- git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | diff -u expected-range-r4 -
+ git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_done
diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh
index d482b407f..7a689bb1c 100755
--- a/t/t9117-git-svn-init-clone.sh
+++ b/t/t9117-git-svn-init-clone.sh
@@ -13,43 +13,43 @@ rm -r .git
mkdir tmp
cd tmp
-test_expect_success 'setup svnrepo' "
+test_expect_success 'setup svnrepo' '
mkdir project project/trunk project/branches project/tags &&
echo foo > project/trunk/foo &&
- svn import -m '$test_description' project $svnrepo/project &&
+ svn import -m "$test_description" project "$svnrepo"/project &&
rm -rf project
- "
+ '
-test_expect_success 'basic clone' "
+test_expect_success 'basic clone' '
test ! -d trunk &&
- git svn clone $svnrepo/project/trunk &&
+ git svn clone "$svnrepo"/project/trunk &&
test -d trunk/.git/svn &&
test -e trunk/foo &&
rm -rf trunk
- "
+ '
-test_expect_success 'clone to target directory' "
+test_expect_success 'clone to target directory' '
test ! -d target &&
- git svn clone $svnrepo/project/trunk target &&
+ git svn clone "$svnrepo"/project/trunk target &&
test -d target/.git/svn &&
test -e target/foo &&
rm -rf target
- "
+ '
-test_expect_success 'clone with --stdlayout' "
+test_expect_success 'clone with --stdlayout' '
test ! -d project &&
- git svn clone -s $svnrepo/project &&
+ git svn clone -s "$svnrepo"/project &&
test -d project/.git/svn &&
test -e project/foo &&
rm -rf project
- "
+ '
-test_expect_success 'clone to target directory with --stdlayout' "
+test_expect_success 'clone to target directory with --stdlayout' '
test ! -d target &&
- git svn clone -s $svnrepo/project target &&
+ git svn clone -s "$svnrepo"/project target &&
test -d target/.git/svn &&
test -e target/foo &&
rm -rf target
- "
+ '
test_done
diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index 640bb066f..3281cbd34 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -6,25 +6,25 @@
test_description='git-svn funky branch names'
. ./lib-git-svn.sh
-test_expect_success 'setup svnrepo' "
+test_expect_success 'setup svnrepo' '
mkdir project project/trunk project/branches project/tags &&
echo foo > project/trunk/foo &&
- svn import -m '$test_description' project \"$svnrepo/pr ject\" &&
+ svn import -m "$test_description" project "$svnrepo/pr ject" &&
rm -rf project &&
- svn cp -m 'fun' \"$svnrepo/pr ject/trunk\" \
- \"$svnrepo/pr ject/branches/fun plugin\" &&
- svn cp -m 'more fun!' \"$svnrepo/pr ject/branches/fun plugin\" \
- \"$svnrepo/pr ject/branches/more fun plugin!\" &&
+ svn cp -m "fun" "$svnrepo/pr ject/trunk" \
+ "$svnrepo/pr ject/branches/fun plugin" &&
+ svn cp -m "more fun!" "$svnrepo/pr ject/branches/fun plugin" \
+ "$svnrepo/pr ject/branches/more fun plugin!" &&
start_httpd
- "
+ '
-test_expect_success 'test clone with funky branch names' "
- git svn clone -s \"$svnrepo/pr ject\" project &&
+test_expect_success 'test clone with funky branch names' '
+ git svn clone -s "$svnrepo/pr ject" project &&
cd project &&
- git rev-parse 'refs/remotes/fun%20plugin' &&
- git rev-parse 'refs/remotes/more%20fun%20plugin!' &&
+ git rev-parse "refs/remotes/fun%20plugin" &&
+ git rev-parse "refs/remotes/more%20fun%20plugin!" &&
cd ..
- "
+ '
test_expect_success 'test dcommit to funky branch' "
cd project &&
diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh
index cc6191159..5fd36a148 100755
--- a/t/t9119-git-svn-info.sh
+++ b/t/t9119-git-svn-info.sh
@@ -5,20 +5,38 @@
test_description='git-svn info'
. ./lib-git-svn.sh
-say 'skipping svn-info test (has a race undiagnosed yet)'
-test_done
+
+set -e
+
+# Tested with: svn, version 1.4.4 (r25188)
+v=`svn --version | sed -n -e 's/^svn, version \(1\.4\.[0-9]\).*$/\1/p'`
+case $v in
+1.4.*)
+ ;;
+*)
+ say "skipping svn-info test (SVN version: $v not supported)"
+ test_done
+ ;;
+esac
ptouch() {
perl -w -e '
use strict;
+ use POSIX qw(mktime);
die "ptouch requires exactly 2 arguments" if @ARGV != 2;
- die "$ARGV[0] does not exist" if ! -e $ARGV[0];
- my @s = stat $ARGV[0];
- utime $s[8], $s[9], $ARGV[1];
- ' "$1" "$2"
+ my $text_last_updated = shift @ARGV;
+ my $git_file = shift @ARGV;
+ die "\"$git_file\" does not exist" if ! -e $git_file;
+ if ($text_last_updated
+ =~ /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/) {
+ my $mtime = mktime($6, $5, $4, $3, $2 - 1, $1 - 1900);
+ my $atime = $mtime;
+ utime $atime, $mtime, $git_file;
+ }
+ ' "`svn info $2 | grep '^Text Last Updated:'`" "$1"
}
-test_expect_success 'setup repository and import' "
+test_expect_success 'setup repository and import' '
mkdir info &&
cd info &&
echo FIRST > A &&
@@ -27,19 +45,19 @@ test_expect_success 'setup repository and import' "
mkdir directory &&
touch directory/.placeholder &&
ln -s directory symlink-directory &&
- svn import -m 'initial' . $svnrepo &&
+ svn import -m "initial" . "$svnrepo" &&
cd .. &&
mkdir gitwc &&
cd gitwc &&
- git-svn init $svnrepo &&
+ git-svn init "$svnrepo" &&
git-svn fetch &&
cd .. &&
- svn co $svnrepo svnwc &&
+ svn co "$svnrepo" svnwc &&
ptouch svnwc/file gitwc/file &&
ptouch svnwc/directory gitwc/directory &&
ptouch svnwc/symlink-file gitwc/symlink-file &&
ptouch svnwc/symlink-directory gitwc/symlink-directory
- "
+ '
test_expect_success 'info' "
(cd svnwc; svn info) > expected.info &&
@@ -48,7 +66,7 @@ test_expect_success 'info' "
"
test_expect_success 'info --url' '
- test $(cd gitwc; git-svn info --url) = $svnrepo
+ test "$(cd gitwc; git-svn info --url)" = "$svnrepo"
'
test_expect_success 'info .' "
@@ -58,7 +76,7 @@ test_expect_success 'info .' "
"
test_expect_success 'info --url .' '
- test $(cd gitwc; git-svn info --url .) = $svnrepo
+ test "$(cd gitwc; git-svn info --url .)" = "$svnrepo"
'
test_expect_success 'info file' "
@@ -68,7 +86,7 @@ test_expect_success 'info file' "
"
test_expect_success 'info --url file' '
- test $(cd gitwc; git-svn info --url file) = "$svnrepo/file"
+ test "$(cd gitwc; git-svn info --url file)" = "$svnrepo/file"
'
test_expect_success 'info directory' "
@@ -78,7 +96,7 @@ test_expect_success 'info directory' "
"
test_expect_success 'info --url directory' '
- test $(cd gitwc; git-svn info --url directory) = "$svnrepo/directory"
+ test "$(cd gitwc; git-svn info --url directory)" = "$svnrepo/directory"
'
test_expect_success 'info symlink-file' "
@@ -88,7 +106,7 @@ test_expect_success 'info symlink-file' "
"
test_expect_success 'info --url symlink-file' '
- test $(cd gitwc; git-svn info --url symlink-file) \
+ test "$(cd gitwc; git-svn info --url symlink-file)" \
= "$svnrepo/symlink-file"
'
@@ -101,7 +119,7 @@ test_expect_success 'info symlink-directory' "
"
test_expect_success 'info --url symlink-directory' '
- test $(cd gitwc; git-svn info --url symlink-directory) \
+ test "$(cd gitwc; git-svn info --url symlink-directory)" \
= "$svnrepo/symlink-directory"
'
@@ -121,7 +139,7 @@ test_expect_success 'info added-file' "
"
test_expect_success 'info --url added-file' '
- test $(cd gitwc; git-svn info --url added-file) \
+ test "$(cd gitwc; git-svn info --url added-file)" \
= "$svnrepo/added-file"
'
@@ -143,7 +161,7 @@ test_expect_success 'info added-directory' "
"
test_expect_success 'info --url added-directory' '
- test $(cd gitwc; git-svn info --url added-directory) \
+ test "$(cd gitwc; git-svn info --url added-directory)" \
= "$svnrepo/added-directory"
'
@@ -166,7 +184,7 @@ test_expect_success 'info added-symlink-file' "
"
test_expect_success 'info --url added-symlink-file' '
- test $(cd gitwc; git-svn info --url added-symlink-file) \
+ test "$(cd gitwc; git-svn info --url added-symlink-file)" \
= "$svnrepo/added-symlink-file"
'
@@ -189,7 +207,7 @@ test_expect_success 'info added-symlink-directory' "
"
test_expect_success 'info --url added-symlink-directory' '
- test $(cd gitwc; git-svn info --url added-symlink-directory) \
+ test "$(cd gitwc; git-svn info --url added-symlink-directory)" \
= "$svnrepo/added-symlink-directory"
'
@@ -215,7 +233,7 @@ test_expect_success 'info deleted-file' "
"
test_expect_success 'info --url file (deleted)' '
- test $(cd gitwc; git-svn info --url file) \
+ test "$(cd gitwc; git-svn info --url file)" \
= "$svnrepo/file"
'
@@ -236,7 +254,7 @@ test_expect_success 'info deleted-directory' "
"
test_expect_success 'info --url directory (deleted)' '
- test $(cd gitwc; git-svn info --url directory) \
+ test "$(cd gitwc; git-svn info --url directory)" \
= "$svnrepo/directory"
'
@@ -258,7 +276,7 @@ test_expect_success 'info deleted-symlink-file' "
"
test_expect_success 'info --url symlink-file (deleted)' '
- test $(cd gitwc; git-svn info --url symlink-file) \
+ test "$(cd gitwc; git-svn info --url symlink-file)" \
= "$svnrepo/symlink-file"
'
@@ -280,7 +298,7 @@ test_expect_success 'info deleted-symlink-directory' "
"
test_expect_success 'info --url symlink-directory (deleted)' '
- test $(cd gitwc; git-svn info --url symlink-directory) \
+ test "$(cd gitwc; git-svn info --url symlink-directory)" \
= "$svnrepo/symlink-directory"
'
@@ -297,8 +315,8 @@ test_expect_success 'info unknown-file' "
"
test_expect_success 'info --url unknown-file' '
- test -z $(cd gitwc; git-svn info --url unknown-file \
- 2> ../actual.info--url-unknown-file) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-file \
+ 2> ../actual.info--url-unknown-file)" &&
git-diff expected.info-unknown-file actual.info--url-unknown-file
'
@@ -314,8 +332,8 @@ test_expect_success 'info unknown-directory' "
"
test_expect_success 'info --url unknown-directory' '
- test -z $(cd gitwc; git-svn info --url unknown-directory \
- 2> ../actual.info--url-unknown-directory) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-directory \
+ 2> ../actual.info--url-unknown-directory)" &&
git-diff expected.info-unknown-directory \
actual.info--url-unknown-directory
'
@@ -337,8 +355,8 @@ test_expect_success 'info unknown-symlink-file' "
"
test_expect_success 'info --url unknown-symlink-file' '
- test -z $(cd gitwc; git-svn info --url unknown-symlink-file \
- 2> ../actual.info--url-unknown-symlink-file) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-symlink-file \
+ 2> ../actual.info--url-unknown-symlink-file)" &&
git-diff expected.info-unknown-symlink-file \
actual.info--url-unknown-symlink-file
'
@@ -361,8 +379,8 @@ test_expect_success 'info unknown-symlink-directory' "
"
test_expect_success 'info --url unknown-symlink-directory' '
- test -z $(cd gitwc; git-svn info --url unknown-symlink-directory \
- 2> ../actual.info--url-unknown-symlink-directory) &&
+ test -z "$(cd gitwc; git-svn info --url unknown-symlink-directory \
+ 2> ../actual.info--url-unknown-symlink-directory)" &&
git-diff expected.info-unknown-symlink-directory \
actual.info--url-unknown-symlink-directory
'
diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh
new file mode 100755
index 000000000..5979e133b
--- /dev/null
+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Kevin Ballard
+#
+
+test_description='git-svn clone with percent escapes'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svnrepo' '
+ mkdir project project/trunk project/branches project/tags &&
+ echo foo > project/trunk/foo &&
+ svn import -m "$test_description" project "$svnrepo/pr ject" &&
+ rm -rf project &&
+ start_httpd
+'
+
+if test "$SVN_HTTPD_PORT" = ""
+then
+ test_expect_failure 'test clone with percent escapes - needs SVN_HTTPD_PORT set' 'false'
+else
+ test_expect_success 'test clone with percent escapes' '
+ git svn clone "$svnrepo/pr%20ject" clone &&
+ cd clone &&
+ git rev-parse refs/remotes/git-svn &&
+ cd ..
+ '
+fi
+
+stop_httpd
+
+test_done
diff --git a/t/t9121-git-svn-fetch-renamed-dir.sh b/t/t9121-git-svn-fetch-renamed-dir.sh
new file mode 100755
index 000000000..99230b081
--- /dev/null
+++ b/t/t9121-git-svn-fetch-renamed-dir.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Santhosh Kumar Mani
+
+
+test_description='git-svn can fetch renamed directories'
+
+. ./lib-git-svn.sh
+
+test_expect_success 'load repository with renamed directory' '
+ svnadmin load -q "$rawsvnrepo" < ../t9121/renamed-dir.dump
+ '
+
+test_expect_success 'init and fetch repository' '
+ git svn init "$svnrepo/newname" &&
+ git svn fetch
+ '
+
+test_done
+
diff --git a/t/t9121/renamed-dir.dump b/t/t9121/renamed-dir.dump
new file mode 100644
index 000000000..5f9127be9
--- /dev/null
+++ b/t/t9121/renamed-dir.dump
@@ -0,0 +1,90 @@
+SVN-fs-dump-format-version: 2
+
+UUID: 06b9b3ad-f546-4fbe-8328-fcb4e6ef5c3f
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2008-04-02T09:11:59.778557Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 117
+Content-length: 117
+
+K 7
+svn:log
+V 14
+initial import
+K 10
+svn:author
+V 8
+santhosh
+K 8
+svn:date
+V 27
+2008-04-02T09:13:03.170863Z
+PROPS-END
+
+Node-path: name
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: name/a.txt
+Node-kind: file
+Node-action: add
+Prop-content-length: 71
+Text-content-length: 6
+Text-content-md5: b1946ac92492d2347c6235b4d2611184
+Content-length: 77
+
+K 13
+svn:mime-type
+V 10
+text/plain
+K 13
+svn:eol-style
+V 2
+LF
+PROPS-END
+hello
+
+
+Revision-number: 2
+Prop-content-length: 109
+Content-length: 109
+
+K 7
+svn:log
+V 7
+renamed
+K 10
+svn:author
+V 8
+santhosh
+K 8
+svn:date
+V 27
+2008-04-02T09:14:22.952186Z
+PROPS-END
+
+Node-path: newname
+Node-kind: dir
+Node-action: add
+Node-copyfrom-rev: 1
+Node-copyfrom-path: name
+
+
+Node-path: name
+Node-action: delete
+
+
diff --git a/t/t9122-git-svn-author.sh b/t/t9122-git-svn-author.sh
new file mode 100755
index 000000000..1190576a6
--- /dev/null
+++ b/t/t9122-git-svn-author.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+test_description='git svn authorship'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svn repository' '
+ svn checkout "$svnrepo" work.svn &&
+ (
+ cd work.svn &&
+ echo >file
+ svn add file
+ svn commit -m "first commit" file
+ )
+'
+
+test_expect_success 'interact with it via git-svn' '
+ mkdir work.git &&
+ (
+ cd work.git &&
+ git svn init "$svnrepo"
+ git svn fetch &&
+
+ echo modification >file &&
+ test_tick &&
+ git commit -a -m second &&
+
+ test_tick &&
+ git svn dcommit &&
+
+ echo "further modification" >file &&
+ test_tick &&
+ git commit -a -m third &&
+
+ test_tick &&
+ git svn --add-author-from dcommit &&
+
+ echo "yet further modification" >file &&
+ test_tick &&
+ git commit -a -m fourth &&
+
+ test_tick &&
+ git svn --add-author-from --use-log-author dcommit &&
+
+ git log &&
+
+ git show -s HEAD^^ >../actual.2 &&
+ git show -s HEAD^ >../actual.3 &&
+ git show -s HEAD >../actual.4
+
+ ) &&
+
+ # Make sure that --add-author-from without --use-log-author
+ # did not affect the authorship information
+ myself=$(grep "^Author: " actual.2) &&
+ unaffected=$(grep "^Author: " actual.3) &&
+ test "z$myself" = "z$unaffected" &&
+
+ # Make sure lack of --add-author-from did not add cruft
+ ! grep "^ From: A U Thor " actual.2 &&
+
+ # Make sure --add-author-from added cruft
+ grep "^ From: A U Thor " actual.3 &&
+ grep "^ From: A U Thor " actual.4 &&
+
+ # Make sure --add-author-from with --use-log-author affected
+ # the authorship information
+ grep "^Author: A U Thor " actual.4 &&
+
+ # Make sure there are no commit messages with excess blank lines
+ test $(grep "^ " actual.2 | wc -l) = 3 &&
+ test $(grep "^ " actual.3 | wc -l) = 5 &&
+ test $(grep "^ " actual.4 | wc -l) = 5 &&
+
+ # Make sure there are no svn commit messages with excess blank lines
+ (
+ cd work.svn &&
+ svn up &&
+
+ test $(svn log -r2:2 | wc -l) = 5 &&
+ test $(svn log -r4:4 | wc -l) = 7
+ )
+'
+
+test_done
diff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
new file mode 100755
index 000000000..c18878fad
--- /dev/null
+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Jan Krüger
+#
+
+test_description='git-svn respects rewriteRoot during rebuild'
+
+. ./lib-git-svn.sh
+
+mkdir import
+cd import
+ touch foo
+ svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
+cd ..
+rm -rf import
+
+test_expect_success 'init, fetch and checkout repository' '
+ git svn init --rewrite-root=http://invalid.invalid/ "$svnrepo" &&
+ git svn fetch
+ git checkout -b mybranch remotes/git-svn
+ '
+
+test_expect_success 'remove rev_map' '
+ rm "$GIT_SVN_DIR"/.rev_map.*
+ '
+
+test_expect_success 'rebuild rev_map' '
+ git svn rebase >/dev/null
+ '
+
+test_done
+
diff --git a/t/t9124-git-svn-dcommit-auto-props.sh b/t/t9124-git-svn-dcommit-auto-props.sh
new file mode 100755
index 000000000..8223c5909
--- /dev/null
+++ b/t/t9124-git-svn-dcommit-auto-props.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Brad King
+
+test_description='git-svn dcommit honors auto-props'
+
+. ./lib-git-svn.sh
+
+generate_auto_props() {
+cat << EOF
+[miscellany]
+enable-auto-props=$1
+[auto-props]
+*.sh = svn:mime-type=application/x-shellscript; svn:eol-style=LF
+*.txt = svn:mime-type=text/plain; svn:eol-style = native
+EOF
+}
+
+test_expect_success 'initialize git-svn' '
+ mkdir import &&
+ (
+ cd import &&
+ echo foo >foo &&
+ svn import -m "import for git-svn" . "$svnrepo"
+ ) &&
+ rm -rf import &&
+ git-svn init "$svnrepo"
+ git-svn fetch
+'
+
+test_expect_success 'enable auto-props config' '
+ cd "$gittestrepo" &&
+ mkdir user &&
+ generate_auto_props yes >user/config
+'
+
+test_expect_success 'add files matching auto-props' '
+ cd "$gittestrepo" &&
+ echo "#!$SHELL_PATH" >exec1.sh &&
+ chmod +x exec1.sh &&
+ echo "hello" >hello.txt &&
+ echo bar >bar &&
+ git add exec1.sh hello.txt bar &&
+ git commit -m "files for enabled auto-props" &&
+ git svn dcommit --config-dir=user
+'
+
+test_expect_success 'disable auto-props config' '
+ cd "$gittestrepo" &&
+ generate_auto_props no >user/config
+'
+
+test_expect_success 'add files matching disabled auto-props' '
+ cd "$gittestrepo" &&
+ echo "#$SHELL_PATH" >exec2.sh &&
+ chmod +x exec2.sh &&
+ echo "world" >world.txt &&
+ echo zot >zot &&
+ git add exec2.sh world.txt zot &&
+ git commit -m "files for disabled auto-props" &&
+ git svn dcommit --config-dir=user
+'
+
+test_expect_success 'check resulting svn repository' '
+ mkdir work &&
+ cd work &&
+ svn co "$svnrepo" &&
+ cd svnrepo &&
+
+ # Check properties from first commit.
+ test "x$(svn propget svn:executable exec1.sh)" = "x*" &&
+ test "x$(svn propget svn:mime-type exec1.sh)" = \
+ "xapplication/x-shellscript" &&
+ test "x$(svn propget svn:mime-type hello.txt)" = "xtext/plain" &&
+ test "x$(svn propget svn:eol-style hello.txt)" = "xnative" &&
+ test "x$(svn propget svn:mime-type bar)" = "x" &&
+
+ # Check properties from second commit.
+ test "x$(svn propget svn:executable exec2.sh)" = "x*" &&
+ test "x$(svn propget svn:mime-type exec2.sh)" = "x" &&
+ test "x$(svn propget svn:mime-type world.txt)" = "x" &&
+ test "x$(svn propget svn:eol-style world.txt)" = "x" &&
+ test "x$(svn propget svn:mime-type zot)" = "x"
+'
+
+test_done
diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh
new file mode 100755
index 000000000..6b62b52f5
--- /dev/null
+++ b/t/t9125-git-svn-multi-glob-branch-names.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (c) 2008 Marcus Griep
+
+test_description='git-svn multi-glob branch names'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svnrepo' '
+ mkdir project project/trunk project/branches \
+ project/branches/v14.1 project/tags &&
+ echo foo > project/trunk/foo &&
+ svn import -m "$test_description" project "$svnrepo/project" &&
+ rm -rf project &&
+ svn cp -m "fun" "$svnrepo/project/trunk" \
+ "$svnrepo/project/branches/v14.1/beta" &&
+ svn cp -m "more fun!" "$svnrepo/project/branches/v14.1/beta" \
+ "$svnrepo/project/branches/v14.1/gold"
+ '
+
+test_expect_success 'test clone with multi-glob in branch names' '
+ git svn clone -T trunk -b branches/*/* -t tags \
+ "$svnrepo/project" project &&
+ cd project &&
+ git rev-parse "refs/remotes/v14.1/beta" &&
+ git rev-parse "refs/remotes/v14.1/gold" &&
+ cd ..
+ '
+
+test_expect_success 'test dcommit to multi-globbed branch' "
+ cd project &&
+ git reset --hard 'refs/remotes/v14.1/gold' &&
+ echo hello >> foo &&
+ git commit -m 'hello' -- foo &&
+ git svn dcommit &&
+ cd ..
+ "
+
+test_done
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
index a15222ced..3e32e84e6 100755
--- a/t/t9200-git-cvsexportcommit.sh
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -2,7 +2,7 @@
#
# Copyright (c) Robin Rosenberg
#
-test_description='CVS export comit. '
+test_description='Test export of commits to CVS'
. ./test-lib.sh
@@ -37,7 +37,7 @@ check_entries () {
else
printf '%s\n' "$2" | tr '|' '\012' >expected
fi
- diff -u expected actual
+ test_cmp expected actual
}
test_expect_success \
@@ -100,7 +100,7 @@ test_expect_success \
git commit -a -m "generation 2" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
- ! git cvsexportcommit -c $id
+ test_must_fail git cvsexportcommit -c $id
)'
#test_expect_success \
@@ -112,7 +112,7 @@ test_expect_success \
# git commit -a -m "generation 3" &&
# id=$(git rev-list --max-count=1 HEAD) &&
# (cd "$CVSWORK" &&
-# ! git cvsexportcommit -c $id
+# test_must_fail git cvsexportcommit -c $id
# )'
# We reuse the state from two tests back here
@@ -222,7 +222,7 @@ test_expect_success \
git commit -a -m "Update two" &&
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
- ! git-cvsexportcommit -c $id
+ test_must_fail git-cvsexportcommit -c $id
)'
case "$(git config --bool core.filemode)" in
@@ -246,4 +246,72 @@ test_expect_success \
;;
esac
+test_expect_success '-w option should work with relative GIT_DIR' '
+ mkdir W &&
+ echo foobar >W/file1.txt &&
+ echo bazzle >W/file2.txt &&
+ git add W/file1.txt &&
+ git add W/file2.txt &&
+ git commit -m "More updates" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$GIT_DIR" &&
+ GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
+ check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
+ test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt &&
+ test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt
+ )
+'
+
+test_expect_success 'check files before directories' '
+
+ echo Notes > release-notes &&
+ git add release-notes &&
+ git commit -m "Add release notes" release-notes &&
+ id=$(git rev-parse HEAD) &&
+ git cvsexportcommit -w "$CVSWORK" -c $id &&
+
+ echo new > DS &&
+ echo new > E/DS &&
+ echo modified > release-notes &&
+ git add DS E/DS release-notes &&
+ git commit -m "Add two files with the same basename" &&
+ id=$(git rev-parse HEAD) &&
+ git cvsexportcommit -w "$CVSWORK" -c $id &&
+ check_entries "$CVSWORK/E" "DS/1.1/|newfile5.txt/1.1/" &&
+ check_entries "$CVSWORK" "DS/1.1/|release-notes/1.2/" &&
+ test_cmp "$CVSWORK/DS" DS &&
+ test_cmp "$CVSWORK/E/DS" E/DS &&
+ test_cmp "$CVSWORK/release-notes" release-notes
+
+'
+
+test_expect_success 'commit a file with leading spaces in the name' '
+
+ echo space > " space" &&
+ git add " space" &&
+ git commit -m "Add a file with a leading space" &&
+ id=$(git rev-parse HEAD) &&
+ git cvsexportcommit -w "$CVSWORK" -c $id &&
+ check_entries "$CVSWORK" " space/1.1/|DS/1.1/|release-notes/1.2/" &&
+ test_cmp "$CVSWORK/ space" " space"
+
+'
+
+test_expect_success 'use the same checkout for Git and CVS' '
+
+ (mkdir shared &&
+ cd shared &&
+ unset GIT_DIR &&
+ cvs co . &&
+ git init &&
+ git add " space" &&
+ git commit -m "fake initial commit" &&
+ echo Hello >> " space" &&
+ git commit -m "Another change" " space" &&
+ git cvsexportcommit -W -p -u -c HEAD &&
+ grep Hello " space" &&
+ git diff-files)
+
+'
+
test_done
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 0595041af..c6bc0a607 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -74,7 +74,7 @@ EOF
test_expect_success \
'A: verify commit' \
'git cat-file commit master | sed 1d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
cat >expect <<EOF
100644 blob file2
@@ -84,22 +84,22 @@ EOF
test_expect_success \
'A: verify tree' \
'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
- git diff expect actual'
+ test_cmp expect actual'
echo "$file2_data" >expect
test_expect_success \
'A: verify file2' \
- 'git cat-file blob master:file2 >actual && git diff expect actual'
+ 'git cat-file blob master:file2 >actual && test_cmp expect actual'
echo "$file3_data" >expect
test_expect_success \
'A: verify file3' \
- 'git cat-file blob master:file3 >actual && git diff expect actual'
+ 'git cat-file blob master:file3 >actual && test_cmp expect actual'
printf "$file4_data" >expect
test_expect_success \
'A: verify file4' \
- 'git cat-file blob master:file4 >actual && git diff expect actual'
+ 'git cat-file blob master:file4 >actual && test_cmp expect actual'
cat >expect <<EOF
:2 `git rev-parse --verify master:file2`
@@ -109,7 +109,7 @@ cat >expect <<EOF
EOF
test_expect_success \
'A: verify marks output' \
- 'git diff expect marks.out'
+ 'test_cmp expect marks.out'
test_expect_success \
'A: verify marks import' \
@@ -117,7 +117,7 @@ test_expect_success \
--import-marks=marks.out \
--export-marks=marks.new \
</dev/null &&
- git diff -u expect marks.new'
+ test_cmp expect marks.new'
test_tick
cat >input <<INPUT_END
@@ -165,9 +165,9 @@ from refs/heads/master
M 755 0000000000000000000000000000000000000001 zero1
INPUT_END
-test_expect_failure \
- 'B: fail on invalid blob sha1' \
- 'git-fast-import <input'
+test_expect_success 'B: fail on invalid blob sha1' '
+ test_must_fail git-fast-import <input
+'
rm -f .git/objects/pack_* .git/objects/index_*
cat >input <<INPUT_END
@@ -180,9 +180,9 @@ COMMIT
from refs/heads/master
INPUT_END
-test_expect_failure \
- 'B: fail on invalid branch name ".badbranchname"' \
- 'git-fast-import <input'
+test_expect_success 'B: fail on invalid branch name ".badbranchname"' '
+ test_must_fail git-fast-import <input
+'
rm -f .git/objects/pack_* .git/objects/index_*
cat >input <<INPUT_END
@@ -195,9 +195,9 @@ COMMIT
from refs/heads/master
INPUT_END
-test_expect_failure \
- 'B: fail on invalid branch name "bad[branch]name"' \
- 'git-fast-import <input'
+test_expect_success 'B: fail on invalid branch name "bad[branch]name"' '
+ test_must_fail git-fast-import <input
+'
rm -f .git/objects/pack_* .git/objects/index_*
cat >input <<INPUT_END
@@ -259,7 +259,7 @@ EOF
test_expect_success \
'C: verify commit' \
'git cat-file commit branch | sed 1d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
cat >expect <<EOF
:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
@@ -316,13 +316,13 @@ echo "$file5_data" >expect
test_expect_success \
'D: verify file5' \
'git cat-file blob branch:newdir/interesting >actual &&
- git diff expect actual'
+ test_cmp expect actual'
echo "$file6_data" >expect
test_expect_success \
'D: verify file6' \
'git cat-file blob branch:newdir/exec.sh >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series E
@@ -339,9 +339,9 @@ COMMIT
from refs/heads/branch^0
INPUT_END
-test_expect_failure \
- 'E: rfc2822 date, --date-format=raw' \
- 'git-fast-import --date-format=raw <input'
+test_expect_success 'E: rfc2822 date, --date-format=raw' '
+ test_must_fail git-fast-import --date-format=raw <input
+'
test_expect_success \
'E: rfc2822 date, --date-format=rfc2822' \
'git-fast-import --date-format=rfc2822 <input'
@@ -358,7 +358,7 @@ EOF
test_expect_success \
'E: verify commit' \
'git cat-file commit branch | sed 1,2d >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series F
@@ -411,7 +411,7 @@ EOF
test_expect_success \
'F: verify other commit' \
'git cat-file commit other >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series G
@@ -489,7 +489,7 @@ echo "$file5_data" >expect
test_expect_success \
'H: verify file' \
'git cat-file blob H:h/e/l/lo >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series I
@@ -515,7 +515,7 @@ EOF
test_expect_success \
'I: verify edge list' \
'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
- git diff expect actual'
+ test_cmp expect actual'
###
### series J
@@ -625,7 +625,7 @@ test_expect_success \
'L: verify internal tree sorting' \
'git-fast-import <input &&
git diff-tree --abbrev --raw L^ L >output &&
- git diff expect output'
+ test_cmp expect output'
###
### series M
@@ -869,6 +869,8 @@ zcommits
COMMIT
reset refs/tags/O3-2nd
from :5
+reset refs/tags/O3-3rd
+from :5
INPUT_END
cat >expect <<INPUT_END
@@ -883,7 +885,7 @@ test_expect_success \
test 8 = `find .git/objects/pack -type f | wc -l` &&
test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
- git diff expect actual'
+ test_cmp expect actual'
cat >input <<INPUT_END
commit refs/heads/O4
@@ -914,6 +916,158 @@ test_expect_success \
'O: progress outputs as requested by input' \
'git-fast-import <input >actual &&
grep "progress " <input >expect &&
- git diff expect actual'
+ test_cmp expect actual'
+
+###
+### series P (gitlinks)
+###
+
+cat >input <<INPUT_END
+blob
+mark :1
+data 10
+test file
+
+reset refs/heads/sub
+commit refs/heads/sub
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 12
+sub_initial
+M 100644 :1 file
+
+blob
+mark :3
+data <<DATAEND
+[submodule "sub"]
+ path = sub
+ url = "`pwd`/sub"
+DATAEND
+
+commit refs/heads/subuse1
+mark :4
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 8
+initial
+from refs/heads/master
+M 100644 :3 .gitmodules
+M 160000 :2 sub
+
+blob
+mark :5
+data 20
+test file
+more data
+
+commit refs/heads/sub
+mark :6
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 11
+sub_second
+from :2
+M 100644 :5 file
+
+commit refs/heads/subuse1
+mark :7
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 7
+second
+from :4
+M 160000 :6 sub
+
+INPUT_END
+
+test_expect_success \
+ 'P: supermodule & submodule mix' \
+ 'git-fast-import <input &&
+ git checkout subuse1 &&
+ rm -rf sub && mkdir sub && cd sub &&
+ git init &&
+ git fetch .. refs/heads/sub:refs/heads/master &&
+ git checkout master &&
+ cd .. &&
+ git submodule init &&
+ git submodule update'
+
+SUBLAST=$(git-rev-parse --verify sub)
+SUBPREV=$(git-rev-parse --verify sub^)
+
+cat >input <<INPUT_END
+blob
+mark :1
+data <<DATAEND
+[submodule "sub"]
+ path = sub
+ url = "`pwd`/sub"
+DATAEND
+
+commit refs/heads/subuse2
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 8
+initial
+from refs/heads/master
+M 100644 :1 .gitmodules
+M 160000 $SUBPREV sub
+
+commit refs/heads/subuse2
+mark :3
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data 7
+second
+from :2
+M 160000 $SUBLAST sub
+
+INPUT_END
+
+test_expect_success \
+ 'P: verbatim SHA gitlinks' \
+ 'git branch -D sub &&
+ git gc && git prune &&
+ git-fast-import <input &&
+ test $(git-rev-parse --verify subuse2) = $(git-rev-parse --verify subuse1)'
+
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/subuse3
+mark :1
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/subuse2
+M 160000 inline sub
+data <<DATA
+$SUBPREV
+DATA
+
+INPUT_END
+
+test_expect_success 'P: fail on inline gitlink' '
+ test_must_fail git-fast-import <input'
+
+test_tick
+cat >input <<INPUT_END
+blob
+mark :1
+data <<DATA
+$SUBPREV
+DATA
+
+commit refs/heads/subuse3
+mark :2
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/subuse2
+M 160000 :1 sub
+
+INPUT_END
+
+test_expect_success 'P: fail on blob mark in gitlink' '
+ test_must_fail git-fast-import <input'
test_done
diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh
index f09bfb111..c19b4a2ba 100755
--- a/t/t9301-fast-export.sh
+++ b/t/t9301-fast-export.sh
@@ -59,7 +59,7 @@ test_expect_success 'fast-export master~2..master' '
test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
git diff master..partial &&
git diff master^..partial^ &&
- ! git rev-parse partial~2)
+ test_must_fail git rev-parse partial~2)
'
@@ -78,6 +78,29 @@ test_expect_success 'iso-8859-1' '
git cat-file commit i18n | grep "Ãéí óú")
'
+test_expect_success 'import/export-marks' '
+
+ git checkout -b marks master &&
+ git fast-export --export-marks=tmp-marks HEAD &&
+ test -s tmp-marks &&
+ test $(wc -l < tmp-marks) -eq 3 &&
+ test $(
+ git fast-export --import-marks=tmp-marks\
+ --export-marks=tmp-marks HEAD |
+ grep ^commit |
+ wc -l) \
+ -eq 0 &&
+ echo change > file &&
+ git commit -m "last commit" file &&
+ test $(
+ git fast-export --import-marks=tmp-marks \
+ --export-marks=tmp-marks HEAD |
+ grep ^commit\ |
+ wc -l) \
+ -eq 1 &&
+ test $(wc -l < tmp-marks) -eq 4
+
+'
cat > signed-tag-import << EOF
tag sign-your-name
@@ -102,7 +125,7 @@ test_expect_success 'set up faked signed tag' '
test_expect_success 'signed-tags=abort' '
- ! git fast-export --signed-tags=abort sign-your-name
+ test_must_fail git fast-export --signed-tags=abort sign-your-name
'
@@ -120,4 +143,92 @@ test_expect_success 'signed-tags=strip' '
'
+test_expect_success 'setup submodule' '
+
+ git checkout -f master &&
+ mkdir sub &&
+ cd sub &&
+ git init &&
+ echo test file > file &&
+ git add file &&
+ git commit -m sub_initial &&
+ cd .. &&
+ git submodule add "`pwd`/sub" sub &&
+ git commit -m initial &&
+ test_tick &&
+ cd sub &&
+ echo more data >> file &&
+ git add file &&
+ git commit -m sub_second &&
+ cd .. &&
+ git add sub &&
+ git commit -m second
+
+'
+
+test_expect_success 'submodule fast-export | fast-import' '
+
+ SUBENT1=$(git ls-tree master^ sub) &&
+ SUBENT2=$(git ls-tree master sub) &&
+ rm -rf new &&
+ mkdir new &&
+ git --git-dir=new/.git init &&
+ git fast-export --signed-tags=strip --all |
+ (cd new &&
+ git fast-import &&
+ test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
+ test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" &&
+ git checkout master &&
+ git submodule init &&
+ git submodule update &&
+ cmp sub/file ../sub/file)
+
+'
+
+export GIT_AUTHOR_NAME='A U Thor'
+export GIT_COMMITTER_NAME='C O Mitter'
+
+test_expect_success 'setup copies' '
+
+ git config --unset i18n.commitencoding &&
+ git checkout -b copy rein &&
+ git mv file file3 &&
+ git commit -m move1 &&
+ test_tick &&
+ cp file2 file4 &&
+ git add file4 &&
+ git mv file2 file5 &&
+ git commit -m copy1 &&
+ test_tick &&
+ cp file3 file6 &&
+ git add file6 &&
+ git commit -m copy2 &&
+ test_tick &&
+ echo more text >> file6 &&
+ echo even more text >> file6 &&
+ git add file6 &&
+ git commit -m modify &&
+ test_tick &&
+ cp file6 file7 &&
+ echo test >> file7 &&
+ git add file7 &&
+ git commit -m copy_modify
+
+'
+
+test_expect_success 'fast-export -C -C | fast-import' '
+
+ ENTRY=$(git rev-parse --verify copy) &&
+ rm -rf new &&
+ mkdir new &&
+ git --git-dir=new/.git init &&
+ git fast-export -C -C --signed-tags=strip --all > output &&
+ grep "^C \"file6\" \"file7\"\$" output &&
+ cat output |
+ (cd new &&
+ git fast-import &&
+ test $ENTRY = $(git rev-parse --verify refs/heads/copy))
+
+'
+
test_done
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 641303e0a..4b91f8d4c 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -33,19 +33,28 @@ CVS_SERVER=git-cvsserver
export CVSROOT CVS_SERVER
rm -rf "$CVSWORK" "$SERVERDIR"
-echo >empty &&
+test_expect_success 'setup' '
+ echo >empty &&
git add empty &&
git commit -q -m "First Commit" &&
+ mkdir secondroot &&
+ ( cd secondroot &&
+ git init &&
+ touch secondrootfile &&
+ git add secondrootfile &&
+ git commit -m "second root") &&
+ git pull secondroot master &&
git clone -q --local --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" ||
- exit 1
+ GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
+'
# note that cvs doesn't accept absolute pathnames
# as argument to co -d
test_expect_success 'basic checkout' \
'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
- test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
+ test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/"
+ test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"'
#------------------------
# PSERVER AUTHENTICATION
@@ -85,7 +94,7 @@ EOF
test_expect_success 'pserver authentication' \
'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'pserver authentication failure (non-anonymous user)' \
'if cat request-git | git-cvsserver pserver >log 2>&1
@@ -94,11 +103,11 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \
else
true
fi &&
- tail -n1 log | grep -q "^I HATE YOU$"'
+ sed -ne \$p log | grep "^I HATE YOU$"'
test_expect_success 'pserver authentication (login)' \
'cat login-anonymous | git-cvsserver pserver >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ sed -ne \$p log | grep "^I LOVE YOU$"'
test_expect_success 'pserver authentication failure (login/non-anonymous user)' \
'if cat login-git | git-cvsserver pserver >log 2>&1
@@ -107,7 +116,7 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)'
else
true
fi &&
- tail -n1 log | grep -q "^I HATE YOU$"'
+ sed -ne \$p log | grep "^I HATE YOU$"'
# misuse pserver authentication for testing of req_Root
@@ -137,25 +146,29 @@ test_expect_success 'req_Root failure (relative pathname)' \
else
true
fi &&
- tail log | grep -q "^error 1 Root must be an absolute pathname$"'
+ tail log | grep "^error 1 Root must be an absolute pathname$"'
test_expect_success 'req_Root failure (conflicting roots)' \
'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
- tail log | grep -q "^error 1 Conflicting roots specified$"'
+ tail log | grep "^error 1 Conflicting roots specified$"'
test_expect_success 'req_Root (strict paths)' \
- 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU$"'
-test_expect_failure 'req_Root failure (strict-paths)' \
- 'cat request-anonymous | git-cvsserver --strict-paths pserver $WORKDIR >log 2>&1'
+test_expect_success 'req_Root failure (strict-paths)' '
+ ! cat request-anonymous |
+ git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1
+'
test_expect_success 'req_Root (w/o strict-paths)' \
- 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU$"'
-test_expect_failure 'req_Root failure (w/o strict-paths)' \
- 'cat request-anonymous | git-cvsserver pserver $WORKDIR/gitcvs >log 2>&1'
+test_expect_success 'req_Root failure (w/o strict-paths)' '
+ ! cat request-anonymous |
+ git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1
+'
cat >request-base <<EOF
BEGIN AUTH REQUEST
@@ -167,25 +180,26 @@ Root /gitcvs.git
EOF
test_expect_success 'req_Root (base-path)' \
- 'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU$"'
-test_expect_failure 'req_Root failure (base-path)' \
- 'cat request-anonymous | git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1'
+test_expect_success 'req_Root failure (base-path)' '
+ ! cat request-anonymous |
+ git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1
+'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
test_expect_success 'req_Root (export-all)' \
- 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU$"'
-test_expect_failure 'req_Root failure (export-all w/o whitelist)' \
- 'cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 ||
- false'
+test_expect_success 'req_Root failure (export-all w/o whitelist)' \
+ '! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)'
test_expect_success 'req_Root (everything together)' \
- 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
- tail -n1 log | grep -q "^I LOVE YOU$"'
+ 'cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 &&
+ sed -ne \$p log | grep "^I LOVE YOU$"'
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
@@ -202,7 +216,7 @@ test_expect_success 'gitcvs.enabled = false' \
else
true
fi &&
- cat cvs.log | grep -q "GITCVS emulation disabled" &&
+ grep "GITCVS emulation disabled" cvs.log &&
test ! -d cvswork2'
rm -fr cvswork2
@@ -223,7 +237,7 @@ test_expect_success 'gitcvs.ext.enabled = false' \
else
true
fi &&
- cat cvs.log | grep -q "GITCVS emulation disabled" &&
+ grep "GITCVS emulation disabled" cvs.log &&
test ! -d cvswork2'
rm -fr cvswork2
@@ -281,15 +295,16 @@ test_expect_success 'cvs update (update existing file)' \
cd "$WORKDIR"
#TODO: cvsserver doesn't support update w/o -d
-test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
- 'mkdir test &&
+test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" '
+ mkdir test &&
echo >test/empty &&
git add test &&
git commit -q -m "Single Subdirectory" &&
git push gitcvs.git >/dev/null &&
cd cvswork &&
GIT_CONFIG="$git_config" cvs -Q update &&
- test ! -d test'
+ test ! -d test
+'
cd "$WORKDIR"
test_expect_success 'cvs update (subdirectories)' \
@@ -405,4 +420,72 @@ test_expect_success 'cvs update (merge no-op)' \
GIT_CONFIG="$git_config" cvs -Q update &&
diff -q merge ../merge'
+cd "$WORKDIR"
+test_expect_success 'cvs update (-p)' '
+ touch really-empty &&
+ echo Line 1 > no-lf &&
+ echo -n Line 2 >> no-lf &&
+ git add really-empty no-lf &&
+ git commit -q -m "Update -p test" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs update &&
+ rm -f failures &&
+ for i in merge no-lf empty really-empty; do
+ GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out
+ diff $i.out ../$i >>failures 2>&1
+ done &&
+ test -z "$(cat failures)"
+'
+
+cd "$WORKDIR"
+test_expect_success 'cvs update (module list supports packed refs)' '
+ GIT_DIR="$SERVERDIR" git pack-refs --all &&
+ GIT_CONFIG="$git_config" cvs -n up -d 2> out &&
+ grep "cvs update: New directory \`master'\''" < out
+'
+
+#------------
+# CVS STATUS
+#------------
+
+cd "$WORKDIR"
+test_expect_success 'cvs status' '
+ mkdir status.dir &&
+ echo Line > status.dir/status.file &&
+ echo Line > status.file &&
+ git add status.dir status.file &&
+ git commit -q -m "Status test" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs update &&
+ GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out &&
+ test $(wc -l <../out) = 2
+'
+
+cd "$WORKDIR"
+test_expect_success 'cvs status (nonrecursive)' '
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out &&
+ test $(wc -l <../out) = 1
+'
+
+cd "$WORKDIR"
+test_expect_success 'cvs status (no subdirs in header)' '
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs status | grep ^File: >../out &&
+ ! grep / <../out
+'
+
+#------------
+# CVS CHECKOUT
+#------------
+
+cd "$WORKDIR"
+test_expect_success 'cvs co -c (shows module database)' '
+ GIT_CONFIG="$git_config" cvs co -c > out &&
+ grep "^master[ ]\+master$" < out &&
+ ! grep -v "^master[ ]\+master$" < out
+'
+
test_done
diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh
new file mode 100755
index 000000000..e27a1c5f8
--- /dev/null
+++ b/t/t9401-git-cvsserver-crlf.sh
@@ -0,0 +1,337 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Matthew Ogilvie
+# Parts adapted from other tests.
+#
+
+test_description='git-cvsserver -kb modes
+
+tests -kb mode for binary files when accessing a git
+repository using cvs CLI client via git-cvsserver server'
+
+. ./test-lib.sh
+
+q_to_nul () {
+ perl -pe 'y/Q/\000/'
+}
+
+q_to_cr () {
+ tr Q '\015'
+}
+
+marked_as () {
+ foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
+ if [ x"$foundEntry" = x"" ] ; then
+ echo "NOT FOUND: $1 $2 1 $3" >> "${WORKDIR}/marked.log"
+ return 1
+ fi
+ test x"$(grep "^/$2/" "$1/CVS/Entries" | cut -d/ -f5)" = x"$3"
+ stat=$?
+ echo "$1 $2 $stat '$3'" >> "${WORKDIR}/marked.log"
+ return $stat
+}
+
+not_present() {
+ foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
+ if [ -r "$1/$2" ] ; then
+ echo "Error: File still exists: $1 $2" >> "${WORKDIR}/marked.log"
+ return 1;
+ fi
+ if [ x"$foundEntry" != x"" ] ; then
+ echo "Error: should not have found: $1 $2" >> "${WORKDIR}/marked.log"
+ return 1;
+ else
+ echo "Correctly not found: $1 $2" >> "${WORKDIR}/marked.log"
+ return 0;
+ fi
+}
+
+cvs >/dev/null 2>&1
+if test $? -ne 1
+then
+ test_expect_success 'skipping git-cvsserver tests, cvs not found' :
+ test_done
+ exit
+fi
+perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
+ test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
+ test_done
+ exit
+}
+
+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' '
+ echo "Simple text file" >textfile.c &&
+ echo "File with embedded NUL: Q <- there" | q_to_nul > binfile.bin &&
+ mkdir subdir &&
+ echo "Another text file" > subdir/file.h &&
+ echo "Another binary: Q (this time CR)" | q_to_cr > subdir/withCr.bin &&
+ echo "Mixed up NUL, but marked text: Q <- there" | q_to_nul > mixedUp.c
+ echo "Unspecified" > subdir/unspecified.other &&
+ echo "/*.bin -crlf" > .gitattributes &&
+ echo "/*.c crlf" >> .gitattributes &&
+ echo "subdir/*.bin -crlf" >> .gitattributes &&
+ echo "subdir/*.c crlf" >> .gitattributes &&
+ echo "subdir/file.h crlf" >> .gitattributes &&
+ git add .gitattributes textfile.c binfile.bin mixedUp.c subdir/* &&
+ git commit -q -m "First Commit" &&
+ git clone -q --local --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"
+'
+
+test_expect_success 'cvs co (default crlf)' '
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ test x"$(grep '/-k' cvswork/CVS/Entries cvswork/subdir/CVS/Entries)" = x""
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co (allbinary)' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary true &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ marked_as cvswork textfile.c -kb &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes -kb &&
+ marked_as cvswork mixedUp.c -kb &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h -kb &&
+ marked_as cvswork/subdir unspecified.other -kb
+'
+
+rm -rf cvswork cvs.log
+test_expect_success 'cvs co (use attributes/allbinary)' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr true &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes -kb &&
+ marked_as cvswork mixedUp.c "" &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h "" &&
+ marked_as cvswork/subdir unspecified.other -kb
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co (use attributes)' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary false &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes "" &&
+ marked_as cvswork mixedUp.c "" &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h "" &&
+ marked_as cvswork/subdir unspecified.other ""
+'
+
+test_expect_success 'adding files' '
+ cd cvswork/subdir &&
+ echo "more text" > src.c &&
+ GIT_CONFIG="$git_config" cvs -Q add src.c >cvs.log 2>&1 &&
+ marked_as . src.c "" &&
+ echo "psuedo-binary" > temp.bin &&
+ cd .. &&
+ GIT_CONFIG="$git_config" cvs -Q add subdir/temp.bin >cvs.log 2>&1 &&
+ marked_as subdir temp.bin "-kb" &&
+ cd subdir &&
+ GIT_CONFIG="$git_config" cvs -Q ci -m "adding files" >cvs.log 2>&1 &&
+ marked_as . temp.bin "-kb" &&
+ marked_as . src.c ""
+'
+
+cd "$WORKDIR"
+test_expect_success 'updating' '
+ git pull gitcvs.git &&
+ echo 'hi' > subdir/newfile.bin &&
+ echo 'junk' > subdir/file.h &&
+ echo 'hi' > subdir/newfile.c &&
+ echo 'hello' >> binfile.bin &&
+ git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&
+ git commit -q -m "Add and change some files" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ cd .. &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes "" &&
+ marked_as cvswork mixedUp.c "" &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h "" &&
+ marked_as cvswork/subdir unspecified.other "" &&
+ marked_as cvswork/subdir newfile.bin -kb &&
+ marked_as cvswork/subdir newfile.c "" &&
+ echo "File with embedded NUL: Q <- there" | q_to_nul > tmpExpect1 &&
+ echo "hello" >> tmpExpect1 &&
+ cmp cvswork/binfile.bin tmpExpect1
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co (use attributes/guess)' '
+ GIT_DIR="$SERVERDIR" git config gitcvs.allbinary guess &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes "" &&
+ marked_as cvswork mixedUp.c "" &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h "" &&
+ marked_as cvswork/subdir unspecified.other "" &&
+ marked_as cvswork/subdir newfile.bin -kb &&
+ marked_as cvswork/subdir newfile.c ""
+'
+
+test_expect_success 'setup multi-line files' '
+ ( echo "line 1" &&
+ echo "line 2" &&
+ echo "line 3" &&
+ echo "line 4 with NUL: Q <-" ) | q_to_nul > multiline.c &&
+ git add multiline.c &&
+ ( echo "line 1" &&
+ echo "line 2" &&
+ echo "line 3" &&
+ echo "line 4" ) | q_to_nul > multilineTxt.c &&
+ git add multilineTxt.c &&
+ git commit -q -m "multiline files" &&
+ git push gitcvs.git >/dev/null
+'
+
+rm -rf cvswork
+test_expect_success 'cvs co (guess)' '
+ GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr false &&
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes "" &&
+ marked_as cvswork mixedUp.c -kb &&
+ marked_as cvswork multiline.c -kb &&
+ marked_as cvswork multilineTxt.c "" &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h "" &&
+ marked_as cvswork/subdir unspecified.other "" &&
+ marked_as cvswork/subdir newfile.bin "" &&
+ marked_as cvswork/subdir newfile.c ""
+'
+
+test_expect_success 'cvs co another copy (guess)' '
+ GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
+ marked_as cvswork2 textfile.c "" &&
+ marked_as cvswork2 binfile.bin -kb &&
+ marked_as cvswork2 .gitattributes "" &&
+ marked_as cvswork2 mixedUp.c -kb &&
+ marked_as cvswork2 multiline.c -kb &&
+ marked_as cvswork2 multilineTxt.c "" &&
+ marked_as cvswork2/subdir withCr.bin -kb &&
+ marked_as cvswork2/subdir file.h "" &&
+ marked_as cvswork2/subdir unspecified.other "" &&
+ marked_as cvswork2/subdir newfile.bin "" &&
+ marked_as cvswork2/subdir newfile.c ""
+'
+
+test_expect_success 'add text (guess)' '
+ cd cvswork &&
+ echo "simpleText" > simpleText.c &&
+ GIT_CONFIG="$git_config" cvs -Q add simpleText.c &&
+ cd .. &&
+ marked_as cvswork simpleText.c ""
+'
+
+test_expect_success 'add bin (guess)' '
+ cd cvswork &&
+ echo "simpleBin: NUL: Q <- there" | q_to_nul > simpleBin.bin &&
+ GIT_CONFIG="$git_config" cvs -Q add simpleBin.bin &&
+ cd .. &&
+ marked_as cvswork simpleBin.bin -kb
+'
+
+test_expect_success 'remove files (guess)' '
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q rm -f subdir/file.h &&
+ cd subdir &&
+ GIT_CONFIG="$git_config" cvs -Q rm -f withCr.bin &&
+ cd ../.. &&
+ marked_as cvswork/subdir withCr.bin -kb &&
+ marked_as cvswork/subdir file.h ""
+'
+
+test_expect_success 'cvs ci (guess)' '
+ cd cvswork &&
+ GIT_CONFIG="$git_config" cvs -Q ci -m "add/rm files" >cvs.log 2>&1 &&
+ cd .. &&
+ marked_as cvswork textfile.c "" &&
+ marked_as cvswork binfile.bin -kb &&
+ marked_as cvswork .gitattributes "" &&
+ marked_as cvswork mixedUp.c -kb &&
+ marked_as cvswork multiline.c -kb &&
+ marked_as cvswork multilineTxt.c "" &&
+ not_present cvswork/subdir withCr.bin &&
+ not_present cvswork/subdir file.h &&
+ marked_as cvswork/subdir unspecified.other "" &&
+ marked_as cvswork/subdir newfile.bin "" &&
+ marked_as cvswork/subdir newfile.c "" &&
+ marked_as cvswork simpleBin.bin -kb &&
+ marked_as cvswork simpleText.c ""
+'
+
+test_expect_success 'update subdir of other copy (guess)' '
+ cd cvswork2/subdir &&
+ GIT_CONFIG="$git_config" cvs -Q update &&
+ cd ../.. &&
+ marked_as cvswork2 textfile.c "" &&
+ marked_as cvswork2 binfile.bin -kb &&
+ marked_as cvswork2 .gitattributes "" &&
+ marked_as cvswork2 mixedUp.c -kb &&
+ marked_as cvswork2 multiline.c -kb &&
+ marked_as cvswork2 multilineTxt.c "" &&
+ not_present cvswork2/subdir withCr.bin &&
+ not_present cvswork2/subdir file.h &&
+ marked_as cvswork2/subdir unspecified.other "" &&
+ marked_as cvswork2/subdir newfile.bin "" &&
+ marked_as cvswork2/subdir newfile.c "" &&
+ not_present cvswork2 simpleBin.bin &&
+ not_present cvswork2 simpleText.c
+'
+
+echo "starting update/merge" >> "${WORKDIR}/marked.log"
+test_expect_success 'update/merge full other copy (guess)' '
+ git pull gitcvs.git master &&
+ sed "s/3/replaced_3/" < multilineTxt.c > ml.temp &&
+ mv ml.temp multilineTxt.c &&
+ git add multilineTxt.c &&
+ git commit -q -m "modify multiline file" >> "${WORKDIR}/marked.log" &&
+ git push gitcvs.git >/dev/null &&
+ cd cvswork2 &&
+ sed "s/1/replaced_1/" < multilineTxt.c > ml.temp &&
+ mv ml.temp multilineTxt.c &&
+ GIT_CONFIG="$git_config" cvs update > cvs.log 2>&1 &&
+ cd .. &&
+ marked_as cvswork2 textfile.c "" &&
+ marked_as cvswork2 binfile.bin -kb &&
+ marked_as cvswork2 .gitattributes "" &&
+ marked_as cvswork2 mixedUp.c -kb &&
+ marked_as cvswork2 multiline.c -kb &&
+ marked_as cvswork2 multilineTxt.c "" &&
+ not_present cvswork2/subdir withCr.bin &&
+ not_present cvswork2/subdir file.h &&
+ marked_as cvswork2/subdir unspecified.other "" &&
+ marked_as cvswork2/subdir newfile.bin "" &&
+ marked_as cvswork2/subdir newfile.c "" &&
+ marked_as cvswork2 simpleBin.bin -kb &&
+ marked_as cvswork2 simpleText.c "" &&
+ echo "line replaced_1" > tmpExpect2 &&
+ echo "line 2" >> tmpExpect2 &&
+ echo "line replaced_3" >> tmpExpect2 &&
+ echo "line 4" | q_to_nul >> tmpExpect2 &&
+ cmp cvswork2/multilineTxt.c tmpExpect2
+'
+
+test_done
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 796cd7dba..ae7082be1 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -10,6 +10,7 @@ commandline, and checks that it would not write any errors
or warnings to log.'
gitweb_init () {
+ safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')"
cat >gitweb_config.perl <<EOF
#!/usr/bin/perl
@@ -17,16 +18,16 @@ gitweb_init () {
our \$version = "current";
our \$GIT = "git";
-our \$projectroot = "$(pwd)";
+our \$projectroot = "$safe_pwd";
our \$project_maxdepth = 8;
our \$home_link_str = "projects";
our \$site_name = "[localhost]";
our \$site_header = "";
our \$site_footer = "";
our \$home_text = "indextext.html";
-our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css");
-our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png";
-our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png";
+our @stylesheets = ("file:///$safe_pwd/../../gitweb/gitweb.css");
+our \$logo = "file:///$safe_pwd/../../gitweb/git-logo.png";
+our \$favicon = "file:///$safe_pwd/../../gitweb/git-favicon.png";
our \$projects_list = "";
our \$export_ok = "";
our \$strict_export = "";
@@ -39,19 +40,21 @@ EOF
}
gitweb_run () {
- export GATEWAY_INTERFACE="CGI/1.1"
- export HTTP_ACCEPT="*/*"
- export REQUEST_METHOD="GET"
- export QUERY_STRING=""$1""
- export PATH_INFO=""$2""
+ GATEWAY_INTERFACE="CGI/1.1"
+ HTTP_ACCEPT="*/*"
+ REQUEST_METHOD="GET"
+ QUERY_STRING=""$1""
+ PATH_INFO=""$2""
+ export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD QUERY_STRING PATH_INFO
- export GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+ GITWEB_CONFIG=$(pwd)/gitweb_config.perl
+ export GITWEB_CONFIG
# some of git commands write to STDERR on error, but this is not
# written to web server logs, so we are not interested in that:
# we are interested only in properly formatted errors/warnings
rm -f gitweb.log &&
- perl -- $(pwd)/../../gitweb/gitweb.perl \
+ perl -- "$(pwd)/../../gitweb/gitweb.perl" \
>/dev/null 2>gitweb.log &&
if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi
@@ -483,6 +486,22 @@ test_expect_success \
'gitweb_run "p=.git;a=history;f=file"'
test_debug 'cat gitweb.log'
+test_expect_success \
+ 'logs: history (implicit HEAD, non-existent file)' \
+ 'gitweb_run "p=.git;a=history;f=non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+ 'logs: history (implicit HEAD, deleted file)' \
+ 'git checkout master &&
+ echo "to be deleted" > deleted_file &&
+ git add deleted_file &&
+ git commit -m "Add file to be deleted" &&
+ git rm deleted_file &&
+ git commit -m "Delete file" &&
+ gitweb_run "p=.git;a=history;f=deleted_file"'
+test_debug 'cat gitweb.log'
+
# ----------------------------------------------------------------------
# feed generation
diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh
index 7706430d8..0d7786a8c 100755
--- a/t/t9600-cvsimport.sh
+++ b/t/t9600-cvsimport.sh
@@ -3,6 +3,13 @@
test_description='git-cvsimport basic tests'
. ./test-lib.sh
+CVSROOT=$(pwd)/cvsroot
+export CVSROOT
+unset CVS_SERVER
+# for clean cvsps cache
+HOME=$(pwd)
+export HOME
+
if ! type cvs >/dev/null 2>&1
then
say 'skipping cvsimport tests, cvs not found'
@@ -12,7 +19,7 @@ fi
cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
case "$cvsps_version" in
-2.1)
+2.1 | 2.2*)
;;
'')
say 'skipping cvsimport tests, cvsps not found'
@@ -20,23 +27,17 @@ case "$cvsps_version" in
exit
;;
*)
- say 'skipping cvsimport tests, cvsps too old'
+ say 'skipping cvsimport tests, unsupported cvsps version'
test_done
exit
;;
esac
-CVSROOT=$(pwd)/cvsroot
-export CVSROOT
-# for clean cvsps cache
-HOME=$(pwd)
-export HOME
-
test_expect_success 'setup cvsroot' 'cvs init'
test_expect_success 'setup a cvs module' '
- mkdir $CVSROOT/module &&
+ mkdir "$CVSROOT/module" &&
cvs co -d module-cvs module &&
cd module-cvs &&
cat <<EOF >o_fortuna &&
@@ -69,7 +70,7 @@ EOF
test_expect_success 'import a trivial module' '
git cvsimport -a -z 0 -C module-git module &&
- git diff module-cvs/o_fortuna module-git/o_fortuna
+ test_cmp module-cvs/o_fortuna module-git/o_fortuna
'
@@ -110,7 +111,7 @@ test_expect_success 'update git module' '
git cvsimport -a -z 0 module &&
git merge origin &&
cd .. &&
- git diff module-cvs/o_fortuna module-git/o_fortuna
+ test_cmp module-cvs/o_fortuna module-git/o_fortuna
'
@@ -131,7 +132,7 @@ test_expect_success 'cvsimport.module config works' '
git cvsimport -a -z0 &&
git merge origin &&
cd .. &&
- git diff module-cvs/tick module-git/tick
+ test_cmp module-cvs/tick module-git/tick
'
@@ -142,7 +143,7 @@ test_expect_success 'import from a CVS working tree' '
git cvsimport -a -z0 &&
echo 1 >expect &&
git log -1 --pretty=format:%s%n >actual &&
- git diff actual expect &&
+ test_cmp actual expect &&
cd ..
'
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh
new file mode 100755
index 000000000..9706ee577
--- /dev/null
+++ b/t/t9700-perl-git.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Lea Wiemann
+#
+
+test_description='perl interface (Git.pm)'
+. ./test-lib.sh
+
+perl -MTest::More -e 0 2>/dev/null || {
+ say_color skip "Perl Test::More unavailable, skipping test"
+ test_done
+}
+
+# set up test repository
+
+test_expect_success \
+ 'set up test repository' \
+ 'echo "test file 1" > file1 &&
+ echo "test file 2" > file2 &&
+ mkdir directory1 &&
+ echo "in directory1" >> directory1/file &&
+ mkdir directory2 &&
+ echo "in directory2" >> directory2/file &&
+ git add . &&
+ git commit -m "first commit" &&
+
+ echo "changed file 1" > file1 &&
+ git commit -a -m "second commit" &&
+
+ git-config --add color.test.slot1 green &&
+ git-config --add test.string value &&
+ git-config --add test.dupstring value1 &&
+ git-config --add test.dupstring value2 &&
+ git-config --add test.booltrue true &&
+ git-config --add test.boolfalse no &&
+ git-config --add test.boolother other &&
+ git-config --add test.int 2k
+ '
+
+test_external_without_stderr \
+ 'Perl API' \
+ perl ../t9700/test.pl
+
+test_done
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
new file mode 100755
index 000000000..4d2312548
--- /dev/null
+++ b/t/t9700/test.pl
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+use lib (split(/:/, $ENV{GITPERLLIB}));
+
+use 5.006002;
+use warnings;
+use strict;
+
+use Test::More qw(no_plan);
+
+use Cwd;
+use File::Basename;
+use File::Temp;
+
+BEGIN { use_ok('Git') }
+
+# set up
+our $repo_dir = "trash directory";
+our $abs_repo_dir = Cwd->cwd;
+die "this must be run by calling the t/t97* shell script(s)\n"
+ if basename(Cwd->cwd) ne $repo_dir;
+ok(our $r = Git->repository(Directory => "."), "open repository");
+
+# config
+is($r->config("test.string"), "value", "config scalar: string");
+is_deeply([$r->config("test.dupstring")], ["value1", "value2"],
+ "config array: string");
+is($r->config("test.nonexistent"), undef, "config scalar: nonexistent");
+is_deeply([$r->config("test.nonexistent")], [], "config array: nonexistent");
+is($r->config_int("test.int"), 2048, "config_int: integer");
+is($r->config_int("test.nonexistent"), undef, "config_int: nonexistent");
+ok($r->config_bool("test.booltrue"), "config_bool: true");
+ok(!$r->config_bool("test.boolfalse"), "config_bool: false");
+our $ansi_green = "\x1b[32m";
+is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
+# Cannot test $r->get_colorbool("color.foo")) because we do not
+# control whether our STDOUT is a terminal.
+
+# Failure cases for config:
+# Save and restore STDERR; we will probably extract this into a
+# "dies_ok" method and possibly move the STDERR handling to Git.pm.
+open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR;
+eval { $r->config("test.dupstring") };
+ok($@, "config: duplicate entry in scalar context fails");
+eval { $r->config_bool("test.boolother") };
+ok($@, "config_bool: non-boolean values fail");
+open STDERR, ">&", $tmpstderr or die "cannot restore STDERR";
+
+# ident
+like($r->ident("aUthor"), qr/^A U Thor <author\@example.com> [0-9]+ \+0000$/,
+ "ident scalar: author (type)");
+like($r->ident("cOmmitter"), qr/^C O Mitter <committer\@example.com> [0-9]+ \+0000$/,
+ "ident scalar: committer (type)");
+is($r->ident("invalid"), "invalid", "ident scalar: invalid ident string (no parsing)");
+my ($name, $email, $time_tz) = $r->ident('author');
+is_deeply([$name, $email], ["A U Thor", "author\@example.com"],
+ "ident array: author");
+like($time_tz, qr/[0-9]+ \+0000/, "ident array: author");
+is_deeply([$r->ident("Name <email> 123 +0000")], ["Name", "email", "123 +0000"],
+ "ident array: ident string");
+is_deeply([$r->ident("invalid")], [], "ident array: invalid ident string");
+
+# ident_person
+is($r->ident_person("aUthor"), "A U Thor <author\@example.com>",
+ "ident_person: author (type)");
+is($r->ident_person("Name <email> 123 +0000"), "Name <email>",
+ "ident_person: ident string");
+is($r->ident_person("Name", "email", "123 +0000"), "Name <email>",
+ "ident_person: array");
+
+# objects and hashes
+ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)");
+our $tmpfile = File::Temp->new;
+is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size");
+our $blobcontents;
+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
+is($blobcontents, "changed file 1\n", "cat_blob: data");
+seek $tmpfile, 0, 0;
+is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip");
+$tmpfile = File::Temp->new();
+print $tmpfile my $test_text = "test blob, to be inserted\n";
+like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,
+ "hash_and_insert_object: returns hash");
+$tmpfile = File::Temp->new;
+is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size");
+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
+is($blobcontents, $test_text, "cat_blob: roundtrip data");
+
+# paths
+is($r->repo_path, "./.git", "repo_path");
+is($r->wc_path, $abs_repo_dir . "/", "wc_path");
+is($r->wc_subdir, "", "wc_subdir initial");
+$r->wc_chdir("directory1");
+is($r->wc_subdir, "directory1", "wc_subdir after wc_chdir");
+TODO: {
+ local $TODO = "commands do not work after wc_chdir";
+ # Failure output is active even in non-verbose mode and thus
+ # annoying. Hence we skip these tests as long as they fail.
+ todo_skip 'config after wc_chdir', 1;
+ is($r->config("color.string"), "value", "config after wc_chdir");
+}
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 90b6844d0..11c027571 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -3,12 +3,16 @@
# Copyright (c) 2005 Junio C Hamano
#
+# Keep the original TERM for say_color
+ORIGINAL_TERM=$TERM
+
# For repeatability, reset the environment to known value.
LANG=C
LC_ALL=C
PAGER=cat
TZ=UTC
-export LANG LC_ALL PAGER TZ
+TERM=dumb
+export LANG LC_ALL PAGER TERM TZ
EDITOR=:
VISUAL=:
unset GIT_EDITOR
@@ -31,6 +35,7 @@ unset GIT_WORK_TREE
unset GIT_EXTERNAL_DIFF
unset GIT_INDEX_FILE
unset GIT_OBJECT_DIRECTORY
+unset GIT_CEILING_DIRECTORIES
unset SHA1_FILE_DIRECTORIES
unset SHA1_FILE_DIRECTORY
GIT_MERGE_VERBOSITY=5
@@ -38,6 +43,7 @@ export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR VISUAL
+GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
@@ -58,12 +64,14 @@ esac
# This test checks if command xyzzy does the right thing...
# '
# . ./test-lib.sh
-
-[ "x$TERM" != "xdumb" ] &&
- [ -t 1 ] &&
- tput bold >/dev/null 2>&1 &&
- tput setaf 1 >/dev/null 2>&1 &&
- tput sgr0 >/dev/null 2>&1 &&
+[ "x$ORIGINAL_TERM" != "xdumb" ] && (
+ TERM=$ORIGINAL_TERM &&
+ export TERM &&
+ [ -t 1 ] &&
+ tput bold >/dev/null 2>&1 &&
+ tput setaf 1 >/dev/null 2>&1 &&
+ tput sgr0 >/dev/null 2>&1
+ ) &&
color=t
while test "$#" -ne 0
@@ -73,6 +81,8 @@ do
debug=t; shift ;;
-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)
immediate=t; shift ;;
+ -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests)
+ export GIT_TEST_LONG=t; shift ;;
-h|--h|--he|--hel|--help)
help=t; shift ;;
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
@@ -80,7 +90,7 @@ do
-q|--q|--qu|--qui|--quie|--quiet)
quiet=t; shift ;;
--no-color)
- color=; shift ;;
+ color=; shift ;;
--no-python)
# noop now...
shift ;;
@@ -91,6 +101,9 @@ done
if test -n "$color"; then
say_color () {
+ (
+ TERM=$ORIGINAL_TERM
+ export TERM
case "$1" in
error) tput bold; tput setaf 1;; # bold red
skip) tput bold; tput setaf 2;; # bold green
@@ -101,6 +114,7 @@ if test -n "$color"; then
shift
echo "* $*"
tput sgr0
+ )
}
else
say_color() {
@@ -139,8 +153,32 @@ fi
test_failure=0
test_count=0
+test_fixed=0
+test_broken=0
+test_success=0
-trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
+die () {
+ echo >&5 "FATAL: Unexpected exit with code $?"
+ exit 1
+}
+
+trap 'die' exit
+
+# The semantics of the editor variables are that of invoking
+# sh -c "$EDITOR \"$@\"" files ...
+#
+# If our trash directory contains shell metacharacters, they will be
+# interpreted if we just set $EDITOR directly, so do a little dance with
+# environment variables to work around this.
+#
+# In particular, quoting isn't enough, as the path may contain the same quote
+# that we're using.
+test_set_editor () {
+ FAKE_EDITOR="$1"
+ export FAKE_EDITOR
+ VISUAL='"$FAKE_EDITOR"'
+ export VISUAL
+}
test_tick () {
if test -z "${test_tick+set}"
@@ -159,6 +197,7 @@ test_tick () {
test_ok_ () {
test_count=$(expr "$test_count" + 1)
+ test_success=$(expr "$test_success" + 1)
say_color "" " ok $test_count: $@"
}
@@ -171,6 +210,17 @@ test_failure_ () {
test "$immediate" = "" || { trap - exit; exit 1; }
}
+test_known_broken_ok_ () {
+ test_count=$(expr "$test_count" + 1)
+ test_fixed=$(($test_fixed+1))
+ say_color "" " FIXED $test_count: $@"
+}
+
+test_known_broken_failure_ () {
+ test_count=$(expr "$test_count" + 1)
+ test_broken=$(($test_broken+1))
+ say_color skip " still broken $test_count: $@"
+}
test_debug () {
test "$debug" = "" || eval "$1"
@@ -211,13 +261,13 @@ test_expect_failure () {
error "bug in the test script: not 2 parameters to test-expect-failure"
if ! test_skip "$@"
then
- say >&3 "expecting failure: $2"
+ say >&3 "checking known breakage: $2"
test_run_ "$2"
- if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
+ if [ "$?" = 0 -a "$eval_ret" = 0 ]
then
- test_ok_ "$1"
+ test_known_broken_ok_ "$1"
else
- test_failure_ "$@"
+ test_known_broken_failure_ "$1"
fi
fi
echo >&3 ""
@@ -257,7 +307,99 @@ test_expect_code () {
echo >&3 ""
}
-# Most tests can use the created repository, but some amy need to create more.
+# test_external runs external test scripts that provide continuous
+# test output about their progress, and succeeds/fails on
+# zero/non-zero exit code. It outputs the test output on stdout even
+# in non-verbose mode, and announces the external script with "* run
+# <n>: ..." before running it. When providing relative paths, keep in
+# mind that all scripts run in "trash directory".
+# Usage: test_external description command arguments...
+# Example: test_external 'Perl API' perl ../path/to/test.pl
+test_external () {
+ test "$#" -eq 3 ||
+ error >&5 "bug in the test script: not 3 parameters to test_external"
+ descr="$1"
+ shift
+ if ! test_skip "$descr" "$@"
+ then
+ # Announce the script to reduce confusion about the
+ # test output that follows.
+ say_color "" " run $(expr "$test_count" + 1): $descr ($*)"
+ # Run command; redirect its stderr to &4 as in
+ # test_run_, but keep its stdout on our stdout even in
+ # non-verbose mode.
+ "$@" 2>&4
+ if [ "$?" = 0 ]
+ then
+ test_ok_ "$descr"
+ else
+ test_failure_ "$descr" "$@"
+ fi
+ fi
+}
+
+# Like test_external, but in addition tests that the command generated
+# no output on stderr.
+test_external_without_stderr () {
+ # The temporary file has no (and must have no) security
+ # implications.
+ tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
+ stderr="$tmp/git-external-stderr.$$.tmp"
+ test_external "$@" 4> "$stderr"
+ [ -f "$stderr" ] || error "Internal error: $stderr disappeared."
+ descr="no stderr: $1"
+ shift
+ say >&3 "expecting no stderr from previous command"
+ if [ ! -s "$stderr" ]; then
+ rm "$stderr"
+ test_ok_ "$descr"
+ else
+ if [ "$verbose" = t ]; then
+ output=`echo; echo Stderr is:; cat "$stderr"`
+ else
+ output=
+ fi
+ # rm first in case test_failure exits.
+ rm "$stderr"
+ test_failure_ "$descr" "$@" "$output"
+ fi
+}
+
+# This is not among top-level (test_expect_success | test_expect_failure)
+# but is a prefix that can be used in the test script, like:
+#
+# test_expect_success 'complain and die' '
+# do something &&
+# do something else &&
+# test_must_fail git checkout ../outerspace
+# '
+#
+# Writing this as "! git checkout ../outerspace" is wrong, because
+# the failure could be due to a segv. We want a controlled failure.
+
+test_must_fail () {
+ "$@"
+ test $? -gt 0 -a $? -le 129 -o $? -gt 192
+}
+
+# test_cmp is a helper function to compare actual and expected output.
+# You can use it like:
+#
+# test_expect_success 'foo works' '
+# echo expected >expected &&
+# foo >actual &&
+# test_cmp expected actual
+# '
+#
+# This could be written as either "cmp" or "diff -u", but:
+# - cmp's output is not nearly as easy to read as diff -u
+# - not all diff versions understand "-u"
+
+test_cmp() {
+ $GIT_TEST_CMP "$@"
+}
+
+# Most tests can use the created repository, but some may need to create more.
# Usage: test_create_repo <directory>
test_create_repo () {
test "$#" = 1 ||
@@ -266,7 +408,7 @@ test_create_repo () {
repo="$1"
mkdir "$repo"
cd "$repo" || error "Cannot setup test environment"
- "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
+ "$GIT_EXEC_PATH/git" init "--template=$GIT_EXEC_PATH/templates/blt/" >&3 2>&4 ||
error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
cd "$owd"
@@ -274,33 +416,59 @@ test_create_repo () {
test_done () {
trap - exit
+ test_results_dir="$TEST_DIRECTORY/test-results"
+ mkdir -p "$test_results_dir"
+ test_results_path="$test_results_dir/${0%-*}-$$"
+
+ echo "total $test_count" >> $test_results_path
+ echo "success $test_success" >> $test_results_path
+ echo "fixed $test_fixed" >> $test_results_path
+ echo "broken $test_broken" >> $test_results_path
+ echo "failed $test_failure" >> $test_results_path
+ echo "" >> $test_results_path
+
+ if test "$test_fixed" != 0
+ then
+ say_color pass "fixed $test_fixed known breakage(s)"
+ fi
+ if test "$test_broken" != 0
+ then
+ say_color error "still have $test_broken known breakage(s)"
+ msg="remaining $(($test_count-$test_broken)) test(s)"
+ else
+ msg="$test_count test(s)"
+ fi
case "$test_failure" in
0)
# We could:
- # cd .. && rm -fr trash
+ # cd .. && rm -fr 'trash directory'
# but that means we forbid any tests that use their own
# subdirectory from calling test_done without coming back
# to where they started from.
# The Makefile provided will clean this test area so
# we will leave things as they are.
- say_color pass "passed all $test_count test(s)"
+ say_color pass "passed all $msg"
exit 0 ;;
*)
- say_color error "failed $test_failure among $test_count test(s)"
+ say_color error "failed $test_failure among $msg"
exit 1 ;;
esac
}
# Test the binaries we have just built. The tests are kept in
-# t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
+# t/ subdirectory and are run in 'trash directory' subdirectory.
+TEST_DIRECTORY=$(pwd)
+PATH=$TEST_DIRECTORY/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
-GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+unset GIT_CONFIG
+unset GIT_CONFIG_LOCAL
+GIT_CONFIG_NOSYSTEM=1
+GIT_CONFIG_NOGLOBAL=1
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
export GITPERLLIB
@@ -314,11 +482,20 @@ if ! test -x ../test-chmtime; then
exit 1
fi
+. ../GIT-BUILD-OPTIONS
+
# Test repository
-test=trash
-rm -fr "$test"
-test_create_repo $test
-cd "$test"
+test="trash directory"
+rm -fr "$test" || {
+ trap - exit
+ echo >&5 "FATAL: Cannot prepare test area"
+ exit 1
+}
+
+test_create_repo "$test"
+# Use -P to resolve symlinks in our working directory so that the cwd
+# in subprocesses like git equals our $PWD (for pathname comparisons).
+cd -P "$test" || exit 1
this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
for skp in $GIT_SKIP_TESTS
diff --git a/tag.c b/tag.c
index 38bf9134f..4470d2bf7 100644
--- a/tag.c
+++ b/tag.c
@@ -9,7 +9,10 @@ const char *tag_type = "tag";
struct object *deref_tag(struct object *o, const char *warn, int warnlen)
{
while (o && o->type == OBJ_TAG)
- o = parse_object(((struct tag *)o)->tagged->sha1);
+ if (((struct tag *)o)->tagged)
+ o = parse_object(((struct tag *)o)->tagged->sha1);
+ else
+ o = NULL;
if (!o && warn) {
if (!warnlen)
warnlen = strlen(warn);
@@ -84,12 +87,6 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
item->tagged = NULL;
}
- if (item->tagged && track_object_refs) {
- struct object_refs *refs = alloc_object_refs(1);
- refs->ref[0] = item->tagged;
- set_object_refs(&item->object, refs);
- }
-
return 0;
}
diff --git a/templates/Makefile b/templates/Makefile
index ebd3a62fd..9f3f1fc35 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -8,12 +8,12 @@ INSTALL ?= install
TAR ?= tar
RM ?= rm -f
prefix ?= $(HOME)
-template_dir ?= $(prefix)/share/git-core/templates
+template_instdir ?= $(prefix)/share/git-core/templates
# DESTDIR=
# Shell quote (do not use $(call) to accommodate ancient setups);
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
-template_dir_SQ = $(subst ','\'',$(template_dir))
+template_instdir_SQ = $(subst ','\'',$(template_instdir))
all: boilerplates.made custom
@@ -29,10 +29,10 @@ boilerplates.made : $(bpsrc)
case "$$boilerplate" in *~) continue ;; esac && \
dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
dir=`expr "$$dst" : '\(.*\)/'` && \
- mkdir -p blt/$$dir && \
+ $(INSTALL) -d -m 755 blt/$$dir && \
case "$$boilerplate" in \
*--) ;; \
- *) cp $$boilerplate blt/$$dst ;; \
+ *) cp -p $$boilerplate blt/$$dst ;; \
esac || exit; \
done && \
date >$@
@@ -46,6 +46,6 @@ clean:
$(RM) -r blt boilerplates.made
install: all
- $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_dir_SQ)'
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
(cd blt && $(TAR) cf - .) | \
- (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
+ (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xf -)
diff --git a/templates/hooks--applypatch-msg b/templates/hooks--applypatch-msg.sample
index 02de1ef84..8b2a2fe84 100644..100755
--- a/templates/hooks--applypatch-msg
+++ b/templates/hooks--applypatch-msg.sample
@@ -7,7 +7,7 @@
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
-# To enable this hook, make this file executable.
+# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
test -x "$GIT_DIR/hooks/commit-msg" &&
diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg.sample
index c5cdb9d7e..6ef1d29d0 100644..100755
--- a/templates/hooks--commit-msg
+++ b/templates/hooks--commit-msg.sample
@@ -6,9 +6,12 @@
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
-# To enable this hook, make this file executable.
+# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
+# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
+# hook is more suited to it.
+#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
diff --git a/templates/hooks--post-commit b/templates/hooks--post-commit.sample
index 8be6f34ad..22668216a 100644..100755
--- a/templates/hooks--post-commit
+++ b/templates/hooks--post-commit.sample
@@ -3,6 +3,6 @@
# An example hook script that is called after a successful
# commit is made.
#
-# To enable this hook, make this file executable.
+# To enable this hook, rename this file to "post-commit".
: Nothing
diff --git a/templates/hooks--post-receive b/templates/hooks--post-receive
deleted file mode 100644
index b70c8fd36..000000000
--- a/templates/hooks--post-receive
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-#
-# An example hook script for the post-receive event
-#
-# This script is run after receive-pack has accepted a pack and the
-# repository has been updated. It is passed arguments in through stdin
-# in the form
-# <oldrev> <newrev> <refname>
-# For example:
-# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
-#
-# see contrib/hooks/ for an sample, or uncomment the next line (on debian)
-#
-
-
-#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
diff --git a/templates/hooks--post-receive.sample b/templates/hooks--post-receive.sample
new file mode 100755
index 000000000..18d2e0f72
--- /dev/null
+++ b/templates/hooks--post-receive.sample
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script for the "post-receive" event.
+#
+# The "post-receive" script is run after receive-pack has accepted a pack
+# and the repository has been updated. It is passed arguments in through
+# stdin in the form
+# <oldrev> <newrev> <refname>
+# For example:
+# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
+#
+# see contrib/hooks/ for an sample, or uncomment the next line and
+# rename the file to "post-receive".
+
+#. /usr/share/doc/git-core/contrib/hooks/post-receive-email
diff --git a/templates/hooks--post-update b/templates/hooks--post-update.sample
index bcba8937b..5323b56b8 100644..100755
--- a/templates/hooks--post-update
+++ b/templates/hooks--post-update.sample
@@ -3,6 +3,6 @@
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
-# To enable this hook, make this file executable by "chmod +x post-update".
+# To enable this hook, rename this file to "post-update".
exec git-update-server-info
diff --git a/templates/hooks--pre-applypatch b/templates/hooks--pre-applypatch.sample
index eeccc934c..b1f187c2e 100644..100755
--- a/templates/hooks--pre-applypatch
+++ b/templates/hooks--pre-applypatch.sample
@@ -6,7 +6,7 @@
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
-# To enable this hook, make this file executable.
+# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit
deleted file mode 100644
index b25dce6bb..000000000
--- a/templates/hooks--pre-commit
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-#
-# An example hook script to verify what is about to be committed.
-# Called by git-commit with no arguments. The hook should
-# exit with non-zero status after issuing an appropriate message if
-# it wants to stop the commit.
-#
-# To enable this hook, make this file executable.
-
-# This is slightly modified from Andrew Morton's Perfect Patch.
-# Lines you introduce should not have trailing whitespace.
-# Also check for an indentation that has SP before a TAB.
-
-if git-rev-parse --verify HEAD 2>/dev/null
-then
- git-diff-index -p -M --cached HEAD --
-else
- # NEEDSWORK: we should produce a diff with an empty tree here
- # if we want to do the same verification for the initial import.
- :
-fi |
-perl -e '
- my $found_bad = 0;
- my $filename;
- my $reported_filename = "";
- my $lineno;
- sub bad_line {
- my ($why, $line) = @_;
- if (!$found_bad) {
- print STDERR "*\n";
- print STDERR "* You have some suspicious patch lines:\n";
- print STDERR "*\n";
- $found_bad = 1;
- }
- if ($reported_filename ne $filename) {
- print STDERR "* In $filename\n";
- $reported_filename = $filename;
- }
- print STDERR "* $why (line $lineno)\n";
- print STDERR "$filename:$lineno:$line\n";
- }
- while (<>) {
- if (m|^diff --git a/(.*) b/\1$|) {
- $filename = $1;
- next;
- }
- if (/^@@ -\S+ \+(\d+)/) {
- $lineno = $1 - 1;
- next;
- }
- if (/^ /) {
- $lineno++;
- next;
- }
- if (s/^\+//) {
- $lineno++;
- chomp;
- if (/\s$/) {
- bad_line("trailing whitespace", $_);
- }
- if (/^\s* \t/) {
- bad_line("indent SP followed by a TAB", $_);
- }
- if (/^([<>])\1{6} |^={7}$/) {
- bad_line("unresolved merge conflict", $_);
- }
- }
- }
- exit($found_bad);
-'
diff --git a/templates/hooks--pre-commit.sample b/templates/hooks--pre-commit.sample
new file mode 100755
index 000000000..0e49279c7
--- /dev/null
+++ b/templates/hooks--pre-commit.sample
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by git-commit with no arguments. The hook should
+# exit with non-zero status after issuing an appropriate message if
+# it wants to stop the commit.
+#
+# To enable this hook, rename this file to "pre-commit".
+
+if git-rev-parse --verify HEAD 2>/dev/null
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+exec git diff-index --check --cached $against --
diff --git a/templates/hooks--pre-rebase b/templates/hooks--pre-rebase.sample
index 981c454cd..be1b06e25 100644..100755
--- a/templates/hooks--pre-rebase
+++ b/templates/hooks--pre-rebase.sample
@@ -1,7 +1,19 @@
#!/bin/sh
#
-# Copyright (c) 2006 Junio C Hamano
+# Copyright (c) 2006, 2008 Junio C Hamano
#
+# The "pre-rebase" hook is run just before "git-rebase" starts doing
+# its job, and can prevent the command from running by exiting with
+# non-zero status.
+#
+# The hook is called with the following parameters:
+#
+# $1 -- the upstream the series was forked from.
+# $2 -- the branch being rebased (or empty when rebasing the current branch).
+#
+# This sample shows how to prevent topic branches that are already
+# merged to 'next' branch from getting rebased, because allowing it
+# would result in rebasing already published history.
publish=next
basebranch="$1"
@@ -9,11 +21,12 @@ if test "$#" = 2
then
topic="refs/heads/$2"
else
- topic=`git symbolic-ref HEAD`
+ topic=`git symbolic-ref HEAD` ||
+ exit 0 ;# we do not interrupt rebasing detached HEAD
fi
-case "$basebranch,$topic" in
-master,refs/heads/??/*)
+case "$topic" in
+refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
@@ -23,6 +36,12 @@ esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
+# Does the topic really exist?
+git show-ref -q "$topic" || {
+ echo >&2 "No such branch $topic"
+ exit 1
+}
+
# Is topic fully merged to master?
not_in_master=`git-rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
diff --git a/templates/hooks--prepare-commit-msg.sample b/templates/hooks--prepare-commit-msg.sample
new file mode 100755
index 000000000..365242499
--- /dev/null
+++ b/templates/hooks--prepare-commit-msg.sample
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# An example hook script to prepare the commit log message.
+# Called by git-commit with the name of the file that has the
+# commit message, followed by the description of the commit
+# message's source. The hook's purpose is to edit the commit
+# message file. If the hook fails with a non-zero status,
+# the commit is aborted.
+#
+# To enable this hook, rename this file to "prepare-commit-msg".
+
+# This hook includes three examples. The first comments out the
+# "Conflicts:" part of a merge commit.
+#
+# The second includes the output of "git diff --name-status -r"
+# into the message, just before the "git status" output. It is
+# commented because it doesn't cope with --amend or with squashed
+# commits.
+#
+# The third example adds a Signed-off-by line to the message, that can
+# still be edited. This is rarely a good idea.
+
+case "$2,$3" in
+ merge,)
+ perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
+
+# ,|template,)
+# perl -i.bak -pe '
+# print "\n" . `git diff --cached --name-status -r`
+# if /^#/ && $first++ == 0' "$1" ;;
+
+ *) ;;
+esac
+
+# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
diff --git a/templates/hooks--update b/templates/hooks--update.sample
index 4b69268fd..93c605594 100644..100755
--- a/templates/hooks--update
+++ b/templates/hooks--update.sample
@@ -3,7 +3,7 @@
# An example hook script to blocks unannotated tags from entering.
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
#
-# To enable this hook, make this file executable by "chmod +x update".
+# To enable this hook, rename this file to "update".
#
# Config
# ------
diff --git a/test-absolute-path.c b/test-absolute-path.c
deleted file mode 100644
index c959ea20d..000000000
--- a/test-absolute-path.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "cache.h"
-
-int main(int argc, char **argv)
-{
- while (argc > 1) {
- puts(make_absolute_path(argv[1]));
- argc--;
- argv++;
- }
- return 0;
-}
diff --git a/test-parse-options.c b/test-parse-options.c
index 4d3e2ec39..61d2c3981 100644
--- a/test-parse-options.c
+++ b/test-parse-options.c
@@ -3,8 +3,22 @@
static int boolean = 0;
static int integer = 0;
+static unsigned long timestamp;
+static int abbrev = 7;
+static int verbose = 0, dry_run = 0, quiet = 0;
static char *string = NULL;
+int length_callback(const struct option *opt, const char *arg, int unset)
+{
+ printf("Callback: \"%s\", %d\n",
+ (arg ? arg : "not set"), unset);
+ if (unset)
+ return 1; /* do not support unset */
+
+ *(int *)opt->value = strlen(arg);
+ return 0;
+}
+
int main(int argc, const char **argv)
{
const char *usage[] = {
@@ -13,12 +27,29 @@ int main(int argc, const char **argv)
};
struct option options[] = {
OPT_BOOLEAN('b', "boolean", &boolean, "get a boolean"),
+ OPT_BIT('4', "or4", &boolean,
+ "bitwise-or boolean with ...0100", 4),
+ OPT_GROUP(""),
OPT_INTEGER('i', "integer", &integer, "get a integer"),
OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
- OPT_GROUP("string options"),
+ OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
+ OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
+ OPT_CALLBACK('L', "length", &integer, "str",
+ "get length of <str>", length_callback),
+ OPT_GROUP("String options"),
OPT_STRING('s', "string", &string, "string", "get a string"),
OPT_STRING(0, "string2", &string, "str", "get another string"),
OPT_STRING(0, "st", &string, "st", "get another string (pervert ordering)"),
+ OPT_STRING('o', NULL, &string, "str", "get another string"),
+ OPT_SET_PTR(0, "default-string", &string,
+ "set string to default", (unsigned long)"default"),
+ OPT_GROUP("Magic arguments"),
+ OPT_ARGUMENT("quux", "means --quux"),
+ OPT_GROUP("Standard options"),
+ OPT__ABBREV(&abbrev),
+ OPT__VERBOSE(&verbose),
+ OPT__DRY_RUN(&dry_run),
+ OPT__QUIET(&quiet),
OPT_END(),
};
int i;
@@ -26,8 +57,13 @@ int main(int argc, const char **argv)
argc = parse_options(argc, argv, options, usage, 0);
printf("boolean: %d\n", boolean);
- printf("integer: %d\n", integer);
+ printf("integer: %u\n", integer);
+ printf("timestamp: %lu\n", timestamp);
printf("string: %s\n", string ? string : "(not set)");
+ printf("abbrev: %d\n", abbrev);
+ printf("verbose: %d\n", verbose);
+ printf("quiet: %s\n", quiet ? "yes" : "no");
+ printf("dry run: %s\n", dry_run ? "yes" : "no");
for (i = 0; i < argc; i++)
printf("arg %02d: %s\n", i, argv[i]);
diff --git a/test-path-utils.c b/test-path-utils.c
new file mode 100644
index 000000000..a0bcb0e21
--- /dev/null
+++ b/test-path-utils.c
@@ -0,0 +1,26 @@
+#include "cache.h"
+
+int main(int argc, char **argv)
+{
+ if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
+ char *buf = xmalloc(strlen(argv[2])+1);
+ int rv = normalize_absolute_path(buf, argv[2]);
+ assert(strlen(buf) == rv);
+ puts(buf);
+ }
+
+ if (argc >= 2 && !strcmp(argv[1], "make_absolute_path")) {
+ while (argc > 2) {
+ puts(make_absolute_path(argv[2]));
+ argc--;
+ argv++;
+ }
+ }
+
+ if (argc == 4 && !strcmp(argv[1], "longest_ancestor_length")) {
+ int len = longest_ancestor_length(argv[2], argv[3]);
+ printf("%d\n", len);
+ }
+
+ return 0;
+}
diff --git a/test-sha1.sh b/test-sha1.sh
index bf526c8f5..0f0bc5d02 100755
--- a/test-sha1.sh
+++ b/test-sha1.sh
@@ -10,7 +10,7 @@ do
{
test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
- tr '\000' 'g'
+ perl -pe 'y/\000/g/'
} | ./test-sha1 $cnt
`
if test "$expect" = "$actual"
@@ -55,7 +55,7 @@ do
{
test -z "$pfx" || echo "$pfx"
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
- tr '\000' 'g'
+ perl -pe 'y/\000/g/'
} | sha1sum |
sed -e 's/ .*//'
`
diff --git a/thread-utils.c b/thread-utils.c
new file mode 100644
index 000000000..55e7e2904
--- /dev/null
+++ b/thread-utils.c
@@ -0,0 +1,48 @@
+#include "cache.h"
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#elif defined(hpux) || defined(__hpux) || defined(_hpux)
+# include <sys/pstat.h>
+#endif
+
+/*
+ * By doing this in two steps we can at least get
+ * the function to be somewhat coherent, even
+ * with this disgusting nest of #ifdefs.
+ */
+#ifndef _SC_NPROCESSORS_ONLN
+# ifdef _SC_NPROC_ONLN
+# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+# elif defined _SC_CRAY_NCPU
+# define _SC_NPROCESSORS_ONLN _SC_CRAY_NCPU
+# endif
+#endif
+
+int online_cpus(void)
+{
+#ifdef _SC_NPROCESSORS_ONLN
+ long ncpus;
+#endif
+
+#ifdef _WIN32
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+
+ if ((int)info.dwNumberOfProcessors > 0)
+ return (int)info.dwNumberOfProcessors;
+#elif defined(hpux) || defined(__hpux) || defined(_hpux)
+ struct pst_dynamic psd;
+
+ if (!pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0))
+ return (int)psd.psd_proc_cnt;
+#endif
+
+#ifdef _SC_NPROCESSORS_ONLN
+ if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
+ return (int)ncpus;
+#endif
+
+ return 1;
+}
diff --git a/thread-utils.h b/thread-utils.h
new file mode 100644
index 000000000..cce4b77bd
--- /dev/null
+++ b/thread-utils.h
@@ -0,0 +1,6 @@
+#ifndef THREAD_COMPAT_H
+#define THREAD_COMPAT_H
+
+extern int online_cpus(void);
+
+#endif /* THREAD_COMPAT_H */
diff --git a/transport.c b/transport.c
index babaa2139..71433d999 100644
--- a/transport.c
+++ b/transport.c
@@ -203,7 +203,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
}
static int fetch_objs_via_rsync(struct transport *transport,
- int nr_objs, struct ref **to_fetch)
+ int nr_objs, const struct ref **to_fetch)
{
struct strbuf buf = STRBUF_INIT;
struct child_process rsync;
@@ -350,7 +350,7 @@ static int rsync_transport_push(struct transport *transport,
#ifndef NO_CURL /* http fetch is the only user */
static int fetch_objs_via_walker(struct transport *transport,
- int nr_objs, struct ref **to_fetch)
+ int nr_objs, const struct ref **to_fetch)
{
char *dest = xstrdup(transport->url);
struct walker *walker = transport->data;
@@ -441,40 +441,38 @@ static struct ref *get_refs_via_curl(struct transport *transport)
struct ref *ref = NULL;
struct ref *last_ref = NULL;
+ struct walker *walker;
+
+ if (!transport->data)
+ transport->data = get_http_walker(transport->url,
+ transport->remote);
+
+ walker = transport->data;
+
refs_url = xmalloc(strlen(transport->url) + 11);
sprintf(refs_url, "%s/info/refs", transport->url);
- http_init();
-
slot = get_active_slot();
slot->results = &results;
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
- if (transport->remote->http_proxy)
- curl_easy_setopt(slot->curl, CURLOPT_PROXY,
- transport->remote->http_proxy);
if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result != CURLE_OK) {
strbuf_release(&buffer);
- if (missing_target(&results)) {
- return NULL;
- } else {
- error("%s", curl_errorstr);
- return NULL;
- }
+ if (missing_target(&results))
+ die("%s not found: did you run git update-server-info on the server?", refs_url);
+ else
+ die("%s download error - %s", refs_url, curl_errorstr);
}
} else {
strbuf_release(&buffer);
- error("Unable to start request");
- return NULL;
+ die("Unable to start HTTP request");
}
- http_cleanup();
-
data = buffer.buf;
start = NULL;
mid = data;
@@ -503,14 +501,24 @@ static struct ref *get_refs_via_curl(struct transport *transport)
strbuf_release(&buffer);
+ ref = alloc_ref_from_str("HEAD");
+ if (!walker->fetch_ref(walker, ref) &&
+ !resolve_remote_symref(ref, refs)) {
+ ref->next = refs;
+ refs = ref;
+ } else {
+ free(ref);
+ }
+
return refs;
}
static int fetch_objs_via_curl(struct transport *transport,
- int nr_objs, struct ref **to_fetch)
+ int nr_objs, const struct ref **to_fetch)
{
if (!transport->data)
- transport->data = get_http_walker(transport->url);
+ transport->data = get_http_walker(transport->url,
+ transport->remote);
return fetch_objs_via_walker(transport, nr_objs, to_fetch);
}
@@ -534,9 +542,8 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
die ("Could not read bundle '%s'.", transport->url);
for (i = 0; i < data->header.references.nr; i++) {
struct ref_list_entry *e = data->header.references.list + i;
- struct ref *ref = alloc_ref(strlen(e->name) + 1);
+ struct ref *ref = alloc_ref_from_str(e->name);
hashcpy(ref->old_sha1, e->sha1);
- strcpy(ref->name, e->name);
ref->next = result;
result = ref;
}
@@ -544,7 +551,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
}
static int fetch_refs_from_bundle(struct transport *transport,
- int nr_heads, struct ref **to_fetch)
+ int nr_heads, const struct ref **to_fetch)
{
struct bundle_transport_data *data = transport->data;
return unbundle(&data->header, data->fd);
@@ -562,7 +569,10 @@ static int close_bundle(struct transport *transport)
struct git_transport_data {
unsigned thin : 1;
unsigned keep : 1;
+ unsigned followtags : 1;
int depth;
+ struct child_process *conn;
+ int fd[2];
const char *uploadpack;
const char *receivepack;
};
@@ -580,6 +590,9 @@ static int set_git_option(struct transport *connection,
} else if (!strcmp(name, TRANS_OPT_THIN)) {
data->thin = !!value;
return 0;
+ } else if (!strcmp(name, TRANS_OPT_FOLLOWTAGS)) {
+ data->followtags = !!value;
+ return 0;
} else if (!strcmp(name, TRANS_OPT_KEEP)) {
data->keep = !!value;
return 0;
@@ -593,52 +606,70 @@ static int set_git_option(struct transport *connection,
return 1;
}
+static int connect_setup(struct transport *transport)
+{
+ struct git_transport_data *data = transport->data;
+ data->conn = git_connect(data->fd, transport->url, data->uploadpack, 0);
+ return 0;
+}
+
static struct ref *get_refs_via_connect(struct transport *transport)
{
struct git_transport_data *data = transport->data;
struct ref *refs;
- int fd[2];
- char *dest = xstrdup(transport->url);
- struct child_process *conn = git_connect(fd, dest, data->uploadpack, 0);
- get_remote_heads(fd[0], &refs, 0, NULL, 0);
- packet_flush(fd[1]);
-
- finish_connect(conn);
-
- free(dest);
+ connect_setup(transport);
+ get_remote_heads(data->fd[0], &refs, 0, NULL, 0);
return refs;
}
static int fetch_refs_via_pack(struct transport *transport,
- int nr_heads, struct ref **to_fetch)
+ int nr_heads, const struct ref **to_fetch)
{
struct git_transport_data *data = transport->data;
char **heads = xmalloc(nr_heads * sizeof(*heads));
char **origh = xmalloc(nr_heads * sizeof(*origh));
- struct ref *refs;
+ const struct ref *refs;
char *dest = xstrdup(transport->url);
struct fetch_pack_args args;
int i;
+ struct ref *refs_tmp = NULL;
memset(&args, 0, sizeof(args));
args.uploadpack = data->uploadpack;
args.keep_pack = data->keep;
args.lock_pack = 1;
args.use_thin_pack = data->thin;
- args.verbose = transport->verbose > 0;
+ args.include_tag = data->followtags;
+ args.verbose = (transport->verbose > 0);
+ args.quiet = args.no_progress = (transport->verbose < 0);
+ args.no_progress = !isatty(1);
args.depth = data->depth;
for (i = 0; i < nr_heads; i++)
origh[i] = heads[i] = xstrdup(to_fetch[i]->name);
- refs = fetch_pack(&args, dest, nr_heads, heads, &transport->pack_lockfile);
+
+ if (!data->conn) {
+ connect_setup(transport);
+ get_remote_heads(data->fd[0], &refs_tmp, 0, NULL, 0);
+ }
+
+ refs = fetch_pack(&args, data->fd, data->conn,
+ refs_tmp ? refs_tmp : transport->remote_refs,
+ dest, nr_heads, heads, &transport->pack_lockfile);
+ close(data->fd[0]);
+ close(data->fd[1]);
+ if (finish_connect(data->conn))
+ refs = NULL;
+ data->conn = NULL;
+
+ free_refs(refs_tmp);
for (i = 0; i < nr_heads; i++)
free(origh[i]);
free(origh);
free(heads);
- free_refs(refs);
free(dest);
return (refs ? 0 : -1);
}
@@ -661,7 +692,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
static int disconnect_git(struct transport *transport)
{
- free(transport->data);
+ struct git_transport_data *data = transport->data;
+ if (data->conn) {
+ packet_flush(data->fd[1]);
+ close(data->fd[0]);
+ close(data->fd[1]);
+ finish_connect(data->conn);
+ }
+
+ free(data);
return 0;
}
@@ -669,7 +708,8 @@ static int is_local(const char *url)
{
const char *colon = strchr(url, ':');
const char *slash = strchr(url, '/');
- return !colon || (slash && slash < colon);
+ return !colon || (slash && slash < colon) ||
+ has_dos_drive_prefix(url);
}
static int is_file(const char *url)
@@ -721,6 +761,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
ret->disconnect = disconnect_git;
data->thin = 1;
+ data->conn = NULL;
data->uploadpack = "git-upload-pack";
if (remote && remote->uploadpack)
data->uploadpack = remote->uploadpack;
@@ -755,12 +796,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
return transport->remote_refs;
}
-int transport_fetch_refs(struct transport *transport, struct ref *refs)
+int transport_fetch_refs(struct transport *transport, const struct ref *refs)
{
int rc;
int nr_heads = 0, nr_alloc = 0;
- struct ref **heads = NULL;
- struct ref *rm;
+ const struct ref **heads = NULL;
+ const struct ref *rm;
for (rm = refs; rm; rm = rm->next) {
if (rm->peer_ref &&
diff --git a/transport.h b/transport.h
index 6fb4526cd..d0b52053f 100644
--- a/transport.h
+++ b/transport.h
@@ -19,7 +19,7 @@ struct transport {
const char *value);
struct ref *(*get_refs_list)(struct transport *transport);
- int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
+ int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs);
int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
int (*disconnect)(struct transport *connection);
@@ -53,6 +53,9 @@ struct transport *transport_get(struct remote *, const char *);
/* Limit the depth of the fetch if not null */
#define TRANS_OPT_DEPTH "depth"
+/* Aggressively fetch annotated tags if possible */
+#define TRANS_OPT_FOLLOWTAGS "followtags"
+
/**
* Returns 0 if the option was used, non-zero otherwise. Prints a
* message to stderr if the option is not used.
@@ -65,7 +68,7 @@ int transport_push(struct transport *connection,
const struct ref *transport_get_remote_refs(struct transport *transport);
-int transport_fetch_refs(struct transport *transport, struct ref *refs);
+int transport_fetch_refs(struct transport *transport, const struct ref *refs);
void transport_unlock_pack(struct transport *transport);
int transport_disconnect(struct transport *transport);
diff --git a/tree-diff.c b/tree-diff.c
index e1e2e6c6c..bbb126fc4 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -15,6 +15,15 @@ static char *malloc_base(const char *base, int baselen, const char *path, int pa
return newbase;
}
+static char *malloc_fullname(const char *base, int baselen, const char *path, int pathlen)
+{
+ char *fullname = xmalloc(baselen + pathlen + 1);
+ memcpy(fullname, base, baselen);
+ memcpy(fullname + baselen, path, pathlen);
+ fullname[baselen + pathlen] = 0;
+ return fullname;
+}
+
static void show_entry(struct diff_options *opt, const char *prefix, struct tree_desc *desc,
const char *base, int baselen);
@@ -24,6 +33,7 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const
const char *path1, *path2;
const unsigned char *sha1, *sha2;
int cmp, pathlen1, pathlen2;
+ char *fullname;
sha1 = tree_entry_extract(t1, &path1, &mode1);
sha2 = tree_entry_extract(t2, &path2, &mode2);
@@ -55,15 +65,20 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, const
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
int retval;
char *newbase = malloc_base(base, baselen, path1, pathlen1);
- if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE))
+ if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
+ newbase[baselen + pathlen1] = 0;
opt->change(opt, mode1, mode2,
- sha1, sha2, base, path1);
+ sha1, sha2, newbase);
+ newbase[baselen + pathlen1] = '/';
+ }
retval = diff_tree_sha1(sha1, sha2, newbase, opt);
free(newbase);
return retval;
}
- opt->change(opt, mode1, mode2, sha1, sha2, base, path1);
+ fullname = malloc_fullname(base, baselen, path1, pathlen1);
+ opt->change(opt, mode1, mode2, sha1, sha2, fullname);
+ free(fullname);
return 0;
}
@@ -205,10 +220,10 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
unsigned mode;
const char *path;
const unsigned char *sha1 = tree_entry_extract(desc, &path, &mode);
+ int pathlen = tree_entry_len(path, sha1);
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode)) {
enum object_type type;
- int pathlen = tree_entry_len(path, sha1);
char *newbase = malloc_base(base, baselen, path, pathlen);
struct tree_desc inner;
void *tree;
@@ -224,7 +239,9 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
free(tree);
free(newbase);
} else {
- opt->add_remove(opt, prefix[0], mode, sha1, base, path);
+ char *fullname = malloc_fullname(base, baselen, path, pathlen);
+ opt->add_remove(opt, prefix[0], mode, sha1, fullname);
+ free(fullname);
}
}
diff --git a/tree-walk.c b/tree-walk.c
index 142205ddc..02e2aed77 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -62,7 +62,7 @@ void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1)
static int entry_compare(struct name_entry *a, struct name_entry *b)
{
- return base_name_compare(
+ return df_name_compare(
a->path, tree_entry_len(a->path, a->sha1), a->mode,
b->path, tree_entry_len(b->path, b->sha1), b->mode);
}
@@ -104,12 +104,48 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
return 1;
}
-void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callback_t callback)
+void setup_traverse_info(struct traverse_info *info, const char *base)
{
+ int pathlen = strlen(base);
+ static struct traverse_info dummy;
+
+ memset(info, 0, sizeof(*info));
+ if (pathlen && base[pathlen-1] == '/')
+ pathlen--;
+ info->pathlen = pathlen ? pathlen + 1 : 0;
+ info->name.path = base;
+ info->name.sha1 = (void *)(base + pathlen + 1);
+ if (pathlen)
+ info->prev = &dummy;
+}
+
+char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)
+{
+ int len = tree_entry_len(n->path, n->sha1);
+ int pathlen = info->pathlen;
+
+ path[pathlen + len] = 0;
+ for (;;) {
+ memcpy(path + pathlen, n->path, len);
+ if (!pathlen)
+ break;
+ path[--pathlen] = '/';
+ n = &info->name;
+ len = tree_entry_len(n->path, n->sha1);
+ info = info->prev;
+ pathlen -= len;
+ }
+ return path;
+}
+
+int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
+{
+ int ret = 0;
struct name_entry *entry = xmalloc(n*sizeof(*entry));
for (;;) {
unsigned long mask = 0;
+ unsigned long dirmask = 0;
int i, last;
last = -1;
@@ -134,25 +170,35 @@ void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callb
mask = 0;
}
mask |= 1ul << i;
+ if (S_ISDIR(entry[i].mode))
+ dirmask |= 1ul << i;
last = i;
}
if (!mask)
break;
+ dirmask &= mask;
/*
- * Update the tree entries we've walked, and clear
- * all the unused name-entries.
+ * Clear all the unused name-entries.
*/
for (i = 0; i < n; i++) {
- if (mask & (1ul << i)) {
- update_tree_entry(t+i);
+ if (mask & (1ul << i))
continue;
- }
entry_clear(entry + i);
}
- callback(n, mask, entry, base);
+ ret = info->fn(n, mask, dirmask, entry, info);
+ if (ret < 0)
+ break;
+ if (ret)
+ mask &= ret;
+ ret = 0;
+ for (i = 0; i < n; i++) {
+ if (mask & (1ul << i))
+ update_tree_entry(t + i);
+ }
}
free(entry);
+ return ret;
}
static int find_tree_entry(struct tree_desc *t, const char *name, unsigned char *result, unsigned *mode)
diff --git a/tree-walk.h b/tree-walk.h
index db0fbdc70..42110a465 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -33,10 +33,27 @@ int tree_entry(struct tree_desc *, struct name_entry *);
void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1);
-typedef void (*traverse_callback_t)(int n, unsigned long mask, struct name_entry *entry, const char *base);
-
-void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callback_t callback);
+struct traverse_info;
+typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
+int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info);
+
+struct traverse_info {
+ struct traverse_info *prev;
+ struct name_entry name;
+ int pathlen;
+
+ unsigned long conflicts;
+ traverse_callback_t fn;
+ void *data;
+};
int get_tree_entry(const unsigned char *, const char *, unsigned char *, unsigned *);
+extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);
+extern void setup_traverse_info(struct traverse_info *info, const char *base);
+
+static inline int traverse_path_len(const struct traverse_info *info, const struct name_entry *n)
+{
+ return info->pathlen + tree_entry_len(n->path, n->sha1);
+}
#endif
diff --git a/tree.c b/tree.c
index 87708ef42..03e782a9c 100644
--- a/tree.c
+++ b/tree.c
@@ -29,7 +29,7 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b
return add_cache_entry(ce, opt);
}
-static int read_one_entry(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
+static int read_one_entry(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *context)
{
return read_one_entry_opt(sha1, base, baselen, pathname, mode, stage,
ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
@@ -39,7 +39,7 @@ static int read_one_entry(const unsigned char *sha1, const char *base, int basel
* This is used when the caller knows there is no existing entries at
* the stage that will conflict with the entry being added.
*/
-static int read_one_entry_quick(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
+static int read_one_entry_quick(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *context)
{
return read_one_entry_opt(sha1, base, baselen, pathname, mode, stage,
ADD_CACHE_JUST_APPEND);
@@ -92,7 +92,7 @@ static int match_tree_entry(const char *base, int baselen, const char *path, uns
int read_tree_recursive(struct tree *tree,
const char *base, int baselen,
int stage, const char **match,
- read_tree_fn_t fn)
+ read_tree_fn_t fn, void *context)
{
struct tree_desc desc;
struct name_entry entry;
@@ -106,7 +106,7 @@ int read_tree_recursive(struct tree *tree,
if (!match_tree_entry(base, baselen, entry.path, entry.mode, match))
continue;
- switch (fn(entry.sha1, base, baselen, entry.path, entry.mode, stage)) {
+ switch (fn(entry.sha1, base, baselen, entry.path, entry.mode, stage, context)) {
case 0:
continue;
case READ_TREE_RECURSIVE:
@@ -126,7 +126,7 @@ int read_tree_recursive(struct tree *tree,
retval = read_tree_recursive(lookup_tree(entry.sha1),
newbase,
baselen + pathlen + 1,
- stage, match, fn);
+ stage, match, fn, context);
free(newbase);
if (retval)
return -1;
@@ -174,7 +174,7 @@ int read_tree(struct tree *tree, int stage, const char **match)
if (!fn)
fn = read_one_entry_quick;
- err = read_tree_recursive(tree, "", 0, stage, match, fn);
+ err = read_tree_recursive(tree, "", 0, stage, match, fn, NULL);
if (fn == read_one_entry || err)
return err;
@@ -202,52 +202,6 @@ struct tree *lookup_tree(const unsigned char *sha1)
return (struct tree *) obj;
}
-/*
- * NOTE! Tree refs to external git repositories
- * (ie gitlinks) do not count as real references.
- *
- * You don't have to have those repositories
- * available at all, much less have the objects
- * accessible from the current repository.
- */
-static void track_tree_refs(struct tree *item)
-{
- int n_refs = 0, i;
- struct object_refs *refs;
- struct tree_desc desc;
- struct name_entry entry;
-
- /* Count how many entries there are.. */
- init_tree_desc(&desc, item->buffer, item->size);
- while (tree_entry(&desc, &entry)) {
- if (S_ISGITLINK(entry.mode))
- continue;
- n_refs++;
- }
-
- /* Allocate object refs and walk it again.. */
- i = 0;
- refs = alloc_object_refs(n_refs);
- init_tree_desc(&desc, item->buffer, item->size);
- while (tree_entry(&desc, &entry)) {
- struct object *obj;
-
- if (S_ISGITLINK(entry.mode))
- continue;
- if (S_ISDIR(entry.mode))
- obj = &lookup_tree(entry.sha1)->object;
- else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode))
- obj = &lookup_blob(entry.sha1)->object;
- else {
- warning("in tree %s: entry %s has bad mode %.6o\n",
- sha1_to_hex(item->object.sha1), entry.path, entry.mode);
- obj = lookup_unknown_object(entry.sha1);
- }
- refs->ref[i++] = obj;
- }
- set_object_refs(&item->object, refs);
-}
-
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
{
if (item->object.parsed)
@@ -256,8 +210,6 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
item->buffer = buffer;
item->size = size;
- if (track_object_refs)
- track_tree_refs(item);
return 0;
}
diff --git a/tree.h b/tree.h
index dd25c539e..2ff01a4f8 100644
--- a/tree.h
+++ b/tree.h
@@ -21,12 +21,12 @@ int parse_tree(struct tree *tree);
struct tree *parse_tree_indirect(const unsigned char *sha1);
#define READ_TREE_RECURSIVE 1
-typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int);
+typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const char *, unsigned int, int, void *);
extern int read_tree_recursive(struct tree *tree,
const char *base, int baselen,
int stage, const char **match,
- read_tree_fn_t fn);
+ read_tree_fn_t fn, void *context);
extern int read_tree(struct tree *tree, int stage, const char **paths);
diff --git a/unpack-file.c b/unpack-file.c
index 65c66eb0b..bcdc8bbb3 100644
--- a/unpack-file.c
+++ b/unpack-file.c
@@ -31,7 +31,7 @@ int main(int argc, char **argv)
die("Not a valid object name %s", argv[1]);
setup_git_directory();
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
puts(create_temp_file(sha1));
return 0;
diff --git a/unpack-trees.c b/unpack-trees.c
index 470fa02e0..cba0aca06 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,3 +1,4 @@
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "dir.h"
#include "tree.h"
@@ -7,279 +8,60 @@
#include "progress.h"
#include "refs.h"
-#define DBRT_DEBUG 1
-
-struct tree_entry_list {
- struct tree_entry_list *next;
- unsigned int mode;
- const char *name;
- const unsigned char *sha1;
-};
+/*
+ * Error messages expected by scripts out of plumbing commands such as
+ * read-tree. Non-scripted Porcelain is not required to use these messages
+ * and in fact are encouraged to reword them to better suit their particular
+ * situation better. See how "git checkout" replaces not_uptodate_file to
+ * explain why it does not allow switching between branches when you have
+ * local changes, for example.
+ */
+static struct unpack_trees_error_msgs unpack_plumbing_errors = {
+ /* would_overwrite */
+ "Entry '%s' would be overwritten by merge. Cannot merge.",
-static struct tree_entry_list *create_tree_entry_list(struct tree_desc *desc)
-{
- struct name_entry one;
- struct tree_entry_list *ret = NULL;
- struct tree_entry_list **list_p = &ret;
+ /* not_uptodate_file */
+ "Entry '%s' not uptodate. Cannot merge.",
- while (tree_entry(desc, &one)) {
- struct tree_entry_list *entry;
+ /* not_uptodate_dir */
+ "Updating '%s' would lose untracked files in it",
- entry = xmalloc(sizeof(struct tree_entry_list));
- entry->name = one.path;
- entry->sha1 = one.sha1;
- entry->mode = one.mode;
- entry->next = NULL;
+ /* would_lose_untracked */
+ "Untracked working tree file '%s' would be %s by merge.",
- *list_p = entry;
- list_p = &entry->next;
- }
- return ret;
-}
-
-static int entcmp(const char *name1, int dir1, const char *name2, int dir2)
-{
- int len1 = strlen(name1);
- int len2 = strlen(name2);
- int len = len1 < len2 ? len1 : len2;
- int ret = memcmp(name1, name2, len);
- unsigned char c1, c2;
- if (ret)
- return ret;
- c1 = name1[len];
- c2 = name2[len];
- if (!c1 && dir1)
- c1 = '/';
- if (!c2 && dir2)
- c2 = '/';
- ret = (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
- if (c1 && c2 && !ret)
- ret = len1 - len2;
- return ret;
-}
+ /* bind_overlap */
+ "Entry '%s' overlaps with '%s'. Cannot bind.",
+};
-static inline void remove_entry(int remove)
-{
- if (remove >= 0)
- remove_cache_entry_at(remove);
-}
+#define ERRORMSG(o,fld) \
+ ( ((o) && (o)->msgs.fld) \
+ ? ((o)->msgs.fld) \
+ : (unpack_plumbing_errors.fld) )
-static int unpack_trees_rec(struct tree_entry_list **posns, int len,
- const char *base, struct unpack_trees_options *o,
- struct tree_entry_list *df_conflict_list)
+static void add_entry(struct unpack_trees_options *o, struct cache_entry *ce,
+ unsigned int set, unsigned int clear)
{
- int remove;
- int baselen = strlen(base);
- int src_size = len + 1;
- int retval = 0;
-
- do {
- int i;
- const char *first;
- int firstdir = 0;
- int pathlen;
- unsigned ce_size;
- struct tree_entry_list **subposns;
- struct cache_entry **src;
- int any_files = 0;
- int any_dirs = 0;
- char *cache_name;
- int ce_stage;
- int skip_entry = 0;
-
- /* Find the first name in the input. */
-
- first = NULL;
- cache_name = NULL;
-
- /* Check the cache */
- if (o->merge && o->pos < active_nr) {
- /* This is a bit tricky: */
- /* If the index has a subdirectory (with
- * contents) as the first name, it'll get a
- * filename like "foo/bar". But that's after
- * "foo", so the entry in trees will get
- * handled first, at which point we'll go into
- * "foo", and deal with "bar" from the index,
- * because the base will be "foo/". The only
- * way we can actually have "foo/bar" first of
- * all the things is if the trees don't
- * contain "foo" at all, in which case we'll
- * handle "foo/bar" without going into the
- * directory, but that's fine (and will return
- * an error anyway, with the added unknown
- * file case.
- */
-
- cache_name = active_cache[o->pos]->name;
- if (strlen(cache_name) > baselen &&
- !memcmp(cache_name, base, baselen)) {
- cache_name += baselen;
- first = cache_name;
- } else {
- cache_name = NULL;
- }
- }
-
-#if DBRT_DEBUG > 1
- if (first)
- fprintf(stderr, "index %s\n", first);
-#endif
- for (i = 0; i < len; i++) {
- if (!posns[i] || posns[i] == df_conflict_list)
- continue;
-#if DBRT_DEBUG > 1
- fprintf(stderr, "%d %s\n", i + 1, posns[i]->name);
-#endif
- if (!first || entcmp(first, firstdir,
- posns[i]->name,
- S_ISDIR(posns[i]->mode)) > 0) {
- first = posns[i]->name;
- firstdir = S_ISDIR(posns[i]->mode);
- }
- }
- /* No name means we're done */
- if (!first)
- goto leave_directory;
-
- pathlen = strlen(first);
- ce_size = cache_entry_size(baselen + pathlen);
-
- src = xcalloc(src_size, sizeof(struct cache_entry *));
-
- subposns = xcalloc(len, sizeof(struct tree_list_entry *));
-
- remove = -1;
- if (cache_name && !strcmp(cache_name, first)) {
- any_files = 1;
- src[0] = active_cache[o->pos];
- remove = o->pos;
- if (o->skip_unmerged && ce_stage(src[0]))
- skip_entry = 1;
- }
-
- for (i = 0; i < len; i++) {
- struct cache_entry *ce;
-
- if (!posns[i] ||
- (posns[i] != df_conflict_list &&
- strcmp(first, posns[i]->name))) {
- continue;
- }
-
- if (posns[i] == df_conflict_list) {
- src[i + o->merge] = o->df_conflict_entry;
- continue;
- }
-
- if (S_ISDIR(posns[i]->mode)) {
- struct tree *tree = lookup_tree(posns[i]->sha1);
- struct tree_desc t;
- any_dirs = 1;
- parse_tree(tree);
- init_tree_desc(&t, tree->buffer, tree->size);
- subposns[i] = create_tree_entry_list(&t);
- posns[i] = posns[i]->next;
- src[i + o->merge] = o->df_conflict_entry;
- continue;
- }
-
- if (skip_entry) {
- subposns[i] = df_conflict_list;
- posns[i] = posns[i]->next;
- continue;
- }
-
- if (!o->merge)
- ce_stage = 0;
- else if (i + 1 < o->head_idx)
- ce_stage = 1;
- else if (i + 1 > o->head_idx)
- ce_stage = 3;
- else
- ce_stage = 2;
-
- ce = xcalloc(1, ce_size);
- ce->ce_mode = create_ce_mode(posns[i]->mode);
- ce->ce_flags = create_ce_flags(baselen + pathlen,
- ce_stage);
- memcpy(ce->name, base, baselen);
- memcpy(ce->name + baselen, first, pathlen + 1);
-
- any_files = 1;
-
- hashcpy(ce->sha1, posns[i]->sha1);
- src[i + o->merge] = ce;
- subposns[i] = df_conflict_list;
- posns[i] = posns[i]->next;
- }
- if (any_files) {
- if (skip_entry) {
- o->pos++;
- while (o->pos < active_nr &&
- !strcmp(active_cache[o->pos]->name,
- src[0]->name))
- o->pos++;
- } else if (o->merge) {
- int ret;
-
-#if DBRT_DEBUG > 1
- fprintf(stderr, "%s:\n", first);
- for (i = 0; i < src_size; i++) {
- fprintf(stderr, " %d ", i);
- if (src[i])
- fprintf(stderr, "%06x %s\n", src[i]->ce_mode, sha1_to_hex(src[i]->sha1));
- else
- fprintf(stderr, "\n");
- }
-#endif
- ret = o->fn(src, o, remove);
- if (ret < 0)
- return ret;
+ unsigned int size = ce_size(ce);
+ struct cache_entry *new = xmalloc(size);
-#if DBRT_DEBUG > 1
- fprintf(stderr, "Added %d entries\n", ret);
-#endif
- o->pos += ret;
- } else {
- remove_entry(remove);
- for (i = 0; i < src_size; i++) {
- if (src[i]) {
- add_cache_entry(src[i], ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
- }
- }
- }
- }
- if (any_dirs) {
- char *newbase = xmalloc(baselen + 2 + pathlen);
- memcpy(newbase, base, baselen);
- memcpy(newbase + baselen, first, pathlen);
- newbase[baselen + pathlen] = '/';
- newbase[baselen + pathlen + 1] = '\0';
- if (unpack_trees_rec(subposns, len, newbase, o,
- df_conflict_list)) {
- retval = -1;
- goto leave_directory;
- }
- free(newbase);
- }
- free(subposns);
- free(src);
- } while (1);
+ clear |= CE_HASHED | CE_UNHASHED;
- leave_directory:
- return retval;
+ memcpy(new, ce, size);
+ new->next = NULL;
+ new->ce_flags = (new->ce_flags & ~clear) | set;
+ add_index_entry(&o->result, new, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE|ADD_CACHE_SKIP_DFCHECK);
}
/* Unlink the last component and attempt to remove leading
* directories, in case this unlink is the removal of the
* last entry in the directory -- empty directories are removed.
*/
-static void unlink_entry(char *name, char *last_symlink)
+static void unlink_entry(struct cache_entry *ce)
{
char *cp, *prev;
+ char *name = ce->name;
- if (has_symlink_leading_path(name, last_symlink))
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
return;
if (unlink(name))
return;
@@ -303,64 +85,299 @@ static void unlink_entry(char *name, char *last_symlink)
}
static struct checkout state;
-static void check_updates(struct unpack_trees_options *o)
+static int check_updates(struct unpack_trees_options *o)
{
unsigned cnt = 0, total = 0;
struct progress *progress = NULL;
- char last_symlink[PATH_MAX];
+ struct index_state *index = &o->result;
int i;
+ int errs = 0;
if (o->update && o->verbose_update) {
- for (total = cnt = 0; cnt < active_nr; cnt++) {
- struct cache_entry *ce = active_cache[cnt];
+ for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
+ struct cache_entry *ce = index->cache[cnt];
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
total++;
}
progress = start_progress_delay("Checking out files",
- total, 50, 2);
+ total, 50, 1);
cnt = 0;
}
- *last_symlink = '\0';
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
+ for (i = 0; i < index->cache_nr; i++) {
+ struct cache_entry *ce = index->cache[i];
- if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
- display_progress(progress, ++cnt);
if (ce->ce_flags & CE_REMOVE) {
+ display_progress(progress, ++cnt);
if (o->update)
- unlink_entry(ce->name, last_symlink);
- remove_cache_entry_at(i);
+ unlink_entry(ce);
+ remove_index_entry_at(&o->result, i);
i--;
continue;
}
+ }
+
+ for (i = 0; i < index->cache_nr; i++) {
+ struct cache_entry *ce = index->cache[i];
+
if (ce->ce_flags & CE_UPDATE) {
+ display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
if (o->update) {
- checkout_entry(ce, &state, NULL);
- *last_symlink = '\0';
+ errs |= checkout_entry(ce, &state, NULL);
}
}
}
stop_progress(&progress);
+ return errs != 0;
}
-int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
+static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_options *o)
+{
+ int ret = o->fn(src, o);
+ if (ret > 0)
+ ret = 0;
+ return ret;
+}
+
+static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o)
+{
+ struct cache_entry *src[5] = { ce, };
+
+ o->pos++;
+ if (ce_stage(ce)) {
+ if (o->skip_unmerged) {
+ add_entry(o, ce, 0, 0);
+ return 0;
+ }
+ }
+ return call_unpack_fn(src, o);
+}
+
+int traverse_trees_recursive(int n, unsigned long dirmask, unsigned long df_conflicts, struct name_entry *names, struct traverse_info *info)
+{
+ int i;
+ struct tree_desc t[MAX_UNPACK_TREES];
+ struct traverse_info newinfo;
+ struct name_entry *p;
+
+ p = names;
+ while (!p->mode)
+ p++;
+
+ newinfo = *info;
+ newinfo.prev = info;
+ newinfo.name = *p;
+ newinfo.pathlen += tree_entry_len(p->path, p->sha1) + 1;
+ newinfo.conflicts |= df_conflicts;
+
+ for (i = 0; i < n; i++, dirmask >>= 1) {
+ const unsigned char *sha1 = NULL;
+ if (dirmask & 1)
+ sha1 = names[i].sha1;
+ fill_tree_descriptor(t+i, sha1);
+ }
+ return traverse_trees(n, t, &newinfo);
+}
+
+/*
+ * Compare the traverse-path to the cache entry without actually
+ * having to generate the textual representation of the traverse
+ * path.
+ *
+ * NOTE! This *only* compares up to the size of the traverse path
+ * itself - the caller needs to do the final check for the cache
+ * entry having more data at the end!
+ */
+static int do_compare_entry(const struct cache_entry *ce, const struct traverse_info *info, const struct name_entry *n)
+{
+ int len, pathlen, ce_len;
+ const char *ce_name;
+
+ if (info->prev) {
+ int cmp = do_compare_entry(ce, info->prev, &info->name);
+ if (cmp)
+ return cmp;
+ }
+ pathlen = info->pathlen;
+ ce_len = ce_namelen(ce);
+
+ /* If ce_len < pathlen then we must have previously hit "name == directory" entry */
+ if (ce_len < pathlen)
+ return -1;
+
+ ce_len -= pathlen;
+ ce_name = ce->name + pathlen;
+
+ len = tree_entry_len(n->path, n->sha1);
+ return df_name_compare(ce_name, ce_len, S_IFREG, n->path, len, n->mode);
+}
+
+static int compare_entry(const struct cache_entry *ce, const struct traverse_info *info, const struct name_entry *n)
+{
+ int cmp = do_compare_entry(ce, info, n);
+ if (cmp)
+ return cmp;
+
+ /*
+ * Even if the beginning compared identically, the ce should
+ * compare as bigger than a directory leading up to it!
+ */
+ return ce_namelen(ce) > traverse_path_len(info, n);
+}
+
+static struct cache_entry *create_ce_entry(const struct traverse_info *info, const struct name_entry *n, int stage)
+{
+ int len = traverse_path_len(info, n);
+ struct cache_entry *ce = xcalloc(1, cache_entry_size(len));
+
+ ce->ce_mode = create_ce_mode(n->mode);
+ ce->ce_flags = create_ce_flags(len, stage);
+ hashcpy(ce->sha1, n->sha1);
+ make_traverse_path(ce->name, info, n);
+
+ return ce;
+}
+
+static int unpack_nondirectories(int n, unsigned long mask, unsigned long dirmask, struct cache_entry *src[5],
+ const struct name_entry *names, const struct traverse_info *info)
{
- struct tree_entry_list **posns;
int i;
- struct tree_entry_list df_conflict_list;
+ struct unpack_trees_options *o = info->data;
+ unsigned long conflicts;
+
+ /* Do we have *only* directories? Nothing to do */
+ if (mask == dirmask && !src[0])
+ return 0;
+
+ conflicts = info->conflicts;
+ if (o->merge)
+ conflicts >>= 1;
+ conflicts |= dirmask;
+
+ /*
+ * Ok, we've filled in up to any potential index entry in src[0],
+ * now do the rest.
+ */
+ for (i = 0; i < n; i++) {
+ int stage;
+ unsigned int bit = 1ul << i;
+ if (conflicts & bit) {
+ src[i + o->merge] = o->df_conflict_entry;
+ continue;
+ }
+ if (!(mask & bit))
+ continue;
+ if (!o->merge)
+ stage = 0;
+ else if (i + 1 < o->head_idx)
+ stage = 1;
+ else if (i + 1 > o->head_idx)
+ stage = 3;
+ else
+ stage = 2;
+ src[i + o->merge] = create_ce_entry(info, names + i, stage);
+ }
+
+ if (o->merge)
+ return call_unpack_fn(src, o);
+
+ n += o->merge;
+ for (i = 0; i < n; i++)
+ add_entry(o, src[i], 0, 0);
+ return 0;
+}
+
+static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
+{
+ struct cache_entry *src[5] = { NULL, };
+ struct unpack_trees_options *o = info->data;
+ const struct name_entry *p = names;
+
+ /* Find first entry with a real name (we could use "mask" too) */
+ while (!p->mode)
+ p++;
+
+ /* Are we supposed to look at the index too? */
+ if (o->merge) {
+ while (o->pos < o->src_index->cache_nr) {
+ struct cache_entry *ce = o->src_index->cache[o->pos];
+ int cmp = compare_entry(ce, info, p);
+ if (cmp < 0) {
+ if (unpack_index_entry(ce, o) < 0)
+ return -1;
+ continue;
+ }
+ if (!cmp) {
+ o->pos++;
+ if (ce_stage(ce)) {
+ /*
+ * If we skip unmerged index entries, we'll skip this
+ * entry *and* the tree entries associated with it!
+ */
+ if (o->skip_unmerged) {
+ add_entry(o, ce, 0, 0);
+ return mask;
+ }
+ }
+ src[0] = ce;
+ }
+ break;
+ }
+ }
+
+ if (unpack_nondirectories(n, mask, dirmask, src, names, info) < 0)
+ return -1;
+
+ /* Now handle any directories.. */
+ if (dirmask) {
+ unsigned long conflicts = mask & ~dirmask;
+ if (o->merge) {
+ conflicts <<= 1;
+ if (src[0])
+ conflicts |= 1;
+ }
+ if (traverse_trees_recursive(n, dirmask, conflicts,
+ names, info) < 0)
+ return -1;
+ return mask;
+ }
+
+ return mask;
+}
+
+static int unpack_failed(struct unpack_trees_options *o, const char *message)
+{
+ discard_index(&o->result);
+ if (!o->gently) {
+ if (message)
+ return error(message);
+ return -1;
+ }
+ return -1;
+}
+
+/*
+ * N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the
+ * resulting index, -2 on failure to reflect the changes to the work tree.
+ */
+int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
+{
+ int ret;
static struct cache_entry *dfc;
- memset(&df_conflict_list, 0, sizeof(df_conflict_list));
- df_conflict_list.next = &df_conflict_list;
+ if (len > MAX_UNPACK_TREES)
+ die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
memset(&state, 0, sizeof(state));
state.base_dir = "";
state.force = 1;
state.quiet = 1;
state.refresh_cache = 1;
+ memset(&o->result, 0, sizeof(o->result));
+ if (o->src_index)
+ o->result.timestamp = o->src_index->timestamp;
o->merge_size = len;
if (!dfc)
@@ -368,39 +385,41 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
o->df_conflict_entry = dfc;
if (len) {
- posns = xmalloc(len * sizeof(struct tree_entry_list *));
- for (i = 0; i < len; i++)
- posns[i] = create_tree_entry_list(t+i);
-
- if (unpack_trees_rec(posns, len, o->prefix ? o->prefix : "",
- o, &df_conflict_list)) {
- if (o->gently) {
- discard_cache();
- read_cache();
- }
- return -1;
- }
+ const char *prefix = o->prefix ? o->prefix : "";
+ struct traverse_info info;
+
+ setup_traverse_info(&info, prefix);
+ info.fn = unpack_callback;
+ info.data = o;
+
+ if (traverse_trees(len, t, &info) < 0)
+ return unpack_failed(o, NULL);
}
- if (o->trivial_merges_only && o->nontrivial_merge) {
- if (o->gently) {
- discard_cache();
- read_cache();
+ /* Any left-over entries in the index? */
+ if (o->merge) {
+ while (o->pos < o->src_index->cache_nr) {
+ struct cache_entry *ce = o->src_index->cache[o->pos];
+ if (unpack_index_entry(ce, o) < 0)
+ return unpack_failed(o, NULL);
}
- return o->gently ? -1 :
- error("Merge requires file-level merging");
}
- check_updates(o);
- return 0;
+ if (o->trivial_merges_only && o->nontrivial_merge)
+ return unpack_failed(o, "Merge requires file-level merging");
+
+ o->src_index = NULL;
+ ret = check_updates(o) ? (-2) : 0;
+ if (o->dst_index)
+ *o->dst_index = o->result;
+ return ret;
}
/* Here come the merge functions */
-static int reject_merge(struct cache_entry *ce)
+static int reject_merge(struct cache_entry *ce, struct unpack_trees_options *o)
{
- return error("Entry '%s' would be overwritten by merge. Cannot merge.",
- ce->name);
+ return error(ERRORMSG(o, would_overwrite), ce->name);
}
static int same(struct cache_entry *a, struct cache_entry *b)
@@ -427,7 +446,7 @@ static int verify_uptodate(struct cache_entry *ce,
return 0;
if (!lstat(ce->name, &st)) {
- unsigned changed = ce_match_stat(ce, &st, CE_MATCH_IGNORE_VALID);
+ unsigned changed = ie_match_stat(o->src_index, ce, &st, CE_MATCH_IGNORE_VALID);
if (!changed)
return 0;
/*
@@ -444,13 +463,13 @@ static int verify_uptodate(struct cache_entry *ce,
if (errno == ENOENT)
return 0;
return o->gently ? -1 :
- error("Entry '%s' not uptodate. Cannot merge.", ce->name);
+ error(ERRORMSG(o, not_uptodate_file), ce->name);
}
-static void invalidate_ce_path(struct cache_entry *ce)
+static void invalidate_ce_path(struct cache_entry *ce, struct unpack_trees_options *o)
{
if (ce)
- cache_tree_invalidate_path(active_cache_tree, ce->name);
+ cache_tree_invalidate_path(o->src_index->cache_tree, ce->name);
}
/*
@@ -495,12 +514,12 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
* in that directory.
*/
namelen = strlen(ce->name);
- pos = cache_name_pos(ce->name, namelen);
+ pos = index_name_pos(o->src_index, ce->name, namelen);
if (0 <= pos)
return cnt; /* we have it as nondirectory */
pos = -pos - 1;
- for (i = pos; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
+ for (i = pos; i < o->src_index->cache_nr; i++) {
+ struct cache_entry *ce = o->src_index->cache[i];
int len = ce_namelen(ce);
if (len < namelen ||
strncmp(ce->name, ce->name, namelen) ||
@@ -512,7 +531,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
if (!ce_stage(ce)) {
if (verify_uptodate(ce, o))
return -1;
- ce->ce_flags |= CE_REMOVE;
+ add_entry(o, ce, CE_REMOVE, 0);
}
cnt++;
}
@@ -531,13 +550,28 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action,
i = read_directory(&d, ce->name, pathbuf, namelen+1, NULL);
if (i)
return o->gently ? -1 :
- error("Updating '%s' would lose untracked files in it",
- ce->name);
+ error(ERRORMSG(o, not_uptodate_dir), ce->name);
free(pathbuf);
return cnt;
}
/*
+ * This gets called when there was no index entry for the tree entry 'dst',
+ * but we found a file in the working tree that 'lstat()' said was fine,
+ * and we're on a case-insensitive filesystem.
+ *
+ * See if we can find a case-insensitive match in the index that also
+ * matches the stat information, and assume it's that other file!
+ */
+static int icase_exists(struct unpack_trees_options *o, struct cache_entry *dst, struct stat *st)
+{
+ struct cache_entry *src;
+
+ src = index_name_exists(o->src_index, dst->name, ce_namelen(dst), 1);
+ return src && !ie_match_stat(o->src_index, src, st, CE_MATCH_IGNORE_VALID);
+}
+
+/*
* We do not want to remove or overwrite a working tree file that
* is not tracked, unless it is ignored.
*/
@@ -549,13 +583,25 @@ static int verify_absent(struct cache_entry *ce, const char *action,
if (o->index_only || o->reset || !o->update)
return 0;
- if (has_symlink_leading_path(ce->name, NULL))
+ if (has_symlink_leading_path(ce_namelen(ce), ce->name))
return 0;
if (!lstat(ce->name, &st)) {
int cnt;
+ int dtype = ce_to_dtype(ce);
+ struct cache_entry *result;
- if (o->dir && excluded(o->dir, ce->name))
+ /*
+ * It may be that the 'lstat()' succeeded even though
+ * target 'ce' was absent, because there is an old
+ * entry that is different only in case..
+ *
+ * Ignore that lstat() if it matches.
+ */
+ if (ignore_case && icase_exists(o, ce, &st))
+ return 0;
+
+ if (o->dir && excluded(o->dir, ce->name, &dtype))
/*
* ce->name is explicitly excluded, so it is Ok to
* overwrite it.
@@ -597,16 +643,14 @@ static int verify_absent(struct cache_entry *ce, const char *action,
* delete this path, which is in a subdirectory that
* is being replaced with a blob.
*/
- cnt = cache_name_pos(ce->name, strlen(ce->name));
- if (0 <= cnt) {
- struct cache_entry *ce = active_cache[cnt];
- if (ce->ce_flags & CE_REMOVE)
+ result = index_name_exists(&o->result, ce->name, ce_namelen(ce), 0);
+ if (result) {
+ if (result->ce_flags & CE_REMOVE)
return 0;
}
return o->gently ? -1 :
- error("Untracked working tree file '%s' "
- "would be %s by merge.", ce->name, action);
+ error(ERRORMSG(o, would_lose_untracked), ce->name, action);
}
return 0;
}
@@ -614,52 +658,54 @@ static int verify_absent(struct cache_entry *ce, const char *action,
static int merged_entry(struct cache_entry *merge, struct cache_entry *old,
struct unpack_trees_options *o)
{
- merge->ce_flags |= CE_UPDATE;
+ int update = CE_UPDATE;
+
if (old) {
/*
* See if we can re-use the old CE directly?
* That way we get the uptodate stat info.
*
- * This also removes the UPDATE flag on
- * a match.
+ * This also removes the UPDATE flag on a match; otherwise
+ * we will end up overwriting local changes in the work tree.
*/
if (same(old, merge)) {
- memcpy(merge, old, offsetof(struct cache_entry, name));
+ copy_cache_entry(merge, old);
+ update = 0;
} else {
if (verify_uptodate(old, o))
return -1;
- invalidate_ce_path(old);
+ invalidate_ce_path(old, o);
}
}
else {
if (verify_absent(merge, "overwritten", o))
return -1;
- invalidate_ce_path(merge);
+ invalidate_ce_path(merge, o);
}
- merge->ce_flags &= ~CE_STAGEMASK;
- add_cache_entry(merge, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
+ add_entry(o, merge, update, CE_STAGEMASK);
return 1;
}
static int deleted_entry(struct cache_entry *ce, struct cache_entry *old,
struct unpack_trees_options *o)
{
- if (old) {
- if (verify_uptodate(old, o))
- return -1;
- } else
+ /* Did it exist in the index? */
+ if (!old) {
if (verify_absent(ce, "removed", o))
return -1;
- ce->ce_flags |= CE_REMOVE;
- add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
- invalidate_ce_path(ce);
+ return 0;
+ }
+ if (verify_uptodate(old, o))
+ return -1;
+ add_entry(o, ce, CE_REMOVE, 0);
+ invalidate_ce_path(ce, o);
return 1;
}
static int keep_entry(struct cache_entry *ce, struct unpack_trees_options *o)
{
- add_cache_entry(ce, ADD_CACHE_OK_TO_ADD);
+ add_entry(o, ce, 0, 0);
return 1;
}
@@ -679,9 +725,7 @@ static void show_stage_entry(FILE *o,
}
#endif
-int threeway_merge(struct cache_entry **stages,
- struct unpack_trees_options *o,
- int remove)
+int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
{
struct cache_entry *index;
struct cache_entry *head;
@@ -738,7 +782,7 @@ int threeway_merge(struct cache_entry **stages,
/* #14, #14ALT, #2ALT */
if (remote && !df_conflict_head && head_match && !remote_match) {
if (index && !same(index, remote) && !same(index, head))
- return o->gently ? -1 : reject_merge(index);
+ return o->gently ? -1 : reject_merge(index, o);
return merged_entry(remote, index, o);
}
/*
@@ -746,7 +790,7 @@ int threeway_merge(struct cache_entry **stages,
* make sure that it matches head.
*/
if (index && !same(index, head))
- return o->gently ? -1 : reject_merge(index);
+ return o->gently ? -1 : reject_merge(index, o);
if (head) {
/* #5ALT, #15 */
@@ -758,10 +802,8 @@ int threeway_merge(struct cache_entry **stages,
}
/* #1 */
- if (!head && !remote && any_anc_missing) {
- remove_entry(remove);
+ if (!head && !remote && any_anc_missing)
return 0;
- }
/* Under the new "aggressive" rule, we resolve mostly trivial
* cases that we historically had git-merge-one-file resolve.
@@ -793,10 +835,9 @@ int threeway_merge(struct cache_entry **stages,
if ((head_deleted && remote_deleted) ||
(head_deleted && remote && remote_match) ||
(remote_deleted && head && head_match)) {
- remove_entry(remove);
if (index)
return deleted_entry(index, index, o);
- else if (ce && !head_deleted) {
+ if (ce && !head_deleted) {
if (verify_absent(ce, "removed", o))
return -1;
}
@@ -819,7 +860,6 @@ int threeway_merge(struct cache_entry **stages,
return -1;
}
- remove_entry(remove);
o->nontrivial_merge = 1;
/* #2, #3, #4, #6, #7, #9, #10, #11. */
@@ -854,9 +894,7 @@ int threeway_merge(struct cache_entry **stages,
* "carry forward" rule, please see <Documentation/git-read-tree.txt>.
*
*/
-int twoway_merge(struct cache_entry **src,
- struct unpack_trees_options *o,
- int remove)
+int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o)
{
struct cache_entry *current = src[0];
struct cache_entry *oldtree = src[1];
@@ -884,7 +922,6 @@ int twoway_merge(struct cache_entry **src,
}
else if (oldtree && !newtree && same(current, oldtree)) {
/* 10 or 11 */
- remove_entry(remove);
return deleted_entry(oldtree, current, o);
}
else if (oldtree && newtree &&
@@ -894,19 +931,17 @@ int twoway_merge(struct cache_entry **src,
}
else {
/* all other failures */
- remove_entry(remove);
if (oldtree)
- return o->gently ? -1 : reject_merge(oldtree);
+ return o->gently ? -1 : reject_merge(oldtree, o);
if (current)
- return o->gently ? -1 : reject_merge(current);
+ return o->gently ? -1 : reject_merge(current, o);
if (newtree)
- return o->gently ? -1 : reject_merge(newtree);
+ return o->gently ? -1 : reject_merge(newtree, o);
return -1;
}
}
else if (newtree)
return merged_entry(newtree, current, o);
- remove_entry(remove);
return deleted_entry(oldtree, current, o);
}
@@ -917,8 +952,7 @@ int twoway_merge(struct cache_entry **src,
* stage0 does not have anything there.
*/
int bind_merge(struct cache_entry **src,
- struct unpack_trees_options *o,
- int remove)
+ struct unpack_trees_options *o)
{
struct cache_entry *old = src[0];
struct cache_entry *a = src[1];
@@ -928,7 +962,7 @@ int bind_merge(struct cache_entry **src,
o->merge_size);
if (a && old)
return o->gently ? -1 :
- error("Entry '%s' overlaps. Cannot bind.", a->name);
+ error(ERRORMSG(o, bind_overlap), a->name, old->name);
if (!a)
return keep_entry(old, o);
else
@@ -941,9 +975,7 @@ int bind_merge(struct cache_entry **src,
* The rule is:
* - take the stat information from stage0, take the data from stage1
*/
-int oneway_merge(struct cache_entry **src,
- struct unpack_trees_options *o,
- int remove)
+int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
{
struct cache_entry *old = src[0];
struct cache_entry *a = src[1];
@@ -952,18 +984,19 @@ int oneway_merge(struct cache_entry **src,
return error("Cannot do a oneway merge of %d trees",
o->merge_size);
- if (!a) {
- remove_entry(remove);
+ if (!a)
return deleted_entry(old, old, o);
- }
+
if (old && same(old, a)) {
+ int update = 0;
if (o->reset) {
struct stat st;
if (lstat(old->name, &st) ||
- ce_match_stat(old, &st, CE_MATCH_IGNORE_VALID))
- old->ce_flags |= CE_UPDATE;
+ ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID))
+ update |= CE_UPDATE;
}
- return keep_entry(old, o);
+ add_entry(o, old, update, 0);
+ return 0;
}
return merged_entry(a, old, o);
}
diff --git a/unpack-trees.h b/unpack-trees.h
index a2df544d0..94e567265 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -1,41 +1,55 @@
#ifndef UNPACK_TREES_H
#define UNPACK_TREES_H
+#define MAX_UNPACK_TREES 8
+
struct unpack_trees_options;
typedef int (*merge_fn_t)(struct cache_entry **src,
- struct unpack_trees_options *options,
- int remove);
+ struct unpack_trees_options *options);
+
+struct unpack_trees_error_msgs {
+ const char *would_overwrite;
+ const char *not_uptodate_file;
+ const char *not_uptodate_dir;
+ const char *would_lose_untracked;
+ const char *bind_overlap;
+};
struct unpack_trees_options {
- int reset;
- int merge;
- int update;
- int index_only;
- int nontrivial_merge;
- int trivial_merges_only;
- int verbose_update;
- int aggressive;
- int skip_unmerged;
- int gently;
+ unsigned int reset:1,
+ merge:1,
+ update:1,
+ index_only:1,
+ nontrivial_merge:1,
+ trivial_merges_only:1,
+ verbose_update:1,
+ aggressive:1,
+ skip_unmerged:1,
+ gently:1;
const char *prefix;
int pos;
struct dir_struct *dir;
merge_fn_t fn;
+ struct unpack_trees_error_msgs msgs;
int head_idx;
int merge_size;
struct cache_entry *df_conflict_entry;
void *unpack_data;
+
+ struct index_state *dst_index;
+ struct index_state *src_index;
+ struct index_state result;
};
extern int unpack_trees(unsigned n, struct tree_desc *t,
struct unpack_trees_options *options);
-int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o, int);
-int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
-int bind_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
-int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o, int);
+int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o);
+int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o);
+int bind_merge(struct cache_entry **src, struct unpack_trees_options *o);
+int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o);
#endif
diff --git a/update-server-info.c b/update-server-info.c
index 0b6c3835b..7e8209ea4 100644
--- a/update-server-info.c
+++ b/update-server-info.c
@@ -1,7 +1,7 @@
#include "cache.h"
static const char update_server_info_usage[] =
-"git-update-server-info [--force]";
+"git update-server-info [--force]";
int main(int ac, char **av)
{
diff --git a/upload-pack.c b/upload-pack.c
index 7e0431102..c911e70c9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -27,7 +27,8 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
static unsigned long oldest_have;
static int multi_ack, nr_our_refs;
-static int use_thin_pack, use_ofs_delta, no_progress;
+static int use_thin_pack, use_ofs_delta, use_include_tag;
+static int no_progress;
static struct object_array have_obj;
static struct object_array want_obj;
static unsigned int timeout;
@@ -35,6 +36,7 @@ static unsigned int timeout;
* otherwise maximum packet size (up to 65520 bytes).
*/
static int use_sideband;
+static int debug_fd;
static void reset_timeout(void)
{
@@ -129,9 +131,12 @@ static int do_rev_list(int fd, void *create_full_pack)
}
setup_revisions(0, NULL, &revs, NULL);
}
- prepare_revision_walk(&revs);
+ if (prepare_revision_walk(&revs))
+ die("revision walk setup failed");
mark_edges_uninteresting(revs.commits, &revs, show_edge);
traverse_commit_list(&revs, show_commit, show_object);
+ fflush(pack_pipe);
+ fclose(pack_pipe);
return 0;
}
@@ -160,6 +165,8 @@ static void create_pack_file(void)
argv[arg++] = "--progress";
if (use_ofs_delta)
argv[arg++] = "--delta-base-offset";
+ if (use_include_tag)
+ argv[arg++] = "--include-tag";
argv[arg++] = NULL;
memset(&pack_objects, 0, sizeof(pack_objects));
@@ -392,7 +399,6 @@ static int get_common_commits(void)
char hex[41], last_hex[41];
int len;
- track_object_refs = 0;
save_commit_buffer = 0;
for(;;) {
@@ -444,6 +450,8 @@ static void receive_needs(void)
static char line[1000];
int len, depth = 0;
+ if (debug_fd)
+ write_in_full(debug_fd, "#S\n", 3);
for (;;) {
struct object *o;
unsigned char sha1_buf[20];
@@ -451,6 +459,8 @@ static void receive_needs(void)
reset_timeout();
if (!len)
break;
+ if (debug_fd)
+ write_in_full(debug_fd, line, len);
if (!prefixcmp(line, "shallow ")) {
unsigned char sha1[20];
@@ -489,6 +499,8 @@ static void receive_needs(void)
use_sideband = DEFAULT_PACKET_MAX;
if (strstr(line+45, "no-progress"))
no_progress = 1;
+ if (strstr(line+45, "include-tag"))
+ use_include_tag = 1;
/* We have sent all our refs already, and the other end
* should have chosen out of them; otherwise they are
@@ -506,6 +518,8 @@ static void receive_needs(void)
add_object_array(o, NULL, &want_obj);
}
}
+ if (debug_fd)
+ write_in_full(debug_fd, "#E\n", 3);
if (depth == 0 && shallows.nr == 0)
return;
if (depth > 0) {
@@ -533,7 +547,8 @@ static void receive_needs(void)
/* make sure the real parents are parsed */
unregister_shallow(object->sha1);
object->parsed = 0;
- parse_commit((struct commit *)object);
+ if (parse_commit((struct commit *)object))
+ die("invalid commit");
parents = ((struct commit *)object)->parents;
while (parents) {
add_object_array(&parents->item->object,
@@ -557,7 +572,8 @@ static void receive_needs(void)
static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
static const char *capabilities = "multi_ack thin-pack side-band"
- " side-band-64k ofs-delta shallow no-progress";
+ " side-band-64k ofs-delta shallow no-progress"
+ " include-tag";
struct object *o = parse_object(sha1);
if (!o)
@@ -575,7 +591,8 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
}
if (o->type == OBJ_TAG) {
o = deref_tag(o, refname, 0);
- packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
+ if (o)
+ packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname);
}
return 0;
}
@@ -620,12 +637,17 @@ int main(int argc, char **argv)
if (i != argc-1)
usage(upload_pack_usage);
+
+ setup_path();
+
dir = argv[i];
if (!enter_repo(dir, strict))
die("'%s': unable to chdir or not a git archive", dir);
if (is_repository_shallow())
die("attempt to fetch/clone from a shallow repository");
+ if (getenv("GIT_DEBUG_SEND_PACK"))
+ debug_fd = atoi(getenv("GIT_DEBUG_SEND_PACK"));
upload_pack();
return 0;
}
diff --git a/var.c b/var.c
index 0de0efa2a..f1eb314e8 100644
--- a/var.c
+++ b/var.c
@@ -5,7 +5,7 @@
*/
#include "cache.h"
-static const char var_usage[] = "git-var [-l | <variable>]";
+static const char var_usage[] = "git var [-l | <variable>]";
struct git_var {
const char *name;
@@ -39,31 +39,32 @@ static const char *read_var(const char *var)
return val;
}
-static int show_config(const char *var, const char *value)
+static int show_config(const char *var, const char *value, void *cb)
{
if (value)
printf("%s=%s\n", var, value);
else
printf("%s\n", var);
- return git_default_config(var, value);
+ return git_default_config(var, value, cb);
}
int main(int argc, char **argv)
{
const char *val;
+ int nongit;
if (argc != 2) {
usage(var_usage);
}
- setup_git_directory();
+ setup_git_directory_gently(&nongit);
val = NULL;
if (strcmp(argv[1], "-l") == 0) {
- git_config(show_config);
+ git_config(show_config, NULL);
list_vars();
return 0;
}
- git_config(git_default_config);
+ git_config(git_default_config, NULL);
val = read_var(argv[1]);
if (!val)
usage(var_usage);
diff --git a/walker.c b/walker.c
index adc3e80ce..0e68ee6d2 100644
--- a/walker.c
+++ b/walker.c
@@ -59,6 +59,7 @@ static int process_tree(struct walker *walker, struct tree *tree)
free(tree->buffer);
tree->buffer = NULL;
tree->size = 0;
+ tree->object.parsed = 0;
return 0;
}
@@ -190,9 +191,13 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
if (!get_sha1_hex(target, sha1))
return 0;
if (!check_ref_format(target)) {
- if (!walker->fetch_ref(walker, target, sha1)) {
+ struct ref *ref = alloc_ref_from_str(target);
+ if (!walker->fetch_ref(walker, ref)) {
+ hashcpy(sha1, ref->old_sha1);
+ free(ref);
return 0;
}
+ free(ref);
}
return -1;
}
@@ -256,7 +261,6 @@ int walker_fetch(struct walker *walker, int targets, char **target,
int i;
save_commit_buffer = 0;
- track_object_refs = 0;
for (i = 0; i < targets; i++) {
if (!write_ref || !write_ref[i])
diff --git a/walker.h b/walker.h
index ea2c363f4..8a149e110 100644
--- a/walker.h
+++ b/walker.h
@@ -1,9 +1,11 @@
#ifndef WALKER_H
#define WALKER_H
+#include "remote.h"
+
struct walker {
void *data;
- int (*fetch_ref)(struct walker *, char *ref, unsigned char *sha1);
+ int (*fetch_ref)(struct walker *, struct ref *ref);
void (*prefetch)(struct walker *, unsigned char *sha1);
int (*fetch)(struct walker *, unsigned char *sha1);
void (*cleanup)(struct walker *);
@@ -32,6 +34,6 @@ int walker_fetch(struct walker *impl, int targets, char **target,
void walker_free(struct walker *walker);
-struct walker *get_http_walker(const char *url);
+struct walker *get_http_walker(const char *url, struct remote *remote);
#endif /* WALKER_H */
diff --git a/wrapper.c b/wrapper.c
new file mode 100644
index 000000000..93562f03e
--- /dev/null
+++ b/wrapper.c
@@ -0,0 +1,198 @@
+/*
+ * Various trivial helper wrappers around standard functions
+ */
+#include "cache.h"
+
+char *xstrdup(const char *str)
+{
+ char *ret = strdup(str);
+ if (!ret) {
+ release_pack_memory(strlen(str) + 1, -1);
+ ret = strdup(str);
+ if (!ret)
+ die("Out of memory, strdup failed");
+ }
+ return ret;
+}
+
+void *xmalloc(size_t size)
+{
+ void *ret = malloc(size);
+ if (!ret && !size)
+ ret = malloc(1);
+ if (!ret) {
+ release_pack_memory(size, -1);
+ ret = malloc(size);
+ if (!ret && !size)
+ ret = malloc(1);
+ if (!ret)
+ die("Out of memory, malloc failed");
+ }
+#ifdef XMALLOC_POISON
+ memset(ret, 0xA5, size);
+#endif
+ return ret;
+}
+
+/*
+ * xmemdupz() allocates (len + 1) bytes of memory, duplicates "len" bytes of
+ * "data" to the allocated memory, zero terminates the allocated memory,
+ * and returns a pointer to the allocated memory. If the allocation fails,
+ * the program dies.
+ */
+void *xmemdupz(const void *data, size_t len)
+{
+ char *p = xmalloc(len + 1);
+ memcpy(p, data, len);
+ p[len] = '\0';
+ return p;
+}
+
+char *xstrndup(const char *str, size_t len)
+{
+ char *p = memchr(str, '\0', len);
+ return xmemdupz(str, p ? p - str : len);
+}
+
+void *xrealloc(void *ptr, size_t size)
+{
+ void *ret = realloc(ptr, size);
+ if (!ret && !size)
+ ret = realloc(ptr, 1);
+ if (!ret) {
+ release_pack_memory(size, -1);
+ ret = realloc(ptr, size);
+ if (!ret && !size)
+ ret = realloc(ptr, 1);
+ if (!ret)
+ die("Out of memory, realloc failed");
+ }
+ return ret;
+}
+
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *ret = calloc(nmemb, size);
+ if (!ret && (!nmemb || !size))
+ ret = calloc(1, 1);
+ if (!ret) {
+ release_pack_memory(nmemb * size, -1);
+ ret = calloc(nmemb, size);
+ if (!ret && (!nmemb || !size))
+ ret = calloc(1, 1);
+ if (!ret)
+ die("Out of memory, calloc failed");
+ }
+ return ret;
+}
+
+void *xmmap(void *start, size_t length,
+ int prot, int flags, int fd, off_t offset)
+{
+ void *ret = mmap(start, length, prot, flags, fd, offset);
+ if (ret == MAP_FAILED) {
+ if (!length)
+ return NULL;
+ release_pack_memory(length, fd);
+ ret = mmap(start, length, prot, flags, fd, offset);
+ if (ret == MAP_FAILED)
+ die("Out of memory? mmap failed: %s", strerror(errno));
+ }
+ return ret;
+}
+
+/*
+ * xread() is the same a read(), but it automatically restarts read()
+ * operations with a recoverable error (EAGAIN and EINTR). xread()
+ * DOES NOT GUARANTEE that "len" bytes is read even if the data is available.
+ */
+ssize_t xread(int fd, void *buf, size_t len)
+{
+ ssize_t nr;
+ while (1) {
+ nr = read(fd, buf, len);
+ if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
+ continue;
+ return nr;
+ }
+}
+
+/*
+ * xwrite() is the same a write(), but it automatically restarts write()
+ * operations with a recoverable error (EAGAIN and EINTR). xwrite() DOES NOT
+ * GUARANTEE that "len" bytes is written even if the operation is successful.
+ */
+ssize_t xwrite(int fd, const void *buf, size_t len)
+{
+ ssize_t nr;
+ while (1) {
+ nr = write(fd, buf, len);
+ if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
+ continue;
+ return nr;
+ }
+}
+
+ssize_t read_in_full(int fd, void *buf, size_t count)
+{
+ char *p = buf;
+ ssize_t total = 0;
+
+ while (count > 0) {
+ ssize_t loaded = xread(fd, p, count);
+ if (loaded <= 0)
+ return total ? total : loaded;
+ count -= loaded;
+ p += loaded;
+ total += loaded;
+ }
+
+ return total;
+}
+
+ssize_t write_in_full(int fd, const void *buf, size_t count)
+{
+ const char *p = buf;
+ ssize_t total = 0;
+
+ while (count > 0) {
+ ssize_t written = xwrite(fd, p, count);
+ if (written < 0)
+ return -1;
+ if (!written) {
+ errno = ENOSPC;
+ return -1;
+ }
+ count -= written;
+ p += written;
+ total += written;
+ }
+
+ return total;
+}
+
+int xdup(int fd)
+{
+ int ret = dup(fd);
+ if (ret < 0)
+ die("dup failed: %s", strerror(errno));
+ return ret;
+}
+
+FILE *xfdopen(int fd, const char *mode)
+{
+ FILE *stream = fdopen(fd, mode);
+ if (stream == NULL)
+ die("Out of memory? fdopen failed: %s", strerror(errno));
+ return stream;
+}
+
+int xmkstemp(char *template)
+{
+ int fd;
+
+ fd = mkstemp(template);
+ if (fd < 0)
+ die("Unable to create temporary file: %s", strerror(errno));
+ return fd;
+}
diff --git a/write_or_die.c b/write_or_die.c
index e125e11d3..4c29255df 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -34,48 +34,22 @@ void maybe_flush_or_die(FILE *f, const char *desc)
return;
}
if (fflush(f)) {
- if (errno == EPIPE)
+ /*
+ * On Windows, EPIPE is returned only by the first write()
+ * after the reading end has closed its handle; subsequent
+ * write()s return EINVAL.
+ */
+ if (errno == EPIPE || errno == EINVAL)
exit(0);
die("write failure on %s: %s", desc, strerror(errno));
}
}
-int read_in_full(int fd, void *buf, size_t count)
-{
- char *p = buf;
- ssize_t total = 0;
-
- while (count > 0) {
- ssize_t loaded = xread(fd, p, count);
- if (loaded <= 0)
- return total ? total : loaded;
- count -= loaded;
- p += loaded;
- total += loaded;
- }
-
- return total;
-}
-
-int write_in_full(int fd, const void *buf, size_t count)
+void fsync_or_die(int fd, const char *msg)
{
- const char *p = buf;
- ssize_t total = 0;
-
- while (count > 0) {
- ssize_t written = xwrite(fd, p, count);
- if (written < 0)
- return -1;
- if (!written) {
- errno = ENOSPC;
- return -1;
- }
- count -= written;
- p += written;
- total += written;
+ if (fsync(fd) < 0) {
+ die("%s: fsync error (%s)", msg, strerror(errno));
}
-
- return total;
}
void write_or_die(int fd, const void *buf, size_t count)
diff --git a/ws.c b/ws.c
index d09b9df89..7a7ff130a 100644
--- a/ws.c
+++ b/ws.c
@@ -14,6 +14,7 @@ static struct whitespace_rule {
{ "trailing-space", WS_TRAILING_SPACE },
{ "space-before-tab", WS_SPACE_BEFORE_TAB },
{ "indent-with-non-tab", WS_INDENT_WITH_NON_TAB },
+ { "cr-at-eol", WS_CR_AT_EOL },
};
unsigned parse_whitespace_rule(const char *string)
@@ -116,14 +117,15 @@ char *whitespace_error_string(unsigned ws)
}
/* If stream is non-NULL, emits the line after checking. */
-unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
- FILE *stream, const char *set,
- const char *reset, const char *ws)
+static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule,
+ FILE *stream, const char *set,
+ const char *reset, const char *ws)
{
unsigned result = 0;
int written = 0;
int trailing_whitespace = -1;
int trailing_newline = 0;
+ int trailing_carriage_return = 0;
int i;
/* Logic is simpler if we temporarily ignore the trailing newline. */
@@ -131,6 +133,11 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
trailing_newline = 1;
len--;
}
+ if ((ws_rule & WS_CR_AT_EOL) &&
+ len > 0 && line[len - 1] == '\r') {
+ trailing_carriage_return = 1;
+ len--;
+ }
/* Check for trailing whitespace. */
if (ws_rule & WS_TRAILING_SPACE) {
@@ -176,8 +183,10 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
}
if (stream) {
- /* Now the rest of the line starts at written.
- * The non-highlighted part ends at trailing_whitespace. */
+ /*
+ * Now the rest of the line starts at "written".
+ * The non-highlighted part ends at "trailing_whitespace".
+ */
if (trailing_whitespace == -1)
trailing_whitespace = len;
@@ -196,8 +205,141 @@ unsigned check_and_emit_line(const char *line, int len, unsigned ws_rule,
len - trailing_whitespace, 1, stream);
fputs(reset, stream);
}
+ if (trailing_carriage_return)
+ fputc('\r', stream);
if (trailing_newline)
fputc('\n', stream);
}
return result;
}
+
+void ws_check_emit(const char *line, int len, unsigned ws_rule,
+ FILE *stream, const char *set,
+ const char *reset, const char *ws)
+{
+ (void)ws_check_emit_1(line, len, ws_rule, stream, set, reset, ws);
+}
+
+unsigned ws_check(const char *line, int len, unsigned ws_rule)
+{
+ return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL);
+}
+
+int ws_blank_line(const char *line, int len, unsigned ws_rule)
+{
+ /*
+ * We _might_ want to treat CR differently from other
+ * whitespace characters when ws_rule has WS_CR_AT_EOL, but
+ * for now we just use this stupid definition.
+ */
+ while (len-- > 0) {
+ if (!isspace(*line))
+ return 0;
+ line++;
+ }
+ return 1;
+}
+
+/* Copy the line to the buffer while fixing whitespaces */
+int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *error_count)
+{
+ /*
+ * len is number of bytes to be copied from src, starting
+ * at src. Typically src[len-1] is '\n', unless this is
+ * the incomplete last line.
+ */
+ int i;
+ int add_nl_to_tail = 0;
+ int add_cr_to_tail = 0;
+ int fixed = 0;
+ int last_tab_in_indent = -1;
+ int last_space_in_indent = -1;
+ int need_fix_leading_space = 0;
+ char *buf;
+
+ /*
+ * Strip trailing whitespace
+ */
+ if ((ws_rule & WS_TRAILING_SPACE) &&
+ (2 <= len && isspace(src[len-2]))) {
+ if (src[len - 1] == '\n') {
+ add_nl_to_tail = 1;
+ len--;
+ if (1 < len && src[len - 1] == '\r') {
+ add_cr_to_tail = !!(ws_rule & WS_CR_AT_EOL);
+ len--;
+ }
+ }
+ if (0 < len && isspace(src[len - 1])) {
+ while (0 < len && isspace(src[len-1]))
+ len--;
+ fixed = 1;
+ }
+ }
+
+ /*
+ * Check leading whitespaces (indent)
+ */
+ for (i = 0; i < len; i++) {
+ char ch = src[i];
+ if (ch == '\t') {
+ last_tab_in_indent = i;
+ if ((ws_rule & WS_SPACE_BEFORE_TAB) &&
+ 0 <= last_space_in_indent)
+ need_fix_leading_space = 1;
+ } else if (ch == ' ') {
+ last_space_in_indent = i;
+ if ((ws_rule & WS_INDENT_WITH_NON_TAB) &&
+ 8 <= i - last_tab_in_indent)
+ need_fix_leading_space = 1;
+ } else
+ break;
+ }
+
+ buf = dst;
+ if (need_fix_leading_space) {
+ /* Process indent ourselves */
+ int consecutive_spaces = 0;
+ int last = last_tab_in_indent + 1;
+
+ if (ws_rule & WS_INDENT_WITH_NON_TAB) {
+ /* have "last" point at one past the indent */
+ if (last_tab_in_indent < last_space_in_indent)
+ last = last_space_in_indent + 1;
+ else
+ last = last_tab_in_indent + 1;
+ }
+
+ /*
+ * between src[0..last-1], strip the funny spaces,
+ * updating them to tab as needed.
+ */
+ for (i = 0; i < last; i++) {
+ char ch = src[i];
+ if (ch != ' ') {
+ consecutive_spaces = 0;
+ *dst++ = ch;
+ } else {
+ consecutive_spaces++;
+ if (consecutive_spaces == 8) {
+ *dst++ = '\t';
+ consecutive_spaces = 0;
+ }
+ }
+ }
+ while (0 < consecutive_spaces--)
+ *dst++ = ' ';
+ len -= last;
+ src += last;
+ fixed = 1;
+ }
+
+ memcpy(dst, src, len);
+ if (add_cr_to_tail)
+ dst[len++] = '\r';
+ if (add_nl_to_tail)
+ dst[len++] = '\n';
+ if (fixed && error_count)
+ (*error_count)++;
+ return dst + len - buf;
+}
diff --git a/wt-status.c b/wt-status.c
index 27b946d55..889e50f89 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -7,14 +7,19 @@
#include "diff.h"
#include "revision.h"
#include "diffcore.h"
+#include "quote.h"
+#include "run-command.h"
+#include "remote.h"
int wt_status_relative_paths = 1;
-int wt_status_use_color = 0;
+int wt_status_use_color = -1;
+int wt_status_submodule_summary;
static char wt_status_colors[][COLOR_MAXLEN] = {
"", /* WT_STATUS_HEADER: normal */
"\033[32m", /* WT_STATUS_UPDATED: green */
"\033[31m", /* WT_STATUS_CHANGED: red */
"\033[31m", /* WT_STATUS_UNTRACKED: red */
+ "\033[31m", /* WT_STATUS_NOBRANCH: red */
};
static const char use_add_msg[] =
@@ -23,6 +28,7 @@ static const char use_add_rm_msg[] =
"use \"git add/rm <file>...\" to update what will be committed";
static const char use_add_to_include_msg[] =
"use \"git add <file>...\" to include in what will be committed";
+enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
static int parse_status_slot(const char *var, int offset)
{
@@ -35,12 +41,14 @@ static int parse_status_slot(const char *var, int offset)
return WT_STATUS_CHANGED;
if (!strcasecmp(var+offset, "untracked"))
return WT_STATUS_UNTRACKED;
+ if (!strcasecmp(var+offset, "nobranch"))
+ return WT_STATUS_NOBRANCH;
die("bad config variable '%s'", var);
}
static const char* color(int slot)
{
- return wt_status_use_color ? wt_status_colors[slot] : "";
+ return wt_status_use_color > 0 ? wt_status_colors[slot] : "";
}
void wt_status_prepare(struct wt_status *s)
@@ -60,7 +68,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
{
const char *c = color(WT_STATUS_HEADER);
color_fprintf_ln(s->fp, c, "# Changes to be committed:");
- if (s->reference) {
+ if (!s->is_initial) {
color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
} else {
color_fprintf_ln(s->fp, c, "# (use \"git rm --cached <file>...\" to unstage)");
@@ -82,51 +90,7 @@ static void wt_status_print_trailer(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
}
-static char *quote_path(const char *in, int len,
- struct strbuf *out, const char *prefix)
-{
- if (len < 0)
- len = strlen(in);
-
- strbuf_grow(out, len);
- strbuf_setlen(out, 0);
- if (prefix) {
- int off = 0;
- while (prefix[off] && off < len && prefix[off] == in[off])
- if (prefix[off] == '/') {
- prefix += off + 1;
- in += off + 1;
- len -= off + 1;
- off = 0;
- } else
- off++;
-
- for (; *prefix; prefix++)
- if (*prefix == '/')
- strbuf_addstr(out, "../");
- }
-
- for ( ; len > 0; in++, len--) {
- int ch = *in;
-
- switch (ch) {
- case '\n':
- strbuf_addstr(out, "\\n");
- break;
- case '\r':
- strbuf_addstr(out, "\\r");
- break;
- default:
- strbuf_addch(out, ch);
- continue;
- }
- }
-
- if (!out->len)
- strbuf_addstr(out, "./");
-
- return out->buf;
-}
+#define quote_path quote_path_relative
static void wt_status_print_filepair(struct wt_status *s,
int t, struct diff_filepair *p)
@@ -247,7 +211,7 @@ static void wt_status_print_updated(struct wt_status *s)
rev.diffopt.format_callback = wt_status_print_updated_cb;
rev.diffopt.format_callback_data = s;
rev.diffopt.detect_rename = 1;
- rev.diffopt.rename_limit = 100;
+ rev.diffopt.rename_limit = 200;
rev.diffopt.break_opt = 0;
run_diff_index(&rev, 1);
}
@@ -263,6 +227,36 @@ static void wt_status_print_changed(struct wt_status *s)
run_diff_files(&rev, 0);
}
+static void wt_status_print_submodule_summary(struct wt_status *s)
+{
+ struct child_process sm_summary;
+ char summary_limit[64];
+ char index[PATH_MAX];
+ const char *env[] = { index, NULL };
+ const char *argv[] = {
+ "submodule",
+ "summary",
+ "--cached",
+ "--for-status",
+ "--summary-limit",
+ summary_limit,
+ s->amend ? "HEAD^" : "HEAD",
+ NULL
+ };
+
+ sprintf(summary_limit, "%d", wt_status_submodule_summary);
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
+
+ memset(&sm_summary, 0, sizeof(sm_summary));
+ sm_summary.argv = argv;
+ sm_summary.env = env;
+ sm_summary.git_cmd = 1;
+ sm_summary.no_stdin = 1;
+ fflush(s->fp);
+ sm_summary.out = dup(fileno(s->fp)); /* run_command closes it */
+ run_command(&sm_summary);
+}
+
static void wt_status_print_untracked(struct wt_status *s)
{
struct dir_struct dir;
@@ -312,34 +306,41 @@ static void wt_status_print_untracked(struct wt_status *s)
static void wt_status_print_verbose(struct wt_status *s)
{
struct rev_info rev;
- int saved_stdout;
-
- fflush(s->fp);
-
- /* Sigh, the entire diff machinery is hardcoded to output to
- * stdout. Do the dup-dance...*/
- saved_stdout = dup(STDOUT_FILENO);
- if (saved_stdout < 0 ||dup2(fileno(s->fp), STDOUT_FILENO) < 0)
- die("couldn't redirect stdout\n");
init_revisions(&rev, NULL);
setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
+ rev.diffopt.file = s->fp;
+ rev.diffopt.close_file = 0;
run_diff_index(&rev, 1);
+}
- fflush(stdout);
-
- if (dup2(saved_stdout, STDOUT_FILENO) < 0)
- die("couldn't restore stdout\n");
- close(saved_stdout);
+static void wt_status_print_tracking(struct wt_status *s)
+{
+ struct strbuf sb = STRBUF_INIT;
+ const char *cp, *ep;
+ struct branch *branch;
+
+ assert(s->branch && !s->is_initial);
+ if (prefixcmp(s->branch, "refs/heads/"))
+ return;
+ branch = branch_get(s->branch + 11);
+ if (!format_tracking_info(branch, &sb))
+ return;
+
+ for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
+ "# %.*s", (int)(ep - cp), cp);
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
}
void wt_status_print(struct wt_status *s)
{
unsigned char sha1[20];
- s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
+ const char *branch_color = color(WT_STATUS_HEADER);
+ s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
if (s->branch) {
const char *on_what = "On branch ";
const char *branch_name = s->branch;
@@ -347,10 +348,13 @@ void wt_status_print(struct wt_status *s)
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
+ branch_color = color(WT_STATUS_NOBRANCH);
on_what = "Not currently on any branch.";
}
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
- "# %s%s", on_what, branch_name);
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+ color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+ if (!s->is_initial)
+ wt_status_print_tracking(s);
}
if (s->is_initial) {
@@ -364,7 +368,12 @@ void wt_status_print(struct wt_status *s)
}
wt_status_print_changed(s);
- wt_status_print_untracked(s);
+ if (wt_status_submodule_summary)
+ wt_status_print_submodule_summary(s);
+ if (show_untracked_files)
+ wt_status_print_untracked(s);
+ else if (s->commitable)
+ fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
if (s->verbose && !s->is_initial)
wt_status_print_verbose(s);
@@ -379,19 +388,30 @@ void wt_status_print(struct wt_status *s)
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
else if (s->is_initial)
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
+ else if (!show_untracked_files)
+ printf("nothing to commit (use -u to show untracked files)\n");
else
printf("nothing to commit (working directory clean)\n");
}
}
-int git_status_config(const char *k, const char *v)
+int git_status_config(const char *k, const char *v, void *cb)
{
+ if (!strcmp(k, "status.submodulesummary")) {
+ int is_bool;
+ wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
+ if (is_bool && wt_status_submodule_summary)
+ wt_status_submodule_summary = -1;
+ return 0;
+ }
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
wt_status_use_color = git_config_colorbool(k, v, -1);
return 0;
}
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
int slot = parse_status_slot(k, 13);
+ if (!v)
+ return config_error_nonbool(k);
color_parse(v, k, wt_status_colors[slot]);
return 0;
}
@@ -399,5 +419,18 @@ int git_status_config(const char *k, const char *v)
wt_status_relative_paths = git_config_bool(k, v);
return 0;
}
- return git_default_config(k, v);
+ if (!strcmp(k, "status.showuntrackedfiles")) {
+ if (!v)
+ return config_error_nonbool(k);
+ else if (!strcmp(v, "no"))
+ show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ else if (!strcmp(v, "normal"))
+ show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ else if (!strcmp(v, "all"))
+ show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ else
+ return error("Invalid untracked files mode '%s'", v);
+ return 0;
+ }
+ return git_color_default_config(k, v, cb);
}
diff --git a/wt-status.h b/wt-status.h
index 02afaa60e..78add09bd 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -8,8 +8,16 @@ enum color_wt_status {
WT_STATUS_UPDATED,
WT_STATUS_CHANGED,
WT_STATUS_UNTRACKED,
+ WT_STATUS_NOBRANCH,
};
+enum untracked_status_type {
+ SHOW_NO_UNTRACKED_FILES,
+ SHOW_NORMAL_UNTRACKED_FILES,
+ SHOW_ALL_UNTRACKED_FILES
+};
+extern enum untracked_status_type show_untracked_files;
+
struct wt_status {
int is_initial;
char *branch;
@@ -27,9 +35,9 @@ struct wt_status {
const char *prefix;
};
-int git_status_config(const char *var, const char *value);
-int wt_status_use_color;
-int wt_status_relative_paths;
+int git_status_config(const char *var, const char *value, void *cb);
+extern int wt_status_use_color;
+extern int wt_status_relative_paths;
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 4b8e5cca8..61dc5c547 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -152,8 +152,8 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
if ((f = fopen(filename, "rb")) == NULL)
return error("Could not open %s", filename);
sz = xsize_t(st.st_size);
- ptr->ptr = xmalloc(sz);
- if (fread(ptr->ptr, sz, 1, f) != 1)
+ ptr->ptr = xmalloc(sz ? sz : 1);
+ if (sz && fread(ptr->ptr, sz, 1, f) != 1)
return error("Could not read %s", filename);
fclose(f);
ptr->size = sz;
@@ -233,8 +233,7 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)
expression = value;
if (regcomp(&reg->re, expression, 0))
die("Invalid regexp to look for hunk header: %s", expression);
- if (buffer)
- free(buffer);
+ free(buffer);
value = ep + 1;
}
}
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index c00ddaa6e..413082e1f 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -53,6 +53,7 @@ extern "C" {
#define XDL_MERGE_MINIMAL 0
#define XDL_MERGE_EAGER 1
#define XDL_MERGE_ZEALOUS 2
+#define XDL_MERGE_ZEALOUS_ALNUM 3
typedef struct s_mmfile {
char *ptr;
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index b83b3348c..82b3573e7 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -248,10 +248,76 @@ static int xdl_refine_conflicts(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m,
return 0;
}
+static int line_contains_alnum(const char *ptr, long size)
+{
+ while (size--)
+ if (isalnum(*(ptr++)))
+ return 1;
+ return 0;
+}
+
+static int lines_contain_alnum(xdfenv_t *xe, int i, int chg)
+{
+ for (; chg; chg--, i++)
+ if (line_contains_alnum(xe->xdf2.recs[i]->ptr,
+ xe->xdf2.recs[i]->size))
+ return 1;
+ return 0;
+}
+
+/*
+ * This function merges m and m->next, marking everything between those hunks
+ * as conflicting, too.
+ */
+static void xdl_merge_two_conflicts(xdmerge_t *m)
+{
+ xdmerge_t *next_m = m->next;
+ m->chg1 = next_m->i1 + next_m->chg1 - m->i1;
+ m->chg2 = next_m->i2 + next_m->chg2 - m->i2;
+ m->next = next_m->next;
+ free(next_m);
+}
+
+/*
+ * If there are less than 3 non-conflicting lines between conflicts,
+ * it appears simpler -- because it takes up less (or as many) lines --
+ * if the lines are moved into the conflicts.
+ */
+static int xdl_simplify_non_conflicts(xdfenv_t *xe1, xdmerge_t *m,
+ int simplify_if_no_alnum)
+{
+ int result = 0;
+
+ if (!m)
+ return result;
+ for (;;) {
+ xdmerge_t *next_m = m->next;
+ int begin, end;
+
+ if (!next_m)
+ return result;
+
+ begin = m->i1 + m->chg1;
+ end = next_m->i1;
+
+ if (m->mode != 0 || next_m->mode != 0 ||
+ (end - begin > 3 &&
+ (!simplify_if_no_alnum ||
+ lines_contain_alnum(xe1, begin, end - begin)))) {
+ m = next_m;
+ } else {
+ result++;
+ xdl_merge_two_conflicts(m);
+ }
+ }
+}
+
/*
* level == 0: mark all overlapping changes as conflict
* level == 1: mark overlapping changes as conflict only if not identical
* level == 2: analyze non-identical changes for minimal conflict set
+ * level == 3: analyze non-identical changes for minimal conflict set, but
+ * treat hunks not containing any letter or number as conflicting
*
* returns < 0 on error, == 0 for no conflicts, else number of conflicts
*/
@@ -355,7 +421,9 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
if (!changes)
changes = c;
/* refine conflicts */
- if (level > 1 && xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0) {
+ if (level > 1 &&
+ (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 ||
+ xdl_simplify_non_conflicts(xe1, changes, level > 2) < 0)) {
xdl_cleanup_merge(changes);
return -1;
}