Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--.mailmap2
-rw-r--r--Documentation/.gitignore2
-rw-r--r--Documentation/Makefile38
-rw-r--r--Documentation/RelNotes-1.5.0.txt468
-rw-r--r--Documentation/SubmittingPatches39
-rwxr-xr-xDocumentation/cmd-list.perl185
-rw-r--r--Documentation/config.txt165
-rw-r--r--Documentation/core-intro.txt591
-rw-r--r--Documentation/core-tutorial.txt79
-rw-r--r--Documentation/cvs-migration.txt4
-rw-r--r--Documentation/diff-format.txt2
-rw-r--r--Documentation/diff-options.txt4
-rw-r--r--Documentation/diffcore.txt7
-rw-r--r--Documentation/docbook-xsl.css286
-rw-r--r--Documentation/everyday.txt11
-rw-r--r--Documentation/git-add.txt6
-rw-r--r--Documentation/git-am.txt13
-rw-r--r--Documentation/git-apply.txt2
-rw-r--r--Documentation/git-applymbox.txt14
-rw-r--r--Documentation/git-applypatch.txt3
-rw-r--r--Documentation/git-archive.txt2
-rw-r--r--Documentation/git-bisect.txt2
-rw-r--r--Documentation/git-blame.txt69
-rw-r--r--Documentation/git-branch.txt4
-rw-r--r--Documentation/git-cat-file.txt6
-rw-r--r--Documentation/git-checkout-index.txt2
-rw-r--r--Documentation/git-checkout.txt59
-rw-r--r--Documentation/git-cherry-pick.txt2
-rw-r--r--Documentation/git-clone.txt2
-rw-r--r--Documentation/git-commit-tree.txt5
-rw-r--r--Documentation/git-commit.txt30
-rw-r--r--Documentation/git-config.txt227
-rw-r--r--Documentation/git-count-objects.txt2
-rw-r--r--Documentation/git-cvsexportcommit.txt7
-rw-r--r--Documentation/git-cvsimport.txt4
-rw-r--r--Documentation/git-daemon.txt4
-rw-r--r--Documentation/git-describe.txt61
-rw-r--r--Documentation/git-diff-stages.txt40
-rw-r--r--Documentation/git-diff.txt3
-rw-r--r--Documentation/git-fast-import.txt901
-rw-r--r--Documentation/git-fetch-pack.txt27
-rw-r--r--Documentation/git-fetch.txt10
-rw-r--r--Documentation/git-for-each-ref.txt8
-rw-r--r--Documentation/git-format-patch.txt33
-rw-r--r--Documentation/git-fsck-objects.txt128
-rw-r--r--Documentation/git-fsck.txt139
-rw-r--r--Documentation/git-gc.txt23
-rw-r--r--Documentation/git-grep.txt2
-rw-r--r--Documentation/git-hash-object.txt2
-rw-r--r--Documentation/git-http-fetch.txt2
-rw-r--r--Documentation/git-http-push.txt2
-rw-r--r--Documentation/git-init-db.txt91
-rw-r--r--Documentation/git-init.txt111
-rw-r--r--Documentation/git-instaweb.txt2
-rw-r--r--Documentation/git-local-fetch.txt2
-rw-r--r--Documentation/git-log.txt7
-rw-r--r--Documentation/git-ls-files.txt2
-rw-r--r--Documentation/git-ls-remote.txt2
-rw-r--r--Documentation/git-ls-tree.txt2
-rw-r--r--Documentation/git-mailinfo.txt20
-rw-r--r--Documentation/git-mailsplit.txt2
-rw-r--r--Documentation/git-merge-base.txt2
-rw-r--r--Documentation/git-merge-file.txt2
-rw-r--r--Documentation/git-merge-index.txt2
-rw-r--r--Documentation/git-merge-one-file.txt2
-rw-r--r--Documentation/git-merge.txt4
-rw-r--r--Documentation/git-mv.txt2
-rw-r--r--Documentation/git-p4import.txt2
-rw-r--r--Documentation/git-pack-redundant.txt4
-rw-r--r--Documentation/git-pack-refs.txt13
-rw-r--r--Documentation/git-parse-remote.txt8
-rw-r--r--Documentation/git-patch-id.txt2
-rw-r--r--Documentation/git-peek-remote.txt9
-rw-r--r--Documentation/git-prune-packed.txt8
-rw-r--r--Documentation/git-prune.txt2
-rw-r--r--Documentation/git-pull.txt63
-rw-r--r--Documentation/git-push.txt23
-rw-r--r--Documentation/git-rebase.txt37
-rw-r--r--Documentation/git-receive-pack.txt2
-rw-r--r--Documentation/git-reflog.txt17
-rw-r--r--Documentation/git-remote.txt30
-rw-r--r--Documentation/git-repack.txt9
-rw-r--r--Documentation/git-repo-config.txt219
-rw-r--r--Documentation/git-rerere.txt14
-rw-r--r--Documentation/git-reset.txt4
-rw-r--r--Documentation/git-resolve.txt36
-rw-r--r--Documentation/git-rev-list.txt17
-rw-r--r--Documentation/git-rev-parse.txt12
-rw-r--r--Documentation/git-revert.txt2
-rw-r--r--Documentation/git-rm.txt12
-rw-r--r--Documentation/git-send-pack.txt23
-rw-r--r--Documentation/git-sh-setup.txt53
-rw-r--r--Documentation/git-shell.txt2
-rw-r--r--Documentation/git-shortlog.txt2
-rw-r--r--Documentation/git-show-branch.txt19
-rw-r--r--Documentation/git-show.txt5
-rw-r--r--Documentation/git-ssh-fetch.txt2
-rw-r--r--Documentation/git-ssh-upload.txt2
-rw-r--r--Documentation/git-status.txt11
-rw-r--r--Documentation/git-svn.txt32
-rw-r--r--Documentation/git-symbolic-ref.txt20
-rw-r--r--Documentation/git-tag.txt149
-rw-r--r--Documentation/git-tar-tree.txt4
-rw-r--r--Documentation/git-tools.txt22
-rw-r--r--Documentation/git-update-index.txt6
-rw-r--r--Documentation/git-update-ref.txt2
-rw-r--r--Documentation/git-upload-archive.txt2
-rw-r--r--Documentation/git-upload-pack.txt2
-rw-r--r--Documentation/git-var.txt6
-rw-r--r--Documentation/git-whatchanged.txt2
-rw-r--r--Documentation/git-write-tree.txt2
-rw-r--r--Documentation/git.txt436
-rw-r--r--Documentation/gitk.txt6
-rw-r--r--Documentation/glossary.txt14
-rw-r--r--Documentation/hooks.txt7
-rw-r--r--Documentation/howto/dangling-objects.txt109
-rw-r--r--Documentation/howto/rebase-from-internal-branch.txt2
-rw-r--r--Documentation/howto/revert-branch-rebase.txt9
-rw-r--r--Documentation/howto/setup-git-server-over-http.txt6
-rwxr-xr-xDocumentation/install-webdoc.sh2
-rw-r--r--Documentation/repository-layout.txt43
-rw-r--r--Documentation/tutorial-2.txt19
-rw-r--r--Documentation/tutorial.txt107
-rw-r--r--Documentation/user-manual.conf21
-rw-r--r--Documentation/user-manual.txt2961
-rwxr-xr-xGIT-VERSION-GEN2
-rw-r--r--INSTALL2
-rw-r--r--Makefile52
-rw-r--r--README599
l---------RelNotes1
-rw-r--r--builtin-add.c5
-rw-r--r--builtin-annotate.c2
-rw-r--r--builtin-apply.c2
-rw-r--r--builtin-archive.c1
-rw-r--r--builtin-blame.c694
-rw-r--r--builtin-branch.c71
-rw-r--r--builtin-commit-tree.c1
-rw-r--r--builtin-config.c (renamed from builtin-repo-config.c)4
-rw-r--r--builtin-describe.c284
-rw-r--r--builtin-diff-stages.c107
-rw-r--r--builtin-for-each-ref.c12
-rw-r--r--builtin-fsck.c (renamed from fsck-objects.c)153
-rw-r--r--builtin-init-db.c16
-rw-r--r--builtin-log.c83
-rw-r--r--builtin-ls-files.c10
-rw-r--r--builtin-mailinfo.c19
-rw-r--r--builtin-pack-objects.c6
-rw-r--r--builtin-pack-refs.c4
-rw-r--r--builtin-prune-packed.c26
-rw-r--r--builtin-push.c139
-rw-r--r--builtin-reflog.c82
-rw-r--r--builtin-rev-parse.c5
-rw-r--r--builtin-rm.c8
-rw-r--r--builtin-show-branch.c151
-rw-r--r--builtin-symbolic-ref.c48
-rw-r--r--builtin-update-index.c8
-rw-r--r--builtin-update-ref.c7
-rw-r--r--builtin.h6
-rw-r--r--cache.h20
-rw-r--r--combine-diff.c34
-rw-r--r--commit.c85
-rw-r--r--commit.h2
-rw-r--r--config.c55
-rw-r--r--connect.c2
-rw-r--r--contrib/blameview/README10
-rwxr-xr-xcontrib/blameview/blameview.perl155
-rw-r--r--contrib/colordiff/README2
-rwxr-xr-xcontrib/colordiff/colordiff.perl196
-rwxr-xr-xcontrib/completion/git-completion.bash458
-rw-r--r--contrib/emacs/git-blame.el380
-rw-r--r--contrib/emacs/git.el8
-rw-r--r--contrib/emacs/vc-git.el11
-rwxr-xr-xcontrib/examples/git-resolve.sh (renamed from git-resolve.sh)0
-rwxr-xr-xcontrib/fast-import/import-tars.perl103
-rwxr-xr-xcontrib/gitview/gitview2
-rwxr-xr-xcontrib/hg-to-git/hg-to-git.py233
-rw-r--r--contrib/hg-to-git/hg-to-git.txt21
-rw-r--r--contrib/mailmap.linux42
-rw-r--r--contrib/remotes2config.sh6
-rw-r--r--contrib/vim/syntax/gitcommit.vim4
-rw-r--r--daemon.c9
-rw-r--r--date.c5
-rw-r--r--describe.c175
-rw-r--r--diff-lib.c44
-rw-r--r--diff.c91
-rw-r--r--diff.h1
-rw-r--r--diffcore-pickaxe.c2
-rw-r--r--entry.c1
-rw-r--r--environment.c12
-rw-r--r--fast-import.c2081
-rw-r--r--fetch-pack.c117
-rwxr-xr-xgenerate-cmdlist.sh2
-rwxr-xr-xgit-add--interactive.perl3
-rwxr-xr-xgit-am.sh16
-rwxr-xr-xgit-applymbox.sh3
-rwxr-xr-xgit-archimport.perl11
-rwxr-xr-xgit-bisect.sh5
-rwxr-xr-xgit-checkout.sh100
-rwxr-xr-xgit-clean.sh1
-rwxr-xr-xgit-clone.sh112
-rwxr-xr-xgit-commit.sh63
-rw-r--r--git-compat-util.h10
-rwxr-xr-xgit-cvsexportcommit.perl6
-rwxr-xr-xgit-cvsimport.perl34
-rwxr-xr-xgit-cvsserver.perl12
-rwxr-xr-xgit-fetch.sh51
-rwxr-xr-xgit-gc.sh26
-rw-r--r--git-gui/.gitignore3
-rwxr-xr-xgit-gui/GIT-VERSION-GEN77
-rw-r--r--git-gui/Makefile56
-rw-r--r--git-gui/TODO44
-rwxr-xr-xgit-gui/git-gui.sh5924
-rwxr-xr-xgit-instaweb.sh10
-rwxr-xr-xgit-lost-found.sh2
-rwxr-xr-xgit-ls-remote.sh8
-rwxr-xr-xgit-merge-resolve.sh2
-rwxr-xr-xgit-merge.sh51
-rw-r--r--git-p4import.py6
-rwxr-xr-xgit-parse-remote.sh48
-rwxr-xr-xgit-pull.sh18
-rwxr-xr-xgit-quiltimport.sh4
-rwxr-xr-xgit-rebase.sh22
-rwxr-xr-xgit-remote.perl149
-rwxr-xr-xgit-repack.sh4
-rwxr-xr-xgit-reset.sh11
-rwxr-xr-xgit-revert.sh58
-rwxr-xr-xgit-send-email.perl10
-rwxr-xr-xgit-sh-setup.sh31
-rwxr-xr-xgit-svn.perl73
-rwxr-xr-xgit-svnimport.perl2
-rwxr-xr-xgit-tag.sh26
-rw-r--r--git.c46
-rw-r--r--git.spec.in50
-rwxr-xr-xgitk299
-rwxr-xr-xgitweb/gitweb.perl10
-rw-r--r--help.c4
-rw-r--r--http-fetch.c3
-rw-r--r--http-push.c1
-rw-r--r--ident.c91
-rw-r--r--index-pack.c2
-rw-r--r--local-fetch.c1
-rw-r--r--log-tree.c30
-rw-r--r--merge-recursive.c400
-rw-r--r--pack.h39
-rw-r--r--pager.c12
-rw-r--r--path.c26
-rw-r--r--peek-remote.c12
-rw-r--r--perl/Git.pm29
-rw-r--r--perl/Makefile.PL4
-rw-r--r--perl/private-Error.pm2
-rw-r--r--ppc/sha1ppc.S6
-rw-r--r--quote.c34
-rw-r--r--quote.h1
-rw-r--r--reachable.c8
-rw-r--r--read-cache.c2
-rw-r--r--receive-pack.c56
-rw-r--r--reflog-walk.c273
-rw-r--r--reflog-walk.h11
-rw-r--r--refs.c330
-rw-r--r--refs.h14
-rw-r--r--revision.c26
-rw-r--r--revision.h2
-rw-r--r--send-pack.c16
-rw-r--r--server-info.c2
-rw-r--r--setup.c31
-rw-r--r--sha1_file.c211
-rw-r--r--sha1_name.c118
-rw-r--r--shallow.c2
-rw-r--r--ssh-fetch.c1
-rw-r--r--t/README2
-rw-r--r--t/annotate-tests.sh3
-rw-r--r--t/lib-git-svn.sh10
-rwxr-xr-xt/t0000-basic.sh4
-rwxr-xr-xt/t1004-read-tree-m-u-wf.sh2
-rwxr-xr-xt/t1020-subdirectory.sh29
-rwxr-xr-xt/t1200-tutorial.sh8
-rwxr-xr-xt/t1300-repo-config.sh122
-rwxr-xr-xt/t1400-update-ref.sh10
-rwxr-xr-xt/t1410-reflog.sh4
-rwxr-xr-xt/t3200-branch.sh8
-rwxr-xr-xt/t3210-pack-refs.sh9
-rwxr-xr-xt/t3501-revert-cherry-pick.sh62
-rwxr-xr-xt/t3700-add.sh6
-rwxr-xr-xt/t3800-mktag.sh6
-rwxr-xr-xt/t3900-i18n-commit.sh24
-rwxr-xr-xt/t3901-8859-1.txt4
-rwxr-xr-xt/t3901-i18n-patch.sh255
-rwxr-xr-xt/t3901-utf8.txt4
-rwxr-xr-xt/t4000-diff-format.sh2
-rwxr-xr-xt/t4006-diff-mode.sh2
-rwxr-xr-xt/t4013-diff-various.sh2
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..master3
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..master^2
-rw-r--r--t/t4013/diff.format-patch_--attach_--stdout_initial..side1
-rw-r--r--t/t4013/diff.format-patch_--stdout_initial..master3
-rw-r--r--t/t4013/diff.format-patch_--stdout_initial..master^2
-rw-r--r--t/t4013/diff.format-patch_--stdout_initial..side1
-rwxr-xr-xt/t4016-diff-quote.sh66
-rwxr-xr-xt/t4102-apply-rename.sh2
-rwxr-xr-xt/t4116-apply-reverse.sh4
-rwxr-xr-xt/t4200-rerere.sh45
-rwxr-xr-xt/t5000-tar-tree.sh2
-rwxr-xr-xt/t5300-pack-object.sh6
-rwxr-xr-xt/t5301-sliding-window.sh14
-rwxr-xr-xt/t5400-send-pack.sh2
-rwxr-xr-xt/t5401-update-hooks.sh4
-rwxr-xr-xt/t5500-fetch-pack.sh9
-rwxr-xr-xt/t5510-fetch.sh12
-rwxr-xr-xt/t5520-pull.sh2
-rwxr-xr-xt/t5600-clone-fail-cleanup.sh2
-rwxr-xr-xt/t5700-clone-reference.sh40
-rwxr-xr-xt/t5710-info-alternate.sh2
-rw-r--r--t/t6023-merge-file.sh2
-rwxr-xr-xt/t6023-merge-rename-nocruft.sh42
-rwxr-xr-xt/t6120-describe.sh97
-rwxr-xr-xt/t6200-fmt-merge-msg.sh6
-rwxr-xr-xt/t7001-mv.sh4
-rwxr-xr-xt/t7201-co.sh67
-rwxr-xr-xt/t9101-git-svn-props.sh9
-rwxr-xr-xt/t9102-git-svn-deep-rmdir.sh1
-rwxr-xr-xt/t9103-git-svn-graft-branches.sh2
-rwxr-xr-xt/t9104-git-svn-follow-parent.sh3
-rwxr-xr-xt/t9106-git-svn-commit-diff-clobber.sh2
-rwxr-xr-xt/t9200-git-cvsexportcommit.sh38
-rwxr-xr-xt/t9300-fast-import.sh496
-rwxr-xr-xt/test-lib.sh6
-rw-r--r--templates/Makefile2
-rw-r--r--templates/hooks--update340
-rw-r--r--upload-pack.c3
-rw-r--r--var.c1
-rw-r--r--write_or_die.c60
-rw-r--r--wt-status.c58
-rw-r--r--wt-status.h6
334 files changed, 22567 insertions, 4401 deletions
diff --git a/.gitignore b/.gitignore
index 6da1cdbd0d..f15155d1b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ git-clean
git-clone
git-commit
git-commit-tree
+git-config
git-convert-objects
git-count-objects
git-cvsexportcommit
@@ -32,15 +33,16 @@ git-daemon
git-diff
git-diff-files
git-diff-index
-git-diff-stages
git-diff-tree
git-describe
+git-fast-import
git-fetch
git-fetch-pack
git-findtags
git-fmt-merge-msg
git-for-each-ref
git-format-patch
+git-fsck
git-fsck-objects
git-gc
git-get-tar-commit-id
@@ -69,7 +71,6 @@ git-merge-tree
git-merge-octopus
git-merge-one-file
git-merge-ours
-git-merge-recur
git-merge-recursive
git-merge-resolve
git-merge-stupid
@@ -99,7 +100,6 @@ git-repo-config
git-request-pull
git-rerere
git-reset
-git-resolve
git-rev-list
git-rev-parse
git-revert
diff --git a/.mailmap b/.mailmap
index 2c658f42f5..c7a3a75f33 100644
--- a/.mailmap
+++ b/.mailmap
@@ -30,7 +30,9 @@ Robert Fitzsimons <robfitz@273k.net>
Santi Béjar <sbejar@gmail.com>
Sean Estabrooks <seanlkml@sympatico.ca>
Shawn O. Pearce <spearce@spearce.org>
+Theodore Ts'o <tytso@mit.edu>
Tony Luck <tony.luck@intel.com>
+Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
Ville Skyttä <scop@xemacs.org>
YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
anonymous <linux@horizon.com>
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
index c87c61af00..6a51331b2f 100644
--- a/Documentation/.gitignore
+++ b/Documentation/.gitignore
@@ -4,4 +4,4 @@
*.7
howto-index.txt
doc.dep
-README
+cmds-*.txt
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 93c7024b48..9e7f2a7880 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -17,7 +17,7 @@ ARTICLES += hooks
ARTICLES += everyday
ARTICLES += git-tools
# with their own formatting rules.
-SP_ARTICLES = glossary howto/revert-branch-rebase
+SP_ARTICLES = glossary howto/revert-branch-rebase user-manual
DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
@@ -31,6 +31,8 @@ man1dir=$(mandir)/man1
man7dir=$(mandir)/man7
# DESTDIR=
+ASCIIDOC=asciidoc
+ASCIIDOC_EXTRA =
INSTALL?=install
DOC_REF = origin/man
@@ -71,30 +73,44 @@ doc.dep : $(wildcard *.txt) build-docdep.perl
-include doc.dep
-git.7: README
+cmds_txt = cmds-ancillaryinterrogators.txt \
+ cmds-ancillarymanipulators.txt \
+ cmds-mainporcelain.txt \
+ cmds-plumbinginterrogators.txt \
+ cmds-plumbingmanipulators.txt \
+ cmds-synchingrepositories.txt \
+ cmds-synchelpers.txt \
+ cmds-purehelpers.txt \
+ cmds-foreignscminterface.txt
-README: ../README
- cp $< $@
+$(cmds_txt): cmd-list.perl $(MAN1_TXT)
+ perl ./cmd-list.perl
+git.7 git.html: git.txt core-intro.txt
clean:
- rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep README
+ rm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep
+ rm -f $(cmds_txt)
%.html : %.txt
- asciidoc -b xhtml11 -d manpage -f asciidoc.conf $<
+ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf $(ASCIIDOC_EXTRA) $<
%.1 %.7 : %.xml
xmlto -m callouts.xsl man $<
%.xml : %.txt
- asciidoc -b docbook -d manpage -f asciidoc.conf $<
+ $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf $<
-git.html: git.txt README
+user-manual.xml: user-manual.txt user-manual.conf
+ $(ASCIIDOC) -b docbook -d book $<
+
+user-manual.html: user-manual.xml
+ xmlto html-nochunks $<
glossary.html : glossary.txt sort_glossary.pl
cat $< | \
perl sort_glossary.pl | \
- asciidoc -b xhtml11 - > glossary.html
+ $(ASCIIDOC) -b xhtml11 - > glossary.html
howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
rm -f $@+ $@
@@ -102,13 +118,13 @@ howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
mv $@+ $@
$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
- asciidoc -b xhtml11 $*.txt
+ $(ASCIIDOC) -b xhtml11 $*.txt
WEBDOC_DEST = /pub/software/scm/git/docs
$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
rm -f $@+ $@
- sed -e '1,/^$$/d' $< | asciidoc -b xhtml11 - >$@+
+ sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+
mv $@+ $@
install-webdoc : html
diff --git a/Documentation/RelNotes-1.5.0.txt b/Documentation/RelNotes-1.5.0.txt
new file mode 100644
index 0000000000..84e7eaf3c8
--- /dev/null
+++ b/Documentation/RelNotes-1.5.0.txt
@@ -0,0 +1,468 @@
+GIT v1.5.0 Release Notes
+========================
+
+Old news
+--------
+
+This section is for people who are upgrading from ancient
+versions of git. Although all of the changes in this section
+happened before the current v1.4.4 release, they are summarized
+here in the v1.5.0 release notes for people who skipped earlier
+versions.
+
+As of git v1.5.0 there are some optional features that changes
+the repository to allow data to be stored and transferred more
+efficiently. These features are not enabled by default, as they
+will make the repository unusable with older versions of git.
+Specifically, the available options are:
+
+ - There is a configuration variable core.legacyheaders that
+ changes the format of loose objects so that they are more
+ efficient to pack and to send out of the repository over git
+ native protocol, since v1.4.2. However, loose objects
+ written in the new format cannot be read by git older than
+ that version; people fetching from your repository using
+ older clients over dumb transports (e.g. http) using older
+ versions of git will also be affected.
+
+ - Since v1.4.3, configuration repack.usedeltabaseoffset allows
+ packfile to be created in more space efficient format, which
+ cannot be read by git older than that version.
+
+The above two are not enabled by default and you explicitly have
+to ask for them, because these two features make repositories
+unreadable by older versions of git, and in v1.5.0 we still do
+not enable them by default for the same reason. We will change
+this default probably 1 year after 1.4.2's release, when it is
+reasonable to expect everybody to have new enough version of
+git.
+
+ - 'git pack-refs' appeared in v1.4.4; this command allows tags
+ to be accessed much more efficiently than the traditional
+ 'one-file-per-tag' format. Older git-native clients can
+ still fetch from a repository that packed and pruned refs
+ (the server side needs to run the up-to-date version of git),
+ but older dumb transports cannot. Packing of refs is done by
+ an explicit user action, either by use of "git pack-refs
+ --prune" command or by use of "git gc" command.
+
+ - 'git -p' to paginate anything -- many commands do pagination
+ by default on a tty. Introduced between v1.4.1 and v1.4.2;
+ this may surprise old timers.
+
+ - 'git archive' superseded 'git tar-tree' in v1.4.3;
+
+ - 'git cvsserver' was new invention in v1.3.0;
+
+ - 'git repo-config', 'git grep', 'git rebase' and 'gitk' were
+ seriously enhanced during v1.4.0 timeperiod.
+
+ - 'gitweb' became part of git.git during v1.4.0 timeperiod and
+ seriously modified since then.
+
+ - reflog is an v1.4.0 invention. This allows you to name a
+ revision that a branch used to be at (e.g. "git diff
+ master@{yesterday} master" allows you to see changes since
+ yesterday's tip of the branch).
+
+
+Updates in v1.5.0 since v1.4.4 series
+-------------------------------------
+
+* Index manipulation
+
+ - git-add is to add contents to the index (aka "staging area"
+ for the next commit), whether the file the contents happen to
+ be is an existing one or a newly created one.
+
+ - git-add without any argument does not add everything
+ anymore. Use 'git-add .' instead. Also you can add
+ otherwise ignored files with an -f option.
+
+ - git-add tries to be more friendly to users by offering an
+ interactive mode ("git-add -i").
+
+ - git-commit <path> used to refuse to commit if <path> was
+ different between HEAD and the index (i.e. update-index was
+ used on it earlier). This check was removed.
+
+ - git-rm is much saner and safer. It is used to remove paths
+ from both the index file and the working tree, and makes sure
+ you are not losing any local modification before doing so.
+
+ - git-reset <tree> <paths>... can be used to revert index
+ entries for selected paths.
+
+ - git-update-index is much less visible. Many suggestions to
+ use the command in git output and documentation have now been
+ replaced by simpler commands such as "git add" or "git rm".
+
+
+* Repository layout and objects transfer
+
+ - The data for origin repository is stored in the configuration
+ file $GIT_DIR/config, not in $GIT_DIR/remotes/, for newly
+ created clones. The latter is still supported and there is
+ no need to convert your existing repository if you are
+ already comfortable with your workflow with the layout.
+
+ - git-clone always uses what is known as "separate remote"
+ layout for a newly created repository with a working tree.
+
+ A repository with the separate remote layout starts with only
+ one default branch, 'master', to be used for your own
+ development. Unlike the traditional layout that copied all
+ the upstream branches into your branch namespace (while
+ renaming their 'master' to your 'origin'), the new layout
+ puts upstream branches into local "remote-tracking branches"
+ with their own namespace. These can be referenced with names
+ such as "origin/$upstream_branch_name" and are stored in
+ .git/refs/remotes rather than .git/refs/heads where normal
+ branches are stored.
+
+ This layout keeps your own branch namespace less cluttered,
+ avoids name collision with your upstream, makes it possible
+ to automatically track new branches created at the remote
+ after you clone from it, and makes it easier to interact with
+ more than one remote repository (you can use "git remote" to
+ add other repositories to track). There might be some
+ surprises:
+
+ * 'git branch' does not show the remote tracking branches.
+ It only lists your own branches. Use '-r' option to view
+ the tracking branches.
+
+ * If you are forking off of a branch obtained from the
+ upstream, you would have done something like 'git branch
+ my-next next', because traditional layout dropped the
+ tracking branch 'next' into your own branch namespace.
+ With the separate remote layout, you say 'git branch next
+ origin/next', which allows you to use the matching name
+ 'next' for your own branch. It also allows you to track a
+ remote other than 'origin' (i.e. where you initially cloned
+ from) and fork off of a branch from there the same way
+ (e.g. "git branch mingw j6t/master").
+
+ Repositories initialized with the traditional layout continue
+ to work.
+
+ - New branches that appear on the origin side after a clone is
+ made are also tracked automatically. This is done with an
+ wildcard refspec "refs/heads/*:refs/remotes/origin/*", which
+ older git does not understand, so if you clone with 1.5.0,
+ you would need to downgrade remote.*.fetch in the
+ configuration file to specify each branch you are interested
+ in individually if you plan to fetch into the repository with
+ older versions of git (but why would you?).
+
+ - Similarly, wildcard refspec "refs/heads/*:refs/remotes/me/*"
+ can be given to "git-push" command to update the tracking
+ branches that is used to track the repository you are pushing
+ from on the remote side.
+
+ - git-branch and git-show-branch know remote tracking branches
+ (use the command line switch "-r" to list only tracked branches).
+
+ - git-push can now be used to delete a remote branch or a tag.
+ This requires the updated git on the remote side (use "git
+ push <remote> :refs/heads/<branch>" to delete "branch").
+
+ - git-push more aggressively keeps the transferred objects
+ packed. Earlier we recommended to monitor amount of loose
+ objects and repack regularly, but you should repack when you
+ accumulated too many small packs this way as well. Updated
+ git-count-objects helps you with this.
+
+ - git-fetch also more aggressively keeps the transferred objects
+ packed. This behavior of git-push and git-fetch can be
+ tweaked with a single configuration transfer.unpacklimit (but
+ usually there should not be any need for a user to tweak it).
+
+ - A new command, git-remote, can help you manage your remote
+ tracking branch definitions.
+
+ - You may need to specify explicit paths for upload-pack and/or
+ receive-pack due to your ssh daemon configuration on the
+ other end. This can now be done via remote.*.uploadpack and
+ remote.*.receivepack configuration.
+
+
+* Bare repositories
+
+ - Certain commands change their behavior in a bare repository
+ (i.e. a repository without associated working tree). We use
+ a fairly conservative heuristic (if $GIT_DIR is ".git", or
+ ends with "/.git", the repository is not bare) to decide if a
+ repository is bare, but "core.bare" configuration variable
+ can be used to override the heuristic when it misidentifies
+ your repository.
+
+ - git-fetch used to complain updating the current branch but
+ this is now allowed for a bare repository. So is the use of
+ 'git-branch -f' to update the current branch.
+
+ - Porcelain-ish commands that require a working tree refuses to
+ work in a bare repository.
+
+
+* Reflog
+
+ - Reflog records the history from the view point of the local
+ repository. In other words, regardless of the real history,
+ the reflog shows the history as seen by one particular
+ repository (this enables you to ask "what was the current
+ revision in _this_ repository, yesterday at 1pm?"). This
+ facility is enabled by default for repositories with working
+ trees, and can be accessed with the "branch@{time}" and
+ "branch@{Nth}" notation.
+
+ - "git show-branch" learned showing the reflog data with the
+ new -g option. "git log" has -s option to view reflog
+ entries in a more verbose manner.
+
+ - git-branch knows how to rename branches and moves existing
+ reflog data from the old branch to the new one.
+
+ - In addition to the reflog support in v1.4.4 series, HEAD
+ reference maintains its own log. "HEAD@{5.minutes.ago}"
+ means the commit you were at 5 minutes ago, which takes
+ branch switching into account. If you want to know where the
+ tip of your current branch was at 5 minutes ago, you need to
+ explicitly say its name (e.g. "master@{5.minutes.ago}") or
+ omit the refname altogether i.e. "@{5.minutes.ago}".
+
+ - The commits referred to by reflog entries are now protected
+ against pruning. The new command "git reflog expire" can be
+ used to truncate older reflog entries and entries that refer
+ to commits that have been pruned away previously with older
+ versions of git.
+
+ Existing repositories that have been using reflog may get
+ complaints from fsck-objects and may not be able to run
+ git-repack, if you had run git-prune from older git; please
+ run "git reflog expire --stale-fix --all" first to remove
+ reflog entries that refer to commits that are no longer in
+ the repository when that happens.
+
+
+* Crufts removal
+
+ - We used to say "old commits are retrievable using reflog and
+ 'master@{yesterday}' syntax as long as you haven't run
+ git-prune". We no longer have to say the latter half of the
+ above sentence, as git-prune does not remove things reachable
+ from reflog entries.
+
+ - 'git-prune' by default does not remove _everything_
+ unreachable, as there is a one-day grace period built-in.
+
+ - There is a toplevel garbage collector script, 'git-gc', that
+ runs periodic cleanup functions, including 'git-repack -a -d',
+ 'git-reflog expire', 'git-pack-refs --prune', and 'git-rerere
+ gc'.
+
+ - The output from fsck ("fsck-objects" is called just "fsck"
+ now, but the old name continues to work) was needlessly
+ alarming in that it warned missing objects that are reachable
+ only from dangling objects. This has been corrected and the
+ output is much more useful.
+
+
+* Detached HEAD
+
+ - You can use 'git-checkout' to check out an arbitrary revision
+ or a tag as well, instead of named branches. This will
+ dissociate your HEAD from the branch you are currently on.
+
+ A typical use of this feature is to "look around". E.g.
+
+ $ git checkout v2.6.16
+ ... compile, test, etc.
+ $ git checkout v2.6.17
+ ... compile, test, etc.
+
+ - After detaching your HEAD, you can go back to an existing
+ branch with usual "git checkout $branch". Also you can
+ start a new branch using "git checkout -b $newbranch" to
+ start a new branch at that commit.
+
+ - You can even pull from other repositories, make merges and
+ commits while your HEAD is detached. Also you can use "git
+ reset" to jump to arbitrary commit, while still keeping your
+ HEAD detached.
+
+ Going back to attached state (i.e. on a particular branch) by
+ "git checkout $branch" can lose the current stat you arrived
+ in these ways, and "git checkout" refuses when the detached
+ HEAD is not pointed by any existing ref (an existing branch,
+ a remote tracking branch or a tag). This safety can be
+ overridden with "git checkout -f $branch".
+
+
+* Packed refs
+
+ - Repositories with hundreds of tags have been paying large
+ overhead, both in storage and in runtime, due to the
+ traditional one-ref-per-file format. A new command,
+ git-pack-refs, can be used to "pack" them in more efficient
+ representation (you can let git-gc do this for you).
+
+ - Clones and fetches over dumb transports are now aware of
+ packed refs and can download from repositories that use
+ them.
+
+
+* Configuration
+
+ - configuration related to color setting are consolidated under
+ color.* namespace (older diff.color.*, status.color.* are
+ still supported).
+
+ - 'git-repo-config' command is accessible as 'git-config' now.
+
+
+* Updated features
+
+ - git-describe uses better criteria to pick a base ref. It
+ used to pick the one with the newest timestamp, but now it
+ picks the one that is topologically the closest (that is,
+ among ancestors of commit C, the ref T that has the shortest
+ output from "git-rev-list T..C" is chosen).
+
+ - git-describe gives the number of commits since the base ref
+ between the refname and the hash suffix. E.g. the commit one
+ before v2.6.20-rc6 in the kernel repository is:
+
+ v2.6.20-rc5-306-ga21b069
+
+ which tells you that its object name begins with a21b069,
+ v2.6.20-rc5 is an ancestor of it (meaning, the commit
+ contains everything -rc5 has), and there are 306 commits
+ since v2.6.20-rc5.
+
+ - git-describe with --abbrev=0 can be used to show only the
+ name of the base ref.
+
+ - git-blame learned a new option, --incremental, that tells it
+ to output the blames as they are assigned. A sample script
+ to use it is also included as contrib/blameview.
+
+ - git-blame starts annotating from the working tree by default.
+
+
+* Less external dependency
+
+ - We no longer require the "merge" program from the RCS suite.
+ All 3-way file-level merges are now done internally.
+
+ - The original implementation of git-merge-recursive which was
+ in Python has been removed; we have a C implementation of it
+ now.
+
+ - git-shortlog is no longer a Perl script. It no longer
+ requires output piped from git-log; it can accept revision
+ parameters directly on the command line.
+
+
+* I18n
+
+ - We have always encouraged the commit message to be encoded in
+ UTF-8, but the users are allowed to use legacy encoding as
+ appropriate for their projects. This will continue to be the
+ case. However, a non UTF-8 commit encoding _must_ be
+ explicitly set with i18n.commitencoding in the repository
+ where a commit is made; otherwise git-commit-tree will
+ complain if the log message does not look like a valid UTF-8
+ string.
+
+ - The value of i18n.commitencoding in the originating
+ repository is recorded in the commit object on the "encoding"
+ header, if it is not UTF-8. git-log and friends notice this,
+ and reencodes the message to the log output encoding when
+ displaying, if they are different. The log output encoding
+ is determined by "git log --encoding=<encoding>",
+ i18n.logoutputencoding configuration, or i18n.commitencoding
+ configuration, in the decreasing order of preference, and
+ defaults to UTF-8.
+
+ - Tools for e-mailed patch application now default to -u
+ behavior; i.e. it always re-codes from the e-mailed encoding
+ to the encoding specified with i18n.commitencoding. This
+ unfortunately forces projects that have happily been using a
+ legacy encoding without setting i18n.commitencoding to set
+ the configuration, but taken with other improvement, please
+ excuse us for this very minor one-time inconvenience.
+
+
+* e-mailed patches
+
+ - See the above I18n section.
+
+ - git-format-patch now enables --binary without being asked.
+ git-am does _not_ default to it, as sending binary patch via
+ e-mail is unusual and is harder to review than textual
+ patches and it is prudent to require the person who is
+ applying the patch to explicitly ask for it.
+
+ - The default suffix for git-format-patch output is now ".patch",
+ not ".txt". This can be changed with --suffix=.txt option,
+ or setting the config variable "format.suffix" to ".txt".
+
+
+* Foreign SCM interfaces
+
+ - git-svn now requires the Perl SVN:: libraries, the
+ command-line backend was too slow and limited.
+
+ - the 'commit' subcommand of git-svn has been renamed to
+ 'set-tree', and 'dcommit' is the recommended replacement for
+ day-to-day work.
+
+ - git fast-import backend.
+
+
+* User support
+
+ - Quite a lot of documentation updates.
+
+ - Bash completion scripts have been updated heavily.
+
+ - Better error messages for often used Porcelainish commands.
+
+ - Git GUI. This is a simple Tk based graphical interface for
+ common Git operations.
+
+
+* Sliding mmap
+
+ - We used to assume that we can mmap the whole packfile while
+ in use, but with a large project this consumes huge virtual
+ memory space and truly huge ones would not fit in the
+ userland address space on 32-bit platforms. We now mmap huge
+ packfile in pieces to avoid this problem.
+
+
+* Shallow clones
+
+ - There is a partial support for 'shallow' repositories that
+ keeps only recent history. A 'shallow clone' is created by
+ specifying how deep that truncated history should be
+ (e.g. "git clone --depth=5 git://some.where/repo.git").
+
+ Currently a shallow repository has number of limitations:
+
+ - Cloning and fetching _from_ a shallow clone are not
+ supported (nor tested -- so they might work by accident but
+ they are not expected to).
+
+ - Pushing from nor into a shallow clone are not expected to
+ work.
+
+ - Merging inside a shallow repository would work as long as a
+ merge base is found in the recent history, but otherwise it
+ will be like merging unrelated histories and may result in
+ huge conflicts.
+
+ but this would be more than adequate for people who want to
+ look at near the tip of a big project with a deep history and
+ send patches in e-mail format.
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 646b6e7331..285781d9db 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -23,7 +23,8 @@ probably need to split up your commit to finer grained pieces.
Oh, another thing. I am picky about whitespaces. Make sure your
changes do not trigger errors with the sample pre-commit hook shipped
-in templates/hooks--pre-commit.
+in templates/hooks--pre-commit. To help ensure this does not happen,
+run git diff --check on your changes before you commit.
(2) Generate your patch using git tools out of your commits.
@@ -72,7 +73,9 @@ other than the commit message itself. Place such "cover letter"
material between the three dash lines and the diffstat.
Do not attach the patch as a MIME attachment, compressed or not.
-Do not let your e-mail client send quoted-printable. Many
+Do not let your e-mail client send quoted-printable. Do not let
+your e-mail client send format=flowed which would destroy
+whitespaces in your patches. Many
popular e-mail applications will not always transmit a MIME
attachment as plain text, making it impossible to comment on
your code. A MIME attachment also takes a bit more time to
@@ -312,3 +315,35 @@ settings but I haven't tried, yet.
mail.identity.default.compose_html => false
mail.identity.id?.compose_html => false
+
+Gnus
+----
+
+'|' in the *Summary* buffer can be used to pipe the current
+message to an external program, and this is a handy way to drive
+"git am". However, if the message is MIME encoded, what is
+piped into the program is the representation you see in your
+*Article* buffer after unwrapping MIME. This is often not what
+you would want for two reasons. It tends to screw up non ASCII
+characters (most notably in people's names), and also
+whitespaces (fatal in patches). Running 'C-u g' to display the
+message in raw form before using '|' to run the pipe can work
+this problem around.
+
+
+KMail
+-----
+
+This should help you to submit patches inline using KMail.
+
+1) Prepare the patch as a text file.
+
+2) Click on New Mail.
+
+3) Go under "Options" in the Composer window and be sure that
+"Word wrap" is not set.
+
+4) Use Message -> Insert file... and insert the patch.
+
+5) Back in the compose window: add whatever other text you wish to the
+message, complete the addressing and subject fields, and press send.
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
new file mode 100755
index 0000000000..d4fd72db4c
--- /dev/null
+++ b/Documentation/cmd-list.perl
@@ -0,0 +1,185 @@
+#
+
+sub format_one {
+ my ($out, $name) = @_;
+ my ($state, $description);
+ open I, '<', "$name.txt" or die "No such file $name.txt";
+ while (<I>) {
+ if (/^NAME$/) {
+ $state = 1;
+ next;
+ }
+ if ($state == 1 && /^----$/) {
+ $state = 2;
+ next;
+ }
+ next if ($state != 2);
+ chomp;
+ $description = $_;
+ last;
+ }
+ close I;
+ if (!defined $description) {
+ die "No description found in $name.txt";
+ }
+ if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) {
+ print $out "gitlink:$name\[1\]::\n";
+ print $out "\t$text.\n\n";
+ }
+ else {
+ die "Description does not match $name: $description";
+ }
+}
+
+my %cmds = ();
+while (<DATA>) {
+ next if /^#/;
+
+ chomp;
+ my ($name, $cat) = /^(\S+)\s+(.*)$/;
+ push @{$cmds{$cat}}, $name;
+}
+
+for my $cat (qw(ancillaryinterrogators
+ ancillarymanipulators
+ mainporcelain
+ plumbinginterrogators
+ plumbingmanipulators
+ synchingrepositories
+ foreignscminterface
+ purehelpers
+ synchelpers)) {
+ my $out = "cmds-$cat.txt";
+ open O, '>', "$out+" or die "Cannot open output file $out+";
+ for (@{$cmds{$cat}}) {
+ format_one(\*O, $_);
+ }
+ close O;
+ rename "$out+", "$out";
+}
+
+__DATA__
+git-add mainporcelain
+git-am mainporcelain
+git-annotate ancillaryinterrogators
+git-applymbox ancillaryinterrogators
+git-applypatch purehelpers
+git-apply plumbingmanipulators
+git-archimport foreignscminterface
+git-archive mainporcelain
+git-bisect mainporcelain
+git-blame ancillaryinterrogators
+git-branch mainporcelain
+git-cat-file plumbinginterrogators
+git-checkout-index plumbingmanipulators
+git-checkout mainporcelain
+git-check-ref-format purehelpers
+git-cherry ancillaryinterrogators
+git-cherry-pick mainporcelain
+git-clean mainporcelain
+git-clone mainporcelain
+git-commit mainporcelain
+git-commit-tree plumbingmanipulators
+git-convert-objects ancillarymanipulators
+git-count-objects ancillaryinterrogators
+git-cvsexportcommit foreignscminterface
+git-cvsimport foreignscminterface
+git-cvsserver foreignscminterface
+git-daemon synchingrepositories
+git-describe mainporcelain
+git-diff-files plumbinginterrogators
+git-diff-index plumbinginterrogators
+git-diff mainporcelain
+git-diff-tree plumbinginterrogators
+git-fast-import ancillarymanipulators
+git-fetch mainporcelain
+git-fetch-pack synchingrepositories
+git-fmt-merge-msg purehelpers
+git-for-each-ref plumbinginterrogators
+git-format-patch mainporcelain
+git-fsck ancillaryinterrogators
+git-gc mainporcelain
+git-get-tar-commit-id ancillaryinterrogators
+git-grep mainporcelain
+git-hash-object plumbingmanipulators
+git-http-fetch synchelpers
+git-http-push synchelpers
+git-imap-send foreignscminterface
+git-index-pack plumbingmanipulators
+git-init mainporcelain
+git-instaweb ancillaryinterrogators
+gitk mainporcelain
+git-local-fetch synchingrepositories
+git-log mainporcelain
+git-lost-found ancillarymanipulators
+git-ls-files plumbinginterrogators
+git-ls-remote plumbinginterrogators
+git-ls-tree plumbinginterrogators
+git-mailinfo purehelpers
+git-mailsplit purehelpers
+git-merge-base plumbinginterrogators
+git-merge-file plumbingmanipulators
+git-merge-index plumbingmanipulators
+git-merge mainporcelain
+git-merge-one-file purehelpers
+git-merge-tree ancillaryinterrogators
+git-mktag plumbingmanipulators
+git-mktree plumbingmanipulators
+git-mv mainporcelain
+git-name-rev plumbinginterrogators
+git-pack-objects plumbingmanipulators
+git-pack-redundant plumbinginterrogators
+git-pack-refs ancillarymanipulators
+git-parse-remote synchelpers
+git-patch-id purehelpers
+git-peek-remote purehelpers
+git-prune ancillarymanipulators
+git-prune-packed plumbingmanipulators
+git-pull mainporcelain
+git-push mainporcelain
+git-quiltimport foreignscminterface
+git-read-tree plumbingmanipulators
+git-rebase mainporcelain
+git-receive-pack synchelpers
+git-reflog ancillarymanipulators
+git-relink ancillarymanipulators
+git-repack ancillarymanipulators
+git-config ancillarymanipulators
+git-request-pull foreignscminterface
+git-rerere ancillaryinterrogators
+git-reset mainporcelain
+git-revert mainporcelain
+git-rev-list plumbinginterrogators
+git-rev-parse ancillaryinterrogators
+git-rm mainporcelain
+git-runstatus ancillaryinterrogators
+git-send-email foreignscminterface
+git-send-pack synchingrepositories
+git-shell synchelpers
+git-shortlog mainporcelain
+git-show mainporcelain
+git-show-branch ancillaryinterrogators
+git-show-index plumbinginterrogators
+git-show-ref plumbinginterrogators
+git-sh-setup purehelpers
+git-ssh-fetch synchingrepositories
+git-ssh-upload synchingrepositories
+git-status mainporcelain
+git-stripspace purehelpers
+git-svn foreignscminterface
+git-svnimport foreignscminterface
+git-symbolic-ref plumbingmanipulators
+git-tag mainporcelain
+git-tar-tree plumbinginterrogators
+git-unpack-file plumbinginterrogators
+git-unpack-objects plumbingmanipulators
+git-update-index plumbingmanipulators
+git-update-ref plumbingmanipulators
+git-update-server-info synchingrepositories
+git-upload-archive synchelpers
+git-upload-pack synchelpers
+git-var plumbinginterrogators
+git-verify-pack plumbinginterrogators
+git-verify-tag ancillaryinterrogators
+git-whatchanged ancillaryinterrogators
+git-write-tree plumbingmanipulators
diff --git a/Documentation/config.txt b/Documentation/config.txt
index b4aae0d0ae..38655350f2 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2,21 +2,84 @@ CONFIGURATION FILE
------------------
The git configuration file contains a number of variables that affect
-the git command's behavior. They can be used by both the git plumbing
+the git command's behavior. `.git/config` file for each repository
+is used to store the information for that repository, and
+`$HOME/.gitconfig` is used to store per user information to give
+fallback values for `.git/config` file.
+
+They can be used by both the git plumbing
and the porcelains. The variables are divided into sections, where
in the fully qualified variable name the variable itself is the last
dot-separated segment and the section name is everything before the last
dot. The variable names are case-insensitive and only alphanumeric
characters are allowed. Some variables may appear multiple times.
+Syntax
+~~~~~~
+
The syntax is fairly flexible and permissive; whitespaces are mostly
-ignored. The '#' and ';' characters begin comments to the end of line,
-blank lines are ignored, lines containing strings enclosed in square
-brackets start sections and all the other lines are recognized
-as setting variables, in the form 'name = value'. If there is no equal
-sign on the line, the entire line is taken as 'name' and the variable
-is recognized as boolean "true". String values may be entirely or partially
-enclosed in double quotes; some variables may require special value format.
+ignored. The '#' and ';' characters begin comments to the end of line,
+blank lines are ignored.
+
+The file consists of sections and variables. A section begins with
+the name of the section in square brackets and continues until the next
+section begins. Section names are not case sensitive. Only alphanumeric
+characters, '`-`' and '`.`' are allowed in section names. Each variable
+must belong to some section, which means that there must be section
+header before first setting of a variable.
+
+Sections can be further divided into subsections. To begin a subsection
+put its name in double quotes, separated by space from the section name,
+in the section header, like in example below:
+
+--------
+ [section "subsection"]
+
+--------
+
+Subsection names can contain any characters except newline (doublequote
+'`"`' and backslash have to be escaped as '`\"`' and '`\\`',
+respectively) and are case sensitive. Section header cannot span multiple
+lines. Variables may belong directly to a section or to a given subsection.
+You can have `[section]` if you have `[section "subsection"]`, but you
+don't need to.
+
+There is also (case insensitive) alternative `[section.subsection]` syntax.
+In this syntax subsection names follow the same restrictions as for section
+name.
+
+All the other lines are recognized as setting variables, in the form
+'name = value'. If there is no equal sign on the line, the entire line
+is taken as 'name' and the variable is recognized as boolean "true".
+The variable names are case-insensitive and only alphanumeric
+characters and '`-`' are allowed. There can be more than one value
+for a given variable; we say then that variable is multivalued.
+
+Leading and trailing whitespace in a variable value is discarded.
+Internal whitespace within a variable value is retained verbatim.
+
+The values following the equals sign in variable assign are all either
+a string, an integer, or a boolean. Boolean values may be given as yes/no,
+0/1 or true/false. Case is not significant in boolean values, when
+converting value to the canonical form using '--bool' type specifier;
+`git-config` will ensure that the output is "true" or "false".
+
+String values may be entirely or partially enclosed in double quotes.
+You need to enclose variable value in double quotes if you want to
+preserve leading or trailing whitespace, or if variable value contains
+beginning of comment characters (if it contains '#' or ';').
+Double quote '`"`' and backslash '`\`' characters in variable value must
+be escaped: use '`\"`' for '`"`' and '`\\`' for '`\`'.
+
+The following escape sequences (beside '`\"`' and '`\\`') are recognized:
+'`\n`' for newline character (NL), '`\t`' for horizontal tabulation (HT, TAB)
+and '`\b`' for backspace (BS). No other char escape sequence, nor octal
+char sequences are valid.
+
+Variable value ending in a '`\`' is continued on the next line in the
+customary UNIX fashion.
+
+Some variables may require special value format.
Example
~~~~~~~
@@ -35,6 +98,10 @@ Example
remote = origin
merge = refs/heads/devel
+ # Proxy settings
+ [core]
+ gitProxy="ssh" for "ssh://kernel.org/"
+ gitProxy=default-proxy ; for the rest
Variables
~~~~~~~~~
@@ -100,7 +167,7 @@ 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 gitlink:git-init-db[1]. False by default.
+ reported by umask(2). See gitlink:git-init[1]. False by default.
core.warnAmbiguousRefs::
If true, git will warn you if the ref name you passed it is ambiguous
@@ -155,6 +222,12 @@ alias.*::
spaces, the usual shell quoting and escaping is supported.
quote pair and a backslash can be used to quote them.
+ If the alias expansion is prefixed with an exclamation point,
+ it will be treated as a shell command. For example, defining
+ "alias.new = !gitk --all --not ORIG_HEAD", the invocation
+ "git new" is equivalent to running the shell command
+ "gitk --all --not ORIG_HEAD".
+
apply.whitespace::
Tells `git-apply` how to handle whitespaces, in the same way
as the '--whitespace' option. See gitlink:git-apply[1].
@@ -183,10 +256,15 @@ color.branch.<slot>::
Use customized color for branch coloration. `<slot>` is one of
`current` (the current branch), `local` (a local branch),
`remote` (a tracking branch in refs/remotes/), `plain` (other
- refs), or `reset` (the normal terminal color). The value for
- these configuration variables can be one of: `normal`, `bold`,
- `dim`, `ul`, `blink`, `reverse`, `reset`, `black`, `red`,
- `green`, `yellow`, `blue`, `magenta`, `cyan`, or `white`.
+ refs).
++
+The value for these configuration variables is a list of colors (at most
+two) and attributes (at most one), separated by spaces. The colors
+accepted are `normal`, `black`, `red`, `green`, `yellow`, `blue`,
+`magenta`, `cyan` and `white`; the attributes are `bold`, `dim`, `ul`,
+`blink` and `reverse`. The first color given is the foreground; the
+second is the background. The position of the attribute, if any,
+doesn't matter.
color.diff::
When true (or `always`), always use colors in patch.
@@ -194,12 +272,13 @@ color.diff::
colors only when the output is to the terminal.
color.diff.<slot>::
- Use customized color for diff colorization. `<slot>`
- specifies which part of the patch to use the specified
- color, and is one of `plain` (context text), `meta`
- (metainformation), `frag` (hunk header), `old` (removed
- lines), or `new` (added lines). The values of these
- variables may be specified as in color.branch.<slot>.
+ Use customized color for diff colorization. `<slot>` specifies
+ which part of the patch to use the specified color, and is one
+ of `plain` (context text), `meta` (metainformation), `frag`
+ (hunk header), `old` (removed lines), `new` (added lines),
+ `commit` (commit headers), or `whitespace` (highlighting dubious
+ whitespace). The values of these variables may be specified as
+ in color.branch.<slot>.
color.pager::
A boolean to enable/disable colored output when the pager is in
@@ -228,10 +307,31 @@ diff.renames::
will enable basic rename detection. If set to "copies" or
"copy", it will detect copies, as well.
+fetch.unpackLimit::
+ If the number of objects fetched over the git native
+ transfer is below this
+ limit, then the objects will be unpacked into loose object
+ files. However if the number of received objects equals or
+ exceeds this limit then the received pack will be stored as
+ a pack, after adding any missing delta bases. Storing the
+ pack from a push can make the push operation complete faster,
+ especially on slow filesystems.
+
format.headers::
Additional email headers to include in a patch to be submitted
by mail. See gitlink:git-format-patch[1].
+gc.packrefs::
+ `git gc` does not run `git pack-refs` in a bare repository by
+ default so that older dumb-transport clients can still fetch
+ 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`.
+
gc.reflogexpire::
`git reflog expire` removes reflog entries older than
this time; defaults to 90 days.
@@ -321,6 +421,13 @@ merge.summary::
Whether to include summaries of merged commits in newly created
merge commit messages. False by default.
+merge.verbosity::
+ Controls the amount of output shown by the recursive merge
+ strategy. Level 0 outputs nothing except a final error
+ message if conflicts were detected. Level 1 outputs only
+ conflicts, 2 outputs conflicts and file changes. Level 5 and
+ above outputs debugging information. The default is level 2.
+
pack.window::
The size of the window used by gitlink:git-pack-objects[1] when no
window size is given on the command line. Defaults to 10.
@@ -344,6 +451,14 @@ remote.<name>.push::
The default set of "refspec" for gitlink:git-push[1]. See
gitlink:git-push[1].
+remote.<name>.receivepack::
+ The default program to execute on the remote side when pushing. See
+ option \--exec of gitlink:git-push[1].
+
+remote.<name>.uploadpack::
+ The default program to execute on the remote side when fetching. See
+ option \--exec of gitlink:git-fetch-pack[1].
+
repack.usedeltabaseoffset::
Allow gitlink:git-repack[1] to create packs that uses
delta-base offset. Defaults to false.
@@ -377,6 +492,13 @@ user.name::
Can be overridden by the 'GIT_AUTHOR_NAME' and 'GIT_COMMITTER_NAME'
environment variables. See gitlink:git-commit-tree[1].
+user.signingkey::
+ If gitlink:git-tag[1] is not selecting the key you want it to
+ automatically when creating a signed tag, you can override the
+ default selection with this variable. This option is passed
+ unchanged to gpg's --local-user parameter, so you may specify a key
+ using any method that gpg supports.
+
whatchanged.difftree::
The default gitlink:git-diff-tree[1] arguments to be used
for gitlink:git-whatchanged[1].
@@ -400,3 +522,8 @@ receive.denyNonFastForwards::
even if that push is forced. This configuration variable is
set when initializing a shared repository.
+transfer.unpackLimit::
+ When `fetch.unpackLimit` or `receive.unpackLimit` are
+ not set, the value of this variable is used instead.
+
+
diff --git a/Documentation/core-intro.txt b/Documentation/core-intro.txt
new file mode 100644
index 0000000000..24b060b91e
--- /dev/null
+++ b/Documentation/core-intro.txt
@@ -0,0 +1,591 @@
+////////////////////////////////////////////////////////////////
+
+ GIT - the stupid content tracker
+
+////////////////////////////////////////////////////////////////
+
+"git" can mean anything, depending on your mood.
+
+ - random three-letter combination that is pronounceable, and not
+ actually used by any common UNIX command. The fact that it is a
+ mispronunciation of "get" may or may not be relevant.
+ - stupid. contemptible and despicable. simple. Take your pick from the
+ dictionary of slang.
+ - "global information tracker": you're in a good mood, and it actually
+ works for you. Angels sing, and a light suddenly fills the room.
+ - "goddamn idiotic truckload of sh*t": when it breaks
+
+This is a (not so) stupid but extremely fast directory content manager.
+It doesn't do a whole lot at its core, but what it 'does' do is track
+directory contents efficiently.
+
+There are two object abstractions: the "object database", and the
+"current directory cache" aka "index".
+
+The Object Database
+~~~~~~~~~~~~~~~~~~~
+The object database is literally just a content-addressable collection
+of objects. All objects are named by their content, which is
+approximated by the SHA1 hash of the object itself. Objects may refer
+to other objects (by referencing their SHA1 hash), and so you can
+build up a hierarchy of objects.
+
+All objects have a statically determined "type" aka "tag", which is
+determined at object creation time, and which identifies the format of
+the object (i.e. how it is used, and how it can refer to other
+objects). There are currently four different object types: "blob",
+"tree", "commit" and "tag".
+
+A "blob" object cannot refer to any other object, and is, like the type
+implies, a pure storage object containing some user data. It is used to
+actually store the file data, i.e. a blob object is associated with some
+particular version of some file.
+
+A "tree" object is an object that ties one or more "blob" objects into a
+directory structure. In addition, a tree object can refer to other tree
+objects, thus creating a directory hierarchy.
+
+A "commit" object ties such directory hierarchies together into
+a DAG of revisions - each "commit" is associated with exactly one tree
+(the directory hierarchy at the time of the commit). In addition, a
+"commit" refers to one or more "parent" commit objects that describe the
+history of how we arrived at that directory hierarchy.
+
+As a special case, a commit object with no parents is called the "root"
+object, and is the point of an initial project commit. Each project
+must have at least one root, and while you can tie several different
+root objects together into one project by creating a commit object which
+has two or more separate roots as its ultimate parents, that's probably
+just going to confuse people. So aim for the notion of "one root object
+per project", even if git itself does not enforce that.
+
+A "tag" object symbolically identifies and can be used to sign other
+objects. It contains the identifier and type of another object, a
+symbolic name (of course!) and, optionally, a signature.
+
+Regardless of object type, all objects share the following
+characteristics: they are all deflated with zlib, and have a header
+that not only specifies their type, but also provides size information
+about the data in the object. It's worth noting that the SHA1 hash
+that is used to name the object is the hash of the original data
+plus this header, so `sha1sum` 'file' does not match the object name
+for 'file'.
+(Historical note: in the dawn of the age of git the hash
+was the sha1 of the 'compressed' object.)
+
+As a result, the general consistency of an object can always be tested
+independently of the contents or the type of the object: all objects can
+be validated by verifying that (a) their hashes match the content of the
+file and (b) the object successfully inflates to a stream of bytes that
+forms a sequence of <ascii type without space> + <space> + <ascii decimal
+size> + <byte\0> + <binary object data>.
+
+The structured objects can further have their structure and
+connectivity to other objects verified. This is generally done with
+the `git-fsck` program, which generates a full dependency graph
+of all objects, and verifies their internal consistency (in addition
+to just verifying their superficial consistency through the hash).
+
+The object types in some more detail:
+
+Blob Object
+~~~~~~~~~~~
+A "blob" object is nothing but a binary blob of data, and doesn't
+refer to anything else. There is no signature or any other
+verification of the data, so while the object is consistent (it 'is'
+indexed by its sha1 hash, so the data itself is certainly correct), it
+has absolutely no other attributes. No name associations, no
+permissions. It is purely a blob of data (i.e. normally "file
+contents").
+
+In particular, since the blob is entirely defined by its data, if two
+files in a directory tree (or in multiple different versions of the
+repository) have the same contents, they will share the same blob
+object. The object is totally independent of its location in the
+directory tree, and renaming a file does not change the object that
+file is associated with in any way.
+
+A blob is typically created when gitlink:git-update-index[1]
+is run, and its data can be accessed by gitlink:git-cat-file[1].
+
+Tree Object
+~~~~~~~~~~~
+The next hierarchical object type is the "tree" object. A tree object
+is a list of mode/name/blob data, sorted by name. Alternatively, the
+mode data may specify a directory mode, in which case instead of
+naming a blob, that name is associated with another TREE object.
+
+Like the "blob" object, a tree object is uniquely determined by the
+set contents, and so two separate but identical trees will always
+share the exact same object. This is true at all levels, i.e. it's
+true for a "leaf" tree (which does not refer to any other trees, only
+blobs) as well as for a whole subdirectory.
+
+For that reason a "tree" object is just a pure data abstraction: it
+has no history, no signatures, no verification of validity, except
+that since the contents are again protected by the hash itself, we can
+trust that the tree is immutable and its contents never change.
+
+So you can trust the contents of a tree to be valid, the same way you
+can trust the contents of a blob, but you don't know where those
+contents 'came' from.
+
+Side note on trees: since a "tree" object is a sorted list of
+"filename+content", you can create a diff between two trees without
+actually having to unpack two trees. Just ignore all common parts,
+and your diff will look right. In other words, you can effectively
+(and efficiently) tell the difference between any two random trees by
+O(n) where "n" is the size of the difference, rather than the size of
+the tree.
+
+Side note 2 on trees: since the name of a "blob" depends entirely and
+exclusively on its contents (i.e. there are no names or permissions
+involved), you can see trivial renames or permission changes by
+noticing that the blob stayed the same. However, renames with data
+changes need a smarter "diff" implementation.
+
+A tree is created with gitlink:git-write-tree[1] and
+its data can be accessed by gitlink:git-ls-tree[1].
+Two trees can be compared with gitlink:git-diff-tree[1].
+
+Commit Object
+~~~~~~~~~~~~~
+The "commit" object is an object that introduces the notion of
+history into the picture. In contrast to the other objects, it
+doesn't just describe the physical state of a tree, it describes how
+we got there, and why.
+
+A "commit" is defined by the tree-object that it results in, the
+parent commits (zero, one or more) that led up to that point, and a
+comment on what happened. Again, a commit is not trusted per se:
+the contents are well-defined and "safe" due to the cryptographically
+strong signatures at all levels, but there is no reason to believe
+that the tree is "good" or that the merge information makes sense.
+The parents do not have to actually have any relationship with the
+result, for example.
+
+Note on commits: unlike real SCM's, commits do not contain
+rename information or file mode change information. All of that is
+implicit in the trees involved (the result tree, and the result trees
+of the parents), and describing that makes no sense in this idiotic
+file manager.
+
+A commit is created with gitlink:git-commit-tree[1] and
+its data can be accessed by gitlink:git-cat-file[1].
+
+Trust
+~~~~~
+An aside on the notion of "trust". Trust is really outside the scope
+of "git", but it's worth noting a few things. First off, since
+everything is hashed with SHA1, you 'can' trust that an object is
+intact and has not been messed with by external sources. So the name
+of an object uniquely identifies a known state - just not a state that
+you may want to trust.
+
+Furthermore, since the SHA1 signature of a commit refers to the
+SHA1 signatures of the tree it is associated with and the signatures
+of the parent, a single named commit specifies uniquely a whole set
+of history, with full contents. You can't later fake any step of the
+way once you have the name of a commit.
+
+So to introduce some real trust in the system, the only thing you need
+to do is to digitally sign just 'one' special note, which includes the
+name of a top-level commit. Your digital signature shows others
+that you trust that commit, and the immutability of the history of
+commits tells others that they can trust the whole history.
+
+In other words, you can easily validate a whole archive by just
+sending out a single email that tells the people the name (SHA1 hash)
+of the top commit, and digitally sign that email using something
+like GPG/PGP.
+
+To assist in this, git also provides the tag object...
+
+Tag Object
+~~~~~~~~~~
+Git provides the "tag" object to simplify creating, managing and
+exchanging symbolic and signed tokens. The "tag" object at its
+simplest simply symbolically identifies another object by containing
+the sha1, type and symbolic name.
+
+However it can optionally contain additional signature information
+(which git doesn't care about as long as there's less than 8k of
+it). This can then be verified externally to git.
+
+Note that despite the tag features, "git" itself only handles content
+integrity; the trust framework (and signature provision and
+verification) has to come from outside.
+
+A tag is created with gitlink:git-mktag[1],
+its data can be accessed by gitlink:git-cat-file[1],
+and the signature can be verified by
+gitlink:git-verify-tag[1].
+
+
+The "index" aka "Current Directory Cache"
+-----------------------------------------
+The index is a simple binary file, which contains an efficient
+representation of a virtual directory content at some random time. It
+does so by a simple array that associates a set of names, dates,
+permissions and content (aka "blob") objects together. The cache is
+always kept ordered by name, and names are unique (with a few very
+specific rules) at any point in time, but the cache has no long-term
+meaning, and can be partially updated at any time.
+
+In particular, the index certainly does not need to be consistent with
+the current directory contents (in fact, most operations will depend on
+different ways to make the index 'not' be consistent with the directory
+hierarchy), but it has three very important attributes:
+
+'(a) it can re-generate the full state it caches (not just the
+directory structure: it contains pointers to the "blob" objects so
+that it can regenerate the data too)'
+
+As a special case, there is a clear and unambiguous one-way mapping
+from a current directory cache to a "tree object", which can be
+efficiently created from just the current directory cache without
+actually looking at any other data. So a directory cache at any one
+time uniquely specifies one and only one "tree" object (but has
+additional data to make it easy to match up that tree object with what
+has happened in the directory)
+
+'(b) it has efficient methods for finding inconsistencies between that
+cached state ("tree object waiting to be instantiated") and the
+current state.'
+
+'(c) it can additionally efficiently represent information about merge
+conflicts between different tree objects, allowing each pathname to be
+associated with sufficient information about the trees involved that
+you can create a three-way merge between them.'
+
+Those are the three ONLY things that the directory cache does. It's a
+cache, and the normal operation is to re-generate it completely from a
+known tree object, or update/compare it with a live tree that is being
+developed. If you blow the directory cache away entirely, you generally
+haven't lost any information as long as you have the name of the tree
+that it described.
+
+At the same time, the index is at the same time also the
+staging area for creating new trees, and creating a new tree always
+involves a controlled modification of the index file. In particular,
+the index file can have the representation of an intermediate tree that
+has not yet been instantiated. So the index can be thought of as a
+write-back cache, which can contain dirty information that has not yet
+been written back to the backing store.
+
+
+
+The Workflow
+------------
+Generally, all "git" operations work on the index file. Some operations
+work *purely* on the index file (showing the current state of the
+index), but most operations move data to and from the index file. Either
+from the database or from the working directory. Thus there are four
+main combinations:
+
+1) working directory -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update the index with information from the working directory with
+the gitlink:git-update-index[1] command. You
+generally update the index information by just specifying the filename
+you want to update, like so:
+
+ git-update-index filename
+
+but to avoid common mistakes with filename globbing etc, the command
+will not normally add totally new entries or remove old entries,
+i.e. it will normally just update existing cache entries.
+
+To tell git that yes, you really do realize that certain files no
+longer exist, or that new files should be added, you
+should use the `--remove` and `--add` flags respectively.
+
+NOTE! A `--remove` flag does 'not' mean that subsequent filenames will
+necessarily be removed: if the files still exist in your directory
+structure, the index will be updated with their new status, not
+removed. The only thing `--remove` means is that update-cache will be
+considering a removed file to be a valid thing, and if the file really
+does not exist any more, it will update the index accordingly.
+
+As a special case, you can also do `git-update-index --refresh`, which
+will refresh the "stat" information of each index to match the current
+stat information. It will 'not' update the object status itself, and
+it will only update the fields that are used to quickly test whether
+an object still matches its old backing store object.
+
+2) index -> object database
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You write your current index file to a "tree" object with the program
+
+ git-write-tree
+
+that doesn't come with any options - it will just write out the
+current index into the set of tree objects that describe that state,
+and it will return the name of the resulting top-level tree. You can
+use that tree to re-generate the index at any time by going in the
+other direction:
+
+3) object database -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You read a "tree" file from the object database, and use that to
+populate (and overwrite - don't do this if your index contains any
+unsaved state that you might want to restore later!) your current
+index. Normal operation is just
+
+ git-read-tree <sha1 of tree>
+
+and your index file will now be equivalent to the tree that you saved
+earlier. However, that is only your 'index' file: your working
+directory contents have not been modified.
+
+4) index -> working directory
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update your working directory from the index by "checking out"
+files. This is not a very common operation, since normally you'd just
+keep your files updated, and rather than write to your working
+directory, you'd tell the index files about the changes in your
+working directory (i.e. `git-update-index`).
+
+However, if you decide to jump to a new version, or check out somebody
+else's version, or just restore a previous tree, you'd populate your
+index file with read-tree, and then you need to check out the result
+with
+
+ git-checkout-index filename
+
+or, if you want to check out all of the index, use `-a`.
+
+NOTE! git-checkout-index normally refuses to overwrite old files, so
+if you have an old version of the tree already checked out, you will
+need to use the "-f" flag ('before' the "-a" flag or the filename) to
+'force' the checkout.
+
+
+Finally, there are a few odds and ends which are not purely moving
+from one representation to the other:
+
+5) Tying it all together
+~~~~~~~~~~~~~~~~~~~~~~~~
+To commit a tree you have instantiated with "git-write-tree", you'd
+create a "commit" object that refers to that tree and the history
+behind it - most notably the "parent" commits that preceded it in
+history.
+
+Normally a "commit" has one parent: the previous state of the tree
+before a certain change was made. However, sometimes it can have two
+or more parent commits, in which case we call it a "merge", due to the
+fact that such a commit brings together ("merges") two or more
+previous states represented by other commits.
+
+In other words, while a "tree" represents a particular directory state
+of a working directory, a "commit" represents that state in "time",
+and explains how we got there.
+
+You create a commit object by giving it the tree that describes the
+state at the time of the commit, and a list of parents:
+
+ git-commit-tree <tree> -p <parent> [-p <parent2> ..]
+
+and then giving the reason for the commit on stdin (either through
+redirection from a pipe or file, or by just typing it at the tty).
+
+git-commit-tree will return the name of the object that represents
+that commit, and you should save it away for later use. Normally,
+you'd commit a new `HEAD` state, and while git doesn't care where you
+save the note about that state, in practice we tend to just write the
+result to the file pointed at by `.git/HEAD`, so that we can always see
+what the last committed state was.
+
+Here is an ASCII art by Jon Loeliger that illustrates how
+various pieces fit together.
+
+------------
+
+ commit-tree
+ commit obj
+ +----+
+ | |
+ | |
+ V V
+ +-----------+
+ | Object DB |
+ | Backing |
+ | Store |
+ +-----------+
+ ^
+ write-tree | |
+ tree obj | |
+ | | read-tree
+ | | tree obj
+ V
+ +-----------+
+ | Index |
+ | "cache" |
+ +-----------+
+ update-index ^
+ blob obj | |
+ | |
+ checkout-index -u | | checkout-index
+ stat | | blob obj
+ V
+ +-----------+
+ | Working |
+ | Directory |
+ +-----------+
+
+------------
+
+
+6) Examining the data
+~~~~~~~~~~~~~~~~~~~~~
+
+You can examine the data represented in the object database and the
+index with various helper tools. For every object, you can use
+gitlink:git-cat-file[1] to examine details about the
+object:
+
+ git-cat-file -t <objectname>
+
+shows the type of the object, and once you have the type (which is
+usually implicit in where you find the object), you can use
+
+ git-cat-file blob|tree|commit|tag <objectname>
+
+to show its contents. NOTE! Trees have binary content, and as a result
+there is a special helper for showing that content, called
+`git-ls-tree`, which turns the binary content into a more easily
+readable form.
+
+It's especially instructive to look at "commit" objects, since those
+tend to be small and fairly self-explanatory. In particular, if you
+follow the convention of having the top commit name in `.git/HEAD`,
+you can do
+
+ git-cat-file commit HEAD
+
+to see what the top commit was.
+
+7) Merging multiple trees
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Git helps you do a three-way merge, which you can expand to n-way by
+repeating the merge procedure arbitrary times until you finally
+"commit" the state. The normal situation is that you'd only do one
+three-way merge (two parents), and commit it, but if you like to, you
+can do multiple parents in one go.
+
+To do a three-way merge, you need the two sets of "commit" objects
+that you want to merge, use those to find the closest common parent (a
+third "commit" object), and then use those commit objects to find the
+state of the directory ("tree" object) at these points.
+
+To get the "base" for the merge, you first look up the common parent
+of two commits with
+
+ git-merge-base <commit1> <commit2>
+
+which will return you the commit they are both based on. You should
+now look up the "tree" objects of those commits, which you can easily
+do with (for example)
+
+ git-cat-file commit <commitname> | head -1
+
+since the tree object information is always the first line in a commit
+object.
+
+Once you know the three trees you are going to merge (the one
+"original" tree, aka the common case, and the two "result" trees, aka
+the branches you want to merge), you do a "merge" read into the
+index. This will complain if it has to throw away your old index contents, so you should
+make sure that you've committed those - in fact you would normally
+always do a merge against your last commit (which should thus match
+what you have in your current index anyway).
+
+To do the merge, do
+
+ git-read-tree -m -u <origtree> <yourtree> <targettree>
+
+which will do all trivial merge operations for you directly in the
+index file, and you can just write the result out with
+`git-write-tree`.
+
+Historical note. We did not have `-u` facility when this
+section was first written, so we used to warn that
+the merge is done in the index file, not in your
+working tree, and your working tree will not match your
+index after this step.
+This is no longer true. The above command, thanks to `-u`
+option, updates your working tree with the merge results for
+paths that have been trivially merged.
+
+
+8) Merging multiple trees, continued
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sadly, many merges aren't trivial. If there are files that have
+been added.moved or removed, or if both branches have modified the
+same file, you will be left with an index tree that contains "merge
+entries" in it. Such an index tree can 'NOT' be written out to a tree
+object, and you will have to resolve any such merge clashes using
+other tools before you can write out the result.
+
+You can examine such index state with `git-ls-files --unmerged`
+command. An example:
+
+------------------------------------------------
+$ git-read-tree -m $orig HEAD $target
+$ git-ls-files --unmerged
+100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
+100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c
+------------------------------------------------
+
+Each line of the `git-ls-files --unmerged` output begins with
+the blob mode bits, blob SHA1, 'stage number', and the
+filename. The 'stage number' is git's way to say which tree it
+came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD`
+tree, and stage3 `$target` tree.
+
+Earlier we said that trivial merges are done inside
+`git-read-tree -m`. For example, if the file did not change
+from `$orig` to `HEAD` nor `$target`, or if the file changed
+from `$orig` to `HEAD` and `$orig` to `$target` the same way,
+obviously the final outcome is what is in `HEAD`. What the
+above example shows is that file `hello.c` was changed from
+`$orig` to `HEAD` and `$orig` to `$target` in a different way.
+You could resolve this by running your favorite 3-way merge
+program, e.g. `diff3` or `merge`, on the blob objects from
+these three stages yourself, like this:
+
+------------------------------------------------
+$ git-cat-file blob 263414f... >hello.c~1
+$ git-cat-file blob 06fa6a2... >hello.c~2
+$ git-cat-file blob cc44c73... >hello.c~3
+$ merge hello.c~2 hello.c~1 hello.c~3
+------------------------------------------------
+
+This would leave the merge result in `hello.c~2` file, along
+with conflict markers if there are conflicts. After verifying
+the merge result makes sense, you can tell git what the final
+merge result for this file is by:
+
+ mv -f hello.c~2 hello.c
+ git-update-index hello.c
+
+When a path is in unmerged state, running `git-update-index` for
+that path tells git to mark the path resolved.
+
+The above is the description of a git merge at the lowest level,
+to help you understand what conceptually happens under the hood.
+In practice, nobody, not even git itself, uses three `git-cat-file`
+for this. There is `git-merge-index` program that extracts the
+stages to temporary files and calls a "merge" script on it:
+
+ git-merge-index git-merge-one-file hello.c
+
+and that is what higher level `git merge -s resolve` is implemented
+with.
diff --git a/Documentation/core-tutorial.txt b/Documentation/core-tutorial.txt
index 5ea611748c..97cdb90cb4 100644
--- a/Documentation/core-tutorial.txt
+++ b/Documentation/core-tutorial.txt
@@ -46,12 +46,12 @@ to import into git.
For our first example, we're going to start a totally new repository from
scratch, with no pre-existing files, and we'll call it `git-tutorial`.
To start up, create a subdirectory for it, change into that
-subdirectory, and initialize the git infrastructure with `git-init-db`:
+subdirectory, and initialize the git infrastructure with `git-init`:
------------------------------------------------
$ mkdir git-tutorial
$ cd git-tutorial
-$ git-init-db
+$ git-init
------------------------------------------------
to which git will reply
@@ -624,7 +624,7 @@ name for the state at that point.
Copying repositories
--------------------
-git repositories are normally totally self-sufficient and relocatable
+git repositories are normally totally self-sufficient and relocatable.
Unlike CVS, for example, there is no separate notion of
"repository" and "working tree". A git repository normally *is* the
working tree, with the local git information hidden in the `.git`
@@ -906,18 +906,13 @@ of it as it can automatically (which in this case is just merge the `example`
file, which had no differences in the `mybranch` branch), and say:
----------------
- Trying really trivial in-index merge...
- fatal: Merge requires file-level merging
- Nope.
- ...
Auto-merging hello
CONFLICT (content): Merge conflict in hello
Automatic merge failed; fix up by hand
----------------
-which is way too verbose, but it basically tells you that it failed the
-really trivial merge ("Simple merge") and did an "Automatic merge"
-instead, but that too failed due to conflicts in `hello`.
+It tells you that it did an "Automatic merge", which
+failed due to conflicts in `hello`.
Not to worry. It left the (trivial) conflict in `hello` in the same form you
should already be well used to if you've ever used CVS, so let's just
@@ -982,7 +977,7 @@ see more complex cases.
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
-resolve to get the "upstream changes" back to your branch.
+`git merge` to get the "upstream changes" back to your branch.
------------
$ git checkout mybranch
@@ -1001,7 +996,7 @@ Fast forward
----------------
Because your branch did not contain anything more than what are
-already merged into the `master` branch, the resolve operation did
+already merged into the `master` branch, the merge operation did
not actually do a merge. Instead, it just updated the top of
the tree of your branch to that of the `master` branch. This is
often called 'fast forward' merge.
@@ -1104,11 +1099,11 @@ programs, which are 'commit walkers'; they outlived their
usefulness when git Native and SSH transports were introduced,
and not used by `git pull` or `git push` scripts.
-Once you fetch from the remote repository, you `resolve` that
+Once you fetch from the remote repository, you `merge` that
with your current branch.
However -- it's such a common thing to `fetch` and then
-immediately `resolve`, that it's called `git pull`, and you can
+immediately `merge`, that it's called `git pull`, and you can
simply do
----------------
@@ -1123,52 +1118,32 @@ 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
you merge between branches. The advantage of this approach is
-that it lets you keep set of files for each `branch` checked
+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
juggle multiple lines of development simultaneously. Of
course, you will pay the price of more disk usage to hold
multiple working trees, but disk space is cheap these days.
-[NOTE]
-You could even pull from your own repository by
-giving '.' as <remote-repository> parameter to `git pull`. This
-is useful when you want to merge a local branch (or more, if you
-are making an Octopus) into the current branch.
-
It is likely that you will be pulling from the same remote
repository from time to time. As a short hand, you can store
-the remote repository URL in a file under .git/remotes/
-directory, like this:
-
-------------------------------------------------
-$ mkdir -p .git/remotes/
-$ cat >.git/remotes/linus <<\EOF
-URL: http://www.kernel.org/pub/scm/git/git.git/
-EOF
-------------------------------------------------
-
-and use the filename to `git pull` instead of the full URL.
-The URL specified in such file can even be a prefix
-of a full URL, like this:
+the remote repository URL in the local repository's config file
+like this:
------------------------------------------------
-$ cat >.git/remotes/jgarzik <<\EOF
-URL: http://www.kernel.org/pub/scm/linux/git/jgarzik/
-EOF
+$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/
------------------------------------------------
+and use the "linus" keyword with `git pull` instead of the full URL.
Examples.
. `git pull linus`
. `git pull linus tag v0.99.1`
-. `git pull jgarzik/netdev-2.6.git/ e100`
the above are equivalent to:
. `git pull http://www.kernel.org/pub/scm/git/git.git/ HEAD`
. `git pull http://www.kernel.org/pub/scm/git/git.git/ tag v0.99.1`
-. `git pull http://www.kernel.org/pub/.../jgarzik/netdev-2.6.git e100`
How does the merge work?
@@ -1325,7 +1300,7 @@ differences since stage 2 (i.e. your version).
Publishing your work
--------------------
-So we can use somebody else's work from a remote repository; but
+So, we can use somebody else's work from a remote repository, but
how can *you* prepare a repository to let other people pull from
it?
@@ -1371,11 +1346,11 @@ $ mkdir my-git.git
------------
Then, make that directory into a git repository by running
-`git init-db`, 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-db
+$ GIT_DIR=my-git.git git-init
------------
Make sure this directory is available for others you want your
@@ -1494,8 +1469,8 @@ Working with Others
Although git is a truly distributed system, it is often
convenient to organize your project with an informal hierarchy
of developers. Linux kernel development is run this way. There
-is a nice illustration (page 17, "Merges to Mainline") in Randy
-Dunlap's presentation (`http://tinyurl.com/a2jdg`).
+is a nice illustration (page 17, "Merges to Mainline") in
+link:http://tinyurl.com/a2jdg[Randy Dunlap's presentation].
It should be stressed that this hierarchy is purely *informal*.
There is nothing fundamental in git that enforces the "chain of
@@ -1511,7 +1486,7 @@ 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-db`,
+'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
@@ -1546,7 +1521,8 @@ on that project and has an own "public repository" goes like this:
1. Prepare your work repository, by `git clone` the public
repository of the "project lead". The URL used for the
- initial cloning is stored in `.git/remotes/origin`.
+ initial cloning is stored in the remote.origin.url
+ configuration variable.
2. Prepare a public repository accessible to others, just like
the "project lead" person does.
@@ -1586,14 +1562,15 @@ like this:
1. Prepare your work repository, by `git clone` the public
repository of the "project lead" (or a "subsystem
maintainer", if you work on a subsystem). The URL used for
- the initial cloning is stored in `.git/remotes/origin`.
+ the initial cloning is stored in the remote.origin.url
+ configuration variable.
2. Do your work in your repository on 'master' branch.
3. Run `git fetch origin` from the public repository of your
upstream every once in a while. This does only the first
half of `git pull` but does not merge. The head of the
- public repository is stored in `.git/refs/heads/origin`.
+ public repository is stored in `.git/refs/remotes/origin/master`.
4. Use `git cherry origin` to see which ones of your patches
were accepted, and/or use `git rebase origin` to port your
@@ -1681,11 +1658,11 @@ $ git reset --hard master~2
You can make sure 'git show-branch' matches the state before
those two 'git merge' you just did. Then, instead of running
-two 'git merge' commands in a row, you would pull these two
+two 'git merge' commands in a row, you would merge these two
branch heads (this is known as 'making an Octopus'):
------------
-$ git pull . commit-fix diff-fix
+$ git merge commit-fix diff-fix
$ git show-branch
! [commit-fix] Fix commit message normalization.
! [diff-fix] Fix rename detection.
@@ -1701,7 +1678,7 @@ $ git show-branch
Note that you should not do Octopus because you can. An octopus
is a valid thing to do and often makes it easier to view the
-commit history if you are pulling more than two independent
+commit history if you are merging more than two independent
changes at the same time. However, if you have merge conflicts
with any of the branches you are merging in and need to hand
resolve, that is an indication that the development happened in
diff --git a/Documentation/cvs-migration.txt b/Documentation/cvs-migration.txt
index 8e09beaa79..764cc560b4 100644
--- a/Documentation/cvs-migration.txt
+++ b/Documentation/cvs-migration.txt
@@ -36,7 +36,7 @@ them first before running git pull.
================================
The `pull` command knows where to get updates from because of certain
configuration variables that were set by the first `git clone`
-command; see `git repo-config -l` and the gitlink:git-repo-config[1] man
+command; see `git config -l` and the gitlink:git-config[1] man
page for details.
================================
@@ -80,7 +80,7 @@ it:
------------------------------------------------
$ mkdir /pub/my-repo.git
$ cd /pub/my-repo.git
-$ git --bare init-db --shared
+$ git --bare init --shared
$ git --bare fetch /home/alice/myproject master:master
------------------------------------------------
diff --git a/Documentation/diff-format.txt b/Documentation/diff-format.txt
index 883c1bb0a6..378e72f38f 100644
--- a/Documentation/diff-format.txt
+++ b/Documentation/diff-format.txt
@@ -159,7 +159,7 @@ or like this (when '--cc' option is used):
deleted file mode <mode>,<mode>
+
The `mode <mode>,<mode>..<mode>` line appears only if at least one of
-the <mode> is diferent from the rest. Extended headers with
+the <mode> is different from the rest. Extended headers with
information about detected contents movement (renames and
copying detection) are designed to work with diff of two
<tree-ish> and are not used by combined diff format.
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index da1cc60e97..019a39f2bf 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -58,6 +58,10 @@
Turn off rename detection, even when the configuration
file gives the default to do so.
+--check::
+ Warn if changes introduce trailing whitespace
+ or an indent that uses a space before a tab.
+
--full-index::
Instead of the first handful characters, show full
object name of pre- and post-image blob on the "index"
diff --git a/Documentation/diffcore.txt b/Documentation/diffcore.txt
index cb4e562004..34cd306bb1 100644
--- a/Documentation/diffcore.txt
+++ b/Documentation/diffcore.txt
@@ -6,8 +6,8 @@ June 2005
Introduction
------------
-The diff commands git-diff-index, git-diff-files, git-diff-tree, and
-git-diff-stages can be told to manipulate differences they find in
+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
is collectively called "diffcore transformation". This short note
describes what they are and how to use them to produce diff outputs
@@ -30,9 +30,6 @@ files:
- git-diff-tree compares contents of two "tree" objects;
- - git-diff-stages compares contents of blobs at two stages in an
- unmerged index file.
-
In all of these cases, the commands themselves compare
corresponding paths in the two sets of files. The result of
comparison is passed from these commands to what is internally
diff --git a/Documentation/docbook-xsl.css b/Documentation/docbook-xsl.css
new file mode 100644
index 0000000000..8821e305dd
--- /dev/null
+++ b/Documentation/docbook-xsl.css
@@ -0,0 +1,286 @@
+/*
+ CSS stylesheet for XHTML produced by DocBook XSL stylesheets.
+ Tested with XSL stylesheets 1.61.2, 1.67.2
+*/
+
+span.strong {
+ font-weight: bold;
+}
+
+body blockquote {
+ margin-top: .75em;
+ line-height: 1.5;
+ margin-bottom: .75em;
+}
+
+html body {
+ margin: 1em 5% 1em 5%;
+ line-height: 1.2;
+}
+
+body div {
+ margin: 0;
+}
+
+h1, h2, h3, h4, h5, h6,
+div.toc p b,
+div.list-of-figures p b,
+div.list-of-tables p b,
+div.abstract p.title
+{
+ color: #527bbd;
+ font-family: tahoma, verdana, sans-serif;
+}
+
+div.toc p:first-child,
+div.list-of-figures p:first-child,
+div.list-of-tables p:first-child,
+div.example p.title
+{
+ margin-bottom: 0.2em;
+}
+
+body h1 {
+ margin: .0em 0 0 -4%;
+ line-height: 1.3;
+ border-bottom: 2px solid silver;
+}
+
+body h2 {
+ margin: 0.5em 0 0 -4%;
+ line-height: 1.3;
+ border-bottom: 2px solid silver;
+}
+
+body h3 {
+ margin: .8em 0 0 -3%;
+ line-height: 1.3;
+}
+
+body h4 {
+ margin: .8em 0 0 -3%;
+ line-height: 1.3;
+}
+
+body h5 {
+ margin: .8em 0 0 -2%;
+ line-height: 1.3;
+}
+
+body h6 {
+ margin: .8em 0 0 -1%;
+ line-height: 1.3;
+}
+
+body hr {
+ border: none; /* Broken on IE6 */
+}
+div.footnotes hr {
+ border: 1px solid silver;
+}
+
+div.navheader th, div.navheader td, div.navfooter td {
+ font-family: sans-serif;
+ font-size: 0.9em;
+ font-weight: bold;
+ color: #527bbd;
+}
+div.navheader img, div.navfooter img {
+ border-style: none;
+}
+div.navheader a, div.navfooter a {
+ font-weight: normal;
+}
+div.navfooter hr {
+ border: 1px solid silver;
+}
+
+body td {
+ line-height: 1.2
+}
+
+body th {
+ line-height: 1.2;
+}
+
+ol {
+ line-height: 1.2;
+}
+
+ul, body dir, body menu {
+ line-height: 1.2;
+}
+
+html {
+ margin: 0;
+ padding: 0;
+}
+
+body h1, body h2, body h3, body h4, body h5, body h6 {
+ margin-left: 0
+}
+
+body pre {
+ margin: 0.5em 10% 0.5em 1em;
+ line-height: 1.0;
+ color: navy;
+}
+
+tt.literal, code.literal {
+ color: navy;
+}
+
+div.literallayout p {
+ padding: 0em;
+ margin: 0em;
+}
+
+div.literallayout {
+ font-family: monospace;
+# margin: 0.5em 10% 0.5em 1em;
+ margin: 0em;
+ color: navy;
+ border: 1px solid silver;
+ background: #f4f4f4;
+ padding: 0.5em;
+}
+
+.programlisting, .screen {
+ border: 1px solid silver;
+ background: #f4f4f4;
+ margin: 0.5em 10% 0.5em 0;
+ padding: 0.5em 1em;
+}
+
+div.sidebar {
+ background: #ffffee;
+ margin: 1.0em 10% 0.5em 0;
+ padding: 0.5em 1em;
+ border: 1px solid silver;
+}
+div.sidebar * { padding: 0; }
+div.sidebar div { margin: 0; }
+div.sidebar p.title {
+ font-family: sans-serif;
+ margin-top: 0.5em;
+ margin-bottom: 0.2em;
+}
+
+div.bibliomixed {
+ margin: 0.5em 5% 0.5em 1em;
+}
+
+div.glossary dt {
+ font-weight: bold;
+}
+div.glossary dd p {
+ margin-top: 0.2em;
+}
+
+dl {
+ margin: .8em 0;
+ line-height: 1.2;
+}
+
+dt {
+ margin-top: 0.5em;
+}
+
+dt span.term {
+ font-style: italic;
+}
+
+div.variablelist dd p {
+ margin-top: 0;
+}
+
+div.itemizedlist li, div.orderedlist li {
+ margin-left: -0.8em;
+ margin-top: 0.5em;
+}
+
+ul, ol {
+ list-style-position: outside;
+}
+
+div.sidebar ul, div.sidebar ol {
+ margin-left: 2.8em;
+}
+
+div.itemizedlist p.title,
+div.orderedlist p.title,
+div.variablelist p.title
+{
+ margin-bottom: -0.8em;
+}
+
+div.revhistory table {
+ border-collapse: collapse;
+ border: none;
+}
+div.revhistory th {
+ border: none;
+ color: #527bbd;
+ font-family: tahoma, verdana, sans-serif;
+}
+div.revhistory td {
+ border: 1px solid silver;
+}
+
+/* Keep TOC and index lines close together. */
+div.toc dl, div.toc dt,
+div.list-of-figures dl, div.list-of-figures dt,
+div.list-of-tables dl, div.list-of-tables dt,
+div.indexdiv dl, div.indexdiv dt
+{
+ line-height: normal;
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+/*
+ Table styling does not work because of overriding attributes in
+ generated HTML.
+*/
+div.table table,
+div.informaltable table
+{
+ margin-left: 0;
+ margin-right: 5%;
+ margin-bottom: 0.8em;
+}
+div.informaltable table
+{
+ margin-top: 0.4em
+}
+div.table thead,
+div.table tfoot,
+div.table tbody,
+div.informaltable thead,
+div.informaltable tfoot,
+div.informaltable tbody
+{
+ /* No effect in IE6. */
+ border-top: 2px solid #527bbd;
+ border-bottom: 2px solid #527bbd;
+}
+div.table thead, div.table tfoot,
+div.informaltable thead, div.informaltable tfoot
+{
+ font-weight: bold;
+}
+
+div.mediaobject img {
+ border: 1px solid silver;
+ margin-bottom: 0.8em;
+}
+div.figure p.title,
+div.table p.title
+{
+ margin-top: 1em;
+ margin-bottom: 0.4em;
+}
+
+@media print {
+ div.navheader, div.navfooter { display: none; }
+}
diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt
index 4e83994c58..08c61b1f1a 100644
--- a/Documentation/everyday.txt
+++ b/Documentation/everyday.txt
@@ -28,7 +28,7 @@ Everybody uses these commands to maintain git repositories.
* gitlink:git-init[1] or gitlink:git-clone[1] to create a
new repository.
- * gitlink:git-fsck-objects[1] to check the repository for errors.
+ * gitlink:git-fsck[1] to check the repository for errors.
* gitlink:git-prune[1] to remove unused objects in the repository.
@@ -43,7 +43,7 @@ Examples
Check health and remove cruft.::
+
------------
-$ git fsck-objects <1>
+$ git fsck <1>
$ git count-objects <2>
$ git repack <3>
$ git gc <4>
@@ -148,8 +148,7 @@ modification will be caught if you do `git commit -a` later.
<8> redo the commit undone in the previous step, using the message
you originally wrote.
<9> switch to the master branch.
-<10> merge a topic branch into your master branch. You can also use
-`git pull . alsa-audio`, i.e. pull from the local repository.
+<10> merge a topic branch into your master branch.
<11> review commit logs; other forms to limit output can be
combined and include `\--max-count=10` (show 10 commits),
`\--until=2005-12-10`, etc.
@@ -213,12 +212,12 @@ Push into another repository.::
------------
satellite$ git clone mothership:frotz frotz <1>
satellite$ cd frotz
-satellite$ git repo-config --get-regexp '^(remote|branch)\.' <2>
+satellite$ git config --get-regexp '^(remote|branch)\.' <2>
remote.origin.url mothership:frotz
remote.origin.fetch refs/heads/*:refs/remotes/origin/*
branch.master.remote origin
branch.master.merge refs/heads/master
-satellite$ git repo-config remote.origin.push \
+satellite$ git config remote.origin.push \
master:refs/remotes/satellite/master <3>
satellite$ edit/compile/test/commit
satellite$ git push origin <4>
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 95bea66374..b73a99d61f 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -7,7 +7,7 @@ git-add - Add file contents to the changeset to be committed next
SYNOPSIS
--------
-'git-add' [-n] [-v] [-f] [--interactive] [--] <file>...
+'git-add' [-n] [-v] [-f] [--interactive | -i] [--] <file>...
DESCRIPTION
-----------
@@ -52,7 +52,7 @@ OPTIONS
-f::
Allow adding otherwise ignored files.
-\--interactive::
+\i, \--interactive::
Add modified contents in the working tree interactively to
the index.
@@ -83,7 +83,7 @@ git-add git-*.sh::
Interactive mode
----------------
When the command enters the interactive mode, it shows the
-output of the 'status' subcommand, and then goes into ints
+output of the 'status' subcommand, and then goes into its
interactive command loop.
The command loop shows the list of subcommands available, and
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 53e81cb103..4fb1d84413 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -3,14 +3,15 @@ git-am(1)
NAME
----
-git-am - Apply a series of patches in a mailbox
+git-am - Apply a series of patches from a mailbox
SYNOPSIS
--------
[verse]
'git-am' [--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
- [--interactive] [--whitespace=<option>] <mbox>...
+ [--interactive] [--whitespace=<option>] [-C<n>] [-p<n>]
+ <mbox>...
'git-am' [--skip | --resolved]
DESCRIPTION
@@ -21,6 +22,10 @@ current branch.
OPTIONS
-------
+<mbox>...::
+ The list of mailbox files to read patches from. If you do not
+ supply this argument, reads from the standard input.
+
--signoff::
Add `Signed-off-by:` line to the commit message, using
the committer identity of yourself.
@@ -64,6 +69,10 @@ default. You could use `--no-utf8` to override this.
This flag is passed to the `git-apply` program that applies
the patch.
+-C<n>, -p<n>::
+ These flag are passed to the `git-apply` program that applies
+ the patch.
+
--interactive::
Run interactively, just like git-applymbox.
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 33b93db508..065ba1bf24 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -3,7 +3,7 @@ git-apply(1)
NAME
----
-git-apply - Apply patch on a git index file and a work tree
+git-apply - Apply a patch on a git index file and a working tree
SYNOPSIS
diff --git a/Documentation/git-applymbox.txt b/Documentation/git-applymbox.txt
index f74c6a49b3..95dc65a583 100644
--- a/Documentation/git-applymbox.txt
+++ b/Documentation/git-applymbox.txt
@@ -42,13 +42,13 @@ OPTIONS
and the current tree.
-u::
- By default, the commit log message, author name and
- author email are taken from the e-mail without any
- charset conversion, after minimally decoding MIME
- transfer encoding. This flag causes the resulting
- commit to be encoded in utf-8 by transliterating them.
- Note that the patch is always used as is without charset
- conversion, even with this flag.
+ The commit log message, author name and author email are
+ taken from the e-mail, and after minimally decoding MIME
+ transfer encoding, re-coded in UTF-8 by transliterating
+ them. This used to be optional but now it is the default.
++
+Note that the patch is always used as-is without charset
+conversion, even with this flag.
-c .dotest/<num>::
When the patch contained in an e-mail does not cleanly
diff --git a/Documentation/git-applypatch.txt b/Documentation/git-applypatch.txt
index 2b1ff1454b..451434a757 100644
--- a/Documentation/git-applypatch.txt
+++ b/Documentation/git-applypatch.txt
@@ -12,6 +12,9 @@ SYNOPSIS
DESCRIPTION
-----------
+This is usually not what an end user wants to run directly. See
+gitlink:git-am[1] instead.
+
Takes three files <msg>, <patch>, and <info> prepared from an
e-mail message by 'git-mailinfo', and creates a commit. It is
usually not necessary to use this command directly.
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 031fcd5190..493474b2ee 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -3,7 +3,7 @@ git-archive(1)
NAME
----
-git-archive - Creates a archive of the files in the named tree
+git-archive - Creates an archive of files from a named tree
SYNOPSIS
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index ac4b4965a9..16ec7269b2 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -3,7 +3,7 @@ git-bisect(1)
NAME
----
-git-bisect - Find the change that introduced a bug
+git-bisect - Find the change that introduced a bug by binary search
SYNOPSIS
diff --git a/Documentation/git-blame.txt b/Documentation/git-blame.txt
index bdfc666928..5c9888d014 100644
--- a/Documentation/git-blame.txt
+++ b/Documentation/git-blame.txt
@@ -8,8 +8,8 @@ git-blame - Show what revision and author last modified each line of a file
SYNOPSIS
--------
[verse]
-'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>]
- [-M] [-C] [-C] [--since=<date>] [<rev>] [--] <file>
+'git-blame' [-c] [-l] [-t] [-f] [-n] [-p] [--incremental] [-L n,m] [-S <revs-file>]
+ [-M] [-C] [-C] [--since=<date>] [<rev> | --contents <file>] [--] <file>
DESCRIPTION
-----------
@@ -24,7 +24,7 @@ replaced; you need to use a tool such as gitlink:git-diff[1] or the "pickaxe"
interface briefly mentioned in the following paragraph.
Apart from supporting file annotation, git also supports searching the
-development history for when a code snippet occured in a change. This makes it
+development history for when a code snippet occurred in a change. This makes it
possible to track when a code snippet was added to a file, moved or copied
between files, and eventually deleted or replaced. It works by searching for
a text string in the diff. A small example:
@@ -63,6 +63,17 @@ OPTIONS
-p, --porcelain::
Show in a format designed for machine consumption.
+--incremental::
+ Show the result incrementally in a format designed for
+ machine consumption.
+
+--contents <file>::
+ 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
+ `-` to make the command read from the standard input).
+
-M::
Detect moving lines in the file as well. When a commit
moves a block of lines in a file (e.g. the original file
@@ -89,7 +100,7 @@ THE PORCELAIN FORMAT
--------------------
In this format, each line is output after a header; the
-header at the minumum has the first line which has:
+header at the minimum has the first line which has:
- 40-byte SHA-1 of the commit the line is attributed to;
- the line number of the line in the original file;
@@ -112,15 +123,18 @@ header, prefixed by a TAB. This is to allow adding more
header elements later.
-SPECIFIYING RANGES
-------------------
+SPECIFYING RANGES
+-----------------
Unlike `git-blame` and `git-annotate` in older git, the extent
of annotation can be limited to both line ranges and revision
ranges. When you are interested in finding the origin for
-ll. 40-60 for file `foo`, you can use `-L` option like this:
+ll. 40-60 for file `foo`, you can use `-L` option like these
+(they mean the same thing -- both ask for 21 lines starting at
+line 40):
git blame -L 40,60 foo
+ git blame -L 40,+21 foo
Also you can use regular expression to specify the line range.
@@ -155,6 +169,47 @@ parents, using `commit{caret}!` notation:
git blame -C -C -f $commit^! -- foo
+INCREMENTAL OUTPUT
+------------------
+
+When called with `--incremental` option, the command outputs the
+result as it is built. The output generally will talk about
+lines touched by more recent commits first (i.e. the lines will
+be annotated out of order) and is meant to be used by
+interactive viewers.
+
+The output format is similar to the Porcelain format, but it
+does not contain the actual lines from the file that is being
+annotated.
+
+. Each blame entry always starts with a line of:
+
+ <40-byte hex sha1> <sourceline> <resultline> <num_lines>
++
+Line numbers count from 1.
+
+. The first time that commit shows up in the stream, it has various
+ other information about it printed out with a one-word tag at the
+ beginning of each line about that "extended commit info" (author,
+ email, committer, dates, summary etc).
+
+. Unlike Porcelain format, the filename information is always
+ given and terminates the entry:
+
+ "filename" <whitespace-quoted-filename-goes-here>
++
+and thus it's really quite easy to parse for some line- and word-oriented
+parser (which should be quite natural for most scripting languages).
++
+[NOTE]
+For people who do parsing: to make it more robust, just ignore any
+lines in between the first and last one ("<sha1>" and "filename" lines)
+where you don't recognize the tag-words (or care about that particular
+one) at the beginning of the "extended information" lines. That way, if
+there is ever added information (like the commit encoding or extended
+commit commentary), a blame viewer won't ever care.
+
+
SEE ALSO
--------
gitlink:git-annotate[1]
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index e872fc89fc..aa1fdd402a 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -3,7 +3,7 @@ git-branch(1)
NAME
----
-git-branch - List, create, or delete branches.
+git-branch - List, create, or delete branches
SYNOPSIS
--------
@@ -74,7 +74,7 @@ OPTIONS
List both remote-tracking branches and local branches.
-v::
- Show sha1 and commit subjectline for each head.
+ Show sha1 and commit subject line for each head.
--abbrev=<length>::
Alter minimum display length for sha1 in output listing,
diff --git a/Documentation/git-cat-file.txt b/Documentation/git-cat-file.txt
index 5e9cbf875d..075c0d05ef 100644
--- a/Documentation/git-cat-file.txt
+++ b/Documentation/git-cat-file.txt
@@ -3,7 +3,7 @@ git-cat-file(1)
NAME
----
-git-cat-file - Provide content or type information for repository objects
+git-cat-file - Provide content or type/size information for repository objects
SYNOPSIS
@@ -19,7 +19,9 @@ or '-s' is used to find the object size.
OPTIONS
-------
<object>::
- The sha1 identifier of the object.
+ The name of the object to show.
+ For a more complete list of ways to spell object names, see
+ "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
-t::
Instead of the content, show the object type identified by
diff --git a/Documentation/git-checkout-index.txt b/Documentation/git-checkout-index.txt
index 765c173e15..6dd6db04bb 100644
--- a/Documentation/git-checkout-index.txt
+++ b/Documentation/git-checkout-index.txt
@@ -3,7 +3,7 @@ git-checkout-index(1)
NAME
----
-git-checkout-index - Copy files from the index to the working directory
+git-checkout-index - Copy files from the index to the working tree
SYNOPSIS
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index fbdbadc74f..e4ffde4fdd 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -8,8 +8,8 @@ git-checkout - Checkout and switch to a branch
SYNOPSIS
--------
[verse]
-'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>]
-'git-checkout' [-m] [<branch>] <paths>...
+'git-checkout' [-q] [-f] [-b <new_branch> [-l]] [-m] [<branch>]
+'git-checkout' [<tree-ish>] <paths>...
DESCRIPTION
-----------
@@ -22,15 +22,20 @@ be created.
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`). In
+the index file (i.e. it runs `git-checkout-index -f -u`), or a
+named commit. In
this case, `-f` and `-b` options are meaningless and giving
-either of them results in an error. <branch> argument can be
-used to specify a specific tree-ish to update the index for the
-given paths before updating the working tree.
+either of them results in an error. <tree-ish> argument can be
+used to specify a specific tree-ish (i.e. commit, tag or tree)
+to update the index for the given paths before updating the
+working tree.
OPTIONS
-------
+-q::
+ Quiet, supress feedback messages.
+
-f::
Force a re-read of everything.
@@ -63,7 +68,47 @@ and mark the resolved paths with `git update-index`.
<branch>::
Branch to checkout; may be any object ID that resolves to a
- commit. Defaults to HEAD.
+ commit. Defaults to HEAD.
++
+When this parameter names a non-branch (but still a valid commit object),
+your HEAD becomes 'detached'.
+
+
+Detached HEAD
+-------------
+
+It is sometimes useful to be able to 'checkout' a commit that is
+not at the tip of one of your branches. The most obvious
+example is to check out the commit at a tagged official release
+point, like this:
+
+------------
+$ git checkout v2.6.18
+------------
+
+Earlier versions of git did not allow this and asked you to
+create a temporary branch using `-b` option, but starting from
+version 1.5.0, the above command 'detaches' your HEAD from the
+current branch and directly point at the commit named by the tag
+(`v2.6.18` in the above example).
+
+You can use usual git commands while in this state. You can use
+`git-reset --hard $othercommit` to further move around, for
+example. You can make changes and create a new commit on top of
+a detached HEAD. You can even create a merge by using `git
+merge $othercommit`.
+
+The state you are in while your HEAD is detached is not recorded
+by any branch (which is natural --- you are not on any branch).
+What this means is that you can discard your temporary commits
+and merges by switching back to an existing branch (e.g. `git
+checkout master`), and a later `git prune` or `git gc` would
+garbage-collect them. If you did this by mistake, you can ask
+the reflog for HEAD where you were, e.g.
+
+------------
+$ git log -g -2 HEAD
+------------
EXAMPLES
diff --git a/Documentation/git-cherry-pick.txt b/Documentation/git-cherry-pick.txt
index 875edb6b9f..3149d08da8 100644
--- a/Documentation/git-cherry-pick.txt
+++ b/Documentation/git-cherry-pick.txt
@@ -19,6 +19,8 @@ OPTIONS
-------
<commit>::
Commit to cherry-pick.
+ For a more complete list of ways to spell commits, see
+ "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
-e|--edit::
With this option, `git-cherry-pick` will let you edit the commit
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index a78207461d..707376f22c 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -3,7 +3,7 @@ git-clone(1)
NAME
----
-git-clone - Clones a repository
+git-clone - Clones a repository into a new directory
SYNOPSIS
diff --git a/Documentation/git-commit-tree.txt b/Documentation/git-commit-tree.txt
index 77ba96ed8a..cf25507f8f 100644
--- a/Documentation/git-commit-tree.txt
+++ b/Documentation/git-commit-tree.txt
@@ -3,7 +3,7 @@ git-commit-tree(1)
NAME
----
-git-commit-tree - Creates a new commit object
+git-commit-tree - Create a new commit object
SYNOPSIS
@@ -12,6 +12,9 @@ SYNOPSIS
DESCRIPTION
-----------
+This is usually not what an end user wants to run directly. See
+gitlink:git-commit[1] instead.
+
Creates a new commit object based on the provided tree object and
emits the new commit object id on stdout. If no parent is given then
it is considered to be an initial tree.
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index a7adf24fa5..2187eee416 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -3,13 +3,13 @@ git-commit(1)
NAME
----
-git-commit - Record your changes
+git-commit - Record changes to the repository
SYNOPSIS
--------
[verse]
-'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg>]
- [--no-verify] [--amend] [-e] [--author <author>]
+'git-commit' [-a] [-s] [-v] [(-c | -C) <commit> | -F <file> | -m <msg> |
+ --amend] [--no-verify] [-e] [--author <author>]
[--] [[-i | -o ]<file>...]
DESCRIPTION
@@ -32,7 +32,8 @@ methods:
4. by using the -a switch with the 'commit' command to automatically "add"
changes from all known files i.e. files that have already been committed
- before, and perform the actual commit.
+ before, and to automatically "rm" files that have been
+ removed from the working tree, and perform the actual commit.
The gitlink:git-status[1] command can be used to obtain a
summary of what is included by any of the above for the next
@@ -72,12 +73,8 @@ OPTIONS
Add Signed-off-by line at the end of the commit message.
--no-verify::
- By default, the command looks for suspicious lines the
- commit introduces, and aborts committing if there is one.
- The definition of 'suspicious lines' is currently the
- lines that has trailing whitespaces, and the lines whose
- indentation has a SP character immediately followed by a
- TAB character. This option turns off the check.
+ This option bypasses the pre-commit hook.
+ See also link:hooks.html[hooks].
-e|--edit::
The message taken from file with `-F`, command line with
@@ -114,7 +111,7 @@ but can be used to amend a merge commit.
are concluding a conflicted merge.
-q|--quiet::
- Supress commit summary message.
+ Suppress commit summary message.
\--::
Do not interpret any more arguments as options.
@@ -145,11 +142,6 @@ $ git add hello.c
$ git commit
------------
-////////////
-We should fix 'git rm' to remove goodbye.c from both index and
-working tree for the above example.
-////////////
-
Instead of staging files after each individual change, you can
tell `git commit` to notice the changes to the files whose
contents are tracked in
@@ -226,6 +218,12 @@ refuses to run when given pathnames (but see `-i` option).
DISCUSSION
----------
+Though not required, it's a good idea to begin the commit message
+with a single short (less than 50 character) line summarizing the
+change, followed by a blank line and then a more thorough description.
+Tools that turn commits into email, for example, use the first line
+on the Subject: line and the rest of the commit in the body.
+
include::i18n.txt[]
ENVIRONMENT VARIABLES
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
new file mode 100644
index 0000000000..6624484fe1
--- /dev/null
+++ b/Documentation/git-config.txt
@@ -0,0 +1,227 @@
+git-config(1)
+=============
+
+NAME
+----
+git-config - Get and set repository or global options
+
+
+SYNOPSIS
+--------
+[verse]
+'git-config' [--global] [type] name [value [value_regex]]
+'git-config' [--global] [type] --add name value
+'git-config' [--global] [type] --replace-all name [value [value_regex]]
+'git-config' [--global] [type] --get name [value_regex]
+'git-config' [--global] [type] --get-all name [value_regex]
+'git-config' [--global] [type] --unset name [value_regex]
+'git-config' [--global] [type] --unset-all name [value_regex]
+'git-config' [--global] -l | --list
+
+DESCRIPTION
+-----------
+You can query/set/replace/unset options with this command. The name is
+actually the section and the key separated by a dot, and the value will be
+escaped.
+
+Multiple lines can be added to an option by using the '--add' option.
+If you want to update or unset an option which can occur on multiple
+lines, a POSIX regexp `value_regex` needs to be given. Only the
+existing values that match the regexp are updated or unset. If
+you want to handle the lines that do *not* match the regex, just
+prepend a single exclamation mark in front (see EXAMPLES).
+
+The type specifier can be either '--int' or '--bool', which will make
+'git-config' ensure that the variable(s) are of the given type and
+convert the value to the canonical form (simple decimal number for int,
+a "true" or "false" string for bool). If no type specifier is passed,
+no checks or transformations are performed on the value.
+
+This command will fail if:
+
+. The .git/config file is invalid,
+. Can not write to .git/config,
+. no section was provided,
+. the section or key is invalid,
+. you try to unset an option which does not exist,
+. you try to unset/set an option for which multiple lines match, or
+. you use --global option without $HOME being properly set.
+
+
+OPTIONS
+-------
+
+--replace-all::
+ Default behavior is to replace at most one line. This replaces
+ all lines matching the key (and optionally the value_regex).
+
+--add::
+ Adds a new line to the option without altering any existing
+ values. This is the same as providing '^$' as the value_regex.
+
+--get::
+ Get the value for a given key (optionally filtered by a regex
+ matching the value). Returns error code 1 if the key was not
+ found and error code 2 if multiple key values were found.
+
+--get-all::
+ Like get, but does not fail if the number of values for the key
+ is not exactly one.
+
+--get-regexp::
+ Like --get-all, but interprets the name as a regular expression.
+
+--global::
+ Use global ~/.gitconfig file rather than the repository .git/config.
+
+--unset::
+ Remove the line matching the key from config file.
+
+--unset-all::
+ Remove all matching lines from config file.
+
+-l, --list::
+ List all variables set in config file.
+
+--bool::
+ git-config will ensure that the output is "true" or "false"
+
+--int::
+ git-config will ensure that the output is a simple
+ decimal number. An optional value suffix of 'k', 'm', or 'g'
+ in the config file will cause the value to be multiplied
+ by 1024, 1048576, or 1073741824 prior to output.
+
+
+ENVIRONMENT
+-----------
+
+GIT_CONFIG::
+ Take the configuration from the given file instead of .git/config.
+ Using the "--global" option forces this to ~/.gitconfig.
+
+GIT_CONFIG_LOCAL::
+ Currently the same as $GIT_CONFIG; when Git will support global
+ configuration files, this will cause it to take the configuration
+ from the global configuration file in addition to the given file.
+
+
+EXAMPLE
+-------
+
+Given a .git/config like this:
+
+ #
+ # This is the config file, and
+ # a '#' or ';' character indicates
+ # a comment
+ #
+
+ ; core variables
+ [core]
+ ; Don't trust file modes
+ filemode = false
+
+ ; Our diff algorithm
+ [diff]
+ external = "/usr/local/bin/gnu-diff -u"
+ renames = true
+
+ ; Proxy settings
+ [core]
+ gitproxy="ssh" for "ssh://kernel.org/"
+ gitproxy="proxy-command" for kernel.org
+ gitproxy="myprotocol-command" for "my://"
+ gitproxy=default-proxy ; for all the rest
+
+you can set the filemode to true with
+
+------------
+% git config core.filemode true
+------------
+
+The hypothetical proxy command entries actually have a postfix to discern
+what URL they apply to. Here is how to change the entry for kernel.org
+to "ssh".
+
+------------
+% git config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$'
+------------
+
+This makes sure that only the key/value pair for kernel.org is replaced.
+
+To delete the entry for renames, do
+
+------------
+% git config --unset diff.renames
+------------
+
+If you want to delete an entry for a multivar (like core.gitproxy above),
+you have to provide a regex matching the value of exactly one line.
+
+To query the value for a given key, do
+
+------------
+% git config --get core.filemode
+------------
+
+or
+
+------------
+% git config core.filemode
+------------
+
+or, to query a multivar:
+
+------------
+% git config --get core.gitproxy "for kernel.org$"
+------------
+
+If you want to know all the values for a multivar, do:
+
+------------
+% git config --get-all core.gitproxy
+------------
+
+If you like to live dangerous, you can replace *all* core.gitproxy by a
+new one with
+
+------------
+% git config --replace-all core.gitproxy ssh
+------------
+
+However, if you really only want to replace the line for the default proxy,
+i.e. the one without a "for ..." postfix, do something like this:
+
+------------
+% git config core.gitproxy ssh '! for '
+------------
+
+To actually match only values with an exclamation mark, you have to
+
+------------
+% git config section.key value '[!]'
+------------
+
+To add a new proxy, without altering any of the existing ones, use
+
+------------
+% git config core.gitproxy '"proxy" for example.com'
+------------
+
+
+include::config.txt[]
+
+
+Author
+------
+Written by Johannes Schindelin <Johannes.Schindelin@gmx.de>
+
+Documentation
+--------------
+Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt
index c59df6438c..91c8c92c76 100644
--- a/Documentation/git-count-objects.txt
+++ b/Documentation/git-count-objects.txt
@@ -3,7 +3,7 @@ git-count-objects(1)
NAME
----
-git-count-objects - Reports on unpacked objects
+git-count-objects - Count unpacked number of objects and their disk consumption
SYNOPSIS
--------
diff --git a/Documentation/git-cvsexportcommit.txt b/Documentation/git-cvsexportcommit.txt
index 092d0d6730..27d531b888 100644
--- a/Documentation/git-cvsexportcommit.txt
+++ b/Documentation/git-cvsexportcommit.txt
@@ -3,12 +3,12 @@ git-cvsexportcommit(1)
NAME
----
-git-cvsexportcommit - Export a commit to a CVS checkout
+git-cvsexportcommit - Export a single commit to a CVS checkout
SYNOPSIS
--------
-'git-cvsexportcommit' [-h] [-v] [-c] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
+'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
DESCRIPTION
@@ -46,6 +46,9 @@ OPTIONS
-f::
Force the merge even if the files are not up to date.
+-P::
+ Force the parent commit, even if it is not a direct parent.
+
-m::
Prepend the commit message with the provided prefix.
Useful for patch series and the like.
diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
index 5c402de267..f5450de74a 100644
--- a/Documentation/git-cvsimport.txt
+++ b/Documentation/git-cvsimport.txt
@@ -3,7 +3,7 @@ git-cvsimport(1)
NAME
----
-git-cvsimport - Import a CVS repository into git
+git-cvsimport - Salvage your data out of another SCM people love to hate
SYNOPSIS
@@ -97,7 +97,7 @@ If you need to pass multiple options, separate them with a comma.
Substitute the character "/" in branch names with <subst>
-A <author-conv-file>::
- CVS by default uses the unix username when writing its
+ CVS by default uses the Unix username when writing its
commit logs. Using this option and an author-conv-file
in this format
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
index 993adc7c5a..9ddab71203 100644
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -131,14 +131,14 @@ Giving these options is an error when used with `--inetd`; use
the facility of inet daemon to achieve the same before spawning
`git-daemon` if needed.
---enable-service, --disable-service::
+--enable=service, --disable=service::
Enable/disable the service site-wide per default. Note
that a service disabled site-wide can still be enabled
per repository if it is marked overridable and the
repository enables the service with an configuration
item.
---allow-override, --forbid-override::
+--allow-override=service, --forbid-override=service::
Allow/forbid overriding the site-wide default with per
repository configuration. By default, all the services
are overridable.
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
index 2700f35bdb..47a583d3a6 100644
--- a/Documentation/git-describe.txt
+++ b/Documentation/git-describe.txt
@@ -14,8 +14,8 @@ DESCRIPTION
-----------
The command finds the most recent tag that is reachable from a
commit, and if the commit itself is pointed at by the tag, shows
-the tag. Otherwise, it suffixes the tag name with abbreviated
-object name of the commit.
+the tag. Otherwise, it suffixes the tag name with the number of
+additional commits and the abbreviated object name of the commit.
OPTIONS
@@ -35,6 +35,16 @@ OPTIONS
Instead of using the default 8 hexadecimal digits as the
abbreviated object name, use <n> digits.
+--candidates=<n>::
+ Instead of considering only the 10 most recent tags as
+ candidates to describe the input committish consider
+ up to <n> candidates. Increasing <n> above 10 will take
+ slightly longer but may produce a more accurate result.
+
+--debug::
+ Verbosely display information about the searching strategy
+ being employed to standard error. The tag name will still
+ be printed to standard out.
EXAMPLES
--------
@@ -42,12 +52,18 @@ EXAMPLES
With something like git.git current tree, I get:
[torvalds@g5 git]$ git-describe parent
- v1.0.4-g2414721b
+ v1.0.4-14-g2414721
i.e. the current head of my "parent" branch is based on v1.0.4,
-but since it has a few commits on top of that, it has added the
-git hash of the thing to the end: "-g" + 8-char shorthand for
-the commit `2414721b194453f058079d897d13c4e377f92dc6`.
+but since it has a handful commits on top of that,
+describe has added the number of additional commits ("14") and
+an abbreviated object name for the commit itself ("2414721")
+at the end.
+
+The number of additional commits is the number
+of commits which would be displayed by "git log v1.0.4..parent".
+The hash suffix is "-g" + 7-char abbreviation for the tip commit
+of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
Doing a "git-describe" on a tag-name will just show the tag name:
@@ -58,16 +74,43 @@ With --all, the command can use branch heads as references, so
the output shows the reference path as well:
[torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
- tags/v1.0.0-g975b
+ tags/v1.0.0-21-g975b
[torvalds@g5 git]$ git describe --all HEAD^
- heads/lt/describe-g975b
+ heads/lt/describe-7-g975b
+
+With --abbrev set to 0, the command can be used to find the
+closest tagname without any suffix:
+
+ [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
+ tags/v1.0.0
+
+SEARCH STRATEGY
+---------------
+
+For each committish supplied "git describe" will first look for
+a tag which tags exactly that commit. Annotated tags will always
+be preferred over lightweight tags, and tags with newer dates will
+always be preferred over tags with older dates. If an exact match
+is found, its name will be output and searching will stop.
+
+If an exact match was not found "git describe" will walk back
+through the commit history to locate an ancestor commit which
+has been tagged. The ancestor's tag will be output along with an
+abbreviation of the input committish's SHA1.
+
+If multiple tags were found during the walk then the tag which
+has the fewest commits different from the input committish will be
+selected and output. Here fewest commits different is defined as
+the number of commits which would be shown by "git log tag..input"
+will be the smallest number of commits possible.
Author
------
Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
-butchered by Junio C Hamano <junkio@cox.net>
+butchered by Junio C Hamano <junkio@cox.net>. Later significantly
+updated by Shawn Pearce <spearce@spearce.org>.
Documentation
--------------
diff --git a/Documentation/git-diff-stages.txt b/Documentation/git-diff-stages.txt
deleted file mode 100644
index 3273918627..0000000000
--- a/Documentation/git-diff-stages.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-git-diff-stages(1)
-==================
-
-NAME
-----
-git-diff-stages - Compares content and mode of blobs between stages in an unmerged index file
-
-
-SYNOPSIS
---------
-'git-diff-stages' [<common diff options>] <stage1> <stage2> [<path>...]
-
-DESCRIPTION
------------
-Compares the content and mode of the blobs in two stages in an
-unmerged index file.
-
-OPTIONS
--------
-include::diff-options.txt[]
-
-<stage1>,<stage2>::
- The stage number to be compared.
-
-Output format
--------------
-include::diff-format.txt[]
-
-
-Author
-------
-Written by Junio C Hamano <junkio@cox.net>
-
-Documentation
---------------
-Documentation by Junio C Hamano.
-
-GIT
----
-Part of the gitlink:git[7] suite
diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt
index 8977877b21..6a098df26b 100644
--- a/Documentation/git-diff.txt
+++ b/Documentation/git-diff.txt
@@ -47,6 +47,9 @@ Just in case if you are doing something exotic, it should be
noted that all of the <commit> in the above description can be
any <tree-ish>.
+For a more complete list of ways to spell <commit>, see
+"SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
+
OPTIONS
-------
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
new file mode 100644
index 0000000000..445f6b8544
--- /dev/null
+++ b/Documentation/git-fast-import.txt
@@ -0,0 +1,901 @@
+git-fast-import(1)
+==================
+
+NAME
+----
+git-fast-import - Backend for fast Git data importers.
+
+
+SYNOPSIS
+--------
+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.
+
+fast-import reads a mixed command/data stream from standard input and
+writes one or more packfiles directly into the current repository.
+When EOF is received on standard input, fast import writes out
+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 gitlink:git-init[1]) 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.
+
+
+OPTIONS
+-------
+--date-format=<fmt>::
+ Specify the type of dates the frontend will supply to
+ fast-import within `author`, `committer` and `tagger` commands.
+ See ``Date Formats'' below for details about which formats
+ are supported, and their syntax.
+
+--force::
+ Force updating modified existing branches, even if doing
+ so would cause commits to be lost (as the new commit does
+ not contain the old commit).
+
+--max-pack-size=<n>::
+ Maximum size of each output packfile, expressed in MiB.
+ The default is 4096 (4 GiB) as that is the maximum allowed
+ packfile size (due to file format limitations). Some
+ importers may wish to lower this, such as to ensure the
+ resulting packfiles fit on CDs.
+
+--depth=<n>::
+ Maximum delta depth, for blob and tree deltification.
+ Default is 10.
+
+--active-branches=<n>::
+ Maximum number of branches to maintain active at once.
+ See ``Memory Utilization'' below for details. Default is 5.
+
+--export-marks=<file>::
+ Dumps the internal marks table to <file> when complete.
+ Marks are written one per line as `:markid SHA-1`.
+ Frontends can use this file to validate imports after they
+ have been completed.
+
+--export-pack-edges=<file>::
+ After creating a packfile, print a line of data to
+ <file> listing the filename of the packfile and the last
+ commit on each branch that was written to that packfile.
+ 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 gitlink:git-pack-objects[1].
+
+--quiet::
+ Disable all non-fatal output, making fast-import silent when it
+ is successful. This option disables the output shown by
+ \--stats.
+
+--stats::
+ Display some basic statistics about the objects fast-import has
+ created, the packfiles they were stored into, and the
+ memory used by fast-import during this run. Showing this output
+ is currently the default, but can be disabled with \--quiet.
+
+
+Performance
+-----------
+The design of fast-import allows it to import large projects in a minimum
+amount of memory usage and processing time. Assuming the frontend
+is able to keep up with fast-import and feed it a constant stream of data,
+import times for projects holding 10+ years of history and containing
+100,000+ individual commits are generally completed in just 1-2
+hours on quite modest (~$2,000 USD) hardware.
+
+Most bottlenecks appear to be in foreign source data access (the
+source just cannot extract revisions fast enough) or disk IO (fast-import
+writes as fast as the disk will take the data). Imports will run
+faster if the source data is stored on a different drive than the
+destination Git repository (due to less IO contention).
+
+
+Development Cost
+----------------
+A typical frontend for fast-import tends to weigh in at approximately 200
+lines of Perl/Python/Ruby code. Most developers have been able to
+create working importers in just a couple of hours, even though it
+is their first exposure to fast-import, and sometimes even to Git. This is
+an ideal situation, given that most conversion tools are throw-away
+(use once, and never look back).
+
+
+Parallel Operation
+------------------
+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
+are never used by fast-import).
+
+fast-import does not lock the branch or tag refs it is actively importing.
+After the import, during its ref update phase, fast-import tests each
+existing branch ref to verify the update will be a fast-forward
+update (the commit stored in the ref is contained in the new
+history of the commit to be written). If the update is not a
+fast-forward update, fast-import will skip updating that ref and instead
+prints a warning message. fast-import will always attempt to update all
+branch refs, and does not stop on the first failure.
+
+Branch updates can be forced with \--force, but its recommended that
+this only be used on an otherwise quiet repository. Using \--force
+is not necessary for an initial import into an empty repository.
+
+
+Technical Discussion
+--------------------
+fast-import tracks a set of branches in memory. Any branch can be created
+or modified at any point during the import process by sending a
+`commit` command on the input stream. This design allows a frontend
+program to process an unlimited number of branches simultaneously,
+generating commits in the order they are available from the source
+data. It also simplifies the frontend programs considerably.
+
+fast-import does not use or alter the current working directory, or any
+file within it. (It does however update the current Git repository,
+as referenced by `GIT_DIR`.) Therefore an import frontend may use
+the working directory for its own purposes, such as extracting file
+revisions from the foreign source. This ignorance of the working
+directory also allows fast-import to run very quickly, as it does not
+need to perform any costly file update operations when switching
+between branches.
+
+Input Format
+------------
+With the exception of raw file data (which Git does not interpret)
+the fast-import input format is text (ASCII) based. This text based
+format simplifies development and debugging of frontend programs,
+especially when a higher level language such as Perl, Python or
+Ruby is being used.
+
+fast-import is very strict about its input. Where we say SP below we mean
+*exactly* one space. Likewise LF means one (and only one) linefeed.
+Supplying additional whitespace characters will cause unexpected
+results, such as branch names or file names with leading or trailing
+spaces in their name, or early termination of fast-import when it encounters
+unexpected input.
+
+Date Formats
+~~~~~~~~~~~~
+The following date formats are supported. A frontend should select
+the format it will use for this import by passing the format name
+in the \--date-format=<fmt> command line option.
+
+`raw`::
+ This is the Git native format and is `<time> SP <offutc>`.
+ It is also fast-import's default format, if \--date-format was
+ not specified.
++
+The time of the event is specified by `<time>` as the number of
+seconds since the UNIX epoch (midnight, Jan 1, 1970, UTC) and is
+written as an ASCII decimal integer.
++
+The local offset is specified by `<offutc>` as a positive or negative
+offset from UTC. For example EST (which is 5 hours behind UTC)
+would be expressed in `<tz>` by ``-0500'' while UTC is ``+0000''.
+The local offset does not affect `<time>`; it is used only as an
+advisement to help formatting routines display the timestamp.
++
+If the local offset is not available in the source material, use
+``+0000'', or the most common local offset. For example many
+organizations have a CVS repository which has only ever been accessed
+by users who are located in the same location and timezone. In this
+case a reasonable offset from UTC could be assumed.
++
+Unlike the `rfc2822` format, this format is very strict. Any
+variation in formatting will cause fast-import to reject the value.
+
+`rfc2822`::
+ This is the standard email format as described by RFC 2822.
++
+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 gitlink:git-am[1] when applying patches
+received from email.
++
+Some malformed strings may be accepted as valid dates. In some of
+these cases Git will still be able to obtain the correct date from
+the malformed string. There are also some types of malformed
+strings which Git will parse wrong, and yet consider valid.
+Seriously malformed strings will be rejected.
++
+Unlike the `raw` format above, the timezone/UTC offset information
+contained in an RFC 2822 date string is used to adjust the date
+value to UTC prior to storage. Therefore it is important that
+this information be as accurate as possible.
++
+If the source material uses RFC 2822 style dates,
+the frontend should let fast-import handle the parsing and conversion
+(rather than attempting to do it itself) as the Git parser has
+been well tested in the wild.
++
+Frontends should prefer the `raw` format if the source material
+already uses UNIX-epoch format, can be coaxed to give dates in that
+format, or its format is easiliy convertible to it, as there is no
+ambiguity in parsing.
+
+`now`::
+ Always use the current time and timezone. The literal
+ `now` must always be supplied for `<when>`.
++
+This is a toy format. The current time and timezone of this system
+is always copied into the identity string at the time it is being
+created by fast-import. There is no way to specify a different time or
+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
+gitlink:git-update-index[1].
++
+If separate `author` and `committer` commands are used in a `commit`
+the timestamps may not match, as the system clock will be polled
+twice (once for each command). The only way to ensure that both
+author and committer identity information has the same timestamp
+is to omit `author` (thus copying from `committer`) or to use a
+date format other than `now`.
+
+Commands
+~~~~~~~~
+fast-import accepts several commands to update the current repository
+and control the current import process. More detailed discussion
+(with examples) of each command follows later.
+
+`commit`::
+ Creates a new branch or updates an existing branch by
+ creating a new commit and updating the branch to point at
+ the newly created commit.
+
+`tag`::
+ Creates an annotated tag object from an existing commit or
+ branch. Lightweight tags are not supported by this command,
+ as they are not recommended for recording meaningful points
+ in time.
+
+`reset`::
+ Reset an existing branch (or a new branch) to a specific
+ revision. This command must be used to change a branch to
+ a specific revision without making a commit on it.
+
+`blob`::
+ Convert raw file data into a blob, for future use in a
+ `commit` command. This command is optional and is not
+ needed to perform an import.
+
+`checkpoint`::
+ Forces fast-import to close the current packfile, generate its
+ unique SHA-1 checksum and index, and start a new packfile.
+ This command is optional and is not needed to perform
+ an import.
+
+`commit`
+~~~~~~~~
+Create or update a branch with a new commit, recording one logical
+change to the project.
+
+....
+ 'commit' SP <ref> LF
+ mark?
+ ('author' SP <name> SP LT <email> GT SP <when> LF)?
+ 'committer' SP <name> SP LT <email> GT SP <when> LF
+ data
+ ('from' SP <committish> LF)?
+ ('merge' SP <committish> LF)?
+ (filemodify | filedelete | filedeleteall)*
+ LF
+....
+
+where `<ref>` is the name of the branch to make the commit on.
+Typically branch names are prefixed with `refs/heads/` in
+Git, so importing the CVS branch symbol `RELENG-1_0` would use
+`refs/heads/RELENG-1_0` for the value of `<ref>`. The value of
+`<ref>` must be a valid refname in Git. As `LF` is not valid in
+a Git refname, no quoting or escaping syntax is supported here.
+
+A `mark` command may optionally appear, requesting fast-import to save a
+reference to the newly created commit for future use by the frontend
+(see below for format). It is very common for frontends to mark
+every commit they create, thereby allowing future branch creation
+from any imported commit.
+
+The `data` command following `committer` must supply the commit
+message (see below for `data` command syntax). To import an empty
+commit message use a 0 length data. Commit messages are free-form
+and are not interpreted by Git. Currently they must be encoded in
+UTF-8, as fast-import does not permit other encodings to be specified.
+
+Zero or more `filemodify`, `filedelete` and `filedeleteall` commands
+may be included to update the contents of the branch prior to
+creating the commit. These commands may be supplied in any order.
+However it is recommended that a `filedeleteall` command preceed
+all `filemodify` commands in the same commit, as `filedeleteall`
+wipes the branch clean (see below).
+
+`author`
+^^^^^^^^
+An `author` command may optionally appear, if the author information
+might differ from the committer information. If `author` is omitted
+then fast-import will automatically use the committer's information for
+the author portion of the commit. See below for a description of
+the fields in `author`, as they are identical to `committer`.
+
+`committer`
+^^^^^^^^^^^
+The `committer` command indicates who made this commit, and when
+they made it.
+
+Here `<name>` is the person's display name (for example
+``Com M Itter'') and `<email>` is the person's email address
+(``cm@example.com''). `LT` and `GT` are the literal less-than (\x3c)
+and greater-than (\x3e) symbols. These are required to delimit
+the email address from the other fields in the line. Note that
+`<name>` is free-form and may contain any sequence of bytes, except
+`LT` and `LF`. It is typically UTF-8 encoded.
+
+The time of the change is specified by `<when>` using the date format
+that was selected by the \--date-format=<fmt> command line option.
+See ``Date Formats'' above for the set of supported formats, and
+their syntax.
+
+`from`
+^^^^^^
+The `from` command is used to specify the commit to initialize
+this branch from. This revision will be the first ancestor of the
+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.
+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.
+
+As `LF` is not valid in a Git refname or SHA-1 expression, no
+quoting or escaping syntax is supported within `<committish>`.
+
+Here `<committish>` is any of the following:
+
+* The name of an existing branch already in fast-import's internal branch
+ table. If fast-import doesn't know the name, its treated as a SHA-1
+ expression.
+
+* A mark reference, `:<idnum>`, where `<idnum>` is the mark number.
++
+The reason fast-import uses `:` to denote a mark reference is this character
+is not legal in a Git branch name. The leading `:` makes it easy
+to distingush between the mark 42 (`:42`) and the branch 42 (`42`
+or `refs/heads/42`), or an abbreviated SHA-1 which happened to
+consist only of base-10 digits.
++
+Marks must be declared (via `mark`) before they can be used.
+
+* A complete 40 byte or abbreviated commit SHA-1 in hex.
+
+* Any valid Git SHA-1 expression that resolves to a commit. See
+ ``SPECIFYING REVISIONS'' in gitlink:git-rev-parse[1] for details.
+
+The special case of restarting an incremental import from the
+current branch value should be written as:
+----
+ from refs/heads/branch^0
+----
+The `{caret}0` suffix is necessary as fast-import does not permit a branch to
+start from itself, and the branch is created in memory before the
+`from` command is even read from the input. Adding `{caret}0` will force
+fast-import to resolve the commit through Git's revision parsing library,
+rather than its internal branch table, thereby loading in the
+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
+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.
+
+Here `<committish>` is any of the commit specification expressions
+also accepted by `from` (see above).
+
+`filemodify`
+^^^^^^^^^^^^
+Included in a `commit` command to add a new file or change the
+content of an existing file. This command has two different means
+of specifying the content of the file.
+
+External data format::
+ The data content for the file was already supplied by a prior
+ `blob` command. The frontend just needs to connect it.
++
+....
+ 'M' SP <mode> SP <dataref> SP <path> LF
+....
++
+Here `<dataref>` can be either a mark reference (`:<idnum>`)
+set by a prior `blob` command, or a full 40-byte SHA-1 of an
+existing Git blob object.
+
+Inline data format::
+ The data content for the file has not been supplied yet.
+ The frontend wants to supply it as part of this modify
+ command.
++
+....
+ 'M' SP <mode> SP 'inline' SP <path> LF
+ data
+....
++
+See below for a detailed description of the `data` command.
+
+In both formats `<mode>` is the type of file entry, specified
+in octal. Git only supports the following modes:
+
+* `100644` or `644`: A normal (not-executable) file. The majority
+ of files in most projects use this mode. If in doubt, this is
+ what you want.
+* `100755` or `755`: A normal, but executable, file.
+* `120000`: A symlink, the content of the file will be the link target.
+
+In both formats `<path>` is the complete path of the file to be added
+(if not already existing) or modified (if already existing).
+
+A `<path>` string must use UNIX-style directory seperators (forward
+slash `/`), may contain any byte other than `LF`, and must not
+start with double quote (`"`).
+
+If an `LF` or double quote must be encoded into `<path>` shell-style
+quoting should be used, e.g. `"path/with\n and \" in it"`.
+
+The value of `<path>` must be in canoncial form. That is it must not:
+
+* contain an empty directory component (e.g. `foo//bar` is invalid),
+* end with a directory seperator (e.g. `foo/` is invalid),
+* start with a directory seperator (e.g. `/foo` is invalid),
+* contain the special component `.` or `..` (e.g. `foo/./bar` and
+ `foo/../bar` are invalid).
+
+It is recommended that `<path>` always be encoded using UTF-8.
+
+`filedelete`
+^^^^^^^^^^^^
+Included in a `commit` command to remove a file from the branch.
+If the file removal makes its directory empty, the directory will
+be automatically removed too. This cascades up the tree until the
+first non-empty directory or the root is reached.
+
+....
+ 'D' SP <path> LF
+....
+
+here `<path>` is the complete path of the file to be removed.
+See `filemodify` above for a detailed description of `<path>`.
+
+`filedeleteall`
+^^^^^^^^^^^^^^^
+Included in a `commit` command to remove all files (and also all
+directories) from the branch. This command resets the internal
+branch structure to have no files in it, allowing the frontend
+to subsequently add all interesting files from scratch.
+
+....
+ 'deleteall' LF
+....
+
+This command is extremely useful if the frontend does not know
+(or does not care to know) what files are currently on the branch,
+and therefore cannot generate the proper `filedelete` commands to
+update the content.
+
+Issuing a `filedeleteall` followed by the needed `filemodify`
+commands to set the correct content will produce the same results
+as sending only the needed `filemodify` and `filedelete` commands.
+The `filedeleteall` approach may however require fast-import to use slightly
+more memory per active branch (less than 1 MiB for even most large
+projects); so frontends that can easily obtain only the affected
+paths for a commit are encouraged to do so.
+
+`mark`
+~~~~~~
+Arranges for fast-import to save a reference to the current object, allowing
+the frontend to recall this object at a future point in time, without
+knowing its SHA-1. Here the current object is the object creation
+command the `mark` command appears within. This can be `commit`,
+`tag`, and `blob`, but `commit` is the most common usage.
+
+....
+ 'mark' SP ':' <idnum> LF
+....
+
+where `<idnum>` is the number assigned by the frontend to this mark.
+The value of `<idnum>` is expressed as an ASCII decimal integer.
+The value 0 is reserved and cannot be used as
+a mark. Only values greater than or equal to 1 may be used as marks.
+
+New marks are created automatically. Existing marks can be moved
+to another object simply by reusing the same `<idnum>` in another
+`mark` command.
+
+`tag`
+~~~~~
+Creates an annotated tag referring to a specific commit. To create
+lightweight (non-annotated) tags see the `reset` command below.
+
+....
+ 'tag' SP <name> LF
+ 'from' SP <committish> LF
+ 'tagger' SP <name> SP LT <email> GT SP <when> LF
+ data
+ LF
+....
+
+where `<name>` is the name of the tag to create.
+
+Tag names are automatically prefixed with `refs/tags/` when stored
+in Git, so importing the CVS branch symbol `RELENG-1_0-FINAL` would
+use just `RELENG-1_0-FINAL` for `<name>`, and fast-import will write the
+corresponding ref as `refs/tags/RELENG-1_0-FINAL`.
+
+The value of `<name>` must be a valid refname in Git and therefore
+may contain forward slashes. As `LF` is not valid in a Git refname,
+no quoting or escaping syntax is supported here.
+
+The `from` command is the same as in the `commit` command; see
+above for details.
+
+The `tagger` command uses the same format as `committer` within
+`commit`; again see above for details.
+
+The `data` command following `tagger` must supply the annotated tag
+message (see below for `data` command syntax). To import an empty
+tag message use a 0 length data. Tag messages are free-form and are
+not interpreted by Git. Currently they must be encoded in UTF-8,
+as fast-import does not permit other encodings to be specified.
+
+Signing annotated tags during import from within fast-import is not
+supported. Trying to include your own PGP/GPG signature is not
+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 gitlink:git-tag[1] process.
+
+`reset`
+~~~~~~~
+Creates (or recreates) the named branch, optionally starting from
+a specific revision. The reset command allows a frontend to issue
+a new `from` command for an existing branch, or to create a new
+branch from an existing commit without creating a new commit.
+
+....
+ 'reset' SP <ref> LF
+ ('from' SP <committish> LF)?
+ LF
+....
+
+For a detailed description of `<ref>` and `<committish>` see above
+under `commit` and `from`.
+
+The `reset` command can also be used to create lightweight
+(non-annotated) tags. For example:
+
+====
+ reset refs/tags/938
+ from :938
+====
+
+would create the lightweight tag `refs/tags/938` referring to
+whatever commit mark `:938` references.
+
+`blob`
+~~~~~~
+Requests writing one file revision to the packfile. The revision
+is not connected to any commit; this connection must be formed in
+a subsequent `commit` command by referencing the blob through an
+assigned mark.
+
+....
+ 'blob' LF
+ mark?
+ data
+....
+
+The mark command is optional here as some frontends have chosen
+to generate the Git SHA-1 for the blob on their own, and feed that
+directly to `commit`. This is typically more work than its worth
+however, as marks are inexpensive to store and easy to use.
+
+`data`
+~~~~~~
+Supplies raw data (for use as blob/file content, commit messages, or
+annotated tag messages) to fast-import. Data can be supplied using an exact
+byte count or delimited with a terminating line. Real frontends
+intended for production-quality conversions should always use the
+exact byte count format, as it is more robust and performs better.
+The delimited format is intended primarily for testing fast-import.
+
+Exact byte count format::
+ The frontend must specify the number of bytes of data.
++
+....
+ 'data' SP <count> LF
+ <raw> LF
+....
++
+where `<count>` is the exact number of bytes appearing within
+`<raw>`. The value of `<count>` is expressed as an ASCII decimal
+integer. The `LF` on either side of `<raw>` is not
+included in `<count>` and will not be included in the imported data.
+
+Delimited format::
+ A delimiter string is used to mark the end of the data.
+ fast-import will compute the length by searching for the delimiter.
+ This format is primarly useful for testing and is not
+ recommended for real data.
++
+....
+ 'data' SP '<<' <delim> LF
+ <raw> LF
+ <delim> LF
+....
++
+where `<delim>` is the chosen delimiter string. The string `<delim>`
+must not appear on a line by itself within `<raw>`, as otherwise
+fast-import will think the data ends earlier than it really does. The `LF`
+immediately trailing `<raw>` is part of `<raw>`. This is one of
+the limitations of the delimited format, it is impossible to supply
+a data chunk which does not have an LF as its last byte.
+
+`checkpoint`
+~~~~~~~~~~~~
+Forces fast-import to close the current packfile, start a new one, and to
+save out all current branch refs, tags and marks.
+
+....
+ 'checkpoint' LF
+ LF
+....
+
+Note that fast-import automatically switches packfiles when the current
+packfile reaches \--max-pack-size, or 4 GiB, whichever limit is
+smaller. During an automatic packfile switch fast-import does not update
+the branch refs, tags or marks.
+
+As a `checkpoint` can require a significant amount of CPU time and
+disk IO (to compute the overall pack SHA-1 checksum, generate the
+corresponding index file, and update the refs) it can easily take
+several minutes for a single `checkpoint` command to complete.
+
+Frontends may choose to issue checkpoints during extremely large
+and long running imports, or when they need to allow another Git
+process access to a branch. However given that a 30 GiB Subversion
+repository can be loaded into Git through fast-import in about 3 hours,
+explicit checkpointing may not be necessary.
+
+
+Tips and Tricks
+---------------
+The following tips and tricks have been collected from various
+users of fast-import, and are offered here as suggestions.
+
+Use One Mark Per Commit
+~~~~~~~~~~~~~~~~~~~~~~~
+When doing a repository conversion, use a unique mark per commit
+(`mark :<n>`) and supply the \--export-marks option on the command
+line. fast-import will dump a file which lists every mark and the Git
+object SHA-1 that corresponds to it. If the frontend can tie
+the marks back to the source repository, it is easy to verify the
+accuracy and completeness of the import by comparing each Git
+commit to the corresponding source revision.
+
+Coming from a system such as Perforce or Subversion this should be
+quite simple, as the fast-import mark can also be the Perforce changeset
+number or the Subversion revision number.
+
+Freely Skip Around Branches
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Don't bother trying to optimize the frontend to stick to one branch
+at a time during an import. Although doing so might be slightly
+faster for fast-import, it tends to increase the complexity of the frontend
+code considerably.
+
+The branch LRU builtin to fast-import tends to behave very well, and the
+cost of activating an inactive branch is so low that bouncing around
+between branches has virtually no impact on import performance.
+
+Handling Renames
+~~~~~~~~~~~~~~~~
+When importing a renamed file or directory, simply delete the old
+name(s) and modify the new name(s) during the corresponding commit.
+Git performs rename detection after-the-fact, rather than explicitly
+during a commit.
+
+Use Tag Fixup Branches
+~~~~~~~~~~~~~~~~~~~~~~
+Some other SCM systems let the user create a tag from multiple
+files which are not from the same commit/changeset. Or to create
+tags which are a subset of the files available in the repository.
+
+Importing these tags as-is in Git is impossible without making at
+least one commit which ``fixes up'' the files to match the content
+of the tag. Use fast-import's `reset` command to reset a dummy branch
+outside of your normal branch space to the base commit for the tag,
+then commit one or more file fixup commits, and finally tag the
+dummy branch.
+
+For example since all normal branches are stored under `refs/heads/`
+name the tag fixup branch `TAG_FIXUP`. This way it is impossible for
+the fixup branch used by the importer to have namespace conflicts
+with real branches imported from the source (the name `TAG_FIXUP`
+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 gitlink:git-blame[1] to track
+through the real commit history and properly annotate the source
+files.
+
+After fast-import terminates the frontend will need to do `rm .git/TAG_FIXUP`
+to remove the dummy branch.
+
+Import Now, Repack Later
+~~~~~~~~~~~~~~~~~~~~~~~~
+As soon as fast-import completes the Git repository is completely valid
+and ready for use. Typicallly this takes only a very short time,
+even for considerably large projects (100,000+ commits).
+
+However repacking the repository is necessary to improve data
+locality and access performance. It can also take hours on extremely
+large projects (especially if -f and a large \--window parameter is
+used). Since repacking is safe to run alongside readers and writers,
+run the repack in the background and let it finish when it finishes.
+There is no reason to wait to explore your new Git project!
+
+If you choose to wait for the repack, don't try to run benchmarks
+or performance tests until repacking is completed. fast-import outputs
+suboptimal packfiles that are simply never seen in real use
+situations.
+
+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 gitlink:git-repack[1].
+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.
+
+
+Packfile Optimization
+---------------------
+When packing a blob fast-import always attempts to deltify against the last
+blob written. Unless specifically arranged for by the frontend,
+this will probably not be a prior version of the same file, so the
+generated delta will not be the smallest possible. The resulting
+packfile will be compressed, but will not be optimal.
+
+Frontends which have efficient access to all revisions of a
+single file (for example reading an RCS/CVS ,v file) can choose
+to supply all revisions of that file as a sequence of consecutive
+`blob` commands. This allows fast-import to deltify the different file
+revisions against each other, saving space in the final packfile.
+Marks can be used to later identify individual file revisions during
+a sequence of `commit` commands.
+
+The packfile(s) created by fast-import do not encourage good disk access
+patterns. This is caused by fast-import writing the data in the order
+it is received on standard input, while Git typically organizes
+data within packfiles to make the most recent (current tip) data
+appear before historical data. Git also clusters commits together,
+speeding up revision traversal through better cache locality.
+
+For this reason it is strongly recommended that users repack the
+repository with `git repack -a -d` after fast-import completes, allowing
+Git to reorganize the packfiles for faster data access. If blob
+deltas are suboptimal (see above) then also adding the `-f` option
+to force recomputation of all deltas can significantly reduce the
+final packfile size (30-50% smaller can be quite typical).
+
+
+Memory Utilization
+------------------
+There are a number of factors which affect how much memory fast-import
+requires to perform an import. Like critical sections of core
+Git, fast-import uses its own memory allocators to ammortize any overheads
+associated with malloc. In practice fast-import tends to ammoritize any
+malloc overheads to 0, due to its use of large block allocations.
+
+per object
+~~~~~~~~~~
+fast-import maintains an in-memory structure for every object written in
+this execution. On a 32 bit system the structure is 32 bytes,
+on a 64 bit system the structure is 40 bytes (due to the larger
+pointer sizes). Objects in the table are not deallocated until
+fast-import terminates. Importing 2 million objects on a 32 bit system
+will require approximately 64 MiB of memory.
+
+The object table is actually a hashtable keyed on the object name
+(the unique SHA-1). This storage configuration allows fast-import to reuse
+an existing or already written object and avoid writing duplicates
+to the output packfile. Duplicate blobs are surprisingly common
+in an import, typically due to branch merges in the source.
+
+per mark
+~~~~~~~~
+Marks are stored in a sparse array, using 1 pointer (4 bytes or 8
+bytes, depending on pointer size) per mark. Although the array
+is sparse, frontends are still strongly encouraged to use marks
+between 1 and n, where n is the total number of marks required for
+this import.
+
+per branch
+~~~~~~~~~~
+Branches are classified as active and inactive. The memory usage
+of the two classes is significantly different.
+
+Inactive branches are stored in a structure which uses 96 or 120
+bytes (32 bit or 64 bit systems, respectively), plus the length of
+the branch name (typically under 200 bytes), per branch. fast-import will
+easily handle as many as 10,000 inactive branches in under 2 MiB
+of memory.
+
+Active branches have the same overhead as inactive branches, but
+also contain copies of every tree that has been recently modified on
+that branch. If subtree `include` has not been modified since the
+branch became active, its contents will not be loaded into memory,
+but if subtree `src` has been modified by a commit since the branch
+became active, then its contents will be loaded in memory.
+
+As active branches store metadata about the files contained on that
+branch, their in-memory storage size can grow to a considerable size
+(see below).
+
+fast-import automatically moves active branches to inactive status based on
+a simple least-recently-used algorithm. The LRU chain is updated on
+each `commit` command. The maximum number of active branches can be
+increased or decreased on the command line with \--active-branches=.
+
+per active tree
+~~~~~~~~~~~~~~~
+Trees (aka directories) use just 12 bytes of memory on top of the
+memory required for their entries (see ``per active file'' below).
+The cost of a tree is virtually 0, as its overhead ammortizes out
+over the individual file entries.
+
+per active file entry
+~~~~~~~~~~~~~~~~~~~~~
+Files (and pointers to subtrees) within active trees require 52 or 64
+bytes (32/64 bit platforms) per entry. To conserve space, file and
+tree names are pooled in a common string table, allowing the filename
+``Makefile'' to use just 16 bytes (after including the string header
+overhead) no matter how many times it occurs within the project.
+
+The active branch LRU, when coupled with the filename string pool
+and lazy loading of subtrees, allows fast-import to efficiently import
+projects with 2,000+ branches and 45,114+ files in a very limited
+memory footprint (less than 2.7 MiB per active branch).
+
+
+Author
+------
+Written by Shawn O. Pearce <spearce@spearce.org>.
+
+Documentation
+--------------
+Documentation by Shawn O. Pearce <spearce@spearce.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt
index 3e6cd880b0..105d76b0ba 100644
--- a/Documentation/git-fetch-pack.txt
+++ b/Documentation/git-fetch-pack.txt
@@ -8,10 +8,13 @@ git-fetch-pack - Receive missing objects from another repository
SYNOPSIS
--------
-'git-fetch-pack' [-q] [-k] [--exec=<git-upload-pack>] [<host>:]<directory> [<refs>...]
+'git-fetch-pack' [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]
DESCRIPTION
-----------
+Usually you would want to use gitlink:git-fetch[1] which is a
+higher level wrapper of this command instead.
+
Invokes 'git-upload-pack' on a potentially remote repository,
and asks it to send objects missing from this repository, to
update the named heads. The list of commits available locally
@@ -25,17 +28,24 @@ have a common ancestor commit.
OPTIONS
-------
--q::
+\--all::
+ Fetch all remote refs.
+
+\--quiet, \-q::
Pass '-q' flag to 'git-unpack-objects'; this makes the
cloning process less verbose.
--k::
+\--keep, \-k::
Do not invoke 'git-unpack-objects' on received data, but
create a single packfile out of it instead, and store it
in the object database. If provided twice then the pack is
locked against repacking.
---exec=<git-upload-pack>::
+\--thin::
+ Spend extra cycles to minimize the number of objects to be sent.
+ Use it on slower connection.
+
+\--upload-pack=<git-upload-pack>::
Use this to specify the path to 'git-upload-pack' on the
remote side, if is not found on your $PATH.
Installations of sshd ignores the user's environment
@@ -47,6 +57,15 @@ OPTIONS
shells by having a lean .bashrc file (they set most of
the things up in .bash_profile).
+\--exec=<git-upload-pack>::
+ Same as \--upload-pack=<git-upload-pack>.
+
+\--depth=<n>::
+ Limit fetching to ancestor-chains not longer than n.
+
+\-v::
+ Run verbosely.
+
<host>::
A remote host that houses the repository. When this
part is specified, 'git-upload-pack' is invoked via
diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
index a9e86fd26b..5fbeab76b7 100644
--- a/Documentation/git-fetch.txt
+++ b/Documentation/git-fetch.txt
@@ -3,7 +3,7 @@ git-fetch(1)
NAME
----
-git-fetch - Download objects and a head from another repository
+git-fetch - Download objects and refs from another repository
SYNOPSIS
@@ -20,6 +20,14 @@ 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".
+When <refspec> stores the fetched result in tracking branches,
+the tags that point at these branches are automatically
+followed. This is done by first fetching from the remote using
+the given <refspec>s, and if the repository has objects that are
+pointed by remote tags that it does not yet have, then fetch
+those missing tags. If the other end has tags that point at
+branches you are not interested in, you will not get them.
+
OPTIONS
-------
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt
index 2bf6aef735..f49b0d944c 100644
--- a/Documentation/git-for-each-ref.txt
+++ b/Documentation/git-for-each-ref.txt
@@ -7,7 +7,7 @@ git-for-each-ref - Output information on each ref
SYNOPSIS
--------
-'git-for-each-ref' [--count=<count>]\* [--shell|--perl|--python] [--sort=<key>]\* [--format=<format>] [<pattern>]
+'git-for-each-ref' [--count=<count>]\* [--shell|--perl|--python|--tcl] [--sort=<key>]\* [--format=<format>] [<pattern>]
DESCRIPTION
-----------
@@ -15,7 +15,7 @@ DESCRIPTION
Iterate over all refs that match `<pattern>` and show them
according to the given `<format>`, after sorting them according
to the given set of `<key>`. If `<max>` is given, stop after
-showing that many refs. The interporated values in `<format>`
+showing that many refs. The interpolated values in `<format>`
can optionally be quoted as string literals in the specified
host language allowing their direct evaluation in that language.
@@ -49,7 +49,7 @@ OPTIONS
using fnmatch(3). Refs that do not match the pattern
are not shown.
---shell, --perl, --python::
+--shell, --perl, --python, --tcl::
If given, strings that substitute `%(fieldname)`
placeholders are quoted as string literals suitable for
the specified host language. This is meant to produce
@@ -66,7 +66,7 @@ keys.
For all objects, the following names can be used:
refname::
- The name of the ref (the part after $GIT_DIR/refs/).
+ The name of the ref (the part after $GIT_DIR/).
objecttype::
The type of the object (`blob`, `tree`, `commit`, `tag`).
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 67425dc035..59f34b9f0d 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -11,7 +11,8 @@ SYNOPSIS
[verse]
'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]
[-s | --signoff] [--diff-options] [--start-number <n>]
- [--in-reply-to=Message-Id]
+ [--in-reply-to=Message-Id] [--suffix=.<sfx>]
+ [--ignore-if-in-upstream]
<since>[..<until>]
DESCRIPTION
@@ -20,7 +21,9 @@ DESCRIPTION
Prepare each commit between <since> and <until> with its patch in
one file per commit, formatted to resemble UNIX mailbox format.
If ..<until> is not specified, the head of the current working
-tree is implied.
+tree is implied. For a more complete list of ways to spell
+<since> and <until>, see "SPECIFYING REVISIONS" section in
+gitlink:git-rev-parse[1].
The output of this command is convenient for e-mail submission or
for use with gitlink:git-am[1].
@@ -78,13 +81,34 @@ OPTIONS
reply to the given Message-Id, which avoids breaking threads to
provide a new patch series.
+--ignore-if-in-upstream::
+ Do not include a patch that matches a commit in
+ <until>..<since>. This will examine all patches reachable
+ from <since> but not from <until> and compare them with the
+ patches being generated, and any patch that matches is
+ ignored.
+
+--suffix=.<sfx>::
+ Instead of using `.patch` as the suffix for generated
+ filenames, use specifed suffix. A common alternative is
+ `--suffix=.txt`.
++
+Note that you would need to include the leading dot `.` if you
+want a filename like `0001-description-of-my-change.patch`, and
+the first letter does not have to be a dot. Leaving it empty would
+not add any suffix.
+
CONFIGURATION
-------------
You can specify extra mail header lines to be added to each
-message in the repository configuration as follows:
+message in the repository configuration. Also you can specify
+the default suffix different from the built-in one:
+------------
[format]
headers = "Organization: git-foo\n"
+ suffix = .txt
+------------
EXAMPLES
@@ -109,6 +133,9 @@ git-format-patch -M -B origin::
understand renaming patches, so use it only when you know
the recipient uses git to apply your patch.
+git-format-patch -3::
+ Extract three topmost commits from the current branch
+ and format them as e-mailable patches.
See Also
--------
diff --git a/Documentation/git-fsck-objects.txt b/Documentation/git-fsck-objects.txt
index d0af99d351..f21061ecfe 100644
--- a/Documentation/git-fsck-objects.txt
+++ b/Documentation/git-fsck-objects.txt
@@ -8,132 +8,10 @@ git-fsck-objects - Verifies the connectivity and validity of the objects in the
SYNOPSIS
--------
-[verse]
-'git-fsck-objects' [--tags] [--root] [--unreachable] [--cache]
- [--full] [--strict] [<object>*]
+'git-fsck-objects' ...
DESCRIPTION
-----------
-Verifies the connectivity and validity of the objects in the database.
-
-OPTIONS
--------
-<object>::
- An object to treat as the head of an unreachability trace.
-+
-If no objects are given, git-fsck-objects defaults to using the
-index file and all SHA1 references in .git/refs/* as heads.
-
---unreachable::
- Print out objects that exist but that aren't readable from any
- of the reference nodes.
-
---root::
- Report root nodes.
-
---tags::
- Report tags.
-
---cache::
- Consider any object recorded in the index also as a head node for
- an unreachability trace.
-
---full::
- Check not just objects in GIT_OBJECT_DIRECTORY
- ($GIT_DIR/objects), but also the ones found in alternate
- object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES
- or $GIT_DIR/objects/info/alternates,
- and in packed git archives found in $GIT_DIR/objects/pack
- and corresponding pack subdirectories in alternate
- object pools.
-
---strict::
- Enable more strict checking, namely to catch a file mode
- recorded with g+w bit set, which was created by older
- versions of git. Existing repositories, including the
- Linux kernel, git itself, and sparse repository have old
- objects that triggers this check, but it is recommended
- to check new projects with this flag.
-
-It tests SHA1 and general object sanity, and it does full tracking of
-the resulting reachability and everything else. It prints out any
-corruption it finds (missing or bad objects), and if you use the
-'--unreachable' flag it will also print out objects that exist but
-that aren't readable from any of the specified head nodes.
-
-So for example
-
- git-fsck-objects --unreachable HEAD $(cat .git/refs/heads/*)
-
-will do quite a _lot_ of verification on the tree. There are a few
-extra validity tests to be added (make sure that tree objects are
-sorted properly etc), but on the whole if "git-fsck-objects" is happy, you
-do have a valid tree.
-
-Any corrupt objects you will have to find in backups or other archives
-(i.e., you can just remove them and do an "rsync" with some other site in
-the hopes that somebody else has the object you have corrupted).
-
-Of course, "valid tree" doesn't mean that it wasn't generated by some
-evil person, and the end result might be crap. git is a revision
-tracking system, not a quality assurance system ;)
-
-Extracted Diagnostics
----------------------
-
-expect dangling commits - potential heads - due to lack of head information::
- You haven't specified any nodes as heads so it won't be
- possible to differentiate between un-parented commits and
- root nodes.
-
-missing sha1 directory '<dir>'::
- The directory holding the sha1 objects is missing.
-
-unreachable <type> <object>::
- The <type> object <object>, isn't actually referred to directly
- or indirectly in any of the trees or commits seen. This can
- mean that there's another root node that you're not specifying
- or that the tree is corrupt. If you haven't missed a root node
- then you might as well delete unreachable nodes since they
- can't be used.
-
-missing <type> <object>::
- The <type> object <object>, is referred to but isn't present in
- the database.
-
-dangling <type> <object>::
- The <type> object <object>, is present in the database but never
- 'directly' used. A dangling commit could be a root node.
-
-warning: git-fsck-objects: tree <tree> has full pathnames in it::
- And it shouldn't...
-
-sha1 mismatch <object>::
- The database has an object who's sha1 doesn't match the
- database value.
- This indicates a serious data integrity problem.
-
-Environment Variables
----------------------
-
-GIT_OBJECT_DIRECTORY::
- used to specify the object database root (usually $GIT_DIR/objects)
-
-GIT_INDEX_FILE::
- used to specify the index file of the index
-
-GIT_ALTERNATE_OBJECT_DIRECTORIES::
- used to specify additional object database roots (usually unset)
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the gitlink:git[7] suite
+This is a synonym for gitlink:git-fsck[1]. Please refer to the
+documentation of that command.
diff --git a/Documentation/git-fsck.txt b/Documentation/git-fsck.txt
new file mode 100644
index 0000000000..058009d2fa
--- /dev/null
+++ b/Documentation/git-fsck.txt
@@ -0,0 +1,139 @@
+git-fsck(1)
+===========
+
+NAME
+----
+git-fsck - Verifies the connectivity and validity of the objects in the database
+
+
+SYNOPSIS
+--------
+[verse]
+'git-fsck' [--tags] [--root] [--unreachable] [--cache]
+ [--full] [--strict] [<object>*]
+
+DESCRIPTION
+-----------
+Verifies the connectivity and validity of the objects in the database.
+
+OPTIONS
+-------
+<object>::
+ An object to treat as the head of an unreachability trace.
++
+If no objects are given, git-fsck defaults to using the
+index file and all SHA1 references in .git/refs/* as heads.
+
+--unreachable::
+ Print out objects that exist but that aren't readable from any
+ of the reference nodes.
+
+--root::
+ Report root nodes.
+
+--tags::
+ Report tags.
+
+--cache::
+ Consider any object recorded in the index also as a head node for
+ an unreachability trace.
+
+--full::
+ Check not just objects in GIT_OBJECT_DIRECTORY
+ ($GIT_DIR/objects), but also the ones found in alternate
+ object pools listed in GIT_ALTERNATE_OBJECT_DIRECTORIES
+ or $GIT_DIR/objects/info/alternates,
+ and in packed git archives found in $GIT_DIR/objects/pack
+ and corresponding pack subdirectories in alternate
+ object pools.
+
+--strict::
+ Enable more strict checking, namely to catch a file mode
+ recorded with g+w bit set, which was created by older
+ versions of git. Existing repositories, including the
+ Linux kernel, git itself, and sparse repository have old
+ objects that triggers this check, but it is recommended
+ to check new projects with this flag.
+
+It tests SHA1 and general object sanity, and it does full tracking of
+the resulting reachability and everything else. It prints out any
+corruption it finds (missing or bad objects), and if you use the
+'--unreachable' flag it will also print out objects that exist but
+that aren't readable from any of the specified head nodes.
+
+So for example
+
+ git-fsck --unreachable HEAD $(cat .git/refs/heads/*)
+
+will do quite a _lot_ of verification on the tree. There are a few
+extra validity tests to be added (make sure that tree objects are
+sorted properly etc), but on the whole if "git-fsck" is happy, you
+do have a valid tree.
+
+Any corrupt objects you will have to find in backups or other archives
+(i.e., you can just remove them and do an "rsync" with some other site in
+the hopes that somebody else has the object you have corrupted).
+
+Of course, "valid tree" doesn't mean that it wasn't generated by some
+evil person, and the end result might be crap. git is a revision
+tracking system, not a quality assurance system ;)
+
+Extracted Diagnostics
+---------------------
+
+expect dangling commits - potential heads - due to lack of head information::
+ You haven't specified any nodes as heads so it won't be
+ possible to differentiate between un-parented commits and
+ root nodes.
+
+missing sha1 directory '<dir>'::
+ The directory holding the sha1 objects is missing.
+
+unreachable <type> <object>::
+ The <type> object <object>, isn't actually referred to directly
+ or indirectly in any of the trees or commits seen. This can
+ mean that there's another root node that you're not specifying
+ or that the tree is corrupt. If you haven't missed a root node
+ then you might as well delete unreachable nodes since they
+ can't be used.
+
+missing <type> <object>::
+ The <type> object <object>, is referred to but isn't present in
+ the database.
+
+dangling <type> <object>::
+ The <type> object <object>, is present in the database but never
+ 'directly' used. A dangling commit could be a root node.
+
+warning: git-fsck: tree <tree> has full pathnames in it::
+ And it shouldn't...
+
+sha1 mismatch <object>::
+ The database has an object who's sha1 doesn't match the
+ database value.
+ This indicates a serious data integrity problem.
+
+Environment Variables
+---------------------
+
+GIT_OBJECT_DIRECTORY::
+ used to specify the object database root (usually $GIT_DIR/objects)
+
+GIT_INDEX_FILE::
+ used to specify the index file of the index
+
+GIT_ALTERNATE_OBJECT_DIRECTORIES::
+ used to specify additional object database roots (usually unset)
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 73d78c15e8..bc1658434a 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -8,7 +8,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
SYNOPSIS
--------
-'git-gc'
+'git-gc' [--prune]
DESCRIPTION
-----------
@@ -21,6 +21,21 @@ Users are encouraged to run this task on a regular basis within
each repository to maintain good disk space utilization and good
operating performance.
+OPTIONS
+-------
+
+--prune::
+ Usually `git-gc` packs refs, expires old reflog entries,
+ packs loose objects,
+ and removes old 'rerere' records. Removal
+ of unreferenced loose objects is an unsafe operation
+ while other git operations are in progress, so it is not
+ done by default. Pass this option if you want it, and only
+ when you know nobody else is creating new objects in the
+ repository at the same time (e.g. never use this option
+ in a cron script).
+
+
Configuration
-------------
@@ -35,7 +50,7 @@ can be set to indicate how long historical reflog entries which
are not part of the current branch should remain available in
this repository. These types of entries are generally created as
a result of using `git commit \--amend` or `git rebase` and are the
-commits prior to the amend or rebase occuring. Since these changes
+commits prior to the amend or rebase occurring. Since these changes
are not part of the current project most users will want to expire
them sooner. This option defaults to '30 days'.
@@ -47,6 +62,10 @@ The optional configuration variable 'gc.rerereunresolved' indicates
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`. Without the configuration, `git-pack-refs`
+is not run in bare repositories by default, to allow older dumb-transport
+clients fetch from the repository, but this will change in the future.
See Also
--------
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index bfbece9864..0140c8e358 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -91,7 +91,7 @@ OPTIONS
combined by 'or'.
--and | --or | --not | ( | )::
- Specify how multiple patterns are combined using boolean
+ Specify how multiple patterns are combined using Boolean
expressions. `--or` is the default operator. `--and` has
higher precedence than `--or`. `-e` has to be used for all
patterns.
diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt
index 04e8d00436..5edc36f060 100644
--- a/Documentation/git-hash-object.txt
+++ b/Documentation/git-hash-object.txt
@@ -3,7 +3,7 @@ git-hash-object(1)
NAME
----
-git-hash-object - Computes object ID and optionally creates a blob from a file
+git-hash-object - Compute object ID and optionally creates a blob from a file
SYNOPSIS
diff --git a/Documentation/git-http-fetch.txt b/Documentation/git-http-fetch.txt
index 3d508094af..7dc2df3044 100644
--- a/Documentation/git-http-fetch.txt
+++ b/Documentation/git-http-fetch.txt
@@ -3,7 +3,7 @@ git-http-fetch(1)
NAME
----
-git-http-fetch - downloads a remote git repository via HTTP
+git-http-fetch - Download from a remote git repository via HTTP
SYNOPSIS
diff --git a/Documentation/git-http-push.txt b/Documentation/git-http-push.txt
index c2485c6e9c..4b4a46169c 100644
--- a/Documentation/git-http-push.txt
+++ b/Documentation/git-http-push.txt
@@ -3,7 +3,7 @@ git-http-push(1)
NAME
----
-git-http-push - Push missing objects using HTTP/DAV
+git-http-push - Push objects over HTTP/DAV to another repository
SYNOPSIS
diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt
index bc3ba14939..5412135d76 100644
--- a/Documentation/git-init-db.txt
+++ b/Documentation/git-init-db.txt
@@ -11,96 +11,9 @@ SYNOPSIS
'git-init-db' [--template=<template_directory>] [--shared[=<permissions>]]
-OPTIONS
--------
-
---
-
---template=<template_directory>::
-
-Provide the directory from which templates will be used. The default template
-directory is `/usr/share/git-core/templates`.
-
-When specified, `<template_directory>` is used as the source of the template
-files rather than the default. The template files include some directory
-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}]::
-
-Specify that the git repository is to be shared amongst several users. This
-allows users belonging to the same group to push into that
-repository. When specified, the config variable "core.sharedRepository" is
-set so that files and directories under `$GIT_DIR` are created with the
-requested permissions. When not specified, git will use permissions reported
-by umask(2).
-
-The option can have the following values, defaulting to 'group' if no value
-is given:
-
- - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
- when `--shared` is not specified.
-
- - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since
- the git group may be not the primary group of all users).
-
- - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
- readable by all users.
-
-By default, the configuration flag receive.denyNonFastforward is enabled
-in shared repositories, so that you cannot force a non fast-forwarding push
-into it.
-
---
-
-
DESCRIPTION
-----------
-This command creates an empty git repository - basically a `.git` directory
-with subdirectories for `objects`, `refs/heads`, `refs/tags`, and
-template files.
-An initial `HEAD` file that references the HEAD of the master branch
-is also created.
-
-If the `$GIT_DIR` environment variable is set then it specifies a path
-to use instead of `./.git` for the base of the repository.
-
-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-db` in an existing repository is safe. It will not overwrite
-things that are already there. The primary reason for rerunning `git-init-db`
-is to pick up newly added templates.
-
-Note that `git-init` is the same as `git-init-db`.
-
-
-EXAMPLES
---------
-
-Start a new git repository for an existing code base::
-+
-----------------
-$ cd /path/to/my/codebase
-$ git-init-db <1>
-$ git-add . <2>
-----------------
-+
-<1> prepare /path/to/my/codebase/.git directory
-<2> add all existing file to the index
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org>
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-GIT
----
-Part of the gitlink:git[7] suite
+This is a synonym for gitlink:git-init[1]. Please refer to the
+documentation of that command.
diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
new file mode 100644
index 0000000000..1b64d3ab03
--- /dev/null
+++ b/Documentation/git-init.txt
@@ -0,0 +1,111 @@
+git-init(1)
+===========
+
+NAME
+----
+git-init - Create an empty git repository or reinitialize an existing one
+
+
+SYNOPSIS
+--------
+'git-init' [--template=<template_directory>] [--shared[=<permissions>]]
+
+
+OPTIONS
+-------
+
+--
+
+--template=<template_directory>::
+
+Provide the directory from which templates will be used. The default template
+directory is `/usr/share/git-core/templates`.
+
+When specified, `<template_directory>` is used as the source of the template
+files rather than the default. The template files include some directory
+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}]::
+
+Specify that the git repository is to be shared amongst several users. This
+allows users belonging to the same group to push into that
+repository. When specified, the config variable "core.sharedRepository" is
+set so that files and directories under `$GIT_DIR` are created with the
+requested permissions. When not specified, git will use permissions reported
+by umask(2).
+
+The option can have the following values, defaulting to 'group' if no value
+is given:
+
+ - 'umask' (or 'false'): Use permissions reported by umask(2). The default,
+ when `--shared` is not specified.
+
+ - 'group' (or 'true'): Make the repository group-writable, (and g+sx, since
+ the git group may be not the primary group of all users).
+
+ - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
+ readable by all users.
+
+By default, the configuration flag receive.denyNonFastforward is enabled
+in shared repositories, so that you cannot force a non fast-forwarding push
+into it.
+
+--
+
+
+DESCRIPTION
+-----------
+This command creates an empty git repository - basically a `.git` directory
+with subdirectories for `objects`, `refs/heads`, `refs/tags`, and
+template files.
+An initial `HEAD` file that references the HEAD of the master branch
+is also created.
+
+If the `$GIT_DIR` environment variable is set then it specifies a path
+to use instead of `./.git` for the base of the repository.
+
+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`
+is to pick up newly added templates.
+
+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
+setting the configuration variables. The old name is retained
+for backward compatibility reasons.
+
+
+EXAMPLES
+--------
+
+Start a new git repository for an existing code base::
++
+----------------
+$ cd /path/to/my/codebase
+$ git-init <1>
+$ git-add . <2>
+----------------
++
+<1> prepare /path/to/my/codebase/.git directory
+<2> add all existing file to the index
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Documentation/git-instaweb.txt b/Documentation/git-instaweb.txt
index 7dd393b97f..52a6aa6e82 100644
--- a/Documentation/git-instaweb.txt
+++ b/Documentation/git-instaweb.txt
@@ -3,7 +3,7 @@ git-instaweb(1)
NAME
----
-git-instaweb - instantly browse your working repository in gitweb
+git-instaweb - Instantly browse your working repository in gitweb
SYNOPSIS
--------
diff --git a/Documentation/git-local-fetch.txt b/Documentation/git-local-fetch.txt
index 2fbdfe086a..22048d82bd 100644
--- a/Documentation/git-local-fetch.txt
+++ b/Documentation/git-local-fetch.txt
@@ -3,7 +3,7 @@ git-local-fetch(1)
NAME
----
-git-local-fetch - Duplicates another git repository on a local system
+git-local-fetch - Duplicate another git repository on a local system
SYNOPSIS
diff --git a/Documentation/git-log.txt b/Documentation/git-log.txt
index e9f746bbd4..361eaec700 100644
--- a/Documentation/git-log.txt
+++ b/Documentation/git-log.txt
@@ -16,7 +16,7 @@ Shows the commit logs.
The command takes options applicable to the gitlink:git-rev-list[1]
command to control what is shown and how, and options applicable to
-the gitlink:git-diff-tree[1] commands to control how the change
+the gitlink:git-diff-tree[1] commands to control how the changes
each commit introduces are shown.
This manual page describes only the most frequently used options.
@@ -27,13 +27,16 @@ OPTIONS
include::pretty-formats.txt[]
---max-count=<n>::
+-<n>::
Limits the number of commits to show.
<since>..<until>::
Show only commits between the named two commits. When
either <since> or <until> is omitted, it defaults to
`HEAD`, i.e. the tip of the current branch.
+ For a more complete list of ways to spell <since>
+ and <until>, see "SPECIFYING REVISIONS" section in
+ gitlink:git-rev-parse[1].
-p::
Show the change the commit introduces in a patch form.
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 8520b97111..79e0b7b71a 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -3,7 +3,7 @@ git-ls-files(1)
NAME
----
-git-ls-files - Information about files in the index/working directory
+git-ls-files - Show information about files in the index and the working tree
SYNOPSIS
diff --git a/Documentation/git-ls-remote.txt b/Documentation/git-ls-remote.txt
index c8a4c5a4d9..c254005ca3 100644
--- a/Documentation/git-ls-remote.txt
+++ b/Documentation/git-ls-remote.txt
@@ -29,7 +29,7 @@ OPTIONS
-u <exec>, --upload-pack=<exec>::
Specify the full path of gitlink:git-upload-pack[1] on the remote
host. This allows listing references from repositories accessed via
- SSH and where the SSH deamon does not use the PATH configured by the
+ SSH and where the SSH daemon does not use the PATH configured by the
user. Also see the '--exec' option for gitlink:git-peek-remote[1].
<repository>::
diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
index f283bacb65..7899394081 100644
--- a/Documentation/git-ls-tree.txt
+++ b/Documentation/git-ls-tree.txt
@@ -3,7 +3,7 @@ git-ls-tree(1)
NAME
----
-git-ls-tree - Lists the contents of a tree object
+git-ls-tree - List the contents of a tree object
SYNOPSIS
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index ea0a06557f..ba18133ead 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -3,7 +3,7 @@ git-mailinfo(1)
NAME
----
-git-mailinfo - Extracts patch from a single e-mail message
+git-mailinfo - Extracts patch and authorship from a single e-mail message
SYNOPSIS
@@ -18,7 +18,7 @@ writes the commit log message in <msg> file, and the patches in
<patch> file. The author name, e-mail and e-mail subject are
written out to the standard output to be used by git-applypatch
to create a commit. It is usually not necessary to use this
-command directly.
+command directly. See gitlink:git-am[1] instead.
OPTIONS
@@ -33,15 +33,13 @@ OPTIONS
format-patch --mbox' output.
-u::
- By default, the commit log message, author name and
- author email are taken from the e-mail without any
- charset conversion, after minimally decoding MIME
- transfer encoding. This flag causes the resulting
- commit to be encoded in the encoding specified by
- i18n.commitencoding configuration (defaults to utf-8) by
- transliterating them.
- Note that the patch is always used as is without charset
- conversion, even with this flag.
+ The commit log message, author name and author email are
+ taken from the e-mail, and after minimally decoding MIME
+ transfer encoding, re-coded in UTF-8 by transliterating
+ them. This used to be optional but now it is the default.
++
+Note that the patch is always used as-is without charset
+conversion, even with this flag.
--encoding=<encoding>::
Similar to -u but if the local convention is different
diff --git a/Documentation/git-mailsplit.txt b/Documentation/git-mailsplit.txt
index 5a17801f6a..c11d6a530f 100644
--- a/Documentation/git-mailsplit.txt
+++ b/Documentation/git-mailsplit.txt
@@ -3,7 +3,7 @@ git-mailsplit(1)
NAME
----
-git-mailsplit - Totally braindamaged mbox splitter program
+git-mailsplit - Simple UNIX mbox splitter program
SYNOPSIS
--------
diff --git a/Documentation/git-merge-base.txt b/Documentation/git-merge-base.txt
index 6099be2add..3190aed108 100644
--- a/Documentation/git-merge-base.txt
+++ b/Documentation/git-merge-base.txt
@@ -3,7 +3,7 @@ git-merge-base(1)
NAME
----
-git-merge-base - Finds as good a common ancestor as possible for a merge
+git-merge-base - Find as good common ancestors as possible for a merge
SYNOPSIS
diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
index 29d3faa556..31882abb87 100644
--- a/Documentation/git-merge-file.txt
+++ b/Documentation/git-merge-file.txt
@@ -3,7 +3,7 @@ git-merge-file(1)
NAME
----
-git-merge-file - three-way file merge
+git-merge-file - Run a three-way file merge
SYNOPSIS
diff --git a/Documentation/git-merge-index.txt b/Documentation/git-merge-index.txt
index 0cf505ea84..b8ee1ff2b0 100644
--- a/Documentation/git-merge-index.txt
+++ b/Documentation/git-merge-index.txt
@@ -3,7 +3,7 @@ git-merge-index(1)
NAME
----
-git-merge-index - Runs a merge for files needing merging
+git-merge-index - Run a merge for files needing merging
SYNOPSIS
diff --git a/Documentation/git-merge-one-file.txt b/Documentation/git-merge-one-file.txt
index 86aad37c6a..f80ab3b8c4 100644
--- a/Documentation/git-merge-one-file.txt
+++ b/Documentation/git-merge-one-file.txt
@@ -3,7 +3,7 @@ git-merge-one-file(1)
NAME
----
-git-merge-one-file - The standard helper program to use with "git-merge-index"
+git-merge-one-file - The standard helper program to use with git-merge-index
SYNOPSIS
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index 0f79665ea6..e53ff4b4e7 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -3,14 +3,14 @@ git-merge(1)
NAME
----
-git-merge - Grand Unified Merge Driver
+git-merge - Join two or more development histories together
SYNOPSIS
--------
[verse]
'git-merge' [-n] [--no-commit] [--squash] [-s <strategy>]...
- -m=<msg> <remote> <remote>...
+ [-m <msg>] <remote> <remote>...
DESCRIPTION
-----------
diff --git a/Documentation/git-mv.txt b/Documentation/git-mv.txt
index 207c43a631..6756b76bb1 100644
--- a/Documentation/git-mv.txt
+++ b/Documentation/git-mv.txt
@@ -3,7 +3,7 @@ git-mv(1)
NAME
----
-git-mv - Move or rename a file, directory or symlink
+git-mv - Move or rename a file, a directory, or a symlink
SYNOPSIS
diff --git a/Documentation/git-p4import.txt b/Documentation/git-p4import.txt
index ee9e8fa909..6edb9f12b8 100644
--- a/Documentation/git-p4import.txt
+++ b/Documentation/git-p4import.txt
@@ -93,7 +93,7 @@ perforce branch into a branch named "jammy", like so:
------------
$ mkdir -p /home/sean/import/jam
$ cd /home/sean/import/jam
-$ git init-db
+$ git init
$ git p4import //public/jam jammy
------------
diff --git a/Documentation/git-pack-redundant.txt b/Documentation/git-pack-redundant.txt
index 7d54b17e37..94bbea0db2 100644
--- a/Documentation/git-pack-redundant.txt
+++ b/Documentation/git-pack-redundant.txt
@@ -3,7 +3,7 @@ git-pack-redundant(1)
NAME
----
-git-pack-redundant - Program used to find redundant pack files
+git-pack-redundant - Find redundant pack files
SYNOPSIS
@@ -21,7 +21,7 @@ given will be ignored when checking which packs are required. This makes the
following command useful when wanting to remove packs which contain unreachable
objects.
-git-fsck-objects --full --unreachable | cut -d ' ' -f3 | \
+git-fsck --full --unreachable | cut -d ' ' -f3 | \
git-pack-redundant --all | xargs rm
OPTIONS
diff --git a/Documentation/git-pack-refs.txt b/Documentation/git-pack-refs.txt
index 464269fbb9..a20fc7de40 100644
--- a/Documentation/git-pack-refs.txt
+++ b/Documentation/git-pack-refs.txt
@@ -29,12 +29,23 @@ file and used if found.
Subsequent updates to branches always creates new file under
`$GIT_DIR/refs` hierarchy.
+A recommended practice to deal with a repository with too many
+refs is to pack its refs with `--all --prune` once, and
+occasionally run `git-pack-refs \--prune`. Tags are by
+definition stationary and are not expected to change. Branch
+heads will be packed with the initial `pack-refs --all`, but
+only the currently active branch heads will become unpacked,
+and next `pack-refs` (without `--all`) will leave them
+unpacked.
+
+
OPTIONS
-------
\--all::
-The command by default packs all tags and leaves branch tips
+The command by default packs all tags and refs that are already
+packed, and leaves other refs
alone. This is because branches are expected to be actively
developed and packing their tips does not help performance.
This option causes branch tips to be packed as well. Useful for
diff --git a/Documentation/git-parse-remote.txt b/Documentation/git-parse-remote.txt
index fc27afe26d..11b1f4d2e2 100644
--- a/Documentation/git-parse-remote.txt
+++ b/Documentation/git-parse-remote.txt
@@ -3,7 +3,7 @@ git-parse-remote(1)
NAME
----
-git-parse-remote - Routines to help parsing $GIT_DIR/remotes/
+git-parse-remote - Routines to help parsing remote repository access parameters
SYNOPSIS
@@ -14,7 +14,8 @@ DESCRIPTION
-----------
This script is included in various scripts to supply
routines to parse files under $GIT_DIR/remotes/ and
-$GIT_DIR/branches/.
+$GIT_DIR/branches/ and configuration variables that are related
+to fetching, pulling and pushing.
The primary entry points are:
@@ -25,7 +26,8 @@ get_remote_refs_for_fetch::
(e.g. `refs/heads/foo`). When `<refspec>...` is empty
the returned list of refs consists of the defaults
for the given `<repo>`, if specified in
- `$GIT_DIR/remotes/` or `$GIT_DIR/branches/`.
+ `$GIT_DIR/remotes/`, `$GIT_DIR/branches/`, or `remote.*.fetch`
+ configuration.
get_remote_refs_for_push::
Given the list of user-supplied `<repo> <refspec>...`,
diff --git a/Documentation/git-patch-id.txt b/Documentation/git-patch-id.txt
index 5389097f73..a7e9fd021a 100644
--- a/Documentation/git-patch-id.txt
+++ b/Documentation/git-patch-id.txt
@@ -3,7 +3,7 @@ git-patch-id(1)
NAME
----
-git-patch-id - Generate a patch ID
+git-patch-id - Compute unique ID for a patch
SYNOPSIS
--------
diff --git a/Documentation/git-peek-remote.txt b/Documentation/git-peek-remote.txt
index a00060c507..74f37bd904 100644
--- a/Documentation/git-peek-remote.txt
+++ b/Documentation/git-peek-remote.txt
@@ -3,12 +3,12 @@ git-peek-remote(1)
NAME
----
-git-peek-remote - Lists the references in a remote repository
+git-peek-remote - List the references in a remote repository
SYNOPSIS
--------
-'git-peek-remote' [--exec=<git-upload-pack>] [<host>:]<directory>
+'git-peek-remote' [--upload-pack=<git-upload-pack>] [<host>:]<directory>
DESCRIPTION
-----------
@@ -17,7 +17,7 @@ stores them in the local repository under the same name.
OPTIONS
-------
---exec=<git-upload-pack>::
+\--upload-pack=<git-upload-pack>::
Use this to specify the path to 'git-upload-pack' on the
remote side, if it is not found on your $PATH. Some
installations of sshd ignores the user's environment
@@ -29,6 +29,9 @@ OPTIONS
shells, but prefer having a lean .bashrc file (they set most of
the things up in .bash_profile).
+\--exec=<git-upload-pack>::
+ Same \--upload-pack=<git-upload-pack>.
+
<host>::
A remote host that houses the repository. When this
part is specified, 'git-upload-pack' is invoked via
diff --git a/Documentation/git-prune-packed.txt b/Documentation/git-prune-packed.txt
index 234882685d..310033e460 100644
--- a/Documentation/git-prune-packed.txt
+++ b/Documentation/git-prune-packed.txt
@@ -3,13 +3,12 @@ git-prune-packed(1)
NAME
----
-git-prune-packed - Program used to remove the extra object files that are now
-residing in a pack file.
+git-prune-packed - Remove extra objects that are already in pack files
SYNOPSIS
--------
-'git-prune-packed' [-n]
+'git-prune-packed' [-n] [-q]
DESCRIPTION
@@ -32,6 +31,9 @@ OPTIONS
Don't actually remove any objects, only show those that would have been
removed.
+-q::
+ Squelch the progress indicator.
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>
diff --git a/Documentation/git-prune.txt b/Documentation/git-prune.txt
index a11e303094..0b44f3015d 100644
--- a/Documentation/git-prune.txt
+++ b/Documentation/git-prune.txt
@@ -13,7 +13,7 @@ SYNOPSIS
DESCRIPTION
-----------
-This runs `git-fsck-objects --unreachable` using all the refs
+This runs `git-fsck --unreachable` using all the refs
available in `$GIT_DIR/refs`, optionally with additional set of
objects specified on the command line, and prunes all
objects unreachable from any of these head objects from the object database.
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 13be992006..94478ed94d 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -3,7 +3,7 @@ git-pull(1)
NAME
----
-git-pull - Pull and merge from another repository or a local branch
+git-pull - Fetch from and merge with another repository or a local branch
SYNOPSIS
@@ -33,6 +33,60 @@ include::urls.txt[]
include::merge-strategies.txt[]
+DEFAULT BEHAVIOUR
+-----------------
+
+Often people use `git pull` without giving any parameter.
+Traditionally, this has been equivalent to saying `git pull
+origin`. However, when configuration `branch.<name>.remote` is
+present while on branch `<name>`, that value is used instead of
+`origin`.
+
+In order to determine what URL to use to fetch from, the value
+of the configuration `remote.<origin>.url` is consulted
+and if there is not any such variable, the value on `URL: ` line
+in `$GIT_DIR/remotes/<origin>` file is used.
+
+In order to determine what remote branches to fetch (and
+optionally store in the tracking branches) when the command is
+run without any refspec parameters on the command line, values
+of the configuration variable `remote.<origin>.fetch` are
+consulted, and if there aren't any, `$GIT_DIR/remotes/<origin>`
+file is consulted and its `Pull: ` lines are used.
+In addition to the refspec formats described in the OPTIONS
+section, you can have a globbing refspec that looks like this:
+
+------------
+refs/heads/*:refs/remotes/origin/*
+------------
+
+A globbing refspec must have a non-empty RHS (i.e. must store
+what were fetched in tracking branches), and its LHS and RHS
+must end with `/*`. The above specifies that all remote
+branches are tracked using tracking branches in
+`refs/remotes/origin/` hierarchy under the same name.
+
+The rule to determine which remote branch to merge after
+fetching is a bit involved, in order not to break backward
+compatibility.
+
+If explicit refspecs were given on the command
+line of `git pull`, they are all merged.
+
+When no refspec was given on the command line, then `git pull`
+uses the refspec from the configuration or
+`$GIT_DIR/remotes/<origin>`. In such cases, the following
+rules apply:
+
+. If `branch.<name>.merge` configuration for the current
+ branch `<name>` exists, that is the name of the branch at the
+ remote site that is merged.
+
+. If the refspec is a globbing one, nothing is merged.
+
+. Otherwise the remote branch of the first refspec is merged.
+
+
EXAMPLES
--------
@@ -42,7 +96,7 @@ git pull, git pull origin::
current branch. Normally the branch merged in is
the HEAD of the remote repository, but the choice is
determined by the branch.<name>.remote and
- branch.<name>.merge options; see gitlink:git-repo-config[1]
+ branch.<name>.merge options; see gitlink:git-config[1]
for details.
git pull origin next::
@@ -52,7 +106,8 @@ git pull origin next::
git pull . fixes enhancements::
Bundle local branch `fixes` and `enhancements` on top of
- the current branch, making an Octopus merge.
+ the current branch, making an Octopus merge. This `git pull .`
+ syntax is equivalent to `git merge`.
git pull -s ours . obsolete::
Merge local branch `obsolete` into the current branch,
@@ -93,7 +148,7 @@ gitlink:git-reset[1].
SEE ALSO
--------
-gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-repo-config[1]
+gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-config[1]
Author
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 197f4b512f..f8cc2b5432 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -8,7 +8,7 @@ git-push - Update remote refs along with associated objects
SYNOPSIS
--------
-'git-push' [--all] [--tags] [-f | --force] <repository> <refspec>...
+'git-push' [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]
DESCRIPTION
-----------
@@ -67,12 +67,33 @@ the remote repository.
addition to refspecs explicitly listed on the command
line.
+\--receive-pack=<git-receive-pack>::
+ Path to the 'git-receive-pack' program on the remote
+ end. Sometimes useful when pushing to a remote
+ repository over ssh, and you do not have the program in
+ a directory on the default $PATH.
+
+\--exec=<git-receive-pack>::
+ Same as \--receive-pack=<git-receive-pack>.
+
-f, \--force::
Usually, the command refuses to update a remote ref that is
not a descendant of the local ref used to overwrite it.
This flag disables the check. This can cause the
remote repository to lose commits; use it with care.
+\--repo=<repo>::
+ When no repository is specified the command defaults to
+ "origin"; this overrides it.
+
+\--thin, \--no-thin::
+ These options are passed to `git-send-pack`. Thin
+ transfer spends extra cycles to minimize the number of
+ objects to be sent and meant to be used on slower connection.
+
+-v::
+ Run verbosely.
+
include::urls.txt[]
Author
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 03e867a403..f2ef1f7dc0 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -3,11 +3,11 @@ git-rebase(1)
NAME
----
-git-rebase - Rebase local commits to a new head
+git-rebase - Forward-port local commits to the updated upstream head
SYNOPSIS
--------
-'git-rebase' [-v] [--merge] [--onto <newbase>] <upstream> [<branch>]
+'git-rebase' [-v] [--merge] [-C<n>] [--onto <newbase>] <upstream> [<branch>]
'git-rebase' --continue | --skip | --abort
@@ -114,6 +114,27 @@ would result in:
This is useful when topicB does not depend on topicA.
+A range of commits could also be removed with rebase. If we have
+the following situation:
+
+------------
+ E---F---G---H---I---J topicA
+------------
+
+then the command
+
+ git-rebase --onto topicA~5 topicA~2 topicA
+
+would result in the removal of commits F and G:
+
+------------
+ E---H'---I'---J' topicA
+------------
+
+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
the markers (<<<<<<) and make edits to resolve the conflict. For each
@@ -141,10 +162,12 @@ OPTIONS
<newbase>::
Starting point at which to create the new commits. If the
--onto option is not specified, the starting point is
- <upstream>.
+ <upstream>. May be any valid commit, and not just an
+ existing branch name.
<upstream>::
- Upstream branch to compare against.
+ Upstream branch to compare against. May be any valid commit,
+ not just an existing branch name.
<branch>::
Working branch; defaults to HEAD.
@@ -173,6 +196,12 @@ OPTIONS
-v, \--verbose::
Display a diffstat of what changed upstream since the last rebase.
+-C<n>::
+ Ensure at least <n> lines of surrounding context match before
+ and after each change. When fewer lines of surrounding
+ context exist they all must match. By default no context is
+ ever ignored.
+
include::merge-strategies.txt[]
NOTES
diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
index 0dfadc2a32..10e8c46c4c 100644
--- a/Documentation/git-receive-pack.txt
+++ b/Documentation/git-receive-pack.txt
@@ -3,7 +3,7 @@ git-receive-pack(1)
NAME
----
-git-receive-pack - Receive what is pushed into it
+git-receive-pack - Receive what is pushed into the repository
SYNOPSIS
diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index 55a24d3266..1e343bcdcd 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -8,13 +8,18 @@ git-reflog - Manage reflog information
SYNOPSIS
--------
-[verse]
-'git-reflog' expire [--dry-run]
- [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
-
+'git reflog' <subcommand> <options>
DESCRIPTION
-----------
+The command takes various subcommands, and different options
+depending on the subcommand:
+
+[verse]
+git reflog expire [--dry-run] [--stale-fix]
+ [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
+
+git reflog [show] [log-options]
Reflog is a mechanism to record when the tip of branches are
updated. This command is to manage the information recorded in it.
@@ -25,6 +30,10 @@ Entries older than `expire` time, or entries older than
tip, are removed from the reflog. This is typically not used
directly by the end users -- instead, see gitlink:git-gc[1].
+The subcommand "show" (which is also the default, in the absense of any
+subcommands) will take all the normal log options, and show the log of
+the current branch. It is basically an alias for 'git log -g --abbrev-commit
+--pretty=oneline', see gitlink:git-log[1].
OPTIONS
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 5b93a8c8be..a60c31a315 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -12,23 +12,43 @@ SYNOPSIS
'git-remote'
'git-remote' add <name> <url>
'git-remote' show <name>
+'git-remote' prune <name>
DESCRIPTION
-----------
Manage the set of repositories ("remotes") whose branches you track.
-With no arguments, shows a list of existing remotes.
-In the second form, adds a remote named <name> for the repository at
+COMMANDS
+--------
+
+With no arguments, shows a list of existing remotes. Several
+subcommands are available to perform operations on the remotes.
+
+'add'::
+
+Adds a remote named <name> for the repository at
<url>. The command `git fetch <name>` can then be used to create and
update remote-tracking branches <name>/<branch>.
-In the third form, gives some information about the remote <name>.
+'show'::
+
+Gives some information about the remote <name>.
+
+'prune'::
+
+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>".
+
+
+DISCUSSION
+----------
The remote configuration is achieved using the `remote.origin.url` and
`remote.origin.fetch` configuration variables. (See
-gitlink:git-repo-config[1]).
+gitlink:git-config[1]).
Examples
--------
@@ -58,7 +78,7 @@ See Also
--------
gitlink:git-fetch[1]
gitlink:git-branch[1]
-gitlink:git-repo-config[1]
+gitlink:git-config[1]
Author
------
diff --git a/Documentation/git-repack.txt b/Documentation/git-repack.txt
index 0fa47e3b01..d39abc126d 100644
--- a/Documentation/git-repack.txt
+++ b/Documentation/git-repack.txt
@@ -3,8 +3,7 @@ git-repack(1)
NAME
----
-git-repack - Script used to pack a repository from a collection of
-objects into pack files.
+git-repack - Pack unpacked objects in a repository
SYNOPSIS
@@ -31,9 +30,9 @@ OPTIONS
Instead of incrementally packing the unpacked objects,
pack everything available into a single pack.
Especially useful when packing a repository that is used
- for a private development and there no need to worry
- about people fetching via dumb protocols from it. Use
- with '-d'.
+ for private development and there is no need to worry
+ about people fetching via dumb file transfer protocols
+ from it. Use with '-d'.
-d::
After packing, if the newly created packs make some
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index c55a8ba0dc..2deba31763 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -3,225 +3,16 @@ git-repo-config(1)
NAME
----
-git-repo-config - Get and set repository or global options.
+git-repo-config - Get and set repository or global options
SYNOPSIS
--------
-[verse]
-'git-repo-config' [--global] [type] name [value [value_regex]]
-'git-repo-config' [--global] [type] --add name value
-'git-repo-config' [--global] [type] --replace-all name [value [value_regex]]
-'git-repo-config' [--global] [type] --get name [value_regex]
-'git-repo-config' [--global] [type] --get-all name [value_regex]
-'git-repo-config' [--global] [type] --unset name [value_regex]
-'git-repo-config' [--global] [type] --unset-all name [value_regex]
-'git-repo-config' [--global] -l | --list
+'git-repo-config' ...
-DESCRIPTION
------------
-You can query/set/replace/unset options with this command. The name is
-actually the section and the key separated by a dot, and the value will be
-escaped.
-
-Multiple lines can be added to an option by using the '--add' option.
-If you want to update or unset an option which can occur on multiple
-lines, a POSIX regexp `value_regex` needs to be given. Only the
-existing values that match the regexp are updated or unset. If
-you want to handle the lines that do *not* match the regex, just
-prepend a single exclamation mark in front (see EXAMPLES).
-
-The type specifier can be either '--int' or '--bool', which will make
-'git-repo-config' ensure that the variable(s) are of the given type and
-convert the value to the canonical form (simple decimal number for int,
-a "true" or "false" string for bool). If no type specifier is passed,
-no checks or transformations are performed on the value.
-
-This command will fail if:
-
-. The .git/config file is invalid,
-. Can not write to .git/config,
-. no section was provided,
-. the section or key is invalid,
-. you try to unset an option which does not exist,
-. you try to unset/set an option for which multiple lines match, or
-. you use --global option without $HOME being properly set.
-
-
-OPTIONS
--------
-
---replace-all::
- Default behavior is to replace at most one line. This replaces
- all lines matching the key (and optionally the value_regex).
-
---add::
- Adds a new line to the option without altering any existing
- values. This is the same as providing '^$' as the value_regex.
-
---get::
- Get the value for a given key (optionally filtered by a regex
- matching the value). Returns error code 1 if the key was not
- found and error code 2 if multiple key values were found.
-
---get-all::
- Like get, but does not fail if the number of values for the key
- is not exactly one.
-
---get-regexp::
- Like --get-all, but interprets the name as a regular expression.
-
---global::
- Use global ~/.gitconfig file rather than the repository .git/config.
-
---unset::
- Remove the line matching the key from config file.
---unset-all::
- Remove all matching lines from config file.
-
--l, --list::
- List all variables set in config file.
-
---bool::
- git-repo-config will ensure that the output is "true" or "false"
-
---int::
- git-repo-config will ensure that the output is a simple
- decimal number. An optional value suffix of 'k', 'm', or 'g'
- in the config file will cause the value to be multiplied
- by 1024, 1048576, or 1073741824 prior to output.
-
-
-ENVIRONMENT
+DESCRIPTION
-----------
-GIT_CONFIG::
- Take the configuration from the given file instead of .git/config.
- Using the "--global" option forces this to ~/.gitconfig.
-
-GIT_CONFIG_LOCAL::
- Currently the same as $GIT_CONFIG; when Git will support global
- configuration files, this will cause it to take the configuration
- from the global configuration file in addition to the given file.
-
-
-EXAMPLE
--------
-
-Given a .git/config like this:
-
- #
- # This is the config file, and
- # a '#' or ';' character indicates
- # a comment
- #
-
- ; core variables
- [core]
- ; Don't trust file modes
- filemode = false
-
- ; Our diff algorithm
- [diff]
- external = "/usr/local/bin/gnu-diff -u"
- renames = true
-
- ; Proxy settings
- [core]
- gitproxy="ssh" for "ssh://kernel.org/"
- gitproxy="proxy-command" for kernel.org
- gitproxy="myprotocol-command" for "my://"
- gitproxy=default-proxy ; for all the rest
-
-you can set the filemode to true with
-
-------------
-% git repo-config core.filemode true
-------------
-
-The hypothetical proxy command entries actually have a postfix to discern
-what URL they apply to. Here is how to change the entry for kernel.org
-to "ssh".
-
-------------
-% git repo-config core.gitproxy '"ssh" for kernel.org' 'for kernel.org$'
-------------
-
-This makes sure that only the key/value pair for kernel.org is replaced.
-
-To delete the entry for renames, do
-
-------------
-% git repo-config --unset diff.renames
-------------
-
-If you want to delete an entry for a multivar (like core.gitproxy above),
-you have to provide a regex matching the value of exactly one line.
-
-To query the value for a given key, do
-
-------------
-% git repo-config --get core.filemode
-------------
-
-or
-
-------------
-% git repo-config core.filemode
-------------
-
-or, to query a multivar:
-
-------------
-% git repo-config --get core.gitproxy "for kernel.org$"
-------------
-
-If you want to know all the values for a multivar, do:
-
-------------
-% git repo-config --get-all core.gitproxy
-------------
-
-If you like to live dangerous, you can replace *all* core.gitproxy by a
-new one with
-
-------------
-% git repo-config --replace-all core.gitproxy ssh
-------------
-
-However, if you really only want to replace the line for the default proxy,
-i.e. the one without a "for ..." postfix, do something like this:
-
-------------
-% git repo-config core.gitproxy ssh '! for '
-------------
-
-To actually match only values with an exclamation mark, you have to
-
-------------
-% git repo-config section.key value '[!]'
-------------
-
-To add a new proxy, without altering any of the existing ones, use
-
-------------
-% git repo-config core.gitproxy '"proxy" for example.com'
-------------
-
-
-include::config.txt[]
-
-
-Author
-------
-Written by Johannes Schindelin <Johannes.Schindelin@gmx.de>
-
-Documentation
---------------
-Documentation by Johannes Schindelin, Petr Baudis and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the gitlink:git[7] suite
-
+This is a synonym for gitlink:git-config[1]. Please refer to the
+documentation of that command.
diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt
index b57a72bdd7..139b6eb773 100644
--- a/Documentation/git-rerere.txt
+++ b/Documentation/git-rerere.txt
@@ -3,7 +3,7 @@ git-rerere(1)
NAME
----
-git-rerere - Reuse recorded resolve
+git-rerere - Reuse recorded resolution of conflicted merges
SYNOPSIS
--------
@@ -38,7 +38,7 @@ its working state.
This resets the metadata used by rerere if a merge resolution is to be
is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
-[--skip|--abort] will automatcally invoke this command.
+[--skip|--abort] will automatically invoke this command.
'diff'::
@@ -81,7 +81,7 @@ One way to do it is to pull master into the topic branch:
------------
$ git checkout topic
- $ git pull . master
+ $ git merge master
o---*---o---+ topic
/ /
@@ -103,10 +103,10 @@ in which case the final commit graph would look like this:
------------
$ git checkout topic
- $ git pull . master
+ $ git merge master
$ ... work on both topic and master branches
$ git checkout master
- $ git pull . topic
+ $ git merge topic
o---*---o---+---o---o topic
/ / \
@@ -126,11 +126,11 @@ top of the tip before the test merge:
------------
$ git checkout topic
- $ git pull . master
+ $ git merge master
$ git reset --hard HEAD^ ;# rewind the test merge
$ ... work on both topic and master branches
$ git checkout master
- $ git pull . topic
+ $ git merge topic
o---*---o-------o---o topic
/ \
diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt
index 4f424782eb..04475a9216 100644
--- a/Documentation/git-reset.txt
+++ b/Documentation/git-reset.txt
@@ -121,10 +121,6 @@ Undo a merge or pull::
+
------------
$ git pull <1>
-Trying really trivial in-index merge...
-fatal: Merge requires file-level merging
-Nope.
-...
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed/prevented; fix up by hand
diff --git a/Documentation/git-resolve.txt b/Documentation/git-resolve.txt
deleted file mode 100644
index 4e57c2b287..0000000000
--- a/Documentation/git-resolve.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-git-resolve(1)
-==============
-
-NAME
-----
-git-resolve - Merge two commits
-
-
-SYNOPSIS
---------
-'git-resolve' <current> <merged> <message>
-
-DESCRIPTION
------------
-Given two commits and a merge message, merge the <merged> commit
-into <current> commit, with the commit log message <message>.
-
-When <current> is a descendant of <merged>, or <current> is an
-ancestor of <merged>, no new commit is created and the <message>
-is ignored. The former is informally called "already up to
-date", and the latter is often called "fast forward".
-
-
-Author
-------
-Written by Linus Torvalds <torvalds@osdl.org> and
-Dan Holmsand <holmsand@gmail.com>.
-
-Documentation
---------------
-Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
-
-GIT
----
-Part of the gitlink:git[7] suite
-
diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 86c94e7dfd..c742117595 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -27,6 +27,7 @@ SYNOPSIS
[ \--pretty | \--header ]
[ \--bisect ]
[ \--merge ]
+ [ \--walk-reflogs ]
<commit>... [ \-- <paths>... ]
DESCRIPTION
@@ -190,6 +191,22 @@ limiting may be applied.
In addition to the '<commit>' listed on the command
line, read them from the standard input.
+-g, --walk-reflogs::
+
+ Instead of walking the commit ancestry chain, walk
+ reflog entries from the most recent one to older ones.
+ When this option is used you cannot specify commits to
+ exclude (that is, '{caret}commit', 'commit1..commit2',
+ nor 'commit1...commit2' notations cannot be used).
++
+With '\--pretty' format other than oneline (for obvious reasons),
+this causes the output to have two extra lines of information
+taken from the reflog. By default, 'commit@{Nth}' notation is
+used in the output. When the starting commit is specified as
+'commit@{now}', output also uses 'commit@{timestamp}' notation
+instead. Under '\--pretty=oneline', the commit message is
+prefixed with this information on the same line.
+
--merge::
After a failed merge, show refs that touch files having a
diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index 4eaf5a0d1e..4041a16070 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -152,6 +152,18 @@ blobs contained in a commit.
used immediately following a ref name and the ref must have an
existing log ($GIT_DIR/logs/<ref>).
+* A ref followed by the suffix '@' with an ordinal specification
+ enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify
+ the n-th prior value of that ref. For example 'master@\{1\}'
+ is the immediate prior value of 'master' while 'master@\{5\}'
+ is the 5th prior value of 'master'. This suffix may only be used
+ immediately following a ref name and the ref must have an existing
+ log ($GIT_DIR/logs/<ref>).
+
+* You can use the '@' construct with an empty ref part to get at a
+ reflog of the current branch. For example, if you are on the
+ branch 'blabla', then '@\{1\}' means the same as 'blabla@\{1\}'.
+
* A suffix '{caret}' to a revision parameter means the first parent of
that commit object. '{caret}<n>' means the <n>th parent (i.e.
'rev{caret}'
diff --git a/Documentation/git-revert.txt b/Documentation/git-revert.txt
index 71f7815d65..8081bbaffa 100644
--- a/Documentation/git-revert.txt
+++ b/Documentation/git-revert.txt
@@ -19,6 +19,8 @@ OPTIONS
-------
<commit>::
Commit to revert.
+ For a more complete list of ways to spell commit names, see
+ "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
-e|--edit::
With this option, `git-revert` will let you edit the commit
diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
index 3a8f279e1a..6feebc0400 100644
--- a/Documentation/git-rm.txt
+++ b/Documentation/git-rm.txt
@@ -60,21 +60,17 @@ a file that you have not told git about does not remove that file.
EXAMPLES
--------
git-rm Documentation/\\*.txt::
-
Removes all `\*.txt` files from the index that are under the
- `Documentation` directory and any of its subdirectories. The
- files are not removed from the working tree.
+ `Documentation` directory and any of its subdirectories.
+
Note that the asterisk `\*` is quoted from the shell in this
example; this lets the command include the files from
subdirectories of `Documentation/` directory.
git-rm -f git-*.sh::
-
- Remove all git-*.sh scripts that are in the index. The files
- are removed from the index, and from the working
- tree. Because this example lets the shell expand the
- asterisk (i.e. you are listing the files explicitly), it
+ Remove all git-*.sh scripts that are in the index.
+ Because this example lets the shell expand the asterisk
+ (i.e. you are listing the files explicitly), it
does not remove `subdir/git-foo.sh`.
See Also
diff --git a/Documentation/git-send-pack.txt b/Documentation/git-send-pack.txt
index 5376f68548..205bfd2d25 100644
--- a/Documentation/git-send-pack.txt
+++ b/Documentation/git-send-pack.txt
@@ -3,38 +3,51 @@ git-send-pack(1)
NAME
----
-git-send-pack - Push missing objects packed
+git-send-pack - Push objects over git protocol to another repository
SYNOPSIS
--------
-'git-send-pack' [--all] [--force] [--exec=<git-receive-pack>] [<host>:]<directory> [<ref>...]
+'git-send-pack' [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]
DESCRIPTION
-----------
+Usually you would want to use gitlink:git-push[1] which is a
+higher level wrapper of this command instead.
+
Invokes 'git-receive-pack' on a possibly remote repository, and
updates it from the current repository, sending named refs.
OPTIONS
-------
---exec=<git-receive-pack>::
+\--receive-pack=<git-receive-pack>::
Path to the 'git-receive-pack' program on the remote
end. Sometimes useful when pushing to a remote
repository over ssh, and you do not have the program in
a directory on the default $PATH.
---all::
+\--exec=<git-receive-pack>::
+ Same as \--receive-pack=<git-receive-pack>.
+
+\--all::
Instead of explicitly specifying which refs to update,
update all refs that locally exist.
---force::
+\--force::
Usually, the command refuses to update a remote ref that
is not an ancestor of the local ref used to overwrite it.
This flag disables the check. What this means is that
the remote repository can lose commits; use it with
care.
+\--verbose::
+ Run verbosely.
+
+\--thin::
+ Spend extra cycles to minimize the number of objects to be sent.
+ Use it on slower connection.
+
<host>::
A remote host to house the repository. When this
part is specified, 'git-receive-pack' is invoked via
diff --git a/Documentation/git-sh-setup.txt b/Documentation/git-sh-setup.txt
index 79217d8a56..2b2abebd60 100644
--- a/Documentation/git-sh-setup.txt
+++ b/Documentation/git-sh-setup.txt
@@ -12,14 +12,51 @@ SYNOPSIS
DESCRIPTION
-----------
-Sets up the normal git environment variables and a few helper functions
-(currently just "die()"), and returns OK if it all looks like a git archive.
-So, to make the rest of the git scripts more careful and readable,
-use it as follows:
-
--------------------------------------------------
-. git-sh-setup || die "Not a git archive"
--------------------------------------------------
+This is not a command the end user would want to run. Ever.
+This documentation is meant for people who are studying the
+Porcelain-ish scripts and/or are writing new ones.
+
+The `git-sh-setup` scriptlet is designed to be sourced (using
+`.`) by other shell scripts to set up some variables pointing at
+the normal git directories and a few helper shell functions.
+
+Before sourcing it, your script should set up a few variables;
+`USAGE` (and `LONG_USAGE`, if any) is used to define message
+given by `usage()` shell function. `SUBDIRECTORY_OK` can be set
+if the script can run from a subdirectory of the working tree
+(some commands do not).
+
+The scriptlet sets `GIT_DIR` and `GIT_OBJECT_DIRECTORY` shell
+variables, but does *not* export them to the environment.
+
+FUNCTIONS
+---------
+
+die::
+ exit after emitting the supplied error message to the
+ standard error stream.
+
+usage::
+ die with the usage message.
+
+set_reflog_action::
+ set the message that will be recorded to describe the
+ end-user action in the reflog, when the script updates a
+ ref.
+
+is_bare_repository::
+ outputs `true` or `false` to the standard output stream
+ to indicate if the repository is a bare repository
+ (i.e. without an associated working tree).
+
+cd_to_toplevel::
+ runs chdir to the toplevel of the working tree.
+
+require_work_tree::
+ checks if the repository is a bare repository, and dies
+ if so. Used by scripts that require working tree
+ (e.g. `checkout`).
+
Author
------
diff --git a/Documentation/git-shell.txt b/Documentation/git-shell.txt
index cc4266d83b..228b9f14f3 100644
--- a/Documentation/git-shell.txt
+++ b/Documentation/git-shell.txt
@@ -3,7 +3,7 @@ git-shell(1)
NAME
----
-git-shell - Restricted login shell for GIT over SSH only
+git-shell - Restricted login shell for GIT-only SSH access
SYNOPSIS
diff --git a/Documentation/git-shortlog.txt b/Documentation/git-shortlog.txt
index 95fa9010c1..b0df92e819 100644
--- a/Documentation/git-shortlog.txt
+++ b/Documentation/git-shortlog.txt
@@ -29,7 +29,7 @@ OPTIONS
of author alphabetic order.
-s::
- Supress commit description and provide a commit count summary only.
+ Suppress commit description and provide a commit count summary only.
FILES
-----
diff --git a/Documentation/git-show-branch.txt b/Documentation/git-show-branch.txt
index 912e15bcba..ba5313d51f 100644
--- a/Documentation/git-show-branch.txt
+++ b/Documentation/git-show-branch.txt
@@ -11,7 +11,7 @@ SYNOPSIS
'git-show-branch' [--all] [--remotes] [--topo-order] [--current]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...
-'git-show-branch' --reflog[=<n>] <ref>
+'git-show-branch' (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]
DESCRIPTION
-----------
@@ -97,9 +97,13 @@ OPTIONS
will show the revisions given by "git rev-list {caret}master
topic1 topic2"
---reflog[=<n>] <ref>::
- Shows <n> most recent ref-log entries for the given ref.
-
+--reflog[=<n>[,<base>]] [<ref>]::
+ Shows <n> most recent ref-log entries for the given
+ ref. If <base> is given, <n> entries going back from
+ that entry. <base> can be specified as count or date.
+ `-g` can be used as a short-hand for this option. When
+ no explicit <ref> parameter is given, it defaults to the
+ current branch (or `HEAD` if it is detached).
Note that --more, --list, --independent and --merge-base options
are mutually exclusive.
@@ -165,6 +169,13 @@ With this, `git show-branch` without extra parameters would show
only the primary branches. In addition, if you happen to be on
your topic branch, it is shown as well.
+------------
+$ git show-branch --reflog='10,1 hour ago' --list master
+------------
+
+shows 10 reflog entries going back from the tip as of 1 hour ago.
+Without `--list`, the output also shows how these tips are
+topologically related with each other.
Author
diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
index c210b9af6b..f56f164983 100644
--- a/Documentation/git-show.txt
+++ b/Documentation/git-show.txt
@@ -25,6 +25,9 @@ with \--name-only).
For plain blobs, it shows the plain contents.
+The command takes options applicable to the gitlink:git-diff-tree[1] command to
+control how the changes the commit introduces are shown.
+
This manual page describes only the most frequently used options.
@@ -32,6 +35,8 @@ OPTIONS
-------
<object>::
The name of the object to show.
+ For a more complete list of ways to spell object names, see
+ "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
include::pretty-formats.txt[]
diff --git a/Documentation/git-ssh-fetch.txt b/Documentation/git-ssh-fetch.txt
index b7116b30e0..192b1f15a9 100644
--- a/Documentation/git-ssh-fetch.txt
+++ b/Documentation/git-ssh-fetch.txt
@@ -3,7 +3,7 @@ git-ssh-fetch(1)
NAME
----
-git-ssh-fetch - Pulls from a remote repository over ssh connection
+git-ssh-fetch - Fetch from a remote repository over ssh connection
diff --git a/Documentation/git-ssh-upload.txt b/Documentation/git-ssh-upload.txt
index 702674e45d..a9b7e9f974 100644
--- a/Documentation/git-ssh-upload.txt
+++ b/Documentation/git-ssh-upload.txt
@@ -3,7 +3,7 @@ git-ssh-upload(1)
NAME
----
-git-ssh-upload - Pushes to a remote repository over ssh connection
+git-ssh-upload - Push to a remote repository over ssh connection
SYNOPSIS
diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt
index ce7857e5a9..03871e5d73 100644
--- a/Documentation/git-status.txt
+++ b/Documentation/git-status.txt
@@ -3,7 +3,7 @@ git-status(1)
NAME
----
-git-status - Show working tree status
+git-status - Show the working tree status
SYNOPSIS
@@ -34,6 +34,15 @@ The output from this command is designed to be used as a commit
template comments, and all the output lines are prefixed with '#'.
+CONFIGURATION
+-------------
+
+The command honors `color.status` (or `status.color` -- they
+mean the same thing and the latter is kept for backward
+compatibility) and `color.status.<slot>` configuration variables
+to colorize its output.
+
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 1b013139af..6ce6a3944d 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -3,7 +3,7 @@ git-svn(1)
NAME
----
-git-svn - bidirectional operation between Subversion and git
+git-svn - Bidirectional operation between a single Subversion branch and git
SYNOPSIS
--------
@@ -113,7 +113,7 @@ manually joining branches on commit.
'commit-diff'::
Commits the diff of two tree-ish arguments from the
- command-line. This command is intended for interopability with
+ command-line. This command is intended for interoperability with
git-svnimport and does not rely on being inside an git-svn
init-ed repository. This command takes three arguments, (a) the
original tree to diff against, (b) the new tree result, (c) the
@@ -133,7 +133,7 @@ manually joining branches on commit.
'multi-init'::
This command supports git-svnimport-like command-line syntax for
- importing repositories that are layed out as recommended by the
+ importing repositories that are laid out as recommended by the
SVN folks. This is a bit more tolerant than the git-svnimport
command-line syntax and doesn't require the user to figure out
where the repository URL ends and where the repository path
@@ -171,7 +171,7 @@ OPTIONS
--shared::
--template=<template_directory>::
Only used with the 'init' command.
- These are passed directly to gitlink:git-init-db[1].
+ These are passed directly to gitlink:git-init[1].
-r <ARG>::
--revision <ARG>::
@@ -204,7 +204,7 @@ removed by default if there are no files left in them. git
cannot version empty directories. Enabling this flag will make
the commit to SVN act like git.
-repo-config key: svn.rmdir
+config key: svn.rmdir
-e::
--edit::
@@ -215,7 +215,7 @@ Edit the commit message before committing to SVN. This is off by
default for objects that are commits, and forced on when committing
tree objects.
-repo-config key: svn.edit
+config key: svn.edit
-l<num>::
--find-copies-harder::
@@ -226,8 +226,8 @@ They are both passed directly to git-diff-tree see
gitlink:git-diff-tree[1] for more information.
[verse]
-repo-config key: svn.l
-repo-config key: svn.findcopiesharder
+config key: svn.l
+config key: svn.findcopiesharder
-A<filename>::
--authors-file=<filename>::
@@ -245,7 +245,7 @@ will abort operation. The user will then have to add the
appropriate entry. Re-running the previous git-svn command
after the authors-file is modified should continue operation.
-repo-config key: svn.authorsfile
+config key: svn.authorsfile
-q::
--quiet::
@@ -262,8 +262,8 @@ repo-config key: svn.authorsfile
--repack-flags are passed directly to gitlink:git-repack[1].
-repo-config key: svn.repack
-repo-config key: svn.repackflags
+config key: svn.repack
+config key: svn.repackflags
-m::
--merge::
@@ -304,7 +304,7 @@ used to track branches across multiple SVN _repositories_.
This option may be specified multiple times, once for each
branch.
-repo-config key: svn.branch
+config key: svn.branch
-i<GIT_SVN_ID>::
--id <GIT_SVN_ID>::
@@ -320,7 +320,7 @@ for more information on using GIT_SVN_ID.
started tracking a branch and never tracked the trunk it was
descended from.
-repo-config key: svn.followparent
+config key: svn.followparent
--no-metadata::
This gets rid of the git-svn-id: lines at the end of every commit.
@@ -332,7 +332,7 @@ repo-config key: svn.followparent
The 'git-svn log' command will not work on repositories using this,
either.
-repo-config key: svn.nometadata
+config key: svn.nometadata
--
@@ -367,7 +367,7 @@ Basic Examples
Tracking and contributing to a the trunk of a Subversion-managed project:
------------------------------------------------------------------------
-# Initialize a repo (like git init-db):
+# Initialize a repo (like git init):
git-svn init http://svn.foo.org/project/trunk
# Fetch remote revisions:
git-svn fetch
@@ -388,7 +388,7 @@ See also:
'<<tracking-multiple-repos,Tracking Multiple Repositories or Branches>>'
------------------------------------------------------------------------
-# Initialize a repo (like git init-db):
+# Initialize a repo (like git init):
git-svn multi-init http://svn.foo.org/project \
-T trunk -b branches -t tags
# Fetch remote revisions:
diff --git a/Documentation/git-symbolic-ref.txt b/Documentation/git-symbolic-ref.txt
index 4bc35a1d4b..a88f722860 100644
--- a/Documentation/git-symbolic-ref.txt
+++ b/Documentation/git-symbolic-ref.txt
@@ -3,11 +3,11 @@ git-symbolic-ref(1)
NAME
----
-git-symbolic-ref - read and modify symbolic refs
+git-symbolic-ref - Read and modify symbolic refs
SYNOPSIS
--------
-'git-symbolic-ref' <name> [<ref>]
+'git-symbolic-ref' [-q] [-m <reason>] <name> [<ref>]
DESCRIPTION
-----------
@@ -23,6 +23,18 @@ A symbolic ref is a regular file that stores a string that
begins with `ref: refs/`. For example, your `.git/HEAD` is
a regular file whose contents is `ref: refs/heads/master`.
+OPTIONS
+-------
+
+-q::
+ Do not issue an error message if the <name> is not a
+ symbolic ref but a detached HEAD; instead exit with
+ non-zero status silently.
+
+-m::
+ Update the reflog for <name> with <reason>. This is valid only
+ when creating or updating a symbolic ref.
+
NOTES
-----
In the past, `.git/HEAD` was a symbolic link pointing at
@@ -36,6 +48,10 @@ cumbersome. On some platforms, `ln -sf` does not even work as
advertised (horrors). Therefore symbolic links are now deprecated
and symbolic refs are used by default.
+git-symbolic-ref will exit with status 0 if the contents of the
+symbolic ref were printed correctly, with status 1 if the requested
+name is not a symbolic ref, or 128 if another error occurs.
+
Author
------
Written by Junio C Hamano <junkio@cox.net>
diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt
index 80bece0775..70235e8ddb 100644
--- a/Documentation/git-tag.txt
+++ b/Documentation/git-tag.txt
@@ -3,14 +3,14 @@ git-tag(1)
NAME
----
-git-tag - Create a tag object signed with GPG
+git-tag - Create, list, delete or verify a tag object signed with GPG
SYNOPSIS
--------
[verse]
-'git-tag' [-a | -s | -u <key-id>] [-f | -d | -v] [-m <msg> | -F <file>]
- <name> [<head>]
+'git-tag' [-a | -s | -u <key-id>] [-f | -v] [-m <msg> | -F <file>] <name> [<head>]
+'git-tag' -d <name>...
'git-tag' -l [<pattern>]
DESCRIPTION
@@ -55,7 +55,7 @@ OPTIONS
Replace an existing tag with the given name (instead of failing)
-d::
- Delete an existing tag with the given name
+ Delete existing tags with the given names.
-v::
Verify the gpg signature of given the tag
@@ -70,6 +70,147 @@ OPTIONS
Take the tag message from the given file. Use '-' to
read the message from the standard input.
+CONFIGURATION
+-------------
+By default, git-tag in sign-with-default mode (-s) will use your
+committer identity (of the form "Your Name <your@email.address>") to
+find a key. If you want to use a different default key, you can specify
+it in the repository configuration as follows:
+
+[user]
+ signingkey = <gpg-key-id>
+
+
+DISCUSSION
+----------
+
+On Re-tagging
+~~~~~~~~~~~~~
+
+What should you do when you tag a wrong commit and you would
+want to re-tag?
+
+If you never pushed anything out, just re-tag it. Use "-f" to
+replace the old one. And you're done.
+
+But if you have pushed things out (or others could just read
+your repository directly), then others will have already seen
+the old tag. In that case you can do one of two things:
+
+. The sane thing.
+Just admit you screwed up, and use a different name. Others have
+already seen one tag-name, and if you keep the same name, you
+may be in the situation that two people both have "version X",
+but they actually have 'different' "X"'s. So just call it "X.1"
+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"
+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
+one.
+
+If somebody got a release tag from you, you cannot just change
+the tag for them by updating your own one. This is a big
+security issue, in that people MUST be able to trust their
+tag-names. If you really want to do the insane thing, you need
+to just fess up to it, and tell people that you messed up. You
+can do that by making a very public announcement saying:
+
+------------
+Ok, I messed up, and I pushed out an earlier version tagged as X. I
+then fixed something, and retagged the *fixed* tree as X again.
+
+If you got the wrong tag, and want the new one, please delete
+the old one and fetch the new one by doing:
+
+ git tag -d X
+ git fetch origin tag X
+
+to get my updated tag.
+
+You can test which tag you have by doing
+
+ git rev-parse X
+
+which should return 0123456789abcdef.. if you have the new version.
+
+Sorry for inconvenience.
+------------
+
+Does this seem a bit complicated? It *should* be. There is no
+way that it would be correct to just "fix" it behind peoples
+backs. People need to know that their tags might have been
+changed.
+
+
+On Automatic following
+~~~~~~~~~~~~~~~~~~~~~~
+
+If you are following somebody else's tree, you are most likely
+using tracking branches (`refs/heads/origin` in traditional
+layout, or `refs/remotes/origin/master` in the separate-remote
+layout). You usually want the tags from the other end.
+
+On the other hand, if you are fetching because you would want a
+one-shot merge from somebody else, you typically do not want to
+get tags from there. This happens more often for people near
+the toplevel but not limited to them. Mere mortals when pulling
+from each other do not necessarily want to automatically get
+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:
+
+------------
+Linus, please pull from
+
+ git://git..../proj.git master
+
+to get the following updates...
+------------
+
+becomes:
+
+------------
+$ git pull git://git..../proj.git master
+------------
+
+In such a case, you do not want to automatically follow other's
+tags.
+
+One important aspect of git is it is distributed, and being
+distributed largely means there is no inherent "upstream" or
+"downstream" in the system. On the face of it, the above
+example might seem to indicate that the tag namespace is owned
+by upper echelon of people and tags only flow downwards, but
+that is not the case. It only shows that the usage pattern
+determines who are interested in whose tags.
+
+A one-shot pull is a sign that a commit history is now crossing
+the boundary between one circle of people (e.g. "people who are
+primarily interested in networking part of the kernel") who may
+have their own set of tags (e.g. "this is the third release
+candidate from the networking group to be proposed for general
+consumption with 2.6.21 release") to another circle of people
+(e.g. "people who integrate various subsystem improvements").
+The latter are usually not interested in the detailed tags used
+internally in the former group (that is what "internal" means).
+That is why it is desirable not to follow tags automatically in
+this case.
+
+It may well be that among networking people, they may want to
+exchange the tags internal to their group, but in that workflow
+they are most likely tracking with each other's progress by
+having tracking branches. Again, the heuristic to automatically
+follow such tags is a good thing.
+
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org>,
diff --git a/Documentation/git-tar-tree.txt b/Documentation/git-tar-tree.txt
index 74a6fddd9a..595940524e 100644
--- a/Documentation/git-tar-tree.txt
+++ b/Documentation/git-tar-tree.txt
@@ -3,7 +3,7 @@ git-tar-tree(1)
NAME
----
-git-tar-tree - Creates a tar archive of the files in the named tree
+git-tar-tree - Create a tar archive of the files in the named tree object
SYNOPSIS
@@ -50,7 +50,7 @@ repository configuration as follows :
umask = 002 ;# group friendly
The special umask value "user" indicates that the user's current umask
-will be used instead. The default value remains 0, which means world
+will be used instead. The default value is 002, which means group
readable/writable files and directories.
EXAMPLES
diff --git a/Documentation/git-tools.txt b/Documentation/git-tools.txt
index 0914cbb0ba..10653ff898 100644
--- a/Documentation/git-tools.txt
+++ b/Documentation/git-tools.txt
@@ -50,7 +50,7 @@ History Viewers
gitview is a GTK based repository browser for git
- - *gitweb* (ftp://ftp.kernel.org/pub/software/scm/gitweb/)
+ - *gitweb* (shipped with git-core)
GITweb provides full-fledged web interface for GIT repositories.
@@ -63,12 +63,18 @@ History Viewers
Currently it is the fastest and most feature rich among the git
viewers and commit tools.
+ - *tig* (http://jonas.nitro.dk/tig/)
+
+ tig by Jonas Fonseca is a simple git repository browser
+ written using ncurses. Basically, it just acts as a front-end
+ for git-log and git-show/git-diff. Additionally, you can also
+ use it as a pager for git commands.
Foreign SCM interface
---------------------
- - *git-svn* (contrib/)
+ - *git-svn* (shipped with git-core)
git-svn is a simple conduit for changesets between a single Subversion
branch and git.
@@ -80,6 +86,14 @@ Foreign SCM interface
series in git back and forth.
+ - *hg-to-git* (contrib/)
+
+ hg-to-git converts a Mercurial repository into a git one, and
+ preserves the full branch history in the process. hg-to-git can
+ also be used in an incremental way to keep the git repository
+ in sync with the master Mercurial repository.
+
+
Others
------
@@ -95,3 +109,7 @@ Others
This is an Emacs interface for git. The user interface is modeled on
pcl-cvs. It has been developed on Emacs 21 and will probably need some
tweaking to work on XEmacs.
+
+
+http://git.or.cz/gitwiki/InterfacesFrontendsAndTools has more
+comprehensive list.
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 0e0a3af1be..b161c8b32b 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -3,7 +3,7 @@ git-update-index(1)
NAME
----
-git-update-index - Modifies the index or directory cache
+git-update-index - Register file contents in the working tree to the index
SYNOPSIS
@@ -289,7 +289,7 @@ Configuration
The command honors `core.filemode` configuration variable. If
your repository is on an filesystem whose executable bits are
-unreliable, this should be set to 'false' (see gitlink:git-repo-config[1]).
+unreliable, this should be set to 'false' (see gitlink:git-config[1]).
This causes the command to ignore differences in file modes recorded
in the index and the file mode on the filesystem if they differ only on
executable bit. On such an unfortunate filesystem, you may
@@ -301,7 +301,7 @@ The command looks at `core.ignorestat` configuration variable. See
See Also
--------
-gitlink:git-repo-config[1]
+gitlink:git-config[1]
Author
diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt
index 71bcb7954f..9424feab32 100644
--- a/Documentation/git-update-ref.txt
+++ b/Documentation/git-update-ref.txt
@@ -3,7 +3,7 @@ git-update-ref(1)
NAME
----
-git-update-ref - update the object name stored in a ref safely
+git-update-ref - Update the object name stored in a ref safely
SYNOPSIS
--------
diff --git a/Documentation/git-upload-archive.txt b/Documentation/git-upload-archive.txt
index 388bb53d29..403871d7c6 100644
--- a/Documentation/git-upload-archive.txt
+++ b/Documentation/git-upload-archive.txt
@@ -3,7 +3,7 @@ git-upload-archive(1)
NAME
----
-git-upload-archive - Send archive
+git-upload-archive - Send archive back to git-archive
SYNOPSIS
diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt
index b2c9307661..9da062d5c9 100644
--- a/Documentation/git-upload-pack.txt
+++ b/Documentation/git-upload-pack.txt
@@ -3,7 +3,7 @@ git-upload-pack(1)
NAME
----
-git-upload-pack - Send missing objects packed
+git-upload-pack - Send objects packed back to git-fetch-pack
SYNOPSIS
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index a5b1a0dbab..9b0de1c111 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -3,7 +3,7 @@ git-var(1)
NAME
----
-git-var - Print the git users identity
+git-var - Show a git logical variable
SYNOPSIS
@@ -20,7 +20,7 @@ OPTIONS
Cause the logical variables to be listed. In addition, all the
variables of the git configuration file .git/config are listed
as well. (However, the configuration variables listing functionality
- is deprecated in favor of `git-repo-config -l`.)
+ is deprecated in favor of `git-config -l`.)
EXAMPLE
--------
@@ -49,7 +49,7 @@ See Also
--------
gitlink:git-commit-tree[1]
gitlink:git-tag[1]
-gitlink:git-repo-config[1]
+gitlink:git-config[1]
Author
------
diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt
index e8f21d02f7..399bff3bbc 100644
--- a/Documentation/git-whatchanged.txt
+++ b/Documentation/git-whatchanged.txt
@@ -27,7 +27,7 @@ OPTIONS
output format that is useful only to tell the changed
paths and their nature of changes.
---max-count=<n>::
+-<n>::
Limit output to <n> commits.
<since>..<until>::
diff --git a/Documentation/git-write-tree.txt b/Documentation/git-write-tree.txt
index c85fa89c30..96d5e07b11 100644
--- a/Documentation/git-write-tree.txt
+++ b/Documentation/git-write-tree.txt
@@ -3,7 +3,7 @@ git-write-tree(1)
NAME
----
-git-write-tree - Creates a tree object from the current index
+git-write-tree - Create a tree object from the current index
SYNOPSIS
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 5662cdc27c..3d8be5931c 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -22,9 +22,34 @@ See this link:tutorial.html[tutorial] 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].
+link:user-manual.html[Git User's Manual] is still work in
+progress, but when finished hopefully it will guide a new user
+in a coherent way to git enlightenment ;-).
The COMMAND is either a name of a Git command (see below) or an alias
-as defined in the configuration file (see gitlink:git-repo-config[1]).
+as defined in the configuration file (see gitlink:git-config[1]).
+
+ifdef::stalenotes[]
+[NOTE]
+============
+You are reading the documentation for the latest version of git.
+Documentation for older releases are available here:
+
+* link:v1.5.0/git.html[documentation for release 1.5.0]
+
+* link:v1.5.0/RelNotes-1.5.0.txt[release notes for 1.5.0]
+
+* link:v1.4.4.4/git.html[documentation for release 1.4.4.4]
+
+* link:v1.3.3/git.html[documentation for release 1.3.3]
+
+* link:v1.2.6/git.html[documentation for release 1.2.6]
+
+* link:v1.0.13/git.html[documentation for release 1.0.13]
+
+============
+
+endif::stalenotes[]
OPTIONS
-------
@@ -81,244 +106,26 @@ ancillary user utilities.
Main porcelain commands
~~~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-add[1]::
- Add paths to the index.
-
-gitlink:git-am[1]::
- Apply patches from a mailbox, but cooler.
-
-gitlink:git-applymbox[1]::
- Apply patches from a mailbox, original version by Linus.
-
-gitlink:git-archive[1]::
- Creates an archive of files from a named tree.
-
-gitlink:git-bisect[1]::
- Find the change that introduced a bug by binary search.
-
-gitlink:git-branch[1]::
- Create and Show branches.
-
-gitlink:git-checkout[1]::
- Checkout and switch to a branch.
-
-gitlink:git-cherry-pick[1]::
- Cherry-pick the effect of an existing commit.
-
-gitlink:git-clean[1]::
- Remove untracked files from the working tree.
-
-gitlink:git-clone[1]::
- Clones a repository into a new directory.
-
-gitlink:git-commit[1]::
- Record changes to the repository.
-
-gitlink:git-diff[1]::
- Show changes between commits, commit and working tree, etc.
-
-gitlink:git-fetch[1]::
- Download from a remote repository via various protocols.
-
-gitlink:git-format-patch[1]::
- Prepare patches for e-mail submission.
-
-gitlink:git-grep[1]::
- Print lines matching a pattern.
-
-gitlink:gitk[1]::
- The git repository browser.
-
-gitlink:git-log[1]::
- Shows commit logs.
-
-gitlink:git-ls-remote[1]::
- Shows references in a remote or local repository.
-
-gitlink:git-merge[1]::
- Grand unified merge driver.
-
-gitlink:git-mv[1]::
- Move or rename a file, a directory, or a symlink.
-
-gitlink:git-pack-refs[1]::
- Pack heads and tags for efficient repository access.
-
-gitlink:git-pull[1]::
- Fetch from and merge with a remote repository or a local branch.
-
-gitlink:git-push[1]::
- Update remote refs along with associated objects.
-
-gitlink:git-rebase[1]::
- Rebase local commits to the updated upstream head.
-
-gitlink:git-repack[1]::
- Pack unpacked objects in a repository.
-
-gitlink:git-rerere[1]::
- Reuse recorded resolution of conflicted merges.
-
-gitlink:git-reset[1]::
- Reset current HEAD to the specified state.
-
-gitlink:git-resolve[1]::
- Merge two commits.
-
-gitlink:git-revert[1]::
- Revert an existing commit.
-
-gitlink:git-rm[1]::
- Remove files from the working tree and from the index.
-
-gitlink:git-shortlog[1]::
- Summarizes 'git log' output.
-
-gitlink:git-show[1]::
- Show one commit log and its diff.
-
-gitlink:git-show-branch[1]::
- Show branches and their commits.
-
-gitlink:git-status[1]::
- Shows the working tree status.
-
-gitlink:git-verify-tag[1]::
- Check the GPG signature of tag.
-
-gitlink:git-whatchanged[1]::
- Shows commit logs and differences they introduce.
-
+include::cmds-mainporcelain.txt[]
Ancillary Commands
~~~~~~~~~~~~~~~~~~
Manipulators:
-gitlink:git-applypatch[1]::
- Apply one patch extracted from an e-mail.
-
-gitlink:git-archimport[1]::
- Import an arch repository into git.
-
-gitlink:git-convert-objects[1]::
- Converts old-style git repository.
-
-gitlink:git-cvsimport[1]::
- Salvage your data out of another SCM people love to hate.
-
-gitlink:git-cvsexportcommit[1]::
- Export a single commit to a CVS checkout.
-
-gitlink:git-cvsserver[1]::
- A CVS server emulator for git.
-
-gitlink:git-gc[1]::
- Cleanup unnecessary files and optimize the local repository.
-
-gitlink:git-lost-found[1]::
- Recover lost refs that luckily have not yet been pruned.
-
-gitlink:git-merge-one-file[1]::
- The standard helper program to use with `git-merge-index`.
-
-gitlink:git-prune[1]::
- Prunes all unreachable objects from the object database.
-
-gitlink:git-quiltimport[1]::
- Applies a quilt patchset onto the current branch.
-
-gitlink:git-reflog[1]::
- Manage reflog information.
-
-gitlink:git-relink[1]::
- Hardlink common objects in local repositories.
-
-gitlink:git-svn[1]::
- Bidirectional operation between a single Subversion branch and git.
-
-gitlink:git-svnimport[1]::
- Import a SVN repository into git.
-
-gitlink:git-sh-setup[1]::
- Common git shell script setup code.
-
-gitlink:git-symbolic-ref[1]::
- Read and modify symbolic refs.
-
-gitlink:git-tag[1]::
- An example script to create a tag object signed with GPG.
-
-gitlink:git-update-ref[1]::
- Update the object name stored in a ref safely.
-
+include::cmds-ancillarymanipulators.txt[]
Interrogators:
-gitlink:git-annotate[1]::
- Annotate file lines with commit info.
-
-gitlink:git-blame[1]::
- Find out where each line in a file came from.
-
-gitlink:git-check-ref-format[1]::
- Make sure ref name is well formed.
-
-gitlink:git-cherry[1]::
- Find commits not merged upstream.
-
-gitlink:git-count-objects[1]::
- Count unpacked number of objects and their disk consumption.
-
-gitlink:git-daemon[1]::
- A really simple server for git repositories.
-
-gitlink:git-fmt-merge-msg[1]::
- Produce a merge commit message.
-
-gitlink:git-get-tar-commit-id[1]::
- Extract commit ID from an archive created using git-tar-tree.
-
-gitlink:git-imap-send[1]::
- Dump a mailbox from stdin into an imap folder.
-
-gitlink:git-instaweb[1]::
- Instantly browse your working repository in gitweb.
-
-gitlink:git-mailinfo[1]::
- Extracts patch and authorship information from a single
- e-mail message, optionally transliterating the commit
- message into utf-8.
-
-gitlink:git-mailsplit[1]::
- A stupid program to split UNIX mbox format mailbox into
- individual pieces of e-mail.
-
-gitlink:git-merge-tree[1]::
- Show three-way merge without touching index.
-
-gitlink:git-patch-id[1]::
- Compute unique ID for a patch.
-
-gitlink:git-parse-remote[1]::
- Routines to help parsing `$GIT_DIR/remotes/` files.
+include::cmds-ancillaryinterrogators.txt[]
-gitlink:git-request-pull[1]::
- git-request-pull.
-gitlink:git-rev-parse[1]::
- Pick out and massage parameters.
-
-gitlink:git-runstatus[1]::
- A helper for git-status and git-commit.
-
-gitlink:git-send-email[1]::
- Send patch e-mails out of "format-patch --mbox" output.
+Interacting with Others
+~~~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-symbolic-ref[1]::
- Read and modify symbolic refs.
+These commands are to interact with foreign SCM and with other
+people via patch over e-mail.
-gitlink:git-stripspace[1]::
- Filter out empty lines.
+include::cmds-foreignscminterface.txt[]
Low-level commands (plumbing)
@@ -330,130 +137,30 @@ development of alternative porcelains. Developers of such porcelains
might start by reading about gitlink:git-update-index[1] and
gitlink:git-read-tree[1].
-We divide the low-level commands into commands that manipulate objects (in
+The interface (input, output, set of options and the semantics)
+to these low-level commands are meant to be a lot more stable
+than Porcelain level commands, because these commands are
+primarily for scripted use. The interface to Porcelain commands
+on the other hand are subject to change in order to improve the
+end user experience.
+
+The following description divides
+the low-level commands into commands that manipulate objects (in
the repository, index, and working tree), commands that interrogate and
compare objects, and commands that move objects and references between
repositories.
+
Manipulation commands
~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-apply[1]::
- Reads a "diff -up1" or git generated patch file and
- applies it to the working tree.
-
-gitlink:git-checkout-index[1]::
- Copy files from the index to the working tree.
-
-gitlink:git-commit-tree[1]::
- Creates a new commit object.
-
-gitlink:git-hash-object[1]::
- Computes the object ID from a file.
-
-gitlink:git-index-pack[1]::
- Build pack idx file for an existing packed archive.
-
-gitlink:git-init[1]::
-gitlink:git-init-db[1]::
- Creates an empty git object database, or reinitialize an
- existing one.
-
-gitlink:git-merge-file[1]::
- Runs a threeway merge.
-
-gitlink:git-merge-index[1]::
- Runs a merge for files needing merging.
-
-gitlink:git-mktag[1]::
- Creates a tag object.
-
-gitlink:git-mktree[1]::
- Build a tree-object from ls-tree formatted text.
-
-gitlink:git-pack-objects[1]::
- Creates a packed archive of objects.
-gitlink:git-prune-packed[1]::
- Remove extra objects that are already in pack files.
-
-gitlink:git-read-tree[1]::
- Reads tree information into the index.
-
-gitlink:git-repo-config[1]::
- Get and set options in .git/config.
-
-gitlink:git-unpack-objects[1]::
- Unpacks objects out of a packed archive.
-
-gitlink:git-update-index[1]::
- Registers files in the working tree to the index.
-
-gitlink:git-write-tree[1]::
- Creates a tree from the index.
+include::cmds-plumbingmanipulators.txt[]
Interrogation commands
~~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-cat-file[1]::
- Provide content or type/size information for repository objects.
-
-gitlink:git-describe[1]::
- Show the most recent tag that is reachable from a commit.
-
-gitlink:git-diff-index[1]::
- Compares content and mode of blobs between the index and repository.
-
-gitlink:git-diff-files[1]::
- Compares files in the working tree and the index.
-
-gitlink:git-diff-stages[1]::
- Compares two "merge stages" in the index.
-
-gitlink:git-diff-tree[1]::
- Compares the content and mode of blobs found via two tree objects.
-
-gitlink:git-for-each-ref[1]::
- Output information on each ref.
-
-gitlink:git-fsck-objects[1]::
- Verifies the connectivity and validity of the objects in the database.
-
-gitlink:git-ls-files[1]::
- Information about files in the index and the working tree.
-
-gitlink:git-ls-tree[1]::
- Displays a tree object in human readable form.
-
-gitlink:git-merge-base[1]::
- Finds as good common ancestors as possible for a merge.
-
-gitlink:git-name-rev[1]::
- Find symbolic names for given revs.
-
-gitlink:git-pack-redundant[1]::
- Find redundant pack files.
-
-gitlink:git-rev-list[1]::
- Lists commit objects in reverse chronological order.
-
-gitlink:git-show-index[1]::
- Displays contents of a pack idx file.
-
-gitlink:git-show-ref[1]::
- List references in a local repository.
-
-gitlink:git-tar-tree[1]::
- Creates a tar archive of the files in the named tree object.
-
-gitlink:git-unpack-file[1]::
- Creates a temporary file with a blob's contents.
-
-gitlink:git-var[1]::
- Displays a git logical variable.
-
-gitlink:git-verify-pack[1]::
- Validates packed git archive files.
+include::cmds-plumbinginterrogators.txt[]
In general, the interrogate commands do not touch the files in
the working tree.
@@ -462,52 +169,21 @@ the working tree.
Synching repositories
~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-fetch-pack[1]::
- Updates from a remote repository (engine for ssh and
- local transport).
-
-gitlink:git-http-fetch[1]::
- Downloads a remote git repository via HTTP by walking
- commit chain.
-
-gitlink:git-local-fetch[1]::
- Duplicates another git repository on a local system by
- walking commit chain.
-
-gitlink:git-peek-remote[1]::
- Lists references on a remote repository using
- upload-pack protocol (engine for ssh and local
- transport).
-
-gitlink:git-receive-pack[1]::
- Invoked by 'git-send-pack' to receive what is pushed to it.
-
-gitlink:git-send-pack[1]::
- Pushes to a remote repository, intelligently.
-
-gitlink:git-http-push[1]::
- Push missing objects using HTTP/DAV.
+include::cmds-synchingrepositories.txt[]
-gitlink:git-shell[1]::
- Restricted shell for GIT-only SSH access.
+The following are helper programs used by the above; end users
+typically do not use them directly.
-gitlink:git-ssh-fetch[1]::
- Pulls from a remote repository over ssh connection by
- walking commit chain.
+include::cmds-synchelpers.txt[]
-gitlink:git-ssh-upload[1]::
- Helper "server-side" program used by git-ssh-fetch.
-gitlink:git-update-server-info[1]::
- Updates auxiliary information on a dumb server to help
- clients discover references and packs on it.
+Internal helper commands
+~~~~~~~~~~~~~~~~~~~~~~~~
-gitlink:git-upload-archive[1]::
- Invoked by 'git-archive' to send a generated archive.
+These are internal helper commands used by other commands; end
+users typically do not use them directly.
-gitlink:git-upload-pack[1]::
- Invoked by 'git-fetch-pack' to push
- what are asked for.
+include::cmds-purehelpers.txt[]
Configuration Mechanism
@@ -700,7 +376,7 @@ other
Discussion[[Discussion]]
------------------------
-include::README[]
+include::core-intro.txt[]
Authors
-------
diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index f1aeb07f64..48c5894736 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -3,7 +3,7 @@ gitk(1)
NAME
----
-gitk - git repository browser
+gitk - The git repository browser
SYNOPSIS
--------
@@ -47,12 +47,14 @@ frequently used options.
meaning show from the given revision and back, or it can be a range in
the form "'<from>'..'<to>'" to show all revisions between '<from>' and
back to '<to>'. Note, more advanced revision selection can be applied.
+ For a more complete list of ways to spell object names, see
+ "SPECIFYING REVISIONS" section in gitlink:git-rev-parse[1].
<path>::
Limit commits to the ones touching files in the given paths. Note, to
avoid ambiguity wrt. revision names use "--" to separate the paths
- from any preceeding options.
+ from any preceding options.
Examples
--------
diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt
index cd61aa2606..d20eb6270c 100644
--- a/Documentation/glossary.txt
+++ b/Documentation/glossary.txt
@@ -259,7 +259,7 @@ refspec::
means "grab the master branch head from the $URL and store
it as my origin branch head".
And `git push $URL refs/heads/master:refs/heads/to-upstream`
- means "publish my master branch head as to-upstream master head
+ means "publish my master branch head as to-upstream branch
at $URL". See also gitlink:git-push[1]
repository::
@@ -286,6 +286,18 @@ SCM::
SHA1::
Synonym for object name.
+shallow repository::
+ A shallow repository has an incomplete history some of
+ whose commits have parents cauterized away (in other
+ words, git is told to pretend that these commits do not
+ have the parents, even though they are recorded in the
+ commit object). This is sometimes useful when you are
+ interested only in the recent history of a project even
+ though the real history recorded in the upstream is
+ much larger. A shallow repository is created by giving
+ `--depth` option to gitlink:git-clone[1], and its
+ history can be later deepened with gitlink:git-fetch[1].
+
symref::
Symbolic reference: instead of containing the SHA1 id itself, it
is of the format 'ref: refs/some/thing' and when referenced, it
diff --git a/Documentation/hooks.txt b/Documentation/hooks.txt
index 161123f142..b083290d12 100644
--- a/Documentation/hooks.txt
+++ b/Documentation/hooks.txt
@@ -3,7 +3,7 @@ Hooks used by git
Hooks are little scripts you can place in `$GIT_DIR/hooks`
directory to trigger action at certain points. When
-`git-init-db` 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`.
@@ -90,9 +90,6 @@ 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 default 'post-commit' hook, when enabled, demonstrates how to
-send out a commit notification e-mail.
-
update
------
@@ -130,6 +127,8 @@ The standard output of this hook is sent to `stderr`, so if you
want to report something to the `git-send-pack` on the other end,
you can simply `echo` your messages.
+The default 'update' hook, when enabled, demonstrates how to
+send out a notification e-mail.
post-update
-----------
diff --git a/Documentation/howto/dangling-objects.txt b/Documentation/howto/dangling-objects.txt
new file mode 100644
index 0000000000..e82ddae3cf
--- /dev/null
+++ b/Documentation/howto/dangling-objects.txt
@@ -0,0 +1,109 @@
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Subject: Re: Question about fsck-objects output
+Date: Thu, 25 Jan 2007 12:01:06 -0800 (PST)
+Message-ID: <Pine.LNX.4.64.0701251144290.25027@woody.linux-foundation.org>
+Archived-At: <http://permalink.gmane.org/gmane.comp.version-control.git/37754>
+Abstract: Linus describes what dangling objects are, when they
+ are left behind, and how to view their relationship with branch
+ heads in gitk
+
+On Thu, 25 Jan 2007, Larry Streepy wrote:
+
+> Sorry to ask such a basic question, but I can't quite decipher the output of
+> fsck-objects. When I run it, I get this:
+>
+> git fsck-objects
+> dangling commit 2213f6d4dd39ca8baebd0427723723e63208521b
+> dangling commit f0d4e00196bd5ee54463e9ea7a0f0e8303da767f
+> dangling blob 6a6d0b01b3e96d49a8f2c7addd4ef8c3bd1f5761
+>
+>
+> Even after a "repack -a -d" they still exist. The man page has a short
+> explanation, but, at least for me, it wasn't fully enlightening. :-)
+>
+> The man page says that dangling commits could be "root" commits, but since my
+> repo started as a clone of another repo, I don't see how I could have any root
+> commits. Also, the page doesn't really describe what a dangling blob is.
+>
+> So, can someone explain what these artifacts are and if they are a problem
+> that I should be worried about?
+
+The most common situation is that you've rebased a branch (or you have
+pulled from somebody else who rebased a branch, like the "pu" branch in
+the git.git archive itself).
+
+What happens is that the old head of the original branch still exists, as
+does obviously everything it pointed to. The branch pointer itself just
+doesn't, since you replaced it with another one.
+
+However, there are certainly other situations too that cause dangling
+objects. For example, the "dangling blob" situation you have tends to be
+because you did a "git add" of a file, but then, before you actually
+committed it and made it part of the bigger picture, you changed something
+else in that file and committed that *updated* thing - the old state that
+you added originally ends up not being pointed to by any commit/tree, so
+it's now a dangling blob object.
+
+Similarly, when the "recursive" merge strategy runs, and finds that there
+are criss-cross merges and thus more than one merge base (which is fairly
+unusual, but it does happen), it will generate one temporary midway tree
+(or possibly even more, if you had lots of criss-crossing merges and
+more than two merge bases) as a temporary internal merge base, and again,
+those are real objects, but the end result will not end up pointing to
+them, so they end up "dangling" in your repository.
+
+Generally, dangling objects aren't anything to worry about. They can even
+be very useful: if you screw something up, the dangling objects can be how
+you recover your old tree (say, you did a rebase, and realized that you
+really didn't want to - you can look at what dangling objects you have,
+and decide to reset your head to some old dangling state).
+
+For commits, the most useful thing to do with dangling objects tends to be
+to do a simple
+
+ gitk <dangling-commit-sha-goes-here> --not --all
+
+which means exactly what it sounds like: it says that you want to see the
+commit history that is described by the dangling commit(s), but you do NOT
+want to see the history that is described by all your branches and tags
+(which are the things you normally reach). That basically shows you in a
+nice way what the danglign commit was (and notice that it might not be
+just one commit: we only report the "tip of the line" as being dangling,
+but there might be a whole deep and complex commit history that has gotten
+dropped - rebasing will do that).
+
+For blobs and trees, you can't do the same, but you can examine them. You
+can just do
+
+ git show <dangling-blob/tree-sha-goes-here>
+
+to show what the contents of the blob were (or, for a tree, basically what
+the "ls" for that directory was), and that may give you some idea of what
+the operation was that left that dangling object.
+
+Usually, dangling blobs and trees aren't very interesting. They're almost
+always the result of either being a half-way mergebase (the blob will
+often even have the conflict markers from a merge in it, if you have had
+conflicting merges that you fixed up by hand), or simply because you
+interrupted a "git fetch" with ^C or something like that, leaving _some_
+of the new objects in the object database, but just dangling and useless.
+
+Anyway, once you are sure that you're not interested in any dangling
+state, you can just prune all unreachable objects:
+
+ git prune
+
+and they'll be gone. But you should only run "git prune" on a quiescent
+repository - it's kind of like doing a filesystem fsck recovery: you don't
+want to do that while the filesystem is mounted.
+
+(The same is true of "git-fsck-objects" itself, btw - but since
+git-fsck-objects never actually *changes* the repository, it just reports
+on what it found, git-fsck-objects itself is never "dangerous" to run.
+Running it while somebody is actually changing the repository can cause
+confusing and scary messages, but it won't actually do anything bad. In
+contrast, running "git prune" while somebody is actively changing the
+repository is a *BAD* idea).
+
+ Linus
+
diff --git a/Documentation/howto/rebase-from-internal-branch.txt b/Documentation/howto/rebase-from-internal-branch.txt
index fcd64e9b9b..3b3a5c2e69 100644
--- a/Documentation/howto/rebase-from-internal-branch.txt
+++ b/Documentation/howto/rebase-from-internal-branch.txt
@@ -106,7 +106,7 @@ prepare #2 and #3 for e-mail submission.
$ git format-patch master^^ master
-This creates two files, 0001-XXXX.txt and 0002-XXXX.txt. Send
+This creates two files, 0001-XXXX.patch and 0002-XXXX.patch. Send
them out "To: " your project maintainer and "Cc: " your mailing
list. You could use contributed script git-send-email if
your host has necessary perl modules for this, but your usual
diff --git a/Documentation/howto/revert-branch-rebase.txt b/Documentation/howto/revert-branch-rebase.txt
index d10476b56e..d88ec23a97 100644
--- a/Documentation/howto/revert-branch-rebase.txt
+++ b/Documentation/howto/revert-branch-rebase.txt
@@ -85,7 +85,7 @@ Fortunately I did not have to; what I have in the current branch
------------------------------------------------
$ git checkout master
-$ git resolve master revert-c99 fast ;# this should be a fast forward
+$ git merge revert-c99 ;# this should be a fast forward
Updating from 10d781b9caa4f71495c7b34963bef137216f86a8 to e3a693c...
cache.h | 8 ++++----
commit.c | 2 +-
@@ -95,13 +95,6 @@ Updating from 10d781b9caa4f71495c7b34963bef137216f86a8 to e3a693c...
5 files changed, 8 insertions(+), 8 deletions(-)
------------------------------------------------
-The 'fast' in the above 'git resolve' is not a magic. I knew this
-'resolve' would result in a fast forward merge, and if not, there is
-something very wrong (so I would do 'git reset' on the 'master' branch
-and examine the situation). When a fast forward merge is done, the
-message parameter to 'git resolve' is discarded, because no new commit
-is created. You could have said 'junk' or 'nothing' there as well.
-
There is no need to redo the test at this point. We fast forwarded
and we know 'master' matches 'revert-c99' exactly. In fact:
diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt
index ba191569af..8eadc20494 100644
--- a/Documentation/howto/setup-git-server-over-http.txt
+++ b/Documentation/howto/setup-git-server-over-http.txt
@@ -70,7 +70,7 @@ DocumentRoot /where/ever/httpd.conf" to find your root:
Initialize a bare repository
$ cd my-new-repo.git
- $ git --bare init-db
+ $ git --bare init
Change the ownership to your web-server's credentials. Use "grep ^User
@@ -205,7 +205,7 @@ To check whether all is OK, do:
Now, add the remote in your existing repository which contains the project
you want to export:
- $ git-repo-config remote.upload.url \
+ $ git-config remote.upload.url \
http://<username>@<servername>/my-new-repo.git/
It is important to put the last '/'; Without it, the server will send
@@ -222,7 +222,7 @@ From your client repository, do
This pushes branch 'master' (which is assumed to be the branch you
want to export) to repository called 'upload', which we previously
-defined with git-repo-config.
+defined with git-config.
Troubleshooting:
diff --git a/Documentation/install-webdoc.sh b/Documentation/install-webdoc.sh
index 60211a5058..b3981936e3 100755
--- a/Documentation/install-webdoc.sh
+++ b/Documentation/install-webdoc.sh
@@ -2,7 +2,7 @@
T="$1"
-for h in *.html *.txt howto/*.txt howto/*.html
+for h in *.html *.txt howto/*.txt howto/*.html RelNotes-*.txt
do
if test -f "$T/$h" &&
diff -u -I'Last updated [0-9][0-9]-[A-Z][a-z][a-z]-' "$T/$h" "$h"
diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt
index e20fb7e74c..0459bd9ca1 100644
--- a/Documentation/repository-layout.txt
+++ b/Documentation/repository-layout.txt
@@ -18,6 +18,8 @@ could have only commit objects without associated blobs and
trees this way, for example. A repository with this kind of
incomplete object store is not suitable to be published to the
outside world but sometimes useful for private repository.
+. You also could have an incomplete but locally usable repository
+by cloning shallowly. See gitlink:git-clone[1].
. You can be using `objects/info/alternates` mechanism, or
`$GIT_ALTERNATE_OBJECT_DIRECTORIES` mechanism to 'borrow'
objects from other object stores. A repository with this kind
@@ -32,7 +34,7 @@ objects/[0-9a-f][0-9a-f]::
two letters from its object name to keep the number of
directory entries `objects` directory itself needs to
hold. Objects found here are often called 'unpacked'
- objects.
+ (or 'loose') objects.
objects/pack::
Packs (files that store many object in compressed form,
@@ -80,6 +82,15 @@ refs/tags/`name`::
records any object name (not necessarily a commit
object, or a tag object that points at a commit object).
+refs/remotes/`name`::
+ records tip-of-the-tree commit objects of branches copied
+ from a remote repository.
+
+packed-refs::
+ records the same information as refs/heads/, refs/tags/,
+ and friends record in a more efficient way. See
+ gitlink:git-pack-refs[1].
+
HEAD::
A symref (see glossary) to the `refs/heads/` namespace
describing the currently active branch. It does not mean
@@ -91,6 +102,12 @@ HEAD::
'name' does not (yet) exist. In some legacy setups, it is
a symbolic link instead of a symref that points at the current
branch.
++
+HEAD can also record a specific commit directly, instead of
+being a symref to point at the current branch. Such a state
+is often called 'detached HEAD', and almost all commands work
+identically as normal. See gitlink:git-checkout[1] for
+details.
branches::
A slightly deprecated way to store shorthands to be used
@@ -102,7 +119,7 @@ branches::
hooks::
Hooks are customization scripts used by various git
commands. A handful of sample hooks are installed when
- `git init-db` 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
each hook.
@@ -116,14 +133,14 @@ info::
in this directory.
info/refs::
- This file is to help dumb transports to discover what
- refs are available in this repository. Whenever you
- create/delete a new branch or a new tag, `git
- update-server-info` should be run to keep this file
- up-to-date if the repository is published for dumb
- transports. The `git-receive-pack` command, which is
- run on a remote repository when you `git push` into it,
- runs `hooks/update` hook to help you achieve this.
+ 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
+ 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
+ repository.
info/grafts::
This file records fake commit ancestry information, to
@@ -156,3 +173,9 @@ logs/refs/heads/`name`::
logs/refs/tags/`name`::
Records all changes made to the tag named `name`.
+
+shallow::
+ This is similar to `info/grafts` but is internally used
+ and maintained by shallow clone mechanism. See `--depth`
+ option to gitlink:git-clone[1] and gitlink:git-fetch[1].
+
diff --git a/Documentation/tutorial-2.txt b/Documentation/tutorial-2.txt
index f48894c9a2..8d89992712 100644
--- a/Documentation/tutorial-2.txt
+++ b/Documentation/tutorial-2.txt
@@ -343,8 +343,8 @@ And, as you can see with cat-file, this new entry refers to the
current contents of the file:
------------------------------------------------
-$ git cat-file blob a6b11f7a
-goodbye, word
+$ git cat-file blob 8b9743b2
+goodbye, world
------------------------------------------------
The "status" command is a useful way to get a quick summary of the
@@ -352,24 +352,23 @@ situation:
------------------------------------------------
$ git status
-#
-# Added but not yet committed:
-# (will commit)
+# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
#
# new file: closing.txt
#
-#
-# Changed but not added:
-# (use "git add file1 file2" to include for commit)
+# Changed but not updated:
+# (use "git add <file>..." to update what will be committed)
#
# modified: file.txt
#
------------------------------------------------
Since the current state of closing.txt is cached in the index file,
-it is listed as "added but not yet committed". Since file.txt has
+it is listed as "Changes to be committed". Since file.txt has
changes in the working directory that aren't reflected in the index,
-it is marked "changed but not added". At this point, running "git
+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.
diff --git a/Documentation/tutorial.txt b/Documentation/tutorial.txt
index d2bf0b905a..129c5c5f5b 100644
--- a/Documentation/tutorial.txt
+++ b/Documentation/tutorial.txt
@@ -11,15 +11,13 @@ diff" with:
$ man git-diff
------------------------------------------------
-It is a good idea to introduce yourself to git before doing any
-operation. The easiest way to do so is:
+It is a good idea to introduce yourself to git with your name and
+public email address before doing any operation. The easiest
+way to do so is:
------------------------------------------------
-$ cat >~/.gitconfig <<\EOF
-[user]
- name = Your Name Comes Here
- email = you@yourdomain.example.com
-EOF
+$ git config --global user.name "Your Name Comes Here"
+$ git config --global user.email you@yourdomain.example.com
------------------------------------------------
@@ -103,27 +101,27 @@ want to commit together. This can be done in a few different ways:
1) By using 'git add <file_spec>...'
- This can be performed multiple times before a commit. Note that this
- is not only for adding new files. Even modified files must be
- added to the set of changes about to be committed. The "git status"
- command gives you a summary of what is included so far for the
- next commit. When done you should use the 'git commit' command to
- make it real.
+This can be performed multiple times before a commit. Note that this
+is not only for adding new files. Even modified files must be
+added to the set of changes about to be committed. The "git status"
+command gives you a summary of what is included so far for the
+next commit. When done you should use the 'git commit' command to
+make it real.
- Note: don't forget to 'add' a file again if you modified it after the
- first 'add' and before 'commit'. Otherwise only the previous added
- state of that file will be committed. This is because git tracks
- content, so what you're really 'add'ing to the commit is the *content*
- of the file in the state it is in when you 'add' it.
+Note: don't forget to 'add' a file again if you modified it after the
+first 'add' and before 'commit'. Otherwise only the previous added
+state of that file will be committed. This is because git tracks
+content, so what you're really 'add'ing to the commit is the *content*
+of the file in the state it is in when you 'add' it.
2) By using 'git commit -a' directly
- This is a quick way to automatically 'add' the content from all files
- that were modified since the previous commit, and perform the actual
- commit without having to separately 'add' them beforehand. This will
- not add content from new files i.e. files that were never added before.
- Those files still have to be added explicitly before performing a
- commit.
+This is a quick way to automatically 'add' the content from all files
+that were modified since the previous commit, and perform the actual
+commit without having to separately 'add' them beforehand. This will
+not add content from new files i.e. files that were never added before.
+Those files still have to be added explicitly before performing a
+commit.
But here's a twist. If you do 'git commit <file1> <file2> ...' then only
the changes belonging to those explicitly specified files will be
@@ -211,7 +209,7 @@ at this point the two branches have diverged, with different changes
made in each. To merge the changes made in experimental into master, run
------------------------------------------------
-$ git pull . experimental
+$ git merge experimental
------------------------------------------------
If the changes don't conflict, you're done. If there are conflicts,
@@ -297,46 +295,51 @@ is the default.)
The "pull" command thus performs two operations: it fetches changes
from a remote branch, then merges them into the current branch.
-You can perform the first operation alone using the "git fetch"
-command. For example, Alice could create a temporary branch just to
-track Bob's changes, without merging them with her own, using:
+When you are working in a small closely knit group, it is not
+unusual to interact with the same repository over and over
+again. By defining 'remote' repository shorthand, you can make
+it easier:
+
+------------------------------------------------
+$ git remote add bob /home/bob/myrepo
+------------------------------------------------
+
+With this, you can perform the first operation alone using the
+"git fetch" command without merging them with her own branch,
+using:
-------------------------------------
-$ git fetch /home/bob/myrepo master:bob-incoming
+$ git fetch bob
-------------------------------------
-which fetches the changes from Bob's master branch into a new branch
-named bob-incoming. Then
+Unlike the longhand form, when Alice fetches from Bob using a
+remote repository shorthand set up with `git remote`, what was
+fetched is stored in a remote tracking branch, in this case
+`bob/master`. So after this:
-------------------------------------
-$ git log -p master..bob-incoming
+$ git log -p master..bob/master
-------------------------------------
shows a list of all the changes that Bob made since he branched from
Alice's master branch.
-After examining those changes, and possibly fixing things, Alice
-could pull the changes into her master branch:
+After examining those changes, Alice
+could merge the changes into her master branch:
-------------------------------------
-$ git checkout master
-$ git pull . bob-incoming
+$ git merge bob/master
-------------------------------------
-The last command is a pull from the "bob-incoming" branch in Alice's
-own repository.
-
-Alice could also perform both steps at once with:
+This `merge` can also be done by 'pulling from her own remote
+tracking branch', like this:
-------------------------------------
-$ git pull /home/bob/myrepo master:bob-incoming
+$ git pull . remotes/bob/master
-------------------------------------
-This is just like the "git pull /home/bob/myrepo master" that we saw
-before, except that it also stores the unmerged changes from bob's
-master branch in bob-incoming before merging them into Alice's
-current branch. Note that git pull always merges into the current
-branch, regardless of what else is given on the commandline.
+Note that git pull always merges into the current branch,
+regardless of what else is given on the commandline.
Later, Bob can update his repo with Alice's latest changes using
@@ -350,12 +353,12 @@ repository in the repository configuration, and that location is
used for pulls:
-------------------------------------
-$ git repo-config --get remote.origin.url
+$ git config --get remote.origin.url
/home/bob/myrepo
-------------------------------------
(The complete configuration created by git-clone is visible using
-"git repo-config -l", and the gitlink:git-repo-config[1] man page
+"git config -l", and the gitlink:git-config[1] man page
explains the meaning of each option.)
Git also keeps a pristine copy of Alice's master branch under the
@@ -455,9 +458,11 @@ $ 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
-publicly-visible branch that other developers pull from, as git will
-be confused by history that disappears in this way.)
+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 gitlink:git-revert[1]
+instead.
The git grep command can search for strings in any version of your
project, so
diff --git a/Documentation/user-manual.conf b/Documentation/user-manual.conf
new file mode 100644
index 0000000000..92b01ecf71
--- /dev/null
+++ b/Documentation/user-manual.conf
@@ -0,0 +1,21 @@
+[titles]
+ underlines="__","==","--","~~","^^"
+
+[attributes]
+caret=^
+startsb=&#91;
+endsb=&#93;
+tilde=&#126;
+
+[gitlink-inlinemacro]
+<ulink url="{target}.html">{target}{0?({0})}</ulink>
+
+ifdef::backend-docbook[]
+# "unbreak" docbook-xsl v1.68 for manpages. v1.69 works with or without this.
+[listingblock]
+<example><title>{title}</title>
+<literallayout>
+|
+</literallayout>
+{title#}</example>
+endif::backend-docbook[]
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
new file mode 100644
index 0000000000..03736bbcd3
--- /dev/null
+++ b/Documentation/user-manual.txt
@@ -0,0 +1,2961 @@
+Git User's Manual
+_________________
+
+This manual is designed to be readable by someone with basic unix
+commandline skills, but no previous knowledge of git.
+
+Chapter 1 gives a brief overview of git commands, without any
+explanation; you may prefer to skip to chapter 2 on a first reading.
+
+Chapters 2 and 3 explain how to fetch and study a project using
+git--the tools you'd need to build and test a particular version of a
+software project, to search for regressions, and so on.
+
+Chapter 4 explains how to do development with git, and chapter 5 how
+to share that development with others.
+
+Further chapters cover more specialized topics.
+
+Comprehensive reference documentation is available through the man
+pages. For a command such as "git clone", just use
+
+------------------------------------------------
+$ man git-clone
+------------------------------------------------
+
+Git Quick Start
+===============
+
+This is a quick summary of the major commands; the following chapters
+will explain how these work in more detail.
+
+Creating a new repository
+-------------------------
+
+From a tarball:
+
+-----------------------------------------------
+$ tar xzf project.tar.gz
+$ cd project
+$ git init
+Initialized empty Git repository in .git/
+$ git add .
+$ git commit
+-----------------------------------------------
+
+From a remote repository:
+
+-----------------------------------------------
+$ git clone git://example.com/pub/project.git
+$ cd project
+-----------------------------------------------
+
+Managing branches
+-----------------
+
+-----------------------------------------------
+$ git branch # list all branches in this repo
+$ git checkout test # switch working directory to branch "test"
+$ git branch new # create branch "new" starting at current HEAD
+$ git branch -d new # delete branch "new"
+-----------------------------------------------
+
+Instead of basing new branch on current HEAD (the default), use:
+
+-----------------------------------------------
+$ git branch new test # branch named "test"
+$ git branch new v2.6.15 # tag named v2.6.15
+$ git branch new HEAD^ # commit before the most recent
+$ git branch new HEAD^^ # commit before that
+$ git branch new test~10 # ten commits before tip of branch "test"
+-----------------------------------------------
+
+Create and switch to a new branch at the same time:
+
+-----------------------------------------------
+$ git checkout -b new v2.6.15
+-----------------------------------------------
+
+Update and examine branches from the repository you cloned from:
+
+-----------------------------------------------
+$ git fetch # update
+$ git branch -r # list
+ origin/master
+ origin/next
+ ...
+$ git branch checkout -b masterwork origin/master
+-----------------------------------------------
+
+Fetch a branch from a different repository, and give it a new
+name in your repository:
+
+-----------------------------------------------
+$ git fetch git://example.com/project.git theirbranch:mybranch
+$ git fetch git://example.com/project.git v2.6.15:mybranch
+-----------------------------------------------
+
+Keep a list of repositories you work with regularly:
+
+-----------------------------------------------
+$ git remote add example git://example.com/project.git
+$ git remote # list remote repositories
+example
+origin
+$ git remote show example # get details
+* remote example
+ URL: git://example.com/project.git
+ Tracked remote branches
+ master next ...
+$ git fetch example # update branches from example
+$ git branch -r # list all remote branches
+-----------------------------------------------
+
+
+Exploring history
+-----------------
+
+-----------------------------------------------
+$ gitk # visualize and browse history
+$ git log # list all commits
+$ git log src/ # ...modifying src/
+$ git log v2.6.15..v2.6.16 # ...in v2.6.16, not in v2.6.15
+$ git log master..test # ...in branch test, not in branch master
+$ git log test..master # ...in branch master, but not in test
+$ git log test...master # ...in one branch, not in both
+$ git log -S'foo()' # ...where difference contain "foo()"
+$ git log --since="2 weeks ago"
+$ git log -p # show patches as well
+$ git show # most recent commit
+$ git diff v2.6.15..v2.6.16 # diff between two tagged versions
+$ git diff v2.6.15..HEAD # diff with current head
+$ git grep "foo()" # search working directory for "foo()"
+$ git grep v2.6.15 "foo()" # search old tree for "foo()"
+$ git show v2.6.15:a.txt # look at old version of a.txt
+-----------------------------------------------
+
+Search for regressions:
+
+-----------------------------------------------
+$ git bisect start
+$ git bisect bad # current version is bad
+$ git bisect good v2.6.13-rc2 # last known good revision
+Bisecting: 675 revisions left to test after this
+ # test here, then:
+$ git bisect good # if this revision is good, or
+$ git bisect bad # if this revision is bad.
+ # repeat until done.
+-----------------------------------------------
+
+Making changes
+--------------
+
+Make sure git knows who to blame:
+
+------------------------------------------------
+$ cat >~/.gitconfig <<\EOF
+[user]
+name = Your Name Comes Here
+email = you@yourdomain.example.com
+EOF
+------------------------------------------------
+
+Select file contents to include in the next commit, then make the
+commit:
+
+-----------------------------------------------
+$ git add a.txt # updated file
+$ git add b.txt # new file
+$ git rm c.txt # old file
+$ git commit
+-----------------------------------------------
+
+Or, prepare and create the commit in one step:
+
+-----------------------------------------------
+$ git commit d.txt # use latest content only of d.txt
+$ git commit -a # use latest content of all tracked files
+-----------------------------------------------
+
+Merging
+-------
+
+-----------------------------------------------
+$ git merge test # merge branch "test" into the current branch
+$ git pull git://example.com/project.git master
+ # fetch and merge in remote branch
+$ git pull . test # equivalent to git merge test
+-----------------------------------------------
+
+Sharing your changes
+--------------------
+
+Importing or exporting patches:
+
+-----------------------------------------------
+$ git format-patch origin..HEAD # format a patch for each commit
+ # in HEAD but not in origin
+$ git-am mbox # import patches from the mailbox "mbox"
+-----------------------------------------------
+
+Fetch a branch in a different git repository, then merge into the
+current branch:
+
+-----------------------------------------------
+$ git pull git://example.com/project.git theirbranch
+-----------------------------------------------
+
+Store the fetched branch into a local branch before merging into the
+current branch:
+
+-----------------------------------------------
+$ git pull git://example.com/project.git theirbranch:mybranch
+-----------------------------------------------
+
+After creating commits on a local branch, update the remote
+branch with your commits:
+
+-----------------------------------------------
+$ git push ssh://example.com/project.git mybranch:theirbranch
+-----------------------------------------------
+
+When remote and local branch are both named "test":
+
+-----------------------------------------------
+$ git push ssh://example.com/project.git test
+-----------------------------------------------
+
+Shortcut version for a frequently used remote repository:
+
+-----------------------------------------------
+$ git remote add example ssh://example.com/project.git
+$ git push example test
+-----------------------------------------------
+
+Repository maintenance
+----------------------
+
+Check for corruption:
+
+-----------------------------------------------
+$ git fsck
+-----------------------------------------------
+
+Recompress, remove unused cruft:
+
+-----------------------------------------------
+$ git gc
+-----------------------------------------------
+
+Repositories and Branches
+=========================
+
+How to get a git repository
+---------------------------
+
+It will be useful to have a git repository to experiment with as you
+read this manual.
+
+The best way to get one is by using the gitlink:git-clone[1] command
+to download a copy of an existing repository for a project that you
+are interested in. If you don't already have a project in mind, here
+are some interesting examples:
+
+------------------------------------------------
+ # git itself (approx. 10MB download):
+$ git clone git://git.kernel.org/pub/scm/git/git.git
+ # the linux kernel (approx. 150MB download):
+$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
+------------------------------------------------
+
+The initial clone may be time-consuming for a large project, but you
+will only need to clone once.
+
+The clone command creates a new directory named after the project
+("git" or "linux-2.6" in the examples above). After you cd into this
+directory, you will see that it contains a copy of the project files,
+together with a special top-level directory named ".git", which
+contains all the information about the history of the project.
+
+In most of the following, examples will be taken from one of the two
+repositories above.
+
+How to check out a different version of a project
+-------------------------------------------------
+
+Git is best thought of as a tool for storing the history of a
+collection of files. It stores the history as a compressed
+collection of interrelated snapshots (versions) of the project's
+contents.
+
+A single git repository may contain multiple branches. Each branch
+is a bookmark referencing a particular point in the project history.
+The gitlink:git-branch[1] command shows you the list of branches:
+
+------------------------------------------------
+$ git branch
+* master
+------------------------------------------------
+
+A freshly cloned repository contains a single branch, named "master",
+and the working directory contains the version of the project
+referred to by the master branch.
+
+Most projects also use tags. Tags, like branches, are references
+into the project's history, and can be listed using the
+gitlink:git-tag[1] command:
+
+------------------------------------------------
+$ git tag -l
+v2.6.11
+v2.6.11-tree
+v2.6.12
+v2.6.12-rc2
+v2.6.12-rc3
+v2.6.12-rc4
+v2.6.12-rc5
+v2.6.12-rc6
+v2.6.13
+...
+------------------------------------------------
+
+Tags are expected to always point at the same version of a project,
+while branches are expected to advance as development progresses.
+
+Create a new branch pointing to one of these versions and check it
+out using gitlink:git-checkout[1]:
+
+------------------------------------------------
+$ git checkout -b new v2.6.13
+------------------------------------------------
+
+The working directory then reflects the contents that the project had
+when it was tagged v2.6.13, and gitlink:git-branch[1] shows two
+branches, with an asterisk marking the currently checked-out branch:
+
+------------------------------------------------
+$ git branch
+ master
+* new
+------------------------------------------------
+
+If you decide that you'd rather see version 2.6.17, you can modify
+the current branch to point at v2.6.17 instead, with
+
+------------------------------------------------
+$ git reset --hard v2.6.17
+------------------------------------------------
+
+Note that if the current branch was your only reference to a
+particular point in history, then resetting that branch may leave you
+with no way to find the history it used to point to; so use this
+command carefully.
+
+Understanding History: Commits
+------------------------------
+
+Every change in the history of a project is represented by a commit.
+The gitlink:git-show[1] command shows the most recent commit on the
+current branch:
+
+------------------------------------------------
+$ git show
+commit 2b5f6dcce5bf94b9b119e9ed8d537098ec61c3d2
+Author: Jamal Hadi Salim <hadi@cyberus.ca>
+Date: Sat Dec 2 22:22:25 2006 -0800
+
+ [XFRM]: Fix aevent structuring to be more complete.
+
+ aevents can not uniquely identify an SA. We break the ABI with this
+ patch, but consensus is that since it is not yet utilized by any
+ (known) application then it is fine (better do it now than later).
+
+ Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
+ Signed-off-by: David S. Miller <davem@davemloft.net>
+
+diff --git a/Documentation/networking/xfrm_sync.txt b/Documentation/networking/xfrm_sync.txt
+index 8be626f..d7aac9d 100644
+--- a/Documentation/networking/xfrm_sync.txt
++++ b/Documentation/networking/xfrm_sync.txt
+@@ -47,10 +47,13 @@ aevent_id structure looks like:
+
+ struct xfrm_aevent_id {
+ struct xfrm_usersa_id sa_id;
++ xfrm_address_t saddr;
+ __u32 flags;
++ __u32 reqid;
+ };
+...
+------------------------------------------------
+
+As you can see, a commit shows who made the latest change, what they
+did, and why.
+
+Every commit has a 40-hexdigit id, sometimes called the "object name"
+or the "SHA1 id", shown on the first line of the "git show" output.
+You can usually refer to a commit by a shorter name, such as a tag or a
+branch name, but this longer name can also be useful. Most
+importantly, it is a globally unique name for this commit: so if you
+tell somebody else the object name (for example in email), then you are
+guaranteed that name will refer to the same commit in their repository
+that it does in yours (assuming their repository has that commit at
+all).
+
+Understanding history: commits, parents, and reachability
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Every commit (except the very first commit in a project) also has a
+parent commit which shows what happened before this commit.
+Following the chain of parents will eventually take you back to the
+beginning of the project.
+
+However, the commits do not form a simple list; git allows lines of
+development to diverge and then reconverge, and the point where two
+lines of development reconverge is called a "merge". The commit
+representing a merge can therefore have more than one parent, with
+each parent representing the most recent commit on one of the lines
+of development leading to that point.
+
+The best way to see how this works is using the gitlink:gitk[1]
+command; running gitk now on a git repository and looking for merge
+commits will help understand how the git organizes history.
+
+In the following, we say that commit X is "reachable" from commit Y
+if commit X is an ancestor of commit Y. Equivalently, you could say
+that Y is a descendent of X, or that there is a chain of parents
+leading from commit Y to commit X.
+
+Understanding history: History diagrams
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+We will sometimes represent git history using diagrams like the one
+below. Commits are shown as "o", and the links between them with
+lines drawn with - / and \. Time goes left to right:
+
+ o--o--o <-- Branch A
+ /
+ o--o--o <-- master
+ \
+ o--o--o <-- Branch B
+
+If we need to talk about a particular commit, the character "o" may
+be replaced with another letter or number.
+
+Understanding history: What is a branch?
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Though we've been using the word "branch" to mean a kind of reference
+to a particular commit, the word branch is also commonly used to
+refer to the line of commits leading up to that point. In the
+example above, git may think of the branch named "A" as just a
+pointer to one particular commit, but we may refer informally to the
+line of three commits leading up to that point as all being part of
+"branch A".
+
+If we need to make it clear that we're just talking about the most
+recent commit on the branch, we may refer to that commit as the
+"head" of the branch.
+
+Manipulating branches
+---------------------
+
+Creating, deleting, and modifying branches is quick and easy; here's
+a summary of the commands:
+
+git branch::
+ list all branches
+git branch <branch>::
+ create a new branch named <branch>, referencing the same
+ point in history as the current branch
+git branch <branch> <start-point>::
+ create a new branch named <branch>, referencing
+ <start-point>, which may be specified any way you like,
+ including using a branch name or a tag name
+git branch -d <branch>::
+ delete the branch <branch>; if the branch you are deleting
+ points to a commit which is not reachable from this branch,
+ this command will fail with a warning.
+git branch -D <branch>::
+ even if the branch points to a commit not reachable
+ from the current branch, you may know that that commit
+ is still reachable from some other branch or tag. In that
+ case it is safe to use this command to force git to delete
+ the branch.
+git checkout <branch>::
+ make the current branch <branch>, updating the working
+ directory to reflect the version referenced by <branch>
+git checkout -b <new> <start-point>::
+ create a new branch <new> referencing <start-point>, and
+ check it out.
+
+It is also useful to know that the special symbol "HEAD" can always
+be used to refer to the current branch.
+
+Examining branches from a remote repository
+-------------------------------------------
+
+The "master" branch that was created at the time you cloned is a copy
+of the HEAD in the repository that you cloned from. That repository
+may also have had other branches, though, and your local repository
+keeps branches which track each of those remote branches, which you
+can view using the "-r" option to gitlink:git-branch[1]:
+
+------------------------------------------------
+$ git branch -r
+ origin/HEAD
+ origin/html
+ origin/maint
+ origin/man
+ origin/master
+ origin/next
+ origin/pu
+ origin/todo
+------------------------------------------------
+
+You cannot check out these remote-tracking branches, but you can
+examine them on a branch of your own, just as you would a tag:
+
+------------------------------------------------
+$ git checkout -b my-todo-copy origin/todo
+------------------------------------------------
+
+Note that the name "origin" is just the name that git uses by default
+to refer to the repository that you cloned from.
+
+[[how-git-stores-references]]
+Naming branches, tags, and other references
+-------------------------------------------
+
+Branches, remote-tracking branches, and tags are all references to
+commits. All references are named with a slash-separated path name
+starting with "refs"; the names we've been using so far are actually
+shorthand:
+
+ - The branch "test" is short for "refs/heads/test".
+ - The tag "v2.6.18" is short for "refs/tags/v2.6.18".
+ - "origin/master" is short for "refs/remotes/origin/master".
+
+The full name is occasionally useful if, for example, there ever
+exists a tag and a branch with the same name.
+
+As another useful shortcut, if the repository "origin" posesses only
+a single branch, you can refer to that branch as just "origin".
+
+More generally, if you have defined a remote repository named
+"example", you can refer to the branch in that repository as
+"example". And for a repository with multiple branches, this will
+refer to the branch designated as the "HEAD" branch.
+
+For the complete list of paths which git checks for references, and
+the order it uses to decide which to choose when there are multiple
+references with the same shorthand name, see the "SPECIFYING
+REVISIONS" section of gitlink:git-rev-parse[1].
+
+[[Updating-a-repository-with-git-fetch]]
+Updating a repository with git fetch
+------------------------------------
+
+Eventually the developer cloned from will do additional work in her
+repository, creating new commits and advancing the branches to point
+at the new commits.
+
+The command "git fetch", with no arguments, will update all of the
+remote-tracking branches to the latest version found in her
+repository. It will not touch any of your own branches--not even the
+"master" branch that was created for you on clone.
+
+Fetching branches from other repositories
+-----------------------------------------
+
+You can also track branches from repositories other than the one you
+cloned from, using gitlink:git-remote[1]:
+
+-------------------------------------------------
+$ git remote add linux-nfs git://linux-nfs.org/pub/nfs-2.6.git
+$ git fetch
+* refs/remotes/linux-nfs/master: storing branch 'master' ...
+ commit: bf81b46
+-------------------------------------------------
+
+New remote-tracking branches will be stored under the shorthand name
+that you gave "git remote add", in this case linux-nfs:
+
+-------------------------------------------------
+$ git branch -r
+linux-nfs/master
+origin/master
+-------------------------------------------------
+
+If you run "git fetch <remote>" later, the tracking branches for the
+named <remote> will be updated.
+
+If you examine the file .git/config, you will see that git has added
+a new stanza:
+
+-------------------------------------------------
+$ cat .git/config
+...
+[remote "linux-nfs"]
+ url = git://linux-nfs.org/~bfields/git.git
+ fetch = +refs/heads/*:refs/remotes/linux-nfs-read/*
+...
+-------------------------------------------------
+
+This is what causes git to track the remote's branches; you may modify
+or delete these configuration options by editing .git/config with a
+text editor. (See the "CONFIGURATION FILE" section of
+gitlink:git-config[1] for details.)
+
+Exploring git history
+=====================
+
+Git is best thought of as a tool for storing the history of a
+collection of files. It does this by storing compressed snapshots of
+the contents of a file heirarchy, together with "commits" which show
+the relationships between these snapshots.
+
+Git provides extremely flexible and fast tools for exploring the
+history of a project.
+
+We start with one specialized tool that is useful for finding the
+commit that introduced a bug into a project.
+
+How to use bisect to find a regression
+--------------------------------------
+
+Suppose version 2.6.18 of your project worked, but the version at
+"master" crashes. Sometimes the best way to find the cause of such a
+regression is to perform a brute-force search through the project's
+history to find the particular commit that caused the problem. The
+gitlink:git-bisect[1] command can help you do this:
+
+-------------------------------------------------
+$ git bisect start
+$ git bisect good v2.6.18
+$ git bisect bad master
+Bisecting: 3537 revisions left to test after this
+[65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6]
+-------------------------------------------------
+
+If you run "git branch" at this point, you'll see that git has
+temporarily moved you to a new branch named "bisect". This branch
+points to a commit (with commit id 65934...) that is reachable from
+v2.6.19 but not from v2.6.18. Compile and test it, and see whether
+it crashes. Assume it does crash. Then:
+
+-------------------------------------------------
+$ git bisect bad
+Bisecting: 1769 revisions left to test after this
+[7eff82c8b1511017ae605f0c99ac275a7e21b867] i2c-core: Drop useless bitmaskings
+-------------------------------------------------
+
+checks out an older version. Continue like this, telling git at each
+stage whether the version it gives you is good or bad, and notice
+that the number of revisions left to test is cut approximately in
+half each time.
+
+After about 13 tests (in this case), it will output the commit id of
+the guilty commit. You can then examine the commit with
+gitlink:git-show[1], find out who wrote it, and mail them your bug
+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.
+
+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
+version if you think it would be a good idea. For example,
+occasionally you may land on a commit that broke something unrelated;
+run
+
+-------------------------------------------------
+$ 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
+id, and check it out with:
+
+-------------------------------------------------
+$ git reset --hard fb47ddb2db...
+-------------------------------------------------
+
+then test, run "bisect good" or "bisect bad" as appropriate, and
+continue.
+
+Naming commits
+--------------
+
+We have seen several ways of naming commits already:
+
+ - 40-hexdigit object name
+ - branch name: refers to the commit at the head of the given
+ branch
+ - tag name: refers to the commit pointed to by the given tag
+ (we've seen branches and tags are special cases of
+ <<how-git-stores-references,references>>).
+ - HEAD: refers to the head of the current branch
+
+There are many more; see the "SPECIFYING REVISIONS" section of the
+gitlink:git-rev-parse[1] man page for the complete list of ways to
+name revisions. Some examples:
+
+-------------------------------------------------
+$ git show fb47ddb2 # the first few characters of the object name
+ # are usually enough to specify it uniquely
+$ git show HEAD^ # the parent of the HEAD commit
+$ git show HEAD^^ # the grandparent
+$ git show HEAD~4 # the great-great-grandparent
+-------------------------------------------------
+
+Recall that merge commits may have more than one parent; by default,
+^ and ~ follow the first parent listed in the commit, but you can
+also choose:
+
+-------------------------------------------------
+$ git show HEAD^1 # show the first parent of HEAD
+$ git show HEAD^2 # show the second parent of HEAD
+-------------------------------------------------
+
+In addition to HEAD, there are several other special names for
+commits:
+
+Merges (to be discussed later), as well as operations such as
+git-reset, which change the currently checked-out commit, generally
+set ORIG_HEAD to the value HEAD had before the current operation.
+
+The git-fetch operation always stores the head of the last fetched
+branch in FETCH_HEAD. For example, if you run git fetch without
+specifying a local branch as the target of the operation
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git theirbranch
+-------------------------------------------------
+
+the fetched commits will still be available from FETCH_HEAD.
+
+When we discuss merges we'll also see the special name MERGE_HEAD,
+which refers to the other branch that we're merging in to the current
+branch.
+
+The gitlink:git-rev-parse[1] command is a low-level command that is
+occasionally useful for translating some name for a commit to the object
+name for that commit:
+
+-------------------------------------------------
+$ git rev-parse origin
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+Creating tags
+-------------
+
+We can also create a tag to refer to a particular commit; after
+running
+
+-------------------------------------------------
+$ git-tag stable-1 1b2e1d63ff
+-------------------------------------------------
+
+You can use stable-1 to refer to the commit 1b2e1d63ff.
+
+This creates a "lightweight" tag. If the tag is a tag you wish to
+share with others, and possibly sign cryptographically, then you
+should create a tag object instead; see the gitlink:git-tag[1] man
+page for details.
+
+Browsing revisions
+------------------
+
+The gitlink:git-log[1] command can show lists of commits. On its
+own, it shows all commits reachable from the parent commit; but you
+can also make more specific requests:
+
+-------------------------------------------------
+$ git log v2.5.. # commits since (not reachable from) v2.5
+$ git log test..master # commits reachable from master but not test
+$ git log master..test # ...reachable from test but not master
+$ git log master...test # ...reachable from either test or master,
+ # but not both
+$ git log --since="2 weeks ago" # commits from the last 2 weeks
+$ git log Makefile # commits which modify Makefile
+$ git log fs/ # ... which modify any file under fs/
+$ git log -S'foo()' # commits which add or remove any file data
+ # matching the string 'foo()'
+-------------------------------------------------
+
+And of course you can combine all of these; the following finds
+commits since v2.5 which touch the Makefile or any file under fs:
+
+-------------------------------------------------
+$ git log v2.5.. Makefile fs/
+-------------------------------------------------
+
+You can also ask git log to show patches:
+
+-------------------------------------------------
+$ git log -p
+-------------------------------------------------
+
+See the "--pretty" option in the gitlink:git-log[1] man page for more
+display options.
+
+Note that git log starts with the most recent commit and works
+backwards through the parents; however, since git history can contain
+multiple independent lines of development, the particular order that
+commits are listed in may be somewhat arbitrary.
+
+Generating diffs
+----------------
+
+You can generate diffs between any two versions using
+gitlink:git-diff[1]:
+
+-------------------------------------------------
+$ git diff master..test
+-------------------------------------------------
+
+Sometimes what you want instead is a set of patches:
+
+-------------------------------------------------
+$ git format-patch master..test
+-------------------------------------------------
+
+will generate a file with a patch for each commit reachable from test
+but not from master. Note that if master also has commits which are
+not reachable from test, then the combined result of these patches
+will not be the same as the diff produced by the git-diff example.
+
+Viewing old file versions
+-------------------------
+
+You can always view an old version of a file by just checking out the
+correct revision first. But sometimes it is more convenient to be
+able to view an old version of a single file without checking
+anything out; this command does that:
+
+-------------------------------------------------
+$ git show v2.5:fs/locks.c
+-------------------------------------------------
+
+Before the colon may be anything that names a commit, and after it
+may be any path to a file tracked by git.
+
+Examples
+--------
+
+Check whether two branches point at the same history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Suppose you want to check whether two branches point at the same point
+in history.
+
+-------------------------------------------------
+$ git diff origin..master
+-------------------------------------------------
+
+will tell you whether the contents of the project are the same at the
+two branches; in theory, however, it's possible that the same project
+contents could have been arrived at by two different historical
+routes. You could compare the object names:
+
+-------------------------------------------------
+$ git rev-list origin
+e05db0fd4f31dde7005f075a84f96b360d05984b
+$ git rev-list master
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+Or you could recall that the ... operator selects all commits
+contained reachable from either one reference or the other but not
+both: so
+
+-------------------------------------------------
+$ git log origin...master
+-------------------------------------------------
+
+will return no commits when the two branches are equal.
+
+Find first tagged version including a given fix
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Suppose you know that the commit e05db0fd fixed a certain problem.
+You'd like to find the earliest tagged release that contains that
+fix.
+
+Of course, there may be more than one answer--if the history branched
+after commit e05db0fd, then there could be multiple "earliest" tagged
+releases.
+
+You could just visually inspect the commits since e05db0fd:
+
+-------------------------------------------------
+$ gitk e05db0fd..
+-------------------------------------------------
+
+Or you can use gitlink:git-name-rev[1], which will give the commit a
+name based on any tag it finds pointing to one of the commit's
+descendants:
+
+-------------------------------------------------
+$ git name-rev e05db0fd
+e05db0fd tags/v1.5.0-rc1^0~23
+-------------------------------------------------
+
+The gitlink:git-describe[1] command does the opposite, naming the
+revision using a tag on which the given commit is based:
+
+-------------------------------------------------
+$ git describe e05db0fd
+v1.5.0-rc0-ge05db0f
+-------------------------------------------------
+
+but that may sometimes help you guess which tags might come after the
+given commit.
+
+If you just want to verify whether a given tagged version contains a
+given commit, you could use gitlink:git-merge-base[1]:
+
+-------------------------------------------------
+$ git merge-base e05db0fd v1.5.0-rc1
+e05db0fd4f31dde7005f075a84f96b360d05984b
+-------------------------------------------------
+
+The merge-base command finds a common ancestor of the given commits,
+and always returns one or the other in the case where one is a
+descendant of the other; so the above output shows that e05db0fd
+actually is an ancestor of v1.5.0-rc1.
+
+Alternatively, note that
+
+-------------------------------------------------
+$ git log v1.5.0-rc1..e05db0fd
+-------------------------------------------------
+
+will produce empty output if and only if v1.5.0-rc1 includes e05db0fd,
+because it outputs only commits that are not reachable from v1.5.0-rc1.
+
+As yet another alternative, the gitlink:git-show-branch[1] command lists
+the commits reachable from its arguments with a display on the left-hand
+side that indicates which arguments that commit is reachable from. So,
+you can run something like
+
+-------------------------------------------------
+$ git show-branch e05db0fd v1.5.0-rc0 v1.5.0-rc1 v1.5.0-rc2
+! [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if
+available
+ ! [v1.5.0-rc0] GIT v1.5.0 preview
+ ! [v1.5.0-rc1] GIT v1.5.0-rc1
+ ! [v1.5.0-rc2] GIT v1.5.0-rc2
+...
+-------------------------------------------------
+
+then search for a line that looks like
+
+-------------------------------------------------
++ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if
+available
+-------------------------------------------------
+
+Which shows that e05db0fd is reachable from itself, from v1.5.0-rc1, and
+from v1.5.0-rc2, but not from v1.5.0-rc0.
+
+
+Developing with git
+===================
+
+Telling git your name
+---------------------
+
+Before creating any commits, you should introduce yourself to git. The
+easiest way to do so is:
+
+------------------------------------------------
+$ cat >~/.gitconfig <<\EOF
+[user]
+ name = Your Name Comes Here
+ email = you@yourdomain.example.com
+EOF
+------------------------------------------------
+
+(See the "CONFIGURATION FILE" section of gitlink:git-config[1] for
+details on the configuration file.)
+
+
+Creating a new repository
+-------------------------
+
+Creating a new repository from scratch is very easy:
+
+-------------------------------------------------
+$ mkdir project
+$ cd project
+$ git init
+-------------------------------------------------
+
+If you have some initial content (say, a tarball):
+
+-------------------------------------------------
+$ tar -xzvf project.tar.gz
+$ cd project
+$ git init
+$ git add . # include everything below ./ in the first commit:
+$ git commit
+-------------------------------------------------
+
+[[how-to-make-a-commit]]
+how to make a commit
+--------------------
+
+Creating a new commit takes three steps:
+
+ 1. Making some changes to the working directory using your
+ favorite editor.
+ 2. Telling git about your changes.
+ 3. Creating the commit using the content you told git about
+ in step 2.
+
+In practice, you can interleave and repeat steps 1 and 2 as many
+times as you want: in order to keep track of what you want committed
+at step 3, git maintains a snapshot of the tree's contents in a
+special staging area called "the index."
+
+At the beginning, the content of the index will be identical to
+that of the HEAD. The command "git diff --cached", which shows
+the difference between the HEAD and the index, should therefore
+produce no output at that point.
+
+Modifying the index is easy:
+
+To update the index with the new contents of a modified file, use
+
+-------------------------------------------------
+$ git add path/to/file
+-------------------------------------------------
+
+To add the contents of a new file to the index, use
+
+-------------------------------------------------
+$ git add path/to/file
+-------------------------------------------------
+
+To remove a file from the index and from the working tree,
+
+-------------------------------------------------
+$ git rm path/to/file
+-------------------------------------------------
+
+After each step you can verify that
+
+-------------------------------------------------
+$ git diff --cached
+-------------------------------------------------
+
+always shows the difference between the HEAD and the index file--this
+is what you'd commit if you created the commit now--and that
+
+-------------------------------------------------
+$ 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
+to the index; further changes to the same file will be ignored unless
+you run git-add on the file again.
+
+When you're ready, just run
+
+-------------------------------------------------
+$ git commit
+-------------------------------------------------
+
+and git will prompt you for a commit message and then create the new
+commit. Check to make sure it looks like what you expected with
+
+-------------------------------------------------
+$ git show
+-------------------------------------------------
+
+As a special shortcut,
+
+-------------------------------------------------
+$ git commit -a
+-------------------------------------------------
+
+will update the index with any files that you've modified or removed
+and create a commit, all in one step.
+
+A number of commands are useful for keeping track of what you're
+about to commit:
+
+-------------------------------------------------
+$ git diff --cached # difference between HEAD and the index; what
+ # would be commited if you ran "commit" now.
+$ git diff # difference between the index file and your
+ # working directory; changes that would not
+ # be included if you ran "commit" now.
+$ git status # a brief per-file summary of the above.
+-------------------------------------------------
+
+creating good commit messages
+-----------------------------
+
+Though not required, it's a good idea to begin the commit message
+with a single short (less than 50 character) line summarizing the
+change, followed by a blank line and then a more thorough
+description. Tools that turn commits into email, for example, use
+the first line on the Subject line and the rest of the commit in the
+body.
+
+how to merge
+------------
+
+You can rejoin two diverging branches of development using
+gitlink:git-merge[1]:
+
+-------------------------------------------------
+$ git merge branchname
+-------------------------------------------------
+
+merges the development in the branch "branchname" into the current
+branch. If there are conflicts--for example, if the same file is
+modified in two different ways in the remote branch and the local
+branch--then you are warned; the output may look something like this:
+
+-------------------------------------------------
+$ git pull . next
+Trying really trivial in-index merge...
+fatal: Merge requires file-level merging
+Nope.
+Merging HEAD with 77976da35a11db4580b80ae27e8d65caf5208086
+Merging:
+15e2162 world
+77976da goodbye
+found 1 common ancestor(s):
+d122ed4 initial
+Auto-merging file.txt
+CONFLICT (content): Merge conflict in file.txt
+Automatic merge failed; fix conflicts and then commit the result.
+-------------------------------------------------
+
+Conflict markers are left in the problematic files, and after
+you resolve the conflicts manually, you can update the index
+with the contents and run git commit, as you normally would when
+creating a new file.
+
+If you examine the resulting commit using gitk, you will see that it
+has two parents, one pointing to the top of the current branch, and
+one to the top of the other branch.
+
+In more detail:
+
+[[resolving-a-merge]]
+Resolving a merge
+-----------------
+
+When a merge isn't resolved automatically, git leaves the index and
+the working tree in a special state that gives you all the
+information you need to help resolve the merge.
+
+Files with conflicts are marked specially in the index, so until you
+resolve the problem and update the index, git commit will fail:
+
+-------------------------------------------------
+$ git commit
+file.txt: needs merge
+-------------------------------------------------
+
+Also, git status will list those files as "unmerged".
+
+All of the changes that git was able to merge automatically are
+already added to the index file, so gitlink:git-diff[1] shows only
+the conflicts. Also, it uses a somewhat unusual syntax:
+
+-------------------------------------------------
+$ git diff
+diff --cc file.txt
+index 802992c,2b60207..0000000
+--- a/file.txt
++++ b/file.txt
+@@@ -1,1 -1,1 +1,5 @@@
+++<<<<<<< HEAD:file.txt
+ +Hello world
+++=======
++ Goodbye
+++>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
+-------------------------------------------------
+
+Recall that the commit which will be commited after we resolve this
+conflict will have two parents instead of the usual one: one parent
+will be HEAD, the tip of the current branch; the other will be the
+tip of the other branch, which is stored temporarily in MERGE_HEAD.
+
+The diff above shows the differences between the working-tree version
+of file.txt and two previous version: one version from HEAD, and one
+from MERGE_HEAD. So instead of preceding each line by a single "+"
+or "-", it now uses two columns: the first column is used for
+differences between the first parent and the working directory copy,
+and the second for differences between the second parent and the
+working directory copy. Thus after resolving the conflict in the
+obvious way, the diff will look like:
+
+-------------------------------------------------
+$ git diff
+diff --cc file.txt
+index 802992c,2b60207..0000000
+--- a/file.txt
++++ b/file.txt
+@@@ -1,1 -1,1 +1,1 @@@
+- Hello world
+ -Goodbye
+++Goodbye world
+-------------------------------------------------
+
+This shows that our resolved version deleted "Hello world" from the
+first parent, deleted "Goodbye" from the second parent, and added
+"Goodbye world", which was previously absent from both.
+
+The gitlink:git-log[1] command also provides special help for merges:
+
+-------------------------------------------------
+$ git log --merge
+-------------------------------------------------
+
+This will list all commits which exist only on HEAD or on MERGE_HEAD,
+and which touch an unmerged file.
+
+We can now add the resolved version to the index and commit:
+
+-------------------------------------------------
+$ git add file.txt
+$ git commit
+-------------------------------------------------
+
+Note that the commit message will already be filled in for you with
+some information about the merge. Normally you can just use this
+default message unchanged, but you may add additional commentary of
+your own if desired.
+
+[[undoing-a-merge]]
+undoing a merge
+---------------
+
+If you get stuck and decide to just give up and throw the whole mess
+away, you can always return to the pre-merge state with
+
+-------------------------------------------------
+$ git reset --hard HEAD
+-------------------------------------------------
+
+Or, if you've already commited the merge that you want to throw away,
+
+-------------------------------------------------
+$ git reset --hard HEAD^
+-------------------------------------------------
+
+However, this last command can be dangerous in some cases--never
+throw away a commit you have already committed if that commit may
+itself have been merged into another branch, as doing so may confuse
+further merges.
+
+Fast-forward merges
+-------------------
+
+There is one special case not mentioned above, which is treated
+differently. Normally, a merge results in a merge commit, with two
+parents, one pointing at each of the two lines of development that
+were merged.
+
+However, if one of the two lines of development is completely
+contained within the other--so every commit present in the one is
+already contained in the other--then git just performs a
+<<fast-forwards,fast forward>>; the head of the current branch is
+moved forward to point at the head of the merged-in branch, without
+any new commits being created.
+
+Fixing mistakes
+---------------
+
+If you've messed up the working tree, but haven't yet committed your
+mistake, you can return the entire working tree to the last committed
+state with
+
+-------------------------------------------------
+$ git reset --hard HEAD
+-------------------------------------------------
+
+If you make a commit that you later wish you hadn't, there are two
+fundamentally different ways to fix the problem:
+
+ 1. You can create a new commit that undoes whatever was done
+ by the previous commit. This is the correct thing if your
+ mistake has already been made public.
+
+ 2. You can go back and modify the old commit. You should
+ never do this if you have already made the history public;
+ git does not normally expect the "history" of a project to
+ change, and cannot correctly perform repeated merges from
+ a branch that has had its history changed.
+
+Fixing a mistake with a new commit
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Creating a new commit that reverts an earlier change is very easy;
+just pass the gitlink:git-revert[1] command a reference to the bad
+commit; for example, to revert the most recent commit:
+
+-------------------------------------------------
+$ git revert HEAD
+-------------------------------------------------
+
+This will create a new commit which undoes the change in HEAD. You
+will be given a chance to edit the commit message for the new commit.
+
+You can also revert an earlier change, for example, the next-to-last:
+
+-------------------------------------------------
+$ git revert HEAD^
+-------------------------------------------------
+
+In this case git will attempt to undo the old change while leaving
+intact any changes made since then. If more recent changes overlap
+with the changes to be reverted, then you will be asked to fix
+conflicts manually, just as in the case of <<resolving-a-merge,
+resolving a merge>>.
+
+Fixing a mistake by editing history
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the problematic commit is the most recent commit, and you have not
+yet made that commit public, then you may just
+<<undoing-a-merge,destroy it using git-reset>>.
+
+Alternatively, you
+can edit the working directory and update the index to fix your
+mistake, just as if you were going to <<how-to-make-a-commit,create a
+new commit>>, then run
+
+-------------------------------------------------
+$ git commit --amend
+-------------------------------------------------
+
+which will replace the old commit by a new commit incorporating your
+changes, giving you a chance to edit the old commit message first.
+
+Again, you should never do this to a commit that may already have
+been merged into another branch; use gitlink:git-revert[1] instead in
+that case.
+
+It is also possible to edit commits further back in the history, but
+this is an advanced topic to be left for
+<<cleaning-up-history,another chapter>>.
+
+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
+gitlink: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
+
+-------------------------------------------------
+$ git checkout HEAD^ path/to/file
+-------------------------------------------------
+
+replaces path/to/file by the contents it had in the commit HEAD^, and
+also updates the index to match. It does not change branches.
+
+If you just want to look at an old version of the file, without
+modifying the working directory, you can do that with
+gitlink:git-show[1]:
+
+-------------------------------------------------
+$ git show HEAD^ path/to/file
+-------------------------------------------------
+
+which will display the given version of the file.
+
+Ensuring good performance
+-------------------------
+
+On large repositories, git depends on compression to keep the history
+information from taking up to much space on disk or in memory.
+
+This compression is not performed automatically. Therefore you
+should occasionally run gitlink:git-gc[1]:
+
+-------------------------------------------------
+$ git gc
+-------------------------------------------------
+
+to recompress the archive. This can be very time-consuming, so
+you may prefer to run git-gc when you are not doing other work.
+
+Ensuring reliability
+--------------------
+
+Checking the repository for corruption
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The gitlink:git-fsck[1] command runs a number of self-consistency checks
+on the repository, and reports on any problems. This may take some
+time. The most common warning by far is about "dangling" objects:
+
+-------------------------------------------------
+$ git fsck
+dangling commit 7281251ddd2a61e38657c827739c57015671a6b3
+dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63
+dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5
+dangling blob 218761f9d90712d37a9c5e36f406f92202db07eb
+dangling commit bf093535a34a4d35731aa2bd90fe6b176302f14f
+dangling commit 8e4bec7f2ddaa268bef999853c25755452100f8e
+dangling tree d50bb86186bf27b681d25af89d3b5b68382e4085
+dangling tree b24c2473f1fd3d91352a624795be026d64c8841f
+...
+-------------------------------------------------
+
+Dangling objects are objects that are harmless, but also unnecessary;
+you can remove them at any time with gitlink:git-prune[1] or the --prune
+option to gitlink: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.
+
+For more about dangling objects, see <<dangling-objects>>.
+
+
+Recovering lost changes
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Reflogs
+^^^^^^^
+
+Say you modify a branch with gitlink:git-reset[1] --hard, and then
+realize that the branch was the only reference you had to that point in
+history.
+
+Fortunately, git also keeps a log, called a "reflog", of all the
+previous values of each branch. So in this case you can still find the
+old history using, for example,
+
+-------------------------------------------------
+$ git log master@{1}
+-------------------------------------------------
+
+This lists the commits reachable from the previous version of the head.
+This syntax can be used to with any git command that accepts a commit,
+not just with git log. Some other examples:
+
+-------------------------------------------------
+$ git show master@{2} # See where the branch pointed 2,
+$ git show master@{3} # 3, ... changes ago.
+$ gitk master@{yesterday} # See where it pointed yesterday,
+$ gitk master@{"1 week ago"} # ... or last week
+-------------------------------------------------
+
+The reflogs are kept by default for 30 days, after which they may be
+pruned. See gitlink:git-reflog[1] and gitlink:git-gc[1] to learn
+how to control this pruning, and see the "SPECIFYING REVISIONS"
+section of gitlink:git-rev-parse[1] for details.
+
+Note that the reflog history is very different from normal git history.
+While normal history is shared by every repository that works on the
+same project, the reflog history is not shared: it tells you only about
+how the branches in your local repository have changed over time.
+
+Examining dangling objects
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+In some situations the reflog may not be able to save you. For
+example, suppose you delete a branch, then realize you need the history
+it pointed you. The reflog is also deleted; however, if you have not
+yet pruned the repository, then you may still be able to find
+the lost commits; run git-fsck and watch for output that mentions
+"dangling commits":
+
+-------------------------------------------------
+$ git fsck
+dangling commit 7281251ddd2a61e38657c827739c57015671a6b3
+dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63
+dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5
+...
+-------------------------------------------------
+
+You can examine
+one of those dangling commits with, for example,
+
+------------------------------------------------
+$ gitk 7281251ddd --not --all
+------------------------------------------------
+
+which does what it sounds like: it says that you want to see the commit
+history that is described by the dangling commit(s), but not the
+history that is described by all your existing branches and tags. Thus
+you get exactly the history reachable from that commit that is lost.
+(And notice that it might not be just one commit: we only report the
+"tip of the line" as being dangling, but there might be a whole deep
+and complex commit history that was gotten dropped.)
+
+If you decide you want the history back, you can always create a new
+reference pointing to it, for example, a new branch:
+
+------------------------------------------------
+$ git branch recovered-branch 7281251ddd
+------------------------------------------------
+
+
+Sharing development with others
+===============================
+
+[[getting-updates-with-git-pull]]
+Getting updates with git pull
+-----------------------------
+
+After you clone a repository and make a few changes of your own, you
+may wish to check the original repository for updates and merge them
+into your own work.
+
+We have already seen <<Updating-a-repository-with-git-fetch,how to
+keep remote tracking branches up to date>> with gitlink:git-fetch[1],
+and how to merge two branches. So you can merge in changes from the
+original repository's master branch with:
+
+-------------------------------------------------
+$ git fetch
+$ git merge origin/master
+-------------------------------------------------
+
+However, the gitlink:git-pull[1] command provides a way to do this in
+one step:
+
+-------------------------------------------------
+$ git pull origin master
+-------------------------------------------------
+
+In fact, "origin" is normally the default repository to pull from,
+and the default branch is normally the HEAD of the remote repository,
+so often you can accomplish the above with just
+
+-------------------------------------------------
+$ git pull
+-------------------------------------------------
+
+See the descriptions of the branch.<name>.remote and
+branch.<name>.merge options in gitlink:git-config[1] to learn
+how to control these defaults depending on the current branch.
+
+In addition to saving you keystrokes, "git pull" also helps you by
+producing a default commit message documenting the branch and
+repository that you pulled from.
+
+(But note that no such commit will be created in the case of a
+<<fast-forwards,fast forward>>; instead, your branch will just be
+updated to point to the latest commit from the upstream branch).
+
+The git-pull command can also be given "." as the "remote" repository,
+in which case it just merges in a branch from the current repository; so
+the commands
+
+-------------------------------------------------
+$ git pull . branch
+$ git merge branch
+-------------------------------------------------
+
+are roughly equivalent. The former is actually very commonly used.
+
+Submitting patches to a project
+-------------------------------
+
+If you just have a few changes, the simplest way to submit them may
+just be to send them as patches in email:
+
+First, use gitlink:git-format-patch[1]; for example:
+
+-------------------------------------------------
+$ git format-patch origin
+-------------------------------------------------
+
+will produce a numbered series of files in the current directory, one
+for each patch in the current branch but not in origin/HEAD.
+
+You can then import these into your mail client and send them by
+hand. However, if you have a lot to send at once, you may prefer to
+use the gitlink:git-send-email[1] script to automate the process.
+Consult the mailing list for your project first to determine how they
+prefer such patches be handled.
+
+Importing patches to a project
+------------------------------
+
+Git also provides a tool called gitlink:git-am[1] (am stands for
+"apply mailbox"), for importing such an emailed series of patches.
+Just save all of the patch-containing messages, in order, into a
+single mailbox file, say "patches.mbox", then run
+
+-------------------------------------------------
+$ git am -3 patches.mbox
+-------------------------------------------------
+
+Git will apply each patch in order; if any conflicts are found, it
+will stop, and you can fix the conflicts as described in
+"<<resolving-a-merge,Resolving a merge>>". (The "-3" option tells
+git to perform a merge; if you would prefer it just to abort and
+leave your tree and index untouched, you may omit that option.)
+
+Once the index is updated with the results of the conflict
+resolution, instead of creating a new commit, just run
+
+-------------------------------------------------
+$ git am --resolved
+-------------------------------------------------
+
+and git will create the commit for you and continue applying the
+remaining patches from the mailbox.
+
+The final result will be a series of commits, one for each patch in
+the original mailbox, with authorship and commit log message each
+taken from the message containing each patch.
+
+[[setting-up-a-public-repository]]
+Setting up a public repository
+------------------------------
+
+Another way to submit changes to a project is to simply tell the
+maintainer of that project to pull from your repository, exactly as
+you did in the section "<<getting-updates-with-git-pull, Getting
+updates with git pull>>".
+
+If you and maintainer both have accounts on the same machine, then
+then you can just pull changes from each other's repositories
+directly; note that all of the command (gitlink:git-clone[1],
+git-fetch[1], git-pull[1], etc.) which accept a URL as an argument
+will also accept a local file patch; so, for example, you can
+use
+
+-------------------------------------------------
+$ git clone /path/to/repository
+$ git pull /path/to/other/repository
+-------------------------------------------------
+
+If this sort of setup is inconvenient or impossible, another (more
+common) option is to set up a public repository on a public server.
+This also allows you to cleanly separate private work in progress
+from publicly visible work.
+
+You will continue to do your day-to-day work in your personal
+repository, but periodically "push" changes from your personal
+repository into your public repository, allowing other developers to
+pull from that repository. So the flow of changes, in a situation
+where there is one other developer with a public repository, looks
+like this:
+
+ you push
+ your personal repo ------------------> your public repo
+ ^ |
+ | |
+ | you pull | they pull
+ | |
+ | |
+ | they push V
+ their public repo <------------------- their repo
+
+Now, assume your personal repository is in the directory ~/proj. We
+first create a new clone of the repository:
+
+-------------------------------------------------
+$ git clone --bare proj-clone.git
+-------------------------------------------------
+
+The resulting directory proj-clone.git will contains a "bare" git
+repository--it is just the contents of the ".git" directory, without
+a checked-out copy of a working directory.
+
+Next, copy proj-clone.git to the server where you plan to host the
+public repository. You can use scp, rsync, or whatever is most
+convenient.
+
+If somebody else maintains the public server, they may already have
+set up a git service for you, and you may skip to the section
+"<<pushing-changes-to-a-public-repository,Pushing changes to a public
+repository>>", below.
+
+Otherwise, the following sections explain how to export your newly
+created public repository:
+
+[[exporting-via-http]]
+Exporting a git repository via http
+-----------------------------------
+
+The git protocol gives better performance and reliability, but on a
+host with a web server set up, http exports may be simpler to set up.
+
+All you need to do is place the newly created bare git repository in
+a directory that is exported by the web server, and make some
+adjustments to give web clients some extra information they need:
+
+-------------------------------------------------
+$ mv proj.git /home/you/public_html/proj.git
+$ cd proj.git
+$ git update-server-info
+$ chmod a+x hooks/post-update
+-------------------------------------------------
+
+(For an explanation of the last two lines, see
+gitlink:git-update-server-info[1], and the documentation
+link:hooks.txt[Hooks used by git].)
+
+Advertise the url of proj.git. Anybody else should then be able to
+clone or pull from that url, for example with a commandline like:
+
+-------------------------------------------------
+$ git clone http://yourserver.com/~you/proj.git
+-------------------------------------------------
+
+(See also
+link:howto/setup-git-server-over-http.txt[setup-git-server-over-http]
+for a slightly more sophisticated setup using WebDAV which also
+allows pushing over http.)
+
+[[exporting-via-git]]
+Exporting a git repository via the git protocol
+-----------------------------------------------
+
+This is the preferred method.
+
+For now, we refer you to the gitlink:git-daemon[1] man page for
+instructions. (See especially the examples section.)
+
+[[pushing-changes-to-a-public-repository]]
+Pushing changes to a public repository
+--------------------------------------
+
+Note that the two techniques outline above (exporting via
+<<exporting-via-http,http>> or <<exporting-via-git,git>>) allow other
+maintainers to fetch your latest changes, but they do not allow write
+access, which you will need to update the public repository with the
+latest changes created in your private repository.
+
+The simplest way to do this is using gitlink:git-push[1] and ssh; to
+update the remote branch named "master" with the latest state of your
+branch named "master", run
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git master:master
+-------------------------------------------------
+
+or just
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git master
+-------------------------------------------------
+
+As with git-fetch, git-push will complain if this does not result in
+a <<fast-forwards,fast forward>>. Normally this is a sign of
+something wrong. However, if you are sure you know what you're
+doing, you may force git-push to perform the update anyway by
+proceeding the branch name by a plus sign:
+
+-------------------------------------------------
+$ git push ssh://yourserver.com/~you/proj.git +master
+-------------------------------------------------
+
+As with git-fetch, you may also set up configuration options to
+save typing; so, for example, after
+
+-------------------------------------------------
+$ cat >.git/config <<EOF
+[remote "public-repo"]
+ url = ssh://yourserver.com/~you/proj.git
+EOF
+-------------------------------------------------
+
+you should be able to perform the above push with just
+
+-------------------------------------------------
+$ git push public-repo master
+-------------------------------------------------
+
+See the explanations of the remote.<name>.url, branch.<name>.remote,
+and remote.<name>.push options in gitlink:git-config[1] for
+details.
+
+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.txt[git for CVS users] for instructions on how to
+set this up.
+
+Allow web browsing of a repository
+----------------------------------
+
+The gitweb cgi script provides users an easy way to browse your
+project's files and history without having to install git; see the file
+gitweb/README in the git source tree for instructions on setting it up.
+
+Examples
+--------
+
+TODO: topic branches, typical roles as in everyday.txt, ?
+
+
+[[cleaning-up-history]]
+Rewriting history and maintaining patch series
+==============================================
+
+Normally commits are only added to a project, never taken away or
+replaced. Git is designed with this assumption, and violating it will
+cause git's merge machinery (for example) to do the wrong thing.
+
+However, there is a situation in which it can be useful to violate this
+assumption.
+
+Creating the perfect patch series
+---------------------------------
+
+Suppose you are a contributor to a large project, and you want to add a
+complicated feature, and to present it to the other developers in a way
+that makes it easy for them to read your changes, verify that they are
+correct, and understand why you made each change.
+
+If you present all of your changes as a single patch (or commit), they
+may find it is too much to digest all at once.
+
+If you present them with the entire history of your work, complete with
+mistakes, corrections, and dead ends, they may be overwhelmed.
+
+So the ideal is usually to produce a series of patches such that:
+
+ 1. Each patch can be applied in order.
+
+ 2. Each patch includes a single logical change, together with a
+ message explaining the change.
+
+ 3. No patch introduces a regression: after applying any initial
+ part of the series, the resulting project still compiles and
+ works, and has no bugs that it didn't have before.
+
+ 4. The complete series produces the same end result as your own
+ (probably much messier!) development process did.
+
+We will introduce some tools that can help you do this, explain how to
+use them, and then explain some of the problems that can arise because
+you are rewriting history.
+
+Keeping a patch series up to date using git-rebase
+--------------------------------------------------
+
+Suppose you have a series of commits in a branch "mywork", which
+originally branched off from "origin".
+
+Suppose you create a branch "mywork" on a remote-tracking branch
+"origin", and created some commits on top of it:
+
+-------------------------------------------------
+$ git checkout -b mywork origin
+$ vi file.txt
+$ git commit
+$ vi otherfile.txt
+$ git commit
+...
+-------------------------------------------------
+
+You have performed no merges into mywork, so it is just a simple linear
+sequence of patches on top of "origin":
+
+
+ o--o--o <-- origin
+ \
+ o--o--o <-- mywork
+
+Some more interesting work has been done in the upstream project, and
+"origin" has advanced:
+
+ o--o--O--o--o--o <-- origin
+ \
+ a--b--c <-- mywork
+
+At this point, you could use "pull" to merge your changes back in;
+the result would create a new merge commit, like this:
+
+
+ o--o--O--o--o--o <-- origin
+ \ \
+ a--b--c--m <-- mywork
+
+However, if you prefer to keep the history in mywork a simple series of
+commits without any merges, you may instead choose to use
+gitlink:git-rebase[1]:
+
+-------------------------------------------------
+$ git checkout mywork
+$ 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
+point at the latest version of origin, then apply each of the saved
+patches to the new mywork. The result will look like:
+
+
+ o--o--O--o--o--o <-- origin
+ \
+ a'--b'--c' <-- mywork
+
+In the process, it may discover conflicts. In that case it will stop
+and allow you to fix the conflicts; after fixing conflicts, use "git
+add" to update the index with those contents, and then, instead of
+running git-commit, just run
+
+-------------------------------------------------
+$ git rebase --continue
+-------------------------------------------------
+
+and git will continue applying the rest of the patches.
+
+At any point you may use the --abort option to abort this process and
+return mywork to the state it had before you started the rebase:
+
+-------------------------------------------------
+$ git rebase --abort
+-------------------------------------------------
+
+Reordering or selecting from a patch series
+-------------------------------------------
+
+Given one existing commit, the gitlink:git-cherry-pick[1] command
+allows you to apply the change introduced by that commit and create a
+new commit that records it. So, for example, if "mywork" points to a
+series of patches on top of "origin", you might do something like:
+
+-------------------------------------------------
+$ git checkout -b mywork-new origin
+$ gitk origin..mywork &
+-------------------------------------------------
+
+And browse through the list of patches in the mywork branch using gitk,
+applying them (possibly in a different order) to mywork-new using
+cherry-pick, and possibly modifying them as you go using commit
+--amend.
+
+Another technique is to use git-format-patch to create a series of
+patches, then reset the state to before the patches:
+
+-------------------------------------------------
+$ git format-patch origin
+$ git reset --hard origin
+-------------------------------------------------
+
+Then modify, reorder, or eliminate patches as preferred before applying
+them again with gitlink:git-am[1].
+
+Other tools
+-----------
+
+There are numerous other tools, such as stgit, which exist for the
+purpose of maintaining a patch series. These are out of the scope of
+this manual.
+
+Problems with rewriting history
+-------------------------------
+
+The primary problem with rewriting the history of a branch has to do
+with merging. Suppose somebody fetches your branch and merges it into
+their branch, with a result something like this:
+
+ o--o--O--o--o--o <-- origin
+ \ \
+ t--t--t--m <-- their branch:
+
+Then suppose you modify the last three commits:
+
+ o--o--o <-- new head of origin
+ /
+ o--o--O--o--o--o <-- old head of origin
+
+If we examined all this history together in one repository, it will
+look like:
+
+ o--o--o <-- new head of origin
+ /
+ o--o--O--o--o--o <-- old head of origin
+ \ \
+ t--t--t--m <-- their branch:
+
+Git has no way of knowing that the new head is an updated version of
+the old head; it treats this situation exactly the same as it would if
+two developers had independently done the work on the old and new heads
+in parallel. At this point, if someone attempts to merge the new head
+in to their branch, git will attempt to merge together the two (old and
+new) lines of development, instead of trying to replace the old by the
+new. The results are likely to be unexpected.
+
+You may still choose to publish branches whose history is rewritten,
+and it may be useful for others to be able to fetch those branches in
+order to examine or test them, but they should not attempt to pull such
+branches into their own work.
+
+For true distributed development that supports proper merging,
+published branches should never be rewritten.
+
+Advanced branch management
+==========================
+
+Fetching individual branches
+----------------------------
+
+Instead of using gitlink:git-remote[1], you can also choose just
+to update one branch at a time, and to store it locally under an
+arbitrary name:
+
+-------------------------------------------------
+$ git fetch origin todo:my-todo-work
+-------------------------------------------------
+
+The first argument, "origin", just tells git to fetch from the
+repository you originally cloned from. The second argument tells git
+to fetch the branch named "todo" from the remote repository, and to
+store it locally under the name refs/heads/my-todo-work.
+
+You can also fetch branches from other repositories; so
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:example-master
+-------------------------------------------------
+
+will create a new branch named "example-master" and store in it the
+branch named "master" from the repository at the given URL. If you
+already have a branch named example-master, it will attempt to
+"fast-forward" to the commit given by example.com's master branch. So
+next we explain what a fast-forward is:
+
+[[fast-forwards]]
+Understanding git history: 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
+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 forward".
+
+A fast forward looks something like this:
+
+ o--o--o--o <-- old head of the branch
+ \
+ o--o--o <-- new head of the branch
+
+
+In some cases it is possible that the new head will *not* actually be
+a descendant of the old head. For example, the developer may have
+realized she made a serious mistake, and decided to backtrack,
+resulting in a situation like:
+
+ o--o--o--o--a--b <-- old head of the branch
+ \
+ o--o--o <-- new head of the branch
+
+
+
+In this case, "git fetch" will fail, and print out a warning.
+
+In that case, you can still force git to update to the new head, as
+described in the following section. However, note that in the
+situation above this may mean losing the commits labeled "a" and "b",
+unless you've already created a reference of your own pointing to
+them.
+
+Forcing git fetch to do non-fast-forward updates
+------------------------------------------------
+
+If git fetch fails because the new head of a branch is not a
+descendant of the old head, you may force the update with:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git +master:refs/remotes/example/master
+-------------------------------------------------
+
+Note the addition of the "+" sign. Be aware that commits which the
+old version of example/master pointed at may be lost, as we saw in
+the previous section.
+
+Configuring remote branches
+---------------------------
+
+We saw above that "origin" is just a shortcut to refer to the
+repository which you originally cloned from. This information is
+stored in git configuration variables, which you can see using
+gitlink:git-config[1]:
+
+-------------------------------------------------
+$ git config -l
+core.repositoryformatversion=0
+core.filemode=true
+core.logallrefupdates=true
+remote.origin.url=git://git.kernel.org/pub/scm/git/git.git
+remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
+branch.master.remote=origin
+branch.master.merge=refs/heads/master
+-------------------------------------------------
+
+If there are other repositories that you also use frequently, you can
+create similar configuration options to save typing; for example,
+after
+
+-------------------------------------------------
+$ git config remote.example.url git://example.com/proj.git
+-------------------------------------------------
+
+then the following two commands will do the same thing:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:refs/remotes/example/master
+$ git fetch example master:refs/remotes/example/master
+-------------------------------------------------
+
+Even better, if you add one more option:
+
+-------------------------------------------------
+$ git config remote.example.fetch master:refs/remotes/example/master
+-------------------------------------------------
+
+then the following commands will all do the same thing:
+
+-------------------------------------------------
+$ git fetch git://example.com/proj.git master:ref/remotes/example/master
+$ git fetch example master:ref/remotes/example/master
+$ git fetch example example/master
+$ git fetch example
+-------------------------------------------------
+
+You can also add a "+" to force the update each time:
+
+-------------------------------------------------
+$ 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.
+
+Also note that all of the above configuration can be performed by
+directly editing the file .git/config instead of using
+gitlink:git-config[1].
+
+See gitlink:git-config[1] for more details on the configuration
+options mentioned above.
+
+
+Git internals
+=============
+
+There are two object abstractions: the "object database", and the
+"current directory cache" aka "index".
+
+The Object Database
+-------------------
+
+The object database is literally just a content-addressable collection
+of objects. All objects are named by their content, which is
+approximated by the SHA1 hash of the object itself. Objects may refer
+to other objects (by referencing their SHA1 hash), and so you can
+build up a hierarchy of objects.
+
+All objects have a statically determined "type" aka "tag", which is
+determined at object creation time, and which identifies the format of
+the object (i.e. how it is used, and how it can refer to other
+objects). There are currently four different object types: "blob",
+"tree", "commit" and "tag".
+
+A "blob" object cannot refer to any other object, and is, like the type
+implies, a pure storage object containing some user data. It is used to
+actually store the file data, i.e. a blob object is associated with some
+particular version of some file.
+
+A "tree" object is an object that ties one or more "blob" objects into a
+directory structure. In addition, a tree object can refer to other tree
+objects, thus creating a directory hierarchy.
+
+A "commit" object ties such directory hierarchies together into
+a DAG of revisions - each "commit" is associated with exactly one tree
+(the directory hierarchy at the time of the commit). In addition, a
+"commit" refers to one or more "parent" commit objects that describe the
+history of how we arrived at that directory hierarchy.
+
+As a special case, a commit object with no parents is called the "root"
+object, and is the point of an initial project commit. Each project
+must have at least one root, and while you can tie several different
+root objects together into one project by creating a commit object which
+has two or more separate roots as its ultimate parents, that's probably
+just going to confuse people. So aim for the notion of "one root object
+per project", even if git itself does not enforce that.
+
+A "tag" object symbolically identifies and can be used to sign other
+objects. It contains the identifier and type of another object, a
+symbolic name (of course!) and, optionally, a signature.
+
+Regardless of object type, all objects share the following
+characteristics: they are all deflated with zlib, and have a header
+that not only specifies their type, but also provides size information
+about the data in the object. It's worth noting that the SHA1 hash
+that is used to name the object is the hash of the original data
+plus this header, so `sha1sum` 'file' does not match the object name
+for 'file'.
+(Historical note: in the dawn of the age of git the hash
+was the sha1 of the 'compressed' object.)
+
+As a result, the general consistency of an object can always be tested
+independently of the contents or the type of the object: all objects can
+be validated by verifying that (a) their hashes match the content of the
+file and (b) the object successfully inflates to a stream of bytes that
+forms a sequence of <ascii type without space> + <space> + <ascii decimal
+size> + <byte\0> + <binary object data>.
+
+The structured objects can further have their structure and
+connectivity to other objects verified. This is generally done with
+the `git-fsck` program, which generates a full dependency graph
+of all objects, and verifies their internal consistency (in addition
+to just verifying their superficial consistency through the hash).
+
+The object types in some more detail:
+
+Blob Object
+-----------
+
+A "blob" object is nothing but a binary blob of data, and doesn't
+refer to anything else. There is no signature or any other
+verification of the data, so while the object is consistent (it 'is'
+indexed by its sha1 hash, so the data itself is certainly correct), it
+has absolutely no other attributes. No name associations, no
+permissions. It is purely a blob of data (i.e. normally "file
+contents").
+
+In particular, since the blob is entirely defined by its data, if two
+files in a directory tree (or in multiple different versions of the
+repository) have the same contents, they will share the same blob
+object. The object is totally independent of its location in the
+directory tree, and renaming a file does not change the object that
+file is associated with in any way.
+
+A blob is typically created when gitlink:git-update-index[1]
+is run, and its data can be accessed by gitlink:git-cat-file[1].
+
+Tree Object
+-----------
+
+The next hierarchical object type is the "tree" object. A tree object
+is a list of mode/name/blob data, sorted by name. Alternatively, the
+mode data may specify a directory mode, in which case instead of
+naming a blob, that name is associated with another TREE object.
+
+Like the "blob" object, a tree object is uniquely determined by the
+set contents, and so two separate but identical trees will always
+share the exact same object. This is true at all levels, i.e. it's
+true for a "leaf" tree (which does not refer to any other trees, only
+blobs) as well as for a whole subdirectory.
+
+For that reason a "tree" object is just a pure data abstraction: it
+has no history, no signatures, no verification of validity, except
+that since the contents are again protected by the hash itself, we can
+trust that the tree is immutable and its contents never change.
+
+So you can trust the contents of a tree to be valid, the same way you
+can trust the contents of a blob, but you don't know where those
+contents 'came' from.
+
+Side note on trees: since a "tree" object is a sorted list of
+"filename+content", you can create a diff between two trees without
+actually having to unpack two trees. Just ignore all common parts,
+and your diff will look right. In other words, you can effectively
+(and efficiently) tell the difference between any two random trees by
+O(n) where "n" is the size of the difference, rather than the size of
+the tree.
+
+Side note 2 on trees: since the name of a "blob" depends entirely and
+exclusively on its contents (i.e. there are no names or permissions
+involved), you can see trivial renames or permission changes by
+noticing that the blob stayed the same. However, renames with data
+changes need a smarter "diff" implementation.
+
+A tree is created with gitlink:git-write-tree[1] and
+its data can be accessed by gitlink:git-ls-tree[1].
+Two trees can be compared with gitlink:git-diff-tree[1].
+
+Commit Object
+-------------
+
+The "commit" object is an object that introduces the notion of
+history into the picture. In contrast to the other objects, it
+doesn't just describe the physical state of a tree, it describes how
+we got there, and why.
+
+A "commit" is defined by the tree-object that it results in, the
+parent commits (zero, one or more) that led up to that point, and a
+comment on what happened. Again, a commit is not trusted per se:
+the contents are well-defined and "safe" due to the cryptographically
+strong signatures at all levels, but there is no reason to believe
+that the tree is "good" or that the merge information makes sense.
+The parents do not have to actually have any relationship with the
+result, for example.
+
+Note on commits: unlike real SCM's, commits do not contain
+rename information or file mode change information. All of that is
+implicit in the trees involved (the result tree, and the result trees
+of the parents), and describing that makes no sense in this idiotic
+file manager.
+
+A commit is created with gitlink:git-commit-tree[1] and
+its data can be accessed by gitlink:git-cat-file[1].
+
+Trust
+-----
+
+An aside on the notion of "trust". Trust is really outside the scope
+of "git", but it's worth noting a few things. First off, since
+everything is hashed with SHA1, you 'can' trust that an object is
+intact and has not been messed with by external sources. So the name
+of an object uniquely identifies a known state - just not a state that
+you may want to trust.
+
+Furthermore, since the SHA1 signature of a commit refers to the
+SHA1 signatures of the tree it is associated with and the signatures
+of the parent, a single named commit specifies uniquely a whole set
+of history, with full contents. You can't later fake any step of the
+way once you have the name of a commit.
+
+So to introduce some real trust in the system, the only thing you need
+to do is to digitally sign just 'one' special note, which includes the
+name of a top-level commit. Your digital signature shows others
+that you trust that commit, and the immutability of the history of
+commits tells others that they can trust the whole history.
+
+In other words, you can easily validate a whole archive by just
+sending out a single email that tells the people the name (SHA1 hash)
+of the top commit, and digitally sign that email using something
+like GPG/PGP.
+
+To assist in this, git also provides the tag object...
+
+Tag Object
+----------
+
+Git provides the "tag" object to simplify creating, managing and
+exchanging symbolic and signed tokens. The "tag" object at its
+simplest simply symbolically identifies another object by containing
+the sha1, type and symbolic name.
+
+However it can optionally contain additional signature information
+(which git doesn't care about as long as there's less than 8k of
+it). This can then be verified externally to git.
+
+Note that despite the tag features, "git" itself only handles content
+integrity; the trust framework (and signature provision and
+verification) has to come from outside.
+
+A tag is created with gitlink:git-mktag[1],
+its data can be accessed by gitlink:git-cat-file[1],
+and the signature can be verified by
+gitlink:git-verify-tag[1].
+
+
+The "index" aka "Current Directory Cache"
+-----------------------------------------
+
+The index is a simple binary file, which contains an efficient
+representation of a virtual directory content at some random time. It
+does so by a simple array that associates a set of names, dates,
+permissions and content (aka "blob") objects together. The cache is
+always kept ordered by name, and names are unique (with a few very
+specific rules) at any point in time, but the cache has no long-term
+meaning, and can be partially updated at any time.
+
+In particular, the index certainly does not need to be consistent with
+the current directory contents (in fact, most operations will depend on
+different ways to make the index 'not' be consistent with the directory
+hierarchy), but it has three very important attributes:
+
+'(a) it can re-generate the full state it caches (not just the
+directory structure: it contains pointers to the "blob" objects so
+that it can regenerate the data too)'
+
+As a special case, there is a clear and unambiguous one-way mapping
+from a current directory cache to a "tree object", which can be
+efficiently created from just the current directory cache without
+actually looking at any other data. So a directory cache at any one
+time uniquely specifies one and only one "tree" object (but has
+additional data to make it easy to match up that tree object with what
+has happened in the directory)
+
+'(b) it has efficient methods for finding inconsistencies between that
+cached state ("tree object waiting to be instantiated") and the
+current state.'
+
+'(c) it can additionally efficiently represent information about merge
+conflicts between different tree objects, allowing each pathname to be
+associated with sufficient information about the trees involved that
+you can create a three-way merge between them.'
+
+Those are the three ONLY things that the directory cache does. It's a
+cache, and the normal operation is to re-generate it completely from a
+known tree object, or update/compare it with a live tree that is being
+developed. If you blow the directory cache away entirely, you generally
+haven't lost any information as long as you have the name of the tree
+that it described.
+
+At the same time, the index is at the same time also the
+staging area for creating new trees, and creating a new tree always
+involves a controlled modification of the index file. In particular,
+the index file can have the representation of an intermediate tree that
+has not yet been instantiated. So the index can be thought of as a
+write-back cache, which can contain dirty information that has not yet
+been written back to the backing store.
+
+
+
+The Workflow
+------------
+
+Generally, all "git" operations work on the index file. Some operations
+work *purely* on the index file (showing the current state of the
+index), but most operations move data to and from the index file. Either
+from the database or from the working directory. Thus there are four
+main combinations:
+
+working directory -> index
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update the index with information from the working directory with
+the gitlink:git-update-index[1] command. You
+generally update the index information by just specifying the filename
+you want to update, like so:
+
+-------------------------------------------------
+$ git-update-index filename
+-------------------------------------------------
+
+but to avoid common mistakes with filename globbing etc, the command
+will not normally add totally new entries or remove old entries,
+i.e. it will normally just update existing cache entries.
+
+To tell git that yes, you really do realize that certain files no
+longer exist, or that new files should be added, you
+should use the `--remove` and `--add` flags respectively.
+
+NOTE! A `--remove` flag does 'not' mean that subsequent filenames will
+necessarily be removed: if the files still exist in your directory
+structure, the index will be updated with their new status, not
+removed. The only thing `--remove` means is that update-cache will be
+considering a removed file to be a valid thing, and if the file really
+does not exist any more, it will update the index accordingly.
+
+As a special case, you can also do `git-update-index --refresh`, which
+will refresh the "stat" information of each index to match the current
+stat information. It will 'not' update the object status itself, and
+it will only update the fields that are used to quickly test whether
+an object still matches its old backing store object.
+
+index -> object database
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+You write your current index file to a "tree" object with the program
+
+-------------------------------------------------
+$ git-write-tree
+-------------------------------------------------
+
+that doesn't come with any options - it will just write out the
+current index into the set of tree objects that describe that state,
+and it will return the name of the resulting top-level tree. You can
+use that tree to re-generate the index at any time by going in the
+other direction:
+
+object database -> index
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+You read a "tree" file from the object database, and use that to
+populate (and overwrite - don't do this if your index contains any
+unsaved state that you might want to restore later!) your current
+index. Normal operation is just
+
+-------------------------------------------------
+$ git-read-tree <sha1 of tree>
+-------------------------------------------------
+
+and your index file will now be equivalent to the tree that you saved
+earlier. However, that is only your 'index' file: your working
+directory contents have not been modified.
+
+index -> working directory
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You update your working directory from the index by "checking out"
+files. This is not a very common operation, since normally you'd just
+keep your files updated, and rather than write to your working
+directory, you'd tell the index files about the changes in your
+working directory (i.e. `git-update-index`).
+
+However, if you decide to jump to a new version, or check out somebody
+else's version, or just restore a previous tree, you'd populate your
+index file with read-tree, and then you need to check out the result
+with
+
+-------------------------------------------------
+$ git-checkout-index filename
+-------------------------------------------------
+
+or, if you want to check out all of the index, use `-a`.
+
+NOTE! git-checkout-index normally refuses to overwrite old files, so
+if you have an old version of the tree already checked out, you will
+need to use the "-f" flag ('before' the "-a" flag or the filename) to
+'force' the checkout.
+
+
+Finally, there are a few odds and ends which are not purely moving
+from one representation to the other:
+
+Tying it all together
+~~~~~~~~~~~~~~~~~~~~~
+
+To commit a tree you have instantiated with "git-write-tree", you'd
+create a "commit" object that refers to that tree and the history
+behind it - most notably the "parent" commits that preceded it in
+history.
+
+Normally a "commit" has one parent: the previous state of the tree
+before a certain change was made. However, sometimes it can have two
+or more parent commits, in which case we call it a "merge", due to the
+fact that such a commit brings together ("merges") two or more
+previous states represented by other commits.
+
+In other words, while a "tree" represents a particular directory state
+of a working directory, a "commit" represents that state in "time",
+and explains how we got there.
+
+You create a commit object by giving it the tree that describes the
+state at the time of the commit, and a list of parents:
+
+-------------------------------------------------
+$ git-commit-tree <tree> -p <parent> [-p <parent2> ..]
+-------------------------------------------------
+
+and then giving the reason for the commit on stdin (either through
+redirection from a pipe or file, or by just typing it at the tty).
+
+git-commit-tree will return the name of the object that represents
+that commit, and you should save it away for later use. Normally,
+you'd commit a new `HEAD` state, and while git doesn't care where you
+save the note about that state, in practice we tend to just write the
+result to the file pointed at by `.git/HEAD`, so that we can always see
+what the last committed state was.
+
+Here is an ASCII art by Jon Loeliger that illustrates how
+various pieces fit together.
+
+------------
+
+ commit-tree
+ commit obj
+ +----+
+ | |
+ | |
+ V V
+ +-----------+
+ | Object DB |
+ | Backing |
+ | Store |
+ +-----------+
+ ^
+ write-tree | |
+ tree obj | |
+ | | read-tree
+ | | tree obj
+ V
+ +-----------+
+ | Index |
+ | "cache" |
+ +-----------+
+ update-index ^
+ blob obj | |
+ | |
+ checkout-index -u | | checkout-index
+ stat | | blob obj
+ V
+ +-----------+
+ | Working |
+ | Directory |
+ +-----------+
+
+------------
+
+
+Examining the data
+------------------
+
+You can examine the data represented in the object database and the
+index with various helper tools. For every object, you can use
+gitlink:git-cat-file[1] to examine details about the
+object:
+
+-------------------------------------------------
+$ git-cat-file -t <objectname>
+-------------------------------------------------
+
+shows the type of the object, and once you have the type (which is
+usually implicit in where you find the object), you can use
+
+-------------------------------------------------
+$ git-cat-file blob|tree|commit|tag <objectname>
+-------------------------------------------------
+
+to show its contents. NOTE! Trees have binary content, and as a result
+there is a special helper for showing that content, called
+`git-ls-tree`, which turns the binary content into a more easily
+readable form.
+
+It's especially instructive to look at "commit" objects, since those
+tend to be small and fairly self-explanatory. In particular, if you
+follow the convention of having the top commit name in `.git/HEAD`,
+you can do
+
+-------------------------------------------------
+$ git-cat-file commit HEAD
+-------------------------------------------------
+
+to see what the top commit was.
+
+Merging multiple trees
+----------------------
+
+Git helps you do a three-way merge, which you can expand to n-way by
+repeating the merge procedure arbitrary times until you finally
+"commit" the state. The normal situation is that you'd only do one
+three-way merge (two parents), and commit it, but if you like to, you
+can do multiple parents in one go.
+
+To do a three-way merge, you need the two sets of "commit" objects
+that you want to merge, use those to find the closest common parent (a
+third "commit" object), and then use those commit objects to find the
+state of the directory ("tree" object) at these points.
+
+To get the "base" for the merge, you first look up the common parent
+of two commits with
+
+-------------------------------------------------
+$ git-merge-base <commit1> <commit2>
+-------------------------------------------------
+
+which will return you the commit they are both based on. You should
+now look up the "tree" objects of those commits, which you can easily
+do with (for example)
+
+-------------------------------------------------
+$ git-cat-file commit <commitname> | head -1
+-------------------------------------------------
+
+since the tree object information is always the first line in a commit
+object.
+
+Once you know the three trees you are going to merge (the one "original"
+tree, aka the common case, and the two "result" trees, aka the branches
+you want to merge), you do a "merge" read into the index. This will
+complain if it has to throw away your old index contents, so you should
+make sure that you've committed those - in fact you would normally
+always do a merge against your last commit (which should thus match what
+you have in your current index anyway).
+
+To do the merge, do
+
+-------------------------------------------------
+$ git-read-tree -m -u <origtree> <yourtree> <targettree>
+-------------------------------------------------
+
+which will do all trivial merge operations for you directly in the
+index file, and you can just write the result out with
+`git-write-tree`.
+
+
+Merging multiple trees, continued
+---------------------------------
+
+Sadly, many merges aren't trivial. If there are files that have
+been added.moved or removed, or if both branches have modified the
+same file, you will be left with an index tree that contains "merge
+entries" in it. Such an index tree can 'NOT' be written out to a tree
+object, and you will have to resolve any such merge clashes using
+other tools before you can write out the result.
+
+You can examine such index state with `git-ls-files --unmerged`
+command. An example:
+
+------------------------------------------------
+$ git-read-tree -m $orig HEAD $target
+$ git-ls-files --unmerged
+100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
+100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
+100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c
+------------------------------------------------
+
+Each line of the `git-ls-files --unmerged` output begins with
+the blob mode bits, blob SHA1, 'stage number', and the
+filename. The 'stage number' is git's way to say which tree it
+came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD`
+tree, and stage3 `$target` tree.
+
+Earlier we said that trivial merges are done inside
+`git-read-tree -m`. For example, if the file did not change
+from `$orig` to `HEAD` nor `$target`, or if the file changed
+from `$orig` to `HEAD` and `$orig` to `$target` the same way,
+obviously the final outcome is what is in `HEAD`. What the
+above example shows is that file `hello.c` was changed from
+`$orig` to `HEAD` and `$orig` to `$target` in a different way.
+You could resolve this by running your favorite 3-way merge
+program, e.g. `diff3` or `merge`, on the blob objects from
+these three stages yourself, like this:
+
+------------------------------------------------
+$ git-cat-file blob 263414f... >hello.c~1
+$ git-cat-file blob 06fa6a2... >hello.c~2
+$ git-cat-file blob cc44c73... >hello.c~3
+$ merge hello.c~2 hello.c~1 hello.c~3
+------------------------------------------------
+
+This would leave the merge result in `hello.c~2` file, along
+with conflict markers if there are conflicts. After verifying
+the merge result makes sense, you can tell git what the final
+merge result for this file is by:
+
+-------------------------------------------------
+$ mv -f hello.c~2 hello.c
+$ git-update-index hello.c
+-------------------------------------------------
+
+When a path is in unmerged state, running `git-update-index` for
+that path tells git to mark the path resolved.
+
+The above is the description of a git merge at the lowest level,
+to help you understand what conceptually happens under the hood.
+In practice, nobody, not even git itself, uses three `git-cat-file`
+for this. There is `git-merge-index` program that extracts the
+stages to temporary files and calls a "merge" script on it:
+
+-------------------------------------------------
+$ git-merge-index git-merge-one-file hello.c
+-------------------------------------------------
+
+and that is what higher level `git merge -s resolve` is implemented with.
+
+How git stores objects efficiently: pack files
+----------------------------------------------
+
+We've seen how git stores each object in a file named after the
+object's SHA1 hash.
+
+Unfortunately this system becomes inefficient once a project has a
+lot of objects. Try this on an old project:
+
+------------------------------------------------
+$ git count-objects
+6930 objects, 47620 kilobytes
+------------------------------------------------
+
+The first number is the number of objects which are kept in
+individual files. The second is the amount of space taken up by
+those "loose" objects.
+
+You can save space and make git faster by moving these loose objects in
+to a "pack file", which stores a group of objects in an efficient
+compressed format; the details of how pack files are formatted can be
+found in link:technical/pack-format.txt[technical/pack-format.txt].
+
+To put the loose objects into a pack, just run git repack:
+
+------------------------------------------------
+$ git repack
+Generating pack...
+Done counting 6020 objects.
+Deltifying 6020 objects.
+ 100% (6020/6020) done
+Writing 6020 objects.
+ 100% (6020/6020) done
+Total 6020, written 6020 (delta 4070), reused 0 (delta 0)
+Pack pack-3e54ad29d5b2e05838c75df582c65257b8d08e1c created.
+------------------------------------------------
+
+You can then run
+
+------------------------------------------------
+$ 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).
+You can verify that the loose objects are gone by looking at the
+.git/objects directory or by running
+
+------------------------------------------------
+$ git count-objects
+0 objects, 0 kilobytes
+------------------------------------------------
+
+Although the object files are gone, any commands that refer to those
+objects will work exactly as they did before.
+
+The gitlink:git-gc[1] command performs packing, pruning, and more for
+you, so is normally the only high-level command you need.
+
+[[dangling-objects]]
+Dangling objects
+----------------
+
+The gitlink:git-fsck[1] command will sometimes complain about dangling
+objects. They are not a problem.
+
+The most common cause of dangling objects is that you've rebased a
+branch, or you have pulled from somebody else who rebased a branch--see
+<<cleaning-up-history>>. In that case, the old head of the original
+branch still exists, as does obviously everything it pointed to. The
+branch pointer itself just doesn't, since you replaced it with another
+one.
+
+There are also other situations too that cause dangling objects. For
+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
+not being pointed to by any commit or tree, so it's now a dangling blob
+object.
+
+Similarly, when the "recursive" merge strategy runs, and finds that
+there are criss-cross merges and thus more than one merge base (which is
+fairly unusual, but it does happen), it will generate one temporary
+midway tree (or possibly even more, if you had lots of criss-crossing
+merges and more than two merge bases) as a temporary internal merge
+base, and again, those are real objects, but the end result will not end
+up pointing to them, so they end up "dangling" in your repository.
+
+Generally, dangling objects aren't anything to worry about. They can
+even be very useful: if you screw something up, the dangling objects can
+be how you recover your old tree (say, you did a rebase, and realized
+that you really didn't want to - you can look at what dangling objects
+you have, and decide to reset your head to some old dangling state).
+
+For commits, the most useful thing to do with dangling objects tends to
+be to do a simple
+
+------------------------------------------------
+$ gitk <dangling-commit-sha-goes-here> --not --all
+------------------------------------------------
+
+For blobs and trees, you can't do the same, but you can examine them.
+You can just do
+
+------------------------------------------------
+$ git show <dangling-blob/tree-sha-goes-here>
+------------------------------------------------
+
+to show what the contents of the blob were (or, for a tree, basically
+what the "ls" for that directory was), and that may give you some idea
+of what the operation was that left that dangling object.
+
+Usually, dangling blobs and trees aren't very interesting. They're
+almost always the result of either being a half-way mergebase (the blob
+will often even have the conflict markers from a merge in it, if you
+have had conflicting merges that you fixed up by hand), or simply
+because you interrupted a "git fetch" with ^C or something like that,
+leaving _some_ of the new objects in the object database, but just
+dangling and useless.
+
+Anyway, once you are sure that you're not interested in any dangling
+state, you can just prune all unreachable objects:
+
+------------------------------------------------
+$ git prune
+------------------------------------------------
+
+and they'll be gone. But you should only run "git prune" on a quiescent
+repository - it's kind of like doing a filesystem fsck recovery: you
+don't want to do that while the filesystem is mounted.
+
+(The same is true of "git-fsck" itself, btw - but since
+git-fsck never actually *changes* the repository, it just reports
+on what it found, git-fsck itself is never "dangerous" to run.
+Running it while somebody is actually changing the repository can cause
+confusing and scary messages, but it won't actually do anything bad. In
+contrast, running "git prune" while somebody is actively changing the
+repository is a *BAD* idea).
+
+Glossary of git terms
+=====================
+
+include::glossary.txt[]
+
+Notes and todo list for this manual
+===================================
+
+This is a work in progress.
+
+The basic requirements:
+ - It must be readable in order, from beginning to end, by
+ someone intelligent with a basic grasp of the unix
+ commandline, but without any special knowledge of git. If
+ necessary, any other prerequisites should be specifically
+ mentioned as they arise.
+ - Whenever possible, section headings should clearly describe
+ the task they explain how to do, in language that requires
+ no more knowledge than necessary: for example, "importing
+ patches into a project" rather than "the git-am command"
+
+Think about how to create a clear chapter dependency graph that will
+allow people to get to important topics without necessarily reading
+everything in between.
+
+Say something about .gitignore.
+
+Scan Documentation/ for other stuff left out; in particular:
+ howto's
+ some of technical/?
+ hooks
+ list of commands in gitlink:git[1]
+
+Scan email archives for other stuff left out
+
+Scan man pages to see if any assume more background than this manual
+provides.
+
+Simplify beginning by suggesting disconnected head instead of
+temporary branch creation?
+
+Explain how to refer to file stages in the "how to resolve a merge"
+section: diff -1, -2, -3, --ours, --theirs :1:/path notation. The
+"git ls-files --unmerged --stage" thing is sorta useful too,
+actually. And note gitk --merge.
+
+Add more good examples. Entire sections of just cookbook examples
+might be a good idea; maybe make an "advanced examples" section a
+standard end-of-chapter section?
+
+Include cross-references to the glossary, where appropriate.
+
+Document shallow clones? See draft 1.5.0 release notes for some
+documentation.
+
+Add a section on working with other version control systems, including
+CVS, Subversion, and just imports of series of release tarballs.
+
+More details on gitweb?
+
+Write a chapter on using plumbing and writing scripts.
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 21ff949ea2..febacd2dc9 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
-DEF_VER=v1.4.5-rc0.GIT
+DEF_VER=v1.5.0.GIT
LF='
'
diff --git a/INSTALL b/INSTALL
index e7aea60e92..361c65bacc 100644
--- a/INSTALL
+++ b/INSTALL
@@ -95,7 +95,7 @@ Issues of note:
repository itself. For example, you could:
$ mkdir manual && cd manual
- $ git init-db
+ $ git init
$ git fetch-pack git://git.kernel.org/pub/scm/git/git.git man html |
while read a b
do
diff --git a/Makefile b/Makefile
index eb88860bc9..d66126d7ec 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
# The default target of this Makefile is...
-all:
+all::
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
# This also implies MOZILLA_SHA1.
@@ -172,7 +172,7 @@ SCRIPT_SH = \
git-merge-one-file.sh git-parse-remote.sh \
git-pull.sh git-rebase.sh \
git-repack.sh git-request-pull.sh git-reset.sh \
- git-resolve.sh git-revert.sh git-sh-setup.sh \
+ git-revert.sh git-sh-setup.sh \
git-tag.sh git-verify-tag.sh \
git-applymbox.sh git-applypatch.sh git-am.sh \
git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \
@@ -192,8 +192,10 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
# ... and all the rest that could be moved out of bindir to gitexecdir
PROGRAMS = \
- git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
+ git-convert-objects$X git-fetch-pack$X git-fsck$X \
git-hash-object$X git-index-pack$X git-local-fetch$X \
+ git-fast-import$X \
+ git-merge-base$X \
git-daemon$X \
git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
git-peek-remote$X git-receive-pack$X \
@@ -203,7 +205,7 @@ PROGRAMS = \
git-update-server-info$X \
git-upload-pack$X git-verify-pack$X \
git-pack-redundant$X git-var$X \
- git-describe$X git-merge-tree$X git-imap-send$X \
+ git-merge-tree$X git-imap-send$X \
git-merge-recursive$X \
$(EXTRA_PROGRAMS)
@@ -212,12 +214,12 @@ EXTRA_PROGRAMS =
BUILT_INS = \
git-format-patch$X git-show$X git-whatchanged$X git-cherry$X \
- git-get-tar-commit-id$X git-init$X \
+ git-get-tar-commit-id$X git-init$X git-repo-config$X \
+ git-fsck-objects$X \
$(patsubst builtin-%.o,git-%$X,$(BUILTIN_OBJS))
# what 'all' will build and 'install' will install, in gitexecdir
-ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) \
- git-merge-recur$X
+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
# Backward compatibility -- to be removed after 1.0
PROGRAMS += git-ssh-pull$X git-ssh-push$X
@@ -240,7 +242,7 @@ LIB_H = \
diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
- utf8.h
+ utf8.h reflog-walk.h
DIFF_OBJS = \
diff.o diff-lib.o diffcore-break.o diffcore-order.o \
@@ -253,7 +255,7 @@ LIB_OBJS = \
interpolate.o \
lockfile.o \
object.o pack-check.o patch-delta.o path.o pkt-line.o sideband.o \
- reachable.o \
+ reachable.o reflog-walk.o \
quote.o read-cache.o refs.o run-command.o dir.o object-refs.o \
server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \
tag.o tree.o usage.o config.o environment.o ctype.o copy.o \
@@ -274,13 +276,14 @@ BUILTIN_OBJS = \
builtin-check-ref-format.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-stages.o \
builtin-diff-tree.o \
builtin-fmt-merge-msg.o \
builtin-for-each-ref.o \
+ builtin-fsck.o \
builtin-grep.o \
builtin-init-db.o \
builtin-log.o \
@@ -298,7 +301,7 @@ BUILTIN_OBJS = \
builtin-push.o \
builtin-read-tree.o \
builtin-reflog.o \
- builtin-repo-config.o \
+ builtin-config.o \
builtin-rerere.o \
builtin-rev-list.o \
builtin-rev-parse.o \
@@ -501,7 +504,7 @@ ifdef NO_D_INO_IN_DIRENT
BASIC_CFLAGS += -DNO_D_INO_IN_DIRENT
endif
ifdef NO_C99_FORMAT
- ALL_CFLAGS += -DNO_C99_FORMAT
+ BASIC_CFLAGS += -DNO_C99_FORMAT
endif
ifdef NO_SYMLINK_HEAD
BASIC_CFLAGS += -DNO_SYMLINK_HEAD
@@ -599,14 +602,18 @@ LIB_OBJS += $(COMPAT_OBJS)
ALL_CFLAGS += $(BASIC_CFLAGS)
ALL_LDFLAGS += $(BASIC_LDFLAGS)
-export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
+export prefix gitexecdir TAR INSTALL DESTDIR SHELL_PATH template_dir
### Build rules
-all: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
+all:: $(ALL_PROGRAMS) $(BUILT_INS) git$X gitk gitweb/gitweb.cgi
+ifneq (,$X)
+ $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), rm -f '$p';)
+endif
-all:
+all::
+ $(MAKE) -C git-gui all
$(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
$(MAKE) -C templates
@@ -620,9 +627,6 @@ git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
help.o: common-cmds.h
-git-merge-recur$X: git-merge-recursive$X
- rm -f $@ && ln git-merge-recursive$X $@
-
$(BUILT_INS): git$X
rm -f $@ && ln git$X $@
@@ -840,6 +844,7 @@ install: all
$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(MAKE) -C perl prefix='$(prefix_SQ)' install
+ $(MAKE) -C git-gui install
if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
then \
ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
@@ -848,6 +853,9 @@ install: all
'$(DESTDIR_SQ)$(gitexecdir_SQ)/git$X'; \
fi
$(foreach p,$(BUILT_INS), rm -f '$(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 -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
+endif
install-doc:
$(MAKE) -C Documentation install
@@ -870,8 +878,11 @@ dist: git.spec git-archive
@mkdir -p $(GIT_TARNAME)
@cp git.spec $(GIT_TARNAME)
@echo $(GIT_VERSION) > $(GIT_TARNAME)/version
+ @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
$(TAR) rf $(GIT_TARNAME).tar \
- $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
+ $(GIT_TARNAME)/git.spec \
+ $(GIT_TARNAME)/version \
+ $(GIT_TARNAME)/git-gui/version
@rm -rf $(GIT_TARNAME)
gzip -f -9 $(GIT_TARNAME).tar
@@ -912,6 +923,7 @@ clean:
rm -f gitweb/gitweb.cgi
$(MAKE) -C Documentation/ clean
$(MAKE) -C perl clean
+ $(MAKE) -C git-gui clean
$(MAKE) -C templates/ clean
$(MAKE) -C t/ clean
rm -f GIT-VERSION-FILE GIT-CFLAGS
@@ -926,7 +938,7 @@ check-docs::
do \
case "$$v" in \
git-merge-octopus | git-merge-ours | git-merge-recursive | \
- git-merge-resolve | git-merge-stupid | git-merge-recur | \
+ git-merge-resolve | git-merge-stupid | \
git-ssh-pull | git-ssh-push ) continue ;; \
esac ; \
test -f "Documentation/$$v.txt" || \
diff --git a/README b/README
index cee7e435d7..441167cb8a 100644
--- a/README
+++ b/README
@@ -3,6 +3,7 @@
GIT - the stupid content tracker
////////////////////////////////////////////////////////////////
+
"git" can mean anything, depending on your mood.
- random three-letter combination that is pronounceable, and not
@@ -11,579 +12,29 @@
- stupid. contemptible and despicable. simple. Take your pick from the
dictionary of slang.
- "global information tracker": you're in a good mood, and it actually
- works for you. Angels sing, and a light suddenly fills the room.
+ works for you. Angels sing, and a light suddenly fills the room.
- "goddamn idiotic truckload of sh*t": when it breaks
-This is a stupid (but extremely fast) directory content manager. It
-doesn't do a whole lot, but what it 'does' do is track directory
-contents efficiently.
-
-There are two object abstractions: the "object database", and the
-"current directory cache" aka "index".
-
-The Object Database
-~~~~~~~~~~~~~~~~~~~
-The object database is literally just a content-addressable collection
-of objects. All objects are named by their content, which is
-approximated by the SHA1 hash of the object itself. Objects may refer
-to other objects (by referencing their SHA1 hash), and so you can
-build up a hierarchy of objects.
-
-All objects have a statically determined "type" aka "tag", which is
-determined at object creation time, and which identifies the format of
-the object (i.e. how it is used, and how it can refer to other
-objects). There are currently four different object types: "blob",
-"tree", "commit" and "tag".
-
-A "blob" object cannot refer to any other object, and is, like the type
-implies, a pure storage object containing some user data. It is used to
-actually store the file data, i.e. a blob object is associated with some
-particular version of some file.
-
-A "tree" object is an object that ties one or more "blob" objects into a
-directory structure. In addition, a tree object can refer to other tree
-objects, thus creating a directory hierarchy.
-
-A "commit" object ties such directory hierarchies together into
-a DAG of revisions - each "commit" is associated with exactly one tree
-(the directory hierarchy at the time of the commit). In addition, a
-"commit" refers to one or more "parent" commit objects that describe the
-history of how we arrived at that directory hierarchy.
-
-As a special case, a commit object with no parents is called the "root"
-object, and is the point of an initial project commit. Each project
-must have at least one root, and while you can tie several different
-root objects together into one project by creating a commit object which
-has two or more separate roots as its ultimate parents, that's probably
-just going to confuse people. So aim for the notion of "one root object
-per project", even if git itself does not enforce that.
-
-A "tag" object symbolically identifies and can be used to sign other
-objects. It contains the identifier and type of another object, a
-symbolic name (of course!) and, optionally, a signature.
-
-Regardless of object type, all objects share the following
-characteristics: they are all deflated with zlib, and have a header
-that not only specifies their type, but also provides size information
-about the data in the object. It's worth noting that the SHA1 hash
-that is used to name the object is the hash of the original data
-plus this header, so `sha1sum` 'file' does not match the object name
-for 'file'.
-(Historical note: in the dawn of the age of git the hash
-was the sha1 of the 'compressed' object.)
-
-As a result, the general consistency of an object can always be tested
-independently of the contents or the type of the object: all objects can
-be validated by verifying that (a) their hashes match the content of the
-file and (b) the object successfully inflates to a stream of bytes that
-forms a sequence of <ascii type without space> + <space> + <ascii decimal
-size> + <byte\0> + <binary object data>.
-
-The structured objects can further have their structure and
-connectivity to other objects verified. This is generally done with
-the `git-fsck-objects` program, which generates a full dependency graph
-of all objects, and verifies their internal consistency (in addition
-to just verifying their superficial consistency through the hash).
-
-The object types in some more detail:
-
-Blob Object
-~~~~~~~~~~~
-A "blob" object is nothing but a binary blob of data, and doesn't
-refer to anything else. There is no signature or any other
-verification of the data, so while the object is consistent (it 'is'
-indexed by its sha1 hash, so the data itself is certainly correct), it
-has absolutely no other attributes. No name associations, no
-permissions. It is purely a blob of data (i.e. normally "file
-contents").
-
-In particular, since the blob is entirely defined by its data, if two
-files in a directory tree (or in multiple different versions of the
-repository) have the same contents, they will share the same blob
-object. The object is totally independent of its location in the
-directory tree, and renaming a file does not change the object that
-file is associated with in any way.
-
-A blob is typically created when gitlink:git-update-index[1]
-is run, and its data can be accessed by gitlink:git-cat-file[1].
-
-Tree Object
-~~~~~~~~~~~
-The next hierarchical object type is the "tree" object. A tree object
-is a list of mode/name/blob data, sorted by name. Alternatively, the
-mode data may specify a directory mode, in which case instead of
-naming a blob, that name is associated with another TREE object.
-
-Like the "blob" object, a tree object is uniquely determined by the
-set contents, and so two separate but identical trees will always
-share the exact same object. This is true at all levels, i.e. it's
-true for a "leaf" tree (which does not refer to any other trees, only
-blobs) as well as for a whole subdirectory.
-
-For that reason a "tree" object is just a pure data abstraction: it
-has no history, no signatures, no verification of validity, except
-that since the contents are again protected by the hash itself, we can
-trust that the tree is immutable and its contents never change.
-
-So you can trust the contents of a tree to be valid, the same way you
-can trust the contents of a blob, but you don't know where those
-contents 'came' from.
-
-Side note on trees: since a "tree" object is a sorted list of
-"filename+content", you can create a diff between two trees without
-actually having to unpack two trees. Just ignore all common parts,
-and your diff will look right. In other words, you can effectively
-(and efficiently) tell the difference between any two random trees by
-O(n) where "n" is the size of the difference, rather than the size of
-the tree.
-
-Side note 2 on trees: since the name of a "blob" depends entirely and
-exclusively on its contents (i.e. there are no names or permissions
-involved), you can see trivial renames or permission changes by
-noticing that the blob stayed the same. However, renames with data
-changes need a smarter "diff" implementation.
-
-A tree is created with gitlink:git-write-tree[1] and
-its data can be accessed by gitlink:git-ls-tree[1].
-Two trees can be compared with gitlink:git-diff-tree[1].
-
-Commit Object
-~~~~~~~~~~~~~
-The "commit" object is an object that introduces the notion of
-history into the picture. In contrast to the other objects, it
-doesn't just describe the physical state of a tree, it describes how
-we got there, and why.
-
-A "commit" is defined by the tree-object that it results in, the
-parent commits (zero, one or more) that led up to that point, and a
-comment on what happened. Again, a commit is not trusted per se:
-the contents are well-defined and "safe" due to the cryptographically
-strong signatures at all levels, but there is no reason to believe
-that the tree is "good" or that the merge information makes sense.
-The parents do not have to actually have any relationship with the
-result, for example.
-
-Note on commits: unlike real SCM's, commits do not contain
-rename information or file mode change information. All of that is
-implicit in the trees involved (the result tree, and the result trees
-of the parents), and describing that makes no sense in this idiotic
-file manager.
-
-A commit is created with gitlink:git-commit-tree[1] and
-its data can be accessed by gitlink:git-cat-file[1].
-
-Trust
-~~~~~
-An aside on the notion of "trust". Trust is really outside the scope
-of "git", but it's worth noting a few things. First off, since
-everything is hashed with SHA1, you 'can' trust that an object is
-intact and has not been messed with by external sources. So the name
-of an object uniquely identifies a known state - just not a state that
-you may want to trust.
-
-Furthermore, since the SHA1 signature of a commit refers to the
-SHA1 signatures of the tree it is associated with and the signatures
-of the parent, a single named commit specifies uniquely a whole set
-of history, with full contents. You can't later fake any step of the
-way once you have the name of a commit.
-
-So to introduce some real trust in the system, the only thing you need
-to do is to digitally sign just 'one' special note, which includes the
-name of a top-level commit. Your digital signature shows others
-that you trust that commit, and the immutability of the history of
-commits tells others that they can trust the whole history.
-
-In other words, you can easily validate a whole archive by just
-sending out a single email that tells the people the name (SHA1 hash)
-of the top commit, and digitally sign that email using something
-like GPG/PGP.
-
-To assist in this, git also provides the tag object...
-
-Tag Object
-~~~~~~~~~~
-Git provides the "tag" object to simplify creating, managing and
-exchanging symbolic and signed tokens. The "tag" object at its
-simplest simply symbolically identifies another object by containing
-the sha1, type and symbolic name.
-
-However it can optionally contain additional signature information
-(which git doesn't care about as long as there's less than 8k of
-it). This can then be verified externally to git.
-
-Note that despite the tag features, "git" itself only handles content
-integrity; the trust framework (and signature provision and
-verification) has to come from outside.
-
-A tag is created with gitlink:git-mktag[1],
-its data can be accessed by gitlink:git-cat-file[1],
-and the signature can be verified by
-gitlink:git-verify-tag[1].
-
-
-The "index" aka "Current Directory Cache"
------------------------------------------
-The index is a simple binary file, which contains an efficient
-representation of a virtual directory content at some random time. It
-does so by a simple array that associates a set of names, dates,
-permissions and content (aka "blob") objects together. The cache is
-always kept ordered by name, and names are unique (with a few very
-specific rules) at any point in time, but the cache has no long-term
-meaning, and can be partially updated at any time.
-
-In particular, the index certainly does not need to be consistent with
-the current directory contents (in fact, most operations will depend on
-different ways to make the index 'not' be consistent with the directory
-hierarchy), but it has three very important attributes:
-
-'(a) it can re-generate the full state it caches (not just the
-directory structure: it contains pointers to the "blob" objects so
-that it can regenerate the data too)'
-
-As a special case, there is a clear and unambiguous one-way mapping
-from a current directory cache to a "tree object", which can be
-efficiently created from just the current directory cache without
-actually looking at any other data. So a directory cache at any one
-time uniquely specifies one and only one "tree" object (but has
-additional data to make it easy to match up that tree object with what
-has happened in the directory)
-
-'(b) it has efficient methods for finding inconsistencies between that
-cached state ("tree object waiting to be instantiated") and the
-current state.'
-
-'(c) it can additionally efficiently represent information about merge
-conflicts between different tree objects, allowing each pathname to be
-associated with sufficient information about the trees involved that
-you can create a three-way merge between them.'
-
-Those are the three ONLY things that the directory cache does. It's a
-cache, and the normal operation is to re-generate it completely from a
-known tree object, or update/compare it with a live tree that is being
-developed. If you blow the directory cache away entirely, you generally
-haven't lost any information as long as you have the name of the tree
-that it described.
-
-At the same time, the index is at the same time also the
-staging area for creating new trees, and creating a new tree always
-involves a controlled modification of the index file. In particular,
-the index file can have the representation of an intermediate tree that
-has not yet been instantiated. So the index can be thought of as a
-write-back cache, which can contain dirty information that has not yet
-been written back to the backing store.
-
-
-
-The Workflow
-------------
-Generally, all "git" operations work on the index file. Some operations
-work *purely* on the index file (showing the current state of the
-index), but most operations move data to and from the index file. Either
-from the database or from the working directory. Thus there are four
-main combinations:
-
-1) working directory -> index
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You update the index with information from the working directory with
-the gitlink:git-update-index[1] command. You
-generally update the index information by just specifying the filename
-you want to update, like so:
-
- git-update-index filename
-
-but to avoid common mistakes with filename globbing etc, the command
-will not normally add totally new entries or remove old entries,
-i.e. it will normally just update existing cache entries.
-
-To tell git that yes, you really do realize that certain files no
-longer exist, or that new files should be added, you
-should use the `--remove` and `--add` flags respectively.
-
-NOTE! A `--remove` flag does 'not' mean that subsequent filenames will
-necessarily be removed: if the files still exist in your directory
-structure, the index will be updated with their new status, not
-removed. The only thing `--remove` means is that update-cache will be
-considering a removed file to be a valid thing, and if the file really
-does not exist any more, it will update the index accordingly.
-
-As a special case, you can also do `git-update-index --refresh`, which
-will refresh the "stat" information of each index to match the current
-stat information. It will 'not' update the object status itself, and
-it will only update the fields that are used to quickly test whether
-an object still matches its old backing store object.
-
-2) index -> object database
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You write your current index file to a "tree" object with the program
-
- git-write-tree
-
-that doesn't come with any options - it will just write out the
-current index into the set of tree objects that describe that state,
-and it will return the name of the resulting top-level tree. You can
-use that tree to re-generate the index at any time by going in the
-other direction:
-
-3) object database -> index
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You read a "tree" file from the object database, and use that to
-populate (and overwrite - don't do this if your index contains any
-unsaved state that you might want to restore later!) your current
-index. Normal operation is just
-
- git-read-tree <sha1 of tree>
-
-and your index file will now be equivalent to the tree that you saved
-earlier. However, that is only your 'index' file: your working
-directory contents have not been modified.
-
-4) index -> working directory
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You update your working directory from the index by "checking out"
-files. This is not a very common operation, since normally you'd just
-keep your files updated, and rather than write to your working
-directory, you'd tell the index files about the changes in your
-working directory (i.e. `git-update-index`).
-
-However, if you decide to jump to a new version, or check out somebody
-else's version, or just restore a previous tree, you'd populate your
-index file with read-tree, and then you need to check out the result
-with
-
- git-checkout-index filename
-
-or, if you want to check out all of the index, use `-a`.
-
-NOTE! git-checkout-index normally refuses to overwrite old files, so
-if you have an old version of the tree already checked out, you will
-need to use the "-f" flag ('before' the "-a" flag or the filename) to
-'force' the checkout.
-
-
-Finally, there are a few odds and ends which are not purely moving
-from one representation to the other:
-
-5) Tying it all together
-~~~~~~~~~~~~~~~~~~~~~~~~
-To commit a tree you have instantiated with "git-write-tree", you'd
-create a "commit" object that refers to that tree and the history
-behind it - most notably the "parent" commits that preceded it in
-history.
-
-Normally a "commit" has one parent: the previous state of the tree
-before a certain change was made. However, sometimes it can have two
-or more parent commits, in which case we call it a "merge", due to the
-fact that such a commit brings together ("merges") two or more
-previous states represented by other commits.
-
-In other words, while a "tree" represents a particular directory state
-of a working directory, a "commit" represents that state in "time",
-and explains how we got there.
-
-You create a commit object by giving it the tree that describes the
-state at the time of the commit, and a list of parents:
-
- git-commit-tree <tree> -p <parent> [-p <parent2> ..]
-
-and then giving the reason for the commit on stdin (either through
-redirection from a pipe or file, or by just typing it at the tty).
-
-git-commit-tree will return the name of the object that represents
-that commit, and you should save it away for later use. Normally,
-you'd commit a new `HEAD` state, and while git doesn't care where you
-save the note about that state, in practice we tend to just write the
-result to the file pointed at by `.git/HEAD`, so that we can always see
-what the last committed state was.
-
-Here is an ASCII art by Jon Loeliger that illustrates how
-various pieces fit together.
-
-------------
-
- commit-tree
- commit obj
- +----+
- | |
- | |
- V V
- +-----------+
- | Object DB |
- | Backing |
- | Store |
- +-----------+
- ^
- write-tree | |
- tree obj | |
- | | read-tree
- | | tree obj
- V
- +-----------+
- | Index |
- | "cache" |
- +-----------+
- update-index ^
- blob obj | |
- | |
- checkout-index -u | | checkout-index
- stat | | blob obj
- V
- +-----------+
- | Working |
- | Directory |
- +-----------+
-
-------------
-
-
-6) Examining the data
-~~~~~~~~~~~~~~~~~~~~~
-
-You can examine the data represented in the object database and the
-index with various helper tools. For every object, you can use
-gitlink:git-cat-file[1] to examine details about the
-object:
-
- git-cat-file -t <objectname>
-
-shows the type of the object, and once you have the type (which is
-usually implicit in where you find the object), you can use
-
- git-cat-file blob|tree|commit|tag <objectname>
-
-to show its contents. NOTE! Trees have binary content, and as a result
-there is a special helper for showing that content, called
-`git-ls-tree`, which turns the binary content into a more easily
-readable form.
-
-It's especially instructive to look at "commit" objects, since those
-tend to be small and fairly self-explanatory. In particular, if you
-follow the convention of having the top commit name in `.git/HEAD`,
-you can do
-
- git-cat-file commit HEAD
-
-to see what the top commit was.
-
-7) Merging multiple trees
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Git helps you do a three-way merge, which you can expand to n-way by
-repeating the merge procedure arbitrary times until you finally
-"commit" the state. The normal situation is that you'd only do one
-three-way merge (two parents), and commit it, but if you like to, you
-can do multiple parents in one go.
-
-To do a three-way merge, you need the two sets of "commit" objects
-that you want to merge, use those to find the closest common parent (a
-third "commit" object), and then use those commit objects to find the
-state of the directory ("tree" object) at these points.
-
-To get the "base" for the merge, you first look up the common parent
-of two commits with
-
- git-merge-base <commit1> <commit2>
-
-which will return you the commit they are both based on. You should
-now look up the "tree" objects of those commits, which you can easily
-do with (for example)
-
- git-cat-file commit <commitname> | head -1
-
-since the tree object information is always the first line in a commit
-object.
-
-Once you know the three trees you are going to merge (the one
-"original" tree, aka the common case, and the two "result" trees, aka
-the branches you want to merge), you do a "merge" read into the
-index. This will complain if it has to throw away your old index contents, so you should
-make sure that you've committed those - in fact you would normally
-always do a merge against your last commit (which should thus match
-what you have in your current index anyway).
-
-To do the merge, do
-
- git-read-tree -m -u <origtree> <yourtree> <targettree>
-
-which will do all trivial merge operations for you directly in the
-index file, and you can just write the result out with
-`git-write-tree`.
-
-Historical note. We did not have `-u` facility when this
-section was first written, so we used to warn that
-the merge is done in the index file, not in your
-working tree, and your working tree will not match your
-index after this step.
-This is no longer true. The above command, thanks to `-u`
-option, updates your working tree with the merge results for
-paths that have been trivially merged.
-
-
-8) Merging multiple trees, continued
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Sadly, many merges aren't trivial. If there are files that have
-been added.moved or removed, or if both branches have modified the
-same file, you will be left with an index tree that contains "merge
-entries" in it. Such an index tree can 'NOT' be written out to a tree
-object, and you will have to resolve any such merge clashes using
-other tools before you can write out the result.
-
-You can examine such index state with `git-ls-files --unmerged`
-command. An example:
-
-------------------------------------------------
-$ git-read-tree -m $orig HEAD $target
-$ git-ls-files --unmerged
-100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
-100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
-100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c
-------------------------------------------------
-
-Each line of the `git-ls-files --unmerged` output begins with
-the blob mode bits, blob SHA1, 'stage number', and the
-filename. The 'stage number' is git's way to say which tree it
-came from: stage 1 corresponds to `$orig` tree, stage 2 `HEAD`
-tree, and stage3 `$target` tree.
-
-Earlier we said that trivial merges are done inside
-`git-read-tree -m`. For example, if the file did not change
-from `$orig` to `HEAD` nor `$target`, or if the file changed
-from `$orig` to `HEAD` and `$orig` to `$target` the same way,
-obviously the final outcome is what is in `HEAD`. What the
-above example shows is that file `hello.c` was changed from
-`$orig` to `HEAD` and `$orig` to `$target` in a different way.
-You could resolve this by running your favorite 3-way merge
-program, e.g. `diff3` or `merge`, on the blob objects from
-these three stages yourself, like this:
-
-------------------------------------------------
-$ git-cat-file blob 263414f... >hello.c~1
-$ git-cat-file blob 06fa6a2... >hello.c~2
-$ git-cat-file blob cc44c73... >hello.c~3
-$ merge hello.c~2 hello.c~1 hello.c~3
-------------------------------------------------
-
-This would leave the merge result in `hello.c~2` file, along
-with conflict markers if there are conflicts. After verifying
-the merge result makes sense, you can tell git what the final
-merge result for this file is by:
-
- mv -f hello.c~2 hello.c
- git-update-index hello.c
-
-When a path is in unmerged state, running `git-update-index` for
-that path tells git to mark the path resolved.
-
-The above is the description of a git merge at the lowest level,
-to help you understand what conceptually happens under the hood.
-In practice, nobody, not even git itself, uses three `git-cat-file`
-for this. There is `git-merge-index` program that extracts the
-stages to temporary files and calls a "merge" script on it:
-
- git-merge-index git-merge-one-file hello.c
-
-and that is what higher level `git resolve` is implemented with.
+Git is a fast, scalable, distributed revision control system with an
+unusually rich command set that provides both high-level operations
+and full access to internals.
+
+Git is an Open Source project covered by the GNU General Public License.
+It was originally written by Linus Torvalds with help of a group of
+hackers around the net. It is currently maintained by Junio C Hamano.
+
+Please read the file INSTALL for installation instructions.
+See Documentation/tutorial.txt to get started, then see
+Documentation/everyday.txt for a useful minimum set of commands,
+and "man git-commandname" for documentation of each command.
+CVS users may also want to read Documentation/cvs-migration.txt.
+
+Many Git online resources are accessible from http://git.or.cz/
+including full documentation and Git related tools.
+
+The user discussion and development of Git take place on the Git
+mailing list -- everyone is welcome to post bug reports, feature
+requests, comments and patches to git@vger.kernel.org. To subscribe
+to the list, send an email with just "subscribe git" in the body to
+majordomo@vger.kernel.org. The mailing list archives are available at
+http://marc.theaimsgroup.com/?l=git and other archival sites.
diff --git a/RelNotes b/RelNotes
new file mode 120000
index 0000000000..4571d0d1cf
--- /dev/null
+++ b/RelNotes
@@ -0,0 +1 @@
+Documentation/RelNotes-1.5.0.txt \ No newline at end of file
diff --git a/builtin-add.c b/builtin-add.c
index e7a1b4d9ab..87e16aa220 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -10,7 +10,7 @@
#include "cache-tree.h"
static const char builtin_add_usage[] =
-"git-add [-n] [-v] [-f] [--interactive] [--] <filepattern>...";
+"git-add [-n] [-v] [-f] [--interactive | -i] [--] <filepattern>...";
static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
{
@@ -102,7 +102,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
int add_interactive = 0;
for (i = 1; i < argc; i++) {
- if (!strcmp("--interactive", argv[i]))
+ if (!strcmp("--interactive", argv[i]) ||
+ !strcmp("-i", argv[i]))
add_interactive++;
}
if (add_interactive) {
diff --git a/builtin-annotate.c b/builtin-annotate.c
index 57c46840d5..9db7cfe74c 100644
--- a/builtin-annotate.c
+++ b/builtin-annotate.c
@@ -12,7 +12,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix)
int i;
nargv = xmalloc(sizeof(char *) * (argc + 2));
- nargv[0] = "blame";
+ nargv[0] = "annotate";
nargv[1] = "-c";
for (i = 1; i < argc; i++) {
diff --git a/builtin-apply.c b/builtin-apply.c
index 54fd2cb0c7..3fefdacd94 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2589,7 +2589,7 @@ static int git_apply_config(const char *var, const char *value)
}
-int cmd_apply(int argc, const char **argv, const char *prefix)
+int cmd_apply(int argc, const char **argv, const char *unused_prefix)
{
int i;
int read_stdin = 1;
diff --git a/builtin-archive.c b/builtin-archive.c
index 32737d3162..f613ac2516 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -74,6 +74,7 @@ static int run_remote_archiver(const char *remote, int argc,
/* Now, start reading from fd[0] and spit it out to stdout */
rv = recv_sideband("archive", fd[0], 1, 2);
close(fd[0]);
+ close(fd[1]);
rv |= finish_connect(pid);
return !!rv;
diff --git a/builtin-blame.c b/builtin-blame.c
index 4a1accf13c..69fc145a38 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -13,10 +13,12 @@
#include "diff.h"
#include "diffcore.h"
#include "revision.h"
+#include "quote.h"
#include "xdiff-interface.h"
+#include "cache-tree.h"
static char blame_usage[] =
-"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
+"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [--contents <filename>] [--incremental] [commit] [--] file\n"
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
" -b Show blank SHA-1 for boundary commits (Default: off)\n"
" -l, --long Show long commit SHA1 (Default: off)\n"
@@ -27,6 +29,8 @@ static char blame_usage[] =
" -p, --porcelain Show in a format designed for machine consumption\n"
" -L n,m Process only line range n,m, counting from 1\n"
" -M, -C Find line movements within and across files\n"
+" --incremental Show blame entries as we find them, incrementally\n"
+" --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 int longest_file;
@@ -36,6 +40,8 @@ static int max_digits;
static int max_score_digits;
static int show_root;
static int blank_boundary;
+static int incremental;
+static int cmd_is_annotate;
#ifndef DEBUG
#define DEBUG 0
@@ -74,6 +80,10 @@ struct origin {
char path[FLEX_ARRAY];
};
+/*
+ * Given an origin, prepare mmfile_t structure to be used by the
+ * diff machinery
+ */
static char *fill_origin_blob(struct origin *o, mmfile_t *file)
{
if (!o->file.ptr) {
@@ -88,6 +98,10 @@ static char *fill_origin_blob(struct origin *o, mmfile_t *file)
return file->ptr;
}
+/*
+ * Origin is refcounted and usually we keep the blob contents to be
+ * reused.
+ */
static inline struct origin *origin_incref(struct origin *o)
{
if (o)
@@ -105,6 +119,11 @@ static void origin_decref(struct origin *o)
}
}
+/*
+ * Each group of lines is described by a blame_entry; it can be split
+ * as we pass blame to the parents. They form a linked list in the
+ * scoreboard structure, sorted by the target line number.
+ */
struct blame_entry {
struct blame_entry *prev;
struct blame_entry *next;
@@ -131,19 +150,24 @@ struct blame_entry {
int s_lno;
/* how significant this entry is -- cached to avoid
- * scanning the lines over and over
+ * scanning the lines over and over.
*/
unsigned score;
};
+/*
+ * The current state of the blame assignment.
+ */
struct scoreboard {
/* the final commit (i.e. where we started digging from) */
struct commit *final;
const char *path;
- /* the contents in the final; pointed into by buf pointers of
- * blame_entries
+ /*
+ * The contents in the final image.
+ * Used by many functions to obtain contents of the nth line,
+ * indexed with scoreboard.lineno[blame_entry.lno].
*/
const char *final_buf;
unsigned long final_buf_size;
@@ -168,6 +192,11 @@ static int cmp_suspect(struct origin *a, struct origin *b)
static void sanity_check_refcnt(struct scoreboard *);
+/*
+ * If two blame entries that are next to each other came from
+ * contiguous lines in the same origin (i.e. <commit, path> pair),
+ * merge them together.
+ */
static void coalesce(struct scoreboard *sb)
{
struct blame_entry *ent, *next;
@@ -191,6 +220,12 @@ static void coalesce(struct scoreboard *sb)
sanity_check_refcnt(sb);
}
+/*
+ * Given a commit and a path in it, create a new origin structure.
+ * The callers that add blame to the scoreboard should use
+ * get_origin() to obtain shared, refcounted copy instead of calling
+ * this function directly.
+ */
static struct origin *make_origin(struct commit *commit, const char *path)
{
struct origin *o;
@@ -201,6 +236,9 @@ static struct origin *make_origin(struct commit *commit, const char *path)
return o;
}
+/*
+ * Locate an existing origin or create a new one.
+ */
static struct origin *get_origin(struct scoreboard *sb,
struct commit *commit,
const char *path)
@@ -215,6 +253,13 @@ static struct origin *get_origin(struct scoreboard *sb,
return make_origin(commit, path);
}
+/*
+ * Fill the blob_sha1 field of an origin if it hasn't, so that later
+ * call to fill_origin_blob() can use it to locate the data. blob_sha1
+ * for an origin is also used to pass the blame for the entire file to
+ * the parent to detect the case where a child's blob is identical to
+ * that of its parent's.
+ */
static int fill_blob_sha1(struct origin *origin)
{
unsigned mode;
@@ -235,6 +280,10 @@ static int fill_blob_sha1(struct origin *origin)
return -1;
}
+/*
+ * We have an origin -- check if the same path exists in the
+ * parent and return an origin structure to represent it.
+ */
static struct origin *find_origin(struct scoreboard *sb,
struct commit *parent,
struct origin *origin)
@@ -244,12 +293,26 @@ static struct origin *find_origin(struct scoreboard *sb,
const char *paths[2];
if (parent->util) {
- /* This is a freestanding copy of origin and not
- * refcounted.
+ /*
+ * Each commit object can cache one origin in that
+ * commit. This is a freestanding copy of origin and
+ * not refcounted.
*/
struct origin *cached = parent->util;
if (!strcmp(cached->path, origin->path)) {
+ /*
+ * The same path between origin and its parent
+ * without renaming -- the most common case.
+ */
porigin = get_origin(sb, parent, cached->path);
+
+ /*
+ * If the origin was newly created (i.e. get_origin
+ * would call make_origin if none is found in the
+ * scoreboard), it does not know the blob_sha1,
+ * so copy it. Otherwise porigin was in the
+ * scoreboard and already knows blob_sha1.
+ */
if (porigin->refcnt == 1)
hashcpy(porigin->blob_sha1, cached->blob_sha1);
return porigin;
@@ -273,9 +336,13 @@ static struct origin *find_origin(struct scoreboard *sb,
diff_tree_setup_paths(paths, &diff_opts);
if (diff_setup_done(&diff_opts) < 0)
die("diff-setup");
- diff_tree_sha1(parent->tree->object.sha1,
- origin->commit->tree->object.sha1,
- "", &diff_opts);
+
+ if (is_null_sha1(origin->commit->object.sha1))
+ do_diff_cache(parent->tree->object.sha1, &diff_opts);
+ else
+ diff_tree_sha1(parent->tree->object.sha1,
+ origin->commit->tree->object.sha1,
+ "", &diff_opts);
diffcore_std(&diff_opts);
/* It is either one entry that says "modified", or "created",
@@ -306,7 +373,13 @@ static struct origin *find_origin(struct scoreboard *sb,
}
diff_flush(&diff_opts);
if (porigin) {
+ /*
+ * Create a freestanding copy that is not part of
+ * the refcounted origin found in the scoreboard, and
+ * cache it in the commit.
+ */
struct origin *cached;
+
cached = make_origin(porigin->commit, porigin->path);
hashcpy(cached->blob_sha1, porigin->blob_sha1);
parent->util = cached;
@@ -314,6 +387,10 @@ static struct origin *find_origin(struct scoreboard *sb,
return porigin;
}
+/*
+ * We have an origin -- find the path that corresponds to it in its
+ * parent and return an origin structure to represent it.
+ */
static struct origin *find_rename(struct scoreboard *sb,
struct commit *parent,
struct origin *origin)
@@ -332,9 +409,13 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_tree_setup_paths(paths, &diff_opts);
if (diff_setup_done(&diff_opts) < 0)
die("diff-setup");
- diff_tree_sha1(parent->tree->object.sha1,
- origin->commit->tree->object.sha1,
- "", &diff_opts);
+
+ if (is_null_sha1(origin->commit->object.sha1))
+ do_diff_cache(parent->tree->object.sha1, &diff_opts);
+ else
+ diff_tree_sha1(parent->tree->object.sha1,
+ origin->commit->tree->object.sha1,
+ "", &diff_opts);
diffcore_std(&diff_opts);
for (i = 0; i < diff_queued_diff.nr; i++) {
@@ -350,6 +431,9 @@ static struct origin *find_rename(struct scoreboard *sb,
return porigin;
}
+/*
+ * Parsing of patch chunks...
+ */
struct chunk {
/* line number in postimage; up to but not including this
* line is the same as preimage
@@ -451,6 +535,11 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
return state.ret;
}
+/*
+ * Run diff between two origins and grab the patch output, so that
+ * we can pass blame for lines origin is currently suspected for
+ * to its parent.
+ */
static struct patch *get_patch(struct origin *parent, struct origin *origin)
{
mmfile_t file_p, file_o;
@@ -471,6 +560,10 @@ static void free_patch(struct patch *p)
free(p);
}
+/*
+ * Link in a new blame entry to the scoreboard. Entries that cover the
+ * same line range have been removed from the scoreboard previously.
+ */
static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
{
struct blame_entry *ent, *prev = NULL;
@@ -494,6 +587,12 @@ static void add_blame_entry(struct scoreboard *sb, struct blame_entry *e)
e->next->prev = e;
}
+/*
+ * src typically is on-stack; we want to copy the information in it to
+ * an malloced blame_entry that is already on the linked list of the
+ * scoreboard. The origin of dst loses a refcnt while the origin of src
+ * gains one.
+ */
static void dup_entry(struct blame_entry *dst, struct blame_entry *src)
{
struct blame_entry *p, *n;
@@ -513,25 +612,25 @@ static const char *nth_line(struct scoreboard *sb, int lno)
return sb->final_buf + sb->lineno[lno];
}
+/*
+ * It is known that lines between tlno to same came from parent, and e
+ * has an overlap with that range. it also is known that parent's
+ * line plno corresponds to e's line tlno.
+ *
+ * <---- e ----->
+ * <------>
+ * <------------>
+ * <------------>
+ * <------------------>
+ *
+ * Split e into potentially three parts; before this chunk, the chunk
+ * to be blamed for the parent, and after that portion.
+ */
static void split_overlap(struct blame_entry *split,
struct blame_entry *e,
int tlno, int plno, int same,
struct origin *parent)
{
- /* it is known that lines between tlno to same came from
- * parent, and e has an overlap with that range. it also is
- * known that parent's line plno corresponds to e's line tlno.
- *
- * <---- e ----->
- * <------>
- * <------------>
- * <------------>
- * <------------------>
- *
- * Potentially we need to split e into three parts; before
- * this chunk, the chunk to be blamed for parent, and after
- * that portion.
- */
int chunk_end_lno;
memset(split, 0, sizeof(struct blame_entry [3]));
@@ -561,11 +660,20 @@ static void split_overlap(struct blame_entry *split,
chunk_end_lno = e->lno + e->num_lines;
split[1].num_lines = chunk_end_lno - split[1].lno;
+ /*
+ * if it turns out there is nothing to blame the parent for,
+ * forget about the splitting. !split[1].suspect signals this.
+ */
if (split[1].num_lines < 1)
return;
split[1].suspect = origin_incref(parent);
}
+/*
+ * split_overlap() divided an existing blame e into up to three parts
+ * in split. Adjust the linked list of blames in the scoreboard to
+ * reflect the split.
+ */
static void split_blame(struct scoreboard *sb,
struct blame_entry *split,
struct blame_entry *e)
@@ -573,21 +681,27 @@ static void split_blame(struct scoreboard *sb,
struct blame_entry *new_entry;
if (split[0].suspect && split[2].suspect) {
- /* we need to split e into two and add another for parent */
+ /* The first part (reuse storage for the existing entry e) */
dup_entry(e, &split[0]);
+ /* The last part -- me */
new_entry = xmalloc(sizeof(*new_entry));
memcpy(new_entry, &(split[2]), sizeof(struct blame_entry));
add_blame_entry(sb, new_entry);
+ /* ... and the middle part -- parent */
new_entry = xmalloc(sizeof(*new_entry));
memcpy(new_entry, &(split[1]), sizeof(struct blame_entry));
add_blame_entry(sb, new_entry);
}
else if (!split[0].suspect && !split[2].suspect)
- /* parent covers the entire area */
+ /*
+ * The parent covers the entire area; reuse storage for
+ * e and replace it with the parent.
+ */
dup_entry(e, &split[1]);
else if (split[0].suspect) {
+ /* me and then parent */
dup_entry(e, &split[0]);
new_entry = xmalloc(sizeof(*new_entry));
@@ -595,6 +709,7 @@ static void split_blame(struct scoreboard *sb,
add_blame_entry(sb, new_entry);
}
else {
+ /* parent and then me */
dup_entry(e, &split[1]);
new_entry = xmalloc(sizeof(*new_entry));
@@ -625,6 +740,10 @@ static void split_blame(struct scoreboard *sb,
}
}
+/*
+ * After splitting the blame, the origins used by the
+ * on-stack blame_entry should lose one refcnt each.
+ */
static void decref_split(struct blame_entry *split)
{
int i;
@@ -633,6 +752,10 @@ static void decref_split(struct blame_entry *split)
origin_decref(split[i].suspect);
}
+/*
+ * Helper for blame_chunk(). blame_entry e is known to overlap with
+ * the patch hunk; split it and pass blame to the parent.
+ */
static void blame_overlap(struct scoreboard *sb, struct blame_entry *e,
int tlno, int plno, int same,
struct origin *parent)
@@ -645,6 +768,9 @@ static void blame_overlap(struct scoreboard *sb, struct blame_entry *e,
decref_split(split);
}
+/*
+ * Find the line number of the last line the target is suspected for.
+ */
static int find_last_in_target(struct scoreboard *sb, struct origin *target)
{
struct blame_entry *e;
@@ -659,6 +785,11 @@ static int find_last_in_target(struct scoreboard *sb, struct origin *target)
return last_in_target;
}
+/*
+ * Process one hunk from the patch between the current suspect for
+ * blame_entry e and its parent. Find and split the overlap, and
+ * pass blame to the overlapping part to the parent.
+ */
static void blame_chunk(struct scoreboard *sb,
int tlno, int plno, int same,
struct origin *target, struct origin *parent)
@@ -675,6 +806,11 @@ static void blame_chunk(struct scoreboard *sb,
}
}
+/*
+ * We are looking at the origin 'target' and aiming to pass blame
+ * for the lines it is suspected to its parent. Run diff to find
+ * which lines came from parent and pass blame for them.
+ */
static int pass_blame_to_parent(struct scoreboard *sb,
struct origin *target,
struct origin *parent)
@@ -695,13 +831,22 @@ static int pass_blame_to_parent(struct scoreboard *sb,
plno = chunk->p_next;
tlno = chunk->t_next;
}
- /* rest (i.e. anything above tlno) are the same as parent */
+ /* The rest (i.e. anything after tlno) are the same as the parent */
blame_chunk(sb, tlno, plno, last_in_target, target, parent);
free_patch(patch);
return 0;
}
+/*
+ * The lines in blame_entry after splitting blames many times can become
+ * very small and trivial, and at some point it becomes pointless to
+ * blame the parents. E.g. "\t\t}\n\t}\n\n" appears everywhere in any
+ * ordinary C program, and it is not worth to say it was copied from
+ * totally unrelated file in the parent.
+ *
+ * Compute how trivial the lines in the blame_entry are.
+ */
static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
{
unsigned score;
@@ -723,6 +868,12 @@ static unsigned ent_score(struct scoreboard *sb, struct blame_entry *e)
return score;
}
+/*
+ * best_so_far[] and this[] are both a split of an existing blame_entry
+ * that passes blame to the parent. Maintain best_so_far the best split
+ * so far, by comparing this and best_so_far and copying this into
+ * bst_so_far as needed.
+ */
static void copy_split_if_better(struct scoreboard *sb,
struct blame_entry *best_so_far,
struct blame_entry *this)
@@ -742,6 +893,11 @@ static void copy_split_if_better(struct scoreboard *sb,
memcpy(best_so_far, this, sizeof(struct blame_entry [3]));
}
+/*
+ * Find the lines from parent that are the same as ent so that
+ * we can pass blames to it. file_p has the blob contents for
+ * the parent.
+ */
static void find_copy_in_blob(struct scoreboard *sb,
struct blame_entry *ent,
struct origin *parent,
@@ -754,6 +910,9 @@ static void find_copy_in_blob(struct scoreboard *sb,
struct patch *patch;
int i, plno, tlno;
+ /*
+ * Prepare mmfile that contains only the lines in ent.
+ */
cp = nth_line(sb, ent->lno);
file_o.ptr = (char*) cp;
cnt = ent->num_lines;
@@ -789,6 +948,10 @@ static void find_copy_in_blob(struct scoreboard *sb,
free_patch(patch);
}
+/*
+ * See if lines currently target is suspected for can be attributed to
+ * parent.
+ */
static int find_move_in_parent(struct scoreboard *sb,
struct origin *target,
struct origin *parent)
@@ -823,12 +986,15 @@ static int find_move_in_parent(struct scoreboard *sb,
return 0;
}
-
struct blame_list {
struct blame_entry *ent;
struct blame_entry split[3];
};
+/*
+ * Count the number of entries the target is suspected for,
+ * and prepare a list of entry and the best split.
+ */
static struct blame_list *setup_blame_list(struct scoreboard *sb,
struct origin *target,
int *num_ents_p)
@@ -837,9 +1003,6 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
int num_ents, i;
struct blame_list *blame_list = NULL;
- /* Count the number of entries the target is suspected for,
- * and prepare a list of entry and the best split.
- */
for (e = sb->ent, num_ents = 0; e; e = e->next)
if (!e->guilty && !cmp_suspect(e->suspect, target))
num_ents++;
@@ -853,6 +1016,11 @@ static struct blame_list *setup_blame_list(struct scoreboard *sb,
return blame_list;
}
+/*
+ * For lines target is suspected for, see if we can find code movement
+ * across file boundary from the parent commit. porigin is the path
+ * in the parent we already tried.
+ */
static int find_copy_in_parent(struct scoreboard *sb,
struct origin *target,
struct commit *parent,
@@ -890,9 +1058,12 @@ static int find_copy_in_parent(struct scoreboard *sb,
(!porigin || strcmp(target->path, porigin->path)))
diff_opts.find_copies_harder = 1;
- diff_tree_sha1(parent->tree->object.sha1,
- target->commit->tree->object.sha1,
- "", &diff_opts);
+ if (is_null_sha1(target->commit->object.sha1))
+ do_diff_cache(parent->tree->object.sha1, &diff_opts);
+ else
+ diff_tree_sha1(parent->tree->object.sha1,
+ target->commit->tree->object.sha1,
+ "", &diff_opts);
if (!diff_opts.find_copies_harder)
diffcore_std(&diff_opts);
@@ -953,7 +1124,8 @@ static int find_copy_in_parent(struct scoreboard *sb,
return retval;
}
-/* The blobs of origin and porigin exactly match, so everything
+/*
+ * The blobs of origin and porigin exactly match, so everything
* origin is suspected for can be blamed on the parent.
*/
static void pass_whole_blame(struct scoreboard *sb,
@@ -1038,7 +1210,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
}
/*
- * Optionally run "miff" to find moves in parents' files here.
+ * Optionally find moves in parents' files.
*/
if (opt & PICKAXE_BLAME_MOVE)
for (i = 0, parent = commit->parents;
@@ -1052,7 +1224,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
}
/*
- * Optionally run "ciff" to find copies from parents' files here.
+ * Optionally find copies from parents' files.
*/
if (opt & PICKAXE_BLAME_COPY)
for (i = 0, parent = commit->parents;
@@ -1069,72 +1241,9 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
origin_decref(parent_origin[i]);
}
-static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
-{
- while (1) {
- struct blame_entry *ent;
- struct commit *commit;
- struct origin *suspect = NULL;
-
- /* find one suspect to break down */
- for (ent = sb->ent; !suspect && ent; ent = ent->next)
- if (!ent->guilty)
- suspect = ent->suspect;
- if (!suspect)
- return; /* all done */
-
- origin_incref(suspect);
- commit = suspect->commit;
- if (!commit->object.parsed)
- parse_commit(commit);
- if (!(commit->object.flags & UNINTERESTING) &&
- !(revs->max_age != -1 && commit->date < revs->max_age))
- pass_blame(sb, suspect, opt);
- else {
- commit->object.flags |= UNINTERESTING;
- if (commit->object.parsed)
- mark_parents_uninteresting(commit);
- }
- /* treat root commit as boundary */
- if (!commit->parents && !show_root)
- commit->object.flags |= UNINTERESTING;
-
- /* Take responsibility for the remaining entries */
- for (ent = sb->ent; ent; ent = ent->next)
- if (!cmp_suspect(ent->suspect, suspect))
- ent->guilty = 1;
- origin_decref(suspect);
-
- if (DEBUG) /* sanity */
- sanity_check_refcnt(sb);
- }
-}
-
-static const char *format_time(unsigned long time, const char *tz_str,
- int show_raw_time)
-{
- static char time_buf[128];
- time_t t = time;
- int minutes, tz;
- struct tm *tm;
-
- if (show_raw_time) {
- sprintf(time_buf, "%lu %s", time, tz_str);
- return time_buf;
- }
-
- tz = atoi(tz_str);
- minutes = tz < 0 ? -tz : tz;
- minutes = (minutes / 100)*60 + (minutes % 100);
- minutes = tz < 0 ? -minutes : minutes;
- t = time + minutes * 60;
- tm = gmtime(&t);
-
- strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
- strcat(time_buf, tz_str);
- return time_buf;
-}
-
+/*
+ * Information on commits, used for output.
+ */
struct commit_info
{
char *author;
@@ -1151,6 +1260,9 @@ struct commit_info
char *summary;
};
+/*
+ * Parse author/committer line in the commit object buffer
+ */
static void get_ac_line(const char *inbuf, const char *what,
int bufsz, char *person, char **mail,
unsigned long *time, char **tz)
@@ -1205,7 +1317,8 @@ static void get_commit_info(struct commit *commit,
static char committer_buf[1024];
static char summary_buf[1024];
- /* We've operated without save_commit_buffer, so
+ /*
+ * We've operated without save_commit_buffer, so
* we now need to populate them for output.
*/
if (!commit->buffer) {
@@ -1237,14 +1350,135 @@ static void get_commit_info(struct commit *commit,
tmp += 2;
endp = strchr(tmp, '\n');
if (!endp)
- goto error_out;
+ endp = tmp + strlen(tmp);
len = endp - tmp;
- if (len >= sizeof(summary_buf))
+ if (len >= sizeof(summary_buf) || len == 0)
goto error_out;
memcpy(summary_buf, tmp, len);
summary_buf[len] = 0;
}
+/*
+ * To allow LF and other nonportable characters in pathnames,
+ * they are c-style quoted as needed.
+ */
+static void write_filename_info(const char *path)
+{
+ printf("filename ");
+ write_name_quoted(NULL, 0, path, 1, stdout);
+ putchar('\n');
+}
+
+/*
+ * The blame_entry is found to be guilty for the range. Mark it
+ * as such, and show it in incremental output.
+ */
+static void found_guilty_entry(struct blame_entry *ent)
+{
+ if (ent->guilty)
+ return;
+ ent->guilty = 1;
+ if (incremental) {
+ struct origin *suspect = ent->suspect;
+
+ printf("%s %d %d %d\n",
+ sha1_to_hex(suspect->commit->object.sha1),
+ ent->s_lno + 1, ent->lno + 1, ent->num_lines);
+ if (!(suspect->commit->object.flags & METAINFO_SHOWN)) {
+ struct commit_info ci;
+ suspect->commit->object.flags |= METAINFO_SHOWN;
+ get_commit_info(suspect->commit, &ci, 1);
+ printf("author %s\n", ci.author);
+ printf("author-mail %s\n", ci.author_mail);
+ printf("author-time %lu\n", ci.author_time);
+ printf("author-tz %s\n", ci.author_tz);
+ printf("committer %s\n", ci.committer);
+ printf("committer-mail %s\n", ci.committer_mail);
+ printf("committer-time %lu\n", ci.committer_time);
+ printf("committer-tz %s\n", ci.committer_tz);
+ printf("summary %s\n", ci.summary);
+ if (suspect->commit->object.flags & UNINTERESTING)
+ printf("boundary\n");
+ }
+ write_filename_info(suspect->path);
+ }
+}
+
+/*
+ * The main loop -- while the scoreboard has lines whose true origin
+ * is still unknown, pick one 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)
+{
+ while (1) {
+ struct blame_entry *ent;
+ struct commit *commit;
+ struct origin *suspect = NULL;
+
+ /* find one suspect to break down */
+ for (ent = sb->ent; !suspect && ent; ent = ent->next)
+ if (!ent->guilty)
+ suspect = ent->suspect;
+ if (!suspect)
+ return; /* all done */
+
+ /*
+ * We will use this suspect later in the loop,
+ * so hold onto it in the meantime.
+ */
+ origin_incref(suspect);
+ commit = suspect->commit;
+ if (!commit->object.parsed)
+ parse_commit(commit);
+ if (!(commit->object.flags & UNINTERESTING) &&
+ !(revs->max_age != -1 && commit->date < revs->max_age))
+ pass_blame(sb, suspect, opt);
+ else {
+ commit->object.flags |= UNINTERESTING;
+ if (commit->object.parsed)
+ mark_parents_uninteresting(commit);
+ }
+ /* treat root commit as boundary */
+ if (!commit->parents && !show_root)
+ commit->object.flags |= UNINTERESTING;
+
+ /* Take responsibility for the remaining entries */
+ for (ent = sb->ent; ent; ent = ent->next)
+ if (!cmp_suspect(ent->suspect, suspect))
+ found_guilty_entry(ent);
+ origin_decref(suspect);
+
+ if (DEBUG) /* sanity */
+ sanity_check_refcnt(sb);
+ }
+}
+
+static const char *format_time(unsigned long time, const char *tz_str,
+ int show_raw_time)
+{
+ static char time_buf[128];
+ time_t t = time;
+ int minutes, tz;
+ struct tm *tm;
+
+ if (show_raw_time) {
+ sprintf(time_buf, "%lu %s", time, tz_str);
+ return time_buf;
+ }
+
+ tz = atoi(tz_str);
+ minutes = tz < 0 ? -tz : tz;
+ minutes = (minutes / 100)*60 + (minutes % 100);
+ minutes = tz < 0 ? -minutes : minutes;
+ t = time + minutes * 60;
+ tm = gmtime(&t);
+
+ strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
+ strcat(time_buf, tz_str);
+ return time_buf;
+}
+
#define OUTPUT_ANNOTATE_COMPAT 001
#define OUTPUT_LONG_OBJECT_NAME 002
#define OUTPUT_RAW_TIMESTAMP 004
@@ -1279,13 +1513,13 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
printf("committer-mail %s\n", ci.committer_mail);
printf("committer-time %lu\n", ci.committer_time);
printf("committer-tz %s\n", ci.committer_tz);
- printf("filename %s\n", suspect->path);
+ write_filename_info(suspect->path);
printf("summary %s\n", ci.summary);
if (suspect->commit->object.flags & UNINTERESTING)
printf("boundary\n");
}
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
- printf("filename %s\n", suspect->path);
+ write_filename_info(suspect->path);
cp = nth_line(sb, ent->lno);
for (cnt = 0; cnt < ent->num_lines; cnt++) {
@@ -1321,12 +1555,12 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;
if (suspect->commit->object.flags & UNINTERESTING) {
- if (!blank_boundary) {
+ if (blank_boundary)
+ memset(hex, ' ', length);
+ else if (!cmd_is_annotate) {
length--;
putchar('^');
}
- else
- memset(hex, ' ', length);
}
printf("%.*s", length, hex);
@@ -1390,6 +1624,10 @@ static void output(struct scoreboard *sb, int option)
}
}
+/*
+ * To allow quick access to the contents of nth line in the
+ * final image, prepare an index in the scoreboard.
+ */
static int prepare_lines(struct scoreboard *sb)
{
const char *buf = sb->final_buf;
@@ -1417,6 +1655,11 @@ static int prepare_lines(struct scoreboard *sb)
return sb->num_lines;
}
+/*
+ * Add phony grafts for use with -S; this is primarily to
+ * support git-cvsserver that wants to give a linear history
+ * to its clients.
+ */
static int read_ancestry(const char *graft_file)
{
FILE *fp = fopen(graft_file, "r");
@@ -1434,6 +1677,9 @@ static int read_ancestry(const char *graft_file)
return 0;
}
+/*
+ * How many columns do we need to show line numbers in decimal?
+ */
static int lineno_width(int lines)
{
int i, width;
@@ -1443,6 +1689,10 @@ static int lineno_width(int lines)
return width;
}
+/*
+ * How many columns do we need to show line numbers, authors,
+ * and filenames?
+ */
static void find_alignment(struct scoreboard *sb, int *option)
{
int longest_src_lines = 0;
@@ -1481,6 +1731,10 @@ static void find_alignment(struct scoreboard *sb, int *option)
max_score_digits = lineno_width(largest_score);
}
+/*
+ * For debugging -- origin is refcounted, and this asserts that
+ * we do not underflow.
+ */
static void sanity_check_refcnt(struct scoreboard *sb)
{
int baa = 0;
@@ -1502,8 +1756,9 @@ static void sanity_check_refcnt(struct scoreboard *sb)
ent->suspect->refcnt = -ent->suspect->refcnt;
}
for (ent = sb->ent; ent; ent = ent->next) {
- /* then pick each and see if they have the the correct
- * refcnt.
+ /*
+ * ... then pick each and see if they have the the
+ * correct refcnt.
*/
int found;
struct blame_entry *e;
@@ -1533,6 +1788,10 @@ static void sanity_check_refcnt(struct scoreboard *sb)
}
}
+/*
+ * Used for the command line parsing; check if the path exists
+ * in the working tree.
+ */
static int has_path_in_work_tree(const char *path)
{
struct stat st;
@@ -1555,6 +1814,9 @@ static const char *add_prefix(const char *prefix, const char *path)
return prefix_path(prefix, strlen(prefix), path);
}
+/*
+ * Parsing of (comma separated) one item in the -L option
+ */
static const char *parse_loc(const char *spec,
struct scoreboard *sb, long lno,
long begin, long *ret)
@@ -1629,6 +1891,9 @@ static const char *parse_loc(const char *spec,
}
}
+/*
+ * Parsing of -L option
+ */
static void prepare_blame_range(struct scoreboard *sb,
const char *bottomtop,
long lno,
@@ -1659,6 +1924,137 @@ static int git_blame_config(const char *var, const char *value)
return git_default_config(var, value);
}
+static struct commit *fake_working_tree_commit(const char *path, const char *contents_from)
+{
+ struct commit *commit;
+ struct origin *origin;
+ unsigned char head_sha1[20];
+ char *buf;
+ const char *ident;
+ int fd;
+ time_t now;
+ unsigned long fin_size;
+ int size, len;
+ struct cache_entry *ce;
+ unsigned mode;
+
+ if (get_sha1("HEAD", head_sha1))
+ die("No such ref: HEAD");
+
+ time(&now);
+ commit = xcalloc(1, sizeof(*commit));
+ commit->parents = xcalloc(1, sizeof(*commit->parents));
+ commit->parents->item = lookup_commit_reference(head_sha1);
+ commit->object.parsed = 1;
+ commit->date = now;
+ commit->object.type = OBJ_COMMIT;
+
+ origin = make_origin(commit, path);
+
+ if (!contents_from || strcmp("-", contents_from)) {
+ struct stat st;
+ const char *read_from;
+
+ if (contents_from) {
+ if (stat(contents_from, &st) < 0)
+ die("Cannot stat %s", contents_from);
+ read_from = contents_from;
+ }
+ else {
+ if (lstat(path, &st) < 0)
+ die("Cannot lstat %s", path);
+ read_from = path;
+ }
+ fin_size = st.st_size;
+ buf = xmalloc(fin_size+1);
+ mode = canon_mode(st.st_mode);
+ switch (st.st_mode & S_IFMT) {
+ case S_IFREG:
+ fd = open(read_from, O_RDONLY);
+ if (fd < 0)
+ die("cannot open %s", read_from);
+ if (read_in_full(fd, buf, fin_size) != fin_size)
+ die("cannot read %s", read_from);
+ break;
+ case S_IFLNK:
+ if (readlink(read_from, buf, fin_size+1) != fin_size)
+ die("cannot readlink %s", read_from);
+ break;
+ default:
+ die("unsupported file type %s", read_from);
+ }
+ }
+ else {
+ /* Reading from stdin */
+ contents_from = "standard input";
+ buf = NULL;
+ fin_size = 0;
+ mode = 0;
+ while (1) {
+ ssize_t cnt = 8192;
+ buf = xrealloc(buf, fin_size + cnt);
+ cnt = xread(0, buf + fin_size, cnt);
+ if (cnt < 0)
+ die("read error %s from stdin",
+ strerror(errno));
+ if (!cnt)
+ break;
+ fin_size += cnt;
+ }
+ buf = xrealloc(buf, fin_size + 1);
+ }
+ buf[fin_size] = 0;
+ origin->file.ptr = buf;
+ origin->file.size = fin_size;
+ pretend_sha1_file(buf, fin_size, blob_type, origin->blob_sha1);
+ commit->util = origin;
+
+ /*
+ * Read the current index, replace the path entry with
+ * origin->blob_sha1 without mucking with its mode or type
+ * bits; we are not going to write this index out -- we just
+ * want to run "diff-index --cached".
+ */
+ discard_cache();
+ read_cache();
+
+ len = strlen(path);
+ if (!mode) {
+ int pos = cache_name_pos(path, len);
+ if (0 <= pos)
+ mode = ntohl(active_cache[pos]->ce_mode);
+ else
+ /* Let's not bother reading from HEAD tree */
+ mode = S_IFREG | 0644;
+ }
+ size = cache_entry_size(len);
+ ce = xcalloc(1, size);
+ hashcpy(ce->sha1, origin->blob_sha1);
+ memcpy(ce->name, path, len);
+ ce->ce_flags = create_ce_flags(len, 0);
+ ce->ce_mode = create_ce_mode(mode);
+ add_cache_entry(ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE);
+
+ /*
+ * We are not going to write this out, so this does not matter
+ * right now, but someday we might optimize diff-index --cached
+ * with cache-tree information.
+ */
+ cache_tree_invalidate_path(active_cache_tree, path);
+
+ commit->buffer = xmalloc(400);
+ ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0);
+ sprintf(commit->buffer,
+ "tree 0000000000000000000000000000000000000000\n"
+ "parent %s\n"
+ "author %s\n"
+ "committer %s\n\n"
+ "Version of %s from %s\n",
+ sha1_to_hex(head_sha1),
+ ident, ident, path, contents_from ? contents_from : path);
+ return commit;
+}
+
int cmd_blame(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -1673,6 +2069,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
const char *final_commit_name = NULL;
char type[10];
const char *bottomtop = NULL;
+ const char *contents_from = NULL;
+
+ cmd_is_annotate = !strcmp(argv[0], "annotate");
git_config(git_blame_config);
save_commit_buffer = 0;
@@ -1717,6 +2116,13 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
die("More than one '-L n,m' option given");
bottomtop = arg;
}
+ else if (!strcmp("--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) ||
@@ -1737,14 +2143,18 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
argv[unk++] = arg;
}
+ if (!incremental)
+ setup_pager();
+
if (!blame_move_score)
blame_move_score = BLAME_DEFAULT_MOVE_SCORE;
if (!blame_copy_score)
blame_copy_score = BLAME_DEFAULT_COPY_SCORE;
- /* We have collected options unknown to us in argv[1..unk]
+ /*
+ * We have collected options unknown to us in argv[1..unk]
* which are to be passed to revision machinery if we are
- * going to do the "bottom" procesing.
+ * going to do the "bottom" processing.
*
* The remaining are:
*
@@ -1822,17 +2232,19 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
if (final_commit_name)
argv[unk++] = final_commit_name;
- /* Now we got rev and path. We do not want the path pruning
+ /*
+ * Now we got rev and path. We do not want the path pruning
* but we may want "bottom" processing.
*/
argv[unk++] = "--"; /* terminate the rev name */
argv[unk] = NULL;
init_revisions(&revs, NULL);
- setup_revisions(unk, argv, &revs, "HEAD");
+ setup_revisions(unk, argv, &revs, NULL);
memset(&sb, 0, sizeof(sb));
- /* There must be one and only one positive commit in the
+ /*
+ * There must be one and only one positive commit in the
* revs->pending array.
*/
for (i = 0; i < revs.pending.nr; i++) {
@@ -1853,27 +2265,40 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
}
if (!sb.final) {
- /* "--not A B -- path" without anything positive */
- unsigned char head_sha1[20];
-
- final_commit_name = "HEAD";
- if (get_sha1(final_commit_name, head_sha1))
- die("No such ref: HEAD");
- sb.final = lookup_commit_reference(head_sha1);
- add_pending_object(&revs, &(sb.final->object), "HEAD");
+ /*
+ * "--not A B -- path" without anything positive;
+ * do not default to HEAD, but use the working tree
+ * or "--contents".
+ */
+ sb.final = fake_working_tree_commit(path, contents_from);
+ add_pending_object(&revs, &(sb.final->object), ":");
}
+ else if (contents_from)
+ die("Cannot use --contents with final commit object name");
- /* If we have bottom, this will mark the ancestors of the
+ /*
+ * If we have bottom, this will mark the ancestors of the
* bottom commits we would reach while traversing as
* uninteresting.
*/
prepare_revision_walk(&revs);
- o = get_origin(&sb, sb.final, path);
- if (fill_blob_sha1(o))
- die("no such path %s in %s", path, final_commit_name);
+ if (is_null_sha1(sb.final->object.sha1)) {
+ char *buf;
+ o = sb.final->util;
+ buf = xmalloc(o->file.size + 1);
+ memcpy(buf, o->file.ptr, o->file.size + 1);
+ sb.final_buf = buf;
+ sb.final_buf_size = o->file.size;
+ }
+ else {
+ o = get_origin(&sb, sb.final, path);
+ if (fill_blob_sha1(o))
+ die("no such path %s in %s", path, final_commit_name);
- sb.final_buf = read_sha1_file(o->blob_sha1, type, &sb.final_buf_size);
+ sb.final_buf = read_sha1_file(o->blob_sha1, type,
+ &sb.final_buf_size);
+ }
num_read_blob++;
lno = prepare_lines(&sb);
@@ -1907,6 +2332,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
assign_blame(&sb, &revs, opt);
+ if (incremental)
+ return 0;
+
coalesce(&sb);
if (!(output_option & OUTPUT_PORCELAIN))
diff --git a/builtin-branch.c b/builtin-branch.c
index 020ed6be7b..d0e7209368 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -275,7 +275,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
}
}
-static void print_ref_list(int kinds, int verbose, int abbrev)
+static void print_ref_list(int kinds, int detached, int verbose, int abbrev)
{
int i;
struct ref_list ref_list;
@@ -286,8 +286,20 @@ static void print_ref_list(int kinds, int verbose, int abbrev)
qsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);
+ detached = (detached && (kinds & REF_LOCAL_BRANCH));
+ if (detached) {
+ struct ref_item item;
+ item.name = "(no branch)";
+ item.kind = REF_LOCAL_BRANCH;
+ hashcpy(item.sha1, head_sha1);
+ if (strlen(item.name) > ref_list.maxwidth)
+ ref_list.maxwidth = strlen(item.name);
+ print_ref_item(&item, ref_list.maxwidth, verbose, abbrev, 1);
+ }
+
for (i = 0; i < ref_list.index; i++) {
- int current = (ref_list.list[i].kind == REF_LOCAL_BRANCH) &&
+ int current = !detached &&
+ (ref_list.list[i].kind == REF_LOCAL_BRANCH) &&
!strcmp(ref_list.list[i].name, head);
print_ref_item(&ref_list.list[i], ref_list.maxwidth, verbose,
abbrev, current);
@@ -296,13 +308,15 @@ static void print_ref_list(int kinds, int verbose, int abbrev)
free_ref_list(&ref_list);
}
-static void create_branch(const char *name, const char *start,
+static void create_branch(const char *name, const char *start_name,
+ unsigned char *start_sha1,
int force, int reflog)
{
struct ref_lock *lock;
struct commit *commit;
unsigned char sha1[20];
char ref[PATH_MAX], msg[PATH_MAX + 20];
+ int forcing = 0;
snprintf(ref, sizeof ref, "refs/heads/%s", name);
if (check_ref_format(ref))
@@ -311,23 +325,34 @@ static void create_branch(const char *name, const char *start,
if (resolve_ref(ref, sha1, 1, NULL)) {
if (!force)
die("A branch named '%s' already exists.", name);
- else if (!strcmp(head, name))
+ else if (!is_bare_repository() && !strcmp(head, name))
die("Cannot force update the current branch.");
+ forcing = 1;
}
- if (get_sha1(start, sha1) ||
- (commit = lookup_commit_reference(sha1)) == NULL)
- die("Not a valid branch point: '%s'.", start);
+ if (start_sha1)
+ /* detached HEAD */
+ hashcpy(sha1, start_sha1);
+ else if (get_sha1(start_name, sha1))
+ die("Not a valid object name: '%s'.", start_name);
+
+ if ((commit = lookup_commit_reference(sha1)) == NULL)
+ die("Not a valid branch point: '%s'.", start_name);
hashcpy(sha1, commit->object.sha1);
lock = lock_any_ref_for_update(ref, NULL);
if (!lock)
die("Failed to lock ref for update: %s.", strerror(errno));
- if (reflog) {
+ if (reflog)
log_all_ref_updates = 1;
- snprintf(msg, sizeof msg, "branch: Created from %s", start);
- }
+
+ if (forcing)
+ snprintf(msg, sizeof msg, "branch: Reset from %s",
+ start_name);
+ else
+ snprintf(msg, sizeof msg, "branch: Created from %s",
+ start_name);
if (write_ref_sha1(lock, sha1, msg) < 0)
die("Failed to write ref: %s.", strerror(errno));
@@ -338,6 +363,9 @@ static void rename_branch(const char *oldname, const char *newname, int force)
char oldref[PATH_MAX], newref[PATH_MAX], logmsg[PATH_MAX*2 + 100];
unsigned char sha1[20];
+ if (!oldname)
+ die("cannot rename the current branch while not on any.");
+
if (snprintf(oldref, sizeof(oldref), "refs/heads/%s", oldname) > sizeof(oldref))
die("Old branchname too long");
@@ -359,7 +387,8 @@ static void rename_branch(const char *oldname, const char *newname, int force)
if (rename_ref(oldref, newref, logmsg))
die("Branch rename failed");
- if (!strcmp(oldname, head) && create_symref("HEAD", newref))
+ /* no need to pass logmsg here as HEAD didn't really move */
+ if (!strcmp(oldname, head) && create_symref("HEAD", newref, NULL))
die("Branch renamed to %s, but HEAD is not updated!", newname);
}
@@ -367,12 +396,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
{
int delete = 0, force_delete = 0, force_create = 0;
int rename = 0, force_rename = 0;
- int verbose = 0, abbrev = DEFAULT_ABBREV;
+ int verbose = 0, abbrev = DEFAULT_ABBREV, detached = 0;
int reflog = 0;
int kinds = REF_LOCAL_BRANCH;
int i;
- setup_ident();
git_config(git_branch_config);
for (i = 1; i < argc; i++) {
@@ -444,22 +472,27 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
head = xstrdup(resolve_ref("HEAD", head_sha1, 0, NULL));
if (!head)
die("Failed to resolve HEAD as a valid ref.");
- if (strncmp(head, "refs/heads/", 11))
- die("HEAD not found below refs/heads!");
- head += 11;
+ if (!strcmp(head, "HEAD")) {
+ detached = 1;
+ }
+ else {
+ if (strncmp(head, "refs/heads/", 11))
+ die("HEAD not found below refs/heads!");
+ head += 11;
+ }
if (delete)
return delete_branches(argc - i, argv + i, force_delete, kinds);
else if (i == argc)
- print_ref_list(kinds, verbose, abbrev);
+ print_ref_list(kinds, detached, verbose, abbrev);
else if (rename && (i == argc - 1))
rename_branch(head, argv[i], force_rename);
else if (rename && (i == argc - 2))
rename_branch(argv[i], argv[i + 1], force_rename);
else if (i == argc - 1)
- create_branch(argv[i], head, force_create, reflog);
+ create_branch(argv[i], head, head_sha1, force_create, reflog);
else if (i == argc - 2)
- create_branch(argv[i], argv[i + 1], force_create, reflog);
+ create_branch(argv[i], argv[i+1], NULL, force_create, reflog);
else
usage(builtin_branch_usage);
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index 0651e5927e..2a818a0a2c 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -94,7 +94,6 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
unsigned int size;
int encoding_is_utf8;
- setup_ident();
git_config(git_default_config);
if (argc < 2)
diff --git a/builtin-repo-config.c b/builtin-config.c
index 90633119d4..0f9051da17 100644
--- a/builtin-repo-config.c
+++ b/builtin-config.c
@@ -2,7 +2,7 @@
#include "cache.h"
static const char git_config_set_usage[] =
-"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";
+"git-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";
static char *key;
static regex_t *key_regexp;
@@ -126,7 +126,7 @@ free_strings:
return ret;
}
-int cmd_repo_config(int argc, const char **argv, const char *prefix)
+int cmd_config(int argc, const char **argv, const char *prefix)
{
int nongit = 0;
setup_git_directory_gently(&nongit);
diff --git a/builtin-describe.c b/builtin-describe.c
new file mode 100644
index 0000000000..bcc645622a
--- /dev/null
+++ b/builtin-describe.c
@@ -0,0 +1,284 @@
+#include "cache.h"
+#include "commit.h"
+#include "tag.h"
+#include "refs.h"
+#include "builtin.h"
+
+#define SEEN (1u<<0)
+#define MAX_TAGS (FLAG_BITS - 1)
+
+static const char describe_usage[] =
+"git-describe [--all] [--tags] [--abbrev=<n>] <committish>*";
+
+static int debug; /* Display lots of verbose info */
+static int all; /* Default to annotated tags only */
+static int tags; /* But allow any tags if --tags is specified */
+static int abbrev = DEFAULT_ABBREV;
+static int max_candidates = 10;
+
+struct commit_name {
+ int prio; /* annotated tag = 2, tag = 1, head = 0 */
+ char path[FLEX_ARRAY]; /* more */
+};
+static const char *prio_names[] = {
+ "head", "lightweight", "annotated",
+};
+
+static void add_to_known_names(const char *path,
+ struct commit *commit,
+ int prio)
+{
+ struct commit_name *e = commit->util;
+ if (!e || e->prio < prio) {
+ size_t len = strlen(path)+1;
+ free(e);
+ e = xmalloc(sizeof(struct commit_name) + len);
+ e->prio = prio;
+ memcpy(e->path, path, len);
+ commit->util = e;
+ }
+}
+
+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);
+ struct object *object;
+ int prio;
+
+ if (!commit)
+ return 0;
+ object = parse_object(sha1);
+ /* If --all, then any refs are used.
+ * If --tags, then any tags are used.
+ * Otherwise only annotated tags are used.
+ */
+ if (!strncmp(path, "refs/tags/", 10)) {
+ if (object->type == OBJ_TAG)
+ prio = 2;
+ else
+ prio = 1;
+ }
+ else
+ prio = 0;
+
+ if (!all) {
+ if (!prio)
+ return 0;
+ if (!tags && prio < 2)
+ return 0;
+ }
+ add_to_known_names(all ? path + 5 : path + 10, commit, prio);
+ return 0;
+}
+
+struct possible_tag {
+ struct commit_name *name;
+ int depth;
+ int found_order;
+ unsigned flag_within;
+};
+
+static int compare_pt(const void *a_, const void *b_)
+{
+ struct possible_tag *a = (struct possible_tag *)a_;
+ struct possible_tag *b = (struct possible_tag *)b_;
+ if (a->name->prio != b->name->prio)
+ return b->name->prio - a->name->prio;
+ if (a->depth != b->depth)
+ return a->depth - b->depth;
+ if (a->found_order != b->found_order)
+ return a->found_order - b->found_order;
+ return 0;
+}
+
+static unsigned long finish_depth_computation(
+ struct commit_list **list,
+ struct possible_tag *best)
+{
+ unsigned long seen_commits = 0;
+ while (*list) {
+ struct commit *c = pop_commit(list);
+ struct commit_list *parents = c->parents;
+ seen_commits++;
+ if (c->object.flags & best->flag_within) {
+ struct commit_list *a = *list;
+ while (a) {
+ struct commit *i = a->item;
+ if (!(i->object.flags & best->flag_within))
+ break;
+ a = a->next;
+ }
+ if (!a)
+ break;
+ } else
+ best->depth++;
+ while (parents) {
+ struct commit *p = parents->item;
+ parse_commit(p);
+ if (!(p->object.flags & SEEN))
+ insert_by_date(p, list);
+ p->object.flags |= c->object.flags;
+ parents = parents->next;
+ }
+ }
+ return seen_commits;
+}
+
+static void describe(const char *arg, int last_one)
+{
+ unsigned char sha1[20];
+ struct commit *cmit, *gave_up_on = NULL;
+ struct commit_list *list;
+ static int initialized = 0;
+ struct commit_name *n;
+ struct possible_tag all_matches[MAX_TAGS];
+ unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
+ unsigned long seen_commits = 0;
+
+ if (get_sha1(arg, sha1))
+ die("Not a valid object name %s", arg);
+ cmit = lookup_commit_reference(sha1);
+ if (!cmit)
+ die("%s is not a valid '%s' object", arg, commit_type);
+
+ if (!initialized) {
+ initialized = 1;
+ for_each_ref(get_name, NULL);
+ }
+
+ n = cmit->util;
+ if (n) {
+ printf("%s\n", n->path);
+ return;
+ }
+
+ if (debug)
+ fprintf(stderr, "searching to describe %s\n", arg);
+
+ list = NULL;
+ cmit->object.flags = SEEN;
+ commit_list_insert(cmit, &list);
+ while (list) {
+ struct commit *c = pop_commit(&list);
+ struct commit_list *parents = c->parents;
+ seen_commits++;
+ n = c->util;
+ if (n) {
+ if (match_cnt < max_candidates) {
+ struct possible_tag *t = &all_matches[match_cnt++];
+ t->name = n;
+ t->depth = seen_commits - 1;
+ t->flag_within = 1u << match_cnt;
+ t->found_order = match_cnt;
+ c->object.flags |= t->flag_within;
+ if (n->prio == 2)
+ annotated_cnt++;
+ }
+ else {
+ gave_up_on = c;
+ break;
+ }
+ }
+ for (cur_match = 0; cur_match < match_cnt; cur_match++) {
+ struct possible_tag *t = &all_matches[cur_match];
+ if (!(c->object.flags & t->flag_within))
+ t->depth++;
+ }
+ if (annotated_cnt && !list) {
+ if (debug)
+ fprintf(stderr, "finished search at %s\n",
+ sha1_to_hex(c->object.sha1));
+ break;
+ }
+ while (parents) {
+ struct commit *p = parents->item;
+ parse_commit(p);
+ if (!(p->object.flags & SEEN))
+ insert_by_date(p, &list);
+ p->object.flags |= c->object.flags;
+ parents = parents->next;
+ }
+ }
+
+ if (!match_cnt)
+ die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
+
+ qsort(all_matches, match_cnt, sizeof(all_matches[0]), compare_pt);
+
+ if (gave_up_on) {
+ insert_by_date(gave_up_on, &list);
+ seen_commits--;
+ }
+ seen_commits += finish_depth_computation(&list, &all_matches[0]);
+ free_commit_list(list);
+
+ if (debug) {
+ for (cur_match = 0; cur_match < match_cnt; cur_match++) {
+ struct possible_tag *t = &all_matches[cur_match];
+ fprintf(stderr, " %-11s %8d %s\n",
+ prio_names[t->name->prio],
+ t->depth, t->name->path);
+ }
+ fprintf(stderr, "traversed %lu commits\n", seen_commits);
+ if (gave_up_on) {
+ fprintf(stderr,
+ "more than %i tags found; listed %i most recent\n"
+ "gave up search at %s\n",
+ max_candidates, max_candidates,
+ sha1_to_hex(gave_up_on->object.sha1));
+ }
+ }
+ if (abbrev == 0)
+ printf("%s\n", all_matches[0].name->path );
+ else
+ printf("%s-%d-g%s\n", all_matches[0].name->path,
+ all_matches[0].depth,
+ find_unique_abbrev(cmit->object.sha1, abbrev));
+
+ if (!last_one)
+ clear_commit_marks(cmit, -1);
+}
+
+int cmd_describe(int argc, const char **argv, const char *prefix)
+{
+ int i;
+
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+
+ if (*arg != '-')
+ break;
+ else if (!strcmp(arg, "--debug"))
+ debug = 1;
+ else if (!strcmp(arg, "--all"))
+ all = 1;
+ else if (!strcmp(arg, "--tags"))
+ tags = 1;
+ else if (!strncmp(arg, "--abbrev=", 9)) {
+ abbrev = strtoul(arg + 9, NULL, 10);
+ if (abbrev != 0 && (abbrev < MINIMUM_ABBREV || 40 < abbrev))
+ abbrev = DEFAULT_ABBREV;
+ }
+ else if (!strncmp(arg, "--candidates=", 13)) {
+ max_candidates = strtoul(arg + 13, NULL, 10);
+ if (max_candidates < 1)
+ max_candidates = 1;
+ else if (max_candidates > MAX_TAGS)
+ max_candidates = MAX_TAGS;
+ }
+ else
+ usage(describe_usage);
+ }
+
+ save_commit_buffer = 0;
+
+ if (argc <= i)
+ describe("HEAD", 1);
+ else
+ while (i < argc) {
+ describe(argv[i], (i == argc - 1));
+ i++;
+ }
+
+ return 0;
+}
diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c
deleted file mode 100644
index 70bb89808d..0000000000
--- a/builtin-diff-stages.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2005 Junio C Hamano
- */
-
-#include "cache.h"
-#include "diff.h"
-#include "builtin.h"
-
-static struct diff_options diff_options;
-
-static const char diff_stages_usage[] =
-"git-diff-stages [<common diff options>] <stage1> <stage2> [<path>...]"
-COMMON_DIFF_OPTIONS_HELP;
-
-static void diff_stages(int stage1, int stage2, const char **pathspec)
-{
- int i = 0;
- while (i < active_nr) {
- struct cache_entry *ce, *stages[4] = { NULL, };
- struct cache_entry *one, *two;
- const char *name;
- int len, skip;
-
- ce = active_cache[i];
- skip = !ce_path_match(ce, pathspec);
- len = ce_namelen(ce);
- name = ce->name;
- for (;;) {
- int stage = ce_stage(ce);
- stages[stage] = ce;
- if (active_nr <= ++i)
- break;
- ce = active_cache[i];
- if (ce_namelen(ce) != len ||
- memcmp(name, ce->name, len))
- break;
- }
- one = stages[stage1];
- two = stages[stage2];
-
- if (skip || (!one && !two))
- continue;
- if (!one)
- diff_addremove(&diff_options, '+', ntohl(two->ce_mode),
- two->sha1, name, NULL);
- else if (!two)
- diff_addremove(&diff_options, '-', ntohl(one->ce_mode),
- one->sha1, name, NULL);
- else if (hashcmp(one->sha1, two->sha1) ||
- (one->ce_mode != two->ce_mode) ||
- diff_options.find_copies_harder)
- diff_change(&diff_options,
- ntohl(one->ce_mode), ntohl(two->ce_mode),
- one->sha1, two->sha1, name, NULL);
- }
-}
-
-int cmd_diff_stages(int ac, const char **av, const char *prefix)
-{
- int stage1, stage2;
- const char **pathspec = NULL;
-
- git_config(git_default_config); /* no "diff" UI options */
- read_cache();
- diff_setup(&diff_options);
- while (1 < ac && av[1][0] == '-') {
- const char *arg = av[1];
- if (!strcmp(arg, "-r"))
- ; /* as usual */
- else {
- int diff_opt_cnt;
- diff_opt_cnt = diff_opt_parse(&diff_options,
- av+1, ac-1);
- if (diff_opt_cnt < 0)
- usage(diff_stages_usage);
- else if (diff_opt_cnt) {
- av += diff_opt_cnt;
- ac -= diff_opt_cnt;
- continue;
- }
- else
- usage(diff_stages_usage);
- }
- ac--; av++;
- }
-
- if (!diff_options.output_format)
- diff_options.output_format = DIFF_FORMAT_RAW;
-
- if (ac < 3 ||
- sscanf(av[1], "%d", &stage1) != 1 ||
- ! (0 <= stage1 && stage1 <= 3) ||
- sscanf(av[2], "%d", &stage2) != 1 ||
- ! (0 <= stage2 && stage2 <= 3))
- usage(diff_stages_usage);
-
- av += 3; /* The rest from av[0] are for paths restriction. */
- pathspec = get_pathspec(prefix, av);
-
- if (diff_setup_done(&diff_options) < 0)
- usage(diff_stages_usage);
-
- diff_stages(stage1, stage2, pathspec);
- diffcore_std(&diff_options);
- diff_flush(&diff_options);
- return 0;
-}
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index af72a12a57..16c785f047 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -12,6 +12,7 @@
#define QUOTE_SHELL 1
#define QUOTE_PERL 2
#define QUOTE_PYTHON 3
+#define QUOTE_TCL 4
typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
@@ -134,7 +135,7 @@ static const char *find_next(const char *cp)
while (*cp) {
if (*cp == '%') {
/* %( is the start of an atom;
- * %% is a quoteed per-cent.
+ * %% is a quoted per-cent.
*/
if (cp[1] == '(')
return cp;
@@ -723,6 +724,9 @@ static void print_value(struct refinfo *ref, int atom, int quote_style)
case QUOTE_PYTHON:
python_quote_print(stdout, v->s);
break;
+ case QUOTE_TCL:
+ tcl_quote_print(stdout, v->s);
+ break;
}
}
@@ -834,6 +838,12 @@ int cmd_for_each_ref(int ac, const char **av, char *prefix)
quote_style = QUOTE_PYTHON;
continue;
}
+ if (!strcmp(arg, "--tcl") ) {
+ if (0 <= quote_style)
+ die("more than one quoting style?");
+ quote_style = QUOTE_TCL;
+ continue;
+ }
if (!strncmp(arg, "--count=", 8)) {
if (maxcount)
die("more than one --count?");
diff --git a/fsck-objects.c b/builtin-fsck.c
index 1cc3b399bc..6da3814d59 100644
--- a/fsck-objects.c
+++ b/builtin-fsck.c
@@ -54,6 +54,99 @@ static int objwarning(struct object *obj, const char *err, ...)
return -1;
}
+/*
+ * Check a single reachable object
+ */
+static void check_reachable_object(struct object *obj)
+{
+ const struct object_refs *refs;
+
+ /*
+ * We obviously want the object to be parsed,
+ * except if it was in a pack-file and we didn't
+ * do a full fsck
+ */
+ if (!obj->parsed) {
+ if (has_sha1_file(obj->sha1))
+ return; /* it is in pack - forget about it */
+ printf("missing %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1));
+ return;
+ }
+
+ /*
+ * Check that everything that we try to reference is also good.
+ */
+ refs = lookup_object_refs(obj);
+ if (refs) {
+ unsigned j;
+ for (j = 0; j < refs->count; j++) {
+ struct object *ref = refs->ref[j];
+ if (ref->parsed ||
+ (has_sha1_file(ref->sha1)))
+ continue;
+ printf("broken link from %7s %s\n",
+ typename(obj->type), sha1_to_hex(obj->sha1));
+ printf(" to %7s %s\n",
+ typename(ref->type), sha1_to_hex(ref->sha1));
+ }
+ }
+}
+
+/*
+ * Check a single unreachable object
+ */
+static void check_unreachable_object(struct object *obj)
+{
+ /*
+ * Missing unreachable object? Ignore it. It's not like
+ * we miss it (since it can't be reached), nor do we want
+ * to complain about it being unreachable (since it does
+ * not exist).
+ */
+ if (!obj->parsed)
+ return;
+
+ /*
+ * Unreachable object that exists? Show it if asked to,
+ * since this is something that is prunable.
+ */
+ if (show_unreachable) {
+ printf("unreachable %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1));
+ return;
+ }
+
+ /*
+ * "!used" means that nothing at all points to it, including
+ * other unreachable objects. In other words, it's the "tip"
+ * of some set of unreachable objects, usually a commit that
+ * got dropped.
+ *
+ * Such starting points are more interesting than some random
+ * set of unreachable objects, so we show them even if the user
+ * hasn't asked for _all_ unreachable objects. If you have
+ * deleted a branch by mistake, this is a prime candidate to
+ * start looking at, for example.
+ */
+ if (!obj->used) {
+ printf("dangling %s %s\n", typename(obj->type),
+ sha1_to_hex(obj->sha1));
+ return;
+ }
+
+ /*
+ * Otherwise? It's there, it's unreachable, and some other unreachable
+ * object points to it. Ignore it - it's not interesting, and we showed
+ * all the interesting cases above.
+ */
+}
+
+static void check_object(struct object *obj)
+{
+ if (obj->flags & REACHABLE)
+ check_reachable_object(obj);
+ else
+ check_unreachable_object(obj);
+}
static void check_connectivity(void)
{
@@ -62,46 +155,10 @@ static void check_connectivity(void)
/* Look up all the requirements, warn about missing objects.. */
max = get_max_object_index();
for (i = 0; i < max; i++) {
- const struct object_refs *refs;
struct object *obj = get_indexed_object(i);
- if (!obj)
- continue;
-
- if (!obj->parsed) {
- if (has_sha1_file(obj->sha1))
- ; /* it is in pack */
- else
- printf("missing %s %s\n",
- typename(obj->type), sha1_to_hex(obj->sha1));
- continue;
- }
-
- refs = lookup_object_refs(obj);
- if (refs) {
- unsigned j;
- for (j = 0; j < refs->count; j++) {
- struct object *ref = refs->ref[j];
- if (ref->parsed ||
- (has_sha1_file(ref->sha1)))
- continue;
- printf("broken link from %7s %s\n",
- typename(obj->type), sha1_to_hex(obj->sha1));
- printf(" to %7s %s\n",
- typename(ref->type), sha1_to_hex(ref->sha1));
- }
- }
-
- if (show_unreachable && !(obj->flags & REACHABLE)) {
- printf("unreachable %s %s\n",
- typename(obj->type), sha1_to_hex(obj->sha1));
- continue;
- }
-
- if (!obj->used) {
- printf("dangling %s %s\n", typename(obj->type),
- sha1_to_hex(obj->sha1));
- }
+ if (obj)
+ check_object(obj);
}
}
@@ -290,7 +347,7 @@ static int fsck_sha1(unsigned char *sha1)
{
struct object *obj = parse_object(sha1);
if (!obj)
- return error("%s: object not found", sha1_to_hex(sha1));
+ return error("%s: object corrupt or missing", sha1_to_hex(sha1));
if (obj->flags & SEEN)
return 0;
obj->flags |= SEEN;
@@ -399,7 +456,9 @@ static void fsck_dir(int i, char *path)
static int default_refs;
-static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, char *datail, void *cb_data)
+static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
{
struct object *obj;
@@ -418,6 +477,12 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, ch
return 0;
}
+static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data)
+{
+ for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL);
+ return 0;
+}
+
static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
struct object *obj;
@@ -436,14 +501,13 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f
obj->used = 1;
mark_reachable(obj, REACHABLE);
- for_each_reflog_ent(refname, fsck_handle_reflog_ent, NULL);
-
return 0;
}
static void get_default_heads(void)
{
for_each_ref(fsck_handle_ref, NULL);
+ for_each_reflog(fsck_handle_reflog, NULL);
/*
* Not having any default heads isn't really fatal, but
@@ -512,12 +576,11 @@ static int fsck_cache_tree(struct cache_tree *it)
return err;
}
-int main(int argc, char **argv)
+int cmd_fsck(int argc, char **argv, const char *prefix)
{
int i, heads;
track_object_refs = 1;
- setup_git_directory();
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -547,7 +610,7 @@ int main(int argc, char **argv)
continue;
}
if (*arg == '-')
- usage("git-fsck-objects [--tags] [--root] [[--unreachable] [--cache] [--full] [--strict] <head-sha1>*]");
+ usage("git-fsck [--tags] [--root] [[--unreachable] [--cache] [--full] [--strict] <head-sha1>*]");
}
fsck_head_link();
diff --git a/builtin-init-db.c b/builtin-init-db.c
index bbef820e47..12e43d0db4 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -56,7 +56,7 @@ static void copy_templates_1(char *path, int baselen,
/* Note: if ".git/hooks" file exists in the repository being
* re-initialized, /etc/core-git/templates/hooks/update would
- * cause git-init-db to fail here. I think this is sane but
+ * cause git-init to fail here. I think this is sane but
* it means that the set of templates we ship by default, along
* with the way the namespace under .git/ is organized, should
* be really carefully chosen.
@@ -231,7 +231,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
strcpy(path + len, "HEAD");
reinit = !read_ref("HEAD", sha1);
if (!reinit) {
- if (create_symref("HEAD", "refs/heads/master") < 0)
+ if (create_symref("HEAD", "refs/heads/master", NULL) < 0)
exit(1);
}
@@ -252,9 +252,15 @@ static int create_default_files(const char *git_dir, const char *template_path)
}
git_config_set("core.filemode", filemode ? "true" : "false");
- /* Enable logAllRefUpdates if a working tree is attached */
- if (!is_bare_git_dir(git_dir))
- git_config_set("core.logallrefupdates", "true");
+ if (is_bare_repository()) {
+ git_config_set("core.bare", "true");
+ }
+ else {
+ git_config_set("core.bare", "false");
+ /* allow template config file to override the default */
+ if (log_all_ref_updates == -1)
+ git_config_set("core.logallrefupdates", "true");
+ }
return reinit;
}
diff --git a/builtin-log.c b/builtin-log.c
index a59b4acef1..af2de54371 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -11,6 +11,7 @@
#include "log-tree.h"
#include "builtin.h"
#include "tag.h"
+#include "reflog-walk.h"
static int default_show_root = 1;
@@ -50,8 +51,11 @@ static int cmd_log_walk(struct rev_info *rev)
prepare_revision_walk(rev);
while ((commit = get_revision(rev)) != NULL) {
log_tree_commit(rev, commit);
- free(commit->buffer);
- commit->buffer = NULL;
+ if (!rev->reflog_info) {
+ /* we allow cycles in reflog ancestry */
+ free(commit->buffer);
+ commit->buffer = NULL;
+ }
free_commit_list(commit->parents);
commit->parents = NULL;
}
@@ -178,6 +182,37 @@ int cmd_show(int argc, const char **argv, const char *prefix)
return ret;
}
+/*
+ * This is equivalent to "git log -g --abbrev-commit --pretty=oneline"
+ */
+int cmd_log_reflog(int argc, const char **argv, const char *prefix)
+{
+ struct rev_info rev;
+
+ git_config(git_log_config);
+ init_revisions(&rev, prefix);
+ init_reflog_walk(&rev.reflog_info);
+ rev.abbrev_commit = 1;
+ rev.verbose_header = 1;
+ cmd_log_init(argc, argv, prefix, &rev);
+
+ /*
+ * This means that we override whatever commit format the user gave
+ * on the cmd line. Sad, but cmd_log_init() currently doesn't
+ * allow us to set a different default.
+ */
+ rev.commit_format = CMIT_FMT_ONELINE;
+ rev.always_show_header = 1;
+
+ /*
+ * We get called through "git reflog", so unlike the other log
+ * routines, we need to set up our pager manually..
+ */
+ setup_pager();
+
+ return cmd_log_walk(&rev);
+}
+
int cmd_log(int argc, const char **argv, const char *prefix)
{
struct rev_info rev;
@@ -197,17 +232,28 @@ static int istitlechar(char c)
static char *extra_headers = NULL;
static int extra_headers_size = 0;
+static const char *fmt_patch_suffix = ".patch";
static int git_format_config(const char *var, const char *value)
{
if (!strcmp(var, "format.headers")) {
- int len = strlen(value);
+ int len;
+
+ if (!value)
+ die("format.headers without value");
+ len = strlen(value);
extra_headers_size += len + 1;
extra_headers = xrealloc(extra_headers, extra_headers_size);
extra_headers[extra_headers_size - len - 1] = 0;
strcat(extra_headers, value);
return 0;
}
+ if (!strcmp(var, "format.suffix")) {
+ if (!value)
+ die("format.suffix without value");
+ fmt_patch_suffix = xstrdup(value);
+ return 0;
+ }
if (!strcmp(var, "diff.color") || !strcmp(var, "color.diff")) {
return 0;
}
@@ -223,9 +269,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
char filename[1024];
char *sol;
int len = 0;
+ int suffix_len = strlen(fmt_patch_suffix) + 10; /* ., NUL and slop */
if (output_directory) {
- strlcpy(filename, output_directory, 1010);
+ strlcpy(filename, output_directory, 1000);
len = strlen(filename);
if (filename[len - 1] != '/')
filename[len++] = '/';
@@ -249,7 +296,10 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
}
}
- for (j = 0; len < 1024 - 6 && sol[j] && sol[j] != '\n'; j++) {
+ for (j = 0;
+ len < sizeof(filename) - suffix_len &&
+ sol[j] && sol[j] != '\n';
+ j++) {
if (istitlechar(sol[j])) {
if (space) {
filename[len++] = '-';
@@ -265,7 +315,7 @@ static void reopen_stdout(struct commit *commit, int nr, int keep_subject)
while (filename[len - 1] == '.' || filename[len - 1] == '-')
len--;
}
- strcpy(filename + len, ".txt");
+ strcpy(filename + len, fmt_patch_suffix);
fprintf(realstdout, "%s\n", filename);
freopen(filename, "w", stdout);
}
@@ -334,7 +384,7 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options, co
static void gen_message_id(char *dest, unsigned int length, char *base)
{
- const char *committer = git_committer_info(1);
+ const char *committer = git_committer_info(-1);
const char *email_start = strrchr(committer, '<');
const char *email_end = strrchr(committer, '>');
if(!email_start || !email_end || email_start > email_end - 1)
@@ -362,7 +412,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
char message_id[1024];
char ref_message_id[1024];
- setup_ident();
git_config(git_format_config);
init_revisions(&rev, prefix);
rev.commit_format = CMIT_FMT_EMAIL;
@@ -436,6 +485,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
die("Need a Message-Id for --in-reply-to");
in_reply_to = argv[i];
}
+ else if (!strncmp(argv[i], "--suffix=", 9))
+ fmt_patch_suffix = argv[i] + 9;
else
argv[j++] = argv[i];
}
@@ -451,9 +502,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
die ("unrecognized argument: %s", argv[1]);
if (!rev.diffopt.output_format)
- rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
+ rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
- if (!output_directory)
+ if (!rev.diffopt.text)
+ rev.diffopt.binary = 1;
+
+ if (!output_directory && !use_stdout)
output_directory = prefix;
if (output_directory) {
@@ -465,8 +519,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
}
if (rev.pending.nr == 1) {
- rev.pending.objects[0].item->flags |= UNINTERESTING;
- add_head(&rev);
+ if (rev.max_count < 0) {
+ rev.pending.objects[0].item->flags |= UNINTERESTING;
+ add_head(&rev);
+ }
+ /* Otherwise, it is "format-patch -22 HEAD", and
+ * get_revision() would return only the specified count.
+ */
}
if (ignore_if_in_upstream)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index 21c2a6e2d9..ac89eb2f77 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -323,7 +323,7 @@ static const char ls_files_usage[] =
int cmd_ls_files(int argc, const char **argv, const char *prefix)
{
int i;
- int exc_given = 0;
+ int exc_given = 0, require_work_tree = 0;
struct dir_struct dir;
memset(&dir, 0, sizeof(dir));
@@ -363,14 +363,17 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "-m") || !strcmp(arg, "--modified")) {
show_modified = 1;
+ require_work_tree = 1;
continue;
}
if (!strcmp(arg, "-o") || !strcmp(arg, "--others")) {
show_others = 1;
+ require_work_tree = 1;
continue;
}
if (!strcmp(arg, "-i") || !strcmp(arg, "--ignored")) {
dir.show_ignored = 1;
+ require_work_tree = 1;
continue;
}
if (!strcmp(arg, "-s") || !strcmp(arg, "--stage")) {
@@ -379,6 +382,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "-k") || !strcmp(arg, "--killed")) {
show_killed = 1;
+ require_work_tree = 1;
continue;
}
if (!strcmp(arg, "--directory")) {
@@ -447,6 +451,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
break;
}
+ if (require_work_tree &&
+ (is_bare_repository() || is_inside_git_dir()))
+ die("This operation must be run in a work tree");
+
pathspec = get_pathspec(prefix, argv + i);
/* Verify that the pathspec matches the prefix */
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index a67f3eb90b..583da38b67 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -515,12 +515,9 @@ static void convert_to_utf8(char *line, char *charset)
char *input_charset = *charset ? charset : latin_one;
char *out = reencode_string(line, metainfo_charset, input_charset);
- if (!out) {
- fprintf(stderr, "cannot convert from %s to %s\n",
- input_charset, metainfo_charset);
- *charset = 0;
- return;
- }
+ if (!out)
+ die("cannot convert from %s to %s\n",
+ input_charset, metainfo_charset);
strcpy(line, out);
free(out);
}
@@ -797,17 +794,23 @@ static const char mailinfo_usage[] =
int cmd_mailinfo(int argc, const char **argv, const char *prefix)
{
+ const char *def_charset;
+
/* NEEDSWORK: might want to do the optional .git/ directory
* discovery
*/
git_config(git_default_config);
+ def_charset = (git_commit_encoding ? git_commit_encoding : "utf-8");
+ metainfo_charset = def_charset;
+
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "-k"))
keep_subject = 1;
else if (!strcmp(argv[1], "-u"))
- metainfo_charset = (git_commit_encoding
- ? git_commit_encoding : "utf-8");
+ metainfo_charset = def_charset;
+ else if (!strcmp(argv[1], "-n"))
+ metainfo_charset = NULL;
else if (!strncmp(argv[1], "--encoding=", 11))
metainfo_charset = argv[1] + 11;
else
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 42dd8c87a2..3824ee33ac 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -569,7 +569,7 @@ static void write_index_file(void)
sha1_to_hex(object_list_sha1), "idx");
struct object_entry **list = sorted_by_sha;
struct object_entry **last = list + nr_result;
- unsigned int array[256];
+ uint32_t array[256];
/*
* Write the first-level table (the list is sorted,
@@ -587,7 +587,7 @@ static void write_index_file(void)
array[i] = htonl(next - sorted_by_sha);
list = next;
}
- sha1write(f, array, 256 * sizeof(int));
+ sha1write(f, array, 256 * 4);
/*
* Write the actual SHA1 entries..
@@ -595,7 +595,7 @@ static void write_index_file(void)
list = sorted_by_sha;
for (i = 0; i < nr_result; i++) {
struct object_entry *entry = *list++;
- unsigned int offset = htonl(entry->offset);
+ uint32_t offset = htonl(entry->offset);
sha1write(f, &offset, 4);
sha1write(f, entry->sha1, 20);
}
diff --git a/builtin-pack-refs.c b/builtin-pack-refs.c
index 6de7128b9d..3de9b3eefd 100644
--- a/builtin-pack-refs.c
+++ b/builtin-pack-refs.c
@@ -37,7 +37,9 @@ static int handle_one_ref(const char *path, const unsigned char *sha1,
if ((flags & REF_ISSYMREF))
return 0;
is_tag_ref = !strncmp(path, "refs/tags/", 10);
- if (!cb->all && !is_tag_ref)
+
+ /* ALWAYS pack refs that were already packed or are tags */
+ if (!cb->all && !is_tag_ref && !(flags & REF_ISPACKED))
return 0;
fprintf(cb->refs_file, "%s %s\n", sha1_to_hex(sha1), path);
diff --git a/builtin-prune-packed.c b/builtin-prune-packed.c
index 24e3b0a8c2..977730064b 100644
--- a/builtin-prune-packed.c
+++ b/builtin-prune-packed.c
@@ -2,9 +2,12 @@
#include "cache.h"
static const char prune_packed_usage[] =
-"git-prune-packed [-n]";
+"git-prune-packed [-n] [-q]";
-static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)
+#define DRY_RUN 01
+#define VERBOSE 02
+
+static void prune_dir(int i, DIR *dir, char *pathname, int len, int opts)
{
struct dirent *de;
char hex[40];
@@ -20,7 +23,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)
if (!has_sha1_pack(sha1, NULL))
continue;
memcpy(pathname + len, de->d_name, 38);
- if (dryrun)
+ if (opts & DRY_RUN)
printf("rm -f %s\n", pathname);
else if (unlink(pathname) < 0)
error("unable to unlink %s", pathname);
@@ -29,7 +32,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len, int dryrun)
rmdir(pathname);
}
-void prune_packed_objects(int dryrun)
+void prune_packed_objects(int opts)
{
int i;
static char pathname[PATH_MAX];
@@ -46,24 +49,31 @@ void prune_packed_objects(int dryrun)
sprintf(pathname + len, "%02x/", i);
d = opendir(pathname);
+ if (opts == VERBOSE && (d || i == 255))
+ fprintf(stderr, "Removing unused objects %d%%...\015",
+ ((i+1) * 100) / 256);
if (!d)
continue;
- prune_dir(i, d, pathname, len + 3, dryrun);
+ prune_dir(i, d, pathname, len + 3, opts);
closedir(d);
}
+ if (opts == VERBOSE)
+ fprintf(stderr, "\nDone.\n");
}
int cmd_prune_packed(int argc, const char **argv, const char *prefix)
{
int i;
- int dryrun = 0;
+ int opts = VERBOSE;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (*arg == '-') {
if (!strcmp(arg, "-n"))
- dryrun = 1;
+ opts |= DRY_RUN;
+ else if (!strcmp(arg, "-q"))
+ opts &= ~VERBOSE;
else
usage(prune_packed_usage);
continue;
@@ -72,6 +82,6 @@ int cmd_prune_packed(int argc, const char **argv, const char *prefix)
usage(prune_packed_usage);
}
sync();
- prune_packed_objects(dryrun);
+ prune_packed_objects(opts);
return 0;
}
diff --git a/builtin-push.c b/builtin-push.c
index 7a3d2bb064..c45649e26c 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -8,10 +8,10 @@
#define MAX_URI (16)
-static const char push_usage[] = "git-push [--all] [--tags] [-f | --force] <repository> [<refspec>...]";
+static const char push_usage[] = "git-push [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]";
static int all, tags, force, thin = 1, verbose;
-static const char *execute;
+static const char *receivepack;
#define BUF_SIZE (2084)
static char buffer[BUF_SIZE];
@@ -54,38 +54,84 @@ static void expand_refspecs(void)
for_each_ref(expand_one_ref, NULL);
}
+struct wildcard_cb {
+ const char *from_prefix;
+ int from_prefix_len;
+ const char *to_prefix;
+ int to_prefix_len;
+ int force;
+};
+
+static int expand_wildcard_ref(const char *ref, const unsigned char *sha1, int flag, void *cb_data)
+{
+ struct wildcard_cb *cb = cb_data;
+ int len = strlen(ref);
+ char *expanded, *newref;
+
+ if (len < cb->from_prefix_len ||
+ memcmp(cb->from_prefix, ref, cb->from_prefix_len))
+ return 0;
+ expanded = xmalloc(len * 2 + cb->force +
+ (cb->to_prefix_len - cb->from_prefix_len) + 2);
+ newref = expanded + cb->force;
+ if (cb->force)
+ expanded[0] = '+';
+ memcpy(newref, ref, len);
+ newref[len] = ':';
+ memcpy(newref + len + 1, cb->to_prefix, cb->to_prefix_len);
+ strcpy(newref + len + 1 + cb->to_prefix_len,
+ ref + cb->from_prefix_len);
+ add_refspec(expanded);
+ return 0;
+}
+
+static int wildcard_ref(const char *ref)
+{
+ int len;
+ const char *colon;
+ struct wildcard_cb cb;
+
+ memset(&cb, 0, sizeof(cb));
+ if (ref[0] == '+') {
+ cb.force = 1;
+ ref++;
+ }
+ len = strlen(ref);
+ colon = strchr(ref, ':');
+ if (! (colon && ref < colon &&
+ colon[-2] == '/' && colon[-1] == '*' &&
+ /* "<mine>/<asterisk>:<yours>/<asterisk>" is at least 7 bytes */
+ 7 <= len &&
+ ref[len-2] == '/' && ref[len-1] == '*') )
+ return 0 ;
+ cb.from_prefix = ref;
+ cb.from_prefix_len = colon - ref - 1;
+ cb.to_prefix = colon + 1;
+ cb.to_prefix_len = len - (colon - ref) - 2;
+ for_each_ref(expand_wildcard_ref, &cb);
+ return 1;
+}
+
static void set_refspecs(const char **refs, int nr)
{
if (nr) {
- int pass;
- for (pass = 0; pass < 2; pass++) {
- /* pass 0 counts and allocates, pass 1 fills */
- int i, cnt;
- for (i = cnt = 0; i < nr; i++) {
- if (!strcmp("tag", refs[i])) {
- int len;
- char *tag;
- if (nr <= ++i)
- die("tag <tag> shorthand without <tag>");
- if (pass) {
- len = strlen(refs[i]) + 11;
- tag = xmalloc(len);
- strcpy(tag, "refs/tags/");
- strcat(tag, refs[i]);
- refspec[cnt] = tag;
- }
- cnt++;
- continue;
- }
- if (pass)
- refspec[cnt] = refs[i];
- cnt++;
- }
- if (!pass) {
- size_t bytes = cnt * sizeof(char *);
- refspec_nr = cnt;
- refspec = xrealloc(refspec, bytes);
+ int i;
+ for (i = 0; i < nr; i++) {
+ const char *ref = refs[i];
+ if (!strcmp("tag", ref)) {
+ char *tag;
+ int len;
+ if (nr <= ++i)
+ die("tag shorthand without <tag>");
+ len = strlen(refs[i]) + 11;
+ tag = xmalloc(len);
+ strcpy(tag, "refs/tags/");
+ strcat(tag, refs[i]);
+ ref = tag;
}
+ else if (wildcard_ref(ref))
+ continue;
+ add_refspec(ref);
}
}
expand_refspecs();
@@ -129,8 +175,10 @@ static int get_remotes_uri(const char *repo, const char *uri[MAX_URI])
else
error("more than %d URL's specified, ignoring the rest", MAX_URI);
}
- else if (is_refspec && !has_explicit_refspec)
- add_refspec(xstrdup(s));
+ else if (is_refspec && !has_explicit_refspec) {
+ if (!wildcard_ref(s))
+ add_refspec(xstrdup(s));
+ }
}
fclose(f);
if (!n)
@@ -143,6 +191,7 @@ static const char *config_repo;
static int config_repo_len;
static int config_current_uri;
static int config_get_refspecs;
+static int config_get_receivepack;
static int get_remote_config(const char* key, const char* value)
{
@@ -155,8 +204,19 @@ static int get_remote_config(const char* key, const char* value)
error("more than %d URL's specified, ignoring the rest", MAX_URI);
}
else if (config_get_refspecs &&
- !strcmp(key + 7 + config_repo_len, ".push"))
- add_refspec(xstrdup(value));
+ !strcmp(key + 7 + config_repo_len, ".push")) {
+ if (!wildcard_ref(value))
+ add_refspec(xstrdup(value));
+ }
+ else if (config_get_receivepack &&
+ !strcmp(key + 7 + config_repo_len, ".receivepack")) {
+ if (!receivepack) {
+ char *rp = xmalloc(strlen(value) + 16);
+ sprintf(rp, "--receive-pack=%s", value);
+ receivepack = rp;
+ } else
+ error("more than one receivepack given, using the first");
+ }
}
return 0;
}
@@ -168,6 +228,7 @@ static int get_config_remotes_uri(const char *repo, const char *uri[MAX_URI])
config_current_uri = 0;
config_uri = uri;
config_get_refspecs = !(refspec_nr || all || tags);
+ config_get_receivepack = (receivepack == NULL);
git_config(get_remote_config);
return config_current_uri;
@@ -252,8 +313,8 @@ static int do_push(const char *repo)
argv[argc++] = "--all";
if (force)
argv[argc++] = "--force";
- if (execute)
- argv[argc++] = execute;
+ if (receivepack)
+ argv[argc++] = receivepack;
common_argc = argc;
for (i = 0; i < n; i++) {
@@ -336,8 +397,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)
thin = 0;
continue;
}
+ if (!strncmp(arg, "--receive-pack=", 15)) {
+ receivepack = arg;
+ continue;
+ }
if (!strncmp(arg, "--exec=", 7)) {
- execute = arg;
+ receivepack = arg;
continue;
}
usage(push_usage);
diff --git a/builtin-reflog.c b/builtin-reflog.c
index fb37984ae6..341555139e 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -13,7 +13,7 @@
*/
static const char reflog_expire_usage[] =
-"git-reflog expire [--verbose] [--dry-run] [--fix-stale] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git-reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
static unsigned long default_reflog_expire;
static unsigned long default_reflog_expire_unreachable;
@@ -173,7 +173,6 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
{
struct commit *commit;
- *it = NULL;
if (is_null_sha1(sha1))
return 1;
commit = lookup_commit_reference_gently(sha1, 1);
@@ -195,41 +194,46 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
}
static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
- char *data, void *cb_data)
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
{
struct expire_reflog_cb *cb = cb_data;
- unsigned long timestamp;
- char *cp, *ep;
struct commit *old, *new;
- cp = strchr(data, '>');
- if (!cp || *++cp != ' ')
- goto prune;
- timestamp = strtoul(cp, &ep, 10);
- if (*ep != ' ')
- goto prune;
if (timestamp < cb->cmd->expire_total)
goto prune;
+ old = new = NULL;
if (cb->cmd->stalefix &&
(!keep_entry(&old, osha1) || !keep_entry(&new, nsha1)))
goto prune;
- if ((timestamp < cb->cmd->expire_unreachable) &&
- (!cb->ref_commit ||
- (old && !in_merge_bases(old, &cb->ref_commit, 1)) ||
- (new && !in_merge_bases(new, &cb->ref_commit, 1))))
- goto prune;
+ if (timestamp < cb->cmd->expire_unreachable) {
+ if (!cb->ref_commit)
+ goto prune;
+ if (!old && !is_null_sha1(osha1))
+ old = lookup_commit_reference_gently(osha1, 1);
+ if (!new && !is_null_sha1(nsha1))
+ new = lookup_commit_reference_gently(nsha1, 1);
+ if ((old && !in_merge_bases(old, &cb->ref_commit, 1)) ||
+ (new && !in_merge_bases(new, &cb->ref_commit, 1)))
+ goto prune;
+ }
- if (cb->newlog)
- fprintf(cb->newlog, "%s %s %s",
- sha1_to_hex(osha1), sha1_to_hex(nsha1), data);
+ if (cb->newlog) {
+ char sign = (tz < 0) ? '-' : '+';
+ int zone = (tz < 0) ? (-tz) : tz;
+ fprintf(cb->newlog, "%s %s %s %lu %c%04d\t%s",
+ sha1_to_hex(osha1), sha1_to_hex(nsha1),
+ email, timestamp, sign, zone,
+ message);
+ }
if (cb->cmd->verbose)
- printf("keep %s", data);
+ printf("keep %s", message);
return 0;
prune:
if (!cb->newlog || cb->cmd->verbose)
- printf("%sprune %s", cb->newlog ? "" : "would ", data);
+ printf("%sprune %s", cb->newlog ? "" : "would ", message);
return 0;
}
@@ -238,20 +242,18 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
struct cmd_reflog_expire_cb *cmd = cb_data;
struct expire_reflog_cb cb;
struct ref_lock *lock;
- char *newlog_path = NULL;
+ char *log_file, *newlog_path = NULL;
int status = 0;
- if (strncmp(ref, "refs/", 5))
- return error("not a ref '%s'", ref);
-
memset(&cb, 0, sizeof(cb));
/* we take the lock for the ref itself to prevent it from
* getting updated.
*/
- lock = lock_ref_sha1(ref + 5, sha1);
+ lock = lock_any_ref_for_update(ref, sha1);
if (!lock)
return error("cannot lock ref '%s'", ref);
- if (!file_exists(lock->log_file))
+ log_file = xstrdup(git_path("logs/%s", ref));
+ if (!file_exists(log_file))
goto finish;
if (!cmd->dry_run) {
newlog_path = xstrdup(git_path("logs/%s.lock", ref));
@@ -259,9 +261,6 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
}
cb.ref_commit = lookup_commit_reference_gently(sha1, 1);
- if (!cb.ref_commit)
- fprintf(stderr,
- "warning: ref '%s' does not point at a commit\n", ref);
cb.ref = ref;
cb.cmd = cmd;
for_each_reflog_ent(ref, expire_reflog_ent, &cb);
@@ -270,13 +269,14 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
if (fclose(cb.newlog))
status |= error("%s: %s", strerror(errno),
newlog_path);
- if (rename(newlog_path, lock->log_file)) {
+ if (rename(newlog_path, log_file)) {
status |= error("cannot rename %s to %s",
- newlog_path, lock->log_file);
+ newlog_path, log_file);
unlink(newlog_path);
}
}
free(newlog_path);
+ free(log_file);
unlock_ref(lock);
return status;
}
@@ -350,7 +350,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
}
if (do_all)
- status |= for_each_ref(expire_reflog, &cb);
+ status |= for_each_reflog(expire_reflog, &cb);
while (i < argc) {
const char *ref = argv[i++];
unsigned char sha1[20];
@@ -372,10 +372,16 @@ static const char reflog_usage[] =
int cmd_reflog(int argc, const char **argv, const char *prefix)
{
- if (argc < 2)
- usage(reflog_usage);
- else if (!strcmp(argv[1], "expire"))
+ /* With no command, we default to showing it. */
+ if (argc < 2 || *argv[1] == '-')
+ return cmd_log_reflog(argc, argv, prefix);
+
+ if (!strcmp(argv[1], "show"))
+ return cmd_log_reflog(argc - 1, argv + 1, prefix);
+
+ if (!strcmp(argv[1], "expire"))
return cmd_reflog_expire(argc - 1, argv + 1, prefix);
- else
- usage(reflog_usage);
+
+ /* Not a recognized reflog command..*/
+ usage(reflog_usage);
}
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 3b716fba13..d53deaa369 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -347,6 +347,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
printf("%s/.git\n", cwd);
continue;
}
+ if (!strcmp(arg, "--is-inside-git-dir")) {
+ printf("%s\n", is_inside_git_dir() ? "true"
+ : "false");
+ continue;
+ }
if (!strncmp(arg, "--since=", 8)) {
show_datestring("--max-age=", arg+8);
continue;
diff --git a/builtin-rm.c b/builtin-rm.c
index 5b078c4194..00dbe39960 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -10,7 +10,7 @@
#include "tree-walk.h"
static const char builtin_rm_usage[] =
-"git-rm [-n] [-f] [--cached] <filepattern>...";
+"git-rm [-f] [-n] [-r] [--cached] [--] <file>...";
static struct {
int nr, alloc;
@@ -32,6 +32,10 @@ static int remove_file(const char *name)
char *slash;
ret = unlink(name);
+ if (ret && errno == ENOENT)
+ /* The user has removed it from the filesystem by hand */
+ ret = errno = 0;
+
if (!ret && (slash = strrchr(name, '/'))) {
char *n = xstrdup(name);
do {
@@ -204,7 +208,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
return 0;
/*
- * Then, unless we used "--cache", remove the filenames from
+ * Then, unless we used "--cached", remove the filenames from
* the workspace. If we fail to remove the first one, we
* abort the "git rm" (but once we've successfully removed
* any file at all, we'll go ahead and commit to it all:
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index c67f2fa2fe..0d94e40df8 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -4,7 +4,9 @@
#include "builtin.h"
static const char show_branch_usage[] =
-"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n] <branch>";
+"git-show-branch [--sparse] [--current] [--all] [--remotes] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n[,b]] <branch>";
+static const char show_branch_usage_reflog[] =
+"--reflog is incompatible with --all, --remotes, --independent or --merge-base";
static int default_num;
static int default_alloc;
@@ -346,18 +348,21 @@ static void sort_ref_range(int bottom, int top)
compare_ref_name);
}
-static int append_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+static int append_ref(const char *refname, const unsigned char *sha1,
+ int allow_dups)
{
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
int i;
if (!commit)
return 0;
- /* Avoid adding the same thing twice */
- for (i = 0; i < ref_name_cnt; i++)
- if (!strcmp(refname, ref_name[i]))
- return 0;
+ if (!allow_dups) {
+ /* Avoid adding the same thing twice */
+ for (i = 0; i < ref_name_cnt; i++)
+ if (!strcmp(refname, ref_name[i]))
+ return 0;
+ }
if (MAX_REVS <= ref_name_cnt) {
fprintf(stderr, "warning: ignoring %s; "
"cannot handle more than %d refs\n",
@@ -380,7 +385,7 @@ static int append_head_ref(const char *refname, const unsigned char *sha1, int f
*/
if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))
ofs = 5;
- return append_ref(refname + ofs, sha1, flag, cb_data);
+ return append_ref(refname + ofs, sha1, 0);
}
static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
@@ -394,14 +399,14 @@ static int append_remote_ref(const char *refname, const unsigned char *sha1, int
*/
if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1))
ofs = 5;
- return append_ref(refname + ofs, sha1, flag, cb_data);
+ return append_ref(refname + ofs, sha1, 0);
}
static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
{
if (strncmp(refname, "refs/tags/", 10))
return 0;
- return append_ref(refname + 5, sha1, flag, cb_data);
+ return append_ref(refname + 5, sha1, 0);
}
static const char *match_ref_pattern = NULL;
@@ -434,7 +439,7 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i
return append_head_ref(refname, sha1, flag, cb_data);
if (!strncmp("refs/tags/", refname, 10))
return append_tag_ref(refname, sha1, flag, cb_data);
- return append_ref(refname, sha1, flag, cb_data);
+ return append_ref(refname, sha1, 0);
}
static void snarf_refs(int head, int remotes)
@@ -507,7 +512,7 @@ static void append_one_rev(const char *av)
{
unsigned char revkey[20];
if (!get_sha1(av, revkey)) {
- append_ref(av, revkey, 0, NULL);
+ append_ref(av, revkey, 0);
return;
}
if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) {
@@ -562,9 +567,24 @@ static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
return 0;
}
+static void parse_reflog_param(const char *arg, int *cnt, const char **base)
+{
+ char *ep;
+ *cnt = strtoul(arg, &ep, 10);
+ if (*ep == ',')
+ *base = ep + 1;
+ else if (*ep)
+ die("unrecognized reflog param '%s'", arg + 9);
+ else
+ *base = NULL;
+ if (*cnt <= 0)
+ *cnt = DEFAULT_REFLOG;
+}
+
int cmd_show_branch(int ac, const char **av, const char *prefix)
{
struct commit *rev[MAX_REVS], *commit;
+ char *reflog_msg[MAX_REVS];
struct commit_list *list = NULL, *seen = NULL;
unsigned int rev_mask[MAX_REVS];
int num_rev, i, extra = 0;
@@ -585,6 +605,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
int topics = 0;
int dense = 1;
int reflog = 0;
+ const char *reflog_base = NULL;
git_config(git_show_branch_config);
@@ -628,42 +649,104 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
dense = 0;
else if (!strcmp(arg, "--date-order"))
lifo = 0;
- else if (!strcmp(arg, "--reflog")) {
+ else if (!strcmp(arg, "--reflog") || !strcmp(arg, "-g")) {
reflog = DEFAULT_REFLOG;
}
- else if (!strncmp(arg, "--reflog=", 9)) {
- char *end;
- reflog = strtoul(arg + 9, &end, 10);
- if (*end != '\0')
- die("unrecognized reflog count '%s'", arg + 9);
- }
+ else if (!strncmp(arg, "--reflog=", 9))
+ parse_reflog_param(arg + 9, &reflog, &reflog_base);
+ else if (!strncmp(arg, "-g=", 3))
+ parse_reflog_param(arg + 3, &reflog, &reflog_base);
else
usage(show_branch_usage);
ac--; av++;
}
ac--; av++;
- /* Only one of these is allowed */
- if (1 < independent + merge_base + (extra != 0) + (!!reflog))
- usage(show_branch_usage);
+ if (extra || reflog) {
+ /* "listing" mode is incompatible with
+ * independent nor merge-base modes.
+ */
+ if (independent || merge_base)
+ usage(show_branch_usage);
+ if (reflog && ((0 < extra) || all_heads || all_remotes))
+ /*
+ * Asking for --more in reflog mode does not
+ * make sense. --list is Ok.
+ *
+ * Also --all and --remotes do not make sense either.
+ */
+ usage(show_branch_usage_reflog);
+ }
/* If nothing is specified, show all branches by default */
if (ac + all_heads + all_remotes == 0)
all_heads = 1;
- if (all_heads + all_remotes)
- snarf_refs(all_heads, all_remotes);
if (reflog) {
- int reflen;
- if (!ac)
+ unsigned char sha1[20];
+ char nth_desc[256];
+ char *ref;
+ int base = 0;
+
+ if (ac == 0) {
+ static const char *fake_av[2];
+ const char *refname;
+
+ refname = resolve_ref("HEAD", sha1, 1, NULL);
+ fake_av[0] = xstrdup(refname);
+ fake_av[1] = NULL;
+ av = fake_av;
+ ac = 1;
+ }
+ if (ac != 1)
die("--reflog option needs one branch name");
- reflen = strlen(*av);
+
+ if (MAX_REVS < reflog)
+ die("Only %d entries can be shown at one time.",
+ MAX_REVS);
+ if (!dwim_ref(*av, strlen(*av), sha1, &ref))
+ die("No such ref %s", *av);
+
+ /* Has the base been specified? */
+ if (reflog_base) {
+ char *ep;
+ base = strtoul(reflog_base, &ep, 10);
+ if (*ep) {
+ /* Ah, that is a date spec... */
+ unsigned long at;
+ at = approxidate(reflog_base);
+ read_ref_at(ref, at, -1, sha1, NULL,
+ NULL, NULL, &base);
+ }
+ }
+
for (i = 0; i < reflog; i++) {
- char *name = xmalloc(reflen + 20);
- sprintf(name, "%s@{%d}", *av, i);
- append_one_rev(name);
+ char *logmsg, *msg, *m;
+ unsigned long timestamp;
+ int tz;
+
+ if (read_ref_at(ref, 0, base+i, sha1, &logmsg,
+ &timestamp, &tz, NULL)) {
+ reflog = i;
+ break;
+ }
+ msg = strchr(logmsg, '\t');
+ if (!msg)
+ msg = "(none)";
+ else
+ msg++;
+ m = xmalloc(strlen(msg) + 200);
+ sprintf(m, "(%s) %s",
+ show_date(timestamp, tz, 1),
+ msg);
+ reflog_msg[i] = m;
+ free(logmsg);
+ sprintf(nth_desc, "%s@{%d}", *av, base+i);
+ append_ref(nth_desc, sha1, 1);
}
}
+ else if (all_heads + all_remotes)
+ snarf_refs(all_heads, all_remotes);
else {
while (0 < ac) {
append_one_rev(*av);
@@ -760,8 +843,14 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
printf("%c [%s] ",
is_head ? '*' : '!', ref_name[i]);
}
- /* header lines never need name */
- show_one_commit(rev[i], 1);
+
+ if (!reflog) {
+ /* header lines never need name */
+ show_one_commit(rev[i], 1);
+ }
+ else
+ puts(reflog_msg[i]);
+
if (is_head)
head_at = i;
}
diff --git a/builtin-symbolic-ref.c b/builtin-symbolic-ref.c
index d8be0527f4..d41b40640b 100644
--- a/builtin-symbolic-ref.c
+++ b/builtin-symbolic-ref.c
@@ -3,9 +3,9 @@
#include "refs.h"
static const char git_symbolic_ref_usage[] =
-"git-symbolic-ref name [ref]";
+"git-symbolic-ref [-q] [-m <reason>] name [ref]";
-static void check_symref(const char *HEAD)
+static void check_symref(const char *HEAD, int quiet)
{
unsigned char sha1[20];
int flag;
@@ -13,20 +13,56 @@ static void check_symref(const char *HEAD)
if (!refs_heads_master)
die("No such ref: %s", HEAD);
- else if (!(flag & REF_ISSYMREF))
- die("ref %s is not a symbolic ref", HEAD);
+ else if (!(flag & REF_ISSYMREF)) {
+ if (!quiet)
+ die("ref %s is not a symbolic ref", HEAD);
+ else
+ exit(1);
+ }
puts(refs_heads_master);
}
int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
{
+ int quiet = 0;
+ const char *msg = NULL;
+
git_config(git_default_config);
+
+ while (1 < argc) {
+ const char *arg = argv[1];
+ if (arg[0] != '-')
+ break;
+ else if (!strcmp("-q", arg))
+ quiet = 1;
+ else if (!strcmp("-m", arg)) {
+ argc--;
+ argv++;
+ if (argc <= 1)
+ break;
+ msg = argv[1];
+ if (!*msg)
+ die("Refusing to perform update with empty message");
+ if (strchr(msg, '\n'))
+ die("Refusing to perform update with \\n in message");
+ }
+ else if (!strcmp("--", arg)) {
+ argc--;
+ argv++;
+ break;
+ }
+ else
+ die("unknown option %s", arg);
+ argc--;
+ argv++;
+ }
+
switch (argc) {
case 2:
- check_symref(argv[1]);
+ check_symref(argv[1], quiet);
break;
case 3:
- create_symref(argv[1], argv[2]);
+ create_symref(argv[1], argv[2], msg);
break;
default:
usage(git_symbolic_ref_usage);
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 182331d341..1ac613a788 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -501,6 +501,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
for (i = 1 ; i < argc; i++) {
const char *path = argv[i];
+ const char *p;
if (allow_options && *path == '-') {
if (!strcmp(path, "--")) {
@@ -616,9 +617,12 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
usage(update_index_usage);
die("unknown option %s", path);
}
- update_one(path, prefix, prefix_length);
+ p = prefix_path(prefix, prefix_length, path);
+ update_one(p, NULL, 0);
if (set_executable_bit)
- chmod_path(set_executable_bit, path);
+ chmod_path(set_executable_bit, p);
+ if (p < path || p > path + strlen(path))
+ free((char*)p);
}
if (read_from_stdin) {
struct strbuf buf;
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index b34e5987dd..5ee960bf41 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -13,7 +13,6 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
int i, delete;
delete = 0;
- setup_ident();
git_config(git_default_config);
for (i = 1; i < argc; i++) {
@@ -62,10 +61,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL);
if (!lock)
- return 1;
+ die("%s: cannot lock the ref", refname);
if (write_ref_sha1(lock, sha1, msg) < 0)
- return 1;
-
- /* write_ref_sha1 always unlocks the ref, no need to do it explicitly */
+ die("%s: cannot update the ref", refname);
return 0;
}
diff --git a/builtin.h b/builtin.h
index ae32993ce9..57e8741ff0 100644
--- a/builtin.h
+++ b/builtin.h
@@ -25,19 +25,21 @@ 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_commit_tree(int argc, const char **argv, const char *prefix);
extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
+extern int cmd_describe(int argc, const char **argv, const char *prefix);
extern int cmd_diff_files(int argc, const char **argv, const char *prefix);
extern int cmd_diff_index(int argc, const char **argv, const char *prefix);
extern int cmd_diff(int argc, const char **argv, const char *prefix);
-extern int cmd_diff_stages(int argc, const char **argv, const char *prefix);
extern int cmd_diff_tree(int argc, const char **argv, const char *prefix);
extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
extern int cmd_for_each_ref(int argc, const char **argv, const char *prefix);
extern int cmd_format_patch(int argc, const char **argv, const char *prefix);
+extern int cmd_fsck(int argc, const char **argv, const char *prefix);
extern int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix);
extern int cmd_grep(int argc, const char **argv, const char *prefix);
extern int cmd_help(int argc, const char **argv, const char *prefix);
extern int cmd_init_db(int argc, const char **argv, const char *prefix);
extern int cmd_log(int argc, const char **argv, const char *prefix);
+extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
extern int cmd_ls_tree(int argc, const char **argv, const char *prefix);
extern int cmd_mailinfo(int argc, const char **argv, const char *prefix);
@@ -53,7 +55,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
-extern int cmd_repo_config(int argc, const char **argv, const char *prefix);
+extern int cmd_config(int argc, const char **argv, const char *prefix);
extern int cmd_rerere(int argc, const char **argv, const char *prefix);
extern int cmd_rev_list(int argc, const char **argv, const char *prefix);
extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
diff --git a/cache.h b/cache.h
index a9583ff18e..c62b0b090d 100644
--- a/cache.h
+++ b/cache.h
@@ -127,7 +127,9 @@ extern int cache_errno;
#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
-extern int is_bare_git_dir(const char *dir);
+extern int is_bare_repository_cfg;
+extern int is_bare_repository(void);
+extern int is_inside_git_dir(void);
extern const char *get_git_dir(void);
extern char *get_object_directory(void);
extern char *get_refs_directory(void);
@@ -255,6 +257,7 @@ extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, uns
extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
extern int hash_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *sha1);
extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
+extern int pretend_sha1_file(void *, unsigned long, const char *, unsigned char *);
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
@@ -298,8 +301,11 @@ extern int get_sha1_hex(const char *hex, unsigned char *sha1);
extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
extern int read_ref(const char *filename, unsigned char *sha1);
extern const char *resolve_ref(const char *path, unsigned char *sha1, int, int *);
-extern int create_symref(const char *ref, const char *refs_heads_master);
-extern int validate_symref(const char *ref);
+extern int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref);
+extern int dwim_log(const char *str, int len, unsigned char *sha1, char **ref);
+
+extern int create_symref(const char *ref, const char *refs_heads_master, const char *logmsg);
+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 cache_name_compare(const char *name1, int len1, const char *name2, int len2);
@@ -315,10 +321,9 @@ int parse_date(const char *date, char *buf, int bufsize);
void datestamp(char *buf, int bufsize);
unsigned long approxidate(const char *);
-extern int setup_ident(void);
-extern void ignore_missing_committer_name();
extern const char *git_author_info(int);
extern const char *git_committer_info(int);
+extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
struct checkout {
const char *base_dir;
@@ -350,7 +355,7 @@ struct pack_window {
extern struct packed_git {
struct packed_git *next;
struct pack_window *windows;
- unsigned int *index_base;
+ uint32_t *index_base;
off_t index_size;
off_t pack_size;
int pack_fd;
@@ -399,7 +404,7 @@ extern void install_packed_git(struct packed_git *pack);
extern struct packed_git *find_sha1_pack(const unsigned char *sha1,
struct packed_git *packs);
-extern void pack_report();
+extern void pack_report(void);
extern unsigned char* use_pack(struct packed_git *, struct pack_window **, unsigned long, unsigned int *);
extern void unuse_pack(struct pack_window **);
extern struct packed_git *add_packed_git(char *, int, int);
@@ -433,7 +438,6 @@ extern char *git_log_output_encoding;
extern int copy_fd(int ifd, int ofd);
extern int read_in_full(int fd, void *buf, size_t count);
-extern void read_or_die(int fd, void *buf, size_t count);
extern int write_in_full(int fd, const void *buf, size_t count);
extern void write_or_die(int fd, const void *buf, size_t count);
extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
diff --git a/combine-diff.c b/combine-diff.c
index 29d0c9cf95..a5f2c8dd4a 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -482,11 +482,11 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
return has_interesting;
}
-static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long l1, int n)
+static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long l1, int n, unsigned long null_context)
{
l0 = sline[l0].p_lno[n];
l1 = sline[l1].p_lno[n];
- printf(" -%lu,%lu", l0, l1-l0);
+ printf(" -%lu,%lu", l0, l1-l0-null_context);
}
static int hunk_comment_line(const char *bol)
@@ -519,6 +519,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
unsigned long hunk_end;
unsigned long rlines;
const char *hunk_comment = NULL;
+ unsigned long null_context = 0;
while (lno <= cnt && !(sline[lno].flag & mark)) {
if (hunk_comment_line(sline[lno].bol))
@@ -535,10 +536,28 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
rlines = hunk_end - lno;
if (cnt < hunk_end)
rlines--; /* pointing at the last delete hunk */
+
+ if (!context) {
+ /*
+ * Even when running with --unified=0, all
+ * lines in the hunk needs to be processed in
+ * the loop below in order to show the
+ * deletion recorded in lost_head. However,
+ * we do not want to show the resulting line
+ * with all blank context markers in such a
+ * case. Compensate.
+ */
+ unsigned long j;
+ for (j = lno; j < hunk_end; j++)
+ if (!(sline[j].flag & (mark-1)))
+ null_context++;
+ rlines -= null_context;
+ }
+
fputs(c_frag, stdout);
for (i = 0; i <= num_parent; i++) putchar(combine_marker);
for (i = 0; i < num_parent; i++)
- show_parent_lno(sline, lno, hunk_end, i);
+ show_parent_lno(sline, lno, hunk_end, i, null_context);
printf(" +%lu,%lu ", lno+1, rlines);
for (i = 0; i <= num_parent; i++) putchar(combine_marker);
@@ -578,8 +597,15 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
if (cnt < lno)
break;
p_mask = 1;
- if (!(sl->flag & (mark-1)))
+ if (!(sl->flag & (mark-1))) {
+ /*
+ * This sline was here to hang the
+ * lost lines in front of it.
+ */
+ if (!context)
+ continue;
fputs(c_plain, stdout);
+ }
else
fputs(c_new, stdout);
for (j = 0; j < num_parent; j++) {
diff --git a/commit.c b/commit.c
index aa14c5adb0..8d279b0b63 100644
--- a/commit.c
+++ b/commit.c
@@ -47,7 +47,8 @@ enum cmit_fmt get_commit_format(const char *arg)
if (*arg == '=')
arg++;
for (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {
- if (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len))
+ 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;
}
@@ -464,20 +465,29 @@ static int get_one_line(const char *msg, unsigned long len)
return ret;
}
+/* High bit set, or ISO-2022-INT */
+static int non_ascii(int ch)
+{
+ ch = (ch & 0xff);
+ return ((ch & 0x80) || (ch == 0x1b));
+}
+
static int is_rfc2047_special(char ch)
{
- return ((ch & 0x80) || (ch == '=') || (ch == '?') || (ch == '_'));
+ return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_'));
}
-static int add_rfc2047(char *buf, const char *line, int len)
+static int add_rfc2047(char *buf, const char *line, int len,
+ const char *encoding)
{
char *bp = buf;
int i, needquote;
- static const char q_utf8[] = "=?utf-8?q?";
+ char q_encoding[128];
+ const char *q_encoding_fmt = "=?%s?q?";
for (i = needquote = 0; !needquote && i < len; i++) {
- unsigned ch = line[i];
- if (ch & 0x80)
+ int ch = line[i];
+ if (non_ascii(ch))
needquote++;
if ((i + 1 < len) &&
(ch == '=' && line[i+1] == '?'))
@@ -486,8 +496,11 @@ static int add_rfc2047(char *buf, const char *line, int len)
if (!needquote)
return sprintf(buf, "%.*s", len, line);
- memcpy(bp, q_utf8, sizeof(q_utf8)-1);
- bp += sizeof(q_utf8)-1;
+ i = snprintf(q_encoding, sizeof(q_encoding), q_encoding_fmt, encoding);
+ if (sizeof(q_encoding) < i)
+ die("Insanely long encoding name %s", encoding);
+ memcpy(bp, q_encoding, i);
+ bp += i;
for (i = 0; i < len; i++) {
unsigned ch = line[i] & 0xFF;
if (is_rfc2047_special(ch)) {
@@ -505,7 +518,8 @@ static int add_rfc2047(char *buf, const char *line, int len)
}
static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
- const char *line, int relative_date)
+ const char *line, int relative_date,
+ const char *encoding)
{
char *date;
int namelen;
@@ -533,7 +547,8 @@ static int add_user_info(const char *what, enum cmit_fmt fmt, char *buf,
filler = "";
strcpy(buf, "From: ");
ret = strlen(buf);
- ret += add_rfc2047(buf + ret, line, display_name_length);
+ ret += add_rfc2047(buf + ret, line, display_name_length,
+ encoding);
memcpy(buf + ret, name_tail, namelen - display_name_length);
ret += namelen - display_name_length;
buf[ret++] = '\n';
@@ -668,21 +683,18 @@ static char *replace_encoding_header(char *buf, char *encoding)
return buf;
}
-static char *logmsg_reencode(const struct commit *commit)
+static char *logmsg_reencode(const struct commit *commit,
+ char *output_encoding)
{
char *encoding;
char *out;
- char *output_encoding = (git_log_output_encoding
- ? git_log_output_encoding
- : git_commit_encoding);
+ char *utf8 = "utf-8";
- if (!output_encoding)
- output_encoding = "utf-8";
- else if (!*output_encoding)
+ if (!*output_encoding)
return NULL;
encoding = get_header(commit, "encoding");
if (!encoding)
- return NULL;
+ encoding = utf8;
if (!strcmp(encoding, output_encoding))
out = strdup(commit->buffer);
else
@@ -691,7 +703,8 @@ static char *logmsg_reencode(const struct commit *commit)
if (out)
out = replace_encoding_header(out, output_encoding);
- free(encoding);
+ if (encoding != utf8)
+ free(encoding);
if (!out)
return NULL;
return out;
@@ -711,8 +724,15 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
int parents_shown = 0;
const char *msg = commit->buffer;
int plain_non_ascii = 0;
- char *reencoded = logmsg_reencode(commit);
+ char *reencoded;
+ char *encoding;
+ encoding = (git_log_output_encoding
+ ? git_log_output_encoding
+ : git_commit_encoding);
+ if (!encoding)
+ encoding = "utf-8";
+ reencoded = logmsg_reencode(commit, encoding);
if (reencoded)
msg = reencoded;
@@ -738,7 +758,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
i + 1 < len && msg[i+1] == '\n')
in_body = 1;
}
- else if (ch & 0x80) {
+ else if (non_ascii(ch)) {
plain_non_ascii = 1;
break;
}
@@ -797,13 +817,15 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
offset += add_user_info("Author", fmt,
buf + offset,
line + 7,
- relative_date);
+ relative_date,
+ encoding);
if (!memcmp(line, "committer ", 10) &&
(fmt == CMIT_FMT_FULL || fmt == CMIT_FMT_FULLER))
offset += add_user_info("Commit", fmt,
buf + offset,
line + 10,
- relative_date);
+ relative_date,
+ encoding);
continue;
}
@@ -826,7 +848,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
int slen = strlen(subject);
memcpy(buf + offset, subject, slen);
offset += slen;
- offset += add_rfc2047(buf + offset, line, linelen);
+ offset += add_rfc2047(buf + offset, line, linelen,
+ encoding);
}
else {
memset(buf + offset, ' ', indent);
@@ -837,11 +860,17 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
if (fmt == CMIT_FMT_ONELINE)
break;
if (subject && plain_non_ascii) {
- static const char header[] =
- "Content-Type: text/plain; charset=UTF-8\n"
+ int sz;
+ char header[512];
+ const char *header_fmt =
+ "Content-Type: text/plain; charset=%s\n"
"Content-Transfer-Encoding: 8bit\n";
- memcpy(buf + offset, header, sizeof(header)-1);
- offset += sizeof(header)-1;
+ sz = snprintf(header, sizeof(header), header_fmt,
+ encoding);
+ if (sizeof(header) < sz)
+ die("Encoding name %s too long", encoding);
+ memcpy(buf + offset, header, sz);
+ offset += sz;
}
if (after_subject) {
int slen = strlen(after_subject);
diff --git a/commit.h b/commit.h
index b8e6e18a80..c73744463c 100644
--- a/commit.h
+++ b/commit.h
@@ -110,7 +110,7 @@ extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *r
extern int register_shallow(const unsigned char *sha1);
extern int unregister_shallow(const unsigned char *sha1);
extern int write_shallow_commits(int fd, int use_pack_protocol);
-extern int is_repository_shallow();
+extern int is_repository_shallow(void);
extern struct commit_list *get_shallow_commits(struct object_array *heads,
int depth, int shallow_flag, int not_shallow_flag);
diff --git a/config.c b/config.c
index 2cd0263e13..d82107124a 100644
--- a/config.c
+++ b/config.c
@@ -269,6 +269,11 @@ int git_default_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.bare")) {
+ is_bare_repository_cfg = git_config_bool(var, value);
+ return 0;
+ }
+
if (!strcmp(var, "core.ignorestat")) {
assume_unchanged = git_config_bool(var, value);
return 0;
@@ -656,6 +661,11 @@ int git_config_set_multivar(const char* key, const char* value,
goto out_free;
}
c = tolower(c);
+ } else if (c == '\n') {
+ fprintf(stderr, "invalid key (newline): %s\n", key);
+ free(store.key);
+ ret = 1;
+ goto out_free;
}
store.key[i] = c;
}
@@ -694,11 +704,9 @@ int git_config_set_multivar(const char* key, const char* value,
store.key = (char*)key;
if (!store_write_section(fd, key) ||
- !store_write_pair(fd, key, value)) {
- ret = write_error();
- goto out_free;
- }
- } else{
+ !store_write_pair(fd, key, value))
+ goto write_err_out;
+ } else {
struct stat st;
char* contents;
int i, copy_begin, copy_end, new_line = 0;
@@ -777,31 +785,33 @@ int git_config_set_multivar(const char* key, const char* value,
/* write the first part of the config */
if (copy_end > copy_begin) {
- write_in_full(fd, contents + copy_begin,
- copy_end - copy_begin);
- if (new_line)
- write_in_full(fd, "\n", 1);
+ if (write_in_full(fd, contents + copy_begin,
+ copy_end - copy_begin) <
+ copy_end - copy_begin)
+ goto write_err_out;
+ if (new_line &&
+ write_in_full(fd, "\n", 1) != 1)
+ goto write_err_out;
}
copy_begin = store.offset[i];
}
/* write the pair (value == NULL means unset) */
if (value != NULL) {
- if (store.state == START)
- if (!store_write_section(fd, key)) {
- ret = write_error();
- goto out_free;
- }
- if (!store_write_pair(fd, key, value)) {
- ret = write_error();
- goto out_free;
+ if (store.state == START) {
+ if (!store_write_section(fd, key))
+ goto write_err_out;
}
+ if (!store_write_pair(fd, key, value))
+ goto write_err_out;
}
/* write the rest of the config */
if (copy_begin < st.st_size)
- write_in_full(fd, contents + copy_begin,
- st.st_size - copy_begin);
+ if (write_in_full(fd, contents + copy_begin,
+ st.st_size - copy_begin) <
+ st.st_size - copy_begin)
+ goto write_err_out;
munmap(contents, st.st_size);
unlink(config_filename);
@@ -824,6 +834,11 @@ out_free:
free(lock_file);
}
return ret;
+
+write_err_out:
+ ret = write_error();
+ goto out_free;
+
}
int git_config_rename_section(const char *old_name, const char *new_name)
@@ -881,7 +896,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
if (buf[i] != old_name[j++])
break;
}
- if (buf[i] == ']') {
+ if (buf[i] == ']' && old_name[j] == 0) {
/* old_name matches */
ret++;
store.baselen = strlen(new_name);
diff --git a/connect.c b/connect.c
index 66daa11a57..78448889da 100644
--- a/connect.c
+++ b/connect.c
@@ -529,7 +529,7 @@ static void git_tcp_connect(int fd[2], char *host)
int sockfd = git_tcp_connect_sock(host);
fd[0] = sockfd;
- fd[1] = sockfd;
+ fd[1] = dup(sockfd);
}
diff --git a/contrib/blameview/README b/contrib/blameview/README
new file mode 100644
index 0000000000..50a6f67fd6
--- /dev/null
+++ b/contrib/blameview/README
@@ -0,0 +1,10 @@
+This is a sample program to use 'git-blame --incremental', based
+on this message.
+
+From: Jeff King <peff@peff.net>
+Subject: Re: More precise tag following
+To: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: git@vger.kernel.org
+Date: Sat, 27 Jan 2007 18:52:38 -0500
+Message-ID: <20070127235238.GA28706@coredump.intra.peff.net>
+
diff --git a/contrib/blameview/blameview.perl b/contrib/blameview/blameview.perl
new file mode 100755
index 0000000000..a9a509febb
--- /dev/null
+++ b/contrib/blameview/blameview.perl
@@ -0,0 +1,155 @@
+#!/usr/bin/perl
+
+use Gtk2 -init;
+use Gtk2::SimpleList;
+
+my $hash;
+my $fn;
+if ( @ARGV == 1 ) {
+ $hash = "HEAD";
+ $fn = shift;
+} elsif ( @ARGV == 2 ) {
+ $hash = shift;
+ $fn = shift;
+} else {
+ die "Usage blameview [<rev>] <filename>";
+}
+
+Gtk2::Rc->parse_string(<<'EOS');
+style "treeview_style"
+{
+ GtkTreeView::vertical-separator = 0
+}
+class "GtkTreeView" style "treeview_style"
+EOS
+
+my $window = Gtk2::Window->new('toplevel');
+$window->signal_connect(destroy => sub { Gtk2->main_quit });
+my $vpan = Gtk2::VPaned->new();
+$window->add($vpan);
+my $scrolled_window = Gtk2::ScrolledWindow->new;
+$vpan->pack1($scrolled_window, 1, 1);
+my $fileview = Gtk2::SimpleList->new(
+ 'Commit' => 'text',
+ 'FileLine' => 'text',
+ 'Data' => 'text'
+);
+$scrolled_window->add($fileview);
+$fileview->get_column(0)->set_spacing(0);
+$fileview->set_size_request(1024, 768);
+$fileview->set_rules_hint(1);
+$fileview->signal_connect (row_activated => sub {
+ my ($sl, $path, $column) = @_;
+ my $row_ref = $sl->get_row_data_from_path ($path);
+ system("blameview @$row_ref[0] $fn &");
+ });
+
+my $commitwindow = Gtk2::ScrolledWindow->new();
+$commitwindow->set_policy ('GTK_POLICY_AUTOMATIC','GTK_POLICY_AUTOMATIC');
+$vpan->pack2($commitwindow, 1, 1);
+my $commit_text = Gtk2::TextView->new();
+my $commit_buffer = Gtk2::TextBuffer->new();
+$commit_text->set_buffer($commit_buffer);
+$commitwindow->add($commit_text);
+
+$fileview->signal_connect (cursor_changed => sub {
+ my ($sl) = @_;
+ my ($path, $focus_column) = $sl->get_cursor();
+ my $row_ref = $sl->get_row_data_from_path ($path);
+ my $c_fh;
+ open($c_fh, '-|', "git cat-file commit @$row_ref[0]")
+ or die "unable to find commit @$row_ref[0]";
+ my @buffer = <$c_fh>;
+ $commit_buffer->set_text("@buffer");
+ close($c_fh);
+ });
+
+my $fh;
+open($fh, '-|', "git cat-file blob $hash:$fn")
+ or die "unable to open $fn: $!";
+
+while(<$fh>) {
+ chomp;
+ $fileview->{data}->[$.] = ['HEAD', "$fn:$.", $_];
+}
+
+my $blame;
+open($blame, '-|', qw(git blame --incremental --), $fn, $hash)
+ or die "cannot start git-blame $fn";
+
+Glib::IO->add_watch(fileno($blame), 'in', \&read_blame_line);
+
+$window->show_all;
+Gtk2->main;
+exit 0;
+
+my %commitinfo = ();
+
+sub flush_blame_line {
+ my ($attr) = @_;
+
+ return unless defined $attr;
+
+ my ($commit, $s_lno, $lno, $cnt) =
+ @{$attr}{qw(COMMIT S_LNO LNO CNT)};
+
+ my ($filename, $author, $author_time, $author_tz) =
+ @{$commitinfo{$commit}}{qw(FILENAME AUTHOR AUTHOR-TIME AUTHOR-TZ)};
+ my $info = $author . ' ' . format_time($author_time, $author_tz);
+
+ for(my $i = 0; $i < $cnt; $i++) {
+ @{$fileview->{data}->[$lno+$i-1]}[0,1,2] =
+ (substr($commit, 0, 8), $filename . ':' . ($s_lno+$i));
+ }
+}
+
+my $buf;
+my $current;
+sub read_blame_line {
+
+ my $r = sysread($blame, $buf, 1024, length($buf));
+ die "I/O error" unless defined $r;
+
+ if ($r == 0) {
+ flush_blame_line($current);
+ $current = undef;
+ return 0;
+ }
+
+ while ($buf =~ s/([^\n]*)\n//) {
+ my $line = $1;
+
+ if (($commit, $s_lno, $lno, $cnt) =
+ ($line =~ /^([0-9a-f]{40}) (\d+) (\d+) (\d+)$/)) {
+ flush_blame_line($current);
+ $current = +{
+ COMMIT => $1,
+ S_LNO => $2,
+ LNO => $3,
+ CNT => $4,
+ };
+ next;
+ }
+
+ # extended attribute values
+ if ($line =~ /^(author|author-mail|author-time|author-tz|committer|committer-mail|committer-time|committer-tz|summary|filename) (.*)$/) {
+ my $commit = $current->{COMMIT};
+ $commitinfo{$commit}{uc($1)} = $2;
+ next;
+ }
+ }
+ return 1;
+}
+
+sub format_time {
+ my $time = shift;
+ my $tz = shift;
+
+ my $minutes = $tz < 0 ? 0-$tz : $tz;
+ $minutes = ($minutes / 100)*60 + ($minutes % 100);
+ $minutes = $tz < 0 ? 0-$minutes : $minutes;
+ $time += $minutes * 60;
+ my @t = gmtime($time);
+ return sprintf('%04d-%02d-%02d %02d:%02d:%02d %s',
+ $t[5] + 1900, @t[4,3,2,1,0], $tz);
+}
diff --git a/contrib/colordiff/README b/contrib/colordiff/README
deleted file mode 100644
index 2678fdf9c2..0000000000
--- a/contrib/colordiff/README
+++ /dev/null
@@ -1,2 +0,0 @@
-This is "colordiff" (http://colordiff.sourceforge.net/) by Dave
-Ewart <davee@sungate.co.uk>, modified specifically for git.
diff --git a/contrib/colordiff/colordiff.perl b/contrib/colordiff/colordiff.perl
deleted file mode 100755
index 9566a765ef..0000000000
--- a/contrib/colordiff/colordiff.perl
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/perl -w
-#
-# $Id: colordiff.pl,v 1.4.2.10 2004/01/04 15:02:59 daveewart Exp $
-
-########################################################################
-# #
-# ColorDiff - a wrapper/replacment for 'diff' producing #
-# colourful output #
-# #
-# Copyright (C)2002-2004 Dave Ewart (davee@sungate.co.uk) #
-# #
-########################################################################
-# #
-# 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 of the License, 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. #
-# #
-########################################################################
-
-use strict;
-use Getopt::Long qw(:config pass_through);
-use IPC::Open2;
-
-my $app_name = 'colordiff';
-my $version = '1.0.4';
-my $author = 'Dave Ewart';
-my $author_email = 'davee@sungate.co.uk';
-my $app_www = 'http://colordiff.sourceforge.net/';
-my $copyright = '(C)2002-2004';
-my $show_banner = 1;
-
-# ANSI sequences for colours
-my %colour;
-$colour{white} = "\033[1;37m";
-$colour{yellow} = "\033[1;33m";
-$colour{green} = "\033[1;32m";
-$colour{blue} = "\033[1;34m";
-$colour{cyan} = "\033[1;36m";
-$colour{red} = "\033[1;31m";
-$colour{magenta} = "\033[1;35m";
-$colour{black} = "\033[1;30m";
-$colour{darkwhite} = "\033[0;37m";
-$colour{darkyellow} = "\033[0;33m";
-$colour{darkgreen} = "\033[0;32m";
-$colour{darkblue} = "\033[0;34m";
-$colour{darkcyan} = "\033[0;36m";
-$colour{darkred} = "\033[0;31m";
-$colour{darkmagenta} = "\033[0;35m";
-$colour{darkblack} = "\033[0;30m";
-$colour{OFF} = "\033[0;0m";
-
-# Default colours if /etc/colordiffrc or ~/.colordiffrc do not exist
-my $plain_text = $colour{OFF};
-my $file_old = $colour{red};
-my $file_new = $colour{blue};
-my $diff_stuff = $colour{magenta};
-
-# Locations for personal and system-wide colour configurations
-my $HOME = $ENV{HOME};
-my $etcdir = '/etc';
-
-my ($setting, $value);
-my @config_files = ("$etcdir/colordiffrc", "$HOME/.colordiffrc");
-my $config_file;
-
-foreach $config_file (@config_files) {
- if (open(COLORDIFFRC, "<$config_file")) {
- while (<COLORDIFFRC>) {
- chop;
- next if (/^#/ || /^$/);
- s/\s+//g;
- ($setting, $value) = split ('=');
- if ($setting eq 'banner') {
- if ($value eq 'no') {
- $show_banner = 0;
- }
- next;
- }
- if (!defined $colour{$value}) {
- print "Invalid colour specification ($value) in $config_file\n";
- next;
- }
- if ($setting eq 'plain') {
- $plain_text = $colour{$value};
- }
- elsif ($setting eq 'oldtext') {
- $file_old = $colour{$value};
- }
- elsif ($setting eq 'newtext') {
- $file_new = $colour{$value};
- }
- elsif ($setting eq 'diffstuff') {
- $diff_stuff = $colour{$value};
- }
- else {
- print "Unknown option in $etcdir/colordiffrc: $setting\n";
- }
- }
- close COLORDIFFRC;
- }
-}
-
-# colordiff specific options here. Need to pre-declare if using variables
-GetOptions(
- "no-banner" => sub { $show_banner = 0 },
- "plain-text=s" => \&set_color,
- "file-old=s" => \&set_color,
- "file-new=s" => \&set_color,
- "diff-stuff=s" => \&set_color
-);
-
-if ($show_banner == 1) {
- print STDERR "$app_name $version ($app_www)\n";
- print STDERR "$copyright $author, $author_email\n\n";
-}
-
-if (defined $ARGV[0]) {
- # More reliable way of pulling in arguments
- open2(\*INPUTSTREAM, undef, "git", "diff", @ARGV);
-}
-else {
- *INPUTSTREAM = \*STDIN;
-}
-
-my $record;
-my $nrecs = 0;
-my $inside_file_old = 1;
-my $nparents = undef;
-
-while (<INPUTSTREAM>) {
- $nrecs++;
- if (/^(\@\@+) -[-+0-9, ]+ \1/) {
- print "$diff_stuff";
- $nparents = length($1) - 1;
- }
- elsif (/^diff -/ || /^index / ||
- /^old mode / || /^new mode / ||
- /^deleted file mode / || /^new file mode / ||
- /^similarity index / || /^dissimilarity index / ||
- /^copy from / || /^copy to / ||
- /^rename from / || /^rename to /) {
- $nparents = undef;
- print "$diff_stuff";
- }
- elsif (defined $nparents) {
- if ($nparents == 1) {
- if (/^\+/) {
- print $file_new;
- }
- elsif (/^-/) {
- print $file_old;
- }
- else {
- print $plain_text;
- }
- }
- elsif (/^ {$nparents}/) {
- print "$plain_text";
- }
- elsif (/^[+ ]{$nparents}/) {
- print "$file_new";
- }
- elsif (/^[- ]{$nparents}/) {
- print "$file_old";
- }
- else {
- print $plain_text;
- }
- }
- elsif (/^--- / || /^\+\+\+ /) {
- print $diff_stuff;
- }
- else {
- print "$plain_text";
- }
- s/$/$colour{OFF}/;
- print "$_";
-}
-close INPUTSTREAM;
-
-sub set_color {
- my ($type, $color) = @_;
-
- $type =~ s/-/_/;
- eval "\$$type = \$colour{$color}";
-}
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7c7520ea29..7c03403484 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1,7 +1,7 @@
#
# bash completion support for core Git.
#
-# Copyright (C) 2006 Shawn Pearce
+# Copyright (C) 2006,2007 Shawn Pearce
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
#
# The contained completion routines provide support for completing:
@@ -61,6 +61,25 @@ __git_ps1 ()
fi
}
+__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
+}
+
__git_heads ()
{
local cmd i is_hash=y dir="$(__gitdir "$1")"
@@ -145,7 +164,7 @@ __git_remotes ()
echo ${i#$d/remotes/}
done
[ "$ngoff" ] && shopt -u nullglob
- for i in $(git --git-dir="$d" repo-config --list); do
+ for i in $(git --git-dir="$d" config --list); do
case "$i" in
remote.*.url=*)
i="${i#remote.}"
@@ -200,7 +219,7 @@ __git_complete_file ()
-- "$cur"))
;;
*)
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
;;
esac
}
@@ -212,15 +231,18 @@ __git_complete_revlist ()
*...*)
pfx="${cur%...*}..."
cur="${cur#*...}"
- COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
;;
*..*)
pfx="${cur%..*}.."
cur="${cur#*..}"
- COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ ;;
+ *.)
+ __gitcomp "$cur."
;;
*)
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
;;
esac
}
@@ -235,15 +257,26 @@ __git_commands ()
for i in $(git help -a|egrep '^ ')
do
case $i in
+ add--interactive) : plumbing;;
+ applymbox) : ask gittus;;
+ applypatch) : ask gittus;;
+ archimport) : import;;
+ cat-file) : plumbing;;
check-ref-format) : plumbing;;
commit-tree) : plumbing;;
convert-objects) : plumbing;;
+ cvsexportcommit) : export;;
+ cvsimport) : import;;
cvsserver) : daemon;;
daemon) : daemon;;
+ fast-import) : import;;
+ fsck-objects) : plumbing;;
fetch-pack) : plumbing;;
+ fmt-merge-msg) : plumbing;;
hash-object) : plumbing;;
http-*) : transport;;
index-pack) : plumbing;;
+ init-db) : deprecated;;
local-fetch) : plumbing;;
mailinfo) : plumbing;;
mailsplit) : plumbing;;
@@ -256,8 +289,13 @@ __git_commands ()
parse-remote) : plumbing;;
patch-id) : plumbing;;
peek-remote) : plumbing;;
+ prune) : plumbing;;
+ prune-packed) : plumbing;;
+ quiltimport) : import;;
read-tree) : plumbing;;
receive-pack) : plumbing;;
+ reflog) : plumbing;;
+ repo-config) : plumbing;;
rerere) : plumbing;;
rev-list) : plumbing;;
rev-parse) : plumbing;;
@@ -268,14 +306,19 @@ __git_commands ()
show-index) : plumbing;;
ssh-*) : transport;;
stripspace) : plumbing;;
+ svn) : import export;;
+ svnimport) : import;;
symbolic-ref) : plumbing;;
+ tar-tree) : deprecated;;
unpack-file) : plumbing;;
unpack-objects) : plumbing;;
+ update-index) : plumbing;;
update-ref) : plumbing;;
update-server-info) : daemon;;
upload-archive) : plumbing;;
upload-pack) : plumbing;;
write-tree) : plumbing;;
+ verify-tag) : plumbing;;
*) echo $i;;
esac
done
@@ -286,7 +329,7 @@ __git_commandlist="$(__git_commands 2>/dev/null)"
__git_aliases ()
{
local i IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" repo-config --list); do
+ for i in $(git --git-dir="$(__gitdir)" config --list); do
case "$i" in
alias.*)
i="${i#alias.}"
@@ -299,7 +342,7 @@ __git_aliases ()
__git_aliased_command ()
{
local word cmdline=$(git --git-dir="$(__gitdir)" \
- repo-config --get "alias.$1")
+ config --get "alias.$1")
for word in $cmdline; do
if [ "${word##-*}" ]; then
echo $word
@@ -314,22 +357,19 @@ _git_am ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
if [ -d .dotest ]; then
- COMPREPLY=($(compgen -W "
- --skip --resolved
- " -- "$cur"))
+ __gitcomp "--skip --resolved"
return
fi
case "$cur" in
--whitespace=*)
- COMPREPLY=($(compgen -W "$__git_whitespacelist" \
- -- "${cur##--whitespace=}"))
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--signoff --utf8 --binary --3way --interactive
--whitespace=
- " -- "$cur"))
+ "
return
esac
COMPREPLY=()
@@ -340,48 +380,74 @@ _git_apply ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--whitespace=*)
- COMPREPLY=($(compgen -W "$__git_whitespacelist" \
- -- "${cur##--whitespace=}"))
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--stat --numstat --summary --check --index
--cached --index-info --reverse --reject --unidiff-zero
--apply --no-add --exclude=
--whitespace= --inaccurate-eof --verbose
- " -- "$cur"))
+ "
return
esac
COMPREPLY=()
}
-_git_branch ()
+_git_add ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "-l -f -d -D $(__git_refs)" -- "$cur"))
+ case "$cur" in
+ --*)
+ __gitcomp "--interactive"
+ return
+ esac
+ COMPREPLY=()
}
-_git_cat_file ()
+_git_bisect ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- case "${COMP_WORDS[0]},$COMP_CWORD" in
- git-cat-file*,1)
- COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
- ;;
- git,2)
- COMPREPLY=($(compgen -W "-p -t blob tree commit tag" -- "$cur"))
+ 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
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ __gitcomp "start bad good reset visualize replay log"
+ return
+ fi
+
+ case "$command" in
+ bad|good|reset)
+ __gitcomp "$(__git_refs)"
;;
*)
- __git_complete_file
+ COMPREPLY=()
;;
esac
}
+_git_branch ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
_git_checkout ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "-l -b $(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
+}
+
+_git_cherry ()
+{
+ __gitcomp "$(__git_refs)"
}
_git_cherry_pick ()
@@ -389,12 +455,10 @@ _git_cherry_pick ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- COMPREPLY=($(compgen -W "
- --edit --no-commit
- " -- "$cur"))
+ __gitcomp "--edit --no-commit"
;;
*)
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
;;
esac
}
@@ -404,10 +468,10 @@ _git_commit ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--all --author= --signoff --verify --no-verify
--edit --amend --include --only
- " -- "$cur"))
+ "
return
esac
COMPREPLY=()
@@ -420,8 +484,7 @@ _git_diff ()
_git_diff_tree ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "-r -p -M $(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
}
_git_fetch ()
@@ -430,16 +493,15 @@ _git_fetch ()
case "${COMP_WORDS[0]},$COMP_CWORD" in
git-fetch*,1)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
git,2)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
*)
case "$cur" in
*:*)
- cur="${cur#*:}"
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)" "" "${cur#*:}"
;;
*)
local remote
@@ -447,7 +509,7 @@ _git_fetch ()
git-fetch) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- COMPREPLY=($(compgen -W "$(__git_refs2 "$remote")" -- "$cur"))
+ __gitcomp "$(__git_refs2 "$remote")"
;;
esac
;;
@@ -459,7 +521,7 @@ _git_format_patch ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--stdout --attach --thread
--output-directory
--numbered --start-number
@@ -467,17 +529,29 @@ _git_format_patch ()
--signoff
--in-reply-to=
--full-index --binary
- " -- "$cur"))
+ --not --all
+ "
return
;;
esac
__git_complete_revlist
}
-_git_ls_remote ()
+_git_gc ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ case "$cur" in
+ --*)
+ __gitcomp "--prune"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_ls_remote ()
+{
+ __gitcomp "$(__git_remotes)"
}
_git_ls_tree ()
@@ -490,13 +564,13 @@ _git_log ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--pretty=*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
oneline short medium full fuller email raw
- " -- "${cur##--pretty=}"))
+ " "" "${cur##--pretty=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--max-count= --max-age= --since= --after=
--min-age= --before= --until=
--root --not --topo-order --date-order
@@ -506,7 +580,8 @@ _git_log ()
--author= --committer= --grep=
--all-match
--pretty= --name-status --name-only
- " -- "$cur"))
+ --not --all
+ "
return
;;
esac
@@ -518,34 +593,31 @@ _git_merge ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${COMP_WORDS[COMP_CWORD-1]}" in
-s|--strategy)
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
+ __gitcomp "$(__git_merge_strategies)"
return
esac
case "$cur" in
--strategy=*)
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
- -- "${cur##--strategy=}"))
+ __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--no-commit --no-summary --squash --strategy
- " -- "$cur"))
+ "
return
esac
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
}
_git_merge_base ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
}
_git_name_rev ()
{
- local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "--tags --all --stdin" -- "$cur"))
+ __gitcomp "--tags --all --stdin"
}
_git_pull ()
@@ -554,10 +626,10 @@ _git_pull ()
case "${COMP_WORDS[0]},$COMP_CWORD" in
git-pull*,1)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
git,2)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
*)
local remote
@@ -565,7 +637,7 @@ _git_pull ()
git-pull) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
+ __gitcomp "$(__git_refs "$remote")"
;;
esac
}
@@ -576,10 +648,10 @@ _git_push ()
case "${COMP_WORDS[0]},$COMP_CWORD" in
git-push*,1)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
git,2)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
;;
*)
case "$cur" in
@@ -589,11 +661,10 @@ _git_push ()
git-push) remote="${COMP_WORDS[1]}" ;;
git) remote="${COMP_WORDS[2]}" ;;
esac
- cur="${cur#*:}"
- COMPREPLY=($(compgen -W "$(__git_refs "$remote")" -- "$cur"))
+ __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
;;
*)
- COMPREPLY=($(compgen -W "$(__git_refs2)" -- "$cur"))
+ __gitcomp "$(__git_refs2)"
;;
esac
;;
@@ -603,58 +674,67 @@ _git_push ()
_git_rebase ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- if [ -d .dotest ]; then
- COMPREPLY=($(compgen -W "
- --continue --skip --abort
- " -- "$cur"))
+ if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
+ __gitcomp "--continue --skip --abort"
return
fi
case "${COMP_WORDS[COMP_CWORD-1]}" in
-s|--strategy)
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" -- "$cur"))
+ __gitcomp "$(__git_merge_strategies)"
return
esac
case "$cur" in
--strategy=*)
- COMPREPLY=($(compgen -W "$(__git_merge_strategies)" \
- -- "${cur##--strategy=}"))
+ __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "
- --onto --merge --strategy
- " -- "$cur"))
+ __gitcomp "--onto --merge --strategy"
return
esac
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
}
-_git_repo_config ()
+_git_config ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
local prv="${COMP_WORDS[COMP_CWORD-1]}"
case "$prv" in
branch.*.remote)
- COMPREPLY=($(compgen -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)"
return
;;
branch.*.merge)
- COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+ __gitcomp "$(__git_refs)"
return
;;
remote.*.fetch)
local remote="${prv#remote.}"
remote="${remote%.fetch}"
- COMPREPLY=($(compgen -W "$(__git_refs_remotes "$remote")" \
- -- "$cur"))
+ __gitcomp "$(__git_refs_remotes "$remote")"
return
;;
remote.*.push)
local remote="${prv#remote.}"
remote="${remote%.push}"
- COMPREPLY=($(compgen -W "$(git --git-dir="$(__gitdir)" \
+ __gitcomp "$(git --git-dir="$(__gitdir)" \
for-each-ref --format='%(refname):%(refname)' \
- refs/heads)" -- "$cur"))
+ refs/heads)"
+ return
+ ;;
+ pull.twohead|pull.octopus)
+ __gitcomp "$(__git_merge_strategies)"
+ return
+ ;;
+ color.branch|color.diff|color.status)
+ __gitcomp "always never auto"
+ return
+ ;;
+ color.*.*)
+ __gitcomp "
+ black red green yellow blue magenta cyan white
+ bold dim ul blink reverse
+ "
return
;;
*.*)
@@ -664,41 +744,39 @@ _git_repo_config ()
esac
case "$cur" in
--*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
--global --list --replace-all
--get --get-all --get-regexp
- --unset --unset-all
- " -- "$cur"))
+ --add --unset --unset-all
+ "
return
;;
branch.*.*)
local pfx="${cur%.*}."
cur="${cur##*.}"
- COMPREPLY=($(compgen -P "$pfx" -W "remote merge" -- "$cur"))
+ __gitcomp "remote merge" "$pfx" "$cur"
return
;;
branch.*)
local pfx="${cur%.*}."
cur="${cur#*.}"
- COMPREPLY=($(compgen -P "$pfx" -S . \
- -W "$(__git_heads)" -- "$cur"))
+ __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
return
;;
remote.*.*)
local pfx="${cur%.*}."
cur="${cur##*.}"
- COMPREPLY=($(compgen -P "$pfx" -W "url fetch push" -- "$cur"))
+ __gitcomp "url fetch push" "$pfx" "$cur"
return
;;
remote.*)
local pfx="${cur%.*}."
cur="${cur#*.}"
- COMPREPLY=($(compgen -P "$pfx" -S . \
- -W "$(__git_remotes)" -- "$cur"))
+ __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
return
;;
esac
- COMPREPLY=($(compgen -W "
+ __gitcomp "
apply.whitespace
core.fileMode
core.gitProxy
@@ -710,47 +788,105 @@ _git_repo_config ()
core.warnAmbiguousRefs
core.compression
core.legacyHeaders
- i18n.commitEncoding
- i18n.logOutputEncoding
- diff.color
+ core.packedGitWindowSize
+ core.packedGitLimit
+ color.branch
+ color.branch.current
+ color.branch.local
+ color.branch.remote
+ color.branch.plain
color.diff
- diff.renameLimit
- diff.renames
- pager.color
+ color.diff.plain
+ color.diff.meta
+ color.diff.frag
+ color.diff.old
+ color.diff.new
+ color.diff.commit
+ color.diff.whitespace
color.pager
- status.color
color.status
- log.showroot
- show.difftree
- showbranch.default
- whatchanged.difftree
+ color.status.header
+ color.status.added
+ color.status.changed
+ color.status.untracked
+ diff.renameLimit
+ diff.renames
+ fetch.unpackLimit
+ format.headers
+ gitcvs.enabled
+ gitcvs.logfile
+ gc.reflogexpire
+ gc.reflogexpireunreachable
+ gc.rerereresolved
+ gc.rerereunresolved
http.sslVerify
http.sslCert
http.sslKey
http.sslCAInfo
http.sslCAPath
http.maxRequests
- http.lowSpeedLimit http.lowSpeedTime
+ http.lowSpeedLimit
+ http.lowSpeedTime
http.noEPSV
+ i18n.commitEncoding
+ i18n.logOutputEncoding
+ log.showroot
+ merge.summary
+ merge.verbosity
pack.window
+ pull.octopus
+ pull.twohead
repack.useDeltaBaseOffset
- pull.octopus pull.twohead
- merge.summary
+ show.difftree
+ showbranch.default
+ tar.umask
+ transfer.unpackLimit
receive.unpackLimit
receive.denyNonFastForwards
- user.name user.email
- tar.umask
- gitcvs.enabled
- gitcvs.logfile
+ user.name
+ user.email
+ user.signingkey
+ whatchanged.difftree
branch. remote.
- " -- "$cur"))
+ "
+}
+
+_git_remote ()
+{
+ local i c=1 command
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ add|show|prune) command="$i"; break ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ __gitcomp "add show prune"
+ return
+ fi
+
+ case "$command" in
+ show|prune)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
}
_git_reset ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- local opt="--mixed --hard --soft"
- COMPREPLY=($(compgen -W "$opt $(__git_refs)" -- "$cur"))
+ case "$cur" in
+ --*)
+ __gitcomp "--mixed --hard --soft"
+ return
+ ;;
+ esac
+ __gitcomp "$(__git_refs)"
}
_git_show ()
@@ -758,13 +894,13 @@ _git_show ()
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
--pretty=*)
- COMPREPLY=($(compgen -W "
+ __gitcomp "
oneline short medium full fuller email raw
- " -- "${cur##--pretty=}"))
+ " "" "${cur##--pretty=}"
return
;;
--*)
- COMPREPLY=($(compgen -W "--pretty=" -- "$cur"))
+ __gitcomp "--pretty="
return
;;
esac
@@ -787,12 +923,12 @@ _git ()
done
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
- COMPREPLY=($(compgen -W "
- --git-dir= --version --exec-path
- $(__git_commands)
- $(__git_aliases)
- " -- "${COMP_WORDS[COMP_CWORD]}"))
- return;
+ case "${COMP_WORDS[COMP_CWORD]}" in
+ --*=*) COMPREPLY=() ;;
+ --*) __gitcomp "--git-dir= --bare --version --exec-path" ;;
+ *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+ esac
+ return
fi
local expansion=$(__git_aliased_command "$command")
@@ -800,16 +936,20 @@ _git ()
case "$command" in
am) _git_am ;;
+ add) _git_add ;;
apply) _git_apply ;;
+ bisect) _git_bisect ;;
branch) _git_branch ;;
- cat-file) _git_cat_file ;;
checkout) _git_checkout ;;
+ cherry) _git_cherry ;;
cherry-pick) _git_cherry_pick ;;
commit) _git_commit ;;
+ config) _git_config ;;
diff) _git_diff ;;
diff-tree) _git_diff_tree ;;
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
+ gc) _git_gc ;;
log) _git_log ;;
ls-remote) _git_ls_remote ;;
ls-tree) _git_ls_tree ;;
@@ -819,7 +959,7 @@ _git ()
pull) _git_pull ;;
push) _git_push ;;
rebase) _git_rebase ;;
- repo-config) _git_repo_config ;;
+ remote) _git_remote ;;
reset) _git_reset ;;
show) _git_show ;;
show-branch) _git_log ;;
@@ -831,33 +971,42 @@ _git ()
_gitk ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
- COMPREPLY=($(compgen -W "--all $(__git_refs)" -- "$cur"))
+ case "$cur" in
+ --*)
+ __gitcomp "--not --all"
+ return
+ ;;
+ esac
+ __git_complete_revlist
}
complete -o default -o nospace -F _git git
-complete -o default -F _gitk gitk
-complete -o default -F _git_am git-am
-complete -o default -F _git_apply git-apply
-complete -o default -F _git_branch git-branch
-complete -o default -o nospace -F _git_cat_file git-cat-file
-complete -o default -F _git_checkout git-checkout
-complete -o default -F _git_cherry_pick git-cherry-pick
-complete -o default -F _git_commit git-commit
+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_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_diff git-diff
-complete -o default -F _git_diff_tree git-diff-tree
+complete -o default -o nospace -F _git_diff_tree git-diff-tree
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 -F _git_ls_remote git-ls-remote
+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 -F _git_merge git-merge
-complete -o default -F _git_merge_base git-merge-base
-complete -o default -F _git_name_rev git-name-rev
+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 -F _git_rebase git-rebase
-complete -o default -F _git_repo_config git-repo-config
-complete -o default -F _git_reset git-reset
+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_show git-show
complete -o default -o nospace -F _git_log git-show-branch
complete -o default -o nospace -F _git_log git-whatchanged
@@ -867,19 +1016,20 @@ complete -o default -o nospace -F _git_log git-whatchanged
# included the '.exe' suffix.
#
if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-complete -o default -F _git_apply git-apply.exe
+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 -F _git_branch git-branch.exe
-complete -o default -o nospace -F _git_cat_file git-cat-file.exe
+complete -o default -o nospace -F _git_branch git-branch.exe
+complete -o default -o nospace -F _git_cherry git-cherry.exe
complete -o default -o nospace -F _git_diff git-diff.exe
complete -o default -o nospace -F _git_diff_tree git-diff-tree.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 -F _git_merge_base git-merge-base.exe
-complete -o default -F _git_name_rev git-name-rev.exe
+complete -o default -o nospace -F _git_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 -F _git_repo_config git-repo-config
+complete -o default -o nospace -F _git_config git-config
complete -o default -o nospace -F _git_show git-show.exe
complete -o default -o nospace -F _git_log git-show-branch.exe
complete -o default -o nospace -F _git_log git-whatchanged.exe
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
new file mode 100644
index 0000000000..64ad50b327
--- /dev/null
+++ b/contrib/emacs/git-blame.el
@@ -0,0 +1,380 @@
+;;; git-blame.el --- Minor mode for incremental blame for Git -*- coding: utf-8 -*-
+;;
+;; Copyright (C) 2007 David KÃ¥gedal
+;;
+;; Authors: David KÃ¥gedal <davidk@lysator.liu.se>
+;; Created: 31 Jan 2007
+;; Message-ID: <87iren2vqx.fsf@morpheus.local>
+;; License: GPL
+;; Keywords: git, version control, release management
+;;
+;; Compatibility: Emacs21
+
+
+;; This file is *NOT* part of GNU Emacs.
+;; This file is distributed under the same terms as GNU Emacs.
+
+;; 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 of
+;; the License, 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., 59 Temple Place, Suite 330, Boston,
+;; MA 02111-1307 USA
+
+;; http://www.fsf.org/copyleft/gpl.html
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Commentary:
+;;
+;; Here is an Emacs implementation of incremental git-blame. When you
+;; turn it on while viewing a file, the editor buffer will be updated by
+;; setting the background of individual lines to a color that reflects
+;; which commit it comes from. And when you move around the buffer, a
+;; one-line summary will be shown in the echo area.
+
+;;; Installation:
+;;
+;; To use this package, put it somewhere in `load-path' (or add
+;; directory with git-blame.el to `load-path'), and add the following
+;; line to your .emacs:
+;;
+;; (require 'git-blame)
+;;
+;; If you do not want to load this package before it is necessary, you
+;; can make use of the `autoload' feature, e.g. by adding to your .emacs
+;; the following lines
+;;
+;; (autoload 'git-blame-mode "git-blame"
+;; "Minor mode for incremental blame for Git." t)
+;;
+;; Then first use of `M-x git-blame-mode' would load the package.
+
+;;; Compatibility:
+;;
+;; It requires GNU Emacs 21. If you'are using Emacs 20, try
+;; changing this:
+;;
+;; (overlay-put ovl 'face (list :background
+;; (cdr (assq 'color (cddddr info)))))
+;;
+;; to
+;;
+;; (overlay-put ovl 'face (cons 'background-color
+;; (cdr (assq 'color (cddddr info)))))
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;;; Code:
+
+(require 'cl) ; to use `push', `pop'
+
+(defun color-scale (l)
+ (let* ((colors ())
+ r g b)
+ (setq r l)
+ (while r
+ (setq g l)
+ (while g
+ (setq b l)
+ (while b
+ (push (concat "#" (car r) (car g) (car b)) colors)
+ (pop b))
+ (pop g))
+ (pop r))
+ colors))
+
+(defvar git-blame-dark-colors
+ (color-scale '("0c" "04" "24" "1c" "2c" "34" "14" "3c")))
+
+(defvar git-blame-light-colors
+ (color-scale '("c4" "d4" "cc" "dc" "f4" "e4" "fc" "ec")))
+
+(defvar git-blame-ancient-color "dark green")
+
+(defvar git-blame-autoupdate t
+ "*Automatically update the blame display while editing")
+
+(defvar git-blame-proc nil
+ "The running git-blame process")
+(make-variable-buffer-local 'git-blame-proc)
+
+(defvar git-blame-overlays nil
+ "The git-blame overlays used in the current buffer.")
+(make-variable-buffer-local 'git-blame-overlays)
+
+(defvar git-blame-cache nil
+ "A cache of git-blame information for the current buffer")
+(make-variable-buffer-local 'git-blame-cache)
+
+(defvar git-blame-idle-timer nil
+ "An idle timer that updates the blame")
+(make-variable-buffer-local 'git-blame-cache)
+
+(defvar git-blame-update-queue nil
+ "A queue of update requests")
+(make-variable-buffer-local 'git-blame-update-queue)
+
+(defvar git-blame-mode nil)
+(make-variable-buffer-local 'git-blame-mode)
+(unless (assq 'git-blame-mode minor-mode-alist)
+ (setq minor-mode-alist
+ (cons (list 'git-blame-mode " blame")
+ minor-mode-alist)))
+
+;;;###autoload
+(defun git-blame-mode (&optional arg)
+ "Minor mode for displaying Git blame"
+ (interactive "P")
+ (if arg
+ (setq git-blame-mode (eq arg 1))
+ (setq git-blame-mode (not git-blame-mode)))
+ (make-local-variable 'git-blame-colors)
+ (if git-blame-autoupdate
+ (add-hook 'after-change-functions 'git-blame-after-change nil t)
+ (remove-hook 'after-change-functions 'git-blame-after-change t))
+ (git-blame-cleanup)
+ (if git-blame-mode
+ (progn
+ (let ((bgmode (cdr (assoc 'background-mode (frame-parameters)))))
+ (if (eq bgmode 'dark)
+ (setq git-blame-colors git-blame-dark-colors)
+ (setq git-blame-colors git-blame-light-colors)))
+ (setq git-blame-cache (make-hash-table :test 'equal))
+ (git-blame-run))
+ (cancel-timer git-blame-idle-timer)))
+
+;;;###autoload
+(defun git-reblame ()
+ "Recalculate all blame information in the current buffer"
+ (unless git-blame-mode
+ (error "git-blame is not active"))
+ (interactive)
+ (git-blame-cleanup)
+ (git-blame-run))
+
+(defun git-blame-run (&optional startline endline)
+ (if git-blame-proc
+ ;; Should maybe queue up a new run here
+ (message "Already running git blame")
+ (let ((display-buf (current-buffer))
+ (blame-buf (get-buffer-create
+ (concat " git blame for " (buffer-name))))
+ (args '("--incremental" "--contents" "-")))
+ (if startline
+ (setq args (append args
+ (list "-L" (format "%d,%d" startline endline)))))
+ (setq args (append args
+ (list (file-name-nondirectory buffer-file-name))))
+ (setq git-blame-proc
+ (apply 'start-process
+ "git-blame" blame-buf
+ "git" "blame"
+ args))
+ (with-current-buffer blame-buf
+ (erase-buffer)
+ (make-local-variable 'git-blame-file)
+ (make-local-variable 'git-blame-current)
+ (setq git-blame-file display-buf)
+ (setq git-blame-current nil))
+ (set-process-filter git-blame-proc 'git-blame-filter)
+ (set-process-sentinel git-blame-proc 'git-blame-sentinel)
+ (process-send-region git-blame-proc (point-min) (point-max))
+ (process-send-eof git-blame-proc))))
+
+(defun remove-git-blame-text-properties (start end)
+ (let ((modified (buffer-modified-p))
+ (inhibit-read-only t))
+ (remove-text-properties start end '(point-entered nil))
+ (set-buffer-modified-p modified)))
+
+(defun git-blame-cleanup ()
+ "Remove all blame properties"
+ (mapcar 'delete-overlay git-blame-overlays)
+ (setq git-blame-overlays nil)
+ (remove-git-blame-text-properties (point-min) (point-max)))
+
+(defun git-blame-update-region (start end)
+ "Rerun blame to get updates between START and END"
+ (let ((overlays (overlays-in start end)))
+ (while overlays
+ (let ((overlay (pop overlays)))
+ (if (< (overlay-start overlay) start)
+ (setq start (overlay-start overlay)))
+ (if (> (overlay-end overlay) end)
+ (setq end (overlay-end overlay)))
+ (setq git-blame-overlays (delete overlay git-blame-overlays))
+ (delete-overlay overlay))))
+ (remove-git-blame-text-properties start end)
+ ;; We can be sure that start and end are at line breaks
+ (git-blame-run (1+ (count-lines (point-min) start))
+ (count-lines (point-min) end)))
+
+(defun git-blame-sentinel (proc status)
+ (with-current-buffer (process-buffer proc)
+ (with-current-buffer git-blame-file
+ (setq git-blame-proc nil)
+ (if git-blame-update-queue
+ (git-blame-delayed-update))))
+ ;;(kill-buffer (process-buffer proc))
+ ;;(message "git blame finished")
+ )
+
+(defvar in-blame-filter nil)
+
+(defun git-blame-filter (proc str)
+ (save-excursion
+ (set-buffer (process-buffer proc))
+ (goto-char (process-mark proc))
+ (insert-before-markers str)
+ (goto-char 0)
+ (unless in-blame-filter
+ (let ((more t)
+ (in-blame-filter t))
+ (while more
+ (setq more (git-blame-parse)))))))
+
+(defun git-blame-parse ()
+ (cond ((looking-at "\\([0-9a-f]\\{40\\}\\) \\([0-9]+\\) \\([0-9]+\\) \\([0-9]+\\)\n")
+ (let ((hash (match-string 1))
+ (src-line (string-to-number (match-string 2)))
+ (res-line (string-to-number (match-string 3)))
+ (num-lines (string-to-number (match-string 4))))
+ (setq git-blame-current
+ (if (string= hash "0000000000000000000000000000000000000000")
+ nil
+ (git-blame-new-commit
+ hash src-line res-line num-lines))))
+ (delete-region (point) (match-end 0))
+ t)
+ ((looking-at "filename \\(.+\\)\n")
+ (let ((filename (match-string 1)))
+ (git-blame-add-info "filename" filename))
+ (delete-region (point) (match-end 0))
+ t)
+ ((looking-at "\\([a-z-]+\\) \\(.+\\)\n")
+ (let ((key (match-string 1))
+ (value (match-string 2)))
+ (git-blame-add-info key value))
+ (delete-region (point) (match-end 0))
+ t)
+ ((looking-at "boundary\n")
+ (setq git-blame-current nil)
+ (delete-region (point) (match-end 0))
+ t)
+ (t
+ nil)))
+
+
+(defun git-blame-new-commit (hash src-line res-line num-lines)
+ (save-excursion
+ (set-buffer git-blame-file)
+ (let ((info (gethash hash git-blame-cache))
+ (inhibit-point-motion-hooks t)
+ (inhibit-modification-hooks t))
+ (when (not info)
+ (let ((color (pop git-blame-colors)))
+ (unless color
+ (setq color git-blame-ancient-color))
+ (setq info (list hash src-line res-line num-lines
+ (git-describe-commit hash)
+ (cons 'color color))))
+ (puthash hash info git-blame-cache))
+ (goto-line res-line)
+ (while (> num-lines 0)
+ (if (get-text-property (point) 'git-blame)
+ (forward-line)
+ (let* ((start (point))
+ (end (progn (forward-line 1) (point)))
+ (ovl (make-overlay start end)))
+ (push ovl git-blame-overlays)
+ (overlay-put ovl 'git-blame info)
+ (overlay-put ovl 'help-echo hash)
+ (overlay-put ovl 'face (list :background
+ (cdr (assq 'color (nthcdr 5 info)))))
+ ;; the point-entered property doesn't seem to work in overlays
+ ;;(overlay-put ovl 'point-entered
+ ;; `(lambda (x y) (git-blame-identify ,hash)))
+ (let ((modified (buffer-modified-p)))
+ (put-text-property (if (= start 1) start (1- start)) (1- end)
+ 'point-entered
+ `(lambda (x y) (git-blame-identify ,hash)))
+ (set-buffer-modified-p modified))))
+ (setq num-lines (1- num-lines))))))
+
+(defun git-blame-add-info (key value)
+ (if git-blame-current
+ (nconc git-blame-current (list (cons (intern key) value)))))
+
+(defun git-blame-current-commit ()
+ (let ((info (get-char-property (point) 'git-blame)))
+ (if info
+ (car info)
+ (error "No commit info"))))
+
+(defun git-describe-commit (hash)
+ (with-temp-buffer
+ (call-process "git" nil t nil
+ "log" "-1" "--pretty=oneline"
+ hash)
+ (buffer-substring (point-min) (1- (point-max)))))
+
+(defvar git-blame-last-identification nil)
+(make-variable-buffer-local 'git-blame-last-identification)
+(defun git-blame-identify (&optional hash)
+ (interactive)
+ (let ((info (gethash (or hash (git-blame-current-commit)) git-blame-cache)))
+ (when (and info (not (eq info git-blame-last-identification)))
+ (message "%s" (nth 4 info))
+ (setq git-blame-last-identification info))))
+
+;; (defun git-blame-after-save ()
+;; (when git-blame-mode
+;; (git-blame-cleanup)
+;; (git-blame-run)))
+;; (add-hook 'after-save-hook 'git-blame-after-save)
+
+(defun git-blame-after-change (start end length)
+ (when git-blame-mode
+ (git-blame-enq-update start end)))
+
+(defvar git-blame-last-update nil)
+(make-variable-buffer-local 'git-blame-last-update)
+(defun git-blame-enq-update (start end)
+ "Mark the region between START and END as needing blame update"
+ ;; Try to be smart and avoid multiple callouts for sequential
+ ;; editing
+ (cond ((and git-blame-last-update
+ (= start (cdr git-blame-last-update)))
+ (setcdr git-blame-last-update end))
+ ((and git-blame-last-update
+ (= end (car git-blame-last-update)))
+ (setcar git-blame-last-update start))
+ (t
+ (setq git-blame-last-update (cons start end))
+ (setq git-blame-update-queue (nconc git-blame-update-queue
+ (list git-blame-last-update)))))
+ (unless (or git-blame-proc git-blame-idle-timer)
+ (setq git-blame-idle-timer
+ (run-with-idle-timer 0.5 nil 'git-blame-delayed-update))))
+
+(defun git-blame-delayed-update ()
+ (setq git-blame-idle-timer nil)
+ (if git-blame-update-queue
+ (let ((first (pop git-blame-update-queue))
+ (inhibit-point-motion-hooks t))
+ (git-blame-update-region (car first) (cdr first)))))
+
+(provide 'git-blame)
+
+;;; git-blame.el ends here
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index d90ba816e0..24629eb3e2 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -222,7 +222,7 @@ and returns the process output as a string."
"Return the name to use as GIT_COMMITTER_NAME."
; copied from log-edit
(or git-committer-name
- (git-repo-config "user.name")
+ (git-config "user.name")
(and (boundp 'add-log-full-name) add-log-full-name)
(and (fboundp 'user-full-name) (user-full-name))
(and (boundp 'user-full-name) user-full-name)))
@@ -231,7 +231,7 @@ and returns the process output as a string."
"Return the email address to use as GIT_COMMITTER_EMAIL."
; copied from log-edit
(or git-committer-email
- (git-repo-config "user.email")
+ (git-config "user.email")
(and (boundp 'add-log-mailing-address) add-log-mailing-address)
(and (fboundp 'user-mail-address) (user-mail-address))
(and (boundp 'user-mail-address) user-mail-address)))
@@ -298,9 +298,9 @@ and returns the process output as a string."
(git-get-string-sha1
(git-call-process-env-string nil "rev-parse" rev)))
-(defun git-repo-config (key)
+(defun git-config (key)
"Retrieve the value associated to KEY in the git repository config file."
- (let ((str (git-call-process-env-string nil "repo-config" key)))
+ (let ((str (git-call-process-env-string nil "config" key)))
(and str (car (split-string str "\n")))))
(defun git-symbolic-ref (ref)
diff --git a/contrib/emacs/vc-git.el b/contrib/emacs/vc-git.el
index 3eb4bd19e9..e456ab9712 100644
--- a/contrib/emacs/vc-git.el
+++ b/contrib/emacs/vc-git.el
@@ -120,7 +120,16 @@
(vc-git--run-command file "commit" "-m" comment "--only" "--")))
(defun vc-git-checkout (file &optional editable rev destfile)
- (vc-git--run-command file "checkout" (or rev "HEAD")))
+ (if destfile
+ (let ((fullname (substring
+ (vc-git--run-command-string file "ls-files" "-z" "--full-name" "--")
+ 0 -1))
+ (coding-system-for-read 'no-conversion)
+ (coding-system-for-write 'no-conversion))
+ (with-temp-file destfile
+ (eq 0 (call-process "git" nil t nil "cat-file" "blob"
+ (concat (or rev "HEAD") ":" fullname)))))
+ (vc-git--run-command file "checkout" (or rev "HEAD"))))
(defun vc-git-annotate-command (file buf &optional rev)
; FIXME: rev is ignored
diff --git a/git-resolve.sh b/contrib/examples/git-resolve.sh
index 36b90e3849..36b90e3849 100755
--- a/git-resolve.sh
+++ b/contrib/examples/git-resolve.sh
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
new file mode 100755
index 0000000000..990c9e70b2
--- /dev/null
+++ b/contrib/fast-import/import-tars.perl
@@ -0,0 +1,103 @@
+#!/usr/bin/perl
+
+## tar archive frontend for git-fast-import
+##
+## For example:
+##
+## mkdir project; cd project; git init
+## perl import-tars.perl *.tar.bz2
+## git whatchanged import-tars
+##
+
+use strict;
+die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV;
+
+my $branch_name = 'import-tars';
+my $branch_ref = "refs/heads/$branch_name";
+my $committer_name = 'T Ar Creator';
+my $committer_email = 'tar@example.com';
+
+open(FI, '|-', 'git', 'fast-import', '--quiet')
+ or die "Unable to start git fast-import: $!\n";
+foreach my $tar_file (@ARGV)
+{
+ $tar_file =~ m,([^/]+)$,;
+ my $tar_name = $1;
+
+ if ($tar_name =~ s/\.(tar\.gz|tgz)$//) {
+ open(I, '-|', 'gzcat', $tar_file) or die "Unable to gzcat $tar_file: $!\n";
+ } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) {
+ open(I, '-|', 'bzcat', $tar_file) or die "Unable to bzcat $tar_file: $!\n";
+ } elsif ($tar_name =~ s/\.tar\.Z$//) {
+ open(I, '-|', 'zcat', $tar_file) or die "Unable to zcat $tar_file: $!\n";
+ } elsif ($tar_name =~ s/\.tar$//) {
+ open(I, $tar_file) or die "Unable to open $tar_file: $!\n";
+ } else {
+ die "Unrecognized compression format: $tar_file\n";
+ }
+
+ my $commit_time = 0;
+ my $next_mark = 1;
+ my $have_top_dir = 1;
+ my ($top_dir, %files);
+
+ while (read(I, $_, 512) == 512) {
+ my ($name, $mode, $uid, $gid, $size, $mtime,
+ $chksum, $typeflag, $linkname, $magic,
+ $version, $uname, $gname, $devmajor, $devminor,
+ $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
+ Z8 Z1 Z100 Z6
+ Z2 Z32 Z32 Z8 Z8 Z*', $_;
+ last unless $name;
+ $mode = oct $mode;
+ $size = oct $size;
+ $mtime = oct $mtime;
+ next if $mode & 0040000;
+
+ print FI "blob\n", "mark :$next_mark\n", "data $size\n";
+ while ($size > 0 && read(I, $_, 512) == 512) {
+ print FI substr($_, 0, $size);
+ $size -= 512;
+ }
+ print FI "\n";
+
+ my $path = "$prefix$name";
+ $files{$path} = [$next_mark++, $mode];
+
+ $commit_time = $mtime if $mtime > $commit_time;
+ $path =~ m,^([^/]+)/,;
+ $top_dir = $1 unless $top_dir;
+ $have_top_dir = 0 if $top_dir ne $1;
+ }
+
+ print FI <<EOF;
+commit $branch_ref
+committer $committer_name <$committer_email> $commit_time +0000
+data <<END_OF_COMMIT_MESSAGE
+Imported from $tar_file.
+END_OF_COMMIT_MESSAGE
+
+deleteall
+EOF
+
+ foreach my $path (keys %files)
+ {
+ my ($mark, $mode) = @{$files{$path}};
+ $path =~ s,^([^/]+)/,, if $have_top_dir;
+ printf FI "M %o :%i %s\n", $mode & 0111 ? 0755 : 0644, $mark, $path;
+ }
+ print FI "\n";
+
+ print FI <<EOF;
+tag $tar_name
+from $branch_ref
+tagger $committer_name <$committer_email> $commit_time +0000
+data <<END_OF_TAG_MESSAGE
+Package $tar_name
+END_OF_TAG_MESSAGE
+
+EOF
+
+ close I;
+}
+close FI;
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 3b6bdceeeb..521b2fcd32 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -497,7 +497,7 @@ class GitView:
fp.close()
def get_encoding(self):
- fp = os.popen("git repo-config --get i18n.commitencoding")
+ fp = os.popen("git config --get i18n.commitencoding")
self.encoding=string.strip(fp.readline())
fp.close()
if (self.encoding == ""):
diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
new file mode 100755
index 0000000000..37337ff01f
--- /dev/null
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -0,0 +1,233 @@
+#! /usr/bin/python
+
+""" hg-to-svn.py - A Mercurial to GIT converter
+
+ Copyright (C)2007 Stelian Pop <stelian@popies.net>
+
+ 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.
+"""
+
+import os, os.path, sys
+import tempfile, popen2, pickle, getopt
+import re
+
+# Maps hg version -> git version
+hgvers = {}
+# List of children for each hg revision
+hgchildren = {}
+# Current branch for each hg revision
+hgbranch = {}
+
+#------------------------------------------------------------------------------
+
+def usage():
+
+ print """\
+%s: [OPTIONS] <hgprj>
+
+options:
+ -s, --gitstate=FILE: name of the state to be saved/read
+ for incrementals
+
+required:
+ hgprj: name of the HG project to import (directory)
+""" % sys.argv[0]
+
+#------------------------------------------------------------------------------
+
+def getgitenv(user, date):
+ env = ''
+ elems = re.compile('(.*?)\s+<(.*)>').match(user)
+ if elems:
+ env += 'export GIT_AUTHOR_NAME="%s" ;' % elems.group(1)
+ env += 'export GIT_COMMITER_NAME="%s" ;' % elems.group(1)
+ env += 'export GIT_AUTHOR_EMAIL="%s" ;' % elems.group(2)
+ env += 'export GIT_COMMITER_EMAIL="%s" ;' % elems.group(2)
+ else:
+ env += 'export GIT_AUTHOR_NAME="%s" ;' % user
+ env += 'export GIT_COMMITER_NAME="%s" ;' % user
+ env += 'export GIT_AUTHOR_EMAIL= ;'
+ env += 'export GIT_COMMITER_EMAIL= ;'
+
+ env += 'export GIT_AUTHOR_DATE="%s" ;' % date
+ env += 'export GIT_COMMITTER_DATE="%s" ;' % date
+ return env
+
+#------------------------------------------------------------------------------
+
+state = ''
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], 's:t:', ['gitstate=', 'tempdir='])
+ for o, a in opts:
+ if o in ('-s', '--gitstate'):
+ state = a
+ state = os.path.abspath(state)
+
+ if len(args) != 1:
+ raise('params')
+except:
+ usage()
+ sys.exit(1)
+
+hgprj = args[0]
+os.chdir(hgprj)
+
+if state:
+ if os.path.exists(state):
+ 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 | head -1 | cut -f 2 -d :').read().strip()
+print 'tip is', tip
+
+# Calculate the branches
+print 'analysing the branches...'
+hgchildren["0"] = ()
+hgbranch["0"] = "master"
+for cset in range(1, int(tip) + 1):
+ hgchildren[str(cset)] = ()
+ prnts = os.popen('hg log -r %d | grep ^parent: | cut -f 2 -d :' % cset).readlines()
+ if len(prnts) > 0:
+ parent = prnts[0].strip()
+ else:
+ parent = str(cset - 1)
+ hgchildren[parent] += ( str(cset), )
+ if len(prnts) > 1:
+ mparent = prnts[1].strip()
+ hgchildren[mparent] += ( str(cset), )
+ else:
+ mparent = None
+
+ if mparent:
+ # For merge changesets, take either one, preferably the 'master' branch
+ if hgbranch[mparent] == 'master':
+ hgbranch[str(cset)] = 'master'
+ else:
+ hgbranch[str(cset)] = hgbranch[parent]
+ else:
+ # Normal changesets
+ # For first children, take the parent branch, for the others create a new branch
+ if hgchildren[parent][0] == str(cset):
+ hgbranch[str(cset)] = hgbranch[parent]
+ else:
+ hgbranch[str(cset)] = "branch-" + str(cset)
+
+if not hgvers.has_key("0"):
+ print 'creating repository'
+ os.system('git-init-db')
+
+# loop through every hg changeset
+for cset in range(int(tip) + 1):
+
+ # incremental, already seen
+ if hgvers.has_key(str(cset)):
+ continue
+
+ # get info
+ prnts = os.popen('hg log -r %d | grep ^parent: | cut -f 2 -d :' % cset).readlines()
+ if len(prnts) > 0:
+ parent = prnts[0].strip()
+ else:
+ parent = str(cset - 1)
+ if len(prnts) > 1:
+ mparent = prnts[1].strip()
+ else:
+ mparent = None
+
+ (fdcomment, filecomment) = tempfile.mkstemp()
+ csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()
+ os.write(fdcomment, csetcomment)
+ os.close(fdcomment)
+
+ date = os.popen('hg log -r %d | grep ^date: | cut -f 2- -d :' % cset).read().strip()
+
+ tag = os.popen('hg log -r %d | grep ^tag: | cut -f 2- -d :' % cset).read().strip()
+
+ user = os.popen('hg log -r %d | grep ^user: | cut -f 2- -d :' % cset).read().strip()
+
+ print '-----------------------------------------'
+ print 'cset:', cset
+ print 'branch:', hgbranch[str(cset)]
+ print 'user:', user
+ print 'date:', date
+ print 'comment:', csetcomment
+ print 'parent:', parent
+ if mparent:
+ print 'mparent:', mparent
+ if tag:
+ print 'tag:', tag
+ print '-----------------------------------------'
+
+ # checkout the parent if necessary
+ 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]))
+ else:
+ print 'checking out branch', hgbranch[str(cset)]
+ os.system('git-checkout %s' % hgbranch[str(cset)])
+
+ # merge
+ if mparent:
+ if hgbranch[parent] == hgbranch[str(cset)]:
+ otherbranch = hgbranch[mparent]
+ 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))
+
+ # remove everything except .git and .hg directories
+ os.system('find . \( -path "./.hg" -o -path "./.git" \) -prune -o ! -name "." -print | xargs rm -rf')
+
+ # repopulate with checkouted files
+ os.system('hg update -C %d' % cset)
+
+ # add new files
+ 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')
+
+ # commit
+ os.system(getgitenv(user, date) + 'git-commit -a -F %s' % filecomment)
+ os.unlink(filecomment)
+
+ # tag
+ if tag and tag != 'tip':
+ 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)
+
+ # retrieve and record the version
+ vvv = os.popen('git-show | head -1').read()
+ vvv = vvv[vvv.index(' ') + 1 : ].strip()
+ print 'record', cset, '->', vvv
+ hgvers[str(cset)] = vvv
+
+os.system('git-repack -a -d')
+
+# write the state for incrementals
+if state:
+ print 'Writing state'
+ f = open(state, 'w')
+ pickle.dump(hgvers, f)
+
+# vim: et ts=8 sw=4 sts=4
diff --git a/contrib/hg-to-git/hg-to-git.txt b/contrib/hg-to-git/hg-to-git.txt
new file mode 100644
index 0000000000..91f8fe6410
--- /dev/null
+++ b/contrib/hg-to-git/hg-to-git.txt
@@ -0,0 +1,21 @@
+hg-to-git.py is able to convert a Mercurial repository into a git one,
+and preserves the branches in the process (unlike tailor)
+
+hg-to-git.py can probably be greatly improved (it's a rather crude
+combination of shell and python) but it does already work quite well for
+me. Features:
+ - supports incremental conversion
+ (for keeping a git repo in sync with a hg one)
+ - supports hg branches
+ - converts hg tags
+
+Note that the git repository will be created 'in place' (at the same
+location as the source hg repo). You will have to manually remove the
+'.hg' directory after the conversion.
+
+Also note that the incremental conversion uses 'simple' hg changesets
+identifiers (ordinals, as opposed to SHA-1 ids), and since these ids
+are not stable across different repositories the hg-to-git.py state file
+is forever tied to one hg repository.
+
+Stelian Pop <stelian@popies.net>
diff --git a/contrib/mailmap.linux b/contrib/mailmap.linux
deleted file mode 100644
index e4907f80f1..0000000000
--- a/contrib/mailmap.linux
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Even with git, we don't always have name translations.
-# So have an email->real name table to translate the
-# (hopefully few) missing names
-#
-# repo-abbrev: /pub/scm/linux/kernel/git/
-#
-Adrian Bunk <bunk@stusta.de>
-Andreas Herrmann <aherrman@de.ibm.com>
-Andrew Morton <akpm@osdl.org>
-Andrew Vasquez <andrew.vasquez@qlogic.com>
-Christoph Hellwig <hch@lst.de>
-Corey Minyard <minyard@acm.org>
-David Woodhouse <dwmw2@shinybook.infradead.org>
-Domen Puncer <domen@coderock.org>
-Douglas Gilbert <dougg@torque.net>
-Ed L Cashin <ecashin@coraid.com>
-Evgeniy Polyakov <johnpol@2ka.mipt.ru>
-Felix Moeller <felix@derklecks.de>
-Frank Zago <fzago@systemfabricworks.com>
-Greg Kroah-Hartman <gregkh@suse.de>
-James Bottomley <jejb@mulgrave.(none)>
-James Bottomley <jejb@titanic.il.steeleye.com>
-Jeff Garzik <jgarzik@pretzel.yyz.us>
-Jens Axboe <axboe@suse.de>
-Kay Sievers <kay.sievers@vrfy.org>
-Mitesh shah <mshah@teja.com>
-Morten Welinder <terra@gnome.org>
-Morten Welinder <welinder@anemone.rentec.com>
-Morten Welinder <welinder@darter.rentec.com>
-Morten Welinder <welinder@troll.com>
-Nguyen Anh Quynh <aquynh@gmail.com>
-Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
-Peter A Jonsson <pj@ludd.ltu.se>
-Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
-Rudolf Marek <R.Marek@sh.cvut.cz>
-Rui Saraiva <rmps@joel.ist.utl.pt>
-Sachin P Sant <ssant@in.ibm.com>
-Santtu Hyrkk,Av(B <santtu.hyrkko@gmail.com>
-Simon Kelley <simon@thekelleys.org.uk>
-Tejun Heo <htejun@gmail.com>
-Tony Luck <tony.luck@intel.com>
diff --git a/contrib/remotes2config.sh b/contrib/remotes2config.sh
index 25901e2b3b..dc09eae972 100644
--- a/contrib/remotes2config.sh
+++ b/contrib/remotes2config.sh
@@ -11,7 +11,7 @@ if [ -d "$GIT_DIR"/remotes ]; then
{
cd "$GIT_DIR"/remotes
ls | while read f; do
- name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".")
+ name=$(printf "$f" | tr -c "A-Za-z0-9" ".")
sed -n \
-e "s/^URL: \(.*\)$/remote.$name.url \1 ./p" \
-e "s/^Pull: \(.*\)$/remote.$name.fetch \1 ^$ /p" \
@@ -26,8 +26,8 @@ if [ -d "$GIT_DIR"/remotes ]; then
mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old
fi ;;
*)
- echo "git-repo-config $key "$value" $regex"
- git-repo-config $key "$value" $regex || error=1 ;;
+ echo "git-config $key "$value" $regex"
+ git-config $key "$value" $regex || error=1 ;;
esac
done
fi
diff --git a/contrib/vim/syntax/gitcommit.vim b/contrib/vim/syntax/gitcommit.vim
index d911efbb4b..332121b40e 100644
--- a/contrib/vim/syntax/gitcommit.vim
+++ b/contrib/vim/syntax/gitcommit.vim
@@ -1,7 +1,7 @@
syn region gitLine start=/^#/ end=/$/
-syn region gitCommit start=/^# Added but not yet committed:$/ end=/^#$/ contains=gitHead,gitCommitFile
+syn region gitCommit start=/^# Changes to be committed:$/ end=/^#$/ contains=gitHead,gitCommitFile
syn region gitHead contained start=/^# (.*)/ end=/^#$/
-syn region gitChanged start=/^# Changed but not added:/ end=/^#$/ contains=gitHead,gitChangedFile
+syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile
syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile
syn match gitCommitFile contained /^#\t.*/hs=s+2
diff --git a/daemon.c b/daemon.c
index f039534d65..2a20ca55cb 100644
--- a/daemon.c
+++ b/daemon.c
@@ -372,9 +372,16 @@ static int upload_archive(void)
return -1;
}
+static int receive_pack(void)
+{
+ execl_git_cmd("receive-pack", ".", NULL);
+ return -1;
+}
+
static struct daemon_service daemon_service[] = {
{ "upload-archive", "uploadarch", upload_archive, 0, 1 },
{ "upload-pack", "uploadpack", upload_pack, 1, 1 },
+ { "receive-pack", "receivepack", receive_pack, 0, 1 },
};
static void enable_service(const char *name, int ena) {
@@ -401,7 +408,7 @@ static void make_service_overridable(const char *name, int ena) {
/*
* Separate the "extra args" information as supplied by the client connection.
- * Any resulting data is squirrelled away in the given interpolation table.
+ * Any resulting data is squirreled away in the given interpolation table.
*/
static void parse_extra_args(struct interp *table, char *extra_args, int buflen)
{
diff --git a/date.c b/date.c
index 7acb8cbd91..542c004c2e 100644
--- a/date.c
+++ b/date.c
@@ -62,12 +62,11 @@ const char *show_date(unsigned long time, int tz, int relative)
if (relative) {
unsigned long diff;
- time_t t = gm_time_t(time, tz);
struct timeval now;
gettimeofday(&now, NULL);
- if (now.tv_sec < t)
+ if (now.tv_sec < time)
return "in the future";
- diff = now.tv_sec - t;
+ diff = now.tv_sec - time;
if (diff < 90) {
snprintf(timebuf, sizeof(timebuf), "%lu seconds ago", diff);
return timebuf;
diff --git a/describe.c b/describe.c
deleted file mode 100644
index f4029ee74e..0000000000
--- a/describe.c
+++ /dev/null
@@ -1,175 +0,0 @@
-#include "cache.h"
-#include "commit.h"
-#include "tag.h"
-#include "refs.h"
-
-#define SEEN (1u << 0)
-
-static const char describe_usage[] =
-"git-describe [--all] [--tags] [--abbrev=<n>] <committish>*";
-
-static int all; /* Default to annotated tags only */
-static int tags; /* But allow any tags if --tags is specified */
-
-static int abbrev = DEFAULT_ABBREV;
-
-static int names, allocs;
-static struct commit_name {
- const struct commit *commit;
- int prio; /* annotated tag = 2, tag = 1, head = 0 */
- char path[FLEX_ARRAY]; /* more */
-} **name_array = NULL;
-
-static struct commit_name *match(struct commit *cmit)
-{
- int i = names;
- struct commit_name **p = name_array;
-
- while (i-- > 0) {
- struct commit_name *n = *p++;
- if (n->commit == cmit)
- return n;
- }
- return NULL;
-}
-
-static void add_to_known_names(const char *path,
- const struct commit *commit,
- int prio)
-{
- int idx;
- int len = strlen(path)+1;
- struct commit_name *name = xmalloc(sizeof(struct commit_name) + len);
-
- name->commit = commit;
- name->prio = prio;
- memcpy(name->path, path, len);
- idx = names;
- if (idx >= allocs) {
- allocs = (idx + 50) * 3 / 2;
- name_array = xrealloc(name_array, allocs*sizeof(*name_array));
- }
- name_array[idx] = name;
- names = ++idx;
-}
-
-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);
- struct object *object;
- int prio;
-
- if (!commit)
- return 0;
- object = parse_object(sha1);
- /* If --all, then any refs are used.
- * If --tags, then any tags are used.
- * Otherwise only annotated tags are used.
- */
- if (!strncmp(path, "refs/tags/", 10)) {
- if (object->type == OBJ_TAG)
- prio = 2;
- else
- prio = 1;
- }
- else
- prio = 0;
-
- if (!all) {
- if (!prio)
- return 0;
- if (!tags && prio < 2)
- return 0;
- }
- add_to_known_names(all ? path + 5 : path + 10, commit, prio);
- return 0;
-}
-
-static int compare_names(const void *_a, const void *_b)
-{
- struct commit_name *a = *(struct commit_name **)_a;
- struct commit_name *b = *(struct commit_name **)_b;
- unsigned long a_date = a->commit->date;
- unsigned long b_date = b->commit->date;
-
- if (a->prio != b->prio)
- return b->prio - a->prio;
- return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
-}
-
-static void describe(const char *arg, int last_one)
-{
- unsigned char sha1[20];
- struct commit *cmit;
- struct commit_list *list;
- static int initialized = 0;
- struct commit_name *n;
-
- if (get_sha1(arg, sha1))
- die("Not a valid object name %s", arg);
- cmit = lookup_commit_reference(sha1);
- if (!cmit)
- die("%s is not a valid '%s' object", arg, commit_type);
-
- if (!initialized) {
- initialized = 1;
- for_each_ref(get_name, NULL);
- qsort(name_array, names, sizeof(*name_array), compare_names);
- }
-
- n = match(cmit);
- if (n) {
- printf("%s\n", n->path);
- return;
- }
-
- list = NULL;
- commit_list_insert(cmit, &list);
- while (list) {
- struct commit *c = pop_most_recent_commit(&list, SEEN);
- n = match(c);
- if (n) {
- printf("%s-g%s\n", n->path,
- find_unique_abbrev(cmit->object.sha1, abbrev));
- if (!last_one)
- clear_commit_marks(cmit, SEEN);
- return;
- }
- }
- die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
-}
-
-int main(int argc, char **argv)
-{
- int i;
-
- for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
-
- if (*arg != '-')
- break;
- else if (!strcmp(arg, "--all"))
- all = 1;
- else if (!strcmp(arg, "--tags"))
- tags = 1;
- else if (!strncmp(arg, "--abbrev=", 9)) {
- abbrev = strtoul(arg + 9, NULL, 10);
- if (abbrev < MINIMUM_ABBREV || 40 < abbrev)
- abbrev = DEFAULT_ABBREV;
- }
- else
- usage(describe_usage);
- }
-
- setup_git_directory();
-
- if (argc <= i)
- describe("HEAD", 1);
- else
- while (i < argc) {
- describe(argv[i], (i == argc - 1));
- i++;
- }
-
- return 0;
-}
diff --git a/diff-lib.c b/diff-lib.c
index 2c9be60ed9..91cd87742f 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -7,6 +7,7 @@
#include "diff.h"
#include "diffcore.h"
#include "revision.h"
+#include "cache-tree.h"
/*
* diff-files
@@ -271,7 +272,7 @@ static int diff_cache(struct rev_info *revs,
break;
}
/* Show difference between old and new */
- show_modified(revs,ac[1], ce, 1,
+ show_modified(revs, ac[1], ce, 1,
cached, match_missing);
break;
case 1:
@@ -372,3 +373,44 @@ int run_diff_index(struct rev_info *revs, int cached)
diff_flush(&revs->diffopt);
return ret;
}
+
+int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
+{
+ struct tree *tree;
+ struct rev_info revs;
+ int i;
+ struct cache_entry **dst;
+ struct cache_entry *last = NULL;
+
+ /*
+ * This is used by git-blame to run diff-cache internally;
+ * it potentially needs to repeatedly run this, so we will
+ * start by removing the higher order entries the last round
+ * left behind.
+ */
+ 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_mode = 0;
+ ce->ce_flags &= ~htons(CE_STAGEMASK);
+ }
+ *dst++ = ce;
+ }
+ active_nr = dst - active_cache;
+
+ init_revisions(&revs, NULL);
+ revs.prune_data = opt->paths;
+ tree = parse_tree_indirect(tree_sha1);
+ if (!tree)
+ die("bad tree object %s", sha1_to_hex(tree_sha1));
+ if (read_tree(tree, 1, opt->paths))
+ return error("unable to read tree %s", sha1_to_hex(tree_sha1));
+ return diff_cache(&revs, active_cache, active_nr, revs.prune_data,
+ 1, 0);
+}
diff --git a/diff.c b/diff.c
index ad476f7c68..13b9b6c560 100644
--- a/diff.c
+++ b/diff.c
@@ -545,6 +545,24 @@ static char *pprint_rename(const char *a, const char *b)
int pfx_length, sfx_length;
int len_a = strlen(a);
int len_b = strlen(b);
+ int qlen_a = quote_c_style(a, NULL, NULL, 0);
+ int qlen_b = quote_c_style(b, NULL, NULL, 0);
+
+ if (qlen_a || qlen_b) {
+ if (qlen_a) len_a = qlen_a;
+ if (qlen_b) len_b = qlen_b;
+ name = xmalloc( len_a + len_b + 5 );
+ if (qlen_a)
+ quote_c_style(a, name, NULL, 0);
+ else
+ memcpy(name, a, len_a);
+ memcpy(name + len_a, " => ", 4);
+ if (qlen_b)
+ quote_c_style(b, name + len_a + 4, NULL, 0);
+ else
+ memcpy(name + len_a + 4, b, len_b + 1);
+ return name;
+ }
/* Find common prefix */
pfx_length = 0;
@@ -701,12 +719,14 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
struct diffstat_file *file = data->files[i];
int change = file->added + file->deleted;
- len = quote_c_style(file->name, NULL, NULL, 0);
- if (len) {
- char *qname = xmalloc(len + 1);
- quote_c_style(file->name, qname, NULL, 0);
- free(file->name);
- file->name = qname;
+ if (!file->is_renamed) { /* renames are already quoted by pprint_rename */
+ len = quote_c_style(file->name, NULL, NULL, 0);
+ if (len) {
+ char *qname = xmalloc(len + 1);
+ quote_c_style(file->name, qname, NULL, 0);
+ free(file->name);
+ file->name = qname;
+ }
}
len = strlen(file->name);
@@ -838,7 +858,7 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
printf("-\t-\t");
else
printf("%d\t%d\t", file->added, file->deleted);
- if (options->line_termination &&
+ if (options->line_termination && !file->is_renamed &&
quote_c_style(file->name, NULL, NULL, 0))
quote_c_style(file->name, NULL, stdout, 0);
else
@@ -1344,6 +1364,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
s->data = xmmap(NULL, s->size, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
s->should_munmap = 1;
+ /* FIXME! CRLF -> LF conversion goes here, based on "s->path" */
}
else {
char type[20];
@@ -2191,13 +2212,13 @@ static void diff_flush_raw(struct diff_filepair *p,
free((void*)path_two);
}
-static void diff_flush_name(struct diff_filepair *p, int line_termination)
+static void diff_flush_name(struct diff_filepair *p, struct diff_options *opt)
{
char *path = p->two->path;
- if (line_termination)
+ if (opt->line_termination)
path = quote_one(p->two->path);
- printf("%s%c", path, line_termination);
+ printf("%s%c", path, opt->line_termination);
if (p->two->path != path)
free(path);
}
@@ -2404,24 +2425,29 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
else if (fmt & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS))
diff_flush_raw(p, opt);
else if (fmt & DIFF_FORMAT_NAME)
- diff_flush_name(p, opt->line_termination);
+ diff_flush_name(p, opt);
}
static void show_file_mode_name(const char *newdelete, struct diff_filespec *fs)
{
+ char *name = quote_one(fs->path);
if (fs->mode)
- printf(" %s mode %06o %s\n", newdelete, fs->mode, fs->path);
+ printf(" %s mode %06o %s\n", newdelete, fs->mode, name);
else
- printf(" %s %s\n", newdelete, fs->path);
+ printf(" %s %s\n", newdelete, name);
+ free(name);
}
static void show_mode_change(struct diff_filepair *p, int show_name)
{
if (p->one->mode && p->two->mode && p->one->mode != p->two->mode) {
- if (show_name)
+ if (show_name) {
+ char *name = quote_one(p->two->path);
printf(" mode change %06o => %06o %s\n",
- p->one->mode, p->two->mode, p->two->path);
+ p->one->mode, p->two->mode, name);
+ free(name);
+ }
else
printf(" mode change %06o => %06o\n",
p->one->mode, p->two->mode);
@@ -2430,34 +2456,11 @@ static void show_mode_change(struct diff_filepair *p, int show_name)
static void show_rename_copy(const char *renamecopy, struct diff_filepair *p)
{
- const char *old, *new;
+ char *names = pprint_rename(p->one->path, p->two->path);
- /* Find common prefix */
- old = p->one->path;
- new = p->two->path;
- while (1) {
- const char *slash_old, *slash_new;
- slash_old = strchr(old, '/');
- slash_new = strchr(new, '/');
- if (!slash_old ||
- !slash_new ||
- slash_old - old != slash_new - new ||
- memcmp(old, new, slash_new - new))
- break;
- old = slash_old + 1;
- new = slash_new + 1;
- }
- /* p->one->path thru old is the common prefix, and old and new
- * through the end of names are renames
- */
- if (old != p->one->path)
- printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
- (int)(old - p->one->path), p->one->path,
- old, new, (int)(0.5 + p->score * 100.0/MAX_SCORE));
- else
- printf(" %s %s => %s (%d%%)\n", renamecopy,
- p->one->path, p->two->path,
- (int)(0.5 + p->score * 100.0/MAX_SCORE));
+ printf(" %s %s (%d%%)\n", renamecopy, names,
+ (int)(0.5 + p->score * 100.0/MAX_SCORE));
+ free(names);
show_mode_change(p, 0);
}
@@ -2478,8 +2481,10 @@ static void diff_summary(struct diff_filepair *p)
break;
default:
if (p->score) {
- printf(" rewrite %s (%d%%)\n", p->two->path,
+ char *name = quote_one(p->two->path);
+ printf(" rewrite %s (%d%%)\n", name,
(int)(0.5 + p->score * 100.0/MAX_SCORE));
+ free(name);
show_mode_change(p, 0);
} else show_mode_change(p, 1);
break;
diff --git a/diff.h b/diff.h
index 7a347cf77d..eece65ddcc 100644
--- a/diff.h
+++ b/diff.h
@@ -222,6 +222,7 @@ extern int run_diff_files(struct rev_info *revs, int silent_on_removed);
extern int run_diff_index(struct rev_info *revs, int cached);
+extern int do_diff_cache(const unsigned char *, struct diff_options *);
extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
#endif /* DIFF_H */
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index de44adabf0..286919e714 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -14,6 +14,8 @@ static unsigned int contains(struct diff_filespec *one,
const char *data;
if (diff_populate_filespec(one, 0))
return 0;
+ if (!len)
+ return 0;
sz = one->size;
data = one->data;
diff --git a/entry.c b/entry.c
index 0ebf0f0c19..c2641ddefd 100644
--- a/entry.c
+++ b/entry.c
@@ -89,6 +89,7 @@ static int write_entry(struct cache_entry *ce, char *path, struct checkout *stat
return error("git-checkout-index: unable to create file %s (%s)",
path, strerror(errno));
}
+ /* FIXME: LF -> CRLF conversion goes here, based on "ce->name" */
wrote = write_in_full(fd, new, size);
close(fd);
free(new);
diff --git a/environment.c b/environment.c
index 09976c7bf6..54c22f8248 100644
--- a/environment.c
+++ b/environment.c
@@ -15,7 +15,8 @@ int use_legacy_headers = 1;
int trust_executable_bit = 1;
int assume_unchanged;
int prefer_symlink_refs;
-int log_all_ref_updates;
+int is_bare_repository_cfg = -1; /* unspecified */
+int log_all_ref_updates = -1; /* unspecified */
int warn_ambiguous_refs = 1;
int repository_format_version;
char *git_commit_encoding;
@@ -51,12 +52,15 @@ static void setup_git_env(void)
git_graft_file = getenv(GRAFT_ENVIRONMENT);
if (!git_graft_file)
git_graft_file = xstrdup(git_path("info/grafts"));
- log_all_ref_updates = !is_bare_git_dir(git_dir);
}
-int is_bare_git_dir (const char *dir)
+int is_bare_repository(void)
{
- const char *s;
+ const char *dir, *s;
+ if (0 <= is_bare_repository_cfg)
+ return is_bare_repository_cfg;
+
+ dir = get_git_dir();
if (!strcmp(dir, DEFAULT_GIT_DIR_ENVIRONMENT))
return 0;
s = strrchr(dir, '/');
diff --git a/fast-import.c b/fast-import.c
new file mode 100644
index 0000000000..404d911390
--- /dev/null
+++ b/fast-import.c
@@ -0,0 +1,2081 @@
+/*
+Format of STDIN stream:
+
+ stream ::= cmd*;
+
+ cmd ::= new_blob
+ | new_commit
+ | new_tag
+ | reset_branch
+ | checkpoint
+ ;
+
+ new_blob ::= 'blob' lf
+ mark?
+ file_content;
+ file_content ::= data;
+
+ new_commit ::= 'commit' sp ref_str lf
+ mark?
+ ('author' sp name '<' email '>' when lf)?
+ 'committer' sp name '<' email '>' when lf
+ commit_msg
+ ('from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf)?
+ ('merge' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf)*
+ file_change*
+ lf;
+ commit_msg ::= data;
+
+ file_change ::= file_clr | file_del | file_obm | file_inm;
+ file_clr ::= 'deleteall' lf;
+ file_del ::= 'D' sp path_str lf;
+ file_obm ::= 'M' sp mode sp (hexsha1 | idnum) sp path_str lf;
+ file_inm ::= 'M' sp mode sp 'inline' sp path_str lf
+ data;
+
+ new_tag ::= 'tag' sp tag_str lf
+ 'from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf
+ 'tagger' sp name '<' email '>' when lf
+ tag_msg;
+ tag_msg ::= data;
+
+ reset_branch ::= 'reset' sp ref_str lf
+ ('from' sp (ref_str | hexsha1 | sha1exp_str | idnum) lf)?
+ lf;
+
+ checkpoint ::= 'checkpoint' lf
+ lf;
+
+ # note: the first idnum in a stream should be 1 and subsequent
+ # idnums should not have gaps between values as this will cause
+ # the stream parser to reserve space for the gapped values. An
+ # idnum can be updated in the future to a new object by issuing
+ # a new mark directive with the old idnum.
+ #
+ mark ::= 'mark' sp idnum lf;
+ data ::= (delimited_data | exact_data)
+ lf;
+
+ # note: delim may be any string but must not contain lf.
+ # data_line may contain any data but must not be exactly
+ # delim.
+ delimited_data ::= 'data' sp '<<' delim lf
+ (data_line lf)*
+ delim lf;
+
+ # note: declen indicates the length of binary_data in bytes.
+ # declen does not include the lf preceeding the binary data.
+ #
+ exact_data ::= 'data' sp declen lf
+ binary_data;
+
+ # note: quoted strings are C-style quoting supporting \c for
+ # common escapes of 'c' (e..g \n, \t, \\, \") or \nnn where nnn
+ # is the signed byte value in octal. Note that the only
+ # characters which must actually be escaped to protect the
+ # stream formatting is: \, " and LF. Otherwise these values
+ # are UTF8.
+ #
+ ref_str ::= ref;
+ sha1exp_str ::= sha1exp;
+ tag_str ::= tag;
+ path_str ::= path | '"' quoted(path) '"' ;
+ mode ::= '100644' | '644'
+ | '100755' | '755'
+ | '120000'
+ ;
+
+ declen ::= # unsigned 32 bit value, ascii base10 notation;
+ bigint ::= # unsigned integer value, ascii base10 notation;
+ binary_data ::= # file content, not interpreted;
+
+ when ::= raw_when | rfc2822_when;
+ raw_when ::= ts sp tz;
+ rfc2822_when ::= # Valid RFC 2822 date and time;
+
+ sp ::= # ASCII space character;
+ lf ::= # ASCII newline (LF) character;
+
+ # note: a colon (':') must precede the numerical value assigned to
+ # an idnum. This is to distinguish it from a ref or tag name as
+ # GIT does not permit ':' in ref or tag strings.
+ #
+ idnum ::= ':' bigint;
+ path ::= # GIT style file path, e.g. "a/b/c";
+ ref ::= # GIT ref name, e.g. "refs/heads/MOZ_GECKO_EXPERIMENT";
+ tag ::= # GIT tag name, e.g. "FIREFOX_1_5";
+ sha1exp ::= # Any valid GIT SHA1 expression;
+ hexsha1 ::= # SHA1 in hexadecimal format;
+
+ # note: name and email are UTF8 strings, however name must not
+ # contain '<' or lf and email must not contain any of the
+ # following: '<', '>', lf.
+ #
+ name ::= # valid GIT author/committer name;
+ email ::= # valid GIT author/committer email;
+ ts ::= # time since the epoch in seconds, ascii base10 notation;
+ tz ::= # GIT style timezone;
+*/
+
+#include "builtin.h"
+#include "cache.h"
+#include "object.h"
+#include "blob.h"
+#include "tree.h"
+#include "commit.h"
+#include "delta.h"
+#include "pack.h"
+#include "refs.h"
+#include "csum-file.h"
+#include "strbuf.h"
+#include "quote.h"
+
+#define PACK_ID_BITS 16
+#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
+
+struct object_entry
+{
+ struct object_entry *next;
+ uint32_t offset;
+ unsigned type : TYPE_BITS;
+ unsigned pack_id : PACK_ID_BITS;
+ unsigned char sha1[20];
+};
+
+struct object_entry_pool
+{
+ struct object_entry_pool *next_pool;
+ struct object_entry *next_free;
+ struct object_entry *end;
+ struct object_entry entries[FLEX_ARRAY]; /* more */
+};
+
+struct mark_set
+{
+ union {
+ struct object_entry *marked[1024];
+ struct mark_set *sets[1024];
+ } data;
+ unsigned int shift;
+};
+
+struct last_object
+{
+ void *data;
+ unsigned long len;
+ uint32_t offset;
+ unsigned int depth;
+ unsigned no_free:1;
+};
+
+struct mem_pool
+{
+ struct mem_pool *next_pool;
+ char *next_free;
+ char *end;
+ char space[FLEX_ARRAY]; /* more */
+};
+
+struct atom_str
+{
+ struct atom_str *next_atom;
+ unsigned short str_len;
+ char str_dat[FLEX_ARRAY]; /* more */
+};
+
+struct tree_content;
+struct tree_entry
+{
+ struct tree_content *tree;
+ struct atom_str* name;
+ struct tree_entry_ms
+ {
+ uint16_t mode;
+ unsigned char sha1[20];
+ } versions[2];
+};
+
+struct tree_content
+{
+ unsigned int entry_capacity; /* must match avail_tree_content */
+ unsigned int entry_count;
+ unsigned int delta_depth;
+ struct tree_entry *entries[FLEX_ARRAY]; /* more */
+};
+
+struct avail_tree_content
+{
+ unsigned int entry_capacity; /* must match tree_content */
+ struct avail_tree_content *next_avail;
+};
+
+struct branch
+{
+ struct branch *table_next_branch;
+ struct branch *active_next_branch;
+ const char *name;
+ struct tree_entry branch_tree;
+ uintmax_t last_commit;
+ unsigned int pack_id;
+ unsigned char sha1[20];
+};
+
+struct tag
+{
+ struct tag *next_tag;
+ const char *name;
+ unsigned int pack_id;
+ unsigned char sha1[20];
+};
+
+struct dbuf
+{
+ void *buffer;
+ size_t capacity;
+};
+
+struct hash_list
+{
+ struct hash_list *next;
+ unsigned char sha1[20];
+};
+
+typedef enum {
+ WHENSPEC_RAW = 1,
+ WHENSPEC_RFC2822,
+ WHENSPEC_NOW,
+} whenspec_type;
+
+/* Configured limits on output */
+static unsigned long max_depth = 10;
+static unsigned long max_packsize = (1LL << 32) - 1;
+static int force_update;
+
+/* Stats and misc. counters */
+static uintmax_t alloc_count;
+static uintmax_t marks_set_count;
+static uintmax_t object_count_by_type[1 << TYPE_BITS];
+static uintmax_t duplicate_count_by_type[1 << TYPE_BITS];
+static uintmax_t delta_count_by_type[1 << TYPE_BITS];
+static unsigned long object_count;
+static unsigned long branch_count;
+static unsigned long branch_load_count;
+static int failure;
+static FILE *pack_edges;
+
+/* Memory pools */
+static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
+static size_t total_allocd;
+static struct mem_pool *mem_pool;
+
+/* Atom management */
+static unsigned int atom_table_sz = 4451;
+static unsigned int atom_cnt;
+static struct atom_str **atom_table;
+
+/* The .pack file being generated */
+static unsigned int pack_id;
+static struct packed_git *pack_data;
+static struct packed_git **all_packs;
+static unsigned long pack_size;
+
+/* Table of objects we've written. */
+static unsigned int object_entry_alloc = 5000;
+static struct object_entry_pool *blocks;
+static struct object_entry *object_table[1 << 16];
+static struct mark_set *marks;
+static const char* mark_file;
+
+/* Our last blob */
+static struct last_object last_blob;
+
+/* Tree management */
+static unsigned int tree_entry_alloc = 1000;
+static void *avail_tree_entry;
+static unsigned int avail_tree_table_sz = 100;
+static struct avail_tree_content **avail_tree_table;
+static struct dbuf old_tree;
+static struct dbuf new_tree;
+
+/* Branch data */
+static unsigned long max_active_branches = 5;
+static unsigned long cur_active_branches;
+static unsigned long branch_table_sz = 1039;
+static struct branch **branch_table;
+static struct branch *active_branches;
+
+/* Tag data */
+static struct tag *first_tag;
+static struct tag *last_tag;
+
+/* Input stream parsing */
+static whenspec_type whenspec = WHENSPEC_RAW;
+static struct strbuf command_buf;
+static uintmax_t next_mark;
+static struct dbuf new_data;
+
+
+static void alloc_objects(unsigned int cnt)
+{
+ struct object_entry_pool *b;
+
+ b = xmalloc(sizeof(struct object_entry_pool)
+ + cnt * sizeof(struct object_entry));
+ b->next_pool = blocks;
+ b->next_free = b->entries;
+ b->end = b->entries + cnt;
+ blocks = b;
+ alloc_count += cnt;
+}
+
+static struct object_entry *new_object(unsigned char *sha1)
+{
+ struct object_entry *e;
+
+ if (blocks->next_free == blocks->end)
+ alloc_objects(object_entry_alloc);
+
+ e = blocks->next_free++;
+ hashcpy(e->sha1, sha1);
+ return e;
+}
+
+static struct object_entry *find_object(unsigned char *sha1)
+{
+ unsigned int h = sha1[0] << 8 | sha1[1];
+ struct object_entry *e;
+ for (e = object_table[h]; e; e = e->next)
+ if (!hashcmp(sha1, e->sha1))
+ return e;
+ return NULL;
+}
+
+static struct object_entry *insert_object(unsigned char *sha1)
+{
+ unsigned int h = sha1[0] << 8 | sha1[1];
+ struct object_entry *e = object_table[h];
+ struct object_entry *p = NULL;
+
+ while (e) {
+ if (!hashcmp(sha1, e->sha1))
+ return e;
+ p = e;
+ e = e->next;
+ }
+
+ e = new_object(sha1);
+ e->next = NULL;
+ e->offset = 0;
+ if (p)
+ p->next = e;
+ else
+ object_table[h] = e;
+ return e;
+}
+
+static unsigned int hc_str(const char *s, size_t len)
+{
+ unsigned int r = 0;
+ while (len-- > 0)
+ r = r * 31 + *s++;
+ return r;
+}
+
+static void *pool_alloc(size_t len)
+{
+ struct mem_pool *p;
+ void *r;
+
+ for (p = mem_pool; p; p = p->next_pool)
+ if ((p->end - p->next_free >= len))
+ break;
+
+ if (!p) {
+ if (len >= (mem_pool_alloc/2)) {
+ total_allocd += len;
+ return xmalloc(len);
+ }
+ total_allocd += sizeof(struct mem_pool) + mem_pool_alloc;
+ p = xmalloc(sizeof(struct mem_pool) + mem_pool_alloc);
+ p->next_pool = mem_pool;
+ p->next_free = p->space;
+ p->end = p->next_free + mem_pool_alloc;
+ mem_pool = p;
+ }
+
+ r = p->next_free;
+ /* round out to a pointer alignment */
+ if (len & (sizeof(void*) - 1))
+ len += sizeof(void*) - (len & (sizeof(void*) - 1));
+ p->next_free += len;
+ return r;
+}
+
+static void *pool_calloc(size_t count, size_t size)
+{
+ size_t len = count * size;
+ void *r = pool_alloc(len);
+ memset(r, 0, len);
+ return r;
+}
+
+static char *pool_strdup(const char *s)
+{
+ char *r = pool_alloc(strlen(s) + 1);
+ strcpy(r, s);
+ return r;
+}
+
+static void size_dbuf(struct dbuf *b, size_t maxlen)
+{
+ if (b->buffer) {
+ if (b->capacity >= maxlen)
+ return;
+ free(b->buffer);
+ }
+ b->capacity = ((maxlen / 1024) + 1) * 1024;
+ b->buffer = xmalloc(b->capacity);
+}
+
+static void insert_mark(uintmax_t idnum, struct object_entry *oe)
+{
+ struct mark_set *s = marks;
+ while ((idnum >> s->shift) >= 1024) {
+ s = pool_calloc(1, sizeof(struct mark_set));
+ s->shift = marks->shift + 10;
+ s->data.sets[0] = marks;
+ marks = s;
+ }
+ while (s->shift) {
+ uintmax_t i = idnum >> s->shift;
+ idnum -= i << s->shift;
+ if (!s->data.sets[i]) {
+ s->data.sets[i] = pool_calloc(1, sizeof(struct mark_set));
+ s->data.sets[i]->shift = s->shift - 10;
+ }
+ s = s->data.sets[i];
+ }
+ if (!s->data.marked[idnum])
+ marks_set_count++;
+ s->data.marked[idnum] = oe;
+}
+
+static struct object_entry *find_mark(uintmax_t idnum)
+{
+ uintmax_t orig_idnum = idnum;
+ struct mark_set *s = marks;
+ struct object_entry *oe = NULL;
+ if ((idnum >> s->shift) < 1024) {
+ while (s && s->shift) {
+ uintmax_t i = idnum >> s->shift;
+ idnum -= i << s->shift;
+ s = s->data.sets[i];
+ }
+ if (s)
+ oe = s->data.marked[idnum];
+ }
+ if (!oe)
+ die("mark :%ju not declared", orig_idnum);
+ return oe;
+}
+
+static struct atom_str *to_atom(const char *s, unsigned short len)
+{
+ unsigned int hc = hc_str(s, len) % atom_table_sz;
+ struct atom_str *c;
+
+ for (c = atom_table[hc]; c; c = c->next_atom)
+ if (c->str_len == len && !strncmp(s, c->str_dat, len))
+ return c;
+
+ c = pool_alloc(sizeof(struct atom_str) + len + 1);
+ c->str_len = len;
+ strncpy(c->str_dat, s, len);
+ c->str_dat[len] = 0;
+ c->next_atom = atom_table[hc];
+ atom_table[hc] = c;
+ atom_cnt++;
+ return c;
+}
+
+static struct branch *lookup_branch(const char *name)
+{
+ unsigned int hc = hc_str(name, strlen(name)) % branch_table_sz;
+ struct branch *b;
+
+ for (b = branch_table[hc]; b; b = b->table_next_branch)
+ if (!strcmp(name, b->name))
+ return b;
+ return NULL;
+}
+
+static struct branch *new_branch(const char *name)
+{
+ unsigned int hc = hc_str(name, strlen(name)) % branch_table_sz;
+ struct branch* b = lookup_branch(name);
+
+ if (b)
+ die("Invalid attempt to create duplicate branch: %s", name);
+ if (check_ref_format(name))
+ die("Branch name doesn't conform to GIT standards: %s", name);
+
+ b = pool_calloc(1, sizeof(struct branch));
+ b->name = pool_strdup(name);
+ b->table_next_branch = branch_table[hc];
+ b->branch_tree.versions[0].mode = S_IFDIR;
+ b->branch_tree.versions[1].mode = S_IFDIR;
+ b->pack_id = MAX_PACK_ID;
+ branch_table[hc] = b;
+ branch_count++;
+ return b;
+}
+
+static unsigned int hc_entries(unsigned int cnt)
+{
+ cnt = cnt & 7 ? (cnt / 8) + 1 : cnt / 8;
+ return cnt < avail_tree_table_sz ? cnt : avail_tree_table_sz - 1;
+}
+
+static struct tree_content *new_tree_content(unsigned int cnt)
+{
+ struct avail_tree_content *f, *l = NULL;
+ struct tree_content *t;
+ unsigned int hc = hc_entries(cnt);
+
+ for (f = avail_tree_table[hc]; f; l = f, f = f->next_avail)
+ if (f->entry_capacity >= cnt)
+ break;
+
+ if (f) {
+ if (l)
+ l->next_avail = f->next_avail;
+ else
+ avail_tree_table[hc] = f->next_avail;
+ } else {
+ cnt = cnt & 7 ? ((cnt / 8) + 1) * 8 : cnt;
+ f = pool_alloc(sizeof(*t) + sizeof(t->entries[0]) * cnt);
+ f->entry_capacity = cnt;
+ }
+
+ t = (struct tree_content*)f;
+ t->entry_count = 0;
+ t->delta_depth = 0;
+ return t;
+}
+
+static void release_tree_entry(struct tree_entry *e);
+static void release_tree_content(struct tree_content *t)
+{
+ struct avail_tree_content *f = (struct avail_tree_content*)t;
+ unsigned int hc = hc_entries(f->entry_capacity);
+ f->next_avail = avail_tree_table[hc];
+ avail_tree_table[hc] = f;
+}
+
+static void release_tree_content_recursive(struct tree_content *t)
+{
+ unsigned int i;
+ for (i = 0; i < t->entry_count; i++)
+ release_tree_entry(t->entries[i]);
+ release_tree_content(t);
+}
+
+static struct tree_content *grow_tree_content(
+ struct tree_content *t,
+ int amt)
+{
+ struct tree_content *r = new_tree_content(t->entry_count + amt);
+ r->entry_count = t->entry_count;
+ r->delta_depth = t->delta_depth;
+ memcpy(r->entries,t->entries,t->entry_count*sizeof(t->entries[0]));
+ release_tree_content(t);
+ return r;
+}
+
+static struct tree_entry *new_tree_entry(void)
+{
+ struct tree_entry *e;
+
+ if (!avail_tree_entry) {
+ unsigned int n = tree_entry_alloc;
+ total_allocd += n * sizeof(struct tree_entry);
+ avail_tree_entry = e = xmalloc(n * sizeof(struct tree_entry));
+ while (n-- > 1) {
+ *((void**)e) = e + 1;
+ e++;
+ }
+ *((void**)e) = NULL;
+ }
+
+ e = avail_tree_entry;
+ avail_tree_entry = *((void**)e);
+ return e;
+}
+
+static void release_tree_entry(struct tree_entry *e)
+{
+ if (e->tree)
+ release_tree_content_recursive(e->tree);
+ *((void**)e) = avail_tree_entry;
+ avail_tree_entry = e;
+}
+
+static void start_packfile(void)
+{
+ static char tmpfile[PATH_MAX];
+ struct packed_git *p;
+ struct pack_header hdr;
+ int pack_fd;
+
+ snprintf(tmpfile, sizeof(tmpfile),
+ "%s/pack_XXXXXX", get_object_directory());
+ pack_fd = mkstemp(tmpfile);
+ if (pack_fd < 0)
+ die("Can't create %s: %s", tmpfile, strerror(errno));
+ p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
+ strcpy(p->pack_name, tmpfile);
+ p->pack_fd = pack_fd;
+
+ hdr.hdr_signature = htonl(PACK_SIGNATURE);
+ hdr.hdr_version = htonl(2);
+ hdr.hdr_entries = 0;
+ write_or_die(p->pack_fd, &hdr, sizeof(hdr));
+
+ pack_data = p;
+ pack_size = sizeof(hdr);
+ object_count = 0;
+
+ all_packs = xrealloc(all_packs, sizeof(*all_packs) * (pack_id + 1));
+ all_packs[pack_id] = p;
+}
+
+static void fixup_header_footer(void)
+{
+ static const int buf_sz = 128 * 1024;
+ int pack_fd = pack_data->pack_fd;
+ SHA_CTX c;
+ struct pack_header hdr;
+ char *buf;
+
+ if (lseek(pack_fd, 0, SEEK_SET) != 0)
+ die("Failed seeking to start: %s", strerror(errno));
+ if (read_in_full(pack_fd, &hdr, sizeof(hdr)) != sizeof(hdr))
+ die("Unable to reread header of %s", pack_data->pack_name);
+ if (lseek(pack_fd, 0, SEEK_SET) != 0)
+ die("Failed seeking to start: %s", strerror(errno));
+ hdr.hdr_entries = htonl(object_count);
+ write_or_die(pack_fd, &hdr, sizeof(hdr));
+
+ SHA1_Init(&c);
+ SHA1_Update(&c, &hdr, sizeof(hdr));
+
+ buf = xmalloc(buf_sz);
+ for (;;) {
+ size_t n = xread(pack_fd, buf, buf_sz);
+ if (!n)
+ break;
+ if (n < 0)
+ die("Failed to checksum %s", pack_data->pack_name);
+ SHA1_Update(&c, buf, n);
+ }
+ free(buf);
+
+ SHA1_Final(pack_data->sha1, &c);
+ write_or_die(pack_fd, pack_data->sha1, sizeof(pack_data->sha1));
+ close(pack_fd);
+}
+
+static int oecmp (const void *a_, const void *b_)
+{
+ struct object_entry *a = *((struct object_entry**)a_);
+ struct object_entry *b = *((struct object_entry**)b_);
+ return hashcmp(a->sha1, b->sha1);
+}
+
+static char *create_index(void)
+{
+ static char tmpfile[PATH_MAX];
+ SHA_CTX ctx;
+ struct sha1file *f;
+ struct object_entry **idx, **c, **last, *e;
+ struct object_entry_pool *o;
+ uint32_t array[256];
+ int i, idx_fd;
+
+ /* Build the sorted table of object IDs. */
+ idx = xmalloc(object_count * sizeof(struct object_entry*));
+ c = idx;
+ for (o = blocks; o; o = o->next_pool)
+ for (e = o->next_free; e-- != o->entries;)
+ if (pack_id == e->pack_id)
+ *c++ = e;
+ last = idx + object_count;
+ if (c != last)
+ die("internal consistency error creating the index");
+ qsort(idx, object_count, sizeof(struct object_entry*), oecmp);
+
+ /* Generate the fan-out array. */
+ c = idx;
+ for (i = 0; i < 256; i++) {
+ struct object_entry **next = c;;
+ while (next < last) {
+ if ((*next)->sha1[0] != i)
+ break;
+ next++;
+ }
+ array[i] = htonl(next - idx);
+ c = next;
+ }
+
+ snprintf(tmpfile, sizeof(tmpfile),
+ "%s/index_XXXXXX", get_object_directory());
+ idx_fd = mkstemp(tmpfile);
+ if (idx_fd < 0)
+ die("Can't create %s: %s", tmpfile, strerror(errno));
+ f = sha1fd(idx_fd, tmpfile);
+ sha1write(f, array, 256 * sizeof(int));
+ SHA1_Init(&ctx);
+ for (c = idx; c != last; c++) {
+ uint32_t offset = htonl((*c)->offset);
+ sha1write(f, &offset, 4);
+ sha1write(f, (*c)->sha1, sizeof((*c)->sha1));
+ SHA1_Update(&ctx, (*c)->sha1, 20);
+ }
+ sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
+ sha1close(f, NULL, 1);
+ free(idx);
+ SHA1_Final(pack_data->sha1, &ctx);
+ return tmpfile;
+}
+
+static char *keep_pack(char *curr_index_name)
+{
+ static char name[PATH_MAX];
+ static char *keep_msg = "fast-import";
+ int keep_fd;
+
+ chmod(pack_data->pack_name, 0444);
+ chmod(curr_index_name, 0444);
+
+ snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
+ get_object_directory(), sha1_to_hex(pack_data->sha1));
+ keep_fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
+ if (keep_fd < 0)
+ die("cannot create keep file");
+ write(keep_fd, keep_msg, strlen(keep_msg));
+ close(keep_fd);
+
+ snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
+ get_object_directory(), sha1_to_hex(pack_data->sha1));
+ if (move_temp_to_file(pack_data->pack_name, name))
+ die("cannot store pack file");
+
+ snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
+ get_object_directory(), sha1_to_hex(pack_data->sha1));
+ if (move_temp_to_file(curr_index_name, name))
+ die("cannot store index file");
+ return name;
+}
+
+static void unkeep_all_packs(void)
+{
+ static char name[PATH_MAX];
+ int k;
+
+ for (k = 0; k < pack_id; k++) {
+ struct packed_git *p = all_packs[k];
+ snprintf(name, sizeof(name), "%s/pack/pack-%s.keep",
+ get_object_directory(), sha1_to_hex(p->sha1));
+ unlink(name);
+ }
+}
+
+static void end_packfile(void)
+{
+ struct packed_git *old_p = pack_data, *new_p;
+
+ if (object_count) {
+ char *idx_name;
+ int i;
+ struct branch *b;
+ struct tag *t;
+
+ fixup_header_footer();
+ idx_name = keep_pack(create_index());
+
+ /* Register the packfile with core git's machinary. */
+ new_p = add_packed_git(idx_name, strlen(idx_name), 1);
+ if (!new_p)
+ die("core git rejected index %s", idx_name);
+ new_p->windows = old_p->windows;
+ all_packs[pack_id] = new_p;
+ install_packed_git(new_p);
+
+ /* Print the boundary */
+ if (pack_edges) {
+ fprintf(pack_edges, "%s:", new_p->pack_name);
+ for (i = 0; i < branch_table_sz; i++) {
+ for (b = branch_table[i]; b; b = b->table_next_branch) {
+ if (b->pack_id == pack_id)
+ fprintf(pack_edges, " %s", sha1_to_hex(b->sha1));
+ }
+ }
+ for (t = first_tag; t; t = t->next_tag) {
+ if (t->pack_id == pack_id)
+ fprintf(pack_edges, " %s", sha1_to_hex(t->sha1));
+ }
+ fputc('\n', pack_edges);
+ fflush(pack_edges);
+ }
+
+ pack_id++;
+ }
+ else
+ unlink(old_p->pack_name);
+ free(old_p);
+
+ /* We can't carry a delta across packfiles. */
+ free(last_blob.data);
+ last_blob.data = NULL;
+ last_blob.len = 0;
+ last_blob.offset = 0;
+ last_blob.depth = 0;
+}
+
+static void cycle_packfile(void)
+{
+ end_packfile();
+ start_packfile();
+}
+
+static size_t encode_header(
+ enum object_type type,
+ size_t size,
+ unsigned char *hdr)
+{
+ int n = 1;
+ unsigned char c;
+
+ if (type < OBJ_COMMIT || type > OBJ_REF_DELTA)
+ die("bad type %d", type);
+
+ c = (type << 4) | (size & 15);
+ size >>= 4;
+ while (size) {
+ *hdr++ = c | 0x80;
+ c = size & 0x7f;
+ size >>= 7;
+ n++;
+ }
+ *hdr = c;
+ return n;
+}
+
+static int store_object(
+ enum object_type type,
+ void *dat,
+ size_t datlen,
+ struct last_object *last,
+ unsigned char *sha1out,
+ uintmax_t mark)
+{
+ void *out, *delta;
+ struct object_entry *e;
+ unsigned char hdr[96];
+ unsigned char sha1[20];
+ unsigned long hdrlen, deltalen;
+ SHA_CTX c;
+ z_stream s;
+
+ hdrlen = sprintf((char*)hdr,"%s %lu", type_names[type],
+ (unsigned long)datlen) + 1;
+ SHA1_Init(&c);
+ SHA1_Update(&c, hdr, hdrlen);
+ SHA1_Update(&c, dat, datlen);
+ SHA1_Final(sha1, &c);
+ if (sha1out)
+ hashcpy(sha1out, sha1);
+
+ e = insert_object(sha1);
+ if (mark)
+ insert_mark(mark, e);
+ if (e->offset) {
+ duplicate_count_by_type[type]++;
+ return 1;
+ }
+
+ if (last && last->data && last->depth < max_depth) {
+ delta = diff_delta(last->data, last->len,
+ dat, datlen,
+ &deltalen, 0);
+ if (delta && deltalen >= datlen) {
+ free(delta);
+ delta = NULL;
+ }
+ } else
+ delta = NULL;
+
+ memset(&s, 0, sizeof(s));
+ deflateInit(&s, zlib_compression_level);
+ if (delta) {
+ s.next_in = delta;
+ s.avail_in = deltalen;
+ } else {
+ s.next_in = dat;
+ s.avail_in = datlen;
+ }
+ s.avail_out = deflateBound(&s, s.avail_in);
+ s.next_out = out = xmalloc(s.avail_out);
+ while (deflate(&s, Z_FINISH) == Z_OK)
+ /* nothing */;
+ deflateEnd(&s);
+
+ /* Determine if we should auto-checkpoint. */
+ if ((pack_size + 60 + s.total_out) > max_packsize
+ || (pack_size + 60 + s.total_out) < pack_size) {
+
+ /* This new object needs to *not* have the current pack_id. */
+ e->pack_id = pack_id + 1;
+ cycle_packfile();
+
+ /* We cannot carry a delta into the new pack. */
+ if (delta) {
+ free(delta);
+ delta = NULL;
+
+ memset(&s, 0, sizeof(s));
+ deflateInit(&s, zlib_compression_level);
+ s.next_in = dat;
+ s.avail_in = datlen;
+ s.avail_out = deflateBound(&s, s.avail_in);
+ s.next_out = out = xrealloc(out, s.avail_out);
+ while (deflate(&s, Z_FINISH) == Z_OK)
+ /* nothing */;
+ deflateEnd(&s);
+ }
+ }
+
+ e->type = type;
+ e->pack_id = pack_id;
+ e->offset = pack_size;
+ object_count++;
+ object_count_by_type[type]++;
+
+ if (delta) {
+ unsigned long ofs = e->offset - last->offset;
+ unsigned pos = sizeof(hdr) - 1;
+
+ delta_count_by_type[type]++;
+ last->depth++;
+
+ hdrlen = encode_header(OBJ_OFS_DELTA, deltalen, hdr);
+ write_or_die(pack_data->pack_fd, hdr, hdrlen);
+ pack_size += hdrlen;
+
+ hdr[pos] = ofs & 127;
+ while (ofs >>= 7)
+ hdr[--pos] = 128 | (--ofs & 127);
+ write_or_die(pack_data->pack_fd, hdr + pos, sizeof(hdr) - pos);
+ pack_size += sizeof(hdr) - pos;
+ } else {
+ if (last)
+ last->depth = 0;
+ hdrlen = encode_header(type, datlen, hdr);
+ write_or_die(pack_data->pack_fd, hdr, hdrlen);
+ pack_size += hdrlen;
+ }
+
+ write_or_die(pack_data->pack_fd, out, s.total_out);
+ pack_size += s.total_out;
+
+ free(out);
+ free(delta);
+ if (last) {
+ if (!last->no_free)
+ free(last->data);
+ last->data = dat;
+ last->offset = e->offset;
+ last->len = datlen;
+ }
+ return 0;
+}
+
+static void *gfi_unpack_entry(
+ struct object_entry *oe,
+ unsigned long *sizep)
+{
+ static char type[20];
+ struct packed_git *p = all_packs[oe->pack_id];
+ if (p == pack_data)
+ p->pack_size = pack_size + 20;
+ return unpack_entry(p, oe->offset, type, sizep);
+}
+
+static const char *get_mode(const char *str, uint16_t *modep)
+{
+ unsigned char c;
+ uint16_t mode = 0;
+
+ while ((c = *str++) != ' ') {
+ if (c < '0' || c > '7')
+ return NULL;
+ mode = (mode << 3) + (c - '0');
+ }
+ *modep = mode;
+ return str;
+}
+
+static void load_tree(struct tree_entry *root)
+{
+ unsigned char* sha1 = root->versions[1].sha1;
+ struct object_entry *myoe;
+ struct tree_content *t;
+ unsigned long size;
+ char *buf;
+ const char *c;
+
+ root->tree = t = new_tree_content(8);
+ if (is_null_sha1(sha1))
+ return;
+
+ myoe = find_object(sha1);
+ if (myoe) {
+ if (myoe->type != OBJ_TREE)
+ die("Not a tree: %s", sha1_to_hex(sha1));
+ t->delta_depth = 0;
+ buf = gfi_unpack_entry(myoe, &size);
+ } else {
+ char type[20];
+ buf = read_sha1_file(sha1, type, &size);
+ if (!buf || strcmp(type, tree_type))
+ die("Can't load tree %s", sha1_to_hex(sha1));
+ }
+
+ c = buf;
+ while (c != (buf + size)) {
+ struct tree_entry *e = new_tree_entry();
+
+ if (t->entry_count == t->entry_capacity)
+ root->tree = t = grow_tree_content(t, 8);
+ t->entries[t->entry_count++] = e;
+
+ e->tree = NULL;
+ c = get_mode(c, &e->versions[1].mode);
+ if (!c)
+ die("Corrupt mode in %s", sha1_to_hex(sha1));
+ e->versions[0].mode = e->versions[1].mode;
+ e->name = to_atom(c, (unsigned short)strlen(c));
+ c += e->name->str_len + 1;
+ hashcpy(e->versions[0].sha1, (unsigned char*)c);
+ hashcpy(e->versions[1].sha1, (unsigned char*)c);
+ c += 20;
+ }
+ free(buf);
+}
+
+static int tecmp0 (const void *_a, const void *_b)
+{
+ struct tree_entry *a = *((struct tree_entry**)_a);
+ struct tree_entry *b = *((struct tree_entry**)_b);
+ return base_name_compare(
+ a->name->str_dat, a->name->str_len, a->versions[0].mode,
+ b->name->str_dat, b->name->str_len, b->versions[0].mode);
+}
+
+static int tecmp1 (const void *_a, const void *_b)
+{
+ struct tree_entry *a = *((struct tree_entry**)_a);
+ struct tree_entry *b = *((struct tree_entry**)_b);
+ return base_name_compare(
+ a->name->str_dat, a->name->str_len, a->versions[1].mode,
+ b->name->str_dat, b->name->str_len, b->versions[1].mode);
+}
+
+static void mktree(struct tree_content *t,
+ int v,
+ unsigned long *szp,
+ struct dbuf *b)
+{
+ size_t maxlen = 0;
+ unsigned int i;
+ char *c;
+
+ if (!v)
+ qsort(t->entries,t->entry_count,sizeof(t->entries[0]),tecmp0);
+ else
+ qsort(t->entries,t->entry_count,sizeof(t->entries[0]),tecmp1);
+
+ for (i = 0; i < t->entry_count; i++) {
+ if (t->entries[i]->versions[v].mode)
+ maxlen += t->entries[i]->name->str_len + 34;
+ }
+
+ size_dbuf(b, maxlen);
+ c = b->buffer;
+ for (i = 0; i < t->entry_count; i++) {
+ struct tree_entry *e = t->entries[i];
+ if (!e->versions[v].mode)
+ continue;
+ c += sprintf(c, "%o", (unsigned int)e->versions[v].mode);
+ *c++ = ' ';
+ strcpy(c, e->name->str_dat);
+ c += e->name->str_len + 1;
+ hashcpy((unsigned char*)c, e->versions[v].sha1);
+ c += 20;
+ }
+ *szp = c - (char*)b->buffer;
+}
+
+static void store_tree(struct tree_entry *root)
+{
+ struct tree_content *t = root->tree;
+ unsigned int i, j, del;
+ unsigned long new_len;
+ struct last_object lo;
+ struct object_entry *le;
+
+ if (!is_null_sha1(root->versions[1].sha1))
+ return;
+
+ for (i = 0; i < t->entry_count; i++) {
+ if (t->entries[i]->tree)
+ store_tree(t->entries[i]);
+ }
+
+ le = find_object(root->versions[0].sha1);
+ if (!S_ISDIR(root->versions[0].mode)
+ || !le
+ || le->pack_id != pack_id) {
+ lo.data = NULL;
+ lo.depth = 0;
+ } else {
+ mktree(t, 0, &lo.len, &old_tree);
+ lo.data = old_tree.buffer;
+ lo.offset = le->offset;
+ lo.depth = t->delta_depth;
+ lo.no_free = 1;
+ }
+
+ mktree(t, 1, &new_len, &new_tree);
+ store_object(OBJ_TREE, new_tree.buffer, new_len,
+ &lo, root->versions[1].sha1, 0);
+
+ t->delta_depth = lo.depth;
+ for (i = 0, j = 0, del = 0; i < t->entry_count; i++) {
+ struct tree_entry *e = t->entries[i];
+ if (e->versions[1].mode) {
+ e->versions[0].mode = e->versions[1].mode;
+ hashcpy(e->versions[0].sha1, e->versions[1].sha1);
+ t->entries[j++] = e;
+ } else {
+ release_tree_entry(e);
+ del++;
+ }
+ }
+ t->entry_count -= del;
+}
+
+static int tree_content_set(
+ struct tree_entry *root,
+ const char *p,
+ const unsigned char *sha1,
+ const uint16_t mode)
+{
+ struct tree_content *t = root->tree;
+ const char *slash1;
+ unsigned int i, n;
+ struct tree_entry *e;
+
+ slash1 = strchr(p, '/');
+ if (slash1)
+ n = slash1 - p;
+ else
+ n = strlen(p);
+
+ for (i = 0; i < t->entry_count; i++) {
+ e = t->entries[i];
+ if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+ if (!slash1) {
+ if (e->versions[1].mode == mode
+ && !hashcmp(e->versions[1].sha1, sha1))
+ return 0;
+ e->versions[1].mode = mode;
+ hashcpy(e->versions[1].sha1, sha1);
+ if (e->tree) {
+ release_tree_content_recursive(e->tree);
+ e->tree = NULL;
+ }
+ hashclr(root->versions[1].sha1);
+ return 1;
+ }
+ if (!S_ISDIR(e->versions[1].mode)) {
+ e->tree = new_tree_content(8);
+ e->versions[1].mode = S_IFDIR;
+ }
+ if (!e->tree)
+ load_tree(e);
+ if (tree_content_set(e, slash1 + 1, sha1, mode)) {
+ hashclr(root->versions[1].sha1);
+ return 1;
+ }
+ return 0;
+ }
+ }
+
+ if (t->entry_count == t->entry_capacity)
+ root->tree = t = grow_tree_content(t, 8);
+ e = new_tree_entry();
+ e->name = to_atom(p, (unsigned short)n);
+ e->versions[0].mode = 0;
+ hashclr(e->versions[0].sha1);
+ t->entries[t->entry_count++] = e;
+ if (slash1) {
+ e->tree = new_tree_content(8);
+ e->versions[1].mode = S_IFDIR;
+ tree_content_set(e, slash1 + 1, sha1, mode);
+ } else {
+ e->tree = NULL;
+ e->versions[1].mode = mode;
+ hashcpy(e->versions[1].sha1, sha1);
+ }
+ hashclr(root->versions[1].sha1);
+ return 1;
+}
+
+static int tree_content_remove(struct tree_entry *root, const char *p)
+{
+ struct tree_content *t = root->tree;
+ const char *slash1;
+ unsigned int i, n;
+ struct tree_entry *e;
+
+ slash1 = strchr(p, '/');
+ if (slash1)
+ n = slash1 - p;
+ else
+ n = strlen(p);
+
+ for (i = 0; i < t->entry_count; i++) {
+ e = t->entries[i];
+ if (e->name->str_len == n && !strncmp(p, e->name->str_dat, n)) {
+ if (!slash1 || !S_ISDIR(e->versions[1].mode))
+ goto del_entry;
+ if (!e->tree)
+ load_tree(e);
+ if (tree_content_remove(e, slash1 + 1)) {
+ for (n = 0; n < e->tree->entry_count; n++) {
+ if (e->tree->entries[n]->versions[1].mode) {
+ hashclr(root->versions[1].sha1);
+ return 1;
+ }
+ }
+ goto del_entry;
+ }
+ return 0;
+ }
+ }
+ return 0;
+
+del_entry:
+ if (e->tree) {
+ release_tree_content_recursive(e->tree);
+ e->tree = NULL;
+ }
+ e->versions[1].mode = 0;
+ hashclr(e->versions[1].sha1);
+ hashclr(root->versions[1].sha1);
+ return 1;
+}
+
+static int update_branch(struct branch *b)
+{
+ static const char *msg = "fast-import";
+ struct ref_lock *lock;
+ unsigned char old_sha1[20];
+
+ if (read_ref(b->name, old_sha1))
+ hashclr(old_sha1);
+ lock = lock_any_ref_for_update(b->name, old_sha1);
+ if (!lock)
+ return error("Unable to lock %s", b->name);
+ if (!force_update && !is_null_sha1(old_sha1)) {
+ struct commit *old_cmit, *new_cmit;
+
+ old_cmit = lookup_commit_reference_gently(old_sha1, 0);
+ new_cmit = lookup_commit_reference_gently(b->sha1, 0);
+ if (!old_cmit || !new_cmit) {
+ unlock_ref(lock);
+ return error("Branch %s is missing commits.", b->name);
+ }
+
+ if (!in_merge_bases(old_cmit, &new_cmit, 1)) {
+ unlock_ref(lock);
+ warn("Not updating %s"
+ " (new tip %s does not contain %s)",
+ b->name, sha1_to_hex(b->sha1), sha1_to_hex(old_sha1));
+ return -1;
+ }
+ }
+ if (write_ref_sha1(lock, b->sha1, msg) < 0)
+ return error("Unable to update %s", b->name);
+ return 0;
+}
+
+static void dump_branches(void)
+{
+ unsigned int i;
+ struct branch *b;
+
+ for (i = 0; i < branch_table_sz; i++) {
+ for (b = branch_table[i]; b; b = b->table_next_branch)
+ failure |= update_branch(b);
+ }
+}
+
+static void dump_tags(void)
+{
+ static const char *msg = "fast-import";
+ struct tag *t;
+ struct ref_lock *lock;
+ char ref_name[PATH_MAX];
+
+ for (t = first_tag; t; t = t->next_tag) {
+ sprintf(ref_name, "tags/%s", t->name);
+ lock = lock_ref_sha1(ref_name, NULL);
+ if (!lock || write_ref_sha1(lock, t->sha1, msg) < 0)
+ failure |= error("Unable to update %s", ref_name);
+ }
+}
+
+static void dump_marks_helper(FILE *f,
+ uintmax_t base,
+ struct mark_set *m)
+{
+ uintmax_t k;
+ if (m->shift) {
+ for (k = 0; k < 1024; k++) {
+ if (m->data.sets[k])
+ dump_marks_helper(f, (base + k) << m->shift,
+ m->data.sets[k]);
+ }
+ } else {
+ for (k = 0; k < 1024; k++) {
+ if (m->data.marked[k])
+ fprintf(f, ":%ju %s\n", base + k,
+ sha1_to_hex(m->data.marked[k]->sha1));
+ }
+ }
+}
+
+static void dump_marks(void)
+{
+ if (mark_file)
+ {
+ FILE *f = fopen(mark_file, "w");
+ if (f) {
+ dump_marks_helper(f, 0, marks);
+ fclose(f);
+ } else
+ failure |= error("Unable to write marks file %s: %s",
+ mark_file, strerror(errno));
+ }
+}
+
+static void read_next_command(void)
+{
+ read_line(&command_buf, stdin, '\n');
+}
+
+static void cmd_mark(void)
+{
+ if (!strncmp("mark :", command_buf.buf, 6)) {
+ next_mark = strtoumax(command_buf.buf + 6, NULL, 10);
+ read_next_command();
+ }
+ else
+ next_mark = 0;
+}
+
+static void *cmd_data (size_t *size)
+{
+ size_t length;
+ char *buffer;
+
+ if (strncmp("data ", command_buf.buf, 5))
+ die("Expected 'data n' command, found: %s", command_buf.buf);
+
+ if (!strncmp("<<", command_buf.buf + 5, 2)) {
+ char *term = xstrdup(command_buf.buf + 5 + 2);
+ size_t sz = 8192, term_len = command_buf.len - 5 - 2;
+ length = 0;
+ buffer = xmalloc(sz);
+ for (;;) {
+ read_next_command();
+ if (command_buf.eof)
+ die("EOF in data (terminator '%s' not found)", term);
+ if (term_len == command_buf.len
+ && !strcmp(term, command_buf.buf))
+ break;
+ if (sz < (length + command_buf.len)) {
+ sz = sz * 3 / 2 + 16;
+ if (sz < (length + command_buf.len))
+ sz = length + command_buf.len;
+ buffer = xrealloc(buffer, sz);
+ }
+ memcpy(buffer + length,
+ command_buf.buf,
+ command_buf.len - 1);
+ length += command_buf.len - 1;
+ buffer[length++] = '\n';
+ }
+ free(term);
+ }
+ else {
+ size_t n = 0;
+ length = strtoul(command_buf.buf + 5, NULL, 10);
+ buffer = xmalloc(length);
+ while (n < length) {
+ size_t s = fread(buffer + n, 1, length - n, stdin);
+ if (!s && feof(stdin))
+ die("EOF in data (%lu bytes remaining)",
+ (unsigned long)(length - n));
+ n += s;
+ }
+ }
+
+ if (fgetc(stdin) != '\n')
+ die("An lf did not trail the binary data as expected.");
+
+ *size = length;
+ return buffer;
+}
+
+static int validate_raw_date(const char *src, char *result, int maxlen)
+{
+ const char *orig_src = src;
+ char *endp, sign;
+
+ strtoul(src, &endp, 10);
+ if (endp == src || *endp != ' ')
+ return -1;
+
+ src = endp + 1;
+ if (*src != '-' && *src != '+')
+ return -1;
+ sign = *src;
+
+ strtoul(src + 1, &endp, 10);
+ if (endp == src || *endp || (endp - orig_src) >= maxlen)
+ return -1;
+
+ strcpy(result, orig_src);
+ return 0;
+}
+
+static char *parse_ident(const char *buf)
+{
+ const char *gt;
+ size_t name_len;
+ char *ident;
+
+ gt = strrchr(buf, '>');
+ if (!gt)
+ die("Missing > in ident string: %s", buf);
+ gt++;
+ if (*gt != ' ')
+ die("Missing space after > in ident string: %s", buf);
+ gt++;
+ name_len = gt - buf;
+ ident = xmalloc(name_len + 24);
+ strncpy(ident, buf, name_len);
+
+ switch (whenspec) {
+ case WHENSPEC_RAW:
+ if (validate_raw_date(gt, ident + name_len, 24) < 0)
+ die("Invalid raw date \"%s\" in ident: %s", gt, buf);
+ break;
+ case WHENSPEC_RFC2822:
+ if (parse_date(gt, ident + name_len, 24) < 0)
+ die("Invalid rfc2822 date \"%s\" in ident: %s", gt, buf);
+ break;
+ case WHENSPEC_NOW:
+ if (strcmp("now", gt))
+ die("Date in ident must be 'now': %s", buf);
+ datestamp(ident + name_len, 24);
+ break;
+ }
+
+ return ident;
+}
+
+static void cmd_new_blob(void)
+{
+ size_t l;
+ void *d;
+
+ read_next_command();
+ cmd_mark();
+ d = cmd_data(&l);
+
+ if (store_object(OBJ_BLOB, d, l, &last_blob, NULL, next_mark))
+ free(d);
+}
+
+static void unload_one_branch(void)
+{
+ while (cur_active_branches
+ && cur_active_branches >= max_active_branches) {
+ unsigned long min_commit = ULONG_MAX;
+ struct branch *e, *l = NULL, *p = NULL;
+
+ for (e = active_branches; e; e = e->active_next_branch) {
+ if (e->last_commit < min_commit) {
+ p = l;
+ min_commit = e->last_commit;
+ }
+ l = e;
+ }
+
+ if (p) {
+ e = p->active_next_branch;
+ p->active_next_branch = e->active_next_branch;
+ } else {
+ e = active_branches;
+ active_branches = e->active_next_branch;
+ }
+ e->active_next_branch = NULL;
+ if (e->branch_tree.tree) {
+ release_tree_content_recursive(e->branch_tree.tree);
+ e->branch_tree.tree = NULL;
+ }
+ cur_active_branches--;
+ }
+}
+
+static void load_branch(struct branch *b)
+{
+ load_tree(&b->branch_tree);
+ b->active_next_branch = active_branches;
+ active_branches = b;
+ cur_active_branches++;
+ branch_load_count++;
+}
+
+static void file_change_m(struct branch *b)
+{
+ const char *p = command_buf.buf + 2;
+ char *p_uq;
+ const char *endp;
+ struct object_entry *oe = oe;
+ unsigned char sha1[20];
+ uint16_t mode, inline_data = 0;
+ char type[20];
+
+ p = get_mode(p, &mode);
+ if (!p)
+ die("Corrupt mode: %s", command_buf.buf);
+ switch (mode) {
+ case S_IFREG | 0644:
+ case S_IFREG | 0755:
+ case S_IFLNK:
+ case 0644:
+ case 0755:
+ /* ok */
+ break;
+ default:
+ die("Corrupt mode: %s", command_buf.buf);
+ }
+
+ if (*p == ':') {
+ char *x;
+ oe = find_mark(strtoumax(p + 1, &x, 10));
+ hashcpy(sha1, oe->sha1);
+ p = x;
+ } else if (!strncmp("inline", p, 6)) {
+ inline_data = 1;
+ p += 6;
+ } else {
+ if (get_sha1_hex(p, sha1))
+ die("Invalid SHA1: %s", command_buf.buf);
+ oe = find_object(sha1);
+ p += 40;
+ }
+ if (*p++ != ' ')
+ die("Missing space after SHA1: %s", command_buf.buf);
+
+ p_uq = unquote_c_style(p, &endp);
+ if (p_uq) {
+ if (*endp)
+ die("Garbage after path in: %s", command_buf.buf);
+ p = p_uq;
+ }
+
+ if (inline_data) {
+ size_t l;
+ void *d;
+ if (!p_uq)
+ p = p_uq = xstrdup(p);
+ read_next_command();
+ d = cmd_data(&l);
+ if (store_object(OBJ_BLOB, d, l, &last_blob, sha1, 0))
+ free(d);
+ } else if (oe) {
+ if (oe->type != OBJ_BLOB)
+ die("Not a blob (actually a %s): %s",
+ command_buf.buf, type_names[oe->type]);
+ } else {
+ if (sha1_object_info(sha1, type, NULL))
+ die("Blob not found: %s", command_buf.buf);
+ if (strcmp(blob_type, type))
+ die("Not a blob (actually a %s): %s",
+ command_buf.buf, type);
+ }
+
+ tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode);
+ free(p_uq);
+}
+
+static void file_change_d(struct branch *b)
+{
+ const char *p = command_buf.buf + 2;
+ char *p_uq;
+ const char *endp;
+
+ p_uq = unquote_c_style(p, &endp);
+ if (p_uq) {
+ if (*endp)
+ die("Garbage after path in: %s", command_buf.buf);
+ p = p_uq;
+ }
+ tree_content_remove(&b->branch_tree, p);
+ free(p_uq);
+}
+
+static void file_change_deleteall(struct branch *b)
+{
+ release_tree_content_recursive(b->branch_tree.tree);
+ hashclr(b->branch_tree.versions[0].sha1);
+ hashclr(b->branch_tree.versions[1].sha1);
+ load_tree(&b->branch_tree);
+}
+
+static void cmd_from(struct branch *b)
+{
+ const char *from;
+ struct branch *s;
+
+ if (strncmp("from ", command_buf.buf, 5))
+ return;
+
+ if (b->branch_tree.tree) {
+ release_tree_content_recursive(b->branch_tree.tree);
+ b->branch_tree.tree = NULL;
+ }
+
+ from = strchr(command_buf.buf, ' ') + 1;
+ s = lookup_branch(from);
+ if (b == s)
+ die("Can't create a branch from itself: %s", b->name);
+ else if (s) {
+ unsigned char *t = s->branch_tree.versions[1].sha1;
+ hashcpy(b->sha1, s->sha1);
+ hashcpy(b->branch_tree.versions[0].sha1, t);
+ hashcpy(b->branch_tree.versions[1].sha1, t);
+ } else if (*from == ':') {
+ uintmax_t idnum = strtoumax(from + 1, NULL, 10);
+ struct object_entry *oe = find_mark(idnum);
+ unsigned long size;
+ char *buf;
+ if (oe->type != OBJ_COMMIT)
+ die("Mark :%ju not a commit", idnum);
+ hashcpy(b->sha1, oe->sha1);
+ buf = gfi_unpack_entry(oe, &size);
+ if (!buf || size < 46)
+ die("Not a valid commit: %s", from);
+ if (memcmp("tree ", buf, 5)
+ || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
+ die("The commit %s is corrupt", sha1_to_hex(b->sha1));
+ free(buf);
+ hashcpy(b->branch_tree.versions[0].sha1,
+ b->branch_tree.versions[1].sha1);
+ } else if (!get_sha1(from, b->sha1)) {
+ if (is_null_sha1(b->sha1)) {
+ hashclr(b->branch_tree.versions[0].sha1);
+ hashclr(b->branch_tree.versions[1].sha1);
+ } else {
+ unsigned long size;
+ char *buf;
+
+ buf = read_object_with_reference(b->sha1,
+ type_names[OBJ_COMMIT], &size, b->sha1);
+ if (!buf || size < 46)
+ die("Not a valid commit: %s", from);
+ if (memcmp("tree ", buf, 5)
+ || get_sha1_hex(buf + 5, b->branch_tree.versions[1].sha1))
+ die("The commit %s is corrupt", sha1_to_hex(b->sha1));
+ free(buf);
+ hashcpy(b->branch_tree.versions[0].sha1,
+ b->branch_tree.versions[1].sha1);
+ }
+ } else
+ die("Invalid ref name or SHA1 expression: %s", from);
+
+ read_next_command();
+}
+
+static struct hash_list *cmd_merge(unsigned int *count)
+{
+ struct hash_list *list = NULL, *n, *e = e;
+ const char *from;
+ struct branch *s;
+
+ *count = 0;
+ while (!strncmp("merge ", command_buf.buf, 6)) {
+ from = strchr(command_buf.buf, ' ') + 1;
+ n = xmalloc(sizeof(*n));
+ s = lookup_branch(from);
+ if (s)
+ hashcpy(n->sha1, s->sha1);
+ else if (*from == ':') {
+ uintmax_t idnum = strtoumax(from + 1, NULL, 10);
+ struct object_entry *oe = find_mark(idnum);
+ if (oe->type != OBJ_COMMIT)
+ die("Mark :%ju not a commit", idnum);
+ hashcpy(n->sha1, oe->sha1);
+ } else if (get_sha1(from, n->sha1))
+ die("Invalid ref name or SHA1 expression: %s", from);
+
+ n->next = NULL;
+ if (list)
+ e->next = n;
+ else
+ list = n;
+ e = n;
+ (*count)++;
+ read_next_command();
+ }
+ return list;
+}
+
+static void cmd_new_commit(void)
+{
+ struct branch *b;
+ void *msg;
+ size_t msglen;
+ char *sp;
+ char *author = NULL;
+ char *committer = NULL;
+ struct hash_list *merge_list = NULL;
+ unsigned int merge_count;
+
+ /* Obtain the branch name from the rest of our command */
+ sp = strchr(command_buf.buf, ' ') + 1;
+ b = lookup_branch(sp);
+ if (!b)
+ b = new_branch(sp);
+
+ read_next_command();
+ cmd_mark();
+ if (!strncmp("author ", command_buf.buf, 7)) {
+ author = parse_ident(command_buf.buf + 7);
+ read_next_command();
+ }
+ if (!strncmp("committer ", command_buf.buf, 10)) {
+ committer = parse_ident(command_buf.buf + 10);
+ read_next_command();
+ }
+ if (!committer)
+ die("Expected committer but didn't get one");
+ msg = cmd_data(&msglen);
+ read_next_command();
+ cmd_from(b);
+ merge_list = cmd_merge(&merge_count);
+
+ /* ensure the branch is active/loaded */
+ if (!b->branch_tree.tree || !max_active_branches) {
+ unload_one_branch();
+ load_branch(b);
+ }
+
+ /* file_change* */
+ for (;;) {
+ if (1 == command_buf.len)
+ break;
+ else if (!strncmp("M ", command_buf.buf, 2))
+ file_change_m(b);
+ else if (!strncmp("D ", command_buf.buf, 2))
+ file_change_d(b);
+ else if (!strcmp("deleteall", command_buf.buf))
+ file_change_deleteall(b);
+ else
+ die("Unsupported file_change: %s", command_buf.buf);
+ read_next_command();
+ }
+
+ /* build the tree and the commit */
+ store_tree(&b->branch_tree);
+ hashcpy(b->branch_tree.versions[0].sha1,
+ b->branch_tree.versions[1].sha1);
+ size_dbuf(&new_data, 114 + msglen
+ + merge_count * 49
+ + (author
+ ? strlen(author) + strlen(committer)
+ : 2 * strlen(committer)));
+ sp = new_data.buffer;
+ sp += sprintf(sp, "tree %s\n",
+ sha1_to_hex(b->branch_tree.versions[1].sha1));
+ if (!is_null_sha1(b->sha1))
+ sp += sprintf(sp, "parent %s\n", sha1_to_hex(b->sha1));
+ while (merge_list) {
+ struct hash_list *next = merge_list->next;
+ sp += sprintf(sp, "parent %s\n", sha1_to_hex(merge_list->sha1));
+ free(merge_list);
+ merge_list = next;
+ }
+ sp += sprintf(sp, "author %s\n", author ? author : committer);
+ sp += sprintf(sp, "committer %s\n", committer);
+ *sp++ = '\n';
+ memcpy(sp, msg, msglen);
+ sp += msglen;
+ free(author);
+ free(committer);
+ free(msg);
+
+ if (!store_object(OBJ_COMMIT,
+ new_data.buffer, sp - (char*)new_data.buffer,
+ NULL, b->sha1, next_mark))
+ b->pack_id = pack_id;
+ b->last_commit = object_count_by_type[OBJ_COMMIT];
+}
+
+static void cmd_new_tag(void)
+{
+ char *sp;
+ const char *from;
+ char *tagger;
+ struct branch *s;
+ void *msg;
+ size_t msglen;
+ struct tag *t;
+ uintmax_t from_mark = 0;
+ unsigned char sha1[20];
+
+ /* Obtain the new tag name from the rest of our command */
+ sp = strchr(command_buf.buf, ' ') + 1;
+ t = pool_alloc(sizeof(struct tag));
+ t->next_tag = NULL;
+ t->name = pool_strdup(sp);
+ if (last_tag)
+ last_tag->next_tag = t;
+ else
+ first_tag = t;
+ last_tag = t;
+ read_next_command();
+
+ /* from ... */
+ if (strncmp("from ", command_buf.buf, 5))
+ die("Expected from command, got %s", command_buf.buf);
+ from = strchr(command_buf.buf, ' ') + 1;
+ s = lookup_branch(from);
+ if (s) {
+ hashcpy(sha1, s->sha1);
+ } else if (*from == ':') {
+ struct object_entry *oe;
+ from_mark = strtoumax(from + 1, NULL, 10);
+ oe = find_mark(from_mark);
+ if (oe->type != OBJ_COMMIT)
+ die("Mark :%ju not a commit", from_mark);
+ hashcpy(sha1, oe->sha1);
+ } else if (!get_sha1(from, sha1)) {
+ unsigned long size;
+ char *buf;
+
+ buf = read_object_with_reference(sha1,
+ type_names[OBJ_COMMIT], &size, sha1);
+ if (!buf || size < 46)
+ die("Not a valid commit: %s", from);
+ free(buf);
+ } else
+ die("Invalid ref name or SHA1 expression: %s", from);
+ read_next_command();
+
+ /* tagger ... */
+ if (strncmp("tagger ", command_buf.buf, 7))
+ die("Expected tagger command, got %s", command_buf.buf);
+ tagger = parse_ident(command_buf.buf + 7);
+
+ /* tag payload/message */
+ read_next_command();
+ msg = cmd_data(&msglen);
+
+ /* build the tag object */
+ size_dbuf(&new_data, 67+strlen(t->name)+strlen(tagger)+msglen);
+ sp = new_data.buffer;
+ sp += sprintf(sp, "object %s\n", sha1_to_hex(sha1));
+ sp += sprintf(sp, "type %s\n", type_names[OBJ_COMMIT]);
+ sp += sprintf(sp, "tag %s\n", t->name);
+ sp += sprintf(sp, "tagger %s\n", tagger);
+ *sp++ = '\n';
+ memcpy(sp, msg, msglen);
+ sp += msglen;
+ free(tagger);
+ free(msg);
+
+ if (store_object(OBJ_TAG, new_data.buffer,
+ sp - (char*)new_data.buffer,
+ NULL, t->sha1, 0))
+ t->pack_id = MAX_PACK_ID;
+ else
+ t->pack_id = pack_id;
+}
+
+static void cmd_reset_branch(void)
+{
+ struct branch *b;
+ char *sp;
+
+ /* Obtain the branch name from the rest of our command */
+ sp = strchr(command_buf.buf, ' ') + 1;
+ b = lookup_branch(sp);
+ if (b) {
+ hashclr(b->sha1);
+ hashclr(b->branch_tree.versions[0].sha1);
+ hashclr(b->branch_tree.versions[1].sha1);
+ if (b->branch_tree.tree) {
+ release_tree_content_recursive(b->branch_tree.tree);
+ b->branch_tree.tree = NULL;
+ }
+ }
+ else
+ b = new_branch(sp);
+ read_next_command();
+ cmd_from(b);
+}
+
+static void cmd_checkpoint(void)
+{
+ if (object_count) {
+ cycle_packfile();
+ dump_branches();
+ dump_tags();
+ dump_marks();
+ }
+ read_next_command();
+}
+
+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]";
+
+int main(int argc, const char **argv)
+{
+ int i, show_stats = 1;
+
+ git_config(git_default_config);
+
+ for (i = 1; i < argc; i++) {
+ const char *a = argv[i];
+
+ if (*a != '-' || !strcmp(a, "--"))
+ break;
+ else if (!strncmp(a, "--date-format=", 14)) {
+ const char *fmt = a + 14;
+ if (!strcmp(fmt, "raw"))
+ whenspec = WHENSPEC_RAW;
+ else if (!strcmp(fmt, "rfc2822"))
+ whenspec = WHENSPEC_RFC2822;
+ else if (!strcmp(fmt, "now"))
+ whenspec = WHENSPEC_NOW;
+ else
+ die("unknown --date-format argument %s", fmt);
+ }
+ else if (!strncmp(a, "--max-pack-size=", 16))
+ max_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;
+ else if (!strncmp(a, "--depth=", 8))
+ max_depth = strtoul(a + 8, NULL, 0);
+ else if (!strncmp(a, "--active-branches=", 18))
+ max_active_branches = strtoul(a + 18, NULL, 0);
+ else if (!strncmp(a, "--export-marks=", 15))
+ mark_file = a + 15;
+ else if (!strncmp(a, "--export-pack-edges=", 20)) {
+ if (pack_edges)
+ fclose(pack_edges);
+ pack_edges = fopen(a + 20, "a");
+ if (!pack_edges)
+ die("Cannot open %s: %s", a + 20, strerror(errno));
+ } else if (!strcmp(a, "--force"))
+ force_update = 1;
+ else if (!strcmp(a, "--quiet"))
+ show_stats = 0;
+ else if (!strcmp(a, "--stats"))
+ show_stats = 1;
+ else
+ die("unknown option %s", a);
+ }
+ if (i != argc)
+ usage(fast_import_usage);
+
+ alloc_objects(object_entry_alloc);
+ strbuf_init(&command_buf);
+
+ atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));
+ branch_table = xcalloc(branch_table_sz, sizeof(struct branch*));
+ avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
+ marks = pool_calloc(1, sizeof(struct mark_set));
+
+ start_packfile();
+ for (;;) {
+ read_next_command();
+ if (command_buf.eof)
+ break;
+ else if (!strcmp("blob", command_buf.buf))
+ cmd_new_blob();
+ else if (!strncmp("commit ", command_buf.buf, 7))
+ cmd_new_commit();
+ else if (!strncmp("tag ", command_buf.buf, 4))
+ cmd_new_tag();
+ else if (!strncmp("reset ", command_buf.buf, 6))
+ cmd_reset_branch();
+ else if (!strcmp("checkpoint", command_buf.buf))
+ cmd_checkpoint();
+ else
+ die("Unsupported command: %s", command_buf.buf);
+ }
+ end_packfile();
+
+ dump_branches();
+ dump_tags();
+ unkeep_all_packs();
+ dump_marks();
+
+ if (pack_edges)
+ fclose(pack_edges);
+
+ if (show_stats) {
+ uintmax_t total_count = 0, duplicate_count = 0;
+ for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
+ total_count += object_count_by_type[i];
+ for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
+ duplicate_count += duplicate_count_by_type[i];
+
+ fprintf(stderr, "%s statistics:\n", argv[0]);
+ fprintf(stderr, "---------------------------------------------------------------------\n");
+ fprintf(stderr, "Alloc'd objects: %10ju\n", alloc_count);
+ fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
+ fprintf(stderr, " blobs : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
+ fprintf(stderr, " trees : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);
+ fprintf(stderr, " commits: %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_COMMIT], duplicate_count_by_type[OBJ_COMMIT], delta_count_by_type[OBJ_COMMIT]);
+ fprintf(stderr, " tags : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TAG], duplicate_count_by_type[OBJ_TAG], delta_count_by_type[OBJ_TAG]);
+ fprintf(stderr, "Total branches: %10lu (%10lu loads )\n", branch_count, branch_load_count);
+ fprintf(stderr, " marks: %10ju (%10ju unique )\n", (((uintmax_t)1) << marks->shift) * 1024, marks_set_count);
+ fprintf(stderr, " atoms: %10u\n", atom_cnt);
+ fprintf(stderr, "Memory total: %10ju KiB\n", (total_allocd + alloc_count*sizeof(struct object_entry))/1024);
+ fprintf(stderr, " pools: %10lu KiB\n", (unsigned long)(total_allocd/1024));
+ fprintf(stderr, " objects: %10ju KiB\n", (alloc_count*sizeof(struct object_entry))/1024);
+ fprintf(stderr, "---------------------------------------------------------------------\n");
+ pack_report();
+ fprintf(stderr, "---------------------------------------------------------------------\n");
+ fprintf(stderr, "\n");
+ }
+
+ return failure ? 1 : 0;
+}
diff --git a/fetch-pack.c b/fetch-pack.c
index 1530a94794..c787106764 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -4,16 +4,20 @@
#include "commit.h"
#include "tag.h"
#include "exec_cmd.h"
+#include "pack.h"
#include "sideband.h"
static int keep_pack;
+static int transfer_unpack_limit = -1;
+static int fetch_unpack_limit = -1;
+static int unpack_limit = 100;
static int quiet;
static int verbose;
static int fetch_all;
static int depth;
static const char fetch_pack_usage[] =
-"git-fetch-pack [--all] [-q] [-v] [-k] [--thin] [--exec=upload-pack] [--depth=<n>] [host:]directory <refs>...";
-static const char *exec = "git-upload-pack";
+"git-fetch-pack [--all] [--quiet|-q] [--keep|-k] [--thin] [--upload-pack=<git-upload-pack>] [--depth=<n>] [-v] [<host>:]<directory> [<refs>...]";
+static const char *uploadpack = "git-upload-pack";
#define COMPLETE (1U << 0)
#define COMMON (1U << 1)
@@ -486,13 +490,58 @@ static pid_t setup_sideband(int fd[2], int xd[2])
return side_pid;
}
-static int get_pack(int xd[2], const char **argv)
+static int get_pack(int xd[2])
{
int status;
pid_t pid, side_pid;
int fd[2];
+ const char *argv[20];
+ char keep_arg[256];
+ char hdr_arg[256];
+ const char **av;
+ int do_keep = keep_pack;
side_pid = setup_sideband(fd, xd);
+
+ av = argv;
+ *hdr_arg = 0;
+ if (unpack_limit) {
+ struct pack_header header;
+
+ if (read_pack_header(fd[0], &header))
+ die("protocol error: bad pack header");
+ snprintf(hdr_arg, sizeof(hdr_arg), "--pack_header=%u,%u",
+ ntohl(header.hdr_version), ntohl(header.hdr_entries));
+ if (ntohl(header.hdr_entries) < unpack_limit)
+ do_keep = 0;
+ else
+ do_keep = 1;
+ }
+
+ if (do_keep) {
+ *av++ = "index-pack";
+ *av++ = "--stdin";
+ if (!quiet)
+ *av++ = "-v";
+ if (use_thin_pack)
+ *av++ = "--fix-thin";
+ if (keep_pack > 1 || unpack_limit) {
+ int s = sprintf(keep_arg,
+ "--keep=fetch-pack %d on ", getpid());
+ if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
+ strcpy(keep_arg + s, "localhost");
+ *av++ = keep_arg;
+ }
+ }
+ else {
+ *av++ = "unpack-objects";
+ if (quiet)
+ *av++ = "-q";
+ }
+ if (*hdr_arg)
+ *av++ = hdr_arg;
+ *av++ = NULL;
+
pid = fork();
if (pid < 0)
die("fetch-pack: unable to fork off %s", argv[0]);
@@ -522,39 +571,10 @@ static int get_pack(int xd[2], const char **argv)
die("%s died of unnatural causes %d", argv[0], status);
}
-static int explode_rx_pack(int xd[2])
-{
- const char *argv[3] = { "unpack-objects", quiet ? "-q" : NULL, NULL };
- return get_pack(xd, argv);
-}
-
-static int keep_rx_pack(int xd[2])
-{
- const char *argv[6];
- char keep_arg[256];
- int n = 0;
-
- argv[n++] = "index-pack";
- argv[n++] = "--stdin";
- if (!quiet)
- argv[n++] = "-v";
- if (use_thin_pack)
- argv[n++] = "--fix-thin";
- if (keep_pack > 1) {
- int s = sprintf(keep_arg, "--keep=fetch-pack %i on ", getpid());
- if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
- strcpy(keep_arg + s, "localhost");
- argv[n++] = keep_arg;
- }
- argv[n] = NULL;
- return get_pack(xd, argv);
-}
-
static int fetch_pack(int fd[2], int nr_match, char **match)
{
struct ref *ref;
unsigned char sha1[20];
- int status;
get_remote_heads(fd[0], &ref, 0, NULL, 0);
if (is_repository_shallow() && !server_supports("shallow"))
@@ -589,8 +609,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
*/
fprintf(stderr, "warning: no common commits\n");
- status = (keep_pack) ? keep_rx_pack(fd) : explode_rx_pack(fd);
- if (status)
+ if (get_pack(fd))
die("git-fetch-pack: fetch failed.");
all_done:
@@ -625,6 +644,21 @@ static int remove_duplicates(int nr_heads, char **heads)
return dst;
}
+static int fetch_pack_config(const char *var, const char *value)
+{
+ if (strcmp(var, "fetch.unpacklimit") == 0) {
+ fetch_unpack_limit = git_config_int(var, value);
+ return 0;
+ }
+
+ if (strcmp(var, "transfer.unpacklimit") == 0) {
+ transfer_unpack_limit = git_config_int(var, value);
+ return 0;
+ }
+
+ return git_default_config(var, value);
+}
+
static struct lock_file lock;
int main(int argc, char **argv)
@@ -636,6 +670,12 @@ int main(int argc, char **argv)
struct stat st;
setup_git_directory();
+ git_config(fetch_pack_config);
+
+ if (0 <= transfer_unpack_limit)
+ unpack_limit = transfer_unpack_limit;
+ else if (0 <= fetch_unpack_limit)
+ unpack_limit = fetch_unpack_limit;
nr_heads = 0;
heads = NULL;
@@ -643,8 +683,12 @@ int main(int argc, char **argv)
char *arg = argv[i];
if (*arg == '-') {
+ if (!strncmp("--upload-pack=", arg, 14)) {
+ uploadpack = arg + 14;
+ continue;
+ }
if (!strncmp("--exec=", arg, 7)) {
- exec = arg + 7;
+ uploadpack = arg + 7;
continue;
}
if (!strcmp("--quiet", arg) || !strcmp("-q", arg)) {
@@ -653,6 +697,7 @@ int main(int argc, char **argv)
}
if (!strcmp("--keep", arg) || !strcmp("-k", arg)) {
keep_pack++;
+ unpack_limit = 0;
continue;
}
if (!strcmp("--thin", arg)) {
@@ -682,7 +727,7 @@ int main(int argc, char **argv)
}
if (!dest)
usage(fetch_pack_usage);
- pid = git_connect(fd, dest, exec);
+ pid = git_connect(fd, dest, uploadpack);
if (pid < 0)
return 1;
if (heads && nr_heads)
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 1de14ea82f..975777f05e 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -22,7 +22,7 @@ commit
diff
fetch
grep
-init-db
+init
log
merge
mv
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 0057f86588..dc3038091d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1,6 +1,5 @@
#!/usr/bin/perl -w
-
use strict;
sub run_cmd_pipe {
@@ -282,7 +281,7 @@ sub update_cmd {
HEADER => $status_head, },
@mods);
if (@update) {
- system(qw(git update-index --add --),
+ system(qw(git update-index --add --remove --),
map { $_->{VALUE} } @update);
say_n_paths('updated', @update);
}
diff --git a/git-am.sh b/git-am.sh
index d9eb79d1aa..6db9cb503a 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -3,10 +3,11 @@
# Copyright (c) 2005, 2006 Junio C Hamano
USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
- [--interactive] [--whitespace=<option>] <mbox>...
+ [--interactive] [--whitespace=<option>] [-C<n>] [-p<n>] <mbox>...
or, when resuming [--skip | --resolved]'
. git-sh-setup
set_reflog_action am
+require_work_tree
git var GIT_COMMITTER_IDENT >/dev/null || exit
@@ -105,7 +106,8 @@ It does not apply to blobs recorded in its index."
}
prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
+git_apply_opt=
while case "$#" in 0) break;; esac
do
@@ -128,7 +130,7 @@ do
-s|--s|--si|--sig|--sign|--signo|--signof|--signoff)
sign=t; shift ;;
-u|--u|--ut|--utf|--utf8)
- shift ;; # this is now default
+ utf8=t; shift ;; # this is now default
--no-u|--no-ut|--no-utf|--no-utf8)
utf8=; shift ;;
-k|--k|--ke|--kee|--keep)
@@ -140,8 +142,8 @@ do
--sk|--ski|--skip)
skip=t; shift ;;
- --whitespace=*)
- ws=$1; shift ;;
+ --whitespace=*|-C*|-p*)
+ git_apply_opt="$git_apply_opt $1"; shift ;;
--resolvemsg=*)
resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
@@ -228,6 +230,8 @@ fi
if test "$(cat "$dotest/utf8")" = t
then
utf8=-u
+else
+ utf8=-n
fi
if test "$(cat "$dotest/keep")" = t
then
@@ -391,7 +395,7 @@ do
case "$resolved" in
'')
- git-apply $binary --index $ws "$dotest/patch"
+ git-apply $git_apply_opt $binary --index "$dotest/patch"
apply_status=$?
;;
t)
diff --git a/git-applymbox.sh b/git-applymbox.sh
index 5569fdcc34..1f68599ae5 100755
--- a/git-applymbox.sh
+++ b/git-applymbox.sh
@@ -23,11 +23,12 @@ USAGE='[-u] [-k] [-q] [-m] (-c .dotest/<num> | mbox) [signoff]'
git var GIT_COMMITTER_IDENT >/dev/null || exit
-keep_subject= query_apply= continue= utf8= resume=t
+keep_subject= query_apply= continue= utf8=-u resume=t
while case "$#" in 0) break ;; esac
do
case "$1" in
-u) utf8=-u ;;
+ -n) utf8=-n ;;
-k) keep_subject=-k ;;
-q) query_apply=t ;;
-c) continue="$2"; resume=f; shift ;;
diff --git a/git-archimport.perl b/git-archimport.perl
index ada60ec240..66aaeae102 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -95,6 +95,15 @@ $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls:
my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1);
$opt_v && print "+ Using $tmp as temporary directory\n";
+unless (-d $git_dir) { # initial import needs empty directory
+ opendir DIR, '.' or die "Unable to open current directory: $!\n";
+ while (my $entry = readdir DIR) {
+ $entry =~ /^\.\.?$/ or
+ die "Initial import needs an empty current working directory.\n"
+ }
+ closedir DIR
+}
+
my %reachable = (); # Arch repositories we can access
my %unreachable = (); # Arch repositories we can't access :<
my @psets = (); # the collection
@@ -226,7 +235,7 @@ my $import = 0;
unless (-d $git_dir) { # initial import
if ($psets[0]{type} eq 'i' || $psets[0]{type} eq 't') {
print "Starting import from $psets[0]{id}\n";
- `git-init-db`;
+ `git-init`;
die $! if $?;
$import = 1;
} else {
diff --git a/git-bisect.sh b/git-bisect.sh
index 6da31e87a0..b1c3a6b1c1 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-USAGE='[start|bad|good|next|reset|visualize]'
+USAGE='[start|bad|good|next|reset|visualize|replay|log]'
LONG_USAGE='git bisect start [<pathspec>] reset bisect state and start bisection.
git bisect bad [<rev>] mark <rev> a known-bad revision.
git bisect good [<rev>...] mark <rev>... known-good revisions.
@@ -11,6 +11,7 @@ git bisect replay <logfile> replay bisection log
git bisect log show bisect log.'
. git-sh-setup
+require_work_tree
sq() {
@@PERL@@ -e '
@@ -152,7 +153,7 @@ bisect_next() {
nr=$(eval "git-rev-list $rev $good -- $(cat $GIT_DIR/BISECT_NAMES)" | wc -l) || exit
echo "Bisecting: $nr revisions left to test after this"
echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
- git checkout new-bisect || exit
+ git checkout -q new-bisect || exit
mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD refs/heads/bisect
git-show-branch "$rev"
diff --git a/git-checkout.sh b/git-checkout.sh
index 92ec069a3a..14835a4aa9 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -1,11 +1,13 @@
#!/bin/sh
-USAGE='[-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
+USAGE='[-q] [-f] [-b <new_branch>] [-m] [<branch>] [<paths>...]'
SUBDIRECTORY_OK=Sometimes
. git-sh-setup
+require_work_tree
old_name=HEAD
old=$(git-rev-parse --verify $old_name 2>/dev/null)
+oldbranch=$(git-symbolic-ref $old_name 2>/dev/null)
new=
new_name=
force=
@@ -13,6 +15,9 @@ branch=
newbranch=
newbranch_log=
merge=
+quiet=
+LF='
+'
while [ "$#" != "0" ]; do
arg="$1"
shift
@@ -36,6 +41,9 @@ while [ "$#" != "0" ]; do
-m)
merge=1
;;
+ "-q")
+ quiet=1
+ ;;
--)
break
;;
@@ -50,7 +58,7 @@ while [ "$#" != "0" ]; do
exit 1
fi
new="$rev"
- new_name="$arg^0"
+ new_name="$arg"
if git-show-ref --verify --quiet -- "refs/heads/$arg"
then
branch="$arg"
@@ -131,31 +139,43 @@ fi
# We are switching branches and checking out trees, so
# we *NEED* to be at the toplevel.
-cdup=$(git-rev-parse --show-cdup)
-if test ! -z "$cdup"
-then
- cd "$cdup"
-fi
+cd_to_toplevel
[ -z "$new" ] && new=$old && new_name="$old_name"
-# If we don't have an old branch that we're switching to,
+# If we don't have an existing branch that we're switching to,
# and we don't have a new branch name for the target we
-# are switching to, then we'd better just be checking out
-# what we already had
+# are switching to, then we are detaching our HEAD from any
+# branch. However, if "git checkout HEAD" detaches the HEAD
+# from the current branch, even though that may be logically
+# correct, it feels somewhat funny. More importantly, we do not
+# want "git checkout" nor "git checkout -f" to detach HEAD.
-[ -z "$branch$newbranch" ] &&
- [ "$new" != "$old" ] &&
- die "git checkout: provided reference cannot be checked out directly
+detached=
+detach_warn=
- You need -b to associate a new branch with the wanted checkout. Example:
- git checkout -b <new_branch_name> $arg
-"
+if test -z "$branch$newbranch" && test "$new" != "$old"
+then
+ detached="$new"
+ if test -n "$oldbranch" && test -z "$quiet"
+ then
+ detach_warn="Note: moving to \"$new_name\" which isn't a local branch
+If you want to create a new branch from this checkout, you may do so
+(now or later) by using -b with the checkout command again. Example:
+ git checkout -b <new_branch_name>"
+ fi
+elif test -z "$oldbranch" && test -z "$quiet"
+then
+ echo >&2 "Previous HEAD position was $old"
+fi
if [ "X$old" = X ]
then
- echo "warning: You do not appear to currently be on a branch." >&2
- echo "warning: Forcing checkout of $new_name." >&2
+ if test -z "$quiet"
+ then
+ echo >&2 "warning: You appear to be on a branch yet to be born."
+ echo >&2 "warning: Forcing checkout of $new_name."
+ fi
force=1
fi
@@ -174,16 +194,12 @@ else
# Match the index to the working tree, and do a three-way.
git diff-files --name-only | git update-index --remove --stdin &&
work=`git write-tree` &&
- git read-tree --reset -u $new &&
- git read-tree -m -u --aggressive --exclude-per-directory=.gitignore $old $new $work ||
- exit
+ git read-tree --reset -u $new || exit
- if result=`git write-tree 2>/dev/null`
- then
- echo >&2 "Trivially automerged."
- else
- git merge-index -o git-merge-one-file -a
- fi
+ eval GITHEAD_$new=${new_name:-${branch:-$new}} &&
+ eval GITHEAD_$work=local &&
+ export GITHEAD_$new GITHEAD_$work &&
+ git merge-recursive $old -- $new $work
# Do not register the cleanly merged paths in the index yet.
# this is not a real merge before committing, but just carrying
@@ -204,9 +220,9 @@ else
exit 0
)
saved_err=$?
- if test "$saved_err" = 0
+ if test "$saved_err" = 0 && test -z "$quiet"
then
- test "$new" = "$old" || git diff-index --name-status "$new"
+ git diff-index --name-status "$new"
fi
(exit $saved_err)
fi
@@ -226,8 +242,30 @@ if [ "$?" -eq 0 ]; then
git-update-ref -m "checkout: Created from $new_name" "refs/heads/$newbranch" $new || exit
branch="$newbranch"
fi
- [ "$branch" ] &&
- GIT_DIR="$GIT_DIR" git-symbolic-ref HEAD "refs/heads/$branch"
+ if test -n "$branch"
+ then
+ GIT_DIR="$GIT_DIR" git-symbolic-ref -m "checkout: moving to $branch" HEAD "refs/heads/$branch"
+ if test -z "$quiet"
+ then
+ echo >&2 "Switched to${newbranch:+ a new} branch \"$branch\""
+ fi
+ elif test -n "$detached"
+ then
+ # NEEDSWORK: we would want a command to detach the HEAD
+ # atomically, instead of this handcrafted command sequence.
+ # Perhaps:
+ # git update-ref --detach HEAD $new
+ # or something like that...
+ #
+ git-rev-parse HEAD >"$GIT_DIR/HEAD.new" &&
+ mv "$GIT_DIR/HEAD.new" "$GIT_DIR/HEAD" &&
+ git-update-ref -m "checkout: moving to $arg" HEAD "$detached" ||
+ die "Cannot detach HEAD"
+ if test -n "$detach_warn"
+ then
+ echo >&2 "$detach_warn"
+ fi
+ fi
rm -f "$GIT_DIR/MERGE_HEAD"
else
exit 1
diff --git a/git-clean.sh b/git-clean.sh
index 071b974f49..db177a7886 100755
--- a/git-clean.sh
+++ b/git-clean.sh
@@ -14,6 +14,7 @@ When optional <paths>... arguments are given, the paths
affected are further limited to those that match them.'
SUBDIRECTORY_OK=Yes
. git-sh-setup
+require_work_tree
ignored=
ignoredonly=
diff --git a/git-clone.sh b/git-clone.sh
index cf761b2c69..1bd54ded3c 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -36,7 +36,7 @@ clone_dumb_http () {
clone_tmp="$GIT_DIR/clone-tmp" &&
mkdir -p "$clone_tmp" || exit 1
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
- "`git-repo-config --bool http.noEPSV`" = true ]; then
+ "`git-config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv"
fi
http_fetch "$1/info/refs" "$clone_tmp/refs" ||
@@ -66,48 +66,6 @@ Perhaps git-update-server-info needs to be run there?"
rm -f "$GIT_DIR/REMOTE_HEAD"
}
-# Read git-fetch-pack -k output and store the remote branches.
-copy_refs='
-use File::Path qw(mkpath);
-use File::Basename qw(dirname);
-my $git_dir = $ARGV[0];
-my $use_separate_remote = $ARGV[1];
-my $origin = $ARGV[2];
-
-my $branch_top = ($use_separate_remote ? "remotes/$origin" : "heads");
-my $tag_top = "tags";
-
-sub store {
- my ($sha1, $name, $top) = @_;
- $name = "$git_dir/refs/$top/$name";
- mkpath(dirname($name));
- open O, ">", "$name";
- print O "$sha1\n";
- close O;
-}
-
-open FH, "<", "$git_dir/CLONE_HEAD";
-while (<FH>) {
- my ($sha1, $name) = /^([0-9a-f]{40})\s(.*)$/;
- next if ($name =~ /\^\173/);
- if ($name eq "HEAD") {
- open O, ">", "$git_dir/REMOTE_HEAD";
- print O "$sha1\n";
- close O;
- next;
- }
- if ($name =~ s/^refs\/heads\///) {
- store($sha1, $name, $branch_top);
- next;
- }
- if ($name =~ s/^refs\/tags\///) {
- store($sha1, $name, $tag_top);
- next;
- }
-}
-close FH;
-'
-
quiet=
local=no
use_local=no
@@ -163,7 +121,9 @@ while
1,-u|1,--upload-pack) usage ;;
*,-u|*,--upload-pack)
shift
- upload_pack="--exec=$1" ;;
+ upload_pack="--upload-pack=$1" ;;
+ *,--upload-pack=*)
+ upload_pack=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
1,--depth) usage;;
*,--depth)
shift
@@ -214,23 +174,36 @@ yes)
GIT_DIR="$D" ;;
*)
GIT_DIR="$D/.git" ;;
-esac && export GIT_DIR && git-init-db ${template+"$template"} || usage
+esac && export GIT_DIR && git-init ${template+"$template"} || usage
if test -n "$reference"
then
+ ref_git=
if test -d "$reference"
then
if test -d "$reference/.git/objects"
then
- reference="$reference/.git"
+ ref_git="$reference/.git"
+ elif test -d "$reference/objects"
+ then
+ ref_git="$reference"
fi
- reference=$(cd "$reference" && pwd)
- echo "$reference/objects" >"$GIT_DIR/objects/info/alternates"
- (cd "$reference" && tar cf - refs) |
- (cd "$GIT_DIR/refs" &&
- mkdir reference-tmp &&
- cd reference-tmp &&
- tar xf -)
+ fi
+ if test -n "$ref_git"
+ then
+ ref_git=$(cd "$ref_git" && pwd)
+ echo "$ref_git/objects" >"$GIT_DIR/objects/info/alternates"
+ (
+ GIT_DIR="$ref_git" git for-each-ref \
+ --format='%(objectname) %(*objectname)'
+ ) |
+ while read a b
+ do
+ test -z "$a" ||
+ git update-ref "refs/reference-tmp/$a" "$a"
+ test -z "$b" ||
+ git update-ref "refs/reference-tmp/$b" "$b"
+ done
else
die "reference repository '$reference' is not a local directory."
fi
@@ -330,8 +303,29 @@ test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"
if test -f "$GIT_DIR/CLONE_HEAD"
then
# Read git-fetch-pack -k output and store the remote branches.
- @@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" ||
- exit
+ if [ -n "$use_separate_remote" ]
+ then
+ branch_top="remotes/$origin"
+ else
+ branch_top="heads"
+ fi
+ tag_top="tags"
+ while read sha1 name
+ do
+ case "$name" in
+ *'^{}')
+ continue ;;
+ HEAD)
+ destname="REMOTE_HEAD" ;;
+ refs/heads/*)
+ destname="refs/$branch_top/${name#refs/heads/}" ;;
+ refs/tags/*)
+ destname="refs/$tag_top/${name#refs/tags/}" ;;
+ *)
+ continue ;;
+ esac
+ git-update-ref -m "clone: from $repo" "$destname" "$sha1" ""
+ done < "$GIT_DIR/CLONE_HEAD"
fi
cd "$D" || exit
@@ -384,17 +378,17 @@ then
git-update-ref HEAD "$head_sha1" &&
# Upstream URL
- git-repo-config remote."$origin".url "$repo" &&
+ git-config remote."$origin".url "$repo" &&
# Set up the mappings to track the remote branches.
- git-repo-config remote."$origin".fetch \
+ git-config remote."$origin".fetch \
"+refs/heads/*:$remote_top/*" '^$' &&
rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at" &&
- git-repo-config branch."$head_points_at".remote "$origin" &&
- git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
+ git-config branch."$head_points_at".remote "$origin" &&
+ git-config branch."$head_points_at".merge "refs/heads/$head_points_at"
esac
case "$no_checkout" in
diff --git a/git-commit.sh b/git-commit.sh
index c2beb76fe4..ec506d956f 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -3,9 +3,10 @@
# Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2006 Junio C Hamano
-USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-u] [--amend] [-e] [--author <author>] [[-i | -o] <path>...]'
+USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [[-i | -o] <path>...]'
SUBDIRECTORY_OK=Yes
. git-sh-setup
+require_work_tree
git-rev-parse --verify HEAD >/dev/null 2>&1 || initial_commit=t
@@ -283,9 +284,9 @@ esac
case "$log_given" in
tt*)
- die "Only one of -c/-C/-F can be used." ;;
+ die "Only one of -c/-C/-F/--amend can be used." ;;
*tm*|*mt*)
- die "Option -m cannot be combined with -c/-C/-F." ;;
+ die "Option -m cannot be combined with -c/-C/-F/--amend." ;;
esac
case "$#,$also,$only,$amend" in
@@ -315,22 +316,16 @@ esac
################################################################
# Prepare index to have a tree to be committed
-TOP=`git-rev-parse --show-cdup`
-if test -z "$TOP"
-then
- TOP=./
-fi
-
case "$all,$also" in
t,)
save_index &&
(
- cd "$TOP"
- GIT_INDEX_FILE="$NEXT_INDEX"
- export GIT_INDEX_FILE
+ cd_to_toplevel &&
+ GIT_INDEX_FILE="$NEXT_INDEX" &&
+ export GIT_INDEX_FILE &&
git-diff-files --name-only -z |
git-update-index --remove -z --stdin
- )
+ ) || exit
;;
,t)
save_index &&
@@ -338,11 +333,11 @@ t,)
git-diff-files --name-only -z -- "$@" |
(
- cd "$TOP"
- GIT_INDEX_FILE="$NEXT_INDEX"
- export GIT_INDEX_FILE
+ cd_to_toplevel &&
+ GIT_INDEX_FILE="$NEXT_INDEX" &&
+ export GIT_INDEX_FILE &&
git-update-index --remove -z --stdin
- )
+ ) || exit
;;
,)
case "$#" in
@@ -434,7 +429,9 @@ then
fi
elif test "$use_commit" != ""
then
- git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
+ encoding=$(git config i18n.commitencoding || echo UTF-8)
+ git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
+ sed -e '1,/^$/d' -e 's/^ //'
elif test -f "$GIT_DIR/MERGE_MSG"
then
cat "$GIT_DIR/MERGE_MSG"
@@ -445,8 +442,11 @@ fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
case "$signoff" in
t)
+ need_blank_before_signoff=
+ tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
+ grep 'Signed-off-by:' >/dev/null || need_blank_before_signoff=yes
{
- echo
+ test -z "$need_blank_before_signoff" || echo
git-var GIT_COMMITTER_IDENT | sed -e '
s/>.*/>/
s/^/Signed-off-by: /
@@ -465,15 +465,7 @@ if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
fi >>"$GIT_DIR"/COMMIT_EDITMSG
# Author
-if test '' != "$force_author"
-then
- GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` &&
- GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` &&
- test '' != "$GIT_AUTHOR_NAME" &&
- test '' != "$GIT_AUTHOR_EMAIL" ||
- die "malformed --author parameter"
- export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
-elif test '' != "$use_commit"
+if test '' != "$use_commit"
then
pick_author_script='
/^author /{
@@ -496,13 +488,23 @@ then
q
}
'
- set_author_env=`git-cat-file commit "$use_commit" |
+ encoding=$(git config i18n.commitencoding || echo UTF-8)
+ set_author_env=`git show -s --pretty=raw --encoding="$encoding" "$use_commit" |
LANG=C LC_ALL=C sed -ne "$pick_author_script"`
eval "$set_author_env"
export GIT_AUTHOR_NAME
export GIT_AUTHOR_EMAIL
export GIT_AUTHOR_DATE
fi
+if test '' != "$force_author"
+then
+ GIT_AUTHOR_NAME=`expr "z$force_author" : 'z\(.*[^ ]\) *<.*'` &&
+ GIT_AUTHOR_EMAIL=`expr "z$force_author" : '.*\(<.*\)'` &&
+ test '' != "$GIT_AUTHOR_NAME" &&
+ test '' != "$GIT_AUTHOR_EMAIL" ||
+ die "malformed --author parameter"
+ export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
+fi
PARENTS="-p HEAD"
if test -z "$initial_commit"
@@ -526,6 +528,7 @@ else
rloga='commit (initial)'
current=''
fi
+set_reflog_action "$rloga"
if test -z "$no_edit"
then
@@ -600,7 +603,7 @@ then
fi &&
commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
- git-update-ref -m "$rloga: $rlogm" HEAD $commit "$current" &&
+ git-update-ref -m "$GIT_REFLOG_ACTION: $rlogm" HEAD $commit "$current" &&
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
if test -f "$NEXT_INDEX"
then
diff --git a/git-compat-util.h b/git-compat-util.h
index f8d46d587b..c1bcb001a5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -15,8 +15,9 @@
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#endif
-#define _GNU_SOURCE
-#define _BSD_SOURCE
+#define _ALL_SOURCE 1
+#define _GNU_SOURCE 1
+#define _BSD_SOURCE 1
#include <unistd.h>
#include <stdio.h>
@@ -45,7 +46,10 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <pwd.h>
+#include <inttypes.h>
+#undef _ALL_SOURCE /* AIX 5.3L defines a struct list with _ALL_SOURCE. */
#include <grp.h>
+#define _ALL_SOURCE 1
#ifndef NO_ICONV
#include <iconv.h>
@@ -202,6 +206,8 @@ static inline void *xmmap(void *start, size_t length,
{
void *ret = mmap(start, length, prot, flags, fd, offset);
if (ret == MAP_FAILED) {
+ if (!length)
+ return NULL;
release_pack_memory(length);
ret = mmap(start, length, prot, flags, fd, offset);
if (ret == MAP_FAILED)
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index 4863c91fe3..870554eade 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -15,9 +15,9 @@ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
die "GIT_DIR is not defined or is unreadable";
}
-our ($opt_h, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m );
+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m );
-getopts('hpvcfam:');
+getopts('hPpvcfam:');
$opt_h && usage();
@@ -89,7 +89,7 @@ if ($parent) {
last;
}; # found it
}
- die "Did not find $parent in the parents for this commit!" if !$found;
+ die "Did not find $parent in the parents for this commit!" if !$found and !$opt_P;
} else { # we don't have a parent from the cmdline...
if (@parents == 1) { # it's safe to get it from the commit
$parent = $parents[0];
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 1018f4f6fa..1a1ba7b1a6 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -85,7 +85,35 @@ sub write_author_info($) {
close ($f);
}
-getopts("hivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage();
+# convert getopts specs for use by git-repo-config
+sub read_repo_config {
+ # Split the string between characters, unless there is a ':'
+ # So "abc:de" becomes ["a", "b", "c:", "d", "e"]
+ my @opts = split(/ *(?!:)/, shift);
+ foreach my $o (@opts) {
+ my $key = $o;
+ $key =~ s/://g;
+ my $arg = 'git-repo-config';
+ $arg .= ' --bool' if ($o !~ /:$/);
+
+ chomp(my $tmp = `$arg --get cvsimport.$key`);
+ if ($tmp && !($arg =~ /--bool/ && $tmp eq 'false')) {
+ no strict 'refs';
+ my $opt_name = "opt_" . $key;
+ if (!$$opt_name) {
+ $$opt_name = $tmp;
+ }
+ }
+ }
+ if (@ARGV == 0) {
+ chomp(my $module = `git-repo-config --get cvsimport.module`);
+ push(@ARGV, $module);
+ }
+}
+
+my $opts = "haivmkuo:d:p:C:z:s:M:P:A:S:L:";
+read_repo_config($opts);
+getopts($opts) or usage();
usage if $opt_h;
@ARGV <= 1 or usage();
@@ -520,7 +548,7 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE};
my %index; # holds filenames of one index per branch
unless (-d $git_dir) {
- system("git-init-db");
+ system("git-init");
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
system("git-read-tree");
die "Cannot init an empty tree: $?\n" if $?;
@@ -660,7 +688,7 @@ $ignorebranch{'#CVSPS_NO_BRANCH'} = 1;
sub commit {
if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) {
# looks like an initial commit
- # use the index primed by git-init-db
+ # use the index primed by git-init
$ENV{GIT_INDEX_FILE} = '.git/index';
$index{$branch} = '.git/index';
} else {
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index a33a876ff6..9371788fab 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -172,11 +172,11 @@ sub req_Root
return 0;
}
- my @gitvars = `git-repo-config -l`;
+ my @gitvars = `git-config -l`;
if ($?) {
- print "E problems executing git-repo-config on the server -- this is not a git repository or the PATH is not set correctly.\n";
+ print "E problems executing git-config on the server -- this is not a git repository or the PATH is not set correctly.\n";
print "E \n";
- print "error 1 - problem executing git-repo-config\n";
+ print "error 1 - problem executing git-config\n";
return 0;
}
foreach my $line ( @gitvars )
@@ -876,9 +876,9 @@ sub req_update
print "MT newline\n";
next;
}
- elsif ( !defined($wrev) || $wrev == 0 )
+ elsif ( (!defined($wrev) || $wrev == 0) && (!defined($meta->{revision}) || $meta->{revision} == 0) )
{
- $log->info("Tell the client the file will be added");
+ $log->info("Tell the client the file is scheduled for addition");
print "MT text A \n";
print "MT fname $filename\n";
print "MT newline\n";
@@ -886,7 +886,7 @@ sub req_update
}
else {
- $log->info("Updating '$filename' $wrev");
+ $log->info("Updating '$filename' to ".$meta->{revision});
print "MT +updated\n";
print "MT text U \n";
print "MT fname $filename\n";
diff --git a/git-fetch.sh b/git-fetch.sh
index 466fe59e35..ca984e739a 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -5,12 +5,8 @@ USAGE='<fetch-options> <repository> <refspec>...'
SUBDIRECTORY_OK=Yes
. git-sh-setup
set_reflog_action "fetch $*"
+cd_to_toplevel ;# probably unnecessary...
-TOP=$(git-rev-parse --show-cdup)
-if test ! -z "$TOP"
-then
- cd "$TOP"
-fi
. git-parse-remote
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
@@ -26,7 +22,6 @@ force=
verbose=
update_head_ok=
exec=
-upload_pack=
keep=
shallow_depth=
while case "$#" in 0) break ;; esac
@@ -38,8 +33,12 @@ do
--upl|--uplo|--uploa|--upload|--upload-|--upload-p|\
--upload-pa|--upload-pac|--upload-pack)
shift
- exec="--exec=$1"
- upload_pack="-u $1"
+ exec="--upload-pack=$1"
+ ;;
+ --upl=*|--uplo=*|--uploa=*|--upload=*|\
+ --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
+ exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
+ shift
;;
-f|--f|--fo|--for|--forc|--force)
force=t
@@ -86,6 +85,12 @@ case "$#" in
set x $origin ; shift ;;
esac
+if test -z "$exec"
+then
+ # No command line override and we have configuration for the remote.
+ exec="--upload-pack=$(get_uploadpack $1)"
+fi
+
remote_nick="$1"
remote=$(get_remote_url "$@")
refs=
@@ -98,7 +103,7 @@ then
fi
# Global that is reused later
-ls_remote_result=$(git ls-remote $upload_pack "$remote") ||
+ls_remote_result=$(git ls-remote $exec "$remote") ||
die "Cannot get the repository state from $remote"
append_fetch_head () {
@@ -231,11 +236,12 @@ update_local_ref () {
esac
}
-case "$update_head_ok" in
-'')
+# updating the current HEAD with git-fetch in a bare
+# repository is always fine.
+if test -z "$update_head_ok" && test $(is_bare_repository) = false
+then
orig_head=$(git-rev-parse --verify HEAD 2>/dev/null)
- ;;
-esac
+fi
# If --tags (and later --heads or --all) is specified, then we are
# not talking about defaults stored in Pull: line of remotes or
@@ -247,23 +253,10 @@ if test "$tags"
then
taglist=`IFS=' ' &&
echo "$ls_remote_result" |
+ git-show-ref --exclude-existing=refs/tags/ |
while read sha1 name
do
- case "$sha1" in
- fail)
- exit 1
- esac
- case "$name" in
- *^*) continue ;;
- refs/tags/*) ;;
- *) continue ;;
- esac
- if git-check-ref-format "$name"
- then
- echo ".${name}:${name}"
- else
- echo >&2 "warning: tag ${name} ignored"
- fi
+ echo ".${name}:${name}"
done` || exit
if test "$#" -gt 1
then
@@ -315,7 +308,7 @@ fetch_main () {
curl_extra_args="-k"
fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
- "`git-repo-config --bool http.noEPSV`" = true ]; then
+ "`git-config --bool http.noEPSV`" = true ]; then
noepsv_opt="--disable-epsv"
fi
diff --git a/git-gc.sh b/git-gc.sh
index 6de55f7292..1a45de5dff 100755
--- a/git-gc.sh
+++ b/git-gc.sh
@@ -4,12 +4,34 @@
#
# Cleanup unreachable files and optimize the repository.
-USAGE=''
+USAGE='git-gc [--prune]'
SUBDIRECTORY_OK=Yes
. git-sh-setup
+no_prune=:
+while case $# in 0) break ;; esac
+do
+ case "$1" in
+ --prune)
+ no_prune=
+ ;;
+ --)
+ usage
+ ;;
+ esac
+ shift
+done
+
+case "$(git config --get gc.packrefs)" in
+notbare|"")
+ test $(is_bare_repository) = true || pack_refs=true;;
+*)
+ pack_refs=$(git config --bool --get gc.packrefs)
+esac
+
+test "true" != "$pack_refs" ||
git-pack-refs --prune &&
git-reflog expire --all &&
git-repack -a -d -l &&
-git-prune &&
+$no_prune git-prune &&
git-rerere gc || exit
diff --git a/git-gui/.gitignore b/git-gui/.gitignore
new file mode 100644
index 0000000000..c714d382e8
--- /dev/null
+++ b/git-gui/.gitignore
@@ -0,0 +1,3 @@
+GIT-VERSION-FILE
+git-citool
+git-gui
diff --git a/git-gui/GIT-VERSION-GEN b/git-gui/GIT-VERSION-GEN
new file mode 100755
index 0000000000..9966126da2
--- /dev/null
+++ b/git-gui/GIT-VERSION-GEN
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+GVF=GIT-VERSION-FILE
+DEF_VER=0.6.GITGUI
+
+LF='
+'
+
+tree_search ()
+{
+ head=$1
+ tree=$2
+ for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)
+ do
+ test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
+ vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
+ case "$vn" in
+ gitgui-[0-9]*) echo $vn; break;;
+ esac
+ done
+}
+
+# We may be a subproject, so try looking for the merge
+# commit that supplied this directory content if we are
+# not at the toplevel. We probably will always be the
+# second parent in the commit, but we shouldn't rely on
+# that fact.
+#
+# If we are at the toplevel or the merge assumption fails
+# try looking for a gitgui-* tag, or fallback onto the
+# distributed version file.
+
+if prefix="$(git rev-parse --show-prefix 2>/dev/null)"
+ test -n "$prefix" &&
+ head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
+ tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
+ VN=$(tree_search $head $tree)
+ case "$VN" in
+ gitgui-[0-9]*) : happy ;;
+ *) (exit 1) ;;
+ esac
+then
+ VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
+elif VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+ case "$VN" in
+ gitgui-[0-9]*) : happy ;;
+ *) (exit 1) ;;
+ esac
+then
+ VN=$(echo "$VN" | sed -e 's/^gitgui-//;s/-/./g');
+elif test -f version
+then
+ VN=$(cat version) || VN="$DEF_VER"
+else
+ VN="$DEF_VER"
+fi
+
+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/^GITGUI_VERSION = //' <$GVF)
+else
+ VC=unset
+fi
+test "$VN" = "$VC" || {
+ echo >&2 "GITGUI_VERSION = $VN"
+ echo "GITGUI_VERSION = $VN" >$GVF
+}
+
+
diff --git a/git-gui/Makefile b/git-gui/Makefile
new file mode 100644
index 0000000000..fd82d9d16d
--- /dev/null
+++ b/git-gui/Makefile
@@ -0,0 +1,56 @@
+all::
+
+GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
+ @$(SHELL_PATH) ./GIT-VERSION-GEN
+-include GIT-VERSION-FILE
+
+SCRIPT_SH = git-gui.sh
+GITGUI_BUILT_INS = git-citool
+ALL_PROGRAMS = $(GITGUI_BUILT_INS) $(patsubst %.sh,%,$(SCRIPT_SH))
+
+ifndef SHELL_PATH
+ SHELL_PATH = /bin/sh
+endif
+
+ifndef gitexecdir
+ gitexecdir := $(shell git --exec-path)
+endif
+
+ifndef INSTALL
+ INSTALL = install
+endif
+
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
+SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
+
+$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
+ rm -f $@ $@+
+ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+ -e 's/@@GITGUI_VERSION@@/$(GITGUI_VERSION)/g' \
+ $@.sh >$@+
+ chmod +x $@+
+ mv $@+ $@
+
+$(GITGUI_BUILT_INS): git-gui
+ rm -f $@ && ln git-gui $@
+
+# These can record GITGUI_VERSION
+$(patsubst %.sh,%,$(SCRIPT_SH)): GIT-VERSION-FILE
+
+all:: $(ALL_PROGRAMS)
+
+install: all
+ $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
+ $(INSTALL) git-gui '$(DESTDIR_SQ)$(gitexecdir_SQ)'
+ $(foreach p,$(GITGUI_BUILT_INS), rm -f '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' && ln '$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' ;)
+
+dist-version:
+ @mkdir -p $(TARDIR)
+ @echo $(GITGUI_VERSION) > $(TARDIR)/version
+
+clean::
+ rm -f $(ALL_PROGRAMS) GIT-VERSION-FILE
+
+.PHONY: all install dist-version clean
+.PHONY: .FORCE-GIT-VERSION-FILE
diff --git a/git-gui/TODO b/git-gui/TODO
new file mode 100644
index 0000000000..b95a137322
--- /dev/null
+++ b/git-gui/TODO
@@ -0,0 +1,44 @@
+Items outstanding:
+
+ * Add file to .gitignore or info/excludes.
+
+ * Populate the pull menu with local branches.
+
+ * Make use of the new default merge data stored in repo-config.
+
+ * Checkout a different local branch.
+
+ * Push any local branch to a remote branch.
+
+ * Merge any local branches through a real merge UI.
+
+ * Allow user to define keyboard shortcuts for frequently used fetch
+ or merge operations. Or maybe just define a keyboard shortcut
+ for default fetch/default merge of current branch is enough;
+ but I do know a few users who merge a couple of common branches
+ also into the same branch so one default isn't quite enough.
+
+ * Better organize fetch/push/pull console windows.
+
+ * Clone UI (to download a new repository).
+
+ * Remotes editor (for .git/config format only).
+
+ * Show a shortlog of the last couple of commits in the main window,
+ to give the user warm fuzzy feelings that we have their data
+ saved. Actually this may be the set of commits not yet in
+ the upstream (aka default merge branch remote repository).
+
+ * GUI configuration editor for options listed in
+ git.git/Documentation/config.txt. Ideally this would
+ parse that file and generate the options dialog from
+ the documentation itself, and include the help text
+ from the documentation as part of the UI somehow.
+
+Known bugs:
+
+ * git-gui sometimes just closes on Windows with no error message.
+ I'm not sure what the problem is here. I suspect the wish
+ process is just terminating due to a segfault or something,
+ as the do_quit proc in git-gui doesn't run. It often seems to
+ occur while writing a commit message in the buffer. Odd.
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
new file mode 100755
index 0000000000..f5010dd47a
--- /dev/null
+++ b/git-gui/git-gui.sh
@@ -0,0 +1,5924 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+set appvers {@@GITGUI_VERSION@@}
+set copyright {
+Copyright © 2006, 2007 Shawn Pearce, Paul Mackerras.
+
+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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA}
+
+######################################################################
+##
+## read only globals
+
+set _appname [lindex [file split $argv0] end]
+set _gitdir {}
+set _gitexec {}
+set _reponame {}
+set _iscygwin {}
+
+proc appname {} {
+ global _appname
+ return $_appname
+}
+
+proc gitdir {args} {
+ global _gitdir
+ if {$args eq {}} {
+ return $_gitdir
+ }
+ return [eval [concat [list file join $_gitdir] $args]]
+}
+
+proc gitexec {args} {
+ global _gitexec
+ if {$_gitexec eq {}} {
+ if {[catch {set _gitexec [exec git --exec-path]} err]} {
+ error "Git not installed?\n\n$err"
+ }
+ }
+ if {$args eq {}} {
+ return $_gitexec
+ }
+ return [eval [concat [list file join $_gitexec] $args]]
+}
+
+proc reponame {} {
+ global _reponame
+ return $_reponame
+}
+
+proc is_MacOSX {} {
+ global tcl_platform tk_library
+ if {[tk windowingsystem] eq {aqua}} {
+ return 1
+ }
+ return 0
+}
+
+proc is_Windows {} {
+ global tcl_platform
+ if {$tcl_platform(platform) eq {windows}} {
+ return 1
+ }
+ return 0
+}
+
+proc is_Cygwin {} {
+ global tcl_platform _iscygwin
+ if {$_iscygwin eq {}} {
+ if {$tcl_platform(platform) eq {windows}} {
+ if {[catch {set p [exec cygpath --windir]} err]} {
+ set _iscygwin 0
+ } else {
+ set _iscygwin 1
+ }
+ } else {
+ set _iscygwin 0
+ }
+ }
+ return $_iscygwin
+}
+
+proc is_enabled {option} {
+ global enabled_options
+ if {[catch {set on $enabled_options($option)}]} {return 0}
+ return $on
+}
+
+proc enable_option {option} {
+ global enabled_options
+ set enabled_options($option) 1
+}
+
+proc disable_option {option} {
+ global enabled_options
+ set enabled_options($option) 0
+}
+
+######################################################################
+##
+## config
+
+proc is_many_config {name} {
+ switch -glob -- $name {
+ remote.*.fetch -
+ remote.*.push
+ {return 1}
+ *
+ {return 0}
+ }
+}
+
+proc is_config_true {name} {
+ global repo_config
+ if {[catch {set v $repo_config($name)}]} {
+ return 0
+ } elseif {$v eq {true} || $v eq {1} || $v eq {yes}} {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+proc load_config {include_global} {
+ global repo_config global_config default_config
+
+ array unset global_config
+ if {$include_global} {
+ catch {
+ set fd_rc [open "| git config --global --list" r]
+ while {[gets $fd_rc line] >= 0} {
+ if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
+ if {[is_many_config $name]} {
+ lappend global_config($name) $value
+ } else {
+ set global_config($name) $value
+ }
+ }
+ }
+ close $fd_rc
+ }
+ }
+
+ array unset repo_config
+ catch {
+ set fd_rc [open "| git config --list" r]
+ while {[gets $fd_rc line] >= 0} {
+ if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
+ if {[is_many_config $name]} {
+ lappend repo_config($name) $value
+ } else {
+ set repo_config($name) $value
+ }
+ }
+ }
+ close $fd_rc
+ }
+
+ foreach name [array names default_config] {
+ if {[catch {set v $global_config($name)}]} {
+ set global_config($name) $default_config($name)
+ }
+ if {[catch {set v $repo_config($name)}]} {
+ set repo_config($name) $default_config($name)
+ }
+ }
+}
+
+proc save_config {} {
+ global default_config font_descs
+ global repo_config global_config
+ global repo_config_new global_config_new
+
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ font configure $font \
+ -family $global_config_new(gui.$font^^family) \
+ -size $global_config_new(gui.$font^^size)
+ font configure ${font}bold \
+ -family $global_config_new(gui.$font^^family) \
+ -size $global_config_new(gui.$font^^size)
+ set global_config_new(gui.$name) [font configure $font]
+ unset global_config_new(gui.$font^^family)
+ unset global_config_new(gui.$font^^size)
+ }
+
+ foreach name [array names default_config] {
+ set value $global_config_new($name)
+ if {$value ne $global_config($name)} {
+ if {$value eq $default_config($name)} {
+ catch {exec git config --global --unset $name}
+ } else {
+ regsub -all "\[{}\]" $value {"} value
+ exec git config --global $name $value
+ }
+ set global_config($name) $value
+ if {$value eq $repo_config($name)} {
+ catch {exec git config --unset $name}
+ set repo_config($name) $value
+ }
+ }
+ }
+
+ foreach name [array names default_config] {
+ set value $repo_config_new($name)
+ if {$value ne $repo_config($name)} {
+ if {$value eq $global_config($name)} {
+ catch {exec git config --unset $name}
+ } else {
+ regsub -all "\[{}\]" $value {"} value
+ exec git config $name $value
+ }
+ set repo_config($name) $value
+ }
+ }
+}
+
+proc error_popup {msg} {
+ set title [appname]
+ if {[reponame] ne {}} {
+ append title " ([reponame])"
+ }
+ set cmd [list tk_messageBox \
+ -icon error \
+ -type ok \
+ -title "$title: error" \
+ -message $msg]
+ if {[winfo ismapped .]} {
+ lappend cmd -parent .
+ }
+ eval $cmd
+}
+
+proc warn_popup {msg} {
+ set title [appname]
+ if {[reponame] ne {}} {
+ append title " ([reponame])"
+ }
+ set cmd [list tk_messageBox \
+ -icon warning \
+ -type ok \
+ -title "$title: warning" \
+ -message $msg]
+ if {[winfo ismapped .]} {
+ lappend cmd -parent .
+ }
+ eval $cmd
+}
+
+proc info_popup {msg {parent .}} {
+ set title [appname]
+ if {[reponame] ne {}} {
+ append title " ([reponame])"
+ }
+ tk_messageBox \
+ -parent $parent \
+ -icon info \
+ -type ok \
+ -title $title \
+ -message $msg
+}
+
+proc ask_popup {msg} {
+ set title [appname]
+ if {[reponame] ne {}} {
+ append title " ([reponame])"
+ }
+ return [tk_messageBox \
+ -parent . \
+ -icon question \
+ -type yesno \
+ -title $title \
+ -message $msg]
+}
+
+######################################################################
+##
+## repository setup
+
+if { [catch {set _gitdir $env(GIT_DIR)}]
+ && [catch {set _gitdir [exec git rev-parse --git-dir]} err]} {
+ catch {wm withdraw .}
+ error_popup "Cannot find the git directory:\n\n$err"
+ exit 1
+}
+if {![file isdirectory $_gitdir] && [is_Cygwin]} {
+ catch {set _gitdir [exec cygpath --unix $_gitdir]}
+}
+if {![file isdirectory $_gitdir]} {
+ catch {wm withdraw .}
+ error_popup "Git directory not found:\n\n$_gitdir"
+ exit 1
+}
+if {[lindex [file split $_gitdir] end] ne {.git}} {
+ catch {wm withdraw .}
+ error_popup "Cannot use funny .git directory:\n\n$_gitdir"
+ exit 1
+}
+if {[catch {cd [file dirname $_gitdir]} err]} {
+ catch {wm withdraw .}
+ error_popup "No working directory [file dirname $_gitdir]:\n\n$err"
+ exit 1
+}
+set _reponame [lindex [file split \
+ [file normalize [file dirname $_gitdir]]] \
+ end]
+
+######################################################################
+##
+## task management
+
+set rescan_active 0
+set diff_active 0
+set last_clicked {}
+
+set disable_on_lock [list]
+set index_lock_type none
+
+proc lock_index {type} {
+ global index_lock_type disable_on_lock
+
+ if {$index_lock_type eq {none}} {
+ set index_lock_type $type
+ foreach w $disable_on_lock {
+ uplevel #0 $w disabled
+ }
+ return 1
+ } elseif {$index_lock_type eq "begin-$type"} {
+ set index_lock_type $type
+ return 1
+ }
+ return 0
+}
+
+proc unlock_index {} {
+ global index_lock_type disable_on_lock
+
+ set index_lock_type none
+ foreach w $disable_on_lock {
+ uplevel #0 $w normal
+ }
+}
+
+######################################################################
+##
+## status
+
+proc repository_state {ctvar hdvar mhvar} {
+ global current_branch
+ upvar $ctvar ct $hdvar hd $mhvar mh
+
+ set mh [list]
+
+ if {[catch {set current_branch [exec git symbolic-ref HEAD]}]} {
+ set current_branch {}
+ } else {
+ regsub ^refs/((heads|tags|remotes)/)? \
+ $current_branch \
+ {} \
+ current_branch
+ }
+
+ if {[catch {set hd [exec git rev-parse --verify HEAD]}]} {
+ set hd {}
+ set ct initial
+ return
+ }
+
+ set merge_head [gitdir MERGE_HEAD]
+ if {[file exists $merge_head]} {
+ set ct merge
+ set fd_mh [open $merge_head r]
+ while {[gets $fd_mh line] >= 0} {
+ lappend mh $line
+ }
+ close $fd_mh
+ return
+ }
+
+ set ct normal
+}
+
+proc PARENT {} {
+ global PARENT empty_tree
+
+ set p [lindex $PARENT 0]
+ if {$p ne {}} {
+ return $p
+ }
+ if {$empty_tree eq {}} {
+ set empty_tree [exec git mktree << {}]
+ }
+ return $empty_tree
+}
+
+proc rescan {after {honor_trustmtime 1}} {
+ global HEAD PARENT MERGE_HEAD commit_type
+ global ui_index ui_workdir ui_status_value ui_comm
+ global rescan_active file_states
+ global repo_config
+
+ if {$rescan_active > 0 || ![lock_index read]} return
+
+ repository_state newType newHEAD newMERGE_HEAD
+ if {[string match amend* $commit_type]
+ && $newType eq {normal}
+ && $newHEAD eq $HEAD} {
+ } else {
+ set HEAD $newHEAD
+ set PARENT $newHEAD
+ set MERGE_HEAD $newMERGE_HEAD
+ set commit_type $newType
+ }
+
+ array unset file_states
+
+ if {![$ui_comm edit modified]
+ || [string trim [$ui_comm get 0.0 end]] eq {}} {
+ if {[load_message GITGUI_MSG]} {
+ } elseif {[load_message MERGE_MSG]} {
+ } elseif {[load_message SQUASH_MSG]} {
+ }
+ $ui_comm edit reset
+ $ui_comm edit modified false
+ }
+
+ if {[is_enabled branch]} {
+ load_all_heads
+ populate_branch_menu
+ }
+
+ if {$honor_trustmtime && $repo_config(gui.trustmtime) eq {true}} {
+ rescan_stage2 {} $after
+ } else {
+ set rescan_active 1
+ set ui_status_value {Refreshing file status...}
+ set cmd [list git update-index]
+ lappend cmd -q
+ lappend cmd --unmerged
+ lappend cmd --ignore-missing
+ lappend cmd --refresh
+ set fd_rf [open "| $cmd" r]
+ fconfigure $fd_rf -blocking 0 -translation binary
+ fileevent $fd_rf readable \
+ [list rescan_stage2 $fd_rf $after]
+ }
+}
+
+proc rescan_stage2 {fd after} {
+ global ui_status_value
+ global rescan_active buf_rdi buf_rdf buf_rlo
+
+ if {$fd ne {}} {
+ read $fd
+ if {![eof $fd]} return
+ close $fd
+ }
+
+ set ls_others [list | git ls-files --others -z \
+ --exclude-per-directory=.gitignore]
+ set info_exclude [gitdir info exclude]
+ if {[file readable $info_exclude]} {
+ lappend ls_others "--exclude-from=$info_exclude"
+ }
+
+ set buf_rdi {}
+ set buf_rdf {}
+ set buf_rlo {}
+
+ set rescan_active 3
+ set ui_status_value {Scanning for modified files ...}
+ set fd_di [open "| git diff-index --cached -z [PARENT]" r]
+ set fd_df [open "| git diff-files -z" r]
+ set fd_lo [open $ls_others r]
+
+ fconfigure $fd_di -blocking 0 -translation binary -encoding binary
+ fconfigure $fd_df -blocking 0 -translation binary -encoding binary
+ fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
+ fileevent $fd_di readable [list read_diff_index $fd_di $after]
+ fileevent $fd_df readable [list read_diff_files $fd_df $after]
+ fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
+}
+
+proc load_message {file} {
+ global ui_comm
+
+ set f [gitdir $file]
+ if {[file isfile $f]} {
+ if {[catch {set fd [open $f r]}]} {
+ return 0
+ }
+ set content [string trim [read $fd]]
+ close $fd
+ regsub -all -line {[ \r\t]+$} $content {} content
+ $ui_comm delete 0.0 end
+ $ui_comm insert end $content
+ return 1
+ }
+ return 0
+}
+
+proc read_diff_index {fd after} {
+ global buf_rdi
+
+ append buf_rdi [read $fd]
+ set c 0
+ set n [string length $buf_rdi]
+ while {$c < $n} {
+ set z1 [string first "\0" $buf_rdi $c]
+ if {$z1 == -1} break
+ incr z1
+ set z2 [string first "\0" $buf_rdi $z1]
+ if {$z2 == -1} break
+
+ incr c
+ set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
+ set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
+ merge_state \
+ [encoding convertfrom $p] \
+ [lindex $i 4]? \
+ [list [lindex $i 0] [lindex $i 2]] \
+ [list]
+ set c $z2
+ incr c
+ }
+ if {$c < $n} {
+ set buf_rdi [string range $buf_rdi $c end]
+ } else {
+ set buf_rdi {}
+ }
+
+ rescan_done $fd buf_rdi $after
+}
+
+proc read_diff_files {fd after} {
+ global buf_rdf
+
+ append buf_rdf [read $fd]
+ set c 0
+ set n [string length $buf_rdf]
+ while {$c < $n} {
+ set z1 [string first "\0" $buf_rdf $c]
+ if {$z1 == -1} break
+ incr z1
+ set z2 [string first "\0" $buf_rdf $z1]
+ if {$z2 == -1} break
+
+ incr c
+ set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
+ set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
+ merge_state \
+ [encoding convertfrom $p] \
+ ?[lindex $i 4] \
+ [list] \
+ [list [lindex $i 0] [lindex $i 2]]
+ set c $z2
+ incr c
+ }
+ if {$c < $n} {
+ set buf_rdf [string range $buf_rdf $c end]
+ } else {
+ set buf_rdf {}
+ }
+
+ rescan_done $fd buf_rdf $after
+}
+
+proc read_ls_others {fd after} {
+ global buf_rlo
+
+ append buf_rlo [read $fd]
+ set pck [split $buf_rlo "\0"]
+ set buf_rlo [lindex $pck end]
+ foreach p [lrange $pck 0 end-1] {
+ merge_state [encoding convertfrom $p] ?O
+ }
+ rescan_done $fd buf_rlo $after
+}
+
+proc rescan_done {fd buf after} {
+ global rescan_active
+ global file_states repo_config
+ upvar $buf to_clear
+
+ if {![eof $fd]} return
+ set to_clear {}
+ close $fd
+ if {[incr rescan_active -1] > 0} return
+
+ prune_selection
+ unlock_index
+ display_all_files
+ reshow_diff
+ uplevel #0 $after
+}
+
+proc prune_selection {} {
+ global file_states selected_paths
+
+ foreach path [array names selected_paths] {
+ if {[catch {set still_here $file_states($path)}]} {
+ unset selected_paths($path)
+ }
+ }
+}
+
+######################################################################
+##
+## diff
+
+proc clear_diff {} {
+ global ui_diff current_diff_path current_diff_header
+ global ui_index ui_workdir
+
+ $ui_diff conf -state normal
+ $ui_diff delete 0.0 end
+ $ui_diff conf -state disabled
+
+ set current_diff_path {}
+ set current_diff_header {}
+
+ $ui_index tag remove in_diff 0.0 end
+ $ui_workdir tag remove in_diff 0.0 end
+}
+
+proc reshow_diff {} {
+ global ui_status_value file_states file_lists
+ global current_diff_path current_diff_side
+
+ set p $current_diff_path
+ if {$p eq {}
+ || $current_diff_side eq {}
+ || [catch {set s $file_states($p)}]
+ || [lsearch -sorted -exact $file_lists($current_diff_side) $p] == -1} {
+ clear_diff
+ } else {
+ show_diff $p $current_diff_side
+ }
+}
+
+proc handle_empty_diff {} {
+ global current_diff_path file_states file_lists
+
+ set path $current_diff_path
+ set s $file_states($path)
+ if {[lindex $s 0] ne {_M}} return
+
+ info_popup "No differences detected.
+
+[short_path $path] has no changes.
+
+The modification date of this file was updated
+by another application, but the content within
+the file was not changed.
+
+A rescan will be automatically started to find
+other files which may have the same state."
+
+ clear_diff
+ display_file $path __
+ rescan {set ui_status_value {Ready.}} 0
+}
+
+proc show_diff {path w {lno {}}} {
+ global file_states file_lists
+ global is_3way_diff diff_active repo_config
+ global ui_diff ui_status_value ui_index ui_workdir
+ global current_diff_path current_diff_side current_diff_header
+
+ if {$diff_active || ![lock_index read]} return
+
+ clear_diff
+ if {$lno == {}} {
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
+ if {$lno >= 0} {
+ incr lno
+ }
+ }
+ if {$lno >= 1} {
+ $w tag add in_diff $lno.0 [expr {$lno + 1}].0
+ }
+
+ set s $file_states($path)
+ set m [lindex $s 0]
+ set is_3way_diff 0
+ set diff_active 1
+ set current_diff_path $path
+ set current_diff_side $w
+ set current_diff_header {}
+ set ui_status_value "Loading diff of [escape_path $path]..."
+
+ # - Git won't give us the diff, there's nothing to compare to!
+ #
+ if {$m eq {_O}} {
+ set max_sz [expr {128 * 1024}]
+ if {[catch {
+ set fd [open $path r]
+ set content [read $fd $max_sz]
+ close $fd
+ set sz [file size $path]
+ } err ]} {
+ set diff_active 0
+ unlock_index
+ set ui_status_value "Unable to display [escape_path $path]"
+ error_popup "Error loading file:\n\n$err"
+ return
+ }
+ $ui_diff conf -state normal
+ if {![catch {set type [exec file $path]}]} {
+ set n [string length $path]
+ if {[string equal -length $n $path $type]} {
+ set type [string range $type $n end]
+ regsub {^:?\s*} $type {} type
+ }
+ $ui_diff insert end "* $type\n" d_@
+ }
+ if {[string first "\0" $content] != -1} {
+ $ui_diff insert end \
+ "* Binary file (not showing content)." \
+ d_@
+ } else {
+ if {$sz > $max_sz} {
+ $ui_diff insert end \
+"* Untracked file is $sz bytes.
+* Showing only first $max_sz bytes.
+" d_@
+ }
+ $ui_diff insert end $content
+ if {$sz > $max_sz} {
+ $ui_diff insert end "
+* Untracked file clipped here by [appname].
+* To see the entire file, use an external editor.
+" d_@
+ }
+ }
+ $ui_diff conf -state disabled
+ set diff_active 0
+ unlock_index
+ set ui_status_value {Ready.}
+ return
+ }
+
+ set cmd [list | git]
+ if {$w eq $ui_index} {
+ lappend cmd diff-index
+ lappend cmd --cached
+ } elseif {$w eq $ui_workdir} {
+ if {[string index $m 0] eq {U}} {
+ lappend cmd diff
+ } else {
+ lappend cmd diff-files
+ }
+ }
+
+ lappend cmd -p
+ lappend cmd --no-color
+ if {$repo_config(gui.diffcontext) > 0} {
+ lappend cmd "-U$repo_config(gui.diffcontext)"
+ }
+ if {$w eq $ui_index} {
+ lappend cmd [PARENT]
+ }
+ lappend cmd --
+ lappend cmd $path
+
+ if {[catch {set fd [open $cmd r]} err]} {
+ set diff_active 0
+ unlock_index
+ set ui_status_value "Unable to display [escape_path $path]"
+ error_popup "Error loading diff:\n\n$err"
+ return
+ }
+
+ fconfigure $fd \
+ -blocking 0 \
+ -encoding binary \
+ -translation binary
+ fileevent $fd readable [list read_diff $fd]
+}
+
+proc read_diff {fd} {
+ global ui_diff ui_status_value diff_active
+ global is_3way_diff current_diff_header
+
+ $ui_diff conf -state normal
+ while {[gets $fd line] >= 0} {
+ # -- Cleanup uninteresting diff header lines.
+ #
+ if { [string match {diff --git *} $line]
+ || [string match {diff --cc *} $line]
+ || [string match {diff --combined *} $line]
+ || [string match {--- *} $line]
+ || [string match {+++ *} $line]} {
+ append current_diff_header $line "\n"
+ continue
+ }
+ if {[string match {index *} $line]} continue
+ if {$line eq {deleted file mode 120000}} {
+ set line "deleted symlink"
+ }
+
+ # -- Automatically detect if this is a 3 way diff.
+ #
+ if {[string match {@@@ *} $line]} {set is_3way_diff 1}
+
+ if {[string match {mode *} $line]
+ || [string match {new file *} $line]
+ || [string match {deleted file *} $line]
+ || [string match {Binary files * and * differ} $line]
+ || $line eq {\ No newline at end of file}
+ || [regexp {^\* Unmerged path } $line]} {
+ set tags {}
+ } elseif {$is_3way_diff} {
+ set op [string range $line 0 1]
+ switch -- $op {
+ { } {set tags {}}
+ {@@} {set tags d_@}
+ { +} {set tags d_s+}
+ { -} {set tags d_s-}
+ {+ } {set tags d_+s}
+ {- } {set tags d_-s}
+ {--} {set tags d_--}
+ {++} {
+ if {[regexp {^\+\+([<>]{7} |={7})} $line _g op]} {
+ set line [string replace $line 0 1 { }]
+ set tags d$op
+ } else {
+ set tags d_++
+ }
+ }
+ default {
+ puts "error: Unhandled 3 way diff marker: {$op}"
+ set tags {}
+ }
+ }
+ } else {
+ set op [string index $line 0]
+ switch -- $op {
+ { } {set tags {}}
+ {@} {set tags d_@}
+ {-} {set tags d_-}
+ {+} {
+ if {[regexp {^\+([<>]{7} |={7})} $line _g op]} {
+ set line [string replace $line 0 0 { }]
+ set tags d$op
+ } else {
+ set tags d_+
+ }
+ }
+ default {
+ puts "error: Unhandled 2 way diff marker: {$op}"
+ set tags {}
+ }
+ }
+ }
+ $ui_diff insert end $line $tags
+ if {[string index $line end] eq "\r"} {
+ $ui_diff tag add d_cr {end - 2c}
+ }
+ $ui_diff insert end "\n" $tags
+ }
+ $ui_diff conf -state disabled
+
+ if {[eof $fd]} {
+ close $fd
+ set diff_active 0
+ unlock_index
+ set ui_status_value {Ready.}
+
+ if {[$ui_diff index end] eq {2.0}} {
+ handle_empty_diff
+ }
+ }
+}
+
+proc apply_hunk {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 {git apply --cached --whitespace=nowarn}
+ set mi [lindex $file_states($current_diff_path) 0]
+ if {$current_diff_side eq $ui_index} {
+ set mode unstage
+ lappend apply_cmd --reverse
+ if {[string index $mi 0] ne {M}} {
+ unlock_index
+ return
+ }
+ } else {
+ set mode stage
+ if {[string index $mi 1] ne {M}} {
+ unlock_index
+ return
+ }
+ }
+
+ set s_lno [lindex [split [$ui_diff index @$x,$y] .] 0]
+ set s_lno [$ui_diff search -backwards -regexp ^@@ $s_lno.0 0.0]
+ if {$s_lno eq {}} {
+ unlock_index
+ return
+ }
+
+ set e_lno [$ui_diff search -forwards -regexp ^@@ "$s_lno + 1 lines" end]
+ if {$e_lno eq {}} {
+ set e_lno end
+ }
+
+ if {[catch {
+ set p [open "| $apply_cmd" w]
+ fconfigure $p -translation binary -encoding binary
+ puts -nonewline $p $current_diff_header
+ puts -nonewline $p [$ui_diff get $s_lno $e_lno]
+ close $p} err]} {
+ error_popup "Failed to $mode selected hunk.\n\n$err"
+ unlock_index
+ return
+ }
+
+ $ui_diff conf -state normal
+ $ui_diff delete $s_lno $e_lno
+ $ui_diff conf -state disabled
+
+ if {[$ui_diff get 1.0 end] eq "\n"} {
+ set o _
+ } else {
+ set o ?
+ }
+
+ if {$current_diff_side eq $ui_index} {
+ set mi ${o}M
+ } elseif {[string index $mi 0] eq {_}} {
+ set mi M$o
+ } else {
+ set mi ?$o
+ }
+ unlock_index
+ display_file $current_diff_path $mi
+ if {$o eq {_}} {
+ clear_diff
+ }
+}
+
+######################################################################
+##
+## commit
+
+proc load_last_commit {} {
+ global HEAD PARENT MERGE_HEAD commit_type ui_comm
+ global repo_config
+
+ if {[llength $PARENT] == 0} {
+ error_popup {There is nothing to amend.
+
+You are about to create the initial commit.
+There is no commit before this to amend.
+}
+ return
+ }
+
+ repository_state curType curHEAD curMERGE_HEAD
+ if {$curType eq {merge}} {
+ error_popup {Cannot amend while merging.
+
+You are currently in the middle of a merge that
+has not been fully completed. You cannot amend
+the prior commit unless you first abort the
+current merge activity.
+}
+ return
+ }
+
+ set msg {}
+ set parents [list]
+ if {[catch {
+ set fd [open "| git cat-file commit $curHEAD" r]
+ fconfigure $fd -encoding binary -translation lf
+ if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
+ set enc utf-8
+ }
+ while {[gets $fd line] > 0} {
+ if {[string match {parent *} $line]} {
+ lappend parents [string range $line 7 end]
+ } elseif {[string match {encoding *} $line]} {
+ set enc [string tolower [string range $line 9 end]]
+ }
+ }
+ fconfigure $fd -encoding $enc
+ set msg [string trim [read $fd]]
+ close $fd
+ } err]} {
+ error_popup "Error loading commit data for amend:\n\n$err"
+ return
+ }
+
+ set HEAD $curHEAD
+ set PARENT $parents
+ set MERGE_HEAD [list]
+ switch -- [llength $parents] {
+ 0 {set commit_type amend-initial}
+ 1 {set commit_type amend}
+ default {set commit_type amend-merge}
+ }
+
+ $ui_comm delete 0.0 end
+ $ui_comm insert end $msg
+ $ui_comm edit reset
+ $ui_comm edit modified false
+ rescan {set ui_status_value {Ready.}}
+}
+
+proc create_new_commit {} {
+ global commit_type ui_comm
+
+ set commit_type normal
+ $ui_comm delete 0.0 end
+ $ui_comm edit reset
+ $ui_comm edit modified false
+ rescan {set ui_status_value {Ready.}}
+}
+
+set GIT_COMMITTER_IDENT {}
+
+proc committer_ident {} {
+ global GIT_COMMITTER_IDENT
+
+ if {$GIT_COMMITTER_IDENT eq {}} {
+ if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
+ error_popup "Unable to obtain your identity:\n\n$err"
+ return {}
+ }
+ if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
+ $me me GIT_COMMITTER_IDENT]} {
+ error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
+ return {}
+ }
+ }
+
+ return $GIT_COMMITTER_IDENT
+}
+
+proc commit_tree {} {
+ global HEAD commit_type file_states ui_comm repo_config
+ global ui_status_value pch_error
+
+ if {[committer_ident] eq {}} return
+ if {![lock_index update]} return
+
+ # -- Our in memory state should match the repository.
+ #
+ repository_state curType curHEAD curMERGE_HEAD
+ if {[string match amend* $commit_type]
+ && $curType eq {normal}
+ && $curHEAD eq $HEAD} {
+ } elseif {$commit_type ne $curType || $HEAD ne $curHEAD} {
+ info_popup {Last scanned state does not match repository state.
+
+Another Git program has modified this repository
+since the last scan. A rescan must be performed
+before another commit can be created.
+
+The rescan will be automatically started now.
+}
+ unlock_index
+ rescan {set ui_status_value {Ready.}}
+ return
+ }
+
+ # -- At least one file should differ in the index.
+ #
+ set files_ready 0
+ foreach path [array names file_states] {
+ switch -glob -- [lindex $file_states($path) 0] {
+ _? {continue}
+ A? -
+ D? -
+ M? {set files_ready 1}
+ U? {
+ error_popup "Unmerged files cannot be committed.
+
+File [short_path $path] has merge conflicts.
+You must resolve them and add the file before committing.
+"
+ unlock_index
+ return
+ }
+ default {
+ error_popup "Unknown file state [lindex $s 0] detected.
+
+File [short_path $path] cannot be committed by this program.
+"
+ }
+ }
+ }
+ if {!$files_ready} {
+ info_popup {No changes to commit.
+
+You must add at least 1 file before you can commit.
+}
+ unlock_index
+ return
+ }
+
+ # -- A message is required.
+ #
+ set msg [string trim [$ui_comm get 1.0 end]]
+ regsub -all -line {[ \t\r]+$} $msg {} msg
+ if {$msg eq {}} {
+ error_popup {Please supply a commit message.
+
+A good commit message has the following format:
+
+- First line: Describe in one sentance what you did.
+- Second line: Blank
+- Remaining lines: Describe why this change is good.
+}
+ unlock_index
+ return
+ }
+
+ # -- Run the pre-commit hook.
+ #
+ set pchook [gitdir hooks pre-commit]
+
+ # On Cygwin [file executable] might lie so we need to ask
+ # the shell if the hook is executable. Yes that's annoying.
+ #
+ 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
+ return
+ }
+
+ set ui_status_value {Calling pre-commit hook...}
+ set pch_error {}
+ set fd_ph [open "| $pchook" r]
+ fconfigure $fd_ph -blocking 0 -translation binary
+ fileevent $fd_ph readable \
+ [list commit_prehook_wait $fd_ph $curHEAD $msg]
+}
+
+proc commit_prehook_wait {fd_ph curHEAD msg} {
+ global pch_error ui_status_value
+
+ append pch_error [read $fd_ph]
+ fconfigure $fd_ph -blocking 1
+ if {[eof $fd_ph]} {
+ if {[catch {close $fd_ph}]} {
+ set ui_status_value {Commit declined by pre-commit hook.}
+ hook_failed_popup pre-commit $pch_error
+ unlock_index
+ } else {
+ commit_writetree $curHEAD $msg
+ }
+ set pch_error {}
+ return
+ }
+ fconfigure $fd_ph -blocking 0
+}
+
+proc commit_writetree {curHEAD msg} {
+ global ui_status_value
+
+ set ui_status_value {Committing changes...}
+ set fd_wt [open "| git write-tree" r]
+ fileevent $fd_wt readable \
+ [list commit_committree $fd_wt $curHEAD $msg]
+}
+
+proc commit_committree {fd_wt curHEAD msg} {
+ global HEAD PARENT MERGE_HEAD commit_type
+ global all_heads current_branch
+ global ui_status_value ui_comm selected_commit_type
+ global file_states selected_paths rescan_active
+ global repo_config
+
+ gets $fd_wt tree_id
+ if {$tree_id eq {} || [catch {close $fd_wt} err]} {
+ error_popup "write-tree failed:\n\n$err"
+ set ui_status_value {Commit failed.}
+ unlock_index
+ return
+ }
+
+ # -- Build the message.
+ #
+ set msg_p [gitdir COMMIT_EDITMSG]
+ set msg_wt [open $msg_p w]
+ if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
+ set enc utf-8
+ }
+ fconfigure $msg_wt -encoding $enc -translation binary
+ puts -nonewline $msg_wt $msg
+ close $msg_wt
+
+ # -- Create the commit.
+ #
+ set cmd [list git commit-tree $tree_id]
+ set parents [concat $PARENT $MERGE_HEAD]
+ if {[llength $parents] > 0} {
+ foreach p $parents {
+ lappend cmd -p $p
+ }
+ } else {
+ # git commit-tree writes to stderr during initial commit.
+ lappend cmd 2>/dev/null
+ }
+ lappend cmd <$msg_p
+ if {[catch {set cmt_id [eval exec $cmd]} err]} {
+ error_popup "commit-tree failed:\n\n$err"
+ set ui_status_value {Commit failed.}
+ unlock_index
+ return
+ }
+
+ # -- Update the HEAD ref.
+ #
+ set reflogm commit
+ if {$commit_type ne {normal}} {
+ append reflogm " ($commit_type)"
+ }
+ set i [string first "\n" $msg]
+ if {$i >= 0} {
+ append reflogm {: } [string range $msg 0 [expr {$i - 1}]]
+ } else {
+ append reflogm {: } $msg
+ }
+ set cmd [list git update-ref -m $reflogm HEAD $cmt_id $curHEAD]
+ if {[catch {eval exec $cmd} err]} {
+ error_popup "update-ref failed:\n\n$err"
+ set ui_status_value {Commit failed.}
+ unlock_index
+ return
+ }
+
+ # -- Make sure our current branch exists.
+ #
+ if {$commit_type eq {initial}} {
+ lappend all_heads $current_branch
+ set all_heads [lsort -unique $all_heads]
+ populate_branch_menu
+ }
+
+ # -- Cleanup after ourselves.
+ #
+ catch {file delete $msg_p}
+ catch {file delete [gitdir MERGE_HEAD]}
+ catch {file delete [gitdir MERGE_MSG]}
+ catch {file delete [gitdir SQUASH_MSG]}
+ catch {file delete [gitdir GITGUI_MSG]}
+
+ # -- Let rerere do its thing.
+ #
+ if {[file isdirectory [gitdir rr-cache]]} {
+ catch {exec git rerere}
+ }
+
+ # -- 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 &}
+ }
+
+ $ui_comm delete 0.0 end
+ $ui_comm edit reset
+ $ui_comm edit modified false
+
+ if {[is_enabled singlecommit]} do_quit
+
+ # -- Update in memory status
+ #
+ set selected_commit_type new
+ set commit_type normal
+ set HEAD $cmt_id
+ set PARENT $cmt_id
+ set MERGE_HEAD [list]
+
+ foreach path [array names file_states] {
+ set s $file_states($path)
+ set m [lindex $s 0]
+ switch -glob -- $m {
+ _O -
+ _M -
+ _D {continue}
+ __ -
+ A_ -
+ M_ -
+ D_ {
+ unset file_states($path)
+ catch {unset selected_paths($path)}
+ }
+ DO {
+ set file_states($path) [list _O [lindex $s 1] {} {}]
+ }
+ AM -
+ AD -
+ MM -
+ MD {
+ set file_states($path) [list \
+ _[string index $m 1] \
+ [lindex $s 1] \
+ [lindex $s 3] \
+ {}]
+ }
+ }
+ }
+
+ display_all_files
+ unlock_index
+ reshow_diff
+ set ui_status_value \
+ "Changes committed as [string range $cmt_id 0 7]."
+}
+
+######################################################################
+##
+## fetch push
+
+proc fetch_from {remote} {
+ set w [new_console \
+ "fetch $remote" \
+ "Fetching new changes from $remote"]
+ set cmd [list git fetch]
+ lappend cmd $remote
+ console_exec $w $cmd console_done
+}
+
+proc push_to {remote} {
+ set w [new_console \
+ "push $remote" \
+ "Pushing changes to $remote"]
+ set cmd [list git push]
+ lappend cmd -v
+ lappend cmd $remote
+ console_exec $w $cmd console_done
+}
+
+######################################################################
+##
+## ui helpers
+
+proc mapicon {w state path} {
+ global all_icons
+
+ if {[catch {set r $all_icons($state$w)}]} {
+ puts "error: no icon for $w state={$state} $path"
+ return file_plain
+ }
+ return $r
+}
+
+proc mapdesc {state path} {
+ global all_descs
+
+ if {[catch {set r $all_descs($state)}]} {
+ puts "error: no desc for state={$state} $path"
+ return $state
+ }
+ return $r
+}
+
+proc escape_path {path} {
+ regsub -all {\\} $path "\\\\" path
+ regsub -all "\n" $path "\\n" path
+ return $path
+}
+
+proc short_path {path} {
+ return [escape_path [lindex [file split $path] end]]
+}
+
+set next_icon_id 0
+set null_sha1 [string repeat 0 40]
+
+proc merge_state {path new_state {head_info {}} {index_info {}}} {
+ global file_states next_icon_id null_sha1
+
+ set s0 [string index $new_state 0]
+ set s1 [string index $new_state 1]
+
+ if {[catch {set info $file_states($path)}]} {
+ set state __
+ set icon n[incr next_icon_id]
+ } else {
+ set state [lindex $info 0]
+ set icon [lindex $info 1]
+ if {$head_info eq {}} {set head_info [lindex $info 2]}
+ if {$index_info eq {}} {set index_info [lindex $info 3]}
+ }
+
+ if {$s0 eq {?}} {set s0 [string index $state 0]} \
+ elseif {$s0 eq {_}} {set s0 _}
+
+ if {$s1 eq {?}} {set s1 [string index $state 1]} \
+ elseif {$s1 eq {_}} {set s1 _}
+
+ if {$s0 eq {A} && $s1 eq {_} && $head_info eq {}} {
+ set head_info [list 0 $null_sha1]
+ } elseif {$s0 ne {_} && [string index $state 0] eq {_}
+ && $head_info eq {}} {
+ set head_info $index_info
+ }
+
+ set file_states($path) [list $s0$s1 $icon \
+ $head_info $index_info \
+ ]
+ return $state
+}
+
+proc display_file_helper {w path icon_name old_m new_m} {
+ global file_lists
+
+ if {$new_m eq {_}} {
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
+ if {$lno >= 0} {
+ set file_lists($w) [lreplace $file_lists($w) $lno $lno]
+ incr lno
+ $w conf -state normal
+ $w delete $lno.0 [expr {$lno + 1}].0
+ $w conf -state disabled
+ }
+ } elseif {$old_m eq {_} && $new_m ne {_}} {
+ lappend file_lists($w) $path
+ set file_lists($w) [lsort -unique $file_lists($w)]
+ set lno [lsearch -sorted -exact $file_lists($w) $path]
+ incr lno
+ $w conf -state normal
+ $w image create $lno.0 \
+ -align center -padx 5 -pady 1 \
+ -name $icon_name \
+ -image [mapicon $w $new_m $path]
+ $w insert $lno.1 "[escape_path $path]\n"
+ $w conf -state disabled
+ } elseif {$old_m ne $new_m} {
+ $w conf -state normal
+ $w image conf $icon_name -image [mapicon $w $new_m $path]
+ $w conf -state disabled
+ }
+}
+
+proc display_file {path state} {
+ global file_states selected_paths
+ global ui_index ui_workdir
+
+ set old_m [merge_state $path $state]
+ set s $file_states($path)
+ set new_m [lindex $s 0]
+ set icon_name [lindex $s 1]
+
+ set o [string index $old_m 0]
+ set n [string index $new_m 0]
+ if {$o eq {U}} {
+ set o _
+ }
+ if {$n eq {U}} {
+ set n _
+ }
+ display_file_helper $ui_index $path $icon_name $o $n
+
+ if {[string index $old_m 0] eq {U}} {
+ set o U
+ } else {
+ set o [string index $old_m 1]
+ }
+ if {[string index $new_m 0] eq {U}} {
+ set n U
+ } else {
+ set n [string index $new_m 1]
+ }
+ display_file_helper $ui_workdir $path $icon_name $o $n
+
+ if {$new_m eq {__}} {
+ unset file_states($path)
+ catch {unset selected_paths($path)}
+ }
+}
+
+proc display_all_files_helper {w path icon_name m} {
+ global file_lists
+
+ lappend file_lists($w) $path
+ set lno [expr {[lindex [split [$w index end] .] 0] - 1}]
+ $w image create end \
+ -align center -padx 5 -pady 1 \
+ -name $icon_name \
+ -image [mapicon $w $m $path]
+ $w insert end "[escape_path $path]\n"
+}
+
+proc display_all_files {} {
+ global ui_index ui_workdir
+ global file_states file_lists
+ global last_clicked
+
+ $ui_index conf -state normal
+ $ui_workdir conf -state normal
+
+ $ui_index delete 0.0 end
+ $ui_workdir delete 0.0 end
+ set last_clicked {}
+
+ set file_lists($ui_index) [list]
+ set file_lists($ui_workdir) [list]
+
+ foreach path [lsort [array names file_states]] {
+ set s $file_states($path)
+ set m [lindex $s 0]
+ set icon_name [lindex $s 1]
+
+ set s [string index $m 0]
+ if {$s ne {U} && $s ne {_}} {
+ display_all_files_helper $ui_index $path \
+ $icon_name $s
+ }
+
+ if {[string index $m 0] eq {U}} {
+ set s U
+ } else {
+ set s [string index $m 1]
+ }
+ if {$s ne {_}} {
+ display_all_files_helper $ui_workdir $path \
+ $icon_name $s
+ }
+ }
+
+ $ui_index conf -state disabled
+ $ui_workdir conf -state disabled
+}
+
+proc update_indexinfo {msg pathList after} {
+ global update_index_cp ui_status_value
+
+ if {![lock_index update]} return
+
+ set update_index_cp 0
+ set pathList [lsort $pathList]
+ set totalCnt [llength $pathList]
+ set batch [expr {int($totalCnt * .01) + 1}]
+ if {$batch > 25} {set batch 25}
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ 0.0]
+ set fd [open "| git update-index -z --index-info" w]
+ fconfigure $fd \
+ -blocking 0 \
+ -buffering full \
+ -buffersize 512 \
+ -encoding binary \
+ -translation binary
+ fileevent $fd writable [list \
+ write_update_indexinfo \
+ $fd \
+ $pathList \
+ $totalCnt \
+ $batch \
+ $msg \
+ $after \
+ ]
+}
+
+proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
+ global update_index_cp ui_status_value
+ global file_states current_diff_path
+
+ if {$update_index_cp >= $totalCnt} {
+ close $fd
+ unlock_index
+ uplevel #0 $after
+ return
+ }
+
+ for {set i $batch} \
+ {$update_index_cp < $totalCnt && $i > 0} \
+ {incr i -1} {
+ set path [lindex $pathList $update_index_cp]
+ incr update_index_cp
+
+ set s $file_states($path)
+ switch -glob -- [lindex $s 0] {
+ A? {set new _O}
+ M? {set new _M}
+ D_ {set new _D}
+ D? {set new _?}
+ ?? {continue}
+ }
+ set info [lindex $s 2]
+ if {$info eq {}} continue
+
+ puts -nonewline $fd "$info\t[encoding convertto $path]\0"
+ display_file $path $new
+ }
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ [expr {100.0 * $update_index_cp / $totalCnt}]]
+}
+
+proc update_index {msg pathList after} {
+ global update_index_cp ui_status_value
+
+ if {![lock_index update]} return
+
+ set update_index_cp 0
+ set pathList [lsort $pathList]
+ set totalCnt [llength $pathList]
+ set batch [expr {int($totalCnt * .01) + 1}]
+ if {$batch > 25} {set batch 25}
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ 0.0]
+ set fd [open "| git update-index --add --remove -z --stdin" w]
+ fconfigure $fd \
+ -blocking 0 \
+ -buffering full \
+ -buffersize 512 \
+ -encoding binary \
+ -translation binary
+ fileevent $fd writable [list \
+ write_update_index \
+ $fd \
+ $pathList \
+ $totalCnt \
+ $batch \
+ $msg \
+ $after \
+ ]
+}
+
+proc write_update_index {fd pathList totalCnt batch msg after} {
+ global update_index_cp ui_status_value
+ global file_states current_diff_path
+
+ if {$update_index_cp >= $totalCnt} {
+ close $fd
+ unlock_index
+ uplevel #0 $after
+ return
+ }
+
+ for {set i $batch} \
+ {$update_index_cp < $totalCnt && $i > 0} \
+ {incr i -1} {
+ set path [lindex $pathList $update_index_cp]
+ incr update_index_cp
+
+ switch -glob -- [lindex $file_states($path) 0] {
+ AD {set new __}
+ ?D {set new D_}
+ _O -
+ AM {set new A_}
+ U? {
+ if {[file exists $path]} {
+ set new M_
+ } else {
+ set new D_
+ }
+ }
+ ?M {set new M_}
+ ?? {continue}
+ }
+ puts -nonewline $fd "[encoding convertto $path]\0"
+ display_file $path $new
+ }
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ [expr {100.0 * $update_index_cp / $totalCnt}]]
+}
+
+proc checkout_index {msg pathList after} {
+ global update_index_cp ui_status_value
+
+ if {![lock_index update]} return
+
+ set update_index_cp 0
+ set pathList [lsort $pathList]
+ set totalCnt [llength $pathList]
+ set batch [expr {int($totalCnt * .01) + 1}]
+ if {$batch > 25} {set batch 25}
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ 0.0]
+ set cmd [list git checkout-index]
+ lappend cmd --index
+ lappend cmd --quiet
+ lappend cmd --force
+ lappend cmd -z
+ lappend cmd --stdin
+ set fd [open "| $cmd " w]
+ fconfigure $fd \
+ -blocking 0 \
+ -buffering full \
+ -buffersize 512 \
+ -encoding binary \
+ -translation binary
+ fileevent $fd writable [list \
+ write_checkout_index \
+ $fd \
+ $pathList \
+ $totalCnt \
+ $batch \
+ $msg \
+ $after \
+ ]
+}
+
+proc write_checkout_index {fd pathList totalCnt batch msg after} {
+ global update_index_cp ui_status_value
+ global file_states current_diff_path
+
+ if {$update_index_cp >= $totalCnt} {
+ close $fd
+ unlock_index
+ uplevel #0 $after
+ return
+ }
+
+ for {set i $batch} \
+ {$update_index_cp < $totalCnt && $i > 0} \
+ {incr i -1} {
+ set path [lindex $pathList $update_index_cp]
+ incr update_index_cp
+ switch -glob -- [lindex $file_states($path) 0] {
+ U? {continue}
+ ?M -
+ ?D {
+ puts -nonewline $fd "[encoding convertto $path]\0"
+ display_file $path ?_
+ }
+ }
+ }
+
+ set ui_status_value [format \
+ "$msg... %i/%i files (%.2f%%)" \
+ $update_index_cp \
+ $totalCnt \
+ [expr {100.0 * $update_index_cp / $totalCnt}]]
+}
+
+######################################################################
+##
+## branch management
+
+proc is_tracking_branch {name} {
+ global tracking_branches
+
+ if {![catch {set info $tracking_branches($name)}]} {
+ return 1
+ }
+ foreach t [array names tracking_branches] {
+ if {[string match {*/\*} $t] && [string match $t $name]} {
+ return 1
+ }
+ }
+ return 0
+}
+
+proc load_all_heads {} {
+ global all_heads
+
+ set all_heads [list]
+ set fd [open "| git for-each-ref --format=%(refname) refs/heads" r]
+ while {[gets $fd line] > 0} {
+ if {[is_tracking_branch $line]} continue
+ if {![regsub ^refs/heads/ $line {} name]} continue
+ lappend all_heads $name
+ }
+ close $fd
+
+ set all_heads [lsort $all_heads]
+}
+
+proc populate_branch_menu {} {
+ global all_heads disable_on_lock
+
+ set m .mbar.branch
+ set last [$m index last]
+ for {set i 0} {$i <= $last} {incr i} {
+ if {[$m type $i] eq {separator}} {
+ $m delete $i last
+ set new_dol [list]
+ foreach a $disable_on_lock {
+ if {[lindex $a 0] ne $m || [lindex $a 2] < $i} {
+ lappend new_dol $a
+ }
+ }
+ set disable_on_lock $new_dol
+ break
+ }
+ }
+
+ if {$all_heads ne {}} {
+ $m add separator
+ }
+ foreach b $all_heads {
+ $m add radiobutton \
+ -label $b \
+ -command [list switch_branch $b] \
+ -variable current_branch \
+ -value $b \
+ -font font_ui
+ lappend disable_on_lock \
+ [list $m entryconf [$m index last] -state]
+ }
+}
+
+proc all_tracking_branches {} {
+ global tracking_branches
+
+ set all_trackings {}
+ set cmd {}
+ foreach name [array names tracking_branches] {
+ if {[regsub {/\*$} $name {} name]} {
+ lappend cmd $name
+ } else {
+ regsub ^refs/(heads|remotes)/ $name {} name
+ lappend all_trackings $name
+ }
+ }
+
+ if {$cmd ne {}} {
+ set fd [open "| git for-each-ref --format=%(refname) $cmd" r]
+ while {[gets $fd name] > 0} {
+ regsub ^refs/(heads|remotes)/ $name {} name
+ lappend all_trackings $name
+ }
+ close $fd
+ }
+
+ return [lsort -unique $all_trackings]
+}
+
+proc do_create_branch_action {w} {
+ global all_heads null_sha1 repo_config
+ global create_branch_checkout create_branch_revtype
+ global create_branch_head create_branch_trackinghead
+ global create_branch_name create_branch_revexp
+
+ set newbranch $create_branch_name
+ if {$newbranch eq {}
+ || $newbranch eq $repo_config(gui.newbranchtemplate)} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Please supply a branch name."
+ focus $w.desc.name_t
+ return
+ }
+ if {![catch {exec git show-ref --verify -- "refs/heads/$newbranch"}]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Branch '$newbranch' already exists."
+ focus $w.desc.name_t
+ return
+ }
+ if {[catch {exec git check-ref-format "heads/$newbranch"}]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "We do not like '$newbranch' as a branch name."
+ focus $w.desc.name_t
+ return
+ }
+
+ set rev {}
+ switch -- $create_branch_revtype {
+ head {set rev $create_branch_head}
+ tracking {set rev $create_branch_trackinghead}
+ expression {set rev $create_branch_revexp}
+ }
+ if {[catch {set cmt [exec git rev-parse --verify "${rev}^0"]}]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Invalid starting revision: $rev"
+ return
+ }
+ set cmd [list git update-ref]
+ lappend cmd -m
+ lappend cmd "branch: Created from $rev"
+ lappend cmd "refs/heads/$newbranch"
+ lappend cmd $cmt
+ lappend cmd $null_sha1
+ if {[catch {eval exec $cmd} err]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Failed to create '$newbranch'.\n\n$err"
+ return
+ }
+
+ lappend all_heads $newbranch
+ set all_heads [lsort $all_heads]
+ populate_branch_menu
+ destroy $w
+ if {$create_branch_checkout} {
+ switch_branch $newbranch
+ }
+}
+
+proc radio_selector {varname value args} {
+ upvar #0 $varname var
+ set var $value
+}
+
+trace add variable create_branch_head write \
+ [list radio_selector create_branch_revtype head]
+trace add variable create_branch_trackinghead write \
+ [list radio_selector create_branch_revtype tracking]
+
+trace add variable delete_branch_head write \
+ [list radio_selector delete_branch_checktype head]
+trace add variable delete_branch_trackinghead write \
+ [list radio_selector delete_branch_checktype tracking]
+
+proc do_create_branch {} {
+ global all_heads current_branch repo_config
+ global create_branch_checkout create_branch_revtype
+ global create_branch_head create_branch_trackinghead
+ global create_branch_name create_branch_revexp
+
+ set w .branch_editor
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text {Create New Branch} \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.create -text Create \
+ -font font_ui \
+ -default active \
+ -command [list do_create_branch_action $w]
+ pack $w.buttons.create -side right
+ button $w.buttons.cancel -text {Cancel} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.cancel -side right -padx 5
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ labelframe $w.desc \
+ -text {Branch Description} \
+ -font font_ui
+ label $w.desc.name_l -text {Name:} -font font_ui
+ entry $w.desc.name_t \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 40 \
+ -textvariable create_branch_name \
+ -font font_ui \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {[~^:?*\[\0- ]} %S]} {return 0}
+ return 1
+ }
+ grid $w.desc.name_l $w.desc.name_t -sticky we -padx {0 5}
+ grid columnconfigure $w.desc 1 -weight 1
+ pack $w.desc -anchor nw -fill x -pady 5 -padx 5
+
+ labelframe $w.from \
+ -text {Starting Revision} \
+ -font font_ui
+ radiobutton $w.from.head_r \
+ -text {Local Branch:} \
+ -value head \
+ -variable create_branch_revtype \
+ -font font_ui
+ eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
+ grid $w.from.head_r $w.from.head_m -sticky w
+ set all_trackings [all_tracking_branches]
+ if {$all_trackings ne {}} {
+ set create_branch_trackinghead [lindex $all_trackings 0]
+ radiobutton $w.from.tracking_r \
+ -text {Tracking Branch:} \
+ -value tracking \
+ -variable create_branch_revtype \
+ -font font_ui
+ eval tk_optionMenu $w.from.tracking_m \
+ create_branch_trackinghead \
+ $all_trackings
+ grid $w.from.tracking_r $w.from.tracking_m -sticky w
+ }
+ radiobutton $w.from.exp_r \
+ -text {Revision Expression:} \
+ -value expression \
+ -variable create_branch_revtype \
+ -font font_ui
+ entry $w.from.exp_t \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 50 \
+ -textvariable create_branch_revexp \
+ -font font_ui \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {\s} %S]} {return 0}
+ if {%d == 1 && [string length %S] > 0} {
+ set create_branch_revtype expression
+ }
+ return 1
+ }
+ grid $w.from.exp_r $w.from.exp_t -sticky we -padx {0 5}
+ grid columnconfigure $w.from 1 -weight 1
+ pack $w.from -anchor nw -fill x -pady 5 -padx 5
+
+ labelframe $w.postActions \
+ -text {Post Creation Actions} \
+ -font font_ui
+ checkbutton $w.postActions.checkout \
+ -text {Checkout after creation} \
+ -variable create_branch_checkout \
+ -font font_ui
+ pack $w.postActions.checkout -anchor nw
+ pack $w.postActions -anchor nw -fill x -pady 5 -padx 5
+
+ set create_branch_checkout 1
+ set create_branch_head $current_branch
+ set create_branch_revtype head
+ set create_branch_name $repo_config(gui.newbranchtemplate)
+ set create_branch_revexp {}
+
+ bind $w <Visibility> "
+ grab $w
+ $w.desc.name_t icursor end
+ focus $w.desc.name_t
+ "
+ bind $w <Key-Escape> "destroy $w"
+ bind $w <Key-Return> "do_create_branch_action $w;break"
+ wm title $w "[appname] ([reponame]): Create Branch"
+ tkwait window $w
+}
+
+proc do_delete_branch_action {w} {
+ global all_heads
+ global delete_branch_checktype delete_branch_head delete_branch_trackinghead
+
+ set check_rev {}
+ switch -- $delete_branch_checktype {
+ head {set check_rev $delete_branch_head}
+ tracking {set check_rev $delete_branch_trackinghead}
+ always {set check_rev {:none}}
+ }
+ if {$check_rev eq {:none}} {
+ set check_cmt {}
+ } elseif {[catch {set check_cmt [exec git rev-parse --verify "${check_rev}^0"]}]} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Invalid check revision: $check_rev"
+ return
+ }
+
+ set to_delete [list]
+ set not_merged [list]
+ foreach i [$w.list.l curselection] {
+ set b [$w.list.l get $i]
+ if {[catch {set o [exec git rev-parse --verify $b]}]} continue
+ if {$check_cmt ne {}} {
+ if {$b eq $check_rev} continue
+ if {[catch {set m [exec git merge-base $o $check_cmt]}]} continue
+ if {$o ne $m} {
+ lappend not_merged $b
+ continue
+ }
+ }
+ lappend to_delete [list $b $o]
+ }
+ if {$not_merged ne {}} {
+ set msg "The following branches are not completely merged into $check_rev:
+
+ - [join $not_merged "\n - "]"
+ tk_messageBox \
+ -icon info \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message $msg
+ }
+ if {$to_delete eq {}} return
+ if {$delete_branch_checktype eq {always}} {
+ set msg {Recovering deleted branches is difficult.
+
+Delete the selected branches?}
+ if {[tk_messageBox \
+ -icon warning \
+ -type yesno \
+ -title [wm title $w] \
+ -parent $w \
+ -message $msg] ne yes} {
+ return
+ }
+ }
+
+ set failed {}
+ foreach i $to_delete {
+ set b [lindex $i 0]
+ set o [lindex $i 1]
+ if {[catch {exec git update-ref -d "refs/heads/$b" $o} err]} {
+ append failed " - $b: $err\n"
+ } else {
+ set x [lsearch -sorted -exact $all_heads $b]
+ if {$x >= 0} {
+ set all_heads [lreplace $all_heads $x $x]
+ }
+ }
+ }
+
+ if {$failed ne {}} {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Failed to delete branches:\n$failed"
+ }
+
+ set all_heads [lsort $all_heads]
+ populate_branch_menu
+ destroy $w
+}
+
+proc do_delete_branch {} {
+ global all_heads tracking_branches current_branch
+ global delete_branch_checktype delete_branch_head delete_branch_trackinghead
+
+ set w .branch_editor
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text {Delete Local Branch} \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.create -text Delete \
+ -font font_ui \
+ -command [list do_delete_branch_action $w]
+ pack $w.buttons.create -side right
+ button $w.buttons.cancel -text {Cancel} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.cancel -side right -padx 5
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ labelframe $w.list \
+ -text {Local Branches} \
+ -font font_ui
+ listbox $w.list.l \
+ -height 10 \
+ -width 70 \
+ -selectmode extended \
+ -yscrollcommand [list $w.list.sby set] \
+ -font font_ui
+ foreach h $all_heads {
+ if {$h ne $current_branch} {
+ $w.list.l insert end $h
+ }
+ }
+ scrollbar $w.list.sby -command [list $w.list.l yview]
+ pack $w.list.sby -side right -fill y
+ pack $w.list.l -side left -fill both -expand 1
+ pack $w.list -fill both -expand 1 -pady 5 -padx 5
+
+ labelframe $w.validate \
+ -text {Delete Only If} \
+ -font font_ui
+ radiobutton $w.validate.head_r \
+ -text {Merged Into Local Branch:} \
+ -value head \
+ -variable delete_branch_checktype \
+ -font font_ui
+ eval tk_optionMenu $w.validate.head_m delete_branch_head $all_heads
+ grid $w.validate.head_r $w.validate.head_m -sticky w
+ set all_trackings [all_tracking_branches]
+ if {$all_trackings ne {}} {
+ set delete_branch_trackinghead [lindex $all_trackings 0]
+ radiobutton $w.validate.tracking_r \
+ -text {Merged Into Tracking Branch:} \
+ -value tracking \
+ -variable delete_branch_checktype \
+ -font font_ui
+ eval tk_optionMenu $w.validate.tracking_m \
+ delete_branch_trackinghead \
+ $all_trackings
+ grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
+ }
+ radiobutton $w.validate.always_r \
+ -text {Always (Do not perform merge checks)} \
+ -value always \
+ -variable delete_branch_checktype \
+ -font font_ui
+ grid $w.validate.always_r -columnspan 2 -sticky w
+ grid columnconfigure $w.validate 1 -weight 1
+ pack $w.validate -anchor nw -fill x -pady 5 -padx 5
+
+ set delete_branch_head $current_branch
+ set delete_branch_checktype head
+
+ bind $w <Visibility> "grab $w; focus $w"
+ bind $w <Key-Escape> "destroy $w"
+ wm title $w "[appname] ([reponame]): Delete Branch"
+ tkwait window $w
+}
+
+proc switch_branch {new_branch} {
+ global HEAD commit_type current_branch repo_config
+
+ if {![lock_index switch]} return
+
+ # -- Our in memory state should match the repository.
+ #
+ repository_state curType curHEAD curMERGE_HEAD
+ if {[string match amend* $commit_type]
+ && $curType eq {normal}
+ && $curHEAD eq $HEAD} {
+ } elseif {$commit_type ne $curType || $HEAD ne $curHEAD} {
+ info_popup {Last scanned state does not match repository state.
+
+Another Git program has modified this repository
+since the last scan. A rescan must be performed
+before the current branch can be changed.
+
+The rescan will be automatically started now.
+}
+ unlock_index
+ rescan {set ui_status_value {Ready.}}
+ return
+ }
+
+ # -- Don't do a pointless switch.
+ #
+ if {$current_branch eq $new_branch} {
+ unlock_index
+ return
+ }
+
+ if {$repo_config(gui.trustmtime) eq {true}} {
+ switch_branch_stage2 {} $new_branch
+ } else {
+ set ui_status_value {Refreshing file status...}
+ set cmd [list git update-index]
+ lappend cmd -q
+ lappend cmd --unmerged
+ lappend cmd --ignore-missing
+ lappend cmd --refresh
+ set fd_rf [open "| $cmd" r]
+ fconfigure $fd_rf -blocking 0 -translation binary
+ fileevent $fd_rf readable \
+ [list switch_branch_stage2 $fd_rf $new_branch]
+ }
+}
+
+proc switch_branch_stage2 {fd_rf new_branch} {
+ global ui_status_value HEAD
+
+ if {$fd_rf ne {}} {
+ read $fd_rf
+ if {![eof $fd_rf]} return
+ close $fd_rf
+ }
+
+ set ui_status_value "Updating working directory to '$new_branch'..."
+ set cmd [list git read-tree]
+ lappend cmd -m
+ lappend cmd -u
+ lappend cmd --exclude-per-directory=.gitignore
+ lappend cmd $HEAD
+ lappend cmd $new_branch
+ set fd_rt [open "| $cmd" r]
+ fconfigure $fd_rt -blocking 0 -translation binary
+ fileevent $fd_rt readable \
+ [list switch_branch_readtree_wait $fd_rt $new_branch]
+}
+
+proc switch_branch_readtree_wait {fd_rt new_branch} {
+ global selected_commit_type commit_type HEAD MERGE_HEAD PARENT
+ global current_branch
+ global ui_comm ui_status_value
+
+ # -- We never get interesting output on stdout; only stderr.
+ #
+ read $fd_rt
+ fconfigure $fd_rt -blocking 1
+ if {![eof $fd_rt]} {
+ fconfigure $fd_rt -blocking 0
+ return
+ }
+
+ # -- The working directory wasn't in sync with the index and
+ # we'd have to overwrite something to make the switch. A
+ # merge is required.
+ #
+ if {[catch {close $fd_rt} err]} {
+ regsub {^fatal: } $err {} err
+ warn_popup "File level merge required.
+
+$err
+
+Staying on branch '$current_branch'."
+ set ui_status_value "Aborted checkout of '$new_branch' (file level merging is required)."
+ unlock_index
+ return
+ }
+
+ # -- Update the symbolic ref. Core git doesn't even check for failure
+ # here, it Just Works(tm). If it doesn't we are in some really ugly
+ # state that is difficult to recover from within git-gui.
+ #
+ if {[catch {exec git symbolic-ref HEAD "refs/heads/$new_branch"} err]} {
+ error_popup "Failed to set current branch.
+
+This working directory is only partially switched.
+We successfully updated your files, but failed to
+update an internal Git file.
+
+This should not have occurred. [appname] will now
+close and give up.
+
+$err"
+ do_quit
+ return
+ }
+
+ # -- Update our repository state. If we were previously in amend mode
+ # we need to toss the current buffer and do a full rescan to update
+ # our file lists. If we weren't in amend mode our file lists are
+ # accurate and we can avoid the rescan.
+ #
+ unlock_index
+ set selected_commit_type new
+ if {[string match amend* $commit_type]} {
+ $ui_comm delete 0.0 end
+ $ui_comm edit reset
+ $ui_comm edit modified false
+ rescan {set ui_status_value "Checked out branch '$current_branch'."}
+ } else {
+ repository_state commit_type HEAD MERGE_HEAD
+ set PARENT $HEAD
+ set ui_status_value "Checked out branch '$current_branch'."
+ }
+}
+
+######################################################################
+##
+## remote management
+
+proc load_all_remotes {} {
+ global repo_config
+ global all_remotes tracking_branches
+
+ set all_remotes [list]
+ array unset tracking_branches
+
+ set rm_dir [gitdir remotes]
+ if {[file isdirectory $rm_dir]} {
+ set all_remotes [glob \
+ -types f \
+ -tails \
+ -nocomplain \
+ -directory $rm_dir *]
+
+ foreach name $all_remotes {
+ catch {
+ set fd [open [file join $rm_dir $name] r]
+ while {[gets $fd line] >= 0} {
+ if {![regexp {^Pull:[ ]*([^:]+):(.+)$} \
+ $line line src dst]} continue
+ if {![regexp ^refs/ $dst]} {
+ set dst "refs/heads/$dst"
+ }
+ set tracking_branches($dst) [list $name $src]
+ }
+ close $fd
+ }
+ }
+ }
+
+ foreach line [array names repo_config remote.*.url] {
+ if {![regexp ^remote\.(.*)\.url\$ $line line name]} continue
+ lappend all_remotes $name
+
+ if {[catch {set fl $repo_config(remote.$name.fetch)}]} {
+ set fl {}
+ }
+ foreach line $fl {
+ if {![regexp {^([^:]+):(.+)$} $line line src dst]} continue
+ if {![regexp ^refs/ $dst]} {
+ set dst "refs/heads/$dst"
+ }
+ set tracking_branches($dst) [list $name $src]
+ }
+ }
+
+ set all_remotes [lsort -unique $all_remotes]
+}
+
+proc populate_fetch_menu {} {
+ global all_remotes repo_config
+
+ set m .mbar.fetch
+ foreach r $all_remotes {
+ set enable 0
+ if {![catch {set a $repo_config(remote.$r.url)}]} {
+ if {![catch {set a $repo_config(remote.$r.fetch)}]} {
+ set enable 1
+ }
+ } else {
+ catch {
+ set fd [open [gitdir remotes $r] r]
+ while {[gets $fd n] >= 0} {
+ if {[regexp {^Pull:[ \t]*([^:]+):} $n]} {
+ set enable 1
+ break
+ }
+ }
+ close $fd
+ }
+ }
+
+ if {$enable} {
+ $m add command \
+ -label "Fetch from $r..." \
+ -command [list fetch_from $r] \
+ -font font_ui
+ }
+ }
+}
+
+proc populate_push_menu {} {
+ global all_remotes repo_config
+
+ set m .mbar.push
+ set fast_count 0
+ foreach r $all_remotes {
+ set enable 0
+ if {![catch {set a $repo_config(remote.$r.url)}]} {
+ if {![catch {set a $repo_config(remote.$r.push)}]} {
+ set enable 1
+ }
+ } else {
+ catch {
+ set fd [open [gitdir remotes $r] r]
+ while {[gets $fd n] >= 0} {
+ if {[regexp {^Push:[ \t]*([^:]+):} $n]} {
+ set enable 1
+ break
+ }
+ }
+ close $fd
+ }
+ }
+
+ if {$enable} {
+ if {!$fast_count} {
+ $m add separator
+ }
+ $m add command \
+ -label "Push to $r..." \
+ -command [list push_to $r] \
+ -font font_ui
+ incr fast_count
+ }
+ }
+}
+
+proc start_push_anywhere_action {w} {
+ global push_urltype push_remote push_url push_thin push_tags
+
+ set r_url {}
+ switch -- $push_urltype {
+ remote {set r_url $push_remote}
+ url {set r_url $push_url}
+ }
+ if {$r_url eq {}} return
+
+ set cmd [list git push]
+ lappend cmd -v
+ if {$push_thin} {
+ lappend cmd --thin
+ }
+ if {$push_tags} {
+ lappend cmd --tags
+ }
+ lappend cmd $r_url
+ set cnt 0
+ foreach i [$w.source.l curselection] {
+ set b [$w.source.l get $i]
+ lappend cmd "refs/heads/$b:refs/heads/$b"
+ incr cnt
+ }
+ if {$cnt == 0} {
+ return
+ } elseif {$cnt == 1} {
+ set unit branch
+ } else {
+ set unit branches
+ }
+
+ set cons [new_console "push $r_url" "Pushing $cnt $unit to $r_url"]
+ console_exec $cons $cmd console_done
+ destroy $w
+}
+
+trace add variable push_remote write \
+ [list radio_selector push_urltype remote]
+
+proc do_push_anywhere {} {
+ global all_heads all_remotes current_branch
+ global push_urltype push_remote push_url push_thin push_tags
+
+ set w .push_setup
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text {Push Branches} -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.create -text Push \
+ -font font_ui \
+ -command [list start_push_anywhere_action $w]
+ pack $w.buttons.create -side right
+ button $w.buttons.cancel -text {Cancel} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.cancel -side right -padx 5
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ labelframe $w.source \
+ -text {Source Branches} \
+ -font font_ui
+ listbox $w.source.l \
+ -height 10 \
+ -width 70 \
+ -selectmode extended \
+ -yscrollcommand [list $w.source.sby set] \
+ -font font_ui
+ foreach h $all_heads {
+ $w.source.l insert end $h
+ if {$h eq $current_branch} {
+ $w.source.l select set end
+ }
+ }
+ scrollbar $w.source.sby -command [list $w.source.l yview]
+ pack $w.source.sby -side right -fill y
+ pack $w.source.l -side left -fill both -expand 1
+ pack $w.source -fill both -expand 1 -pady 5 -padx 5
+
+ labelframe $w.dest \
+ -text {Destination Repository} \
+ -font font_ui
+ if {$all_remotes ne {}} {
+ radiobutton $w.dest.remote_r \
+ -text {Remote:} \
+ -value remote \
+ -variable push_urltype \
+ -font font_ui
+ eval tk_optionMenu $w.dest.remote_m push_remote $all_remotes
+ grid $w.dest.remote_r $w.dest.remote_m -sticky w
+ if {[lsearch -sorted -exact $all_remotes origin] != -1} {
+ set push_remote origin
+ } else {
+ set push_remote [lindex $all_remotes 0]
+ }
+ set push_urltype remote
+ } else {
+ set push_urltype url
+ }
+ radiobutton $w.dest.url_r \
+ -text {Arbitrary URL:} \
+ -value url \
+ -variable push_urltype \
+ -font font_ui
+ entry $w.dest.url_t \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 50 \
+ -textvariable push_url \
+ -font font_ui \
+ -validate key \
+ -validatecommand {
+ if {%d == 1 && [regexp {\s} %S]} {return 0}
+ if {%d == 1 && [string length %S] > 0} {
+ set push_urltype url
+ }
+ return 1
+ }
+ grid $w.dest.url_r $w.dest.url_t -sticky we -padx {0 5}
+ grid columnconfigure $w.dest 1 -weight 1
+ pack $w.dest -anchor nw -fill x -pady 5 -padx 5
+
+ labelframe $w.options \
+ -text {Transfer Options} \
+ -font font_ui
+ checkbutton $w.options.thin \
+ -text {Use thin pack (for slow network connections)} \
+ -variable push_thin \
+ -font font_ui
+ grid $w.options.thin -columnspan 2 -sticky w
+ checkbutton $w.options.tags \
+ -text {Include tags} \
+ -variable push_tags \
+ -font font_ui
+ grid $w.options.tags -columnspan 2 -sticky w
+ grid columnconfigure $w.options 1 -weight 1
+ pack $w.options -anchor nw -fill x -pady 5 -padx 5
+
+ set push_url {}
+ set push_thin 0
+ set push_tags 0
+
+ bind $w <Visibility> "grab $w"
+ bind $w <Key-Escape> "destroy $w"
+ wm title $w "[appname] ([reponame]): Push"
+ tkwait window $w
+}
+
+######################################################################
+##
+## merge
+
+proc can_merge {} {
+ global HEAD commit_type file_states
+
+ if {[string match amend* $commit_type]} {
+ info_popup {Cannot merge while amending.
+
+You must finish amending this commit before
+starting any type of merge.
+}
+ return 0
+ }
+
+ if {[committer_ident] eq {}} {return 0}
+ if {![lock_index merge]} {return 0}
+
+ # -- Our in memory state should match the repository.
+ #
+ repository_state curType curHEAD curMERGE_HEAD
+ if {$commit_type ne $curType || $HEAD ne $curHEAD} {
+ info_popup {Last scanned state does not match repository state.
+
+Another Git program has modified this repository
+since the last scan. A rescan must be performed
+before a merge can be performed.
+
+The rescan will be automatically started now.
+}
+ unlock_index
+ rescan {set ui_status_value {Ready.}}
+ return 0
+ }
+
+ foreach path [array names file_states] {
+ switch -glob -- [lindex $file_states($path) 0] {
+ _O {
+ continue; # and pray it works!
+ }
+ U? {
+ error_popup "You are in the middle of a conflicted merge.
+
+File [short_path $path] has merge conflicts.
+
+You must resolve them, add the file, and commit to
+complete the current merge. Only then can you
+begin another merge.
+"
+ unlock_index
+ return 0
+ }
+ ?? {
+ error_popup "You are in the middle of a change.
+
+File [short_path $path] is modified.
+
+You should complete the current commit before
+starting a merge. Doing so will help you abort
+a failed merge, should the need arise.
+"
+ unlock_index
+ return 0
+ }
+ }
+ }
+
+ return 1
+}
+
+proc visualize_local_merge {w} {
+ set revs {}
+ foreach i [$w.source.l curselection] {
+ lappend revs [$w.source.l get $i]
+ }
+ if {$revs eq {}} return
+ lappend revs --not HEAD
+ do_gitk $revs
+}
+
+proc start_local_merge_action {w} {
+ global HEAD ui_status_value current_branch
+
+ set cmd [list git merge]
+ set names {}
+ set revcnt 0
+ foreach i [$w.source.l curselection] {
+ set b [$w.source.l get $i]
+ lappend cmd $b
+ lappend names $b
+ incr revcnt
+ }
+
+ if {$revcnt == 0} {
+ return
+ } elseif {$revcnt == 1} {
+ set unit branch
+ } elseif {$revcnt <= 15} {
+ set unit branches
+ } else {
+ tk_messageBox \
+ -icon error \
+ -type ok \
+ -title [wm title $w] \
+ -parent $w \
+ -message "Too many branches selected.
+
+You have requested to merge $revcnt branches
+in an octopus merge. This exceeds Git's
+internal limit of 15 branches per merge.
+
+Please select fewer branches. To merge more
+than 15 branches, merge the branches in batches.
+"
+ return
+ }
+
+ set msg "Merging $current_branch, [join $names {, }]"
+ set ui_status_value "$msg..."
+ set cons [new_console "Merge" $msg]
+ console_exec $cons $cmd [list finish_merge $revcnt]
+ bind $w <Destroy> {}
+ destroy $w
+}
+
+proc finish_merge {revcnt w ok} {
+ console_done $w $ok
+ if {$ok} {
+ set msg {Merge completed successfully.}
+ } else {
+ if {$revcnt != 1} {
+ info_popup "Octopus merge failed.
+
+Your merge of $revcnt branches has failed.
+
+There are file-level conflicts between the
+branches which must be resolved manually.
+
+The working directory will now be reset.
+
+You can attempt this merge again
+by merging only one branch at a time." $w
+
+ set fd [open "| git read-tree --reset -u HEAD" r]
+ fconfigure $fd -blocking 0 -translation binary
+ fileevent $fd readable [list reset_hard_wait $fd]
+ set ui_status_value {Aborting... please wait...}
+ return
+ }
+
+ set msg {Merge failed. Conflict resolution is required.}
+ }
+ unlock_index
+ rescan [list set ui_status_value $msg]
+}
+
+proc do_local_merge {} {
+ global current_branch
+
+ if {![can_merge]} return
+
+ set w .merge_setup
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header \
+ -text "Merge Into $current_branch" \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.visualize -text Visualize \
+ -font font_ui \
+ -command [list visualize_local_merge $w]
+ pack $w.buttons.visualize -side left
+ button $w.buttons.create -text Merge \
+ -font font_ui \
+ -command [list start_local_merge_action $w]
+ pack $w.buttons.create -side right
+ button $w.buttons.cancel -text {Cancel} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.cancel -side right -padx 5
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ labelframe $w.source \
+ -text {Source Branches} \
+ -font font_ui
+ listbox $w.source.l \
+ -height 10 \
+ -width 70 \
+ -selectmode extended \
+ -yscrollcommand [list $w.source.sby set] \
+ -font font_ui
+ scrollbar $w.source.sby -command [list $w.source.l yview]
+ pack $w.source.sby -side right -fill y
+ pack $w.source.l -side left -fill both -expand 1
+ pack $w.source -fill both -expand 1 -pady 5 -padx 5
+
+ set cmd [list git for-each-ref]
+ lappend cmd {--format=%(objectname) %(refname)}
+ lappend cmd refs/heads
+ lappend cmd refs/remotes
+ set fr_fd [open "| $cmd" r]
+ fconfigure $fr_fd -translation binary
+ while {[gets $fr_fd line] > 0} {
+ set line [split $line { }]
+ set sha1([lindex $line 0]) [lindex $line 1]
+ }
+ close $fr_fd
+
+ set to_show {}
+ set fr_fd [open "| git rev-list --all --not HEAD"]
+ while {[gets $fr_fd line] > 0} {
+ if {[catch {set ref $sha1($line)}]} continue
+ regsub ^refs/(heads|remotes)/ $ref {} ref
+ lappend to_show $ref
+ }
+ close $fr_fd
+
+ foreach ref [lsort -unique $to_show] {
+ $w.source.l insert end $ref
+ }
+
+ bind $w <Visibility> "grab $w"
+ bind $w <Key-Escape> "unlock_index;destroy $w"
+ bind $w <Destroy> unlock_index
+ wm title $w "[appname] ([reponame]): Merge"
+ tkwait window $w
+}
+
+proc do_reset_hard {} {
+ global HEAD commit_type file_states
+
+ if {[string match amend* $commit_type]} {
+ info_popup {Cannot abort while amending.
+
+You must finish amending this commit.
+}
+ return
+ }
+
+ if {![lock_index abort]} return
+
+ if {[string match *merge* $commit_type]} {
+ set op merge
+ } else {
+ set op commit
+ }
+
+ if {[ask_popup "Abort $op?
+
+Aborting the current $op will cause
+*ALL* uncommitted changes to be lost.
+
+Continue with aborting the current $op?"] eq {yes}} {
+ set fd [open "| git read-tree --reset -u HEAD" r]
+ fconfigure $fd -blocking 0 -translation binary
+ fileevent $fd readable [list reset_hard_wait $fd]
+ set ui_status_value {Aborting... please wait...}
+ } else {
+ unlock_index
+ }
+}
+
+proc reset_hard_wait {fd} {
+ global ui_comm
+
+ read $fd
+ if {[eof $fd]} {
+ close $fd
+ unlock_index
+
+ $ui_comm delete 0.0 end
+ $ui_comm edit modified false
+
+ catch {file delete [gitdir MERGE_HEAD]}
+ catch {file delete [gitdir rr-cache MERGE_RR]}
+ catch {file delete [gitdir SQUASH_MSG]}
+ catch {file delete [gitdir MERGE_MSG]}
+ catch {file delete [gitdir GITGUI_MSG]}
+
+ rescan {set ui_status_value {Abort completed. Ready.}}
+ }
+}
+
+######################################################################
+##
+## browser
+
+set next_browser_id 0
+
+proc new_browser {commit} {
+ global next_browser_id cursor_ptr M1B
+ global browser_commit browser_status browser_stack browser_path browser_busy
+
+ set w .browser[incr next_browser_id]
+ set w_list $w.list.l
+ set browser_commit($w_list) $commit
+ set browser_status($w_list) {Starting...}
+ set browser_stack($w_list) {}
+ set browser_path($w_list) $browser_commit($w_list):
+ set browser_busy($w_list) 1
+
+ toplevel $w
+ label $w.path -textvariable browser_path($w_list) \
+ -anchor w \
+ -justify left \
+ -borderwidth 1 \
+ -relief sunken \
+ -font font_uibold
+ pack $w.path -anchor w -side top -fill x
+
+ frame $w.list
+ text $w_list -background white -borderwidth 0 \
+ -cursor $cursor_ptr \
+ -state disabled \
+ -wrap none \
+ -height 20 \
+ -width 70 \
+ -xscrollcommand [list $w.list.sbx set] \
+ -yscrollcommand [list $w.list.sby set] \
+ -font font_ui
+ $w_list tag conf in_sel \
+ -background [$w_list cget -foreground] \
+ -foreground [$w_list cget -background]
+ scrollbar $w.list.sbx -orient h -command [list $w_list xview]
+ scrollbar $w.list.sby -orient v -command [list $w_list yview]
+ pack $w.list.sbx -side bottom -fill x
+ pack $w.list.sby -side right -fill y
+ pack $w_list -side left -fill both -expand 1
+ pack $w.list -side top -fill both -expand 1
+
+ label $w.status -textvariable browser_status($w_list) \
+ -anchor w \
+ -justify left \
+ -borderwidth 1 \
+ -relief sunken \
+ -font font_ui
+ pack $w.status -anchor w -side bottom -fill x
+
+ bind $w_list <Button-1> "browser_click 0 $w_list @%x,%y;break"
+ bind $w_list <Double-Button-1> "browser_click 1 $w_list @%x,%y;break"
+ bind $w_list <$M1B-Up> "browser_parent $w_list;break"
+ bind $w_list <$M1B-Left> "browser_parent $w_list;break"
+ bind $w_list <Up> "browser_move -1 $w_list;break"
+ bind $w_list <Down> "browser_move 1 $w_list;break"
+ bind $w_list <$M1B-Right> "browser_enter $w_list;break"
+ bind $w_list <Return> "browser_enter $w_list;break"
+ bind $w_list <Prior> "browser_page -1 $w_list;break"
+ bind $w_list <Next> "browser_page 1 $w_list;break"
+ bind $w_list <Left> break
+ bind $w_list <Right> break
+
+ bind $w <Visibility> "focus $w"
+ bind $w <Destroy> "
+ array unset browser_buffer $w_list
+ array unset browser_files $w_list
+ array unset browser_status $w_list
+ array unset browser_stack $w_list
+ array unset browser_path $w_list
+ array unset browser_commit $w_list
+ array unset browser_busy $w_list
+ "
+ wm title $w "[appname] ([reponame]): File Browser"
+ ls_tree $w_list $browser_commit($w_list) {}
+}
+
+proc browser_move {dir w} {
+ global browser_files browser_busy
+
+ if {$browser_busy($w)} return
+ set lno [lindex [split [$w index in_sel.first] .] 0]
+ incr lno $dir
+ if {[lindex $browser_files($w) [expr {$lno - 1}]] ne {}} {
+ $w tag remove in_sel 0.0 end
+ $w tag add in_sel $lno.0 [expr {$lno + 1}].0
+ $w see $lno.0
+ }
+}
+
+proc browser_page {dir w} {
+ global browser_files browser_busy
+
+ if {$browser_busy($w)} return
+ $w yview scroll $dir pages
+ set lno [expr {int(
+ [lindex [$w yview] 0]
+ * [llength $browser_files($w)]
+ + 1)}]
+ if {[lindex $browser_files($w) [expr {$lno - 1}]] ne {}} {
+ $w tag remove in_sel 0.0 end
+ $w tag add in_sel $lno.0 [expr {$lno + 1}].0
+ $w see $lno.0
+ }
+}
+
+proc browser_parent {w} {
+ global browser_files browser_status browser_path
+ global browser_stack browser_busy
+
+ if {$browser_busy($w)} return
+ set info [lindex $browser_files($w) 0]
+ if {[lindex $info 0] eq {parent}} {
+ set parent [lindex $browser_stack($w) end-1]
+ set browser_stack($w) [lrange $browser_stack($w) 0 end-2]
+ if {$browser_stack($w) eq {}} {
+ regsub {:.*$} $browser_path($w) {:} browser_path($w)
+ } else {
+ regsub {/[^/]+$} $browser_path($w) {} browser_path($w)
+ }
+ set browser_status($w) "Loading $browser_path($w)..."
+ ls_tree $w [lindex $parent 0] [lindex $parent 1]
+ }
+}
+
+proc browser_enter {w} {
+ global browser_files browser_status browser_path
+ global browser_commit browser_stack browser_busy
+
+ if {$browser_busy($w)} return
+ set lno [lindex [split [$w index in_sel.first] .] 0]
+ set info [lindex $browser_files($w) [expr {$lno - 1}]]
+ if {$info ne {}} {
+ switch -- [lindex $info 0] {
+ parent {
+ browser_parent $w
+ }
+ tree {
+ set name [lindex $info 2]
+ set escn [escape_path $name]
+ set browser_status($w) "Loading $escn..."
+ append browser_path($w) $escn
+ ls_tree $w [lindex $info 1] $name
+ }
+ blob {
+ set name [lindex $info 2]
+ set p {}
+ foreach n $browser_stack($w) {
+ append p [lindex $n 1]
+ }
+ append p $name
+ show_blame $browser_commit($w) $p
+ }
+ }
+ }
+}
+
+proc browser_click {was_double_click w pos} {
+ global browser_files browser_busy
+
+ if {$browser_busy($w)} return
+ set lno [lindex [split [$w index $pos] .] 0]
+ focus $w
+
+ if {[lindex $browser_files($w) [expr {$lno - 1}]] ne {}} {
+ $w tag remove in_sel 0.0 end
+ $w tag add in_sel $lno.0 [expr {$lno + 1}].0
+ if {$was_double_click} {
+ browser_enter $w
+ }
+ }
+}
+
+proc ls_tree {w tree_id name} {
+ global browser_buffer browser_files browser_stack browser_busy
+
+ set browser_buffer($w) {}
+ set browser_files($w) {}
+ set browser_busy($w) 1
+
+ $w conf -state normal
+ $w tag remove in_sel 0.0 end
+ $w delete 0.0 end
+ if {$browser_stack($w) ne {}} {
+ $w image create end \
+ -align center -padx 5 -pady 1 \
+ -name icon0 \
+ -image file_uplevel
+ $w insert end {[Up To Parent]}
+ lappend browser_files($w) parent
+ }
+ lappend browser_stack($w) [list $tree_id $name]
+ $w conf -state disabled
+
+ set cmd [list git ls-tree -z $tree_id]
+ set fd [open "| $cmd" r]
+ fconfigure $fd -blocking 0 -translation binary -encoding binary
+ fileevent $fd readable [list read_ls_tree $fd $w]
+}
+
+proc read_ls_tree {fd w} {
+ global browser_buffer browser_files browser_status browser_busy
+
+ if {![winfo exists $w]} {
+ catch {close $fd}
+ return
+ }
+
+ append browser_buffer($w) [read $fd]
+ set pck [split $browser_buffer($w) "\0"]
+ set browser_buffer($w) [lindex $pck end]
+
+ set n [llength $browser_files($w)]
+ $w conf -state normal
+ foreach p [lrange $pck 0 end-1] {
+ set info [split $p "\t"]
+ set path [lindex $info 1]
+ set info [split [lindex $info 0] { }]
+ set type [lindex $info 1]
+ set object [lindex $info 2]
+
+ switch -- $type {
+ blob {
+ set image file_mod
+ }
+ tree {
+ set image file_dir
+ append path /
+ }
+ default {
+ set image file_question
+ }
+ }
+
+ if {$n > 0} {$w insert end "\n"}
+ $w image create end \
+ -align center -padx 5 -pady 1 \
+ -name icon[incr n] \
+ -image $image
+ $w insert end [escape_path $path]
+ lappend browser_files($w) [list $type $object $path]
+ }
+ $w conf -state disabled
+
+ if {[eof $fd]} {
+ close $fd
+ set browser_status($w) Ready.
+ set browser_busy($w) 0
+ array unset browser_buffer $w
+ if {$n > 0} {
+ $w tag add in_sel 1.0 2.0
+ focus -force $w
+ }
+ }
+}
+
+proc show_blame {commit path} {
+ global next_browser_id blame_status blame_data
+
+ if {[winfo ismapped .]} {
+ set w .browser[incr next_browser_id]
+ set tl $w
+ toplevel $w
+ } else {
+ set w {}
+ set tl .
+ }
+ set blame_status($w) {Loading current file content...}
+
+ label $w.path -text "$commit:$path" \
+ -anchor w \
+ -justify left \
+ -borderwidth 1 \
+ -relief sunken \
+ -font font_uibold
+ pack $w.path -side top -fill x
+
+ frame $w.out
+ text $w.out.loaded_t \
+ -background white -borderwidth 0 \
+ -state disabled \
+ -wrap none \
+ -height 40 \
+ -width 1 \
+ -font font_diff
+ $w.out.loaded_t tag conf annotated -background grey
+
+ text $w.out.linenumber_t \
+ -background white -borderwidth 0 \
+ -state disabled \
+ -wrap none \
+ -height 40 \
+ -width 5 \
+ -font font_diff
+ $w.out.linenumber_t tag conf linenumber -justify right
+
+ text $w.out.file_t \
+ -background white -borderwidth 0 \
+ -state disabled \
+ -wrap none \
+ -height 40 \
+ -width 80 \
+ -xscrollcommand [list $w.out.sbx set] \
+ -font font_diff
+
+ scrollbar $w.out.sbx -orient h -command [list $w.out.file_t xview]
+ scrollbar $w.out.sby -orient v \
+ -command [list scrollbar2many [list \
+ $w.out.loaded_t \
+ $w.out.linenumber_t \
+ $w.out.file_t \
+ ] yview]
+ grid \
+ $w.out.linenumber_t \
+ $w.out.loaded_t \
+ $w.out.file_t \
+ $w.out.sby \
+ -sticky nsew
+ grid conf $w.out.sbx -column 2 -sticky we
+ grid columnconfigure $w.out 2 -weight 1
+ grid rowconfigure $w.out 0 -weight 1
+ pack $w.out -fill both -expand 1
+
+ label $w.status -textvariable blame_status($w) \
+ -anchor w \
+ -justify left \
+ -borderwidth 1 \
+ -relief sunken \
+ -font font_ui
+ pack $w.status -side bottom -fill x
+
+ frame $w.cm
+ text $w.cm.t \
+ -background white -borderwidth 0 \
+ -state disabled \
+ -wrap none \
+ -height 10 \
+ -width 80 \
+ -xscrollcommand [list $w.cm.sbx set] \
+ -yscrollcommand [list $w.cm.sby set] \
+ -font font_diff
+ scrollbar $w.cm.sbx -orient h -command [list $w.cm.t xview]
+ scrollbar $w.cm.sby -orient v -command [list $w.cm.t yview]
+ pack $w.cm.sby -side right -fill y
+ pack $w.cm.sbx -side bottom -fill x
+ pack $w.cm.t -expand 1 -fill both
+ pack $w.cm -side bottom -fill x
+
+ menu $w.ctxm -tearoff 0
+ $w.ctxm add command -label "Copy Commit" \
+ -font font_ui \
+ -command "blame_copycommit $w \$cursorW @\$cursorX,\$cursorY"
+
+ foreach i [list \
+ $w.out.loaded_t \
+ $w.out.linenumber_t \
+ $w.out.file_t] {
+ $i tag conf in_sel \
+ -background [$i cget -foreground] \
+ -foreground [$i cget -background]
+ $i conf -yscrollcommand \
+ [list many2scrollbar [list \
+ $w.out.loaded_t \
+ $w.out.linenumber_t \
+ $w.out.file_t \
+ ] yview $w.out.sby]
+ bind $i <Button-1> "
+ blame_click {$w} \\
+ $w.cm.t \\
+ $w.out.linenumber_t \\
+ $w.out.file_t \\
+ $i @%x,%y
+ focus $i
+ "
+ bind_button3 $i "
+ set cursorX %x
+ set cursorY %y
+ set cursorW %W
+ tk_popup $w.ctxm %X %Y
+ "
+ }
+
+ bind $w.cm.t <Button-1> "focus $w.cm.t"
+ bind $tl <Visibility> "focus $tl"
+ bind $tl <Destroy> "
+ array unset blame_status {$w}
+ array unset blame_data $w,*
+ "
+ wm title $tl "[appname] ([reponame]): File Viewer"
+
+ set blame_data($w,commit_count) 0
+ set blame_data($w,commit_list) {}
+ set blame_data($w,total_lines) 0
+ set blame_data($w,blame_lines) 0
+ set blame_data($w,highlight_commit) {}
+ set blame_data($w,highlight_line) -1
+
+ set cmd [list git cat-file blob "$commit:$path"]
+ set fd [open "| $cmd" r]
+ fconfigure $fd -blocking 0 -translation lf -encoding binary
+ fileevent $fd readable [list read_blame_catfile \
+ $fd $w $commit $path \
+ $w.cm.t $w.out.loaded_t $w.out.linenumber_t $w.out.file_t]
+}
+
+proc read_blame_catfile {fd w commit path w_cmit w_load w_line w_file} {
+ global blame_status blame_data
+
+ if {![winfo exists $w_file]} {
+ catch {close $fd}
+ return
+ }
+
+ set n $blame_data($w,total_lines)
+ $w_load conf -state normal
+ $w_line conf -state normal
+ $w_file conf -state normal
+ while {[gets $fd line] >= 0} {
+ regsub "\r\$" $line {} line
+ incr n
+ $w_load insert end "\n"
+ $w_line insert end "$n\n" linenumber
+ $w_file insert end "$line\n"
+ }
+ $w_load conf -state disabled
+ $w_line conf -state disabled
+ $w_file conf -state disabled
+ set blame_data($w,total_lines) $n
+
+ if {[eof $fd]} {
+ close $fd
+ blame_incremental_status $w
+ set cmd [list git blame -M -C --incremental]
+ lappend cmd $commit -- $path
+ set fd [open "| $cmd" r]
+ fconfigure $fd -blocking 0 -translation lf -encoding binary
+ fileevent $fd readable [list read_blame_incremental $fd $w \
+ $w_load $w_cmit $w_line $w_file]
+ }
+}
+
+proc read_blame_incremental {fd w w_load w_cmit w_line w_file} {
+ global blame_status blame_data
+
+ if {![winfo exists $w_file]} {
+ catch {close $fd}
+ return
+ }
+
+ while {[gets $fd line] >= 0} {
+ if {[regexp {^([a-z0-9]{40}) (\d+) (\d+) (\d+)$} $line line \
+ cmit original_line final_line line_count]} {
+ set blame_data($w,commit) $cmit
+ set blame_data($w,original_line) $original_line
+ set blame_data($w,final_line) $final_line
+ set blame_data($w,line_count) $line_count
+
+ if {[catch {set g $blame_data($w,$cmit,order)}]} {
+ $w_line tag conf g$cmit
+ $w_file tag conf g$cmit
+ $w_line tag raise in_sel
+ $w_file tag raise in_sel
+ $w_file tag raise sel
+ set blame_data($w,$cmit,order) $blame_data($w,commit_count)
+ incr blame_data($w,commit_count)
+ lappend blame_data($w,commit_list) $cmit
+ }
+ } elseif {[string match {filename *} $line]} {
+ set file [string range $line 9 end]
+ set n $blame_data($w,line_count)
+ set lno $blame_data($w,final_line)
+ set cmit $blame_data($w,commit)
+
+ while {$n > 0} {
+ if {[catch {set g g$blame_data($w,line$lno,commit)}]} {
+ $w_load tag add annotated $lno.0 "$lno.0 lineend + 1c"
+ } else {
+ $w_line tag remove g$g $lno.0 "$lno.0 lineend + 1c"
+ $w_file tag remove g$g $lno.0 "$lno.0 lineend + 1c"
+ }
+
+ set blame_data($w,line$lno,commit) $cmit
+ set blame_data($w,line$lno,file) $file
+ $w_line tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
+ $w_file tag add g$cmit $lno.0 "$lno.0 lineend + 1c"
+
+ if {$blame_data($w,highlight_line) == -1} {
+ if {[lindex [$w_file yview] 0] == 0} {
+ $w_file see $lno.0
+ blame_showcommit $w $w_cmit $w_line $w_file $lno
+ }
+ } elseif {$blame_data($w,highlight_line) == $lno} {
+ blame_showcommit $w $w_cmit $w_line $w_file $lno
+ }
+
+ incr n -1
+ incr lno
+ incr blame_data($w,blame_lines)
+ }
+
+ set hc $blame_data($w,highlight_commit)
+ if {$hc ne {}
+ && [expr {$blame_data($w,$hc,order) + 1}]
+ == $blame_data($w,$cmit,order)} {
+ blame_showcommit $w $w_cmit $w_line $w_file \
+ $blame_data($w,highlight_line)
+ }
+ } elseif {[regexp {^([a-z-]+) (.*)$} $line line header data]} {
+ set blame_data($w,$blame_data($w,commit),$header) $data
+ }
+ }
+
+ if {[eof $fd]} {
+ close $fd
+ set blame_status($w) {Annotation complete.}
+ } else {
+ blame_incremental_status $w
+ }
+}
+
+proc blame_incremental_status {w} {
+ global blame_status blame_data
+
+ set blame_status($w) [format \
+ "Loading annotations... %i of %i lines annotated (%2i%%)" \
+ $blame_data($w,blame_lines) \
+ $blame_data($w,total_lines) \
+ [expr {100 * $blame_data($w,blame_lines)
+ / $blame_data($w,total_lines)}]]
+}
+
+proc blame_click {w w_cmit w_line w_file cur_w pos} {
+ set lno [lindex [split [$cur_w index $pos] .] 0]
+ if {$lno eq {}} return
+
+ $w_line tag remove in_sel 0.0 end
+ $w_file tag remove in_sel 0.0 end
+ $w_line tag add in_sel $lno.0 "$lno.0 + 1 line"
+ $w_file tag add in_sel $lno.0 "$lno.0 + 1 line"
+
+ blame_showcommit $w $w_cmit $w_line $w_file $lno
+}
+
+set blame_colors {
+ #ff4040
+ #ff40ff
+ #4040ff
+}
+
+proc blame_showcommit {w w_cmit w_line w_file lno} {
+ global blame_colors blame_data repo_config
+
+ set cmit $blame_data($w,highlight_commit)
+ if {$cmit ne {}} {
+ set idx $blame_data($w,$cmit,order)
+ set i 0
+ foreach c $blame_colors {
+ set h [lindex $blame_data($w,commit_list) [expr {$idx - 1 + $i}]]
+ $w_line tag conf g$h -background white
+ $w_file tag conf g$h -background white
+ incr i
+ }
+ }
+
+ $w_cmit conf -state normal
+ $w_cmit delete 0.0 end
+ if {[catch {set cmit $blame_data($w,line$lno,commit)}]} {
+ set cmit {}
+ $w_cmit insert end "Loading annotation..."
+ } else {
+ set idx $blame_data($w,$cmit,order)
+ set i 0
+ foreach c $blame_colors {
+ set h [lindex $blame_data($w,commit_list) [expr {$idx - 1 + $i}]]
+ $w_line tag conf g$h -background $c
+ $w_file tag conf g$h -background $c
+ incr i
+ }
+
+ if {[catch {set msg $blame_data($w,$cmit,message)}]} {
+ set msg {}
+ catch {
+ set fd [open "| git cat-file commit $cmit" r]
+ fconfigure $fd -encoding binary -translation lf
+ if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
+ set enc utf-8
+ }
+ while {[gets $fd line] > 0} {
+ if {[string match {encoding *} $line]} {
+ set enc [string tolower [string range $line 9 end]]
+ }
+ }
+ fconfigure $fd -encoding $enc
+ set msg [string trim [read $fd]]
+ close $fd
+ }
+ set blame_data($w,$cmit,message) $msg
+ }
+
+ set author_name {}
+ set author_email {}
+ set author_time {}
+ catch {set author_name $blame_data($w,$cmit,author)}
+ catch {set author_email $blame_data($w,$cmit,author-mail)}
+ catch {set author_time [clock format $blame_data($w,$cmit,author-time)]}
+
+ set committer_name {}
+ set committer_email {}
+ set committer_time {}
+ catch {set committer_name $blame_data($w,$cmit,committer)}
+ catch {set committer_email $blame_data($w,$cmit,committer-mail)}
+ catch {set committer_time [clock format $blame_data($w,$cmit,committer-time)]}
+
+ $w_cmit insert end "commit $cmit\n"
+ $w_cmit insert end "Author: $author_name $author_email $author_time\n"
+ $w_cmit insert end "Committer: $committer_name $committer_email $committer_time\n"
+ $w_cmit insert end "Original File: [escape_path $blame_data($w,line$lno,file)]\n"
+ $w_cmit insert end "\n"
+ $w_cmit insert end $msg
+ }
+ $w_cmit conf -state disabled
+
+ set blame_data($w,highlight_line) $lno
+ set blame_data($w,highlight_commit) $cmit
+}
+
+proc blame_copycommit {w i pos} {
+ global blame_data
+ set lno [lindex [split [$i index $pos] .] 0]
+ if {![catch {set commit $blame_data($w,line$lno,commit)}]} {
+ clipboard clear
+ clipboard append \
+ -format STRING \
+ -type STRING \
+ -- $commit
+ }
+}
+
+######################################################################
+##
+## icons
+
+set filemask {
+#define mask_width 14
+#define mask_height 15
+static unsigned char mask_bits[] = {
+ 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
+ 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f,
+ 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f};
+}
+
+image create bitmap file_plain -background white -foreground black -data {
+#define plain_width 14
+#define plain_height 15
+static unsigned char plain_bits[] = {
+ 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
+ 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10, 0x02, 0x10,
+ 0x02, 0x10, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_mod -background white -foreground blue -data {
+#define mod_width 14
+#define mod_height 15
+static unsigned char mod_bits[] = {
+ 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
+ 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
+ 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_fulltick -background white -foreground "#007000" -data {
+#define file_fulltick_width 14
+#define file_fulltick_height 15
+static unsigned char file_fulltick_bits[] = {
+ 0xfe, 0x01, 0x02, 0x1a, 0x02, 0x0c, 0x02, 0x0c, 0x02, 0x16, 0x02, 0x16,
+ 0x02, 0x13, 0x00, 0x13, 0x86, 0x11, 0x8c, 0x11, 0xd8, 0x10, 0xf2, 0x10,
+ 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_parttick -background white -foreground "#005050" -data {
+#define parttick_width 14
+#define parttick_height 15
+static unsigned char parttick_bits[] = {
+ 0xfe, 0x01, 0x02, 0x03, 0x7a, 0x05, 0x02, 0x09, 0x7a, 0x1f, 0x02, 0x10,
+ 0x7a, 0x14, 0x02, 0x16, 0x02, 0x13, 0x8a, 0x11, 0xda, 0x10, 0x72, 0x10,
+ 0x22, 0x10, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_question -background white -foreground black -data {
+#define file_question_width 14
+#define file_question_height 15
+static unsigned char file_question_bits[] = {
+ 0xfe, 0x01, 0x02, 0x02, 0xe2, 0x04, 0xf2, 0x09, 0x1a, 0x1b, 0x0a, 0x13,
+ 0x82, 0x11, 0xc2, 0x10, 0x62, 0x10, 0x62, 0x10, 0x02, 0x10, 0x62, 0x10,
+ 0x62, 0x10, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_removed -background white -foreground red -data {
+#define file_removed_width 14
+#define file_removed_height 15
+static unsigned char file_removed_bits[] = {
+ 0xfe, 0x01, 0x02, 0x03, 0x02, 0x05, 0x02, 0x09, 0x02, 0x1f, 0x02, 0x10,
+ 0x1a, 0x16, 0x32, 0x13, 0xe2, 0x11, 0xc2, 0x10, 0xe2, 0x11, 0x32, 0x13,
+ 0x1a, 0x16, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+image create bitmap file_merge -background white -foreground blue -data {
+#define file_merge_width 14
+#define file_merge_height 15
+static unsigned char file_merge_bits[] = {
+ 0xfe, 0x01, 0x02, 0x03, 0x62, 0x05, 0x62, 0x09, 0x62, 0x1f, 0x62, 0x10,
+ 0xfa, 0x11, 0xf2, 0x10, 0x62, 0x10, 0x02, 0x10, 0xfa, 0x17, 0x02, 0x10,
+ 0xfa, 0x17, 0x02, 0x10, 0xfe, 0x1f};
+} -maskdata $filemask
+
+set file_dir_data {
+#define file_width 18
+#define file_height 18
+static unsigned char file_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0x00,
+ 0x0c, 0x03, 0x00, 0x04, 0xfe, 0x00, 0x06, 0x80, 0x00, 0xff, 0x9f, 0x00,
+ 0x03, 0x98, 0x00, 0x02, 0x90, 0x00, 0x06, 0xb0, 0x00, 0x04, 0xa0, 0x00,
+ 0x0c, 0xe0, 0x00, 0x08, 0xc0, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+}
+image create bitmap file_dir -background white -foreground blue \
+ -data $file_dir_data -maskdata $file_dir_data
+unset file_dir_data
+
+set file_uplevel_data {
+#define up_width 15
+#define up_height 15
+static unsigned char up_bits[] = {
+ 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f,
+ 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
+}
+image create bitmap file_uplevel -background white -foreground red \
+ -data $file_uplevel_data -maskdata $file_uplevel_data
+unset file_uplevel_data
+
+set ui_index .vpane.files.index.list
+set ui_workdir .vpane.files.workdir.list
+
+set all_icons(_$ui_index) file_plain
+set all_icons(A$ui_index) file_fulltick
+set all_icons(M$ui_index) file_fulltick
+set all_icons(D$ui_index) file_removed
+set all_icons(U$ui_index) file_merge
+
+set all_icons(_$ui_workdir) file_plain
+set all_icons(M$ui_workdir) file_mod
+set all_icons(D$ui_workdir) file_question
+set all_icons(U$ui_workdir) file_merge
+set all_icons(O$ui_workdir) file_plain
+
+set max_status_desc 0
+foreach i {
+ {__ "Unmodified"}
+
+ {_M "Modified, not staged"}
+ {M_ "Staged for commit"}
+ {MM "Portions staged for commit"}
+ {MD "Staged for commit, missing"}
+
+ {_O "Untracked, not staged"}
+ {A_ "Staged for commit"}
+ {AM "Portions staged for commit"}
+ {AD "Staged for commit, missing"}
+
+ {_D "Missing"}
+ {D_ "Staged for removal"}
+ {DO "Staged for removal, still present"}
+
+ {U_ "Requires merge resolution"}
+ {UU "Requires merge resolution"}
+ {UM "Requires merge resolution"}
+ {UD "Requires merge resolution"}
+ } {
+ if {$max_status_desc < [string length [lindex $i 1]]} {
+ set max_status_desc [string length [lindex $i 1]]
+ }
+ set all_descs([lindex $i 0]) [lindex $i 1]
+}
+unset i
+
+######################################################################
+##
+## util
+
+proc bind_button3 {w cmd} {
+ bind $w <Any-Button-3> $cmd
+ if {[is_MacOSX]} {
+ bind $w <Control-Button-1> $cmd
+ }
+}
+
+proc scrollbar2many {list mode args} {
+ foreach w $list {eval $w $mode $args}
+}
+
+proc many2scrollbar {list mode sb top bottom} {
+ $sb set $top $bottom
+ foreach w $list {$w $mode moveto $top}
+}
+
+proc incr_font_size {font {amt 1}} {
+ set sz [font configure $font -size]
+ incr sz $amt
+ font configure $font -size $sz
+ font configure ${font}bold -size $sz
+}
+
+proc hook_failed_popup {hook msg} {
+ set w .hookfail
+ toplevel $w
+
+ frame $w.m
+ label $w.m.l1 -text "$hook hook failed:" \
+ -anchor w \
+ -justify left \
+ -font font_uibold
+ text $w.m.t \
+ -background white -borderwidth 1 \
+ -relief sunken \
+ -width 80 -height 10 \
+ -font font_diff \
+ -yscrollcommand [list $w.m.sby set]
+ label $w.m.l2 \
+ -text {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
+ 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
+
+ $w.m.t insert 1.0 $msg
+ $w.m.t conf -state disabled
+
+ button $w.ok -text OK \
+ -width 15 \
+ -font font_ui \
+ -command "destroy $w"
+ pack $w.ok -side bottom -anchor e -pady 10 -padx 10
+
+ bind $w <Visibility> "grab $w; focus $w"
+ bind $w <Key-Return> "destroy $w"
+ wm title $w "[appname] ([reponame]): error"
+ tkwait window $w
+}
+
+set next_console_id 0
+
+proc new_console {short_title long_title} {
+ global next_console_id console_data
+ set w .console[incr next_console_id]
+ set console_data($w) [list $short_title $long_title]
+ return [console_init $w]
+}
+
+proc console_init {w} {
+ global console_cr console_data M1B
+
+ set console_cr($w) 1.0
+ toplevel $w
+ frame $w.m
+ label $w.m.l1 -text "[lindex $console_data($w) 1]:" \
+ -anchor w \
+ -justify left \
+ -font font_uibold
+ text $w.m.t \
+ -background white -borderwidth 1 \
+ -relief sunken \
+ -width 80 -height 10 \
+ -font font_diff \
+ -state disabled \
+ -yscrollcommand [list $w.m.sby set]
+ label $w.m.s -text {Working... please wait...} \
+ -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.s -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
+
+ menu $w.ctxm -tearoff 0
+ $w.ctxm add command -label "Copy" \
+ -font font_ui \
+ -command "tk_textCopy $w.m.t"
+ $w.ctxm add command -label "Select All" \
+ -font font_ui \
+ -command "focus $w.m.t;$w.m.t tag add sel 0.0 end"
+ $w.ctxm add command -label "Copy All" \
+ -font font_ui \
+ -command "
+ $w.m.t tag add sel 0.0 end
+ tk_textCopy $w.m.t
+ $w.m.t tag remove sel 0.0 end
+ "
+
+ button $w.ok -text {Close} \
+ -font font_ui \
+ -state disabled \
+ -command "destroy $w"
+ pack $w.ok -side bottom -anchor e -pady 10 -padx 10
+
+ bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y"
+ bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
+ bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
+ bind $w <Visibility> "focus $w"
+ wm title $w "[appname] ([reponame]): [lindex $console_data($w) 0]"
+ return $w
+}
+
+proc console_exec {w cmd after} {
+ # -- Cygwin's Tcl tosses the enviroment when we exec our child.
+ # But most users need that so we have to relogin. :-(
+ #
+ if {[is_Cygwin]} {
+ set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"]
+ }
+
+ # -- Tcl won't let us redirect both stdout and stderr to
+ # the same pipe. So pass it through cat...
+ #
+ set cmd [concat | $cmd |& cat]
+
+ set fd_f [open $cmd r]
+ fconfigure $fd_f -blocking 0 -translation binary
+ fileevent $fd_f readable [list console_read $w $fd_f $after]
+}
+
+proc console_read {w fd after} {
+ global console_cr
+
+ set buf [read $fd]
+ if {$buf ne {}} {
+ if {![winfo exists $w]} {console_init $w}
+ $w.m.t conf -state normal
+ set c 0
+ set n [string length $buf]
+ while {$c < $n} {
+ set cr [string first "\r" $buf $c]
+ set lf [string first "\n" $buf $c]
+ if {$cr < 0} {set cr [expr {$n + 1}]}
+ if {$lf < 0} {set lf [expr {$n + 1}]}
+
+ if {$lf < $cr} {
+ $w.m.t insert end [string range $buf $c $lf]
+ set console_cr($w) [$w.m.t index {end -1c}]
+ set c $lf
+ incr c
+ } else {
+ $w.m.t delete $console_cr($w) end
+ $w.m.t insert end "\n"
+ $w.m.t insert end [string range $buf $c $cr]
+ set c $cr
+ incr c
+ }
+ }
+ $w.m.t conf -state disabled
+ $w.m.t see end
+ }
+
+ fconfigure $fd -blocking 1
+ if {[eof $fd]} {
+ if {[catch {close $fd}]} {
+ set ok 0
+ } else {
+ set ok 1
+ }
+ uplevel #0 $after $w $ok
+ return
+ }
+ fconfigure $fd -blocking 0
+}
+
+proc console_chain {cmdlist w {ok 1}} {
+ if {$ok} {
+ if {[llength $cmdlist] == 0} {
+ console_done $w $ok
+ return
+ }
+
+ set cmd [lindex $cmdlist 0]
+ set cmdlist [lrange $cmdlist 1 end]
+
+ if {[lindex $cmd 0] eq {console_exec}} {
+ console_exec $w \
+ [lindex $cmd 1] \
+ [list console_chain $cmdlist]
+ } else {
+ uplevel #0 $cmd $cmdlist $w $ok
+ }
+ } else {
+ console_done $w $ok
+ }
+}
+
+proc console_done {args} {
+ global console_cr console_data
+
+ switch -- [llength $args] {
+ 2 {
+ set w [lindex $args 0]
+ set ok [lindex $args 1]
+ }
+ 3 {
+ set w [lindex $args 1]
+ set ok [lindex $args 2]
+ }
+ default {
+ error "wrong number of args: console_done ?ignored? w ok"
+ }
+ }
+
+ if {$ok} {
+ if {[winfo exists $w]} {
+ $w.m.s conf -background green -text {Success}
+ $w.ok conf -state normal
+ }
+ } else {
+ if {![winfo exists $w]} {
+ console_init $w
+ }
+ $w.m.s conf -background red -text {Error: Command Failed}
+ $w.ok conf -state normal
+ }
+
+ array unset console_cr $w
+ array unset console_data $w
+}
+
+######################################################################
+##
+## ui commands
+
+set starting_gitk_msg {Starting gitk... please wait...}
+
+proc do_gitk {revs} {
+ global env ui_status_value starting_gitk_msg
+
+ # -- Always start gitk through whatever we were loaded with. This
+ # lets us bypass using shell process on Windows systems.
+ #
+ set cmd [info nameofexecutable]
+ lappend cmd [gitexec gitk]
+ if {$revs ne {}} {
+ append cmd { }
+ append cmd $revs
+ }
+
+ if {[catch {eval exec $cmd &} err]} {
+ error_popup "Failed to start gitk:\n\n$err"
+ } else {
+ set ui_status_value $starting_gitk_msg
+ after 10000 {
+ if {$ui_status_value eq $starting_gitk_msg} {
+ set ui_status_value {Ready.}
+ }
+ }
+ }
+}
+
+proc do_stats {} {
+ set fd [open "| git count-objects -v" r]
+ while {[gets $fd line] > 0} {
+ if {[regexp {^([^:]+): (\d+)$} $line _ name value]} {
+ set stats($name) $value
+ }
+ }
+ close $fd
+
+ set packed_sz 0
+ foreach p [glob -directory [gitdir objects pack] \
+ -type f \
+ -nocomplain -- *] {
+ incr packed_sz [file size $p]
+ }
+ if {$packed_sz > 0} {
+ set stats(size-pack) [expr {$packed_sz / 1024}]
+ }
+
+ set w .stats_view
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text {Database Statistics} \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons -border 1
+ button $w.buttons.close -text Close \
+ -font font_ui \
+ -command [list destroy $w]
+ button $w.buttons.gc -text {Compress Database} \
+ -font font_ui \
+ -command "destroy $w;do_gc"
+ pack $w.buttons.close -side right
+ pack $w.buttons.gc -side left
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ frame $w.stat -borderwidth 1 -relief solid
+ foreach s {
+ {count {Number of loose objects}}
+ {size {Disk space used by loose objects} { KiB}}
+ {in-pack {Number of packed objects}}
+ {packs {Number of packs}}
+ {size-pack {Disk space used by packed objects} { KiB}}
+ {prune-packable {Packed objects waiting for pruning}}
+ {garbage {Garbage files}}
+ } {
+ set name [lindex $s 0]
+ set label [lindex $s 1]
+ if {[catch {set value $stats($name)}]} continue
+ if {[llength $s] > 2} {
+ set value "$value[lindex $s 2]"
+ }
+
+ label $w.stat.l_$name -text "$label:" -anchor w -font font_ui
+ label $w.stat.v_$name -text $value -anchor w -font font_ui
+ grid $w.stat.l_$name $w.stat.v_$name -sticky we -padx {0 5}
+ }
+ pack $w.stat -pady 10 -padx 10
+
+ bind $w <Visibility> "grab $w; focus $w"
+ bind $w <Key-Escape> [list destroy $w]
+ bind $w <Key-Return> [list destroy $w]
+ wm title $w "[appname] ([reponame]): Database Statistics"
+ tkwait window $w
+}
+
+proc do_gc {} {
+ set w [new_console {gc} {Compressing the object database}]
+ console_chain {
+ {console_exec {git pack-refs --prune}}
+ {console_exec {git reflog expire --all}}
+ {console_exec {git repack -a -d -l}}
+ {console_exec {git rerere gc}}
+ } $w
+}
+
+proc do_fsck_objects {} {
+ set w [new_console {fsck-objects} \
+ {Verifying the object database with fsck-objects}]
+ set cmd [list git fsck-objects]
+ lappend cmd --full
+ lappend cmd --cache
+ lappend cmd --strict
+ console_exec $w $cmd console_done
+}
+
+set is_quitting 0
+
+proc do_quit {} {
+ global ui_comm is_quitting repo_config commit_type
+
+ if {$is_quitting} return
+ set is_quitting 1
+
+ if {[winfo exists $ui_comm]} {
+ # -- Stash our current commit buffer.
+ #
+ set save [gitdir GITGUI_MSG]
+ set msg [string trim [$ui_comm get 0.0 end]]
+ regsub -all -line {[ \r\t]+$} $msg {} msg
+ if {(![string match amend* $commit_type]
+ || [$ui_comm edit modified])
+ && $msg ne {}} {
+ catch {
+ set fd [open $save w]
+ puts -nonewline $fd $msg
+ close $fd
+ }
+ } else {
+ catch {file delete $save}
+ }
+
+ # -- Stash our current window geometry into this repository.
+ #
+ set cfg_geometry [list]
+ lappend cfg_geometry [wm geometry .]
+ lappend cfg_geometry [lindex [.vpane sash coord 0] 1]
+ lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0]
+ if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
+ set rc_geometry {}
+ }
+ if {$cfg_geometry ne $rc_geometry} {
+ catch {exec git config gui.geometry $cfg_geometry}
+ }
+ }
+
+ destroy .
+}
+
+proc do_rescan {} {
+ rescan {set ui_status_value {Ready.}}
+}
+
+proc unstage_helper {txt paths} {
+ global file_states current_diff_path
+
+ if {![lock_index begin-update]} return
+
+ set pathList [list]
+ set after {}
+ foreach path $paths {
+ switch -glob -- [lindex $file_states($path) 0] {
+ A? -
+ M? -
+ D? {
+ lappend pathList $path
+ if {$path eq $current_diff_path} {
+ set after {reshow_diff;}
+ }
+ }
+ }
+ }
+ if {$pathList eq {}} {
+ unlock_index
+ } else {
+ update_indexinfo \
+ $txt \
+ $pathList \
+ [concat $after {set ui_status_value {Ready.}}]
+ }
+}
+
+proc do_unstage_selection {} {
+ global current_diff_path selected_paths
+
+ if {[array size selected_paths] > 0} {
+ unstage_helper \
+ {Unstaging selected files from commit} \
+ [array names selected_paths]
+ } elseif {$current_diff_path ne {}} {
+ unstage_helper \
+ "Unstaging [short_path $current_diff_path] from commit" \
+ [list $current_diff_path]
+ }
+}
+
+proc add_helper {txt paths} {
+ global file_states current_diff_path
+
+ if {![lock_index begin-update]} return
+
+ set pathList [list]
+ set after {}
+ foreach path $paths {
+ switch -glob -- [lindex $file_states($path) 0] {
+ _O -
+ ?M -
+ ?D -
+ U? {
+ lappend pathList $path
+ if {$path eq $current_diff_path} {
+ set after {reshow_diff;}
+ }
+ }
+ }
+ }
+ if {$pathList eq {}} {
+ unlock_index
+ } else {
+ update_index \
+ $txt \
+ $pathList \
+ [concat $after {set ui_status_value {Ready to commit.}}]
+ }
+}
+
+proc do_add_selection {} {
+ global current_diff_path selected_paths
+
+ if {[array size selected_paths] > 0} {
+ add_helper \
+ {Adding selected files} \
+ [array names selected_paths]
+ } elseif {$current_diff_path ne {}} {
+ add_helper \
+ "Adding [short_path $current_diff_path]" \
+ [list $current_diff_path]
+ }
+}
+
+proc do_add_all {} {
+ global file_states
+
+ set paths [list]
+ foreach path [array names file_states] {
+ switch -glob -- [lindex $file_states($path) 0] {
+ U? {continue}
+ ?M -
+ ?D {lappend paths $path}
+ }
+ }
+ add_helper {Adding all changed files} $paths
+}
+
+proc revert_helper {txt paths} {
+ global file_states current_diff_path
+
+ if {![lock_index begin-update]} return
+
+ set pathList [list]
+ set after {}
+ foreach path $paths {
+ switch -glob -- [lindex $file_states($path) 0] {
+ U? {continue}
+ ?M -
+ ?D {
+ lappend pathList $path
+ if {$path eq $current_diff_path} {
+ set after {reshow_diff;}
+ }
+ }
+ }
+ }
+
+ set n [llength $pathList]
+ if {$n == 0} {
+ unlock_index
+ return
+ } elseif {$n == 1} {
+ set s "[short_path [lindex $pathList]]"
+ } else {
+ set s "these $n files"
+ }
+
+ set reply [tk_dialog \
+ .confirm_revert \
+ "[appname] ([reponame])" \
+ "Revert changes in $s?
+
+Any unadded changes will be permanently lost by the revert." \
+ question \
+ 1 \
+ {Do Nothing} \
+ {Revert Changes} \
+ ]
+ if {$reply == 1} {
+ checkout_index \
+ $txt \
+ $pathList \
+ [concat $after {set ui_status_value {Ready.}}]
+ } else {
+ unlock_index
+ }
+}
+
+proc do_revert_selection {} {
+ global current_diff_path selected_paths
+
+ if {[array size selected_paths] > 0} {
+ revert_helper \
+ {Reverting selected files} \
+ [array names selected_paths]
+ } elseif {$current_diff_path ne {}} {
+ revert_helper \
+ "Reverting [short_path $current_diff_path]" \
+ [list $current_diff_path]
+ }
+}
+
+proc do_signoff {} {
+ global ui_comm
+
+ set me [committer_ident]
+ if {$me eq {}} return
+
+ set sob "Signed-off-by: $me"
+ set last [$ui_comm get {end -1c linestart} {end -1c}]
+ if {$last ne $sob} {
+ $ui_comm edit separator
+ if {$last ne {}
+ && ![regexp {^[A-Z][A-Za-z]*-[A-Za-z-]+: *} $last]} {
+ $ui_comm insert end "\n"
+ }
+ $ui_comm insert end "\n$sob"
+ $ui_comm edit separator
+ $ui_comm see end
+ }
+}
+
+proc do_select_commit_type {} {
+ global commit_type selected_commit_type
+
+ if {$selected_commit_type eq {new}
+ && [string match amend* $commit_type]} {
+ create_new_commit
+ } elseif {$selected_commit_type eq {amend}
+ && ![string match amend* $commit_type]} {
+ load_last_commit
+
+ # The amend request was rejected...
+ #
+ if {![string match amend* $commit_type]} {
+ set selected_commit_type new
+ }
+ }
+}
+
+proc do_commit {} {
+ commit_tree
+}
+
+proc do_about {} {
+ global appvers copyright
+ global tcl_patchLevel tk_patchLevel
+
+ set w .about_dialog
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text "About [appname]" \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.close -text {Close} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.close -side right
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ label $w.desc \
+ -text "[appname] - a commit creation tool for Git.
+$copyright" \
+ -padx 5 -pady 5 \
+ -justify left \
+ -anchor w \
+ -borderwidth 1 \
+ -relief solid \
+ -font font_ui
+ pack $w.desc -side top -fill x -padx 5 -pady 5
+
+ set v {}
+ append v "[appname] version $appvers\n"
+ append v "[exec git version]\n"
+ append v "\n"
+ if {$tcl_patchLevel eq $tk_patchLevel} {
+ append v "Tcl/Tk version $tcl_patchLevel"
+ } else {
+ append v "Tcl version $tcl_patchLevel"
+ append v ", Tk version $tk_patchLevel"
+ }
+
+ label $w.vers \
+ -text $v \
+ -padx 5 -pady 5 \
+ -justify left \
+ -anchor w \
+ -borderwidth 1 \
+ -relief solid \
+ -font font_ui
+ pack $w.vers -side top -fill x -padx 5 -pady 5
+
+ menu $w.ctxm -tearoff 0
+ $w.ctxm add command \
+ -label {Copy} \
+ -font font_ui \
+ -command "
+ clipboard clear
+ clipboard append -format STRING -type STRING -- \[$w.vers cget -text\]
+ "
+
+ bind $w <Visibility> "grab $w; focus $w"
+ bind $w <Key-Escape> "destroy $w"
+ bind_button3 $w.vers "tk_popup $w.ctxm %X %Y; grab $w; focus $w"
+ wm title $w "About [appname]"
+ tkwait window $w
+}
+
+proc do_options {} {
+ global repo_config global_config font_descs
+ global repo_config_new global_config_new
+
+ array unset repo_config_new
+ array unset global_config_new
+ foreach name [array names repo_config] {
+ set repo_config_new($name) $repo_config($name)
+ }
+ load_config 1
+ foreach name [array names repo_config] {
+ switch -- $name {
+ gui.diffcontext {continue}
+ }
+ set repo_config_new($name) $repo_config($name)
+ }
+ foreach name [array names global_config] {
+ set global_config_new($name) $global_config($name)
+ }
+
+ set w .options_editor
+ toplevel $w
+ wm geometry $w "+[winfo rootx .]+[winfo rooty .]"
+
+ label $w.header -text "[appname] Options" \
+ -font font_uibold
+ pack $w.header -side top -fill x
+
+ frame $w.buttons
+ button $w.buttons.restore -text {Restore Defaults} \
+ -font font_ui \
+ -command do_restore_defaults
+ pack $w.buttons.restore -side left
+ button $w.buttons.save -text Save \
+ -font font_ui \
+ -command [list do_save_config $w]
+ pack $w.buttons.save -side right
+ button $w.buttons.cancel -text {Cancel} \
+ -font font_ui \
+ -command [list destroy $w]
+ pack $w.buttons.cancel -side right -padx 5
+ pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+ labelframe $w.repo -text "[reponame] Repository" \
+ -font font_ui
+ labelframe $w.global -text {Global (All Repositories)} \
+ -font font_ui
+ pack $w.repo -side left -fill both -expand 1 -pady 5 -padx 5
+ pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
+
+ set optid 0
+ foreach option {
+ {t user.name {User Name}}
+ {t user.email {Email Address}}
+
+ {b merge.summary {Summarize Merge Commits}}
+ {i-1..5 merge.verbosity {Merge Verbosity}}
+
+ {b gui.trustmtime {Trust File Modification Timestamps}}
+ {i-1..99 gui.diffcontext {Number of Diff Context Lines}}
+ {t gui.newbranchtemplate {New Branch Name Template}}
+ } {
+ set type [lindex $option 0]
+ set name [lindex $option 1]
+ set text [lindex $option 2]
+ incr optid
+ foreach f {repo global} {
+ switch -glob -- $type {
+ b {
+ checkbutton $w.$f.$optid -text $text \
+ -variable ${f}_config_new($name) \
+ -onvalue true \
+ -offvalue false \
+ -font font_ui
+ pack $w.$f.$optid -side top -anchor w
+ }
+ i-* {
+ regexp -- {-(\d+)\.\.(\d+)$} $type _junk min max
+ frame $w.$f.$optid
+ label $w.$f.$optid.l -text "$text:" -font font_ui
+ pack $w.$f.$optid.l -side left -anchor w -fill x
+ spinbox $w.$f.$optid.v \
+ -textvariable ${f}_config_new($name) \
+ -from $min \
+ -to $max \
+ -increment 1 \
+ -width [expr {1 + [string length $max]}] \
+ -font font_ui
+ bind $w.$f.$optid.v <FocusIn> {%W selection range 0 end}
+ pack $w.$f.$optid.v -side right -anchor e -padx 5
+ pack $w.$f.$optid -side top -anchor w -fill x
+ }
+ t {
+ frame $w.$f.$optid
+ label $w.$f.$optid.l -text "$text:" -font font_ui
+ entry $w.$f.$optid.v \
+ -borderwidth 1 \
+ -relief sunken \
+ -width 20 \
+ -textvariable ${f}_config_new($name) \
+ -font font_ui
+ pack $w.$f.$optid.l -side left -anchor w
+ pack $w.$f.$optid.v -side left -anchor w \
+ -fill x -expand 1 \
+ -padx 5
+ pack $w.$f.$optid -side top -anchor w -fill x
+ }
+ }
+ }
+ }
+
+ set all_fonts [lsort [font families]]
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ set text [lindex $option 2]
+
+ set global_config_new(gui.$font^^family) \
+ [font configure $font -family]
+ set global_config_new(gui.$font^^size) \
+ [font configure $font -size]
+
+ frame $w.global.$name
+ label $w.global.$name.l -text "$text:" -font font_ui
+ pack $w.global.$name.l -side left -anchor w -fill x
+ eval tk_optionMenu $w.global.$name.family \
+ global_config_new(gui.$font^^family) \
+ $all_fonts
+ spinbox $w.global.$name.size \
+ -textvariable global_config_new(gui.$font^^size) \
+ -from 2 -to 80 -increment 1 \
+ -width 3 \
+ -font font_ui
+ bind $w.global.$name.size <FocusIn> {%W selection range 0 end}
+ pack $w.global.$name.size -side right -anchor e
+ pack $w.global.$name.family -side right -anchor e
+ pack $w.global.$name -side top -anchor w -fill x
+ }
+
+ bind $w <Visibility> "grab $w; focus $w"
+ bind $w <Key-Escape> "destroy $w"
+ wm title $w "[appname] ([reponame]): Options"
+ tkwait window $w
+}
+
+proc do_restore_defaults {} {
+ global font_descs default_config repo_config
+ global repo_config_new global_config_new
+
+ foreach name [array names default_config] {
+ set repo_config_new($name) $default_config($name)
+ set global_config_new($name) $default_config($name)
+ }
+
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set repo_config(gui.$name) $default_config(gui.$name)
+ }
+ apply_config
+
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ set global_config_new(gui.$font^^family) \
+ [font configure $font -family]
+ set global_config_new(gui.$font^^size) \
+ [font configure $font -size]
+ }
+}
+
+proc do_save_config {w} {
+ if {[catch {save_config} err]} {
+ error_popup "Failed to completely save options:\n\n$err"
+ }
+ reshow_diff
+ destroy $w
+}
+
+proc do_windows_shortcut {} {
+ global argv0
+
+ set fn [tk_getSaveFile \
+ -parent . \
+ -title "[appname] ([reponame]): Create Desktop Icon" \
+ -initialfile "Git [reponame].bat"]
+ if {$fn != {}} {
+ if {[catch {
+ set fd [open $fn w]
+ puts $fd "@ECHO Entering [reponame]"
+ puts $fd "@ECHO Starting git-gui... please wait..."
+ puts $fd "@SET PATH=[file normalize [gitexec]];%PATH%"
+ puts $fd "@SET GIT_DIR=[file normalize [gitdir]]"
+ puts -nonewline $fd "@\"[info nameofexecutable]\""
+ puts $fd " \"[file normalize $argv0]\""
+ close $fd
+ } err]} {
+ error_popup "Cannot write script:\n\n$err"
+ }
+ }
+}
+
+proc do_cygwin_shortcut {} {
+ global argv0
+
+ if {[catch {
+ set desktop [exec cygpath \
+ --windows \
+ --absolute \
+ --long-name \
+ --desktop]
+ }]} {
+ set desktop .
+ }
+ set fn [tk_getSaveFile \
+ -parent . \
+ -title "[appname] ([reponame]): Create Desktop Icon" \
+ -initialdir $desktop \
+ -initialfile "Git [reponame].bat"]
+ if {$fn != {}} {
+ if {[catch {
+ set fd [open $fn w]
+ set sh [exec cygpath \
+ --windows \
+ --absolute \
+ /bin/sh]
+ set me [exec cygpath \
+ --unix \
+ --absolute \
+ $argv0]
+ set gd [exec cygpath \
+ --unix \
+ --absolute \
+ [gitdir]]
+ set gw [exec cygpath \
+ --windows \
+ --absolute \
+ [file dirname [gitdir]]]
+ regsub -all ' $me "'\\''" me
+ regsub -all ' $gd "'\\''" gd
+ puts $fd "@ECHO Entering $gw"
+ puts $fd "@ECHO Starting git-gui... please wait..."
+ puts -nonewline $fd "@\"$sh\" --login -c \""
+ puts -nonewline $fd "GIT_DIR='$gd'"
+ puts -nonewline $fd " '$me'"
+ puts $fd "&\""
+ close $fd
+ } err]} {
+ error_popup "Cannot write script:\n\n$err"
+ }
+ }
+}
+
+proc do_macosx_app {} {
+ global argv0 env
+
+ set fn [tk_getSaveFile \
+ -parent . \
+ -title "[appname] ([reponame]): Create Desktop Icon" \
+ -initialdir [file join $env(HOME) Desktop] \
+ -initialfile "Git [reponame].app"]
+ if {$fn != {}} {
+ if {[catch {
+ set Contents [file join $fn Contents]
+ set MacOS [file join $Contents MacOS]
+ set exe [file join $MacOS git-gui]
+
+ file mkdir $MacOS
+
+ set fd [open [file join $Contents Info.plist] w]
+ puts $fd {<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>git-gui</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.spearce.git-gui</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>}
+ close $fd
+
+ set fd [open $exe w]
+ set gd [file normalize [gitdir]]
+ set ep [file normalize [gitexec]]
+ regsub -all ' $gd "'\\''" gd
+ regsub -all ' $ep "'\\''" ep
+ puts $fd "#!/bin/sh"
+ foreach name [array names env] {
+ if {[string match GIT_* $name]} {
+ regsub -all ' $env($name) "'\\''" v
+ puts $fd "export $name='$v'"
+ }
+ }
+ puts $fd "export PATH='$ep':\$PATH"
+ puts $fd "export GIT_DIR='$gd'"
+ puts $fd "exec [file normalize $argv0]"
+ close $fd
+
+ file attributes $exe -permissions u+x,g+x,o+x
+ } err]} {
+ error_popup "Cannot write icon:\n\n$err"
+ }
+ }
+}
+
+proc toggle_or_diff {w x y} {
+ global file_states file_lists current_diff_path ui_index ui_workdir
+ global last_clicked selected_paths
+
+ set pos [split [$w index @$x,$y] .]
+ set lno [lindex $pos 0]
+ set col [lindex $pos 1]
+ set path [lindex $file_lists($w) [expr {$lno - 1}]]
+ if {$path eq {}} {
+ set last_clicked {}
+ return
+ }
+
+ set last_clicked [list $w $lno]
+ array unset selected_paths
+ $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} {
+ set after {reshow_diff;}
+ } else {
+ set after {}
+ }
+ if {$w eq $ui_index} {
+ update_indexinfo \
+ "Unstaging [short_path $path] from commit" \
+ [list $path] \
+ [concat $after {set ui_status_value {Ready.}}]
+ } elseif {$w eq $ui_workdir} {
+ update_index \
+ "Adding [short_path $path]" \
+ [list $path] \
+ [concat $after {set ui_status_value {Ready.}}]
+ }
+ } else {
+ show_diff $path $w $lno
+ }
+}
+
+proc add_one_to_selection {w x y} {
+ global file_lists last_clicked selected_paths
+
+ set lno [lindex [split [$w index @$x,$y] .] 0]
+ set path [lindex $file_lists($w) [expr {$lno - 1}]]
+ if {$path eq {}} {
+ set last_clicked {}
+ return
+ }
+
+ if {$last_clicked ne {}
+ && [lindex $last_clicked 0] ne $w} {
+ array unset selected_paths
+ [lindex $last_clicked 0] tag remove in_sel 0.0 end
+ }
+
+ set last_clicked [list $w $lno]
+ if {[catch {set in_sel $selected_paths($path)}]} {
+ set in_sel 0
+ }
+ if {$in_sel} {
+ unset selected_paths($path)
+ $w tag remove in_sel $lno.0 [expr {$lno + 1}].0
+ } else {
+ set selected_paths($path) 1
+ $w tag add in_sel $lno.0 [expr {$lno + 1}].0
+ }
+}
+
+proc add_range_to_selection {w x y} {
+ global file_lists last_clicked selected_paths
+
+ if {[lindex $last_clicked 0] ne $w} {
+ toggle_or_diff $w $x $y
+ return
+ }
+
+ set lno [lindex [split [$w index @$x,$y] .] 0]
+ set lc [lindex $last_clicked 1]
+ if {$lc < $lno} {
+ set begin $lc
+ set end $lno
+ } else {
+ set begin $lno
+ set end $lc
+ }
+
+ foreach path [lrange $file_lists($w) \
+ [expr {$begin - 1}] \
+ [expr {$end - 1}]] {
+ set selected_paths($path) 1
+ }
+ $w tag add in_sel $begin.0 [expr {$end + 1}].0
+}
+
+######################################################################
+##
+## config defaults
+
+set cursor_ptr arrow
+font create font_diff -family Courier -size 10
+font create font_ui
+catch {
+ label .dummy
+ eval font configure font_ui [font actual [.dummy cget -font]]
+ destroy .dummy
+}
+
+font create font_uibold
+font create font_diffbold
+
+if {[is_Windows]} {
+ set M1B Control
+ set M1T Ctrl
+} elseif {[is_MacOSX]} {
+ set M1B M1
+ set M1T Cmd
+} else {
+ set M1B M1
+ set M1T M1
+}
+
+proc apply_config {} {
+ global repo_config font_descs
+
+ foreach option $font_descs {
+ set name [lindex $option 0]
+ set font [lindex $option 1]
+ if {[catch {
+ foreach {cn cv} $repo_config(gui.$name) {
+ font configure $font $cn $cv
+ }
+ } err]} {
+ error_popup "Invalid font specified in gui.$name:\n\n$err"
+ }
+ foreach {cn cv} [font configure $font] {
+ font configure ${font}bold $cn $cv
+ }
+ font configure ${font}bold -weight bold
+ }
+}
+
+set default_config(merge.summary) false
+set default_config(merge.verbosity) 2
+set default_config(user.name) {}
+set default_config(user.email) {}
+
+set default_config(gui.trustmtime) false
+set default_config(gui.diffcontext) 5
+set default_config(gui.newbranchtemplate) {}
+set default_config(gui.fontui) [font configure font_ui]
+set default_config(gui.fontdiff) [font configure font_diff]
+set font_descs {
+ {fontui font_ui {Main Font}}
+ {fontdiff font_diff {Diff/Console Font}}
+}
+load_config 0
+apply_config
+
+######################################################################
+##
+## feature option selection
+
+if {[regexp {^git-(.+)$} [appname] _junk subcommand]} {
+ unset _junk
+} else {
+ set subcommand gui
+}
+if {$subcommand eq {gui.sh}} {
+ set subcommand gui
+}
+if {$subcommand eq {gui} && [llength $argv] > 0} {
+ set subcommand [lindex $argv 0]
+ set argv [lrange $argv 1 end]
+}
+
+enable_option multicommit
+enable_option branch
+enable_option transport
+
+switch -- $subcommand {
+blame {
+ disable_option multicommit
+ disable_option branch
+ disable_option transport
+}
+citool {
+ enable_option singlecommit
+
+ disable_option multicommit
+ disable_option branch
+ disable_option transport
+}
+}
+
+######################################################################
+##
+## ui construction
+
+set ui_comm {}
+
+# -- Menu Bar
+#
+menu .mbar -tearoff 0
+.mbar add cascade -label Repository -menu .mbar.repository
+.mbar add cascade -label Edit -menu .mbar.edit
+if {[is_enabled branch]} {
+ .mbar add cascade -label Branch -menu .mbar.branch
+}
+if {[is_enabled multicommit] || [is_enabled singlecommit]} {
+ .mbar add cascade -label Commit -menu .mbar.commit
+}
+if {[is_enabled transport]} {
+ .mbar add cascade -label Merge -menu .mbar.merge
+ .mbar add cascade -label Fetch -menu .mbar.fetch
+ .mbar add cascade -label Push -menu .mbar.push
+}
+. configure -menu .mbar
+
+# -- Repository Menu
+#
+menu .mbar.repository
+
+.mbar.repository add command \
+ -label {Browse Current Branch} \
+ -command {new_browser $current_branch} \
+ -font font_ui
+trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Browse \$current_branch\" ;#"
+.mbar.repository add separator
+
+.mbar.repository add command \
+ -label {Visualize Current Branch} \
+ -command {do_gitk $current_branch} \
+ -font font_ui
+trace add variable current_branch write ".mbar.repository entryconf [.mbar.repository index last] -label \"Visualize \$current_branch\" ;#"
+.mbar.repository add command \
+ -label {Visualize All Branches} \
+ -command {do_gitk --all} \
+ -font font_ui
+.mbar.repository add separator
+
+if {[is_enabled multicommit]} {
+ .mbar.repository add command -label {Database Statistics} \
+ -command do_stats \
+ -font font_ui
+
+ .mbar.repository add command -label {Compress Database} \
+ -command do_gc \
+ -font font_ui
+
+ .mbar.repository add command -label {Verify Database} \
+ -command do_fsck_objects \
+ -font font_ui
+
+ .mbar.repository add separator
+
+ if {[is_Cygwin]} {
+ .mbar.repository add command \
+ -label {Create Desktop Icon} \
+ -command do_cygwin_shortcut \
+ -font font_ui
+ } elseif {[is_Windows]} {
+ .mbar.repository add command \
+ -label {Create Desktop Icon} \
+ -command do_windows_shortcut \
+ -font font_ui
+ } elseif {[is_MacOSX]} {
+ .mbar.repository add command \
+ -label {Create Desktop Icon} \
+ -command do_macosx_app \
+ -font font_ui
+ }
+}
+
+.mbar.repository add command -label Quit \
+ -command do_quit \
+ -accelerator $M1T-Q \
+ -font font_ui
+
+# -- Edit Menu
+#
+menu .mbar.edit
+.mbar.edit add command -label Undo \
+ -command {catch {[focus] edit undo}} \
+ -accelerator $M1T-Z \
+ -font font_ui
+.mbar.edit add command -label Redo \
+ -command {catch {[focus] edit redo}} \
+ -accelerator $M1T-Y \
+ -font font_ui
+.mbar.edit add separator
+.mbar.edit add command -label Cut \
+ -command {catch {tk_textCut [focus]}} \
+ -accelerator $M1T-X \
+ -font font_ui
+.mbar.edit add command -label Copy \
+ -command {catch {tk_textCopy [focus]}} \
+ -accelerator $M1T-C \
+ -font font_ui
+.mbar.edit add command -label Paste \
+ -command {catch {tk_textPaste [focus]; [focus] see insert}} \
+ -accelerator $M1T-V \
+ -font font_ui
+.mbar.edit add command -label Delete \
+ -command {catch {[focus] delete sel.first sel.last}} \
+ -accelerator Del \
+ -font font_ui
+.mbar.edit add separator
+.mbar.edit add command -label {Select All} \
+ -command {catch {[focus] tag add sel 0.0 end}} \
+ -accelerator $M1T-A \
+ -font font_ui
+
+# -- Branch Menu
+#
+if {[is_enabled branch]} {
+ menu .mbar.branch
+
+ .mbar.branch add command -label {Create...} \
+ -command do_create_branch \
+ -accelerator $M1T-N \
+ -font font_ui
+ lappend disable_on_lock [list .mbar.branch entryconf \
+ [.mbar.branch index last] -state]
+
+ .mbar.branch add command -label {Delete...} \
+ -command do_delete_branch \
+ -font font_ui
+ lappend disable_on_lock [list .mbar.branch entryconf \
+ [.mbar.branch index last] -state]
+}
+
+# -- Commit Menu
+#
+if {[is_enabled multicommit] || [is_enabled singlecommit]} {
+ menu .mbar.commit
+
+ .mbar.commit add radiobutton \
+ -label {New Commit} \
+ -command do_select_commit_type \
+ -variable selected_commit_type \
+ -value new \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add radiobutton \
+ -label {Amend Last Commit} \
+ -command do_select_commit_type \
+ -variable selected_commit_type \
+ -value amend \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add separator
+
+ .mbar.commit add command -label Rescan \
+ -command do_rescan \
+ -accelerator F5 \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add command -label {Add To Commit} \
+ -command do_add_selection \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add command -label {Add Existing To Commit} \
+ -command do_add_all \
+ -accelerator $M1T-I \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add command -label {Unstage From Commit} \
+ -command do_unstage_selection \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add command -label {Revert Changes} \
+ -command do_revert_selection \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+
+ .mbar.commit add separator
+
+ .mbar.commit add command -label {Sign Off} \
+ -command do_signoff \
+ -accelerator $M1T-S \
+ -font font_ui
+
+ .mbar.commit add command -label Commit \
+ -command do_commit \
+ -accelerator $M1T-Return \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
+}
+
+if {[is_MacOSX]} {
+ # -- Apple Menu (Mac OS X only)
+ #
+ .mbar add cascade -label Apple -menu .mbar.apple
+ menu .mbar.apple
+
+ .mbar.apple add command -label "About [appname]" \
+ -command do_about \
+ -font font_ui
+ .mbar.apple add command -label "[appname] Options..." \
+ -command do_options \
+ -font font_ui
+} else {
+ # -- Edit Menu
+ #
+ .mbar.edit add separator
+ .mbar.edit add command -label {Options...} \
+ -command do_options \
+ -font font_ui
+
+ # -- Tools Menu
+ #
+ if {[file exists /usr/local/miga/lib/gui-miga]
+ && [file exists .pvcsrc]} {
+ proc do_miga {} {
+ global ui_status_value
+ if {![lock_index update]} return
+ set cmd [list sh --login -c "/usr/local/miga/lib/gui-miga \"[pwd]\""]
+ set miga_fd [open "|$cmd" r]
+ fconfigure $miga_fd -blocking 0
+ fileevent $miga_fd readable [list miga_done $miga_fd]
+ set ui_status_value {Running miga...}
+ }
+ proc miga_done {fd} {
+ read $fd 512
+ if {[eof $fd]} {
+ close $fd
+ unlock_index
+ rescan [list set ui_status_value {Ready.}]
+ }
+ }
+ .mbar add cascade -label Tools -menu .mbar.tools
+ menu .mbar.tools
+ .mbar.tools add command -label "Migrate" \
+ -command do_miga \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.tools entryconf [.mbar.tools index last] -state]
+ }
+}
+
+# -- Help Menu
+#
+.mbar add cascade -label Help -menu .mbar.help
+menu .mbar.help
+
+if {![is_MacOSX]} {
+ .mbar.help add command -label "About [appname]" \
+ -command do_about \
+ -font font_ui
+}
+
+set browser {}
+catch {set browser $repo_config(instaweb.browser)}
+set doc_path [file dirname [gitexec]]
+set doc_path [file join $doc_path Documentation index.html]
+
+if {[is_Cygwin]} {
+ set doc_path [exec cygpath --windows $doc_path]
+}
+
+if {$browser eq {}} {
+ if {[is_MacOSX]} {
+ set browser open
+ } elseif {[is_Cygwin]} {
+ set program_files [file dirname [exec cygpath --windir]]
+ set program_files [file join $program_files {Program Files}]
+ set firefox [file join $program_files {Mozilla Firefox} firefox.exe]
+ set ie [file join $program_files {Internet Explorer} IEXPLORE.EXE]
+ if {[file exists $firefox]} {
+ set browser $firefox
+ } elseif {[file exists $ie]} {
+ set browser $ie
+ }
+ unset program_files firefox ie
+ }
+}
+
+if {[file isfile $doc_path]} {
+ set doc_url "file:$doc_path"
+} else {
+ set doc_url {http://www.kernel.org/pub/software/scm/git/docs/}
+}
+
+if {$browser ne {}} {
+ .mbar.help add command -label {Online Documentation} \
+ -command [list exec $browser $doc_url &] \
+ -font font_ui
+}
+unset browser doc_path doc_url
+
+# -- Standard bindings
+#
+bind . <Destroy> do_quit
+bind all <$M1B-Key-q> do_quit
+bind all <$M1B-Key-Q> do_quit
+bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
+bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
+
+# -- Not a normal commit type invocation? Do that instead!
+#
+switch -- $subcommand {
+blame {
+ if {[llength $argv] != 2} {
+ puts stderr "usage: $argv0 blame commit path"
+ exit 1
+ }
+ set current_branch [lindex $argv 0]
+ show_blame $current_branch [lindex $argv 1]
+ return
+}
+citool -
+gui {
+ if {[llength $argv] != 0} {
+ puts -nonewline stderr "usage: $argv0"
+ if {$subcommand ne {gui} && [appname] ne "git-$subcommand"} {
+ puts -nonewline stderr " $subcommand"
+ }
+ puts stderr {}
+ exit 1
+ }
+ # fall through to setup UI for commits
+}
+default {
+ puts stderr "usage: $argv0 \[{blame|citool}\]"
+ exit 1
+}
+}
+
+# -- Branch Control
+#
+frame .branch \
+ -borderwidth 1 \
+ -relief sunken
+label .branch.l1 \
+ -text {Current Branch:} \
+ -anchor w \
+ -justify left \
+ -font font_ui
+label .branch.cb \
+ -textvariable current_branch \
+ -anchor w \
+ -justify left \
+ -font font_ui
+pack .branch.l1 -side left
+pack .branch.cb -side left -fill x
+pack .branch -side top -fill x
+
+if {[is_enabled branch]} {
+ menu .mbar.merge
+ .mbar.merge add command -label {Local Merge...} \
+ -command do_local_merge \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.merge entryconf [.mbar.merge index last] -state]
+ .mbar.merge add command -label {Abort Merge...} \
+ -command do_reset_hard \
+ -font font_ui
+ lappend disable_on_lock \
+ [list .mbar.merge entryconf [.mbar.merge index last] -state]
+
+
+ menu .mbar.fetch
+
+ menu .mbar.push
+ .mbar.push add command -label {Push...} \
+ -command do_push_anywhere \
+ -font font_ui
+}
+
+# -- Main Window Layout
+#
+panedwindow .vpane -orient vertical
+panedwindow .vpane.files -orient horizontal
+.vpane add .vpane.files -sticky nsew -height 100 -width 200
+pack .vpane -anchor n -side top -fill both -expand 1
+
+# -- Index File List
+#
+frame .vpane.files.index -height 100 -width 200
+label .vpane.files.index.title -text {Changes To Be Committed} \
+ -background green \
+ -font font_ui
+text $ui_index -background white -borderwidth 0 \
+ -width 20 -height 10 \
+ -wrap none \
+ -font font_ui \
+ -cursor $cursor_ptr \
+ -xscrollcommand {.vpane.files.index.sx set} \
+ -yscrollcommand {.vpane.files.index.sy set} \
+ -state disabled
+scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview]
+scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview]
+pack .vpane.files.index.title -side top -fill x
+pack .vpane.files.index.sx -side bottom -fill x
+pack .vpane.files.index.sy -side right -fill y
+pack $ui_index -side left -fill both -expand 1
+.vpane.files add .vpane.files.index -sticky nsew
+
+# -- Working Directory File List
+#
+frame .vpane.files.workdir -height 100 -width 200
+label .vpane.files.workdir.title -text {Changed But Not Updated} \
+ -background red \
+ -font font_ui
+text $ui_workdir -background white -borderwidth 0 \
+ -width 20 -height 10 \
+ -wrap none \
+ -font font_ui \
+ -cursor $cursor_ptr \
+ -xscrollcommand {.vpane.files.workdir.sx set} \
+ -yscrollcommand {.vpane.files.workdir.sy set} \
+ -state disabled
+scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
+scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
+pack .vpane.files.workdir.title -side top -fill x
+pack .vpane.files.workdir.sx -side bottom -fill x
+pack .vpane.files.workdir.sy -side right -fill y
+pack $ui_workdir -side left -fill both -expand 1
+.vpane.files add .vpane.files.workdir -sticky nsew
+
+foreach i [list $ui_index $ui_workdir] {
+ $i tag conf in_diff -font font_uibold
+ $i tag conf in_sel \
+ -background [$i cget -foreground] \
+ -foreground [$i cget -background]
+}
+unset i
+
+# -- Diff and Commit Area
+#
+frame .vpane.lower -height 300 -width 400
+frame .vpane.lower.commarea
+frame .vpane.lower.diff -relief sunken -borderwidth 1
+pack .vpane.lower.commarea -side top -fill x
+pack .vpane.lower.diff -side bottom -fill both -expand 1
+.vpane add .vpane.lower -sticky nsew
+
+# -- Commit Area Buttons
+#
+frame .vpane.lower.commarea.buttons
+label .vpane.lower.commarea.buttons.l -text {} \
+ -anchor w \
+ -justify left \
+ -font font_ui
+pack .vpane.lower.commarea.buttons.l -side top -fill x
+pack .vpane.lower.commarea.buttons -side left -fill y
+
+button .vpane.lower.commarea.buttons.rescan -text {Rescan} \
+ -command do_rescan \
+ -font font_ui
+pack .vpane.lower.commarea.buttons.rescan -side top -fill x
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.rescan conf -state}
+
+button .vpane.lower.commarea.buttons.incall -text {Add Existing} \
+ -command do_add_all \
+ -font font_ui
+pack .vpane.lower.commarea.buttons.incall -side top -fill x
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.incall conf -state}
+
+button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
+ -command do_signoff \
+ -font font_ui
+pack .vpane.lower.commarea.buttons.signoff -side top -fill x
+
+button .vpane.lower.commarea.buttons.commit -text {Commit} \
+ -command do_commit \
+ -font font_ui
+pack .vpane.lower.commarea.buttons.commit -side top -fill x
+lappend disable_on_lock \
+ {.vpane.lower.commarea.buttons.commit conf -state}
+
+# -- Commit Message Buffer
+#
+frame .vpane.lower.commarea.buffer
+frame .vpane.lower.commarea.buffer.header
+set ui_comm .vpane.lower.commarea.buffer.t
+set ui_coml .vpane.lower.commarea.buffer.header.l
+radiobutton .vpane.lower.commarea.buffer.header.new \
+ -text {New Commit} \
+ -command do_select_commit_type \
+ -variable selected_commit_type \
+ -value new \
+ -font font_ui
+lappend disable_on_lock \
+ [list .vpane.lower.commarea.buffer.header.new conf -state]
+radiobutton .vpane.lower.commarea.buffer.header.amend \
+ -text {Amend Last Commit} \
+ -command do_select_commit_type \
+ -variable selected_commit_type \
+ -value amend \
+ -font font_ui
+lappend disable_on_lock \
+ [list .vpane.lower.commarea.buffer.header.amend conf -state]
+label $ui_coml \
+ -anchor w \
+ -justify left \
+ -font font_ui
+proc trace_commit_type {varname args} {
+ global ui_coml commit_type
+ switch -glob -- $commit_type {
+ initial {set txt {Initial Commit Message:}}
+ amend {set txt {Amended Commit Message:}}
+ amend-initial {set txt {Amended Initial Commit Message:}}
+ amend-merge {set txt {Amended Merge Commit Message:}}
+ merge {set txt {Merge Commit Message:}}
+ * {set txt {Commit Message:}}
+ }
+ $ui_coml conf -text $txt
+}
+trace add variable commit_type write trace_commit_type
+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 \
+ -undo true \
+ -maxundo 20 \
+ -autoseparators true \
+ -relief sunken \
+ -width 75 -height 9 -wrap none \
+ -font font_diff \
+ -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
+scrollbar .vpane.lower.commarea.buffer.sby \
+ -command [list $ui_comm yview]
+pack .vpane.lower.commarea.buffer.header -side top -fill x
+pack .vpane.lower.commarea.buffer.sby -side right -fill y
+pack $ui_comm -side left -fill y
+pack .vpane.lower.commarea.buffer -side left -fill y
+
+# -- Commit Message Buffer Context Menu
+#
+set ctxm .vpane.lower.commarea.buffer.ctxm
+menu $ctxm -tearoff 0
+$ctxm add command \
+ -label {Cut} \
+ -font font_ui \
+ -command {tk_textCut $ui_comm}
+$ctxm add command \
+ -label {Copy} \
+ -font font_ui \
+ -command {tk_textCopy $ui_comm}
+$ctxm add command \
+ -label {Paste} \
+ -font font_ui \
+ -command {tk_textPaste $ui_comm}
+$ctxm add command \
+ -label {Delete} \
+ -font font_ui \
+ -command {$ui_comm delete sel.first sel.last}
+$ctxm add separator
+$ctxm add command \
+ -label {Select All} \
+ -font font_ui \
+ -command {focus $ui_comm;$ui_comm tag add sel 0.0 end}
+$ctxm add command \
+ -label {Copy All} \
+ -font font_ui \
+ -command {
+ $ui_comm tag add sel 0.0 end
+ tk_textCopy $ui_comm
+ $ui_comm tag remove sel 0.0 end
+ }
+$ctxm add separator
+$ctxm add command \
+ -label {Sign Off} \
+ -font font_ui \
+ -command do_signoff
+bind_button3 $ui_comm "tk_popup $ctxm %X %Y"
+
+# -- Diff Header
+#
+set current_diff_path {}
+set current_diff_side {}
+set diff_actions [list]
+proc trace_current_diff_path {varname args} {
+ global current_diff_path diff_actions file_states
+ if {$current_diff_path eq {}} {
+ set s {}
+ set f {}
+ set p {}
+ set o disabled
+ } else {
+ set p $current_diff_path
+ set s [mapdesc [lindex $file_states($p) 0] $p]
+ set f {File:}
+ set p [escape_path $p]
+ set o normal
+ }
+
+ .vpane.lower.diff.header.status configure -text $s
+ .vpane.lower.diff.header.file configure -text $f
+ .vpane.lower.diff.header.path configure -text $p
+ foreach w $diff_actions {
+ uplevel #0 $w $o
+ }
+}
+trace add variable current_diff_path write trace_current_diff_path
+
+frame .vpane.lower.diff.header -background orange
+label .vpane.lower.diff.header.status \
+ -background orange \
+ -width $max_status_desc \
+ -anchor w \
+ -justify left \
+ -font font_ui
+label .vpane.lower.diff.header.file \
+ -background orange \
+ -anchor w \
+ -justify left \
+ -font font_ui
+label .vpane.lower.diff.header.path \
+ -background orange \
+ -anchor w \
+ -justify left \
+ -font font_ui
+pack .vpane.lower.diff.header.status -side left
+pack .vpane.lower.diff.header.file -side left
+pack .vpane.lower.diff.header.path -fill x
+set ctxm .vpane.lower.diff.header.ctxm
+menu $ctxm -tearoff 0
+$ctxm add command \
+ -label {Copy} \
+ -font font_ui \
+ -command {
+ clipboard clear
+ clipboard append \
+ -format STRING \
+ -type STRING \
+ -- $current_diff_path
+ }
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
+
+# -- Diff Body
+#
+frame .vpane.lower.diff.body
+set ui_diff .vpane.lower.diff.body.t
+text $ui_diff -background white -borderwidth 0 \
+ -width 80 -height 15 -wrap none \
+ -font font_diff \
+ -xscrollcommand {.vpane.lower.diff.body.sbx set} \
+ -yscrollcommand {.vpane.lower.diff.body.sby set} \
+ -state disabled
+scrollbar .vpane.lower.diff.body.sbx -orient horizontal \
+ -command [list $ui_diff xview]
+scrollbar .vpane.lower.diff.body.sby -orient vertical \
+ -command [list $ui_diff yview]
+pack .vpane.lower.diff.body.sbx -side bottom -fill x
+pack .vpane.lower.diff.body.sby -side right -fill y
+pack $ui_diff -side left -fill both -expand 1
+pack .vpane.lower.diff.header -side top -fill x
+pack .vpane.lower.diff.body -side bottom -fill both -expand 1
+
+$ui_diff tag conf d_cr -elide true
+$ui_diff tag conf d_@ -foreground blue -font font_diffbold
+$ui_diff tag conf d_+ -foreground {#00a000}
+$ui_diff tag conf d_- -foreground red
+
+$ui_diff tag conf d_++ -foreground {#00a000}
+$ui_diff tag conf d_-- -foreground red
+$ui_diff tag conf d_+s \
+ -foreground {#00a000} \
+ -background {#e2effa}
+$ui_diff tag conf d_-s \
+ -foreground red \
+ -background {#e2effa}
+$ui_diff tag conf d_s+ \
+ -foreground {#00a000} \
+ -background ivory1
+$ui_diff tag conf d_s- \
+ -foreground red \
+ -background ivory1
+
+$ui_diff tag conf d<<<<<<< \
+ -foreground orange \
+ -font font_diffbold
+$ui_diff tag conf d======= \
+ -foreground orange \
+ -font font_diffbold
+$ui_diff tag conf d>>>>>>> \
+ -foreground orange \
+ -font font_diffbold
+
+$ui_diff tag raise sel
+
+# -- Diff Body Context Menu
+#
+set ctxm .vpane.lower.diff.body.ctxm
+menu $ctxm -tearoff 0
+$ctxm add command \
+ -label {Refresh} \
+ -font font_ui \
+ -command reshow_diff
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+ -label {Copy} \
+ -font font_ui \
+ -command {tk_textCopy $ui_diff}
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+ -label {Select All} \
+ -font font_ui \
+ -command {focus $ui_diff;$ui_diff tag add sel 0.0 end}
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+ -label {Copy All} \
+ -font font_ui \
+ -command {
+ $ui_diff tag add sel 0.0 end
+ tk_textCopy $ui_diff
+ $ui_diff tag remove sel 0.0 end
+ }
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add separator
+$ctxm add command \
+ -label {Apply/Reverse Hunk} \
+ -font font_ui \
+ -command {apply_hunk $cursorX $cursorY}
+set ui_diff_applyhunk [$ctxm index last]
+lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
+$ctxm add separator
+$ctxm add command \
+ -label {Decrease Font Size} \
+ -font font_ui \
+ -command {incr_font_size font_diff -1}
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+ -label {Increase Font Size} \
+ -font font_ui \
+ -command {incr_font_size font_diff 1}
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add separator
+$ctxm add command \
+ -label {Show Less Context} \
+ -font font_ui \
+ -command {if {$repo_config(gui.diffcontext) >= 2} {
+ incr repo_config(gui.diffcontext) -1
+ reshow_diff
+ }}
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add command \
+ -label {Show More Context} \
+ -font font_ui \
+ -command {
+ incr repo_config(gui.diffcontext)
+ reshow_diff
+ }
+lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
+$ctxm add separator
+$ctxm add command -label {Options...} \
+ -font font_ui \
+ -command do_options
+bind_button3 $ui_diff "
+ set cursorX %x
+ set cursorY %y
+ if {\$ui_index eq \$current_diff_side} {
+ $ctxm entryconf $ui_diff_applyhunk -label {Unstage Hunk From Commit}
+ } else {
+ $ctxm entryconf $ui_diff_applyhunk -label {Stage Hunk For Commit}
+ }
+ tk_popup $ctxm %X %Y
+"
+unset ui_diff_applyhunk
+
+# -- Status Bar
+#
+set ui_status_value {Initializing...}
+label .status -textvariable ui_status_value \
+ -anchor w \
+ -justify left \
+ -borderwidth 1 \
+ -relief sunken \
+ -font font_ui
+pack .status -anchor w -side bottom -fill x
+
+# -- Load geometry
+#
+catch {
+set gm $repo_config(gui.geometry)
+wm geometry . [lindex $gm 0]
+.vpane sash place 0 \
+ [lindex [.vpane sash coord 0] 0] \
+ [lindex $gm 1]
+.vpane.files sash place 0 \
+ [lindex $gm 2] \
+ [lindex [.vpane.files sash coord 0] 1]
+unset gm
+}
+
+# -- Key Bindings
+#
+bind $ui_comm <$M1B-Key-Return> {do_commit;break}
+bind $ui_comm <$M1B-Key-i> {do_add_all;break}
+bind $ui_comm <$M1B-Key-I> {do_add_all;break}
+bind $ui_comm <$M1B-Key-x> {tk_textCut %W;break}
+bind $ui_comm <$M1B-Key-X> {tk_textCut %W;break}
+bind $ui_comm <$M1B-Key-c> {tk_textCopy %W;break}
+bind $ui_comm <$M1B-Key-C> {tk_textCopy %W;break}
+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_diff <$M1B-Key-x> {tk_textCopy %W;break}
+bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}
+bind $ui_diff <$M1B-Key-c> {tk_textCopy %W;break}
+bind $ui_diff <$M1B-Key-C> {tk_textCopy %W;break}
+bind $ui_diff <$M1B-Key-v> {break}
+bind $ui_diff <$M1B-Key-V> {break}
+bind $ui_diff <$M1B-Key-a> {%W tag add sel 0.0 end;break}
+bind $ui_diff <$M1B-Key-A> {%W tag add sel 0.0 end;break}
+bind $ui_diff <Key-Up> {catch {%W yview scroll -1 units};break}
+bind $ui_diff <Key-Down> {catch {%W yview scroll 1 units};break}
+bind $ui_diff <Key-Left> {catch {%W xview scroll -1 units};break}
+bind $ui_diff <Key-Right> {catch {%W xview scroll 1 units};break}
+bind $ui_diff <Button-1> {focus %W}
+
+if {[is_enabled branch]} {
+ bind . <$M1B-Key-n> do_create_branch
+ bind . <$M1B-Key-N> do_create_branch
+}
+
+bind all <Key-F5> do_rescan
+bind all <$M1B-Key-r> do_rescan
+bind all <$M1B-Key-R> do_rescan
+bind . <$M1B-Key-s> do_signoff
+bind . <$M1B-Key-S> do_signoff
+bind . <$M1B-Key-i> do_add_all
+bind . <$M1B-Key-I> do_add_all
+bind . <$M1B-Key-Return> do_commit
+foreach i [list $ui_index $ui_workdir] {
+ bind $i <Button-1> "toggle_or_diff $i %x %y; break"
+ bind $i <$M1B-Button-1> "add_one_to_selection $i %x %y; break"
+ bind $i <Shift-Button-1> "add_range_to_selection $i %x %y; break"
+}
+unset i
+
+set file_lists($ui_index) [list]
+set file_lists($ui_workdir) [list]
+
+set HEAD {}
+set PARENT {}
+set MERGE_HEAD [list]
+set commit_type {}
+set empty_tree {}
+set current_branch {}
+set current_diff_path {}
+set selected_commit_type new
+
+wm title . "[appname] ([file normalize [file dirname [gitdir]]])"
+focus -force $ui_comm
+
+# -- Warn the user about environmental problems. Cygwin's Tcl
+# does *not* pass its env array onto any processes it spawns.
+# This means that git processes get none of our environment.
+#
+if {[is_Cygwin]} {
+ set ignored_env 0
+ set suggest_user {}
+ set msg "Possible environment issues exist.
+
+The following environment variables are probably
+going to be ignored by any Git subprocess run
+by [appname]:
+
+"
+ foreach name [array names env] {
+ switch -regexp -- $name {
+ {^GIT_INDEX_FILE$} -
+ {^GIT_OBJECT_DIRECTORY$} -
+ {^GIT_ALTERNATE_OBJECT_DIRECTORIES$} -
+ {^GIT_DIFF_OPTS$} -
+ {^GIT_EXTERNAL_DIFF$} -
+ {^GIT_PAGER$} -
+ {^GIT_TRACE$} -
+ {^GIT_CONFIG$} -
+ {^GIT_CONFIG_LOCAL$} -
+ {^GIT_(AUTHOR|COMMITTER)_DATE$} {
+ append msg " - $name\n"
+ incr ignored_env
+ }
+ {^GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL)$} {
+ append msg " - $name\n"
+ incr ignored_env
+ set suggest_user $name
+ }
+ }
+ }
+ if {$ignored_env > 0} {
+ append msg "
+This is due to a known issue with the
+Tcl binary distributed by Cygwin."
+
+ if {$suggest_user ne {}} {
+ append msg "
+
+A good replacement for $suggest_user
+is placing values for the user.name and
+user.email settings into your personal
+~/.gitconfig file.
+"
+ }
+ warn_popup $msg
+ }
+ unset ignored_env msg suggest_user name
+}
+
+# -- Only initialize complex UI if we are going to stay running.
+#
+if {[is_enabled transport]} {
+ load_all_remotes
+ load_all_heads
+
+ populate_branch_menu
+ populate_fetch_menu
+ populate_push_menu
+}
+
+# -- Only suggest a gc run if we are going to stay running.
+#
+if {[is_enabled multicommit]} {
+ set object_limit 2000
+ if {[is_Windows]} {set object_limit 200}
+ regexp {^([0-9]+) objects,} [exec git count-objects] _junk objects_current
+ if {$objects_current >= $object_limit} {
+ if {[ask_popup \
+ "This repository currently has $objects_current loose objects.
+
+To maintain optimal performance it is strongly
+recommended that you compress the database
+when more than $object_limit loose objects exist.
+
+Compress the database now?"] eq yes} {
+ do_gc
+ }
+ }
+ unset object_limit _junk objects_current
+}
+
+lock_index begin-read
+after 1 do_rescan
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 80adc8307b..cbc7418e35 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -15,11 +15,11 @@ case "$GIT_DIR" in
fqgitdir="$PWD/$GIT_DIR" ;;
esac
-local="`git repo-config --bool --get instaweb.local`"
-httpd="`git repo-config --get instaweb.httpd`"
-browser="`git repo-config --get instaweb.browser`"
-port=`git repo-config --get instaweb.port`
-module_path="`git repo-config --get instaweb.modulepath`"
+local="`git config --bool --get instaweb.local`"
+httpd="`git config --get instaweb.httpd`"
+browser="`git config --get instaweb.browser`"
+port=`git config --get instaweb.port`
+module_path="`git config --get instaweb.modulepath`"
conf=$GIT_DIR/gitweb/httpd.conf
diff --git a/git-lost-found.sh b/git-lost-found.sh
index b928f2ca52..9360804711 100755
--- a/git-lost-found.sh
+++ b/git-lost-found.sh
@@ -12,7 +12,7 @@ fi
laf="$GIT_DIR/lost-found"
rm -fr "$laf" && mkdir -p "$laf/commit" "$laf/other" || exit
-git fsck-objects --full |
+git fsck --full |
while read dangling type sha1
do
case "$dangling" in
diff --git a/git-ls-remote.sh b/git-ls-remote.sh
index 03b624ef33..8ea5c5e816 100755
--- a/git-ls-remote.sh
+++ b/git-ls-remote.sh
@@ -23,7 +23,11 @@ do
-u|--u|--up|--upl|--uploa|--upload|--upload-|--upload-p|--upload-pa|\
--upload-pac|--upload-pack)
shift
- exec="--exec=$1"
+ exec="--upload-pack=$1"
+ shift;;
+ -u=*|--u=*|--up=*|--upl=*|--uplo=*|--uploa=*|--upload=*|\
+ --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
+ exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
shift;;
--)
shift; break ;;
@@ -54,7 +58,7 @@ http://* | https://* | ftp://* )
curl_extra_args="-k"
fi
if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
- "`git-repo-config --bool http.noEPSV`" = true ]; then
+ "`git-config --bool http.noEPSV`" = true ]; then
curl_extra_args="${curl_extra_args} --disable-epsv"
fi
curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||
diff --git a/git-merge-resolve.sh b/git-merge-resolve.sh
index 0a8ef216cb..75e1de49ac 100755
--- a/git-merge-resolve.sh
+++ b/git-merge-resolve.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Linus Torvalds
# Copyright (c) 2005 Junio C Hamano
#
-# Resolve two trees, using enhancd multi-base read-tree.
+# Resolve two trees, using enhanced multi-base read-tree.
# The first parameters up to -- are merge bases; the rest are heads.
bases= head= remotes= sep_seen=
diff --git a/git-merge.sh b/git-merge.sh
index 477002910e..04a5eb0f29 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -5,11 +5,13 @@
USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commit>+'
+SUBDIRECTORY_OK=Yes
. git-sh-setup
-set_reflog_action "merge $*"
+require_work_tree
+cd_to_toplevel
test -z "$(git ls-files -u)" ||
- die "You are in a middle of conflicted merge."
+ die "You are in the middle of a conflicted merge."
LF='
'
@@ -214,6 +216,7 @@ head=$(git-rev-parse --verify "$head_arg"^0) || usage
# All the rest are remote heads
test "$#" = 0 && usage ;# we need at least one remote head.
+set_reflog_action "merge $*"
remoteheads=
for remote
@@ -230,7 +233,7 @@ case "$use_strategies" in
'')
case "$#" in
1)
- var="`git-repo-config --get pull.twohead`"
+ var="`git-config --get pull.twohead`"
if test -n "$var"
then
use_strategies="$var"
@@ -238,7 +241,7 @@ case "$use_strategies" in
use_strategies="$default_twohead_strategies"
fi ;;
*)
- var="`git-repo-config --get pull.octopus`"
+ var="`git-config --get pull.octopus`"
if test -n "$var"
then
use_strategies="$var"
@@ -298,24 +301,30 @@ f,*)
;;
?,1,*,)
# We are not doing octopus, not fast forward, and have only
- # one common. See if it is really trivial.
- git var GIT_COMMITTER_IDENT >/dev/null || exit
-
- echo "Trying really trivial in-index merge..."
+ # one common.
git-update-index --refresh 2>/dev/null
- if git-read-tree --trivial -m -u -v $common $head "$1" &&
- result_tree=$(git-write-tree)
- then
- echo "Wonderful."
- result_commit=$(
- echo "$merge_msg" |
- git-commit-tree $result_tree -p HEAD -p "$1"
- ) || exit
- finish "$result_commit" "In-index merge"
- dropsave
- exit 0
- fi
- echo "Nope."
+ case " $use_strategies " in
+ *' recursive '*|*' recur '*)
+ : run merge later
+ ;;
+ *)
+ # See if it is really trivial.
+ git var GIT_COMMITTER_IDENT >/dev/null || exit
+ echo "Trying really trivial in-index merge..."
+ if git-read-tree --trivial -m -u -v $common $head "$1" &&
+ result_tree=$(git-write-tree)
+ then
+ echo "Wonderful."
+ result_commit=$(
+ echo "$merge_msg" |
+ git-commit-tree $result_tree -p HEAD -p "$1"
+ ) || exit
+ finish "$result_commit" "In-index merge"
+ dropsave
+ exit 0
+ fi
+ echo "Nope."
+ esac
;;
*)
# An octopus. If we can reach all the remote we are up to date.
diff --git a/git-p4import.py b/git-p4import.py
index 908941dd77..60a758bfe3 100644
--- a/git-p4import.py
+++ b/git-p4import.py
@@ -163,7 +163,7 @@ class git_command:
self.gitdir = self.get_single("rev-parse --git-dir")
report(2, "gdir:", self.gitdir)
except:
- die("Not a git repository... did you forget to \"git init-db\" ?")
+ die("Not a git repository... did you forget to \"git init\" ?")
try:
self.cdup = self.get_single("rev-parse --show-cdup")
if self.cdup != "":
@@ -193,13 +193,13 @@ class git_command:
def get_config(self, variable):
try:
- return self.git("repo-config --get %s" % variable)[0].rstrip()
+ return self.git("config --get %s" % variable)[0].rstrip()
except:
return None
def set_config(self, variable, value):
try:
- self.git("repo-config %s %s"%(variable, value) )
+ self.git("config %s %s"%(variable, value) )
except:
die("Could not set %s to " % variable, value)
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index d2e4c2b9ae..5208ee6ce0 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -10,7 +10,7 @@ get_data_source () {
echo ''
;;
*)
- if test "$(git-repo-config --get "remote.$1.url")"
+ if test "$(git-config --get "remote.$1.url")"
then
echo config
elif test -f "$GIT_DIR/remotes/$1"
@@ -32,7 +32,7 @@ get_remote_url () {
echo "$1"
;;
config)
- git-repo-config --get "remote.$1.url"
+ git-config --get "remote.$1.url"
;;
remotes)
sed -ne '/^URL: */{
@@ -49,8 +49,8 @@ get_remote_url () {
}
get_default_remote () {
- curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
- origin=$(git-repo-config --get "branch.$curr_branch.remote")
+ curr_branch=$(git-symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
+ origin=$(git-config --get "branch.$curr_branch.remote")
echo ${origin:-origin}
}
@@ -60,7 +60,7 @@ get_remote_default_refs_for_push () {
'' | branches)
;; # no default push mapping, just send matching refs.
config)
- git-repo-config --get-all "remote.$1.push" ;;
+ git-config --get-all "remote.$1.push" ;;
remotes)
sed -ne '/^Push: */{
s///p
@@ -81,7 +81,14 @@ get_remote_default_refs_for_push () {
# is to help prevent randomly "globbed" ref from being chosen as
# a merge candidate
expand_refs_wildcard () {
+ remote="$1"
+ shift
first_one=yes
+ if test "$#" = 0
+ then
+ echo empty
+ echo >&2 "Nothing specified for fetching with remote.$remote.fetch"
+ fi
for ref
do
lref=${ref#'+'}
@@ -132,14 +139,14 @@ canon_refs_list_for_fetch () {
if test "$1" = "-d"
then
shift ; remote="$1" ; shift
- set $(expand_refs_wildcard "$@")
+ set $(expand_refs_wildcard "$remote" "$@")
is_explicit="$1"
shift
if test "$remote" = "$(get_default_remote)"
then
- curr_branch=$(git-symbolic-ref HEAD | \
+ curr_branch=$(git-symbolic-ref -q HEAD | \
sed -e 's|^refs/heads/||')
- merge_branches=$(git-repo-config \
+ merge_branches=$(git-config \
--get-all "branch.${curr_branch}.merge")
fi
if test -z "$merge_branches" && test $is_explicit != explicit
@@ -167,16 +174,12 @@ canon_refs_list_for_fetch () {
else
for merge_branch in $merge_branches
do
- if test "$remote" = "$merge_branch" ||
- test "$local" = "$merge_branch"
- then
- dot_prefix=
- break
- fi
+ [ "$remote" = "$merge_branch" ] &&
+ dot_prefix= && break
done
fi
case "$remote" in
- '') remote=HEAD ;;
+ '' | HEAD ) remote=HEAD ;;
refs/heads/* | refs/tags/* | refs/remotes/*) ;;
heads/* | tags/* | remotes/* ) remote="refs/$remote" ;;
*) remote="refs/heads/$remote" ;;
@@ -205,7 +208,7 @@ get_remote_default_refs_for_fetch () {
echo "HEAD:" ;;
config)
canon_refs_list_for_fetch -d "$1" \
- $(git-repo-config --get-all "remote.$1.fetch") ;;
+ $(git-config --get-all "remote.$1.fetch") ;;
branches)
remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
case "$remote_branch" in '') remote_branch=master ;; esac
@@ -279,3 +282,16 @@ resolve_alternates () {
esac
done
}
+
+get_uploadpack () {
+ data_source=$(get_data_source "$1")
+ case "$data_source" in
+ config)
+ uplp=$(git-config --get "remote.$1.uploadpack")
+ echo ${uplp:-git-upload-pack}
+ ;;
+ *)
+ echo "git-upload-pack"
+ ;;
+ esac
+}
diff --git a/git-pull.sh b/git-pull.sh
index c184fb81a4..a3665d7751 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -6,11 +6,14 @@
USAGE='[-n | --no-summary] [--no-commit] [-s strategy]... [<fetch-options>] <repo> <head>...'
LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.'
+SUBDIRECTORY_OK=Yes
. git-sh-setup
set_reflog_action "pull $*"
+require_work_tree
+cd_to_toplevel
test -z "$(git ls-files -u)" ||
- die "You are in a middle of conflicted merge."
+ die "You are in the middle of a conflicted merge."
strategy_args= no_summary= no_commit= squash=
while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
@@ -80,8 +83,17 @@ merge_head=$(sed -e '/ not-for-merge /d' \
case "$merge_head" in
'')
- curr_branch=$(git-symbolic-ref HEAD | \
- sed -e 's|^refs/heads/||')
+ curr_branch=$(git-symbolic-ref -q HEAD)
+ case $? in
+ 0) ;;
+ 1) echo >&2 "You are not currently on a branch; you must explicitly"
+ echo >&2 "specify which branch you wish to merge:"
+ echo >&2 " git pull <remote> <branch>"
+ exit 1;;
+ *) exit $?;;
+ esac
+ curr_branch=${curr_branch#refs/heads/}
+
echo >&2 "Warning: No merge candidate found because value of config option
\"branch.${curr_branch}.merge\" does not match any remote branch fetched."
echo >&2 "No changes."
diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 10135da3ac..671a5ff865 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -59,7 +59,7 @@ if ! [ -d "$QUILT_PATCHES" ] ; then
exit 1
fi
-# Temporay directories
+# Temporary directories
tmp_dir=.dotest
tmp_msg="$tmp_dir/msg"
tmp_patch="$tmp_dir/patch"
@@ -89,7 +89,7 @@ for patch_name in $(cat "$QUILT_PATCHES/series" | grep -v '^#'); do
echo "No author found in $patch_name" >&2;
echo "---"
cat $tmp_msg
- echo -n "Author: ";
+ printf "Author: ";
read patch_author
echo "$patch_author"
diff --git a/git-rebase.sh b/git-rebase.sh
index 828c59ce61..b51d19d12e 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -27,8 +27,12 @@ Example: git-rebase master~1 topic
/ --> /
D---E---F---G master D---E---F---G master
'
+
+SUBDIRECTORY_OK=Yes
. git-sh-setup
set_reflog_action rebase
+require_work_tree
+cd_to_toplevel
RESOLVEMSG="
When you have resolved this problem run \"git rebase --continue\".
@@ -41,6 +45,7 @@ do_merge=
dotest=$GIT_DIR/.dotest-merge
prec=4
verbose=
+git_am_opt=
continue_merge () {
test -n "$prev_head" || die "prev_head must be defined"
@@ -209,6 +214,10 @@ do
-v|--verbose)
verbose=t
;;
+ -C*)
+ git_am_opt=$1
+ shift
+ ;;
-*)
usage
;;
@@ -245,7 +254,8 @@ fi
git-update-index --refresh || exit
diff=$(git-diff-index --cached --name-status -r HEAD)
case "$diff" in
-?*) echo "$diff"
+?*) echo "cannot rebase: your index is not up-to-date"
+ echo "$diff"
exit 1
;;
esac
@@ -271,8 +281,12 @@ case "$#" in
git-checkout "$2" || usage
;;
*)
- branch_name=`git symbolic-ref HEAD` || die "No current branch"
- branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
+ if branch_name=`git symbolic-ref -q HEAD`
+ then
+ branch_name=`expr "z$branch_name" : 'zrefs/heads/\(.*\)'`
+ else
+ branch_name=HEAD ;# detached
+ fi
;;
esac
branch=$(git-rev-parse --verify "${branch_name}^0") || exit
@@ -313,7 +327,7 @@ fi
if test -z "$do_merge"
then
git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
- git am --binary -3 -k --resolvemsg="$RESOLVEMSG"
+ git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG"
exit $?
fi
diff --git a/git-remote.perl b/git-remote.perl
index 059c141b68..c56c5a84a4 100755
--- a/git-remote.perl
+++ b/git-remote.perl
@@ -64,7 +64,7 @@ sub list_remote {
my ($git) = @_;
my %seen = ();
my @remotes = eval {
- $git->command(qw(repo-config --get-regexp), '^remote\.');
+ $git->command(qw(config --get-regexp), '^remote\.');
};
for (@remotes) {
if (/^remote\.([^.]*)\.(\S*)\s+(.*)$/) {
@@ -103,7 +103,7 @@ sub list_branch {
my ($git) = @_;
my %seen = ();
my @branches = eval {
- $git->command(qw(repo-config --get-regexp), '^branch\.');
+ $git->command(qw(config --get-regexp), '^branch\.');
};
for (@branches) {
if (/^branch\.([^.]*)\.(\S*)\s+(.*)$/) {
@@ -130,7 +130,7 @@ sub update_ls_remote {
$info->{'LS_REMOTE'} = \@ref;
}
-sub show_wildcard_mapping {
+sub list_wildcard_mapping {
my ($forced, $ours, $ls) = @_;
my %refs;
for (@$ls) {
@@ -156,25 +156,14 @@ sub show_wildcard_mapping {
push @tracked, $_;
}
}
- if (@new) {
- print " New remote branches (next fetch will store in remotes/$ours)\n";
- print " @new\n";
- }
- if (@stale) {
- print " Stale tracking branches in remotes/$ours (you'd better remove them)\n";
- print " @stale\n";
- }
- if (@tracked) {
- print " Tracked remote branches\n";
- print " @tracked\n";
- }
+ return \@new, \@stale, \@tracked;
}
-sub show_mapping {
+sub list_mapping {
my ($name, $info) = @_;
my $fetch = $info->{'FETCH'};
my $ls = $info->{'LS_REMOTE'};
- my (@stale, @tracked);
+ my (@new, @stale, @tracked);
for (@$fetch) {
next unless (/(\+)?([^:]+):(.*)/);
@@ -182,7 +171,11 @@ sub show_mapping {
if ($theirs eq 'refs/heads/*' &&
$ours =~ /^refs\/remotes\/(.*)\/\*$/) {
# wildcard mapping
- show_wildcard_mapping($forced, $1, $ls);
+ my ($w_new, $w_stale, $w_tracked)
+ = list_wildcard_mapping($forced, $1, $ls);
+ push @new, @$w_new;
+ push @stale, @$w_stale;
+ push @tracked, @$w_tracked;
}
elsif ($theirs =~ /\*/ || $ours =~ /\*/) {
print STDERR "Warning: unrecognized mapping in remotes.$name.fetch: $_\n";
@@ -196,13 +189,40 @@ sub show_mapping {
}
}
}
- if (@stale) {
- print " Stale tracking branches in remotes/$name (you'd better remove them)\n";
- print " @stale\n";
+ return \@new, \@stale, \@tracked;
+}
+
+sub show_mapping {
+ my ($name, $info) = @_;
+ my ($new, $stale, $tracked) = list_mapping($name, $info);
+ if (@$new) {
+ print " New remote branches (next fetch will store in remotes/$name)\n";
+ print " @$new\n";
+ }
+ if (@$stale) {
+ print " Stale tracking branches in remotes/$name (use 'git remote prune')\n";
+ print " @$stale\n";
}
- if (@tracked) {
+ if (@$tracked) {
print " Tracked remote branches\n";
- print " @tracked\n";
+ print " @$tracked\n";
+ }
+}
+
+sub prune_remote {
+ my ($name, $ls_remote) = @_;
+ if (!exists $remote->{$name}) {
+ print STDERR "No such remote $name\n";
+ return;
+ }
+ my $info = $remote->{$name};
+ update_ls_remote($ls_remote, $info);
+
+ my ($new, $stale, $tracked) = list_mapping($name, $info);
+ my $prefix = "refs/remotes/$name";
+ foreach my $to_prune (@$stale) {
+ my @v = $git->command(qw(rev-parse --verify), "$prefix/$to_prune");
+ $git->command(qw(update-ref -d), "$prefix/$to_prune", $v[0]);
}
}
@@ -233,14 +253,30 @@ sub show_remote {
}
sub add_remote {
- my ($name, $url) = @_;
+ my ($name, $url, $opts) = @_;
if (exists $remote->{$name}) {
print STDERR "remote $name already exists.\n";
exit(1);
}
- $git->command('repo-config', "remote.$name.url", $url);
- $git->command('repo-config', "remote.$name.fetch",
- "+refs/heads/*:refs/remotes/$name/*");
+ $git->command('config', "remote.$name.url", $url);
+ my $track = $opts->{'track'} || ["*"];
+
+ for (@$track) {
+ $git->command('config', '--add', "remote.$name.fetch",
+ "+refs/heads/$_:refs/remotes/$name/$_");
+ }
+ if ($opts->{'fetch'}) {
+ $git->command('fetch', $name);
+ }
+ if (exists $opts->{'master'}) {
+ $git->command('symbolic-ref', "refs/remotes/$name/HEAD",
+ "refs/remotes/$name/$opts->{'master'}");
+ }
+}
+
+sub add_usage {
+ print STDERR "Usage: git remote add [-f] [-t track]* [-m master] <name> <url>\n";
+ exit(1);
}
if (!@ARGV) {
@@ -267,11 +303,62 @@ elsif ($ARGV[0] eq 'show') {
show_remote($ARGV[$i], $ls_remote);
}
}
+elsif ($ARGV[0] eq 'prune') {
+ my $ls_remote = 1;
+ my $i;
+ for ($i = 1; $i < @ARGV; $i++) {
+ if ($ARGV[$i] eq '-n') {
+ $ls_remote = 0;
+ }
+ else {
+ last;
+ }
+ }
+ if ($i >= @ARGV) {
+ print STDERR "Usage: git remote prune <remote>\n";
+ exit(1);
+ }
+ for (; $i < @ARGV; $i++) {
+ prune_remote($ARGV[$i], $ls_remote);
+ }
+}
elsif ($ARGV[0] eq 'add') {
+ my %opts = ();
+ while (1 < @ARGV && $ARGV[1] =~ /^-/) {
+ my $opt = $ARGV[1];
+ shift @ARGV;
+ if ($opt eq '-f' || $opt eq '--fetch') {
+ $opts{'fetch'} = 1;
+ next;
+ }
+ if ($opt eq '-t' || $opt eq '--track') {
+ if (@ARGV < 1) {
+ add_usage();
+ }
+ $opts{'track'} ||= [];
+ push @{$opts{'track'}}, $ARGV[1];
+ shift @ARGV;
+ next;
+ }
+ if ($opt eq '-m' || $opt eq '--master') {
+ if ((@ARGV < 1) || exists $opts{'master'}) {
+ add_usage();
+ }
+ $opts{'master'} = $ARGV[1];
+ shift @ARGV;
+ next;
+ }
+ add_usage();
+ }
if (@ARGV != 3) {
- print STDERR "Usage: git remote add <name> <url>\n";
- exit(1);
+ add_usage();
}
- add_remote($ARGV[1], $ARGV[2]);
+ add_remote($ARGV[1], $ARGV[2], \%opts);
+}
+else {
+ print STDERR "Usage: git remote\n";
+ print STDERR " git remote add <name> <url>\n";
+ print STDERR " git remote show <name>\n";
+ print STDERR " git remote prune <name>\n";
+ exit(1);
}
-
diff --git a/git-repack.sh b/git-repack.sh
index 375434b1dc..ddfa8b44a1 100755
--- a/git-repack.sh
+++ b/git-repack.sh
@@ -28,7 +28,7 @@ done
# Later we will default repack.UseDeltaBaseOffset to true
default_dbo=false
-case "`git repo-config --bool repack.usedeltabaseoffset ||
+case "`git config --bool repack.usedeltabaseoffset ||
echo $default_dbo`" in
true)
extra="$extra --delta-base-offset" ;;
@@ -110,7 +110,7 @@ then
done
)
fi
- git-prune-packed
+ git-prune-packed $quiet
fi
case "$no_update_info" in
diff --git a/git-reset.sh b/git-reset.sh
index 76c8a818d4..fee6d98d9c 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -6,6 +6,7 @@ USAGE='[--mixed | --soft | --hard] [<commit-ish>] [ [--] <paths>...]'
SUBDIRECTORY_OK=Yes
. git-sh-setup
set_reflog_action "reset $*"
+require_work_tree
update= reset_type=--mixed
unset rev
@@ -42,7 +43,7 @@ case "$1" in --) shift ;; esac
# affecting the working tree nor HEAD.
if test $# != 0
then
- test "$reset_type" == "--mixed" ||
+ test "$reset_type" = "--mixed" ||
die "Cannot do partial $reset_type reset."
git-diff-index --cached $rev -- "$@" |
@@ -52,11 +53,7 @@ then
exit
fi
-TOP=$(git-rev-parse --show-cdup)
-if test ! -z "$TOP"
-then
- cd "$TOP"
-fi
+cd_to_toplevel
if test "$reset_type" = "--hard"
then
@@ -90,7 +87,7 @@ update_ref_status=$?
case "$reset_type" in
--hard )
test $update_ref_status = 0 && {
- echo -n "HEAD is now at "
+ printf "HEAD is now at "
GIT_PAGER= git log --max-count=1 --pretty=oneline \
--abbrev-commit HEAD
}
diff --git a/git-revert.sh b/git-revert.sh
index 50cc47b063..49f00321b2 100755
--- a/git-revert.sh
+++ b/git-revert.sh
@@ -16,9 +16,14 @@ case "$0" in
me=cherry-pick
USAGE='[--edit] [-n] [-r] [-x] <commit-ish>' ;;
* )
- die "What are you talking about?" ;;
+ echo >&2 "What are you talking about?"
+ exit 1 ;;
esac
+
+SUBDIRECTORY_OK=Yes ;# we will cd up
. git-sh-setup
+require_work_tree
+cd_to_toplevel
no_commit=
while case "$#" in 0) break ;; esac
@@ -49,6 +54,8 @@ do
shift
done
+set_reflog_action "$me"
+
test "$me,$replay" = "revert,t" && usage
case "$no_commit" in
@@ -76,6 +83,8 @@ prev=$(git-rev-parse --verify "$commit^1" 2>/dev/null) ||
git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
die "Cannot run $me a multi-parent commit."
+encoding=$(git config i18n.commitencoding || echo UTF-8)
+
# "commit" is an existing commit. We would want to apply
# the difference it introduces since its first parent "prev"
# on top of the current HEAD if we are cherry-pick. Or the
@@ -83,10 +92,11 @@ git-rev-parse --verify "$commit^2" >/dev/null 2>&1 &&
case "$me" in
revert)
- git-rev-list --pretty=oneline --max-count=1 $commit |
+ git show -s --pretty=oneline --encoding="$encoding" $commit |
sed -e '
s/^[^ ]* /Revert "/
- s/$/"/'
+ s/$/"/
+ '
echo
echo "This reverts commit $commit."
test "$rev" = "$commit" ||
@@ -115,14 +125,17 @@ cherry-pick)
q
}'
- set_author_env=`git-cat-file commit "$commit" |
+
+ logmsg=`git show -s --pretty=raw --encoding="$encoding" "$commit"`
+ set_author_env=`echo "$logmsg" |
LANG=C LC_ALL=C sed -ne "$pick_author_script"`
eval "$set_author_env"
export GIT_AUTHOR_NAME
export GIT_AUTHOR_EMAIL
export GIT_AUTHOR_DATE
- git-cat-file commit $commit | sed -e '1,/^$/d'
+ echo "$logmsg" |
+ sed -e '1,/^$/d' -e 's/^ //'
case "$replay" in
'')
echo "(cherry picked from commit $commit)"
@@ -135,37 +148,38 @@ cherry-pick)
esac >.msg
+eval GITHEAD_$head=HEAD
+eval GITHEAD_$next='`git show -s \
+ --pretty=oneline --encoding="$encoding" "$commit" |
+ sed -e "s/^[^ ]* //"`'
+export GITHEAD_$head GITHEAD_$next
+
# This three way merge is an interesting one. We are at
# $head, and would want to apply the change between $commit
# and $prev on top of us (when reverting), or the change between
# $prev and $commit on top of us (when cherry-picking or replaying).
-echo >&2 "First trying simple merge strategy to $me."
-git-read-tree -m -u --aggressive $base $head $next &&
+git-merge-recursive $base -- $head $next &&
result=$(git-write-tree 2>/dev/null) || {
- echo >&2 "Simple $me fails; trying Automatic $me."
- git-merge-index -o git-merge-one-file -a || {
- mv -f .msg "$GIT_DIR/MERGE_MSG"
- {
- echo '
+ mv -f .msg "$GIT_DIR/MERGE_MSG"
+ {
+ echo '
Conflicts:
'
git ls-files --unmerged |
sed -e 's/^[^ ]* / /' |
uniq
- } >>"$GIT_DIR/MERGE_MSG"
- echo >&2 "Automatic $me failed. After resolving the conflicts,"
- echo >&2 "mark the corrected paths with 'git-add <paths>'"
- echo >&2 "and commit the result."
- case "$me" in
- cherry-pick)
+ } >>"$GIT_DIR/MERGE_MSG"
+ echo >&2 "Automatic $me failed. After resolving the conflicts,"
+ echo >&2 "mark the corrected paths with 'git-add <paths>'"
+ echo >&2 "and commit the result."
+ case "$me" in
+ cherry-pick)
echo >&2 "You may choose to use the following when making"
echo >&2 "the commit:"
echo >&2 "$set_author_env"
- esac
- exit 1
- }
- result=$(git-write-tree) || exit
+ esac
+ exit 1
}
echo >&2 "Finished one $me."
diff --git a/git-send-email.perl b/git-send-email.perl
index ba39d39384..6a285bfd21 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -402,6 +402,15 @@ sub make_message_id
$cc = "";
$time = time - scalar $#files;
+sub unquote_rfc2047 {
+ local ($_) = @_;
+ if (s/=\?utf-8\?q\?(.*)\?=/$1/g) {
+ s/_/ /g;
+ s/=([0-9A-F]{2})/chr(hex($1))/eg;
+ }
+ return "$_";
+}
+
sub send_message
{
my @recipients = unique_email_list(@to);
@@ -555,6 +564,7 @@ foreach my $t (@files) {
}
close F;
if (defined $author_not_sender) {
+ $author_not_sender = unquote_rfc2047($author_not_sender);
$message = "From: $author_not_sender\n\n$message";
}
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 87b939c0e4..f24c7f2d23 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -28,6 +28,31 @@ set_reflog_action() {
fi
}
+is_bare_repository () {
+ git-config --bool --get core.bare ||
+ case "$GIT_DIR" in
+ .git | */.git) echo false ;;
+ *) echo true ;;
+ esac
+}
+
+cd_to_toplevel () {
+ cdup=$(git-rev-parse --show-cdup)
+ if test ! -z "$cdup"
+ then
+ cd "$cdup" || {
+ echo >&2 "Cannot chdir to $cdup, the toplevel of the working tree"
+ exit 1
+ }
+ fi
+}
+
+require_work_tree () {
+ test $(is_bare_repository) = false &&
+ test $(git-rev-parse --is-inside-git-dir) = false ||
+ die "fatal: $0 cannot be used without a working tree."
+}
+
if [ -z "$LONG_USAGE" ]
then
LONG_USAGE="Usage: $0 $USAGE"
@@ -47,7 +72,11 @@ esac
if [ -z "$SUBDIRECTORY_OK" ]
then
: ${GIT_DIR=.git}
- GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || exit
+ GIT_DIR=$(GIT_DIR="$GIT_DIR" git-rev-parse --git-dir) || {
+ 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
fi
diff --git a/git-svn.perl b/git-svn.perl
index 56f17002d1..d792a62d7c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -286,7 +286,7 @@ sub init {
$SVN_URL = $url;
unless (-d $GIT_DIR) {
- my @init_db = ('init-db');
+ my @init_db = ('init');
push @init_db, "--template=$_template" if defined $_template;
push @init_db, "--shared" if defined $_shared;
command_noisy(@init_db);
@@ -593,7 +593,7 @@ sub multi_init {
"$trunk_url ($_trunk)\n";
}
init($trunk_url);
- command_noisy('repo-config', 'svn.trunk', $trunk_url);
+ command_noisy('config', 'svn.trunk', $trunk_url);
}
}
$_prefix = '' unless defined $_prefix;
@@ -681,7 +681,7 @@ sub show_log {
process_commit($_, $r_min, $r_max) foreach reverse @k;
}
out:
- eval { command_close_pipe($log) };
+ close $log;
print '-' x72,"\n" unless $_incremental || $_oneline;
}
@@ -772,22 +772,22 @@ sub log_use_color {
return 1 if $_color;
my ($dc, $dcvar);
$dcvar = 'color.diff';
- $dc = `git-repo-config --get $dcvar`;
+ $dc = `git-config --get $dcvar`;
if ($dc eq '') {
# nothing at all; fallback to "diff.color"
$dcvar = 'diff.color';
- $dc = `git-repo-config --get $dcvar`;
+ $dc = `git-config --get $dcvar`;
}
chomp($dc);
if ($dc eq 'auto') {
my $pc;
- $pc = `git-repo-config --get color.pager`;
+ $pc = `git-config --get color.pager`;
if ($pc eq '') {
# does not have it -- fallback to pager.color
- $pc = `git-repo-config --bool --get pager.color`;
+ $pc = `git-config --bool --get pager.color`;
}
else {
- $pc = `git-repo-config --bool --get color.pager`;
+ $pc = `git-config --bool --get color.pager`;
if ($?) {
$pc = 'false';
}
@@ -800,7 +800,7 @@ sub log_use_color {
}
return 0 if $dc eq 'never';
return 1 if $dc eq 'always';
- chomp($dc = `git-repo-config --bool --get $dcvar`);
+ chomp($dc = `git-config --bool --get $dcvar`);
return ($dc eq 'true');
}
@@ -919,7 +919,7 @@ sub complete_url_ls_init {
waitpid $pid, 0;
croak $? if $?;
my ($n) = ($switch =~ /^--(\w+)/);
- command_noisy('repo-config', "svn.$n", $full_url);
+ command_noisy('config', "svn.$n", $full_url);
}
sub common_prefix {
@@ -1475,7 +1475,7 @@ sub map_tree_joins {
$seen{$commit} = 1;
}
}
- eval { command_close_pipe($pipe) };
+ close $pipe;
}
}
@@ -1594,7 +1594,7 @@ sub init_vars {
%tree_map = ();
}
-# convert GetOpt::Long specs for use by git-repo-config
+# convert GetOpt::Long specs for use by git-config
sub read_repo_config {
return unless -d $GIT_DIR;
my $opts = shift;
@@ -1602,7 +1602,7 @@ sub read_repo_config {
my $v = $opts->{$o};
my ($key) = ($o =~ /^([a-z\-]+)/);
$key =~ s/-//g;
- my $arg = 'git-repo-config';
+ my $arg = 'git-config';
$arg .= ' --int' if ($o =~ /[:=]i$/);
$arg .= ' --bool' if ($o !~ /[:=][sfi]$/);
if (ref $v eq 'ARRAY') {
@@ -1610,7 +1610,7 @@ sub read_repo_config {
@$v = @tmp if @tmp;
} else {
chomp(my $tmp = `$arg --get svn.$key`);
- if ($tmp && !($arg =~ / --bool / && $tmp eq 'false')) {
+ if ($tmp && !($arg =~ / --bool/ && $tmp eq 'false')) {
$$v = $tmp;
}
}
@@ -1669,7 +1669,7 @@ sub write_grafts {
last unless /^\S/;
}
}
- eval { command_close_pipe($ch) }; # breaking the pipe
+ close $ch; # breaking the pipe
# if real parents are the only ones in the grafts, drop it
next if join(' ',sort keys %$p) eq join(' ',sort keys %x);
@@ -1766,7 +1766,7 @@ sub get_commit_time {
} elsif ($tz =~ s/^\-//) {
$s -= tz_to_s_offset($tz);
}
- eval { command_close_pipe($fh) };
+ close $fh;
return $s;
}
die "Can't get commit time for commit: $cmt\n";
@@ -1918,7 +1918,8 @@ sub _simple_prompt {
$default_username = $_username if defined $_username;
if (defined $default_username && length $default_username) {
if (defined $realm && length $realm) {
- print "Authentication realm: $realm\n";
+ print STDERR "Authentication realm: $realm\n";
+ STDERR->flush;
}
$cred->username($default_username);
} else {
@@ -1933,36 +1934,38 @@ sub _simple_prompt {
sub _ssl_server_trust_prompt {
my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
- print "Error validating server certificate for '$realm':\n";
+ print STDERR "Error validating server certificate for '$realm':\n";
if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
- print " - The certificate is not issued by a trusted ",
+ print STDERR " - The certificate is not issued by a trusted ",
"authority. Use the\n",
" fingerprint to validate the certificate manually!\n";
}
if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
- print " - The certificate hostname does not match.\n";
+ print STDERR " - The certificate hostname does not match.\n";
}
if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
- print " - The certificate is not yet valid.\n";
+ print STDERR " - The certificate is not yet valid.\n";
}
if ($failures & $SVN::Auth::SSL::EXPIRED) {
- print " - The certificate has expired.\n";
+ print STDERR " - The certificate has expired.\n";
}
if ($failures & $SVN::Auth::SSL::OTHER) {
- print " - The certificate has an unknown error.\n";
+ print STDERR " - The certificate has an unknown error.\n";
}
- printf( "Certificate information:\n".
+ printf STDERR
+ "Certificate information:\n".
" - Hostname: %s\n".
" - Valid: from %s until %s\n".
" - Issuer: %s\n".
" - Fingerprint: %s\n",
map $cert_info->$_, qw(hostname valid_from valid_until
- issuer_dname fingerprint) );
+ issuer_dname fingerprint);
my $choice;
prompt:
- print $may_save ?
+ print STDERR $may_save ?
"(R)eject, accept (t)emporarily or accept (p)ermanently? " :
"(R)eject or accept (t)emporarily? ";
+ STDERR->flush;
$choice = lc(substr(<STDIN> || 'R', 0, 1));
if ($choice =~ /^t$/i) {
$cred->may_save(undef);
@@ -1980,7 +1983,8 @@ prompt:
sub _ssl_client_cert_prompt {
my ($cred, $realm, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
- print "Client certificate filename: ";
+ print STDERR "Client certificate filename: ";
+ STDERR->flush;
chomp(my $filename = <STDIN>);
$cred->cert_file($filename);
$cred->may_save($may_save);
@@ -1999,13 +2003,14 @@ sub _username_prompt {
my ($cred, $realm, $may_save, $pool) = @_;
$may_save = undef if $_no_auth_cache;
if (defined $realm && length $realm) {
- print "Authentication realm: $realm\n";
+ print STDERR "Authentication realm: $realm\n";
}
my $username;
if (defined $_username) {
$username = $_username;
} else {
- print "Username: ";
+ print STDERR "Username: ";
+ STDERR->flush;
chomp($username = <STDIN>);
}
$cred->username($username);
@@ -2015,7 +2020,8 @@ sub _username_prompt {
sub _read_password {
my ($prompt, $realm) = @_;
- print $prompt;
+ print STDERR $prompt;
+ STDERR->flush;
require Term::ReadKey;
Term::ReadKey::ReadMode('noecho');
my $password = '';
@@ -2024,7 +2030,8 @@ sub _read_password {
$password .= $key;
}
Term::ReadKey::ReadMode('restore');
- print "\n";
+ print STDERR "\n";
+ STDERR->flush;
$password;
}
@@ -2839,7 +2846,7 @@ sub rmdirs {
delete $rm->{join '/', @dn};
}
unless (%$rm) {
- eval { command_close_pipe($fh) };
+ close $fh;
return;
}
}
@@ -2849,7 +2856,7 @@ sub rmdirs {
foreach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) {
$self->close_directory($bat->{$d}, $p);
my ($dn) = ($d =~ m#^(.*?)/?(?:[^/]+)$#);
- print "\tD+\t/$d/\n" unless $q;
+ print "\tD+\t$d/\n" unless $q;
$self->SUPER::delete_entry($d, $r, $bat->{$dn}, $p);
delete $bat->{$d};
}
diff --git a/git-svnimport.perl b/git-svnimport.perl
index f1f1a7dbed..3af8c7e110 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -285,7 +285,7 @@ my $last_rev = "";
my $last_branch;
my $current_rev = $opt_s || 1;
unless(-d $git_dir) {
- system("git-init-db");
+ system("git-init");
die "Cannot init the GIT db at $git_tree: $?\n" if $?;
system("git-read-tree");
die "Cannot init an empty tree: $?\n" if $?;
diff --git a/git-tag.sh b/git-tag.sh
index ecb9100e4b..4a0a7b6607 100755
--- a/git-tag.sh
+++ b/git-tag.sh
@@ -63,12 +63,21 @@ do
;;
-d)
shift
- tag_name="$1"
- tag=$(git-show-ref --verify --hash -- "refs/tags/$tag_name") ||
- die "Seriously, what tag are you talking about?"
- git-update-ref -m 'tag: delete' -d "refs/tags/$tag_name" "$tag" &&
- echo "Deleted tag $tag_name."
- exit $?
+ had_error=0
+ for tag
+ do
+ cur=$(git-show-ref --verify --hash -- "refs/tags/$tag") || {
+ echo >&2 "Seriously, what tag are you talking about?"
+ had_error=1
+ continue
+ }
+ git-update-ref -m 'tag: delete' -d "refs/tags/$tag" "$cur" || {
+ had_error=1
+ continue
+ }
+ echo "Deleted tag $tag."
+ done
+ exit $had_error
;;
-v)
shift
@@ -103,7 +112,10 @@ git-check-ref-format "tags/$name" ||
object=$(git-rev-parse --verify --default HEAD "$@") || exit 1
type=$(git-cat-file -t $object) || exit 1
tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1
-: ${username:=$(expr "z$tagger" : 'z\(.*>\)')}
+
+test -n "$username" ||
+ username=$(git-repo-config user.signingkey) ||
+ username=$(expr "z$tagger" : 'z\(.*>\)')
trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG "$GIT_DIR"/TAG_EDITMSG' 0
diff --git a/git.c b/git.c
index e7bc79af93..4dd196721f 100644
--- a/git.c
+++ b/git.c
@@ -159,6 +159,16 @@ static int handle_alias(int *argcp, const char ***argv)
alias_command = (*argv)[0];
git_config(git_alias_config);
if (alias_string) {
+ if (alias_string[0] == '!') {
+ trace_printf("trace: alias to shell cmd: %s => %s\n",
+ alias_command, alias_string + 1);
+ ret = system(alias_string + 1);
+ if (ret >= 0 && WIFEXITED(ret) &&
+ WEXITSTATUS(ret) != 127)
+ exit(WEXITSTATUS(ret));
+ die("Failed to run '%s' when expanding alias '%s'\n",
+ alias_string + 1, alias_command);
+ }
count = split_cmdline(alias_string, &new_argv);
option_count = handle_options(&new_argv, &count);
memmove(new_argv - option_count, new_argv,
@@ -199,6 +209,11 @@ const char git_version_string[] = GIT_VERSION;
#define RUN_SETUP (1<<0)
#define USE_PAGER (1<<1)
+/*
+ * require working tree to be present -- anything uses this needs
+ * RUN_SETUP for reading from the configuration file.
+ */
+#define NOT_BARE (1<<2)
static void handle_internal_command(int argc, const char **argv, char **envp)
{
@@ -208,26 +223,29 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
int (*fn)(int, const char **, const char *);
int option;
} commands[] = {
- { "add", cmd_add, RUN_SETUP },
- { "annotate", cmd_annotate, },
+ { "add", cmd_add, RUN_SETUP | NOT_BARE },
+ { "annotate", cmd_annotate, USE_PAGER },
{ "apply", cmd_apply },
{ "archive", cmd_archive },
- { "blame", cmd_blame, RUN_SETUP | USE_PAGER },
+ { "blame", cmd_blame, RUN_SETUP },
{ "branch", cmd_branch, RUN_SETUP },
{ "cat-file", cmd_cat_file, RUN_SETUP },
{ "checkout-index", cmd_checkout_index, RUN_SETUP },
{ "check-ref-format", cmd_check_ref_format },
{ "cherry", cmd_cherry, RUN_SETUP },
{ "commit-tree", cmd_commit_tree, RUN_SETUP },
+ { "config", cmd_config },
{ "count-objects", cmd_count_objects, RUN_SETUP },
+ { "describe", cmd_describe, RUN_SETUP },
{ "diff", cmd_diff, RUN_SETUP | USE_PAGER },
{ "diff-files", cmd_diff_files, RUN_SETUP },
{ "diff-index", cmd_diff_index, RUN_SETUP },
- { "diff-stages", cmd_diff_stages, RUN_SETUP },
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
{ "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP },
{ "for-each-ref", cmd_for_each_ref, RUN_SETUP },
{ "format-patch", cmd_format_patch, RUN_SETUP },
+ { "fsck", cmd_fsck, RUN_SETUP },
+ { "fsck-objects", cmd_fsck, RUN_SETUP },
{ "get-tar-commit-id", cmd_get_tar_commit_id },
{ "grep", cmd_grep, RUN_SETUP },
{ "help", cmd_help },
@@ -240,7 +258,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "mailsplit", cmd_mailsplit },
{ "merge-base", cmd_merge_base, RUN_SETUP },
{ "merge-file", cmd_merge_file },
- { "mv", cmd_mv, RUN_SETUP },
+ { "mv", cmd_mv, RUN_SETUP | NOT_BARE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
{ "pickaxe", cmd_blame, RUN_SETUP | USE_PAGER },
@@ -249,12 +267,12 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "push", cmd_push, RUN_SETUP },
{ "read-tree", cmd_read_tree, RUN_SETUP },
{ "reflog", cmd_reflog, RUN_SETUP },
- { "repo-config", cmd_repo_config },
+ { "repo-config", cmd_config },
{ "rerere", cmd_rerere, RUN_SETUP },
{ "rev-list", cmd_rev_list, RUN_SETUP },
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
- { "rm", cmd_rm, RUN_SETUP },
- { "runstatus", cmd_runstatus, RUN_SETUP },
+ { "rm", cmd_rm, RUN_SETUP | NOT_BARE },
+ { "runstatus", cmd_runstatus, RUN_SETUP | NOT_BARE },
{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
@@ -291,6 +309,9 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
prefix = setup_git_directory();
if (p->option & USE_PAGER)
setup_pager();
+ if ((p->option & NOT_BARE) &&
+ (is_bare_repository() || is_inside_git_dir()))
+ die("%s must be run in a work tree", cmd);
trace_argv_printf(argv, argc, "trace: built-in: git");
exit(p->fn(argc, argv, prefix));
@@ -376,8 +397,15 @@ int main(int argc, const char **argv, char **envp)
done_alias = 1;
}
- if (errno == ENOENT)
+ if (errno == ENOENT) {
+ if (done_alias) {
+ fprintf(stderr, "Expansion of alias '%s' failed; "
+ "'%s' is not a git-command\n",
+ cmd, argv[0]);
+ exit(1);
+ }
help_unknown_cmd(cmd);
+ }
fprintf(stderr, "Failed to run command '%s': %s\n",
cmd, strerror(errno));
diff --git a/git.spec.in b/git.spec.in
index fb95e37594..46aee88fd1 100644
--- a/git.spec.in
+++ b/git.spec.in
@@ -9,15 +9,12 @@ 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}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: git-core, git-svn, git-cvs, git-arch, git-email, gitk, perl-Git
+Requires: git-core, git-svn, git-cvs, git-arch, git-email, gitk, git-gui, perl-Git
%description
-This is a stupid (but extremely fast) directory content manager. It
-doesn't do a whole lot, but what it _does_ do is track directory
-contents efficiently. It is intended to be the base of an efficient,
-distributed source code management system. This package includes
-rudimentary tools that can be used as a SCM, but you should look
-elsewhere for tools for ordinary humans layered on top of this.
+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.
@@ -26,12 +23,9 @@ Summary: Core git tools
Group: Development/Tools
Requires: zlib >= 1.2, rsync, curl, less, openssh-clients, expat
%description core
-This is a stupid (but extremely fast) directory content manager. It
-doesn't do a whole lot, but what it _does_ do is track directory
-contents efficiently. It is intended to be the base of an efficient,
-distributed source code management system. This package includes
-rudimentary tools that can be used as a SCM, but you should look
-elsewhere for tools for ordinary humans layered on top of this.
+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.
@@ -63,6 +57,13 @@ Requires: git-core = %{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
+%description gui
+Git GUI tool
+
%package -n gitk
Summary: Git revision tree visualiser ('gitk')
Group: Development/Tools
@@ -89,17 +90,18 @@ make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease \
%install
rm -rf $RPM_BUILD_ROOT
-make %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT WITH_OWN_SUBPROCESS_PY=YesPlease \
+make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \
+ WITH_OWN_SUBPROCESS_PY=YesPlease \
prefix=%{_prefix} mandir=%{_mandir} INSTALLDIRS=vendor \
install %{!?_without_docs: install-doc}
find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';'
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" | sed -e s@^$RPM_BUILD_ROOT@@) > bin-man-doc-files
+(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%{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" | sed -e s@^$RPM_BUILD_ROOT@@ -e 's/$/*/' ) >> bin-man-doc-files
+(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
%else
rm -rf $RPM_BUILD_ROOT%{_mandir}
%endif
@@ -138,6 +140,16 @@ rm -rf $RPM_BUILD_ROOT
%{!?_without_docs: %{_mandir}/man1/*email*.1*}
%{!?_without_docs: %doc Documentation/*email*.html }
+%files gui
+%defattr(-,root,root)
+%{_bindir}/git-gui
+%{_bindir}/git-citool
+# Not Yet...
+# %{!?_without_docs: %{_mandir}/man1/git-gui.1}
+# %{!?_without_docs: %doc Documentation/git-gui.html}
+# %{!?_without_docs: %{_mandir}/man1/git-citool.1}
+# %{!?_without_docs: %doc Documentation/git-citool.html}
+
%files -n gitk
%defattr(-,root,root)
%doc Documentation/*gitk*.txt
@@ -155,6 +167,12 @@ rm -rf $RPM_BUILD_ROOT
%{!?_without_docs: %doc Documentation/*.html }
%changelog
+* Mon Feb 13 2007 Nicolas Pitre <nico@cam.org>
+- Update core package description (Git isn't as stupid as it used to be)
+
+* Mon Feb 12 2007 Junio C Hamano <junkio@cox.net>
+- Add git-gui and git-citool.
+
* Mon Nov 14 2005 H. Peter Anvin <hpa@zytor.com> 0.99.9j-1
- Change subpackage names to git-<name> instead of git-core-<name>
- Create empty root package which brings in all subpackages
diff --git a/gitk b/gitk
index 3dabc69516..9ddff3e7f7 100755
--- a/gitk
+++ b/gitk
@@ -12,7 +12,7 @@ proc gitdir {} {
if {[info exists env(GIT_DIR)]} {
return $env(GIT_DIR)
} else {
- return ".git"
+ return [exec git rev-parse --git-dir]
}
}
@@ -309,9 +309,9 @@ proc readrefs {} {
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
catch {unset $v}
}
- set refd [open [list | git ls-remote [gitdir]] r]
+ set refd [open [list | git show-ref] r]
while {0 <= [set n [gets $refd line]]} {
- if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
+ if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
match id path]} {
continue
}
@@ -427,7 +427,7 @@ proc makewindow {} {
.bar.view add separator
.bar.view add radiobutton -label "All files" -command {showview 0} \
-variable selectedview -value 0
-
+
menu .bar.help
.bar add cascade -label "Help" -menu .bar.help
.bar.help add command -label "About gitk" -command about
@@ -435,56 +435,60 @@ proc makewindow {} {
.bar.help configure -font $uifont
. configure -menu .bar
- if {![info exists geometry(canv1)]} {
- set geometry(canv1) [expr {45 * $charspc}]
- set geometry(canv2) [expr {30 * $charspc}]
- set geometry(canv3) [expr {15 * $charspc}]
- set geometry(canvh) [expr {25 * $linespc + 4}]
- set geometry(ctextw) 80
- set geometry(ctexth) 30
- set geometry(cflistw) 30
- }
+ # the gui has upper and lower half, parts of a paned window.
panedwindow .ctop -orient vertical
- if {[info exists geometry(width)]} {
- .ctop conf -width $geometry(width) -height $geometry(height)
- set texth [expr {$geometry(height) - $geometry(canvh) - 56}]
- set geometry(ctexth) [expr {($texth - 8) /
- [font metrics $textfont -linespace]}]
- }
- frame .ctop.top
- frame .ctop.top.bar
- frame .ctop.top.lbar
- pack .ctop.top.lbar -side bottom -fill x
- pack .ctop.top.bar -side bottom -fill x
- set cscroll .ctop.top.csb
- scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
- pack $cscroll -side right -fill y
- panedwindow .ctop.top.clist -orient horizontal -sashpad 0 -handlesize 4
- pack .ctop.top.clist -side top -fill both -expand 1
- .ctop add .ctop.top
- set canv .ctop.top.clist.canv
- canvas $canv -height $geometry(canvh) -width $geometry(canv1) \
+
+ # possibly use assumed geometry
+ if {![info exists geometry(pwsash0)]} {
+ set geometry(topheight) [expr {15 * $linespc}]
+ set geometry(topwidth) [expr {80 * $charspc}]
+ set geometry(botheight) [expr {15 * $linespc}]
+ set geometry(botwidth) [expr {50 * $charspc}]
+ set geometry(pwsash0) "[expr {40 * $charspc}] 2"
+ set geometry(pwsash1) "[expr {60 * $charspc}] 2"
+ }
+
+ # the upper half will have a paned window, a scroll bar to the right, and some stuff below
+ frame .tf -height $geometry(topheight) -width $geometry(topwidth)
+ frame .tf.histframe
+ panedwindow .tf.histframe.pwclist -orient horizontal -sashpad 0 -handlesize 4
+
+ # create three canvases
+ set cscroll .tf.histframe.csb
+ set canv .tf.histframe.pwclist.canv
+ canvas $canv \
-background $bgcolor -bd 0 \
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
- .ctop.top.clist add $canv
- set canv2 .ctop.top.clist.canv2
- canvas $canv2 -height $geometry(canvh) -width $geometry(canv2) \
+ .tf.histframe.pwclist add $canv
+ set canv2 .tf.histframe.pwclist.canv2
+ canvas $canv2 \
-background $bgcolor -bd 0 -yscrollincr $linespc
- .ctop.top.clist add $canv2
- set canv3 .ctop.top.clist.canv3
- canvas $canv3 -height $geometry(canvh) -width $geometry(canv3) \
+ .tf.histframe.pwclist add $canv2
+ set canv3 .tf.histframe.pwclist.canv3
+ canvas $canv3 \
-background $bgcolor -bd 0 -yscrollincr $linespc
- .ctop.top.clist add $canv3
- bind .ctop.top.clist <Configure> {resizeclistpanes %W %w}
+ .tf.histframe.pwclist add $canv3
+ eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
+ eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
+
+ # a scroll bar to rule them
+ scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
+ pack $cscroll -side right -fill y
+ bind .tf.histframe.pwclist <Configure> {resizeclistpanes %W %w}
lappend bglist $canv $canv2 $canv3
+ pack .tf.histframe.pwclist -fill both -expand 1 -side left
+
+ # we have two button bars at bottom of top frame. Bar 1
+ frame .tf.bar
+ frame .tf.lbar -height 15
- set sha1entry .ctop.top.bar.sha1
+ set sha1entry .tf.bar.sha1
set entries $sha1entry
- set sha1but .ctop.top.bar.sha1label
+ set sha1but .tf.bar.sha1label
button $sha1but -text "SHA1 ID: " -state disabled -relief flat \
-command gotocommit -width 8 -font $uifont
$sha1but conf -disabledforeground [$sha1but cget -foreground]
- pack .ctop.top.bar.sha1label -side left
+ pack .tf.bar.sha1label -side left
entry $sha1entry -width 40 -font $textfont -textvariable sha1string
trace add variable sha1string write sha1change
pack $sha1entry -side left -pady 2
@@ -505,91 +509,107 @@ proc makewindow {} {
0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,
0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};
}
- button .ctop.top.bar.leftbut -image bm-left -command goback \
+ button .tf.bar.leftbut -image bm-left -command goback \
-state disabled -width 26
- pack .ctop.top.bar.leftbut -side left -fill y
- button .ctop.top.bar.rightbut -image bm-right -command goforw \
+ pack .tf.bar.leftbut -side left -fill y
+ button .tf.bar.rightbut -image bm-right -command goforw \
-state disabled -width 26
- pack .ctop.top.bar.rightbut -side left -fill y
+ pack .tf.bar.rightbut -side left -fill y
- button .ctop.top.bar.findbut -text "Find" -command dofind -font $uifont
- pack .ctop.top.bar.findbut -side left
+ button .tf.bar.findbut -text "Find" -command dofind -font $uifont
+ pack .tf.bar.findbut -side left
set findstring {}
- set fstring .ctop.top.bar.findstring
+ set fstring .tf.bar.findstring
lappend entries $fstring
entry $fstring -width 30 -font $textfont -textvariable findstring
trace add variable findstring write find_change
- pack $fstring -side left -expand 1 -fill x
+ pack $fstring -side left -expand 1 -fill x -in .tf.bar
set findtype Exact
- set findtypemenu [tk_optionMenu .ctop.top.bar.findtype \
- findtype Exact IgnCase Regexp]
+ set findtypemenu [tk_optionMenu .tf.bar.findtype \
+ findtype Exact IgnCase Regexp]
trace add variable findtype write find_change
- .ctop.top.bar.findtype configure -font $uifont
- .ctop.top.bar.findtype.menu configure -font $uifont
+ .tf.bar.findtype configure -font $uifont
+ .tf.bar.findtype.menu configure -font $uifont
set findloc "All fields"
- tk_optionMenu .ctop.top.bar.findloc findloc "All fields" Headline \
+ tk_optionMenu .tf.bar.findloc findloc "All fields" Headline \
Comments Author Committer
trace add variable findloc write find_change
- .ctop.top.bar.findloc configure -font $uifont
- .ctop.top.bar.findloc.menu configure -font $uifont
- pack .ctop.top.bar.findloc -side right
- pack .ctop.top.bar.findtype -side right
-
- label .ctop.top.lbar.flabel -text "Highlight: Commits " \
- -font $uifont
- pack .ctop.top.lbar.flabel -side left -fill y
+ .tf.bar.findloc configure -font $uifont
+ .tf.bar.findloc.menu configure -font $uifont
+ pack .tf.bar.findloc -side right
+ pack .tf.bar.findtype -side right
+
+ # build up the bottom bar of upper window
+ label .tf.lbar.flabel -text "Highlight: Commits " \
+ -font $uifont
+ pack .tf.lbar.flabel -side left -fill y
set gdttype "touching paths:"
- set gm [tk_optionMenu .ctop.top.lbar.gdttype gdttype "touching paths:" \
- "adding/removing string:"]
+ set gm [tk_optionMenu .tf.lbar.gdttype gdttype "touching paths:" \
+ "adding/removing string:"]
trace add variable gdttype write hfiles_change
$gm conf -font $uifont
- .ctop.top.lbar.gdttype conf -font $uifont
- pack .ctop.top.lbar.gdttype -side left -fill y
- entry .ctop.top.lbar.fent -width 25 -font $textfont \
+ .tf.lbar.gdttype conf -font $uifont
+ pack .tf.lbar.gdttype -side left -fill y
+ entry .tf.lbar.fent -width 25 -font $textfont \
-textvariable highlight_files
trace add variable highlight_files write hfiles_change
- lappend entries .ctop.top.lbar.fent
- pack .ctop.top.lbar.fent -side left -fill x -expand 1
- label .ctop.top.lbar.vlabel -text " OR in view" -font $uifont
- pack .ctop.top.lbar.vlabel -side left -fill y
+ lappend entries .tf.lbar.fent
+ pack .tf.lbar.fent -side left -fill x -expand 1
+ label .tf.lbar.vlabel -text " OR in view" -font $uifont
+ pack .tf.lbar.vlabel -side left -fill y
global viewhlmenu selectedhlview
- set viewhlmenu [tk_optionMenu .ctop.top.lbar.vhl selectedhlview None]
+ set viewhlmenu [tk_optionMenu .tf.lbar.vhl selectedhlview None]
$viewhlmenu entryconf None -command delvhighlight
$viewhlmenu conf -font $uifont
- .ctop.top.lbar.vhl conf -font $uifont
- pack .ctop.top.lbar.vhl -side left -fill y
- label .ctop.top.lbar.rlabel -text " OR " -font $uifont
- pack .ctop.top.lbar.rlabel -side left -fill y
+ .tf.lbar.vhl conf -font $uifont
+ pack .tf.lbar.vhl -side left -fill y
+ label .tf.lbar.rlabel -text " OR " -font $uifont
+ pack .tf.lbar.rlabel -side left -fill y
global highlight_related
- set m [tk_optionMenu .ctop.top.lbar.relm highlight_related None \
- "Descendent" "Not descendent" "Ancestor" "Not ancestor"]
+ set m [tk_optionMenu .tf.lbar.relm highlight_related None \
+ "Descendent" "Not descendent" "Ancestor" "Not ancestor"]
$m conf -font $uifont
- .ctop.top.lbar.relm conf -font $uifont
+ .tf.lbar.relm conf -font $uifont
trace add variable highlight_related write vrel_change
- pack .ctop.top.lbar.relm -side left -fill y
-
- panedwindow .ctop.cdet -orient horizontal
- .ctop add .ctop.cdet
- frame .ctop.cdet.left
- frame .ctop.cdet.left.bot
- pack .ctop.cdet.left.bot -side bottom -fill x
- button .ctop.cdet.left.bot.search -text "Search" -command dosearch \
+ pack .tf.lbar.relm -side left -fill y
+
+ # Finish putting the upper half of the viewer together
+ pack .tf.lbar -in .tf -side bottom -fill x
+ pack .tf.bar -in .tf -side bottom -fill x
+ pack .tf.histframe -fill both -side top -expand 1
+ .ctop add .tf
+ .ctop paneconfigure .tf -height $geometry(topheight)
+ .ctop paneconfigure .tf -width $geometry(topwidth)
+
+ # now build up the bottom
+ panedwindow .pwbottom -orient horizontal
+
+ # lower left, a text box over search bar, scroll bar to the right
+ # if we know window height, then that will set the lower text height, otherwise
+ # we set lower text height which will drive window height
+ if {[info exists geometry(main)]} {
+ frame .bleft -width $geometry(botwidth)
+ } else {
+ frame .bleft -width $geometry(botwidth) -height $geometry(botheight)
+ }
+ frame .bleft.top
+
+ button .bleft.top.search -text "Search" -command dosearch \
-font $uifont
- pack .ctop.cdet.left.bot.search -side left -padx 5
- set sstring .ctop.cdet.left.bot.sstring
+ pack .bleft.top.search -side left -padx 5
+ set sstring .bleft.top.sstring
entry $sstring -width 20 -font $textfont -textvariable searchstring
lappend entries $sstring
trace add variable searchstring write incrsearch
pack $sstring -side left -expand 1 -fill x
- set ctext .ctop.cdet.left.ctext
+ set ctext .bleft.ctext
text $ctext -background $bgcolor -foreground $fgcolor \
-state disabled -font $textfont \
- -width $geometry(ctextw) -height $geometry(ctexth) \
-yscrollcommand scrolltext -wrap none
- scrollbar .ctop.cdet.left.sb -command "$ctext yview"
- pack .ctop.cdet.left.sb -side right -fill y
+ scrollbar .bleft.sb -command "$ctext yview"
+ pack .bleft.top -side top -fill x
+ pack .bleft.sb -side right -fill y
pack $ctext -side left -fill both -expand 1
- .ctop.cdet add .ctop.cdet.left
lappend bglist $ctext
lappend fglist $ctext
@@ -620,36 +640,46 @@ proc makewindow {} {
$ctext tag conf msep -font [concat $textfont bold]
$ctext tag conf found -back yellow
- frame .ctop.cdet.right
- frame .ctop.cdet.right.mode
- radiobutton .ctop.cdet.right.mode.patch -text "Patch" \
+ .pwbottom add .bleft
+ .pwbottom paneconfigure .bleft -width $geometry(botwidth)
+
+ # lower right
+ frame .bright
+ frame .bright.mode
+ radiobutton .bright.mode.patch -text "Patch" \
-command reselectline -variable cmitmode -value "patch"
- radiobutton .ctop.cdet.right.mode.tree -text "Tree" \
+ radiobutton .bright.mode.tree -text "Tree" \
-command reselectline -variable cmitmode -value "tree"
- grid .ctop.cdet.right.mode.patch .ctop.cdet.right.mode.tree -sticky ew
- pack .ctop.cdet.right.mode -side top -fill x
- set cflist .ctop.cdet.right.cfiles
+ grid .bright.mode.patch .bright.mode.tree -sticky ew
+ pack .bright.mode -side top -fill x
+ set cflist .bright.cfiles
set indent [font measure $mainfont "nn"]
- text $cflist -width $geometry(cflistw) \
+ text $cflist \
-background $bgcolor -foreground $fgcolor \
-font $mainfont \
-tabs [list $indent [expr {2 * $indent}]] \
- -yscrollcommand ".ctop.cdet.right.sb set" \
+ -yscrollcommand ".bright.sb set" \
-cursor [. cget -cursor] \
-spacing1 1 -spacing3 1
lappend bglist $cflist
lappend fglist $cflist
- scrollbar .ctop.cdet.right.sb -command "$cflist yview"
- pack .ctop.cdet.right.sb -side right -fill y
+ scrollbar .bright.sb -command "$cflist yview"
+ pack .bright.sb -side right -fill y
pack $cflist -side left -fill both -expand 1
$cflist tag configure highlight \
-background [$cflist cget -selectbackground]
$cflist tag configure bold -font [concat $mainfont bold]
- .ctop.cdet add .ctop.cdet.right
- bind .ctop.cdet <Configure> {resizecdetpanes %W %w}
- pack .ctop -side top -fill both -expand 1
+ .pwbottom add .bright
+ .ctop add .pwbottom
+
+ # restore window position if known
+ if {[info exists geometry(main)]} {
+ wm geometry . "$geometry(main)"
+ }
+ bind .pwbottom <Configure> {resizecdetpanes %W %w}
+ pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y}
#bindall <B1-Motion> {selcanvline %W %x %y}
bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
@@ -699,7 +729,7 @@ proc makewindow {} {
bind . <Control-KP_Add> {incrfont 1}
bind . <Control-minus> {incrfont -1}
bind . <Control-KP_Subtract> {incrfont -1}
- bind . <Destroy> {savestuff %W}
+ wm protocol . WM_DELETE_WINDOW doquit
bind . <Button-1> "click %W"
bind $fstring <Key-Return> dofind
bind $sha1entry <Key-Return> gotocommit
@@ -802,18 +832,15 @@ proc savestuff {w} {
puts $f [list set fgcolor $fgcolor]
puts $f [list set colors $colors]
puts $f [list set diffcolors $diffcolors]
- puts $f "set geometry(width) [winfo width .ctop]"
- puts $f "set geometry(height) [winfo height .ctop]"
- puts $f "set geometry(canv1) [expr {[winfo width $canv]-2}]"
- puts $f "set geometry(canv2) [expr {[winfo width $canv2]-2}]"
- puts $f "set geometry(canv3) [expr {[winfo width $canv3]-2}]"
- puts $f "set geometry(canvh) [expr {[winfo height $canv]-2}]"
- set wid [expr {([winfo width $ctext] - 8) \
- / [font measure $textfont "0"]}]
- puts $f "set geometry(ctextw) $wid"
- set wid [expr {([winfo width $cflist] - 11) \
- / [font measure [$cflist cget -font] "0"]}]
- puts $f "set geometry(cflistw) $wid"
+
+ puts $f "set geometry(main) [wm geometry .]"
+ puts $f "set geometry(topwidth) [winfo width .tf]"
+ puts $f "set geometry(topheight) [winfo height .tf]"
+ puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
+ puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
+ puts $f "set geometry(botwidth) [winfo width .bleft]"
+ puts $f "set geometry(botheight) [winfo height .bleft]"
+
puts -nonewline $f "set permviews {"
for {set v 0} {$v < $nextviewnum} {incr v} {
if {$viewperm($v)} {
@@ -1402,7 +1429,7 @@ proc newview {ishighlight} {
set newviewname($nextviewnum) "View $nextviewnum"
set newviewperm($nextviewnum) 0
set newviewargs($nextviewnum) [shellarglist $revtreeargs]
- vieweditor $top $nextviewnum "Gitk view definition"
+ vieweditor $top $nextviewnum "Gitk view definition"
}
proc editview {} {
@@ -3897,7 +3924,7 @@ proc selectline {l isnew} {
}
$ctext insert end "\n"
}
-
+
set headers {}
set olds [lindex $parentlist $l]
if {[llength $olds] > 1} {
@@ -4006,7 +4033,7 @@ proc selnextpage {dir} {
set l [expr $numcommits - 1]
}
unmarkmatches
- selectline $l 1
+ selectline $l 1
}
proc unselectline {} {
@@ -4043,11 +4070,11 @@ proc addtohistory {cmd} {
}
incr historyindex
if {$historyindex > 1} {
- .ctop.top.bar.leftbut conf -state normal
+ .tf.bar.leftbut conf -state normal
} else {
- .ctop.top.bar.leftbut conf -state disabled
+ .tf.bar.leftbut conf -state disabled
}
- .ctop.top.bar.rightbut conf -state disabled
+ .tf.bar.rightbut conf -state disabled
}
proc godo {elt} {
@@ -4067,10 +4094,10 @@ proc goback {} {
if {$historyindex > 1} {
incr historyindex -1
godo [lindex $history [expr {$historyindex - 1}]]
- .ctop.top.bar.rightbut conf -state normal
+ .tf.bar.rightbut conf -state normal
}
if {$historyindex <= 1} {
- .ctop.top.bar.leftbut conf -state disabled
+ .tf.bar.leftbut conf -state disabled
}
}
@@ -4081,10 +4108,10 @@ proc goforw {} {
set cmd [lindex $history $historyindex]
incr historyindex
godo $cmd
- .ctop.top.bar.leftbut conf -state normal
+ .tf.bar.leftbut conf -state normal
}
if {$historyindex >= [llength $history]} {
- .ctop.top.bar.rightbut conf -state disabled
+ .tf.bar.rightbut conf -state disabled
}
}
@@ -4591,7 +4618,7 @@ proc searchmarkvisible {doall} {
proc scrolltext {f0 f1} {
global searchstring
- .ctop.cdet.left.sb set $f0 $f1
+ .bleft.sb set $f0 $f1
if {$searchstring ne {}} {
searchmarkvisible 0
}
@@ -5776,6 +5803,7 @@ proc showtag {tag isnew} {
proc doquit {} {
global stopped
set stopped 100
+ savestuff .
destroy .
}
@@ -6193,7 +6221,7 @@ set wrcomcmd "git diff-tree --stdin -p --pretty"
set gitencoding {}
catch {
- set gitencoding [exec git repo-config --get i18n.commitencoding]
+ set gitencoding [exec git config --get i18n.commitencoding]
}
if {$gitencoding == ""} {
set gitencoding "utf-8"
@@ -6293,6 +6321,7 @@ set stuffsaved 0
set patchnum 0
setcoords
makewindow
+wm title . "[file tail $argv0]: [file tail [pwd]]"
readrefs
if {$cmdline_files ne {} || $revtreeargs ne {}} {
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 88af2e6380..653ca3cc60 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -834,7 +834,7 @@ sub file_type_long {
## ----------------------------------------------------------------------
## functions returning short HTML fragments, or transforming HTML fragments
-## which don't beling to other sections
+## which don't belong to other sections
# format line of commit message.
sub format_log_line_html {
@@ -986,7 +986,7 @@ sub git_get_project_config {
$key =~ s/^gitweb\.//;
return if ($key =~ m/\W/);
- my @x = (git_cmd(), 'repo-config');
+ my @x = (git_cmd(), 'config');
if (defined $type) { push @x, $type; }
push @x, "--get";
push @x, "gitweb.$key";
@@ -1690,7 +1690,7 @@ sub git_header_html {
my $title = "$site_name";
if (defined $project) {
- $title .= " - $project";
+ $title .= " - " . to_utf8($project);
if (defined $action) {
$title .= "/$action";
if (defined $file_name) {
@@ -1963,7 +1963,7 @@ sub git_print_page_path {
print "<div class=\"page_path\">";
print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
- -title => 'tree root'}, "[$project]");
+ -title => 'tree root'}, to_utf8("[$project]"));
print " / ";
if (defined $name) {
my @dirname = split '/', $name;
@@ -3610,7 +3610,7 @@ sub git_snapshot {
$hash = git_get_head_hash($project);
}
- my $filename = basename($project) . "-$hash.tar.$suffix";
+ my $filename = to_utf8(basename($project)) . "-$hash.tar.$suffix";
print $cgi->header(
-type => "application/$ctype",
diff --git a/help.c b/help.c
index 341b9e370e..b6674635a2 100644
--- a/help.c
+++ b/help.c
@@ -168,8 +168,8 @@ static void list_common_cmds_help(void)
puts("The most commonly used git commands are:");
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
- printf(" %s", common_cmds[i].name);
- mput_char(' ', longest - strlen(common_cmds[i].name) + 4);
+ printf(" %s ", common_cmds[i].name);
+ mput_char(' ', longest - strlen(common_cmds[i].name));
puts(common_cmds[i].help);
}
puts("(use 'git help -a' to get a list of all installed git commands)");
diff --git a/http-fetch.c b/http-fetch.c
index 67dfb0a033..9f790a08e5 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1003,7 +1003,6 @@ int main(int argc, const char **argv)
int arg = 1;
int rc = 0;
- setup_ident();
setup_git_directory();
git_config(git_default_config);
@@ -1070,7 +1069,7 @@ int main(int argc, const char **argv)
fprintf(stderr,
"Some loose object were found to be corrupt, but they might be just\n"
"a false '404 Not Found' error message sent with incorrect HTTP\n"
-"status code. Suggest running git fsck-objects.\n");
+"status code. Suggest running git-fsck.\n");
}
return rc;
}
diff --git a/http-push.c b/http-push.c
index 0a15f53782..b128c0146c 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2299,7 +2299,6 @@ int main(int argc, char **argv)
struct ref *ref;
setup_git_directory();
- setup_ident();
remote = xcalloc(sizeof(*remote), 1);
diff --git a/ident.c b/ident.c
index 6ad8fedd60..bb03bddd34 100644
--- a/ident.c
+++ b/ident.c
@@ -43,19 +43,13 @@ static void copy_gecos(struct passwd *w, char *name, int sz)
}
-int setup_ident(void)
+static void copy_email(struct passwd *pw)
{
- int len;
- struct passwd *pw = getpwuid(getuid());
-
- if (!pw)
- die("You don't exist. Go away!");
-
- /* Get the name ("gecos") */
- copy_gecos(pw, git_default_name, sizeof(git_default_name));
-
- /* Make up a fake email address (name + '@' + hostname [+ '.' + domainname]) */
- len = strlen(pw->pw_name);
+ /*
+ * Make up a fake email address
+ * (name + '@' + hostname [+ '.' + domainname])
+ */
+ int len = strlen(pw->pw_name);
if (len > sizeof(git_default_email)/2)
die("Your sysadmin must hate you!");
memcpy(git_default_email, pw->pw_name, len);
@@ -68,13 +62,37 @@ int setup_ident(void)
len = strlen(git_default_email);
git_default_email[len++] = '.';
if (he && (domainname = strchr(he->h_name, '.')))
- strlcpy(git_default_email + len, domainname + 1, sizeof(git_default_email) - len);
+ strlcpy(git_default_email + len, domainname + 1,
+ sizeof(git_default_email) - len);
else
- strlcpy(git_default_email + len, "(none)", sizeof(git_default_email) - len);
+ strlcpy(git_default_email + len, "(none)",
+ sizeof(git_default_email) - len);
+ }
+}
+
+static void setup_ident(void)
+{
+ struct passwd *pw = NULL;
+
+ /* Get the name ("gecos") */
+ if (!git_default_name[0]) {
+ pw = getpwuid(getuid());
+ if (!pw)
+ die("You don't exist. Go away!");
+ copy_gecos(pw, git_default_name, sizeof(git_default_name));
}
+
+ if (!git_default_email[0]) {
+ if (!pw)
+ pw = getpwuid(getuid());
+ if (!pw)
+ die("You don't exist. Go away!");
+ copy_email(pw);
+ }
+
/* And set the default date */
- datestamp(git_default_date, sizeof(git_default_date));
- return 0;
+ if (!git_default_date[0])
+ datestamp(git_default_date, sizeof(git_default_date));
}
static int add_raw(char *buf, int size, int offset, const char *str)
@@ -160,32 +178,42 @@ static const char *env_hint =
"\n"
"Run\n"
"\n"
-" git repo-config user.email \"you@email.com\"\n"
-" git repo-config user.name \"Your Name\"\n"
+" git config user.email \"you@email.com\"\n"
+" git config user.name \"Your Name\"\n"
"\n"
"To set the identity in this repository.\n"
"Add --global to set your account\'s default\n"
"\n";
-static const char *get_ident(const char *name, const char *email,
- const char *date_str, int error_on_no_name)
+const char *fmt_ident(const char *name, const char *email,
+ const char *date_str, int error_on_no_name)
{
static char buffer[1000];
char date[50];
int i;
+ setup_ident();
if (!name)
name = git_default_name;
if (!email)
email = git_default_email;
if (!*name) {
- if (name == git_default_name && env_hint) {
+ struct passwd *pw;
+
+ if (0 <= error_on_no_name &&
+ name == git_default_name && env_hint) {
fprintf(stderr, env_hint, au_env, co_env);
env_hint = NULL; /* warn only once, for "git-var -l" */
}
- if (error_on_no_name)
+ if (0 < error_on_no_name)
die("empty ident %s <%s> not allowed", name, email);
+ pw = getpwuid(getuid());
+ if (!pw)
+ die("You don't exist. Go away!");
+ strlcpy(git_default_name, pw->pw_name,
+ sizeof(git_default_name));
+ name = git_default_name;
}
strcpy(date, git_default_date);
@@ -205,7 +233,7 @@ static const char *get_ident(const char *name, const char *email,
const char *git_author_info(int error_on_no_name)
{
- return get_ident(getenv("GIT_AUTHOR_NAME"),
+ return fmt_ident(getenv("GIT_AUTHOR_NAME"),
getenv("GIT_AUTHOR_EMAIL"),
getenv("GIT_AUTHOR_DATE"),
error_on_no_name);
@@ -213,23 +241,8 @@ const char *git_author_info(int error_on_no_name)
const char *git_committer_info(int error_on_no_name)
{
- return get_ident(getenv("GIT_COMMITTER_NAME"),
+ return fmt_ident(getenv("GIT_COMMITTER_NAME"),
getenv("GIT_COMMITTER_EMAIL"),
getenv("GIT_COMMITTER_DATE"),
error_on_no_name);
}
-
-void ignore_missing_committer_name()
-{
- /* If we did not get a name from the user's gecos entry then
- * git_default_name is empty; so instead load the username
- * into it as a 'good enough for now' approximation of who
- * this user is.
- */
- if (!*git_default_name) {
- struct passwd *pw = getpwuid(getuid());
- if (!pw)
- die("You don't exist. Go away!");
- strlcpy(git_default_name, pw->pw_name, sizeof(git_default_name));
- }
-}
diff --git a/index-pack.c b/index-pack.c
index 8d10d6ba24..72e0962415 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -814,7 +814,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
char buf[48];
int len = snprintf(buf, sizeof(buf), "%s\t%s\n",
report, sha1_to_hex(sha1));
- write_in_full(1, buf, len);
+ write_or_die(1, buf, len);
/*
* Let's just mimic git-unpack-objects here and write
diff --git a/local-fetch.c b/local-fetch.c
index cf99cb72dd..7cfe8b3587 100644
--- a/local-fetch.c
+++ b/local-fetch.c
@@ -210,7 +210,6 @@ int main(int argc, const char **argv)
char **commit_id;
int arg = 1;
- setup_ident();
setup_git_directory();
git_config(git_default_config);
diff --git a/log-tree.c b/log-tree.c
index 35be33aaf7..ac86194047 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -2,6 +2,7 @@
#include "diff.h"
#include "commit.h"
#include "log-tree.h"
+#include "reflog-walk.h"
static void show_parents(struct commit *commit, int abbrev)
{
@@ -101,6 +102,16 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
return at;
}
+static unsigned int digits_in_number(unsigned int number)
+{
+ unsigned int i = 10, result = 1;
+ while (i <= number) {
+ i *= 10;
+ result++;
+ }
+ return result;
+}
+
void show_log(struct rev_info *opt, const char *sep)
{
static char this_header[16384];
@@ -142,7 +153,7 @@ void show_log(struct rev_info *opt, const char *sep)
if (*sep != '\n' && opt->commit_format == CMIT_FMT_ONELINE)
extra = "\n";
if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
- putchar('\n');
+ putchar(opt->diffopt.line_termination);
opt->shown_one = 1;
/*
@@ -154,7 +165,8 @@ void show_log(struct rev_info *opt, const char *sep)
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
- "Subject: [PATCH %d/%d] ",
+ "Subject: [PATCH %0*d/%d] ",
+ digits_in_number(opt->total),
opt->nr, opt->total);
subject = buffer;
} else if (opt->total == 0)
@@ -223,6 +235,15 @@ void show_log(struct rev_info *opt, const char *sep)
printf("%s",
diff_get_color(opt->diffopt.color_diff, DIFF_RESET));
putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
+ if (opt->reflog_info) {
+ show_reflog_message(opt->reflog_info,
+ opt->commit_format == CMIT_FMT_ONELINE,
+ opt->relative_date);
+ if (opt->commit_format == CMIT_FMT_ONELINE) {
+ printf("%s", sep);
+ return;
+ }
+ }
}
/*
@@ -261,9 +282,8 @@ int log_tree_diff_flush(struct rev_info *opt)
opt->commit_format != CMIT_FMT_ONELINE) {
int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
if ((pch & opt->diffopt.output_format) == pch)
- printf("---%c", opt->diffopt.line_termination);
- else
- putchar(opt->diffopt.line_termination);
+ printf("---");
+ putchar('\n');
}
}
diff_flush(&opt->diffopt);
diff --git a/merge-recursive.c b/merge-recursive.c
index 87a27e0379..58989424d7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -67,27 +67,75 @@ struct stage_data
unsigned processed:1;
};
+struct output_buffer
+{
+ struct output_buffer *next;
+ char *str;
+};
+
static struct path_list current_file_set = {NULL, 0, 0, 1};
static struct path_list current_directory_set = {NULL, 0, 0, 1};
-static int output_indent = 0;
+static int call_depth = 0;
+static int verbosity = 2;
+static int buffer_output = 1;
+static int do_progress = 1;
+static unsigned last_percent;
+static unsigned merged_cnt;
+static unsigned total_cnt;
+static volatile sig_atomic_t progress_update;
+static struct output_buffer *output_list, *output_end;
+
+static int show (int v)
+{
+ return (!call_depth && verbosity >= v) || verbosity >= 5;
+}
-static void output(const char *fmt, ...)
+static void output(int v, const char *fmt, ...)
{
va_list args;
- int i;
- for (i = output_indent; i--;)
- fputs(" ", stdout);
va_start(args, fmt);
- vfprintf(stdout, fmt, args);
+ if (buffer_output && show(v)) {
+ struct output_buffer *b = xmalloc(sizeof(*b));
+ nfvasprintf(&b->str, fmt, args);
+ b->next = NULL;
+ if (output_end)
+ output_end->next = b;
+ else
+ output_list = b;
+ output_end = b;
+ } else if (show(v)) {
+ int i;
+ for (i = call_depth; i--;)
+ fputs(" ", stdout);
+ vfprintf(stdout, fmt, args);
+ fputc('\n', stdout);
+ }
va_end(args);
- fputc('\n', stdout);
+}
+
+static void flush_output()
+{
+ struct output_buffer *b, *n;
+ for (b = output_list; b; b = n) {
+ int i;
+ for (i = call_depth; i--;)
+ fputs(" ", stdout);
+ fputs(b->str, stdout);
+ fputc('\n', stdout);
+ n = b->next;
+ free(b->str);
+ free(b);
+ }
+ output_list = NULL;
+ output_end = NULL;
}
static void output_commit_title(struct commit *commit)
{
int i;
- for (i = output_indent; i--;)
+ flush_output();
+ for (i = call_depth; i--;)
fputs(" ", stdout);
if (commit->util)
printf("virtual %s\n", (char *)commit->util);
@@ -110,33 +158,37 @@ static void output_commit_title(struct commit *commit)
}
}
-static const char *current_index_file = NULL;
-static const char *original_index_file;
-static const char *temporary_index_file;
-static int cache_dirty = 0;
+static void progress_interval(int signum)
+{
+ progress_update = 1;
+}
-static int flush_cache(void)
+static void setup_progress_signal(void)
{
- /* flush temporary index */
- struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
- int fd = hold_lock_file_for_update(lock, current_index_file, 1);
- if (write_cache(fd, active_cache, active_nr) ||
- close(fd) || commit_lock_file(lock))
- die ("unable to write %s", current_index_file);
- discard_cache();
- cache_dirty = 0;
- return 0;
+ struct sigaction sa;
+ struct itimerval v;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = progress_interval;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGALRM, &sa, NULL);
+
+ v.it_interval.tv_sec = 1;
+ v.it_interval.tv_usec = 0;
+ v.it_value = v.it_interval;
+ setitimer(ITIMER_REAL, &v, NULL);
}
-static void setup_index(int temp)
+static void display_progress()
{
- current_index_file = temp ? temporary_index_file: original_index_file;
- if (cache_dirty) {
- discard_cache();
- cache_dirty = 0;
+ unsigned percent = total_cnt ? merged_cnt * 100 / total_cnt : 0;
+ if (progress_update || percent != last_percent) {
+ fprintf(stderr, "%4u%% (%u/%u) done\r",
+ percent, merged_cnt, total_cnt);
+ progress_update = 0;
+ last_percent = percent;
}
- unlink(temporary_index_file);
- discard_cache();
}
static struct cache_entry *make_cache_entry(unsigned int mode,
@@ -167,9 +219,6 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
const char *path, int stage, int refresh, int options)
{
struct cache_entry *ce;
- if (!cache_dirty)
- read_cache_from(current_index_file);
- cache_dirty++;
ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, refresh);
if (!ce)
return error("cache_addinfo failed: %s", strerror(cache_errno));
@@ -187,26 +236,6 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
*/
static int index_only = 0;
-static int git_read_tree(struct tree *tree)
-{
- int rc;
- struct object_list *trees = NULL;
- struct unpack_trees_options opts;
-
- if (cache_dirty)
- die("read-tree with dirty cache");
-
- memset(&opts, 0, sizeof(opts));
- object_list_append(&tree->object, &trees);
- rc = unpack_trees(trees, &opts);
- cache_tree_free(&active_cache_tree);
-
- if (rc == 0)
- cache_dirty = 1;
-
- return rc;
-}
-
static int git_merge_trees(int index_only,
struct tree *common,
struct tree *head,
@@ -216,11 +245,6 @@ static int git_merge_trees(int index_only,
struct object_list *trees = NULL;
struct unpack_trees_options opts;
- if (!cache_dirty) {
- read_cache_from(current_index_file);
- cache_dirty = 1;
- }
-
memset(&opts, 0, sizeof(opts));
if (index_only)
opts.index_only = 1;
@@ -236,39 +260,37 @@ static int git_merge_trees(int index_only,
rc = unpack_trees(trees, &opts);
cache_tree_free(&active_cache_tree);
-
- cache_dirty = 1;
-
return rc;
}
+static int unmerged_index(void)
+{
+ int i;
+ for (i = 0; i < active_nr; i++) {
+ struct cache_entry *ce = active_cache[i];
+ if (ce_stage(ce))
+ return 1;
+ }
+ return 0;
+}
+
static struct tree *git_write_tree(void)
{
struct tree *result = NULL;
- if (cache_dirty) {
- unsigned i;
- for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce))
- return NULL;
- }
- } else
- read_cache_from(current_index_file);
+ if (unmerged_index())
+ return NULL;
if (!active_cache_tree)
active_cache_tree = cache_tree();
if (!cache_tree_fully_valid(active_cache_tree) &&
- cache_tree_update(active_cache_tree,
- active_cache, active_nr, 0, 0) < 0)
+ cache_tree_update(active_cache_tree,
+ active_cache, active_nr, 0, 0) < 0)
die("error building trees");
result = lookup_tree(active_cache_tree->sha1);
- flush_cache();
- cache_dirty = 0;
-
return result;
}
@@ -331,14 +353,14 @@ static struct path_list *get_unmerged(void)
int i;
unmerged->strdup_paths = 1;
- if (!cache_dirty) {
- read_cache_from(current_index_file);
- cache_dirty++;
- }
- for (i = 0; i < active_nr; i++) {
+ total_cnt += active_nr;
+
+ for (i = 0; i < active_nr; i++, merged_cnt++) {
struct path_list_item *item;
struct stage_data *e;
struct cache_entry *ce = active_cache[i];
+ if (do_progress)
+ display_progress();
if (!ce_stage(ce))
continue;
@@ -364,7 +386,7 @@ struct rename
};
/*
- * Get information of all renames which occured between 'o_tree' and
+ * Get information of all renames which occurred between 'o_tree' and
* 'tree'. We need the three trees in the merge ('o_tree', 'a_tree' and
* '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.
@@ -469,9 +491,6 @@ static int remove_file(int clean, const char *path, int no_wd)
int update_working_directory = !index_only && !no_wd;
if (update_cache) {
- if (!cache_dirty)
- read_cache_from(current_index_file);
- cache_dirty++;
if (remove_file_from_cache(path))
return -1;
}
@@ -705,13 +724,13 @@ static void conflict_rename_rename(struct rename *ren1,
const char *dst_name2 = ren2_dst;
if (path_list_has_path(&current_directory_set, ren1_dst)) {
dst_name1 = del[delp++] = unique_path(ren1_dst, branch1);
- output("%s is a directory in %s adding as %s instead",
+ output(1, "%s is a directory in %s added as %s instead",
ren1_dst, branch2, dst_name1);
remove_file(0, ren1_dst, 0);
}
if (path_list_has_path(&current_directory_set, ren2_dst)) {
dst_name2 = del[delp++] = unique_path(ren2_dst, branch2);
- output("%s is a directory in %s adding as %s instead",
+ output(1, "%s is a directory in %s added as %s instead",
ren2_dst, branch1, dst_name2);
remove_file(0, ren2_dst, 0);
}
@@ -725,7 +744,7 @@ static void conflict_rename_dir(struct rename *ren1,
const char *branch1)
{
char *new_path = unique_path(ren1->pair->two->path, branch1);
- output("Renaming %s to %s instead", ren1->pair->one->path, new_path);
+ output(1, "Renamed %s to %s instead", ren1->pair->one->path, new_path);
remove_file(0, ren1->pair->two->path, 0);
update_file(0, ren1->pair->two->sha1, ren1->pair->two->mode, new_path);
free(new_path);
@@ -738,7 +757,7 @@ static void conflict_rename_rename_2(struct rename *ren1,
{
char *new_path1 = unique_path(ren1->pair->two->path, branch1);
char *new_path2 = unique_path(ren2->pair->two->path, branch2);
- output("Renaming %s to %s and %s to %s instead",
+ output(1, "Renamed %s to %s and %s to %s instead",
ren1->pair->one->path, new_path1,
ren2->pair->one->path, new_path2);
remove_file(0, ren1->pair->two->path, 0);
@@ -831,7 +850,7 @@ static int process_renames(struct path_list *a_renames,
ren2->processed = 1;
if (strcmp(ren1_dst, ren2_dst) != 0) {
clean_merge = 0;
- output("CONFLICT (rename/rename): "
+ output(1, "CONFLICT (rename/rename): "
"Rename %s->%s in branch %s "
"rename %s->%s in %s",
src, ren1_dst, branch1,
@@ -846,13 +865,13 @@ static int process_renames(struct path_list *a_renames,
branch1,
branch2);
if (mfi.merge || !mfi.clean)
- output("Renaming %s->%s", src, ren1_dst);
+ output(1, "Renamed %s->%s", src, ren1_dst);
if (mfi.merge)
- output("Auto-merging %s", ren1_dst);
+ output(2, "Auto-merged %s", ren1_dst);
if (!mfi.clean) {
- output("CONFLICT (content): merge conflict in %s",
+ output(1, "CONFLICT (content): merge conflict in %s",
ren1_dst);
clean_merge = 0;
@@ -872,7 +891,7 @@ static int process_renames(struct path_list *a_renames,
struct diff_filespec src_other, dst_other;
int try_merge, stage = a_renames == renames1 ? 3: 2;
- remove_file(1, ren1_src, index_only);
+ remove_file(1, ren1_src, index_only || stage == 3);
hashcpy(src_other.sha1, ren1->src_entry->stages[stage].sha);
src_other.mode = ren1->src_entry->stages[stage].mode;
@@ -883,14 +902,14 @@ static int process_renames(struct path_list *a_renames,
if (path_list_has_path(&current_directory_set, ren1_dst)) {
clean_merge = 0;
- output("CONFLICT (rename/directory): Rename %s->%s in %s "
+ output(1, "CONFLICT (rename/directory): Renamed %s->%s in %s "
" directory %s added in %s",
ren1_src, ren1_dst, branch1,
ren1_dst, branch2);
conflict_rename_dir(ren1, branch1);
} else if (sha_eq(src_other.sha1, null_sha1)) {
clean_merge = 0;
- output("CONFLICT (rename/delete): Rename %s->%s in %s "
+ output(1, "CONFLICT (rename/delete): Renamed %s->%s in %s "
"and deleted in %s",
ren1_src, ren1_dst, branch1,
branch2);
@@ -899,19 +918,19 @@ static int process_renames(struct path_list *a_renames,
const char *new_path;
clean_merge = 0;
try_merge = 1;
- output("CONFLICT (rename/add): Rename %s->%s in %s. "
+ output(1, "CONFLICT (rename/add): Renamed %s->%s in %s. "
"%s added in %s",
ren1_src, ren1_dst, branch1,
ren1_dst, branch2);
new_path = unique_path(ren1_dst, branch2);
- output("Adding as %s instead", new_path);
+ output(1, "Added as %s instead", new_path);
update_file(0, dst_other.sha1, dst_other.mode, new_path);
} else if ((item = path_list_lookup(ren1_dst, renames2Dst))) {
ren2 = item->util;
clean_merge = 0;
ren2->processed = 1;
- output("CONFLICT (rename/rename): Rename %s->%s in %s. "
- "Rename %s->%s in %s",
+ output(1, "CONFLICT (rename/rename): Renamed %s->%s in %s. "
+ "Renamed %s->%s in %s",
ren1_src, ren1_dst, branch1,
ren2->pair->one->path, ren2->pair->two->path, branch2);
conflict_rename_rename_2(ren1, branch1, ren2, branch2);
@@ -935,11 +954,11 @@ static int process_renames(struct path_list *a_renames,
a_branch, b_branch);
if (mfi.merge || !mfi.clean)
- output("Renaming %s => %s", ren1_src, ren1_dst);
+ output(1, "Renamed %s => %s", ren1_src, ren1_dst);
if (mfi.merge)
- output("Auto-merging %s", ren1_dst);
+ output(2, "Auto-merged %s", ren1_dst);
if (!mfi.clean) {
- output("CONFLICT (rename/modify): Merge conflict in %s",
+ output(1, "CONFLICT (rename/modify): Merge conflict in %s",
ren1_dst);
clean_merge = 0;
@@ -954,8 +973,6 @@ static int process_renames(struct path_list *a_renames,
path_list_clear(&a_by_dst, 0);
path_list_clear(&b_by_dst, 0);
- if (cache_dirty)
- flush_cache();
return clean_merge;
}
@@ -989,20 +1006,20 @@ static int process_entry(const char *path, struct stage_data *entry,
/* Deleted in both or deleted in one and
* unchanged in the other */
if (a_sha)
- output("Removing %s", path);
+ output(2, "Removed %s", path);
/* do not touch working file if it did not exist */
remove_file(1, path, !a_sha);
} else {
/* Deleted in one and changed in the other */
clean_merge = 0;
if (!a_sha) {
- output("CONFLICT (delete/modify): %s deleted in %s "
+ output(1, "CONFLICT (delete/modify): %s deleted in %s "
"and modified in %s. Version %s of %s left in tree.",
path, branch1,
branch2, branch2, path);
update_file(0, b_sha, b_mode, path);
} else {
- output("CONFLICT (delete/modify): %s deleted in %s "
+ output(1, "CONFLICT (delete/modify): %s deleted in %s "
"and modified in %s. Version %s of %s left in tree.",
path, branch2,
branch1, branch1, path);
@@ -1035,13 +1052,13 @@ static int process_entry(const char *path, struct stage_data *entry,
if (path_list_has_path(&current_directory_set, path)) {
const char *new_path = unique_path(path, add_branch);
clean_merge = 0;
- output("CONFLICT (%s): There is a directory with name %s in %s. "
- "Adding %s as %s",
+ output(1, "CONFLICT (%s): There is a directory with name %s in %s. "
+ "Added %s as %s",
conf, path, other_branch, path, new_path);
remove_file(0, path, 0);
update_file(0, sha, mode, new_path);
} else {
- output("Adding %s", path);
+ output(2, "Added %s", path);
update_file(1, sha, mode, path);
}
} else if (a_sha && b_sha) {
@@ -1055,7 +1072,7 @@ static int process_entry(const char *path, struct stage_data *entry,
reason = "add/add";
o_sha = (unsigned char *)null_sha1;
}
- output("Auto-merging %s", path);
+ output(2, "Auto-merged %s", path);
o.path = a.path = b.path = (char *)path;
hashcpy(o.sha1, o_sha);
o.mode = o_mode;
@@ -1071,7 +1088,7 @@ static int process_entry(const char *path, struct stage_data *entry,
update_file(1, mfi.sha, mfi.mode, path);
else {
clean_merge = 0;
- output("CONFLICT (%s): Merge conflict in %s",
+ output(1, "CONFLICT (%s): Merge conflict in %s",
reason, path);
if (index_only)
@@ -1083,9 +1100,6 @@ static int process_entry(const char *path, struct stage_data *entry,
} else
die("Fatal merge failure, shouldn't happen.");
- if (cache_dirty)
- flush_cache();
-
return clean_merge;
}
@@ -1098,7 +1112,7 @@ static int merge_trees(struct tree *head,
{
int code, clean;
if (sha_eq(common->object.sha1, merge->object.sha1)) {
- output("Already uptodate!");
+ output(0, "Already uptodate!");
*result = head;
return 1;
}
@@ -1110,9 +1124,7 @@ static int merge_trees(struct tree *head,
sha1_to_hex(head->object.sha1),
sha1_to_hex(merge->object.sha1));
- *result = git_write_tree();
-
- if (!*result) {
+ if (unmerged_index()) {
struct path_list *entries, *re_head, *re_merge;
int i;
path_list_clear(&current_file_set, 1);
@@ -1125,30 +1137,27 @@ static int merge_trees(struct tree *head,
re_merge = get_renames(merge, common, head, merge, entries);
clean = process_renames(re_head, re_merge,
branch1, branch2);
- for (i = 0; i < entries->nr; i++) {
+ total_cnt += entries->nr;
+ for (i = 0; i < entries->nr; i++, merged_cnt++) {
const char *path = entries->items[i].path;
struct stage_data *e = entries->items[i].util;
- if (e->processed)
- continue;
- if (!process_entry(path, e, branch1, branch2))
+ if (!e->processed
+ && !process_entry(path, e, branch1, branch2))
clean = 0;
+ if (do_progress)
+ display_progress();
}
path_list_clear(re_merge, 0);
path_list_clear(re_head, 0);
path_list_clear(entries, 1);
- if (clean || index_only)
- *result = git_write_tree();
- else
- *result = NULL;
- } else {
- clean = 1;
- printf("merging of trees %s and %s resulted in %s\n",
- sha1_to_hex(head->object.sha1),
- sha1_to_hex(merge->object.sha1),
- sha1_to_hex((*result)->object.sha1));
}
+ else
+ clean = 1;
+
+ if (index_only)
+ *result = git_write_tree();
return clean;
}
@@ -1166,33 +1175,36 @@ static struct commit_list *reverse_commit_list(struct commit_list *list)
/*
* Merge the commits h1 and h2, return the resulting virtual
- * commit object and a flag indicating the cleaness of the merge.
+ * commit object and a flag indicating the cleanness of the merge.
*/
static int merge(struct commit *h1,
struct commit *h2,
const char *branch1,
const char *branch2,
- int call_depth /* =0 */,
- struct commit *ancestor /* =None */,
+ struct commit_list *ca,
struct commit **result)
{
- struct commit_list *ca = NULL, *iter;
+ struct commit_list *iter;
struct commit *merged_common_ancestors;
struct tree *mrtree;
int clean;
- output("Merging:");
- output_commit_title(h1);
- output_commit_title(h2);
+ if (show(4)) {
+ output(4, "Merging:");
+ output_commit_title(h1);
+ output_commit_title(h2);
+ }
- if (ancestor)
- commit_list_insert(ancestor, &ca);
- else
- ca = reverse_commit_list(get_merge_bases(h1, h2, 1));
+ if (!ca) {
+ ca = get_merge_bases(h1, h2, 1);
+ ca = reverse_commit_list(ca);
+ }
- output("found %u common ancestor(s):", commit_list_count(ca));
- for (iter = ca; iter; iter = iter->next)
- output_commit_title(iter->item);
+ if (show(5)) {
+ output(5, "found %u common ancestor(s):", commit_list_count(ca));
+ for (iter = ca; iter; iter = iter->next)
+ output_commit_title(iter->item);
+ }
merged_common_ancestors = pop_commit(&ca);
if (merged_common_ancestors == NULL) {
@@ -1201,50 +1213,56 @@ static int merge(struct commit *h1,
tree->object.parsed = 1;
tree->object.type = OBJ_TREE;
- write_sha1_file(NULL, 0, tree_type, tree->object.sha1);
+ pretend_sha1_file(NULL, 0, tree_type, tree->object.sha1);
merged_common_ancestors = make_virtual_commit(tree, "ancestor");
}
for (iter = ca; iter; iter = iter->next) {
- output_indent = call_depth + 1;
+ call_depth++;
/*
* When the merge fails, the result contains files
* with conflict markers. The cleanness flag is
- * ignored, it was never acutally used, as result of
- * merge_trees has always overwritten it: the commited
+ * ignored, it was never actually used, as result of
+ * merge_trees has always overwritten it: the committed
* "conflicts" were already resolved.
*/
+ discard_cache();
merge(merged_common_ancestors, iter->item,
"Temporary merge branch 1",
"Temporary merge branch 2",
- call_depth + 1,
NULL,
&merged_common_ancestors);
- output_indent = call_depth;
+ call_depth--;
if (!merged_common_ancestors)
die("merge returned no commit");
}
- if (call_depth == 0) {
- setup_index(0 /* $GIT_DIR/index */);
+ discard_cache();
+ if (!call_depth) {
+ read_cache();
index_only = 0;
- } else {
- setup_index(1 /* temporary index */);
- git_read_tree(h1->tree);
+ } else
index_only = 1;
- }
clean = merge_trees(h1->tree, h2->tree, merged_common_ancestors->tree,
branch1, branch2, &mrtree);
- if (!ancestor && (clean || index_only)) {
+ if (index_only) {
*result = make_virtual_commit(mrtree, "merged tree");
commit_list_insert(h1, &(*result)->parents);
commit_list_insert(h2, &(*result)->parents->next);
- } else
- *result = NULL;
-
+ }
+ if (!call_depth && do_progress) {
+ /* Make sure we end at 100% */
+ if (!total_cnt)
+ total_cnt = 1;
+ merged_cnt = total_cnt;
+ progress_update = 1;
+ display_progress();
+ fputc('\n', stderr);
+ }
+ flush_output();
return clean;
}
@@ -1278,21 +1296,29 @@ static struct commit *get_ref(const char *ref)
return (struct commit *)object;
}
+static int merge_config(const char *var, const char *value)
+{
+ if (!strcasecmp(var, "merge.verbosity")) {
+ verbosity = git_config_int(var, value);
+ return 0;
+ }
+ return git_default_config(var, value);
+}
+
int main(int argc, char *argv[])
{
- static const char *bases[2];
+ static const char *bases[20];
static unsigned bases_count = 0;
int i, clean;
const char *branch1, *branch2;
struct commit *result, *h1, *h2;
+ struct commit_list *ca = NULL;
+ struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+ int index_fd;
- git_config(git_default_config); /* core.filemode */
- original_index_file = getenv(INDEX_ENVIRONMENT);
-
- if (!original_index_file)
- original_index_file = xstrdup(git_path("index"));
-
- temporary_index_file = xstrdup(git_path("mrg-rcrsv-tmp-idx"));
+ git_config(merge_config);
+ if (getenv("GIT_MERGE_VERBOSITY"))
+ verbosity = strtol(getenv("GIT_MERGE_VERBOSITY"), NULL, 10);
if (argc < 4)
die("Usage: %s <base>... -- <head> <remote> ...\n", argv[0]);
@@ -1305,6 +1331,12 @@ int main(int argc, char *argv[])
}
if (argc - i != 3) /* "--" "<head>" "<remote>" */
die("Not handling anything other than two heads merge.");
+ if (verbosity >= 5) {
+ buffer_output = 0;
+ do_progress = 0;
+ }
+ else
+ do_progress = isatty(1);
branch1 = argv[++i];
branch2 = argv[++i];
@@ -1314,20 +1346,24 @@ int main(int argc, char *argv[])
branch1 = better_branch_name(branch1);
branch2 = better_branch_name(branch2);
- printf("Merging %s with %s\n", branch1, branch2);
- if (bases_count == 1) {
- struct commit *ancestor = get_ref(bases[0]);
- clean = merge(h1, h2, branch1, branch2, 0, ancestor, &result);
- } else
- clean = merge(h1, h2, branch1, branch2, 0, NULL, &result);
+ if (do_progress)
+ setup_progress_signal();
+ if (show(3))
+ printf("Merging %s with %s\n", branch1, branch2);
- if (cache_dirty)
- flush_cache();
+ index_fd = hold_lock_file_for_update(lock, get_index_file(), 1);
+
+ for (i = 0; i < bases_count; i++) {
+ struct commit *ancestor = get_ref(bases[i]);
+ ca = commit_list_insert(ancestor, &ca);
+ }
+ clean = merge(h1, h2, branch1, branch2, ca, &result);
+
+ if (active_cache_changed &&
+ (write_cache(index_fd, active_cache, active_nr) ||
+ close(index_fd) || commit_lock_file(lock)))
+ die ("unable to write %s", get_index_file());
return clean ? 0: 1;
}
-
-/*
-vim: sw=8 noet
-*/
diff --git a/pack.h b/pack.h
index 4814800f28..deb427edbe 100644
--- a/pack.h
+++ b/pack.h
@@ -10,10 +10,43 @@
#define PACK_VERSION 2
#define pack_version_ok(v) ((v) == htonl(2) || (v) == htonl(3))
struct pack_header {
- unsigned int hdr_signature;
- unsigned int hdr_version;
- unsigned int hdr_entries;
+ uint32_t hdr_signature;
+ uint32_t hdr_version;
+ uint32_t hdr_entries;
};
+/*
+ * Packed object index header
+ *
+ * struct pack_idx_header {
+ * uint32_t idx_signature;
+ * uint32_t idx_version;
+ * };
+ *
+ * Note: this header isn't active yet. In future versions of git
+ * we may change the index file format. At that time we would start
+ * the first four bytes of the new index format with this signature,
+ * as all older git binaries would find this value illegal and abort
+ * reading the file.
+ *
+ * This is the case because the number of objects in a packfile
+ * cannot exceed 1,431,660,000 as every object would need at least
+ * 3 bytes of data and the overall packfile cannot exceed 4 GiB due
+ * to the 32 bit offsets used by the index. Clearly the signature
+ * exceeds this maximum.
+ *
+ * Very old git binaries will also compare the first 4 bytes to the
+ * next 4 bytes in the index and abort with a "non-monotonic index"
+ * error if the second 4 byte word is smaller than the first 4
+ * byte word. This would be true in the proposed future index
+ * format as idx_signature would be greater than idx_version.
+ */
+#define PACK_IDX_SIGNATURE 0xff744f63 /* "\377tOc" */
+
extern int verify_pack(struct packed_git *, int);
+
+#define PH_ERROR_EOF (-1)
+#define PH_ERROR_PACK_SIGNATURE (-2)
+#define PH_ERROR_PROTOCOL (-3)
+extern int read_pack_header(int fd, struct pack_header *);
#endif
diff --git a/pager.c b/pager.c
index 4587fbbdb5..5f280ab527 100644
--- a/pager.c
+++ b/pager.c
@@ -1,5 +1,7 @@
#include "cache.h"
+#include <sys/select.h>
+
/*
* This is split up from the rest of git so that we might do
* something different on Windows, for example.
@@ -7,6 +9,16 @@
static void run_pager(const char *pager)
{
+ /*
+ * Work around bug in "less" by not starting it until we
+ * have real input
+ */
+ fd_set in;
+
+ FD_ZERO(&in);
+ FD_SET(0, &in);
+ select(1, &in, NULL, &in, NULL);
+
execlp(pager, pager, NULL);
execl("/bin/sh", "sh", "-c", pager, NULL);
}
diff --git a/path.c b/path.c
index bb5ee7bf99..c5d25a4b90 100644
--- a/path.c
+++ b/path.c
@@ -90,10 +90,11 @@ int git_mkstemp(char *path, size_t len, const char *template)
}
-int validate_symref(const char *path)
+int validate_headref(const char *path)
{
struct stat st;
char *buf, buffer[256];
+ unsigned char sha1[20];
int len, fd;
if (lstat(path, &st) < 0)
@@ -119,14 +120,23 @@ int validate_symref(const char *path)
/*
* Is it a symbolic ref?
*/
- if (len < 4 || memcmp("ref:", buffer, 4))
+ if (len < 4)
return -1;
- buf = buffer + 4;
- len -= 4;
- while (len && isspace(*buf))
- buf++, len--;
- if (len >= 5 && !memcmp("refs/", buf, 5))
+ if (!memcmp("ref:", buffer, 4)) {
+ buf = buffer + 4;
+ len -= 4;
+ while (len && isspace(*buf))
+ buf++, len--;
+ if (len >= 5 && !memcmp("refs/", buf, 5))
+ return 0;
+ }
+
+ /*
+ * Is this a detached HEAD?
+ */
+ if (!get_sha1_hex(buffer, sha1))
return 0;
+
return -1;
}
@@ -241,7 +251,7 @@ char *enter_repo(char *path, int strict)
return NULL;
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
- validate_symref("HEAD") == 0) {
+ validate_headref("HEAD") == 0) {
putenv("GIT_DIR=.");
check_repository_format();
return path;
diff --git a/peek-remote.c b/peek-remote.c
index 353da002b4..ef3c76ce52 100644
--- a/peek-remote.c
+++ b/peek-remote.c
@@ -3,8 +3,8 @@
#include "pkt-line.h"
static const char peek_remote_usage[] =
-"git-peek-remote [--exec=upload-pack] [host:]directory";
-static const char *exec = "git-upload-pack";
+"git-peek-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
+static const char *uploadpack = "git-upload-pack";
static int peek_remote(int fd[2], unsigned flags)
{
@@ -35,8 +35,12 @@ int main(int argc, char **argv)
char *arg = argv[i];
if (*arg == '-') {
+ if (!strncmp("--upload-pack=", arg, 14)) {
+ uploadpack = arg + 14;
+ continue;
+ }
if (!strncmp("--exec=", arg, 7)) {
- exec = arg + 7;
+ uploadpack = arg + 7;
continue;
}
if (!strcmp("--tags", arg)) {
@@ -60,7 +64,7 @@ int main(int argc, char **argv)
if (!dest || i != argc - 1)
usage(peek_remote_usage);
- pid = git_connect(fd, dest, exec);
+ pid = git_connect(fd, dest, uploadpack);
if (pid < 0)
return 1;
ret = peek_remote(fd, flags);
diff --git a/perl/Git.pm b/perl/Git.pm
index 2b26b65bfb..f2c156cde9 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -63,7 +63,7 @@ for doing easily operations which are not totally trivial to do over
the generic command interface.
While some commands can be executed outside of any context (e.g. 'version'
-or 'init-db'), most operations require a repository context, which in practice
+or 'init'), most operations require a repository context, which in practice
means getting an instance of the Git object using the repository() constructor.
(In the future, we will also get a new_repository() constructor.) All commands
called as methods of the object are then executed in the context of the
@@ -275,7 +275,7 @@ sub command {
} else {
my @lines = <$fh>;
- chomp @lines;
+ defined and chomp for @lines;
try {
_cmd_close($fh, $ctx);
} catch Git::Error::Command with {
@@ -354,7 +354,7 @@ sub command_input_pipe {
=item command_close_pipe ( PIPE [, CTX ] )
Close the C<PIPE> as returned from C<command_*_pipe()>, checking
-whether the command finished successfuly. The optional C<CTX> argument
+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 second value returned by C<command_*_pipe()> when
called in array context. The call idiom is:
@@ -482,14 +482,14 @@ sub wc_chdir {
=item config ( VARIABLE )
-Retrieve the configuration C<VARIABLE> in the same manner as C<repo-config>
+Retrieve the configuration C<VARIABLE> in the same manner as C<config>
does. In scalar context requires the variable to be set only one time
(exception is thrown otherwise), in array context returns allows the
variable to be set multiple times and returns all the values.
Must be called on a repository instance.
-This currently wraps command('repo-config') so it is not so fast.
+This currently wraps command('config') so it is not so fast.
=cut
@@ -500,9 +500,9 @@ sub config {
try {
if (wantarray) {
- return $self->command('repo-config', '--get-all', $var);
+ return $self->command('config', '--get-all', $var);
} else {
- return $self->command_oneline('repo-config', '--get', $var);
+ return $self->command_oneline('config', '--get', $var);
}
} catch Git::Error::Command with {
my $E = shift;
@@ -736,13 +736,19 @@ sub _command_common_pipe {
_check_valid_cmd($cmd);
my $fh;
- if ($^O eq '##INSERT_ACTIVESTATE_STRING_HERE##') {
+ if ($^O eq 'MSWin32') {
# ActiveState Perl
#defined $opts{STDERR} and
# warn 'ignoring STDERR option - running w/ ActiveState';
$direction eq '-|' or
die 'input pipe for ActiveState not implemented';
- tie ($fh, 'Git::activestate_pipe', $cmd, @args);
+ # the strange construction with *ACPIPE is just to
+ # explain the tie below that we want to bind to
+ # a handle class, not scalar. It is not known if
+ # it is something specific to ActiveState Perl or
+ # just a Perl quirk.
+ tie (*ACPIPE, 'Git::activestate_pipe', $cmd, @args);
+ $fh = *ACPIPE;
} else {
my $pid = open($fh, $direction);
@@ -809,8 +815,9 @@ sub TIEHANDLE {
# FIXME: This is probably horrible idea and the thing will explode
# at the moment you give it arguments that require some quoting,
# but I have no ActiveState clue... --pasky
- my $cmdline = join " ", @params;
- my @data = qx{$cmdline};
+ # Let's just hope ActiveState Perl does at least the quoting
+ # correctly.
+ my @data = qx{git @params};
bless { i => 0, data => \@data }, $class;
}
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 41687757a7..9b117fd0d7 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -20,6 +20,10 @@ if ($@) {
my %extra;
$extra{DESTDIR} = $ENV{DESTDIR} if $ENV{DESTDIR};
+# redirect stdout, otherwise the message "Writing perl.mak for Git"
+# disrupts the output for the target 'instlibdir'
+open STDOUT, ">&STDERR";
+
WriteMakefile(
NAME => 'Git',
VERSION_FROM => 'Git.pm',
diff --git a/perl/private-Error.pm b/perl/private-Error.pm
index 8fff86699f..11e9cd9a02 100644
--- a/perl/private-Error.pm
+++ b/perl/private-Error.pm
@@ -781,7 +781,7 @@ that is a plain string. (Unless C<$Error::ObjectifyCallback> is modified)
This variable holds a reference to a subroutine that converts errors that
are plain strings to objects. It is used by Error.pm to convert textual
-errors to objects, and can be overrided by the user.
+errors to objects, and can be overridden by the user.
It accepts a single argument which is a hash reference to named parameters.
Currently the only named parameter passed is C<'text'> which is the text
diff --git a/ppc/sha1ppc.S b/ppc/sha1ppc.S
index 140cb53370..f132696ee7 100644
--- a/ppc/sha1ppc.S
+++ b/ppc/sha1ppc.S
@@ -18,7 +18,7 @@
* %r0 - temp
* %r3 - argument (pointer to 5 words of SHA state)
* %r4 - argument (pointer to data to hash)
- * %r5 - Contant K in SHA round (initially number of blocks to hash)
+ * %r5 - Constant K in SHA round (initially number of blocks to hash)
* %r6-%r10 - Working copies of SHA variables A..E (actually E..A order)
* %r11-%r26 - Data being hashed W[].
* %r27-%r31 - Previous copies of A..E, for final add back.
@@ -48,7 +48,7 @@
* E += ROTL(A,5) + F(B,C,D) + W[i] + K; B = ROTL(B,30)
* Then the variables are renamed: (A,B,C,D,E) = (E,A,B,C,D).
*
- * Every 20 rounds, the function F() and the contant K changes:
+ * Every 20 rounds, the function F() and the constant K changes:
* - 20 rounds of f0(b,c,d) = "bit wise b ? c : d" = (^b & d) + (b & c)
* - 20 rounds of f1(b,c,d) = b^c^d = (b^d)^c
* - 20 rounds of f2(b,c,d) = majority(b,c,d) = (b&d) + ((b^d)&c)
@@ -57,7 +57,7 @@
* These are all scheduled for near-optimal performance on a G4.
* The G4 is a 3-issue out-of-order machine with 3 ALUs, but it can only
* *consider* starting the oldest 3 instructions per cycle. So to get
- * maximum performace out of it, you have to treat it as an in-order
+ * maximum performance out of it, you have to treat it as an in-order
* machine. Which means interleaving the computation round t with the
* computation of W[t+4].
*
diff --git a/quote.c b/quote.c
index a418a0f803..fb9e4ca253 100644
--- a/quote.c
+++ b/quote.c
@@ -387,3 +387,37 @@ void python_quote_print(FILE *stream, const char *src)
}
fputc(sq, stream);
}
+
+void tcl_quote_print(FILE *stream, const char *src)
+{
+ char c;
+
+ fputc('"', stream);
+ while ((c = *src++)) {
+ switch (c) {
+ case '[': case ']':
+ case '{': case '}':
+ case '$': case '\\': case '"':
+ fputc('\\', stream);
+ default:
+ fputc(c, stream);
+ break;
+ case '\f':
+ fputs("\\f", stream);
+ break;
+ case '\r':
+ fputs("\\r", stream);
+ break;
+ case '\n':
+ fputs("\\n", stream);
+ break;
+ case '\t':
+ fputs("\\t", stream);
+ break;
+ case '\v':
+ fputs("\\v", stream);
+ break;
+ }
+ }
+ fputc('"', stream);
+}
diff --git a/quote.h b/quote.h
index b55e699750..bdc3610df5 100644
--- a/quote.h
+++ b/quote.h
@@ -55,5 +55,6 @@ extern void write_name_quoted(const char *prefix, int prefix_len,
/* quoting as a string literal for other languages */
extern void perl_quote_print(FILE *stream, const char *src);
extern void python_quote_print(FILE *stream, const char *src);
+extern void tcl_quote_print(FILE *stream, const char *src);
#endif
diff --git a/reachable.c b/reachable.c
index 4dfee1dbe8..01760d7046 100644
--- a/reachable.c
+++ b/reachable.c
@@ -104,7 +104,9 @@ static void walk_commit_list(struct rev_info *revs)
}
}
-static int add_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1, char *datail, void *cb_data)
+static int add_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
{
struct object *object;
struct rev_info *revs = (struct rev_info *)cb_data;
@@ -186,9 +188,9 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog)
/* Add all external refs */
for_each_ref(add_one_ref, revs);
- /* Add all reflog info from refs */
+ /* Add all reflog info */
if (mark_reflog)
- for_each_ref(add_one_reflog, revs);
+ for_each_reflog(add_one_reflog, revs);
/*
* Set up the revision walk - this will move all commits
diff --git a/read-cache.c b/read-cache.c
index 8ecd826e9c..c54a611877 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1010,7 +1010,7 @@ int write_cache(int newfd, struct cache_entry **cache, int entries)
if (data &&
!write_index_ext_header(&c, newfd, CACHE_EXT_TREE, sz) &&
!ce_write(&c, newfd, data, sz))
- ;
+ free(data);
else {
free(data);
return -1;
diff --git a/receive-pack.c b/receive-pack.c
index c176d8fd00..7311c822dd 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -10,6 +10,8 @@
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
static int deny_non_fast_forwards = 0;
+static int receive_unpack_limit = -1;
+static int transfer_unpack_limit = -1;
static int unpack_limit = 100;
static int report_status;
@@ -18,21 +20,22 @@ static int capabilities_sent;
static int receive_pack_config(const char *var, const char *value)
{
- git_default_config(var, value);
-
- if (strcmp(var, "receive.denynonfastforwards") == 0)
- {
+ if (strcmp(var, "receive.denynonfastforwards") == 0) {
deny_non_fast_forwards = git_config_bool(var, value);
return 0;
}
- if (strcmp(var, "receive.unpacklimit") == 0)
- {
- unpack_limit = git_config_int(var, value);
+ if (strcmp(var, "receive.unpacklimit") == 0) {
+ receive_unpack_limit = git_config_int(var, value);
return 0;
}
- return 0;
+ if (strcmp(var, "transfer.unpacklimit") == 0) {
+ transfer_unpack_limit = git_config_int(var, value);
+ return 0;
+ }
+
+ return git_default_config(var, value);
}
static int show_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
@@ -250,20 +253,22 @@ static void read_head_info(void)
static const char *parse_pack_header(struct pack_header *hdr)
{
- char *c = (char*)hdr;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(0, c, remaining);
- if (r <= 0)
- return "eof before pack header was fully read";
- remaining -= r;
- c += r;
- } while (remaining > 0);
- if (hdr->hdr_signature != htonl(PACK_SIGNATURE))
+ switch (read_pack_header(0, hdr)) {
+ case PH_ERROR_EOF:
+ return "eof before pack header was fully read";
+
+ case PH_ERROR_PACK_SIGNATURE:
return "protocol error (pack signature mismatch detected)";
- if (!pack_version_ok(hdr->hdr_version))
+
+ case PH_ERROR_PROTOCOL:
return "protocol error (pack version unsupported)";
- return NULL;
+
+ default:
+ return "unknown error in parse_pack_header";
+
+ case 0:
+ return NULL;
+ }
}
static const char *pack_lockfile;
@@ -421,11 +426,16 @@ int main(int argc, char **argv)
if (!enter_repo(dir, 0))
die("'%s': unable to chdir or not a git archive", dir);
- setup_ident();
- /* don't die if gecos is empty */
- ignore_missing_committer_name();
+ if (is_repository_shallow())
+ die("attempt to push into a shallow repository");
+
git_config(receive_pack_config);
+ if (0 <= transfer_unpack_limit)
+ unpack_limit = transfer_unpack_limit;
+ else if (0 <= receive_unpack_limit)
+ unpack_limit = receive_unpack_limit;
+
write_head_info();
/* EOF */
diff --git a/reflog-walk.c b/reflog-walk.c
new file mode 100644
index 0000000000..c983858259
--- /dev/null
+++ b/reflog-walk.c
@@ -0,0 +1,273 @@
+#include "cache.h"
+#include "commit.h"
+#include "refs.h"
+#include "diff.h"
+#include "revision.h"
+#include "path-list.h"
+#include "reflog-walk.h"
+
+struct complete_reflogs {
+ char *ref;
+ struct reflog_info {
+ unsigned char osha1[20], nsha1[20];
+ char *email;
+ unsigned long timestamp;
+ int tz;
+ char *message;
+ } *items;
+ int nr, alloc;
+};
+
+static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
+{
+ struct complete_reflogs *array = cb_data;
+ struct reflog_info *item;
+
+ if (array->nr >= array->alloc) {
+ array->alloc = alloc_nr(array->nr + 1);
+ array->items = xrealloc(array->items, array->alloc *
+ sizeof(struct reflog_info));
+ }
+ item = array->items + array->nr;
+ memcpy(item->osha1, osha1, 20);
+ memcpy(item->nsha1, nsha1, 20);
+ item->email = xstrdup(email);
+ item->timestamp = timestamp;
+ item->tz = tz;
+ item->message = xstrdup(message);
+ array->nr++;
+ return 0;
+}
+
+static struct complete_reflogs *read_complete_reflog(const char *ref)
+{
+ struct complete_reflogs *reflogs =
+ xcalloc(sizeof(struct complete_reflogs), 1);
+ reflogs->ref = xstrdup(ref);
+ for_each_reflog_ent(ref, read_one_reflog, reflogs);
+ if (reflogs->nr == 0) {
+ unsigned char sha1[20];
+ const char *name = resolve_ref(ref, sha1, 1, NULL);
+ if (name)
+ for_each_reflog_ent(name, read_one_reflog, reflogs);
+ }
+ if (reflogs->nr == 0) {
+ int len = strlen(ref);
+ char *refname = xmalloc(len + 12);
+ sprintf(refname, "refs/%s", ref);
+ for_each_reflog_ent(refname, read_one_reflog, reflogs);
+ if (reflogs->nr == 0) {
+ sprintf(refname, "refs/heads/%s", ref);
+ for_each_reflog_ent(refname, read_one_reflog, reflogs);
+ }
+ free(refname);
+ }
+ return reflogs;
+}
+
+static int get_reflog_recno_by_time(struct complete_reflogs *array,
+ unsigned long timestamp)
+{
+ int i;
+ for (i = array->nr - 1; i >= 0; i--)
+ if (timestamp >= array->items[i].timestamp)
+ return i;
+ return -1;
+}
+
+struct commit_info_lifo {
+ struct commit_info {
+ struct commit *commit;
+ void *util;
+ } *items;
+ int nr, alloc;
+};
+
+static struct commit_info *get_commit_info(struct commit *commit,
+ struct commit_info_lifo *lifo, int pop)
+{
+ int i;
+ for (i = 0; i < lifo->nr; i++)
+ if (lifo->items[i].commit == commit) {
+ struct commit_info *result = &lifo->items[i];
+ if (pop) {
+ if (i + 1 < lifo->nr)
+ memmove(lifo->items + i,
+ lifo->items + i + 1,
+ (lifo->nr - i) *
+ sizeof(struct commit_info));
+ lifo->nr--;
+ }
+ return result;
+ }
+ return NULL;
+}
+
+static void add_commit_info(struct commit *commit, void *util,
+ struct commit_info_lifo *lifo)
+{
+ struct commit_info *info;
+ if (lifo->nr >= lifo->alloc) {
+ lifo->alloc = alloc_nr(lifo->nr + 1);
+ lifo->items = xrealloc(lifo->items,
+ lifo->alloc * sizeof(struct commit_info));
+ }
+ info = lifo->items + lifo->nr;
+ info->commit = commit;
+ info->util = util;
+ lifo->nr++;
+}
+
+struct commit_reflog {
+ int flag, recno;
+ struct complete_reflogs *reflogs;
+};
+
+struct reflog_walk_info {
+ struct commit_info_lifo reflogs;
+ struct path_list complete_reflogs;
+ struct commit_reflog *last_commit_reflog;
+};
+
+void init_reflog_walk(struct reflog_walk_info** info)
+{
+ *info = xcalloc(sizeof(struct reflog_walk_info), 1);
+}
+
+void add_reflog_for_walk(struct reflog_walk_info *info,
+ struct commit *commit, const char *name)
+{
+ unsigned long timestamp = 0;
+ int recno = -1;
+ struct path_list_item *item;
+ struct complete_reflogs *reflogs;
+ char *branch, *at = strchr(name, '@');
+ struct commit_reflog *commit_reflog;
+
+ if (commit->object.flags & UNINTERESTING)
+ die ("Cannot walk reflogs for %s", name);
+
+ branch = xstrdup(name);
+ if (at && at[1] == '{') {
+ char *ep;
+ branch[at - name] = '\0';
+ recno = strtoul(at + 2, &ep, 10);
+ if (*ep != '}') {
+ recno = -1;
+ timestamp = approxidate(at + 2);
+ }
+ } else
+ recno = 0;
+
+ item = path_list_lookup(branch, &info->complete_reflogs);
+ if (item)
+ reflogs = item->util;
+ else {
+ if (*branch == '\0') {
+ unsigned char sha1[20];
+ const char *head = resolve_ref("HEAD", sha1, 0, NULL);
+ if (!head)
+ die ("No current branch");
+ free(branch);
+ branch = xstrdup(head);
+ }
+ reflogs = read_complete_reflog(branch);
+ if (!reflogs || reflogs->nr == 0) {
+ unsigned char sha1[20];
+ char *b;
+ if (dwim_log(branch, strlen(branch), sha1, &b) == 1) {
+ if (reflogs) {
+ free(reflogs->ref);
+ free(reflogs);
+ }
+ free(branch);
+ branch = b;
+ reflogs = read_complete_reflog(branch);
+ }
+ }
+ if (!reflogs || reflogs->nr == 0)
+ die("No reflogs found for '%s'", branch);
+ path_list_insert(branch, &info->complete_reflogs)->util
+ = reflogs;
+ }
+
+ commit_reflog = xcalloc(sizeof(struct commit_reflog), 1);
+ if (recno < 0) {
+ commit_reflog->flag = 1;
+ commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
+ if (commit_reflog->recno < 0) {
+ free(branch);
+ free(commit_reflog);
+ return;
+ }
+ } else
+ commit_reflog->recno = reflogs->nr - recno - 1;
+ commit_reflog->reflogs = reflogs;
+
+ add_commit_info(commit, commit_reflog, &info->reflogs);
+}
+
+void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
+{
+ struct commit_info *commit_info =
+ get_commit_info(commit, &info->reflogs, 0);
+ struct commit_reflog *commit_reflog;
+ struct reflog_info *reflog;
+
+ info->last_commit_reflog = NULL;
+ if (!commit_info)
+ return;
+
+ commit_reflog = commit_info->util;
+ if (commit_reflog->recno < 0) {
+ commit->parents = NULL;
+ return;
+ }
+
+ reflog = &commit_reflog->reflogs->items[commit_reflog->recno];
+ info->last_commit_reflog = commit_reflog;
+ commit_reflog->recno--;
+ commit_info->commit = (struct commit *)parse_object(reflog->osha1);
+ if (!commit_info->commit) {
+ commit->parents = NULL;
+ return;
+ }
+
+ commit->parents = xcalloc(sizeof(struct commit_list), 1);
+ commit->parents->item = commit_info->commit;
+ commit->object.flags &= ~(ADDED | SEEN | SHOWN);
+}
+
+void show_reflog_message(struct reflog_walk_info* info, int oneline,
+ int relative_date)
+{
+ if (info && info->last_commit_reflog) {
+ struct commit_reflog *commit_reflog = info->last_commit_reflog;
+ struct reflog_info *info;
+
+ info = &commit_reflog->reflogs->items[commit_reflog->recno+1];
+ if (oneline) {
+ printf("%s@{", commit_reflog->reflogs->ref);
+ if (commit_reflog->flag || relative_date)
+ printf("%s", show_date(info->timestamp, 0, 1));
+ else
+ printf("%d", commit_reflog->reflogs->nr
+ - 2 - commit_reflog->recno);
+ printf("}: %s", info->message);
+ }
+ else {
+ printf("Reflog: %s@{", commit_reflog->reflogs->ref);
+ if (commit_reflog->flag || relative_date)
+ printf("%s", show_date(info->timestamp,
+ info->tz,
+ relative_date));
+ else
+ printf("%d", commit_reflog->reflogs->nr
+ - 2 - commit_reflog->recno);
+ printf("} (%s)\nReflog message: %s",
+ info->email, info->message);
+ }
+ }
+}
diff --git a/reflog-walk.h b/reflog-walk.h
new file mode 100644
index 0000000000..a4f7015d3e
--- /dev/null
+++ b/reflog-walk.h
@@ -0,0 +1,11 @@
+#ifndef REFLOG_WALK_H
+#define REFLOG_WALK_H
+
+extern void init_reflog_walk(struct reflog_walk_info** info);
+extern void add_reflog_for_walk(struct reflog_walk_info *info,
+ struct commit *commit, const char *name);
+extern void fake_reflog_parent(struct reflog_walk_info *info,
+ struct commit *commit);
+extern void show_reflog_message(struct reflog_walk_info *info, int, int);
+
+#endif
diff --git a/refs.c b/refs.c
index 4d6fad8879..6387703789 100644
--- a/refs.c
+++ b/refs.c
@@ -309,49 +309,6 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
return ref;
}
-int create_symref(const char *ref_target, const char *refs_heads_master)
-{
- const char *lockpath;
- char ref[1000];
- int fd, len, written;
- const char *git_HEAD = git_path("%s", ref_target);
-
-#ifndef NO_SYMLINK_HEAD
- if (prefer_symlink_refs) {
- unlink(git_HEAD);
- if (!symlink(refs_heads_master, git_HEAD))
- return 0;
- fprintf(stderr, "no symlink - falling back to symbolic ref\n");
- }
-#endif
-
- len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
- if (sizeof(ref) <= len) {
- error("refname too long: %s", refs_heads_master);
- return -1;
- }
- lockpath = mkpath("%s.lock", git_HEAD);
- fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
- written = write_in_full(fd, ref, len);
- close(fd);
- if (written != len) {
- unlink(lockpath);
- error("Unable to write to %s", lockpath);
- return -2;
- }
- if (rename(lockpath, git_HEAD) < 0) {
- unlink(lockpath);
- error("Unable to create %s", git_HEAD);
- return -3;
- }
- if (adjust_shared_perm(git_HEAD)) {
- unlink(lockpath);
- error("Unable to fix permissions on %s", lockpath);
- return -4;
- }
- return 0;
-}
-
int read_ref(const char *ref, unsigned char *sha1)
{
if (resolve_ref(ref, sha1, 1, NULL))
@@ -676,7 +633,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
lock->lk = xcalloc(1, sizeof(struct lock_file));
lock->ref_name = xstrdup(ref);
- lock->log_file = xstrdup(git_path("logs/%s", ref));
+ lock->orig_ref_name = xstrdup(orig_ref);
ref_file = git_path("%s", ref);
lock->force_write = lstat(ref_file, &st) && errno == ENOENT;
@@ -706,6 +663,8 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1)
{
+ if (check_ref_format(ref) == -1)
+ return NULL;
return lock_ref_sha1_basic(ref, old_sha1, NULL);
}
@@ -772,10 +731,10 @@ int delete_ref(const char *refname, unsigned char *sha1)
*/
ret |= repack_without_ref(refname);
- err = unlink(lock->log_file);
+ err = unlink(git_path("logs/%s", lock->ref_name));
if (err && errno != ENOENT)
fprintf(stderr, "warning: unlink(%s) failed: %s",
- lock->log_file, strerror(errno));
+ git_path("logs/%s", lock->ref_name), strerror(errno));
invalidate_cached_refs();
unlock_ref(lock);
return ret;
@@ -837,7 +796,12 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
retry:
if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
- if (errno==EISDIR) {
+ if (errno==EISDIR || errno==ENOTDIR) {
+ /*
+ * rename(a, b) when b is an existing
+ * directory ought to result in ISDIR, but
+ * Solaris 5.8 gives ENOTDIR. Sheesh.
+ */
if (remove_empty_directories(git_path("logs/%s", newref))) {
error("Directory not empty: logs/%s", newref);
goto rollback;
@@ -911,68 +875,81 @@ void unlock_ref(struct ref_lock *lock)
rollback_lock_file(lock->lk);
}
free(lock->ref_name);
- free(lock->log_file);
+ free(lock->orig_ref_name);
free(lock);
}
-static int log_ref_write(struct ref_lock *lock,
- const unsigned char *sha1, const char *msg)
+static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
+ const unsigned char *new_sha1, const char *msg)
{
int logfd, written, oflags = O_APPEND | O_WRONLY;
unsigned maxlen, len;
- char *logrec;
+ int msglen;
+ char *log_file, *logrec;
const char *committer;
+ if (log_all_ref_updates < 0)
+ log_all_ref_updates = !is_bare_repository();
+
+ log_file = git_path("logs/%s", ref_name);
+
if (log_all_ref_updates &&
- (!strncmp(lock->ref_name, "refs/heads/", 11) ||
- !strncmp(lock->ref_name, "refs/remotes/", 13))) {
- if (safe_create_leading_directories(lock->log_file) < 0)
+ (!strncmp(ref_name, "refs/heads/", 11) ||
+ !strncmp(ref_name, "refs/remotes/", 13) ||
+ !strcmp(ref_name, "HEAD"))) {
+ if (safe_create_leading_directories(log_file) < 0)
return error("unable to create directory for %s",
- lock->log_file);
+ log_file);
oflags |= O_CREAT;
}
- logfd = open(lock->log_file, oflags, 0666);
+ logfd = open(log_file, oflags, 0666);
if (logfd < 0) {
if (!(oflags & O_CREAT) && errno == ENOENT)
return 0;
if ((oflags & O_CREAT) && errno == EISDIR) {
- if (remove_empty_directories(lock->log_file)) {
+ if (remove_empty_directories(log_file)) {
return error("There are still logs under '%s'",
- lock->log_file);
+ log_file);
}
- logfd = open(lock->log_file, oflags, 0666);
+ logfd = open(log_file, oflags, 0666);
}
if (logfd < 0)
return error("Unable to append to %s: %s",
- lock->log_file, strerror(errno));
+ log_file, strerror(errno));
}
- committer = git_committer_info(1);
+ msglen = 0;
if (msg) {
- maxlen = strlen(committer) + strlen(msg) + 2*40 + 5;
- logrec = xmalloc(maxlen);
- len = snprintf(logrec, maxlen, "%s %s %s\t%s\n",
- sha1_to_hex(lock->old_sha1),
- sha1_to_hex(sha1),
- committer,
- msg);
- }
- else {
- maxlen = strlen(committer) + 2*40 + 4;
- logrec = xmalloc(maxlen);
- len = snprintf(logrec, maxlen, "%s %s %s\n",
- sha1_to_hex(lock->old_sha1),
- sha1_to_hex(sha1),
- committer);
+ /* clean up the message and make sure it is a single line */
+ for ( ; *msg; msg++)
+ if (!isspace(*msg))
+ break;
+ if (*msg) {
+ const char *ep = strchr(msg, '\n');
+ if (ep)
+ msglen = ep - msg;
+ else
+ msglen = strlen(msg);
+ }
}
+
+ committer = git_committer_info(-1);
+ maxlen = strlen(committer) + msglen + 100;
+ logrec = xmalloc(maxlen);
+ len = sprintf(logrec, "%s %s %s\n",
+ sha1_to_hex(old_sha1),
+ sha1_to_hex(new_sha1),
+ committer);
+ if (msglen)
+ len += sprintf(logrec + len - 1, "\t%.*s\n", msglen, msg) - 1;
written = len <= maxlen ? write_in_full(logfd, logrec, len) : -1;
free(logrec);
close(logfd);
if (written != len)
- return error("Unable to append to %s", lock->log_file);
+ return error("Unable to append to %s", log_file);
return 0;
}
@@ -995,7 +972,9 @@ int write_ref_sha1(struct ref_lock *lock,
return -1;
}
invalidate_cached_refs();
- if (log_ref_write(lock, sha1, logmsg) < 0) {
+ if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
+ (strcmp(lock->ref_name, lock->orig_ref_name) &&
+ log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
unlock_ref(lock);
return -1;
}
@@ -1009,7 +988,83 @@ int write_ref_sha1(struct ref_lock *lock,
return 0;
}
-int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1)
+int create_symref(const char *ref_target, const char *refs_heads_master,
+ const char *logmsg)
+{
+ const char *lockpath;
+ char ref[1000];
+ int fd, len, written;
+ char *git_HEAD = xstrdup(git_path("%s", ref_target));
+ unsigned char old_sha1[20], new_sha1[20];
+
+ if (logmsg && read_ref(ref_target, old_sha1))
+ hashclr(old_sha1);
+
+ if (safe_create_leading_directories(git_HEAD) < 0)
+ return error("unable to create directory for %s", git_HEAD);
+
+#ifndef NO_SYMLINK_HEAD
+ if (prefer_symlink_refs) {
+ unlink(git_HEAD);
+ if (!symlink(refs_heads_master, git_HEAD))
+ goto done;
+ fprintf(stderr, "no symlink - falling back to symbolic ref\n");
+ }
+#endif
+
+ len = snprintf(ref, sizeof(ref), "ref: %s\n", refs_heads_master);
+ if (sizeof(ref) <= len) {
+ error("refname too long: %s", refs_heads_master);
+ goto error_free_return;
+ }
+ lockpath = mkpath("%s.lock", git_HEAD);
+ fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
+ if (fd < 0) {
+ error("Unable to open %s for writing", lockpath);
+ goto error_free_return;
+ }
+ written = write_in_full(fd, ref, len);
+ close(fd);
+ if (written != len) {
+ error("Unable to write to %s", lockpath);
+ goto error_unlink_return;
+ }
+ if (rename(lockpath, git_HEAD) < 0) {
+ error("Unable to create %s", git_HEAD);
+ goto error_unlink_return;
+ }
+ if (adjust_shared_perm(git_HEAD)) {
+ error("Unable to fix permissions on %s", lockpath);
+ error_unlink_return:
+ unlink(lockpath);
+ error_free_return:
+ free(git_HEAD);
+ return -1;
+ }
+
+ done:
+ if (logmsg && !read_ref(refs_heads_master, new_sha1))
+ log_ref_write(ref_target, old_sha1, new_sha1, logmsg);
+
+ free(git_HEAD);
+ return 0;
+}
+
+static char *ref_msg(const char *line, const char *endp)
+{
+ const char *ep;
+ char *msg;
+
+ line += 82;
+ for (ep = line; ep < endp && *ep != '\n'; ep++)
+ ;
+ msg = xmalloc(ep - line + 1);
+ memcpy(msg, line, ep - line);
+ msg[ep - line] = 0;
+ return msg;
+}
+
+int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
{
const char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;
char *tz_c;
@@ -1017,6 +1072,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
struct stat st;
unsigned long date;
unsigned char logged_sha1[20];
+ void *log_mapped;
logfile = git_path("logs/%s", ref);
logfd = open(logfile, O_RDONLY, 0);
@@ -1025,7 +1081,8 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
fstat(logfd, &st);
if (!st.st_size)
die("Log %s is empty.", logfile);
- logdata = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, logfd, 0);
+ log_mapped = xmmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, logfd, 0);
+ logdata = log_mapped;
close(logfd);
lastrec = NULL;
@@ -1044,13 +1101,21 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
die("Log %s is corrupt.", logfile);
date = strtoul(lastgt + 1, &tz_c, 10);
if (date <= at_time || cnt == 0) {
+ tz = strtoul(tz_c, NULL, 10);
+ if (msg)
+ *msg = ref_msg(rec, logend);
+ if (cutoff_time)
+ *cutoff_time = date;
+ if (cutoff_tz)
+ *cutoff_tz = tz;
+ if (cutoff_cnt)
+ *cutoff_cnt = reccnt - 1;
if (lastrec) {
if (get_sha1_hex(lastrec, logged_sha1))
die("Log %s is corrupt.", logfile);
if (get_sha1_hex(rec + 41, sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s has gap after %s.\n",
logfile, show_rfc2822_date(date, tz));
@@ -1064,13 +1129,12 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (get_sha1_hex(rec + 41, logged_sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- tz = strtoul(tz_c, NULL, 10);
fprintf(stderr,
"warning: Log %s unexpectedly ended on %s.\n",
logfile, show_rfc2822_date(date, tz));
}
}
- munmap((void*)logdata, st.st_size);
+ munmap(log_mapped, st.st_size);
return 0;
}
lastrec = rec;
@@ -1087,38 +1151,112 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
tz = strtoul(tz_c, NULL, 10);
if (get_sha1_hex(logdata, sha1))
die("Log %s is corrupt.", logfile);
- munmap((void*)logdata, st.st_size);
- if (at_time)
- fprintf(stderr, "warning: Log %s only goes back to %s.\n",
- logfile, show_rfc2822_date(date, tz));
- else
- fprintf(stderr, "warning: Log %s only has %d entries.\n",
- logfile, reccnt);
- return 0;
+ if (msg)
+ *msg = ref_msg(logdata, logend);
+ munmap(log_mapped, st.st_size);
+
+ if (cutoff_time)
+ *cutoff_time = date;
+ if (cutoff_tz)
+ *cutoff_tz = tz;
+ if (cutoff_cnt)
+ *cutoff_cnt = reccnt;
+ return 1;
}
-void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
+int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)
{
const char *logfile;
FILE *logfp;
char buf[1024];
+ int ret = 0;
logfile = git_path("logs/%s", ref);
logfp = fopen(logfile, "r");
if (!logfp)
- return;
+ return -1;
while (fgets(buf, sizeof(buf), logfp)) {
unsigned char osha1[20], nsha1[20];
- int len;
+ char *email_end, *message;
+ unsigned long timestamp;
+ int len, tz;
/* old SP new SP name <email> SP time TAB msg LF */
len = strlen(buf);
if (len < 83 || buf[len-1] != '\n' ||
get_sha1_hex(buf, osha1) || buf[40] != ' ' ||
- get_sha1_hex(buf + 41, nsha1) || buf[81] != ' ')
+ get_sha1_hex(buf + 41, nsha1) || buf[81] != ' ' ||
+ !(email_end = strchr(buf + 82, '>')) ||
+ email_end[1] != ' ' ||
+ !(timestamp = strtoul(email_end + 2, &message, 10)) ||
+ !message || message[0] != ' ' ||
+ (message[1] != '+' && message[1] != '-') ||
+ !isdigit(message[2]) || !isdigit(message[3]) ||
+ !isdigit(message[4]) || !isdigit(message[5]))
continue; /* corrupt? */
- fn(osha1, nsha1, buf+82, cb_data);
+ email_end[1] = '\0';
+ tz = strtol(message + 1, NULL, 10);
+ if (message[6] != '\t')
+ message += 6;
+ else
+ message += 7;
+ ret = fn(osha1, nsha1, buf+82, timestamp, tz, message, cb_data);
+ if (ret)
+ break;
}
fclose(logfp);
+ return ret;
}
+static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)
+{
+ DIR *dir = opendir(git_path("logs/%s", base));
+ int retval = 0;
+
+ if (dir) {
+ struct dirent *de;
+ int baselen = strlen(base);
+ char *log = xmalloc(baselen + 257);
+
+ memcpy(log, base, baselen);
+ if (baselen && base[baselen-1] != '/')
+ log[baselen++] = '/';
+
+ while ((de = readdir(dir)) != NULL) {
+ struct stat st;
+ int namelen;
+
+ if (de->d_name[0] == '.')
+ continue;
+ namelen = strlen(de->d_name);
+ if (namelen > 255)
+ continue;
+ if (has_extension(de->d_name, ".lock"))
+ continue;
+ memcpy(log + baselen, de->d_name, namelen+1);
+ if (stat(git_path("logs/%s", log), &st) < 0)
+ continue;
+ if (S_ISDIR(st.st_mode)) {
+ retval = do_for_each_reflog(log, fn, cb_data);
+ } else {
+ unsigned char sha1[20];
+ if (!resolve_ref(log, sha1, 0, NULL))
+ retval = error("bad ref for %s", log);
+ else
+ retval = fn(log, sha1, 0, cb_data);
+ }
+ if (retval)
+ break;
+ }
+ free(log);
+ closedir(dir);
+ }
+ else if (*base)
+ return errno;
+ return retval;
+}
+
+int for_each_reflog(each_ref_fn fn, void *cb_data)
+{
+ return do_for_each_reflog("", fn, cb_data);
+}
diff --git a/refs.h b/refs.h
index de43cc768a..acedffc0e4 100644
--- a/refs.h
+++ b/refs.h
@@ -3,7 +3,7 @@
struct ref_lock {
char *ref_name;
- char *log_file;
+ char *orig_ref_name;
struct lock_file *lk;
unsigned char old_sha1[20];
int lock_fd;
@@ -42,11 +42,17 @@ extern void unlock_ref(struct ref_lock *lock);
extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);
/** Reads log for the value of ref during at_time. **/
-extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1);
+extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
/* iterate over reflog entries */
-typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, char *, void *);
-void for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data);
+typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);
+int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data);
+
+/*
+ * Calls the specified function for each reflog file until it returns nonzero,
+ * and returns the value
+ */
+extern int for_each_reflog(each_ref_fn, void *);
/** Returns 0 if target has the right format for a ref. **/
extern int check_ref_format(const char *target);
diff --git a/revision.c b/revision.c
index 6e4ec46302..15bdaf6095 100644
--- a/revision.c
+++ b/revision.c
@@ -7,6 +7,7 @@
#include "refs.h"
#include "revision.h"
#include "grep.h"
+#include "reflog-walk.h"
static char *path_name(struct name_path *path, const char *name)
{
@@ -116,6 +117,9 @@ void mark_parents_uninteresting(struct commit *commit)
void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
{
add_object_array(obj, name, &revs->pending);
+ if (revs->reflog_info && obj->type == OBJ_COMMIT)
+ add_reflog_for_walk(revs->reflog_info,
+ (struct commit *)obj, name);
}
static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
@@ -505,7 +509,9 @@ static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data)
}
}
-static int handle_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1, char *detail, void *cb_data)
+static int handle_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+ const char *email, unsigned long timestamp, int tz,
+ const char *message, void *cb_data)
{
handle_one_reflog_commit(osha1, cb_data);
handle_one_reflog_commit(nsha1, cb_data);
@@ -526,7 +532,7 @@ static void handle_reflog(struct rev_info *revs, unsigned flags)
struct all_refs_cb cb;
cb.all_revs = revs;
cb.all_flags = flags;
- for_each_ref(handle_one_reflog, &cb);
+ for_each_reflog(handle_one_reflog, &cb);
}
static int add_parents_only(struct rev_info *revs, const char *arg, int flags)
@@ -862,6 +868,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
handle_reflog(revs, flags);
continue;
}
+ if (!strcmp(arg, "-g") ||
+ !strcmp(arg, "--walk-reflogs")) {
+ init_reflog_walk(&revs->reflog_info);
+ continue;
+ }
if (!strcmp(arg, "--not")) {
flags ^= UNINTERESTING;
continue;
@@ -1119,21 +1130,23 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
void prepare_revision_walk(struct rev_info *revs)
{
int nr = revs->pending.nr;
- struct object_array_entry *list = revs->pending.objects;
+ struct object_array_entry *e, *list;
+ e = list = revs->pending.objects;
revs->pending.nr = 0;
revs->pending.alloc = 0;
revs->pending.objects = NULL;
while (--nr >= 0) {
- struct commit *commit = handle_commit(revs, list->item, list->name);
+ struct commit *commit = handle_commit(revs, e->item, e->name);
if (commit) {
if (!(commit->object.flags & SEEN)) {
commit->object.flags |= SEEN;
insert_by_date(commit, &revs->commits);
}
}
- list++;
+ e++;
}
+ free(list);
if (revs->no_walk)
return;
@@ -1206,6 +1219,9 @@ static struct commit *get_revision_1(struct rev_info *revs)
revs->commits = entry->next;
free(entry);
+ if (revs->reflog_info)
+ fake_reflog_parent(revs->reflog_info, commit);
+
/*
* If we haven't done the list limiting, we need to look at
* the parents here. We also need to do the date-based limiting
diff --git a/revision.h b/revision.h
index 8f7907d7ab..d93481f68f 100644
--- a/revision.h
+++ b/revision.h
@@ -89,6 +89,8 @@ struct rev_info {
topo_sort_set_fn_t topo_setter;
topo_sort_get_fn_t topo_getter;
+
+ struct reflog_walk_info *reflog_info;
};
#define REV_TREE_SAME 0
diff --git a/send-pack.c b/send-pack.c
index 6756264b29..33e69dbe18 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -6,9 +6,9 @@
#include "exec_cmd.h"
static const char send_pack_usage[] =
-"git-send-pack [--all] [--exec=git-receive-pack] <remote> [<head>...]\n"
-" --all and explicit <head> specification are mutually exclusive.";
-static const char *exec = "git-receive-pack";
+"git-send-pack [--all] [--force] [--receive-pack=<git-receive-pack>] [--verbose] [--thin] [<host>:]<directory> [<ref>...]\n"
+" --all and explicit <ref> specification are mutually exclusive.";
+static const char *receivepack = "git-receive-pack";
static int verbose;
static int send_all;
static int force_update;
@@ -25,6 +25,8 @@ static int pack_objects(int fd, struct ref *refs)
if (pipe(pipe_fd) < 0)
return error("send-pack: pipe failed");
pid = fork();
+ if (pid < 0)
+ return error("send-pack: unable to fork git-pack-objects");
if (!pid) {
/*
* The child becomes pack-objects --revs; we feed
@@ -377,8 +379,12 @@ int main(int argc, char **argv)
char *arg = *argv;
if (*arg == '-') {
+ if (!strncmp(arg, "--receive-pack=", 15)) {
+ receivepack = arg + 15;
+ continue;
+ }
if (!strncmp(arg, "--exec=", 7)) {
- exec = arg + 7;
+ receivepack = arg + 7;
continue;
}
if (!strcmp(arg, "--all")) {
@@ -413,7 +419,7 @@ int main(int argc, char **argv)
usage(send_pack_usage);
verify_remote_names(nr_heads, heads);
- pid = git_connect(fd, dest, exec);
+ pid = git_connect(fd, dest, receivepack);
if (pid < 0)
return 1;
ret = send_pack(fd[0], fd[1], nr_heads, heads);
diff --git a/server-info.c b/server-info.c
index 6cd38be329..f9be5a7f60 100644
--- a/server-info.c
+++ b/server-info.c
@@ -10,6 +10,8 @@ static FILE *info_ref_fp;
static int add_info_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data)
{
struct object *o = parse_object(sha1);
+ if (!o)
+ return -1;
fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path);
if (o->type == OBJ_TAG) {
diff --git a/setup.c b/setup.c
index 2ae57f7c94..e9d3f5aab6 100644
--- a/setup.c
+++ b/setup.c
@@ -95,6 +95,8 @@ void verify_non_filename(const char *prefix, const char *arg)
const char *name;
struct stat st;
+ if (is_inside_git_dir())
+ return;
if (*arg == '-')
return; /* flag */
name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg;
@@ -138,7 +140,8 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
* GIT_OBJECT_DIRECTORY environment variable
* - a refs/ directory
* - either a HEAD symlink or a HEAD file that is formatted as
- * a proper "ref:".
+ * a proper "ref:", or a regular file HEAD that has a properly
+ * formatted sha1 object name.
*/
static int is_git_directory(const char *suspect)
{
@@ -161,12 +164,34 @@ static int is_git_directory(const char *suspect)
return 0;
strcpy(path + len, "/HEAD");
- if (validate_symref(path))
+ if (validate_headref(path))
return 0;
return 1;
}
+static int inside_git_dir = -1;
+
+int is_inside_git_dir(void)
+{
+ if (inside_git_dir < 0) {
+ char buffer[1024];
+
+ if (is_bare_repository())
+ return (inside_git_dir = 1);
+ if (getcwd(buffer, sizeof(buffer))) {
+ const char *git_dir = get_git_dir(), *cwd = buffer;
+ while (*git_dir && *git_dir == *cwd) {
+ git_dir++;
+ cwd++;
+ }
+ inside_git_dir = !*git_dir;
+ } else
+ inside_git_dir = 0;
+ }
+ return inside_git_dir;
+}
+
const char *setup_git_directory_gently(int *nongit_ok)
{
static char cwd[PATH_MAX+1];
@@ -205,6 +230,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
if (chdir(cwd))
die("Cannot come back to cwd");
setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+ inside_git_dir = 1;
return NULL;
}
if (nongit_ok) {
@@ -225,6 +251,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
offset++;
cwd[len++] = '/';
cwd[len] = 0;
+ inside_git_dir = !strncmp(cwd + offset, ".git/", 5);
return cwd + offset;
}
diff --git a/sha1_file.c b/sha1_file.c
index 095a7e1622..8ad7fad825 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -22,6 +22,12 @@
#endif
#endif
+#ifdef NO_C99_FORMAT
+#define SZ_FMT "lu"
+#else
+#define SZ_FMT "zu"
+#endif
+
const unsigned char null_sha1[20];
static unsigned int sha1_file_open_flag = O_NOATIME;
@@ -407,9 +413,9 @@ struct packed_git *packed_git;
void pack_report()
{
fprintf(stderr,
- "pack_report: getpagesize() = %10lu\n"
- "pack_report: core.packedGitWindowSize = %10lu\n"
- "pack_report: core.packedGitLimit = %10lu\n",
+ "pack_report: getpagesize() = %10" SZ_FMT "\n"
+ "pack_report: core.packedGitWindowSize = %10" SZ_FMT "\n"
+ "pack_report: core.packedGitLimit = %10" SZ_FMT "\n",
page_size,
packed_git_window_size,
packed_git_limit);
@@ -417,7 +423,8 @@ void pack_report()
"pack_report: pack_used_ctr = %10u\n"
"pack_report: pack_mmap_calls = %10u\n"
"pack_report: pack_open_windows = %10u / %10u\n"
- "pack_report: pack_mapped = %10lu / %10lu\n",
+ "pack_report: pack_mapped = "
+ "%10" SZ_FMT " / %10" SZ_FMT "\n",
pack_used_ctr,
pack_mmap_calls,
pack_open_windows, peak_pack_open_windows,
@@ -428,7 +435,7 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
void **idx_map_)
{
void *idx_map;
- unsigned int *index;
+ uint32_t *index;
unsigned long idx_size;
int nr, i;
int fd = open(path, O_RDONLY);
@@ -449,12 +456,23 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
/* check index map */
if (idx_size < 4*256 + 20 + 20)
- return error("index file too small");
+ return error("index file %s is too small", path);
+
+ /* a future index format would start with this, as older git
+ * binaries would fail the non-monotonic index check below.
+ * give a nicer warning to the user if we can.
+ */
+ if (index[0] == htonl(PACK_IDX_SIGNATURE))
+ return error("index file %s is a newer version"
+ " and is not supported by this binary"
+ " (try upgrading GIT to a newer version)",
+ path);
+
nr = 0;
for (i = 0; i < 256; i++) {
unsigned int n = ntohl(index[i]);
if (n < nr)
- return error("non-monotonic index");
+ return error("non-monotonic index %s", path);
nr = n;
}
@@ -466,7 +484,7 @@ static int check_packed_git_idx(const char *path, unsigned long *idx_size_,
* - 20-byte SHA1 file checksum
*/
if (idx_size != 4*256 + nr * 24 + 20 + 20)
- return error("wrong index file size");
+ return error("wrong index file size in %s", path);
return 0;
}
@@ -534,7 +552,11 @@ void unuse_pack(struct pack_window **w_cursor)
}
}
-static void open_packed_git(struct packed_git *p)
+/*
+ * Do not call this directly as this leaks p->pack_fd on error return;
+ * call open_packed_git() instead.
+ */
+static int open_packed_git_1(struct packed_git *p)
{
struct stat st;
struct pack_header hdr;
@@ -544,47 +566,61 @@ static void open_packed_git(struct packed_git *p)
p->pack_fd = open(p->pack_name, O_RDONLY);
if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
- die("packfile %s cannot be opened", p->pack_name);
+ return -1;
/* If we created the struct before we had the pack we lack size. */
if (!p->pack_size) {
if (!S_ISREG(st.st_mode))
- die("packfile %s not a regular file", p->pack_name);
+ return error("packfile %s not a regular file", p->pack_name);
p->pack_size = st.st_size;
} else if (p->pack_size != st.st_size)
- die("packfile %s size changed", p->pack_name);
+ return error("packfile %s size changed", p->pack_name);
/* We leave these file descriptors open with sliding mmap;
* there is no point keeping them open across exec(), though.
*/
fd_flag = fcntl(p->pack_fd, F_GETFD, 0);
if (fd_flag < 0)
- die("cannot determine file descriptor flags");
+ return error("cannot determine file descriptor flags");
fd_flag |= FD_CLOEXEC;
if (fcntl(p->pack_fd, F_SETFD, fd_flag) == -1)
- die("cannot set FD_CLOEXEC");
+ return error("cannot set FD_CLOEXEC");
/* Verify we recognize this pack file format. */
- read_or_die(p->pack_fd, &hdr, sizeof(hdr));
+ if (read_in_full(p->pack_fd, &hdr, sizeof(hdr)) != sizeof(hdr))
+ return error("file %s is far too short to be a packfile", p->pack_name);
if (hdr.hdr_signature != htonl(PACK_SIGNATURE))
- die("file %s is not a GIT packfile", p->pack_name);
+ return error("file %s is not a GIT packfile", p->pack_name);
if (!pack_version_ok(hdr.hdr_version))
- die("packfile %s is version %u and not supported"
+ return error("packfile %s is version %u and not supported"
" (try upgrading GIT to a newer version)",
p->pack_name, ntohl(hdr.hdr_version));
/* Verify the pack matches its index. */
if (num_packed_objects(p) != ntohl(hdr.hdr_entries))
- die("packfile %s claims to have %u objects"
+ return error("packfile %s claims to have %u objects"
" while index size indicates %u objects",
p->pack_name, ntohl(hdr.hdr_entries),
num_packed_objects(p));
if (lseek(p->pack_fd, p->pack_size - sizeof(sha1), SEEK_SET) == -1)
- die("end of packfile %s is unavailable", p->pack_name);
- read_or_die(p->pack_fd, sha1, sizeof(sha1));
+ return error("end of packfile %s is unavailable", p->pack_name);
+ if (read_in_full(p->pack_fd, sha1, sizeof(sha1)) != sizeof(sha1))
+ return error("packfile %s signature is unavailable", p->pack_name);
idx_sha1 = ((unsigned char *)p->index_base) + p->index_size - 40;
if (hashcmp(sha1, idx_sha1))
- die("packfile %s does not match index", p->pack_name);
+ return error("packfile %s does not match index", p->pack_name);
+ return 0;
+}
+
+static int open_packed_git(struct packed_git *p)
+{
+ if (!open_packed_git_1(p))
+ return 0;
+ if (p->pack_fd != -1) {
+ close(p->pack_fd);
+ p->pack_fd = -1;
+ }
+ return -1;
}
static int in_window(struct pack_window *win, unsigned long offset)
@@ -607,8 +643,8 @@ unsigned char* use_pack(struct packed_git *p,
{
struct pack_window *win = *w_cursor;
- if (p->pack_fd == -1)
- open_packed_git(p);
+ if (p->pack_fd == -1 && open_packed_git(p))
+ die("packfile %s cannot be accessed", p->pack_name);
/* Since packfiles end in a hash of their content and its
* pointless to ask for an offset into the middle of that
@@ -759,7 +795,7 @@ static void prepare_packed_git_one(char *objdir, int local)
if (!has_extension(de->d_name, ".idx"))
continue;
- /* we have .idx. Is it a file we can map? */
+ /* Don't reopen a pack we already have. */
strcpy(path + len, de->d_name);
for (p = packed_git; p; p = p->next) {
if (!memcmp(path, p->pack_name, len + namelen - 4))
@@ -767,11 +803,13 @@ static void prepare_packed_git_one(char *objdir, int local)
}
if (p)
continue;
+ /* See if it really is a valid .idx file with corresponding
+ * .pack file that we can map.
+ */
p = add_packed_git(path, len + namelen, local);
if (!p)
continue;
- p->next = packed_git;
- packed_git = p;
+ install_packed_git(p);
}
closedir(dir);
}
@@ -1125,7 +1163,7 @@ static unsigned long unpack_object_header(struct packed_git *p,
/* use_pack() assures us we have [base, base + 20) available
* as a range that we can look at at. (Its actually the hash
- * size that is assurred.) With our object header encoding
+ * size that is assured.) With our object header encoding
* the maximum deflated object size is 2^137, which is just
* insane, so we know won't exceed what we have been given.
*/
@@ -1331,7 +1369,7 @@ int nth_packed_object_sha1(const struct packed_git *p, int n,
unsigned long find_pack_entry_one(const unsigned char *sha1,
struct packed_git *p)
{
- unsigned int *level1_ofs = p->index_base;
+ uint32_t *level1_ofs = p->index_base;
int hi = ntohl(level1_ofs[*sha1]);
int lo = ((*sha1 == 0x0) ? 0 : ntohl(level1_ofs[*sha1 - 1]));
void *index = p->index_base + 256;
@@ -1340,7 +1378,7 @@ unsigned long find_pack_entry_one(const unsigned char *sha1,
int mi = (lo + hi) / 2;
int cmp = hashcmp((unsigned char *)index + (24 * mi) + 4, sha1);
if (!cmp)
- return ntohl(*((unsigned int *) ((char *) index + (24 * mi))));
+ return ntohl(*((uint32_t *)((char *)index + (24 * mi))));
if (cmp > 0)
hi = mi;
else
@@ -1385,6 +1423,18 @@ static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, cons
}
offset = find_pack_entry_one(sha1, p);
if (offset) {
+ /*
+ * We are about to tell the caller where they can
+ * locate the requested object. We better make
+ * sure the packfile is still here and can be
+ * accessed before supplying that answer, as
+ * it may have been deleted since the index
+ * was loaded!
+ */
+ if (p->pack_fd == -1 && open_packed_git(p)) {
+ error("packfile %s cannot be accessed", p->pack_name);
+ continue;
+ }
e->offset = offset;
e->p = p;
hashcpy(e->sha1, sha1);
@@ -1449,21 +1499,77 @@ static void *read_packed_sha1(const unsigned char *sha1, char *type, unsigned lo
{
struct pack_entry e;
- if (!find_pack_entry(sha1, &e, NULL)) {
- error("cannot read sha1_file for %s", sha1_to_hex(sha1));
+ if (!find_pack_entry(sha1, &e, NULL))
return NULL;
+ else
+ return unpack_entry(e.p, e.offset, type, size);
+}
+
+/*
+ * This is meant to hold a *small* number of objects that you would
+ * want read_sha1_file() to be able to return, but yet you do not want
+ * to write them into the object store (e.g. a browse-only
+ * application).
+ */
+static struct cached_object {
+ unsigned char sha1[20];
+ const char *type;
+ void *buf;
+ unsigned long size;
+} *cached_objects;
+static int cached_object_nr, cached_object_alloc;
+
+static struct cached_object *find_cached_object(const unsigned char *sha1)
+{
+ int i;
+ struct cached_object *co = cached_objects;
+
+ for (i = 0; i < cached_object_nr; i++, co++) {
+ if (!hashcmp(co->sha1, sha1))
+ return co;
+ }
+ return NULL;
+}
+
+int pretend_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *sha1)
+{
+ struct cached_object *co;
+
+ hash_sha1_file(buf, len, type, sha1);
+ if (has_sha1_file(sha1) || find_cached_object(sha1))
+ return 0;
+ if (cached_object_alloc <= cached_object_nr) {
+ cached_object_alloc = alloc_nr(cached_object_alloc);
+ cached_objects = xrealloc(cached_objects,
+ sizeof(*cached_objects) *
+ cached_object_alloc);
}
- return unpack_entry(e.p, e.offset, type, size);
+ co = &cached_objects[cached_object_nr++];
+ co->size = len;
+ co->type = strdup(type);
+ hashcpy(co->sha1, sha1);
+ return 0;
}
void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size)
{
unsigned long mapsize;
void *map, *buf;
- struct pack_entry e;
+ struct cached_object *co;
+
+ co = find_cached_object(sha1);
+ if (co) {
+ buf = xmalloc(co->size + 1);
+ memcpy(buf, co->buf, co->size);
+ ((char*)buf)[co->size] = 0;
+ strcpy(type, co->type);
+ *size = co->size;
+ return buf;
+ }
- if (find_pack_entry(sha1, &e, NULL))
- return read_packed_sha1(sha1, type, size);
+ buf = read_packed_sha1(sha1, type, size);
+ if (buf)
+ return buf;
map = map_sha1_file(sha1, &mapsize);
if (map) {
buf = unpack_sha1_file(map, mapsize, type, size);
@@ -1471,9 +1577,7 @@ void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size
return buf;
}
reprepare_packed_git();
- if (find_pack_entry(sha1, &e, NULL))
- return read_packed_sha1(sha1, type, size);
- return NULL;
+ return read_packed_sha1(sha1, type, size);
}
void *read_object_with_reference(const unsigned char *sha1,
@@ -1611,12 +1715,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
static int write_buffer(int fd, const void *buf, size_t len)
{
- ssize_t size;
-
- size = write_in_full(fd, buf, len);
- if (!size)
- return error("file write: disk full");
- if (size < 0)
+ if (write_in_full(fd, buf, len) < 0)
return error("file write error (%s)", strerror(errno));
return 0;
}
@@ -1766,6 +1865,8 @@ static void *repack_object(const unsigned char *sha1, unsigned long *objsize)
/* need to unpack and recompress it by itself */
unpacked = read_packed_sha1(sha1, type, &len);
+ if (!unpacked)
+ error("cannot read sha1_file for %s", sha1_to_hex(sha1));
hdrlen = sprintf(hdr, "%s %lu", type, len) + 1;
@@ -1990,6 +2091,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con
if (!type)
type = blob_type;
+ /* FIXME: CRLF -> LF conversion here for blobs! We'll need the path! */
if (write_object)
ret = write_sha1_file(buf, size, type, sha1);
else
@@ -2034,3 +2136,24 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
}
return 0;
}
+
+int read_pack_header(int fd, struct pack_header *header)
+{
+ char *c = (char*)header;
+ ssize_t remaining = sizeof(struct pack_header);
+ do {
+ ssize_t r = xread(fd, c, remaining);
+ if (r <= 0)
+ /* "eof before pack header was fully read" */
+ return PH_ERROR_EOF;
+ remaining -= r;
+ c += r;
+ } while (remaining > 0);
+ if (header->hdr_signature != htonl(PACK_SIGNATURE))
+ /* "protocol error (pack signature mismatch detected)" */
+ return PH_ERROR_PACK_SIGNATURE;
+ if (!pack_version_ok(header->hdr_version))
+ /* "protocol error (pack version unsupported)" */
+ return PH_ERROR_PROTOCOL;
+ return 0;
+}
diff --git a/sha1_name.c b/sha1_name.c
index 6d7cd78381..a7efa96f35 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -235,24 +235,79 @@ static int ambiguous_path(const char *path, int len)
return slash;
}
+static const char *ref_fmt[] = {
+ "%.*s",
+ "refs/%.*s",
+ "refs/tags/%.*s",
+ "refs/heads/%.*s",
+ "refs/remotes/%.*s",
+ "refs/remotes/%.*s/HEAD",
+ NULL
+};
+
+int dwim_ref(const char *str, int len, unsigned char *sha1, char **ref)
+{
+ const char **p, *r;
+ int refs_found = 0;
+
+ *ref = NULL;
+ for (p = ref_fmt; *p; p++) {
+ unsigned char sha1_from_ref[20];
+ unsigned char *this_result;
+
+ this_result = refs_found ? sha1_from_ref : sha1;
+ r = resolve_ref(mkpath(*p, len, str), this_result, 1, NULL);
+ if (r) {
+ if (!refs_found++)
+ *ref = xstrdup(r);
+ if (!warn_ambiguous_refs)
+ break;
+ }
+ }
+ return refs_found;
+}
+
+int dwim_log(const char *str, int len, unsigned char *sha1, char **log)
+{
+ const char **p;
+ int logs_found = 0;
+
+ *log = NULL;
+ for (p = ref_fmt; *p; p++) {
+ struct stat st;
+ unsigned char hash[20];
+ char path[PATH_MAX];
+ const char *ref, *it;
+
+ strcpy(path, mkpath(*p, len, str));
+ ref = resolve_ref(path, hash, 0, NULL);
+ if (!ref)
+ continue;
+ if (!stat(git_path("logs/%s", path), &st) &&
+ S_ISREG(st.st_mode))
+ it = path;
+ else if (strcmp(ref, path) &&
+ !stat(git_path("logs/%s", ref), &st) &&
+ S_ISREG(st.st_mode))
+ it = ref;
+ else
+ continue;
+ if (!logs_found++) {
+ *log = xstrdup(it);
+ hashcpy(sha1, hash);
+ }
+ if (!warn_ambiguous_refs)
+ break;
+ }
+ return logs_found;
+}
+
static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
{
- static const char *fmt[] = {
- "%.*s",
- "refs/%.*s",
- "refs/tags/%.*s",
- "refs/heads/%.*s",
- "refs/remotes/%.*s",
- "refs/remotes/%.*s/HEAD",
- NULL
- };
static const char *warning = "warning: refname '%.*s' is ambiguous.\n";
- const char **p, *ref;
char *real_ref = NULL;
int refs_found = 0;
int at, reflog_len;
- unsigned char *this_result;
- unsigned char sha1_from_ref[20];
if (len == 40 && !get_sha1_hex(str, sha1))
return 0;
@@ -260,7 +315,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
/* basic@{time or number} format to query ref-log */
reflog_len = at = 0;
if (str[len-1] == '}') {
- for (at = 1; at < len - 1; at++) {
+ for (at = 0; at < len - 1; at++) {
if (str[at] == '@' && str[at+1] == '{') {
reflog_len = (len-1) - (at+2);
len = at;
@@ -270,19 +325,16 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
}
/* Accept only unambiguous ref paths. */
- if (ambiguous_path(str, len))
+ if (len && ambiguous_path(str, len))
return -1;
- for (p = fmt; *p; p++) {
- this_result = refs_found ? sha1_from_ref : sha1;
- ref = resolve_ref(mkpath(*p, len, str), this_result, 1, NULL);
- if (ref) {
- if (!refs_found++)
- real_ref = xstrdup(ref);
- if (!warn_ambiguous_refs)
- break;
- }
- }
+ if (!len && reflog_len) {
+ /* allow "@{...}" to mean the current branch reflog */
+ refs_found = dwim_ref("HEAD", 4, sha1, &real_ref);
+ } else if (reflog_len)
+ refs_found = dwim_log(str, len, sha1, &real_ref);
+ else
+ refs_found = dwim_ref(str, len, sha1, &real_ref);
if (!refs_found)
return -1;
@@ -291,9 +343,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
fprintf(stderr, warning, len, str);
if (reflog_len) {
- /* Is it asking for N-th entry, or approxidate? */
int nth, i;
unsigned long at_time;
+ unsigned long co_time;
+ int co_tz, co_cnt;
+
+ /* Is it asking for N-th entry, or approxidate? */
for (i = nth = 0; 0 <= nth && i < reflog_len; i++) {
char ch = str[at+2+i];
if ('0' <= ch && ch <= '9')
@@ -305,7 +360,18 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
at_time = 0;
else
at_time = approxidate(str + at + 2);
- read_ref_at(real_ref, at_time, nth, sha1);
+ if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
+ &co_time, &co_tz, &co_cnt)) {
+ if (at_time)
+ fprintf(stderr,
+ "warning: Log for '%.*s' only goes "
+ "back to %s.\n", len, str,
+ show_rfc2822_date(co_time, co_tz));
+ else
+ fprintf(stderr,
+ "warning: Log for '%.*s' only has "
+ "%d entries.\n", len, str, co_cnt);
+ }
}
free(real_ref);
diff --git a/shallow.c b/shallow.c
index 3d53d17423..d17868929c 100644
--- a/shallow.c
+++ b/shallow.c
@@ -17,7 +17,7 @@ int register_shallow(const unsigned char *sha1)
return register_commit_graft(graft, 0);
}
-int is_repository_shallow()
+int is_repository_shallow(void)
{
FILE *fp;
char buf[1024];
diff --git a/ssh-fetch.c b/ssh-fetch.c
index 4c172b6824..bdf51a7a14 100644
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
@@ -124,7 +124,6 @@ int main(int argc, char **argv)
prog = getenv("GIT_SSH_PUSH");
if (!prog) prog = "git-ssh-upload";
- setup_ident();
setup_git_directory();
git_config(git_default_config);
diff --git a/t/README b/t/README
index 7abab1dafe..36f2517617 100644
--- a/t/README
+++ b/t/README
@@ -18,7 +18,7 @@ The easiest way to run tests is to say "make". This runs all
the tests.
*** t0000-basic.sh ***
- * ok 1: .git/objects should be empty after git-init-db in an empty repo.
+ * ok 1: .git/objects should be empty after git-init in an empty repo.
* ok 2: .git/objects should have 256 subdirectories.
* ok 3: git-update-index without --add should fail adding.
...
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index b5ceba4acf..87403da780 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -113,7 +113,8 @@ test_expect_success \
test_expect_success \
'some edit' \
- 'perl -p -i.orig -e "s/^1A.*\n$//; s/^3A/99/" file &&
+ 'mv file file.orig &&
+ sed -e "s/^3A/99/" -e "/^1A/d" < file.orig > file &&
GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
test_expect_success \
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index af42ccc8d1..67d08cf740 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -25,14 +25,15 @@ perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
-SVN::Repos::create('$svnrepo', undef, undef, undef,
- { 'fs-config' => 'fsfs'});
-"
+system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
+" >&3 2>&4
x=$?
if test $x -ne 0
then
if test $x -eq 42; then
err='Perl SVN libraries must be >= 1.1.0'
+ elif test $x -eq 41; then
+ err='svnadmin failed to create fsfs repository'
else
err='Perl SVN libraries not found or unusable, skipping test'
fi
@@ -44,3 +45,6 @@ fi
svnrepo="file://$svnrepo"
+poke() {
+ perl -e '@x = stat($ARGV[0]); utime($x[8], $x[9] + 1, $ARGV[0])' "$1"
+}
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 0cd1c41866..186de70243 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -31,12 +31,12 @@ fi
. ./test-lib.sh
################################################################
-# init-db has been done in an empty repository.
+# git-init has been done in an empty repository.
# make sure it is empty.
find .git/objects -type f -print >should-be-empty
test_expect_success \
- '.git/objects should be empty after git-init-db in an empty repo.' \
+ '.git/objects should be empty after git-init in an empty repo.' \
'cmp -s /dev/null should-be-empty'
# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 4f664f6adf..c11420a8b6 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -87,7 +87,7 @@ test_expect_success 'three-way not complaining on an untracked path in both' '
git-read-tree -m -u branch-point master side
'
-test_expect_success 'three-way not cloberring a working tree file' '
+test_expect_success 'three-way not clobbering a working tree file' '
git reset --hard &&
rm -f file2 subdir/file2 file3 subdir/file3 &&
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index 4409b87f8d..1e8f9e59df 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -106,4 +106,33 @@ test_expect_success 'read-tree' '
cmp ../one ../original.one
'
+test_expect_success 'no file/rev ambiguity check inside .git' '
+ cd $HERE &&
+ git commit -a -m 1 &&
+ cd $HERE/.git &&
+ git show -s HEAD
+'
+
+test_expect_success 'no file/rev ambiguity check inside a bare repo' '
+ cd $HERE &&
+ git clone -s --bare .git foo.git &&
+ cd foo.git && GIT_DIR=. git show -s HEAD
+'
+
+# This still does not work as it should...
+: test_expect_success 'no file/rev ambiguity check inside a bare repo' '
+ cd $HERE &&
+ git clone -s --bare .git foo.git &&
+ cd foo.git && git show -s HEAD
+'
+
+test_expect_success 'detection should not be fooled by a symlink' '
+ cd $HERE &&
+ rm -fr foo.git &&
+ git clone -s .git another &&
+ ln -s another yetanother &&
+ cd yetanother/.git &&
+ git show -s HEAD
+'
+
test_done
diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh
index eebe643bda..ca2c30f7af 100755
--- a/t/t1200-tutorial.sh
+++ b/t/t1200-tutorial.sh
@@ -101,7 +101,9 @@ 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 resolve HEAD mybranch "Merge work in mybranch"'
+test_expect_failure 'git resolve now fails' '
+ git merge -m "Merge work in mybranch" mybranch
+'
cat > hello << EOF
Hello World
@@ -134,8 +136,8 @@ Updating from VARIABLE to VARIABLE
2 files changed, 2 insertions(+), 0 deletions(-)
EOF
-git resolve HEAD master "Merge upstream changes." | \
- sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" > resolve.output
+git merge -s "Merge upstream changes." master | \
+ sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" >resolve.output
test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'
cat > show-branch2.expect << EOF
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 60acdd368b..49b5666b33 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -3,13 +3,13 @@
# Copyright (c) 2005 Johannes Schindelin
#
-test_description='Test git-repo-config in different settings'
+test_description='Test git-config in different settings'
. ./test-lib.sh
test -f .git/config && rm .git/config
-git-repo-config core.penguin "little blue"
+git-config core.penguin "little blue"
cat > expect << EOF
[core]
@@ -18,7 +18,7 @@ EOF
test_expect_success 'initial' 'cmp .git/config expect'
-git-repo-config Core.Movie BadPhysics
+git-config Core.Movie BadPhysics
cat > expect << EOF
[core]
@@ -28,7 +28,7 @@ EOF
test_expect_success 'mixed case' 'cmp .git/config expect'
-git-repo-config Cores.WhatEver Second
+git-config Cores.WhatEver Second
cat > expect << EOF
[core]
@@ -40,7 +40,7 @@ EOF
test_expect_success 'similar section' 'cmp .git/config expect'
-git-repo-config CORE.UPPERCASE true
+git-config CORE.UPPERCASE true
cat > expect << EOF
[core]
@@ -54,10 +54,10 @@ EOF
test_expect_success 'similar section' 'cmp .git/config expect'
test_expect_success 'replace with non-match' \
- 'git-repo-config core.penguin kingpin !blue'
+ 'git-config core.penguin kingpin !blue'
test_expect_success 'replace with non-match (actually matching)' \
- 'git-repo-config core.penguin "very blue" !kingpin'
+ 'git-config core.penguin "very blue" !kingpin'
cat > expect << EOF
[core]
@@ -86,7 +86,7 @@ EOF
cp .git/config .git/config2
test_expect_success 'multiple unset' \
- 'git-repo-config --unset-all beta.haha'
+ 'git-config --unset-all beta.haha'
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -102,7 +102,7 @@ test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
mv .git/config2 .git/config
test_expect_success '--replace-all' \
- 'git-repo-config --replace-all beta.haha gamma'
+ 'git-config --replace-all beta.haha gamma'
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -116,7 +116,7 @@ EOF
test_expect_success 'all replaced' 'cmp .git/config expect'
-git-repo-config beta.haha alpha
+git-config beta.haha alpha
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -130,7 +130,7 @@ EOF
test_expect_success 'really mean test' 'cmp .git/config expect'
-git-repo-config nextsection.nonewline wow
+git-config nextsection.nonewline wow
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -145,8 +145,8 @@ EOF
test_expect_success 'really really mean test' 'cmp .git/config expect'
-test_expect_success 'get value' 'test alpha = $(git-repo-config beta.haha)'
-git-repo-config --unset beta.haha
+test_expect_success 'get value' 'test alpha = $(git-config beta.haha)'
+git-config --unset beta.haha
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -160,7 +160,7 @@ EOF
test_expect_success 'unset' 'cmp .git/config expect'
-git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
+git-config nextsection.NoNewLine "wow2 for me" "for me$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -176,18 +176,18 @@ EOF
test_expect_success 'multivar' 'cmp .git/config expect'
test_expect_success 'non-match' \
- 'git-repo-config --get nextsection.nonewline !for'
+ 'git-config --get nextsection.nonewline !for'
test_expect_success 'non-match value' \
- 'test wow = $(git-repo-config --get nextsection.nonewline !for)'
+ 'test wow = $(git-config --get nextsection.nonewline !for)'
test_expect_failure 'ambiguous get' \
- 'git-repo-config --get nextsection.nonewline'
+ 'git-config --get nextsection.nonewline'
test_expect_success 'get multivar' \
- 'git-repo-config --get-all nextsection.nonewline'
+ 'git-config --get-all nextsection.nonewline'
-git-repo-config nextsection.nonewline "wow3" "wow$"
+git-config nextsection.nonewline "wow3" "wow$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -202,15 +202,15 @@ EOF
test_expect_success 'multivar replace' 'cmp .git/config expect'
-test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline'
+test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline'
test_expect_failure 'ambiguous unset' \
- 'git-repo-config --unset nextsection.nonewline'
+ 'git-config --unset nextsection.nonewline'
test_expect_failure 'invalid unset' \
- 'git-repo-config --unset somesection.nonewline'
+ 'git-config --unset somesection.nonewline'
-git-repo-config --unset nextsection.nonewline "wow3$"
+git-config --unset nextsection.nonewline "wow3$"
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -224,12 +224,12 @@ EOF
test_expect_success 'multivar unset' 'cmp .git/config expect'
-test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla'
+test_expect_failure 'invalid key' 'git-config inval.2key blabla'
-test_expect_success 'correct key' 'git-repo-config 123456.a123 987'
+test_expect_success 'correct key' 'git-config 123456.a123 987'
test_expect_success 'hierarchical section' \
- 'git-repo-config Version.1.2.3eX.Alpha beta'
+ 'git-config Version.1.2.3eX.Alpha beta'
cat > expect << EOF
[beta] ; silly comment # another comment
@@ -255,7 +255,7 @@ version.1.2.3eX.alpha=beta
EOF
test_expect_success 'working --list' \
- 'git-repo-config --list > output && cmp output expect'
+ 'git-config --list > output && cmp output expect'
cat > expect << EOF
beta.noindent sillyValue
@@ -263,9 +263,9 @@ nextsection.nonewline wow2 for me
EOF
test_expect_success '--get-regexp' \
- 'git-repo-config --get-regexp in > output && cmp output expect'
+ 'git-config --get-regexp in > output && cmp output expect'
-git-repo-config --add nextsection.nonewline "wow4 for you"
+git-config --add nextsection.nonewline "wow4 for you"
cat > expect << EOF
wow2 for me
@@ -273,7 +273,7 @@ wow4 for you
EOF
test_expect_success '--add' \
- 'git-repo-config --get-all nextsection.nonewline > output && cmp output expect'
+ 'git-config --get-all nextsection.nonewline > output && cmp output expect'
cat > .git/config << EOF
[novalue]
@@ -281,9 +281,9 @@ cat > .git/config << EOF
EOF
test_expect_success 'get variable with no value' \
- 'git-repo-config --get novalue.variable ^$'
+ 'git-config --get novalue.variable ^$'
-git-repo-config > output 2>&1
+git-config > output 2>&1
test_expect_success 'no arguments, but no crash' \
"test $? = 129 && grep usage output"
@@ -293,7 +293,7 @@ cat > .git/config << EOF
c = d
EOF
-git-repo-config a.x y
+git-config a.x y
cat > expect << EOF
[a.b]
@@ -304,8 +304,8 @@ EOF
test_expect_success 'new section is partial match of another' 'cmp .git/config expect'
-git-repo-config b.x y
-git-repo-config a.b c
+git-config b.x y
+git-config a.b c
cat > expect << EOF
[a.b]
@@ -328,11 +328,11 @@ cat > expect << EOF
ein.bahn=strasse
EOF
-GIT_CONFIG=other-config git-repo-config -l > output
+GIT_CONFIG=other-config git-config -l > output
test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
-GIT_CONFIG=other-config git-repo-config anwohner.park ausweis
+GIT_CONFIG=other-config git-config anwohner.park ausweis
cat > expect << EOF
[ein]
@@ -355,7 +355,7 @@ weird
EOF
test_expect_success "rename section" \
- "git-repo-config --rename-section branch.eins branch.zwei"
+ "git-config --rename-section branch.eins branch.zwei"
cat > expect << EOF
# Hallo
@@ -371,12 +371,12 @@ EOF
test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_failure "rename non-existing section" \
- 'git-repo-config --rename-section branch."world domination" branch.drei'
+ 'git-config --rename-section branch."world domination" branch.drei'
test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename another section" \
- 'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei'
+ 'git-config --rename-section branch."1 234 blabl/a" branch.drei'
cat > expect << EOF
# Hallo
@@ -393,20 +393,20 @@ test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success numbers '
- git-repo-config kilo.gram 1k &&
- git-repo-config mega.ton 1m &&
- k=$(git-repo-config --int --get kilo.gram) &&
+ git-config kilo.gram 1k &&
+ git-config mega.ton 1m &&
+ k=$(git-config --int --get kilo.gram) &&
test z1024 = "z$k" &&
- m=$(git-repo-config --int --get mega.ton) &&
+ m=$(git-config --int --get mega.ton) &&
test z1048576 = "z$m"
'
rm .git/config
-git-repo-config quote.leading " test"
-git-repo-config quote.ending "test "
-git-repo-config quote.semicolon "test;test"
-git-repo-config quote.hash "test#test"
+git-config quote.leading " test"
+git-config quote.ending "test "
+git-config quote.semicolon "test;test"
+git-config quote.hash "test#test"
cat > expect << EOF
[quote]
@@ -418,5 +418,31 @@ EOF
test_expect_success 'quoting' 'cmp .git/config expect'
+test_expect_failure 'key with newline' 'git config key.with\\\
+newline 123'
+
+test_expect_success 'value with newline' 'git config key.sub value.with\\\
+newline'
+
+cat > .git/config <<\EOF
+[section]
+ ; comment \
+ continued = cont\
+inued
+ noncont = not continued ; \
+ quotecont = "cont;\
+inued"
+EOF
+
+cat > expect <<\EOF
+section.continued=continued
+section.noncont=not continued
+section.quotecont=cont;inued
+EOF
+
+git config --list > result
+
+test_expect_success 'value continued on next line' 'cmp result expect'
+
test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index 5637cb5eac..d0aba2c2ae 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -93,8 +93,8 @@ rm -rf .git/$m .git/logs expect
test_expect_success \
'enable core.logAllRefUpdates' \
- 'git-repo-config core.logAllRefUpdates true &&
- test true = $(git-repo-config --bool --get core.logAllRefUpdates)'
+ 'git-config core.logAllRefUpdates true &&
+ test true = $(git-config --bool --get core.logAllRefUpdates)'
test_expect_success \
"create $m (logged by config)" \
@@ -138,19 +138,19 @@ test_expect_success \
'rm -f o e
git-rev-parse --verify "master@{May 25 2005}" >o 2>e &&
test '"$C"' = $(cat o) &&
- test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
+ test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \
"Query master@{2005-05-25} (before history)" \
'rm -f o e
git-rev-parse --verify master@{2005-05-25} >o 2>e &&
test '"$C"' = $(cat o) &&
- echo test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
+ echo test "warning: Log for '\'master\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \
'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
'rm -f o e
git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
test '"$C"' = $(cat o) &&
- test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
+ test "warning: Log for '\''master'\'' only goes back to $ed." = "$(cat e)"'
test_expect_success \
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index 738d1513d4..e5bbc384f7 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -20,7 +20,7 @@ check_have () {
}
check_fsck () {
- output=$(git fsck-objects --full)
+ output=$(git fsck --full)
case "$1" in
'')
test -z "$output" ;;
@@ -71,6 +71,8 @@ test_expect_success setup '
check_fsck &&
chmod +x C &&
+ ( test "`git config --bool core.filemode`" != false ||
+ echo executable >>C ) &&
git add C &&
test_tick && git commit -m dragon &&
L=`git rev-parse --verify HEAD` &&
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index a6ea0f6a19..5565c27033 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -48,7 +48,7 @@ test_expect_success \
test ! -f .git/logs/refs/heads/d/e/f'
cat >expect <<EOF
-0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master^0
+0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master
EOF
test_expect_success \
'git checkout -b g/h/i -l should create a branch and a log' \
@@ -94,7 +94,7 @@ test_expect_failure \
git-branch r &&
git-branch -m q r/q'
-git-repo-config branch.s/s.dummy Hello
+git-config branch.s/s.dummy Hello
test_expect_success \
'git branch -m s/s s should work when s/t is deleted' \
@@ -107,8 +107,8 @@ test_expect_success \
test -f .git/logs/refs/heads/s'
test_expect_success 'config information was renamed, too' \
- "test $(git-repo-config branch.s.dummy) = Hello &&
- ! git-repo-config branch.s/s/dummy"
+ "test $(git-config branch.s.dummy) = Hello &&
+ ! git-config branch.s/s/dummy"
test_expect_failure \
'git-branch -m u v should fail when the reflog for u is a symlink' \
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 16bdae4f23..f0c7e22b36 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -96,4 +96,13 @@ test_expect_success \
git-branch -d n/o/p &&
git-branch n'
+test_expect_success 'pack, prune and repack' '
+ git-tag foo &&
+ git-pack-refs --all --prune &&
+ git-show-ref >all-of-them &&
+ git-pack-refs &&
+ git-show-ref >again &&
+ diff all-of-them again
+'
+
test_done
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
new file mode 100755
index 0000000000..552af1c4d2
--- /dev/null
+++ b/t/t3501-revert-cherry-pick.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+test_description='test cherry-pick and revert with renames
+
+ --
+ + rename2: renames oops to opos
+ + rename1: renames oops to spoo
+ + added: adds extra line to oops
+ ++ initial: has lines in oops
+
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ for l in a b c d e f g h i j k l m n o
+ do
+ echo $l$l$l$l$l$l$l$l$l
+ done >oops &&
+
+ test_tick &&
+ git add oops &&
+ git commit -m initial &&
+ git tag initial &&
+
+ test_tick &&
+ echo "Add extra line at the end" >>oops &&
+ git commit -a -m added &&
+ git tag added &&
+
+ test_tick &&
+ git mv oops spoo &&
+ git commit -m rename1 &&
+ git tag rename1 &&
+
+ test_tick &&
+ git checkout -b side initial &&
+ git mv oops opos &&
+ git commit -m rename2 &&
+ git tag rename2
+'
+
+test_expect_success 'cherry-pick after renaming branch' '
+
+ git checkout rename2 &&
+ EDITOR=: VISUAL=: git cherry-pick added &&
+ test -f opos &&
+ grep "Add extra line at the end" opos
+
+'
+
+test_expect_success 'revert after renaming branch' '
+
+ git checkout rename1 &&
+ EDITOR=: VISUAL=: git revert added &&
+ test -f spoo &&
+ ! grep "Add extra line at the end" spoo
+
+'
+
+test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index e98786de32..caaab26c2f 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -21,7 +21,7 @@ test_expect_success \
test_expect_success \
'git-add: Test that executable bit is not used if core.filemode=0' \
- 'git repo-config core.filemode 0 &&
+ 'git config core.filemode 0 &&
echo foo >xfoo1 &&
chmod 755 xfoo1 &&
git-add xfoo1 &&
@@ -32,7 +32,7 @@ test_expect_success \
test_expect_success \
'git-update-index --add: Test that executable bit is not used...' \
- 'git repo-config core.filemode 0 &&
+ 'git config core.filemode 0 &&
echo foo >xfoo2 &&
chmod 755 xfoo2 &&
git-update-index --add xfoo2 &&
@@ -43,7 +43,7 @@ test_expect_success \
test_expect_success \
'git-update-index --add: Test that executable bit is not used...' \
- 'git repo-config core.filemode 0 &&
+ 'git config core.filemode 0 &&
ln -s xfoo2 xfoo3 &&
git-update-index --add xfoo3 &&
case "`git-ls-files --stage xfoo3`" in
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
index 5b23b7769d..7c7e4335d6 100755
--- a/t/t3800-mktag.sh
+++ b/t/t3800-mktag.sh
@@ -88,7 +88,7 @@ check_verify_failure '"type" line label check'
# 5. type line eol check
echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
-echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig
+printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
cat >expect.pat <<EOF
^error: char48: .*"[\]n"$
@@ -172,7 +172,7 @@ EOF
check_verify_failure 'verify tag-name check'
############################################################
-# 11. tagger line lable check #1
+# 11. tagger line label check #1
cat >tag.sig <<EOF
object $head
@@ -187,7 +187,7 @@ EOF
check_verify_failure '"tagger" line label check #1'
############################################################
-# 12. tagger line lable check #2
+# 12. tagger line label check #2
cat >tag.sig <<EOF
object $head
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index 6714b0dd6e..e54fe0f401 100755
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
@@ -29,7 +29,7 @@ test_expect_success 'no encoding header for base case' '
for H in ISO-8859-1 EUCJP ISO-2022-JP
do
test_expect_success "$H setup" '
- git-repo-config i18n.commitencoding $H &&
+ git-config i18n.commitencoding $H &&
git-checkout -b $H C0 &&
echo $H >F &&
git-commit -a -F ../t3900/$H.txt
@@ -44,16 +44,16 @@ do
'
done
-test_expect_success 'repo-config to remove customization' '
- git-repo-config --unset-all i18n.commitencoding &&
- if Z=$(git-repo-config --get-all i18n.commitencoding)
+test_expect_success 'config to remove customization' '
+ git-config --unset-all i18n.commitencoding &&
+ if Z=$(git-config --get-all i18n.commitencoding)
then
echo Oops, should have failed.
false
else
test z = "z$Z"
fi &&
- git-repo-config i18n.commitencoding utf-8
+ git-config i18n.commitencoding utf-8
'
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
@@ -67,9 +67,9 @@ do
'
done
-test_expect_success 'repo-config to add customization' '
- git-repo-config --unset-all i18n.commitencoding &&
- if Z=$(git-repo-config --get-all i18n.commitencoding)
+test_expect_success 'config to add customization' '
+ git-config --unset-all i18n.commitencoding &&
+ if Z=$(git-config --get-all i18n.commitencoding)
then
echo Oops, should have failed.
false
@@ -81,13 +81,13 @@ test_expect_success 'repo-config to add customization' '
for H in ISO-8859-1 EUCJP ISO-2022-JP
do
test_expect_success "$H should be shown in itself now" '
- git-repo-config i18n.commitencoding '$H' &&
+ git-config i18n.commitencoding '$H' &&
compare_with '$H' ../t3900/'$H'.txt
'
done
-test_expect_success 'repo-config to tweak customization' '
- git-repo-config i18n.logoutputencoding utf-8
+test_expect_success 'config to tweak customization' '
+ git-config i18n.logoutputencoding utf-8
'
test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
@@ -103,7 +103,7 @@ done
for J in EUCJP ISO-2022-JP
do
- git-repo-config i18n.logoutputencoding $J
+ git-config i18n.logoutputencoding $J
for H in EUCJP ISO-2022-JP
do
test_expect_success "$H should be shown in $J now" '
diff --git a/t/t3901-8859-1.txt b/t/t3901-8859-1.txt
new file mode 100755
index 0000000000..38c21a6a7f
--- /dev/null
+++ b/t/t3901-8859-1.txt
@@ -0,0 +1,4 @@
+: to be sourced in t3901 -- this is latin-1
+GIT_AUTHOR_NAME="Áéí óú" &&
+GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME &&
+export GIT_AUTHOR_NAME GIT_COMMITTER_NAME
diff --git a/t/t3901-i18n-patch.sh b/t/t3901-i18n-patch.sh
new file mode 100755
index 0000000000..a881797bc7
--- /dev/null
+++ b/t/t3901-i18n-patch.sh
@@ -0,0 +1,255 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+test_description='i18n settings and format-patch | am pipe'
+
+. ./test-lib.sh
+
+check_encoding () {
+ # Make sure characters are not corrupted
+ cnt="$1" header="$2" i=1 j=0 bad=0
+ while test "$i" -le $cnt
+ do
+ git format-patch --encoding=UTF-8 --stdout HEAD~$i..HEAD~$j |
+ grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" &&
+ git-cat-file commit HEAD~$j |
+ case "$header" in
+ 8859)
+ grep "^encoding ISO-8859-1" ;;
+ *)
+ ! grep "^encoding ISO-8859-1" ;;
+ esac || {
+ bad=1
+ break
+ }
+ j=$i
+ i=$(($i+1))
+ done
+ (exit $bad)
+}
+
+test_expect_success setup '
+ git-config i18n.commitencoding UTF-8 &&
+
+ # use UTF-8 in author and committer name to match the
+ # i18n.commitencoding settings
+ . ../t3901-utf8.txt &&
+
+ test_tick &&
+ echo "$GIT_AUTHOR_NAME" >mine &&
+ git add mine &&
+ git commit -s -m "Initial commit" &&
+
+ test_tick &&
+ echo Hello world >mine &&
+ git add mine &&
+ git commit -s -m "Second on main" &&
+
+ # the first commit on the side branch is UTF-8
+ test_tick &&
+ git checkout -b side master^ &&
+ echo Another file >yours &&
+ git add yours &&
+ git commit -s -m "Second on side" &&
+
+ # the second one on the side branch is ISO-8859-1
+ git-config i18n.commitencoding ISO-8859-1 &&
+ # use author and committer name in ISO-8859-1 to match it.
+ . ../t3901-8859-1.txt &&
+ test_tick &&
+ echo Yet another >theirs &&
+ git add theirs &&
+ git commit -s -m "Third on side" &&
+
+ # Back to default
+ git-config i18n.commitencoding UTF-8
+'
+
+test_expect_success 'format-patch output (ISO-8859-1)' '
+ git-config i18n.logoutputencoding ISO-8859-1 &&
+
+ git format-patch --stdout master..HEAD^ >out-l1 &&
+ git format-patch --stdout HEAD^ >out-l2 &&
+ grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&
+ grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 &&
+ grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&
+ grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l2
+'
+
+test_expect_success 'format-patch output (UTF-8)' '
+ git config i18n.logoutputencoding UTF-8 &&
+
+ git format-patch --stdout master..HEAD^ >out-u1 &&
+ git format-patch --stdout HEAD^ >out-u2 &&
+ grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&
+ grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 &&
+ grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&
+ grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u2
+'
+
+test_expect_success 'rebase (U/U)' '
+ # We want the result of rebase in UTF-8
+ git-config i18n.commitencoding UTF-8 &&
+
+ # The test is about logoutputencoding not affecting the
+ # final outcome -- it is used internally to generate the
+ # patch and the log.
+
+ git config i18n.logoutputencoding UTF-8 &&
+
+ # The result will be committed by GIT_COMMITTER_NAME --
+ # we want UTF-8 encoded name.
+ . ../t3901-utf8.txt &&
+ git checkout -b test &&
+ git-rebase master &&
+
+ check_encoding 2
+'
+
+test_expect_success 'rebase (U/L)' '
+ git-config i18n.commitencoding UTF-8 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-utf8.txt &&
+
+ git reset --hard side &&
+ git-rebase master &&
+
+ check_encoding 2
+'
+
+test_expect_success 'rebase (L/L)' '
+ # In this test we want ISO-8859-1 encoded commits as the result
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard side &&
+ git-rebase master &&
+
+ check_encoding 2 8859
+'
+
+test_expect_success 'rebase (L/U)' '
+ # This is pathological -- use UTF-8 as intermediate form
+ # to get ISO-8859-1 results.
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding UTF-8 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard side &&
+ git-rebase master &&
+
+ check_encoding 2 8859
+'
+
+test_expect_success 'cherry-pick(U/U)' '
+ # Both the commitencoding and logoutputencoding is set to UTF-8.
+
+ git-config i18n.commitencoding UTF-8 &&
+ git config i18n.logoutputencoding UTF-8 &&
+ . ../t3901-utf8.txt &&
+
+ git reset --hard master &&
+ git cherry-pick side^ &&
+ git cherry-pick side &&
+ EDITOR=: VISUAL=: git revert HEAD &&
+
+ check_encoding 3
+'
+
+test_expect_success 'cherry-pick(L/L)' '
+ # Both the commitencoding and logoutputencoding is set to ISO-8859-1
+
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard master &&
+ git cherry-pick side^ &&
+ git cherry-pick side &&
+ EDITOR=: VISUAL=: git revert HEAD &&
+
+ check_encoding 3 8859
+'
+
+test_expect_success 'cherry-pick(U/L)' '
+ # Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
+
+ git-config i18n.commitencoding UTF-8 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-utf8.txt &&
+
+ git reset --hard master &&
+ git cherry-pick side^ &&
+ git cherry-pick side &&
+ EDITOR=: VISUAL=: git revert HEAD &&
+
+ check_encoding 3
+'
+
+test_expect_success 'cherry-pick(L/U)' '
+ # Again, the commitencoding is set to ISO-8859-1 but
+ # logoutputencoding is set to UTF-8.
+
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding UTF-8 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard master &&
+ git cherry-pick side^ &&
+ git cherry-pick side &&
+ EDITOR=: VISUAL=: git revert HEAD &&
+
+ check_encoding 3 8859
+'
+
+test_expect_success 'rebase --merge (U/U)' '
+ git-config i18n.commitencoding UTF-8 &&
+ git config i18n.logoutputencoding UTF-8 &&
+ . ../t3901-utf8.txt &&
+
+ git reset --hard side &&
+ git-rebase --merge master &&
+
+ check_encoding 2
+'
+
+test_expect_success 'rebase --merge (U/L)' '
+ git-config i18n.commitencoding UTF-8 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-utf8.txt &&
+
+ git reset --hard side &&
+ git-rebase --merge master &&
+
+ check_encoding 2
+'
+
+test_expect_success 'rebase --merge (L/L)' '
+ # In this test we want ISO-8859-1 encoded commits as the result
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding ISO-8859-1 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard side &&
+ git-rebase --merge master &&
+
+ check_encoding 2 8859
+'
+
+test_expect_success 'rebase --merge (L/U)' '
+ # This is pathological -- use UTF-8 as intermediate form
+ # to get ISO-8859-1 results.
+ git-config i18n.commitencoding ISO-8859-1 &&
+ git config i18n.logoutputencoding UTF-8 &&
+ . ../t3901-8859-1.txt &&
+
+ git reset --hard side &&
+ git-rebase --merge master &&
+
+ check_encoding 2 8859
+'
+
+test_done
diff --git a/t/t3901-utf8.txt b/t/t3901-utf8.txt
new file mode 100755
index 0000000000..5f5205cd02
--- /dev/null
+++ b/t/t3901-utf8.txt
@@ -0,0 +1,4 @@
+: to be sourced in t3901 -- this is utf8
+GIT_AUTHOR_NAME="Ãéí óú" &&
+GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME &&
+export GIT_AUTHOR_NAME GIT_COMMITTER_NAME
diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh
index 67b9681d36..9c58d77cc2 100755
--- a/t/t4000-diff-format.sh
+++ b/t/t4000-diff-format.sh
@@ -28,7 +28,7 @@ test_expect_success \
'git-diff-files -p >current'
# that's as far as it comes
-if [ "$(git repo-config --get core.filemode)" = false ]
+if [ "$(git config --get core.filemode)" = false ]
then
say 'filemode disabled on the filesystem'
test_done
diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh
index 8ad69d1115..ca342f48a1 100755
--- a/t/t4006-diff-mode.sh
+++ b/t/t4006-diff-mode.sh
@@ -15,7 +15,7 @@ test_expect_success \
tree=`git-write-tree` &&
echo $tree'
-if [ "$(git repo-config --get core.filemode)" = false ]
+if [ "$(git config --get core.filemode)" = false ]
then
say 'filemode disabled on the filesystem, using update-index --chmod=+x'
test_expect_success \
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index ed37141b6e..3d85ceaae9 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -73,7 +73,7 @@ test_expect_success setup '
for i in 1 2; do echo $i; done >>dir/sub &&
git update-index file0 dir/sub &&
- git repo-config log.showroot false &&
+ git config log.showroot false &&
git commit --amend &&
git show-branch
'
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master b/t/t4013/diff.format-patch_--attach_--stdout_initial..master
index b4745e1001..e5ddd6fcbb 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master
@@ -19,6 +19,7 @@ This is the second commit.
file0 | 3 +++
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
+ delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
@@ -77,6 +78,7 @@ Content-Transfer-Encoding: 8bit
dir/sub | 2 ++
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
@@ -126,6 +128,7 @@ Content-Transfer-Encoding: 8bit
file0 | 3 +++
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
+ create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
index a9d1cd368b..d0dd19b623 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..master^
@@ -19,6 +19,7 @@ This is the second commit.
file0 | 3 +++
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
+ delete mode 100644 file2
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="1bde4ae5f36c8d9abe3a0fce0c6aab3c4a12fe44.diff"
@@ -77,6 +78,7 @@ Content-Transfer-Encoding: 8bit
dir/sub | 2 ++
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 file1
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0.diff"
diff --git a/t/t4013/diff.format-patch_--attach_--stdout_initial..side b/t/t4013/diff.format-patch_--attach_--stdout_initial..side
index 57b9d0bdc1..67a95c5cba 100644
--- a/t/t4013/diff.format-patch_--attach_--stdout_initial..side
+++ b/t/t4013/diff.format-patch_--attach_--stdout_initial..side
@@ -17,6 +17,7 @@ Content-Transfer-Encoding: 8bit
file0 | 3 +++
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
+ create mode 100644 file3
--------------g-i-t--v-e-r-s-i-o-n
Content-Type: text/x-patch;
name="c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a.diff"
diff --git a/t/t4013/diff.format-patch_--stdout_initial..master b/t/t4013/diff.format-patch_--stdout_initial..master
index c33302e92f..8b88ca4927 100644
--- a/t/t4013/diff.format-patch_--stdout_initial..master
+++ b/t/t4013/diff.format-patch_--stdout_initial..master
@@ -10,6 +10,7 @@ This is the second commit.
file0 | 3 +++
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
+ delete mode 100644 file2
diff --git a/dir/sub b/dir/sub
index 35d242b..8422d40 100644
@@ -53,6 +54,7 @@ Subject: [PATCH] Third
dir/sub | 2 ++
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 file1
diff --git a/dir/sub b/dir/sub
index 8422d40..cead32e 100644
@@ -87,6 +89,7 @@ Subject: [PATCH] Side
file0 | 3 +++
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
+ create mode 100644 file3
diff --git a/dir/sub b/dir/sub
index 35d242b..7289e35 100644
diff --git a/t/t4013/diff.format-patch_--stdout_initial..master^ b/t/t4013/diff.format-patch_--stdout_initial..master^
index 03d0f9693c..47a4b88637 100644
--- a/t/t4013/diff.format-patch_--stdout_initial..master^
+++ b/t/t4013/diff.format-patch_--stdout_initial..master^
@@ -10,6 +10,7 @@ This is the second commit.
file0 | 3 +++
file2 | 3 ---
3 files changed, 5 insertions(+), 3 deletions(-)
+ delete mode 100644 file2
diff --git a/dir/sub b/dir/sub
index 35d242b..8422d40 100644
@@ -53,6 +54,7 @@ Subject: [PATCH] Third
dir/sub | 2 ++
file1 | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)
+ create mode 100644 file1
diff --git a/dir/sub b/dir/sub
index 8422d40..cead32e 100644
diff --git a/t/t4013/diff.format-patch_--stdout_initial..side b/t/t4013/diff.format-patch_--stdout_initial..side
index d10a46523b..e765088475 100644
--- a/t/t4013/diff.format-patch_--stdout_initial..side
+++ b/t/t4013/diff.format-patch_--stdout_initial..side
@@ -9,6 +9,7 @@ Subject: [PATCH] Side
file0 | 3 +++
file3 | 4 ++++
3 files changed, 9 insertions(+), 0 deletions(-)
+ create mode 100644 file3
diff --git a/dir/sub b/dir/sub
index 35d242b..7289e35 100644
diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh
new file mode 100755
index 0000000000..edde8f5568
--- /dev/null
+++ b/t/t4016-diff-quote.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Junio C Hamano
+#
+
+test_description='Quoting paths in diff output.
+'
+
+. ./test-lib.sh
+
+P0='pathname'
+P1='pathname with HT'
+P2='pathname with SP'
+P3='pathname
+with LF'
+
+test_expect_success setup '
+ echo P0.0 >"$P0.0" &&
+ echo P0.1 >"$P0.1" &&
+ echo P0.2 >"$P0.2" &&
+ echo P0.3 >"$P0.3" &&
+ echo P1.0 >"$P1.0" &&
+ echo P1.2 >"$P1.2" &&
+ echo P1.3 >"$P1.3" &&
+ git add . &&
+ git commit -m initial &&
+ git mv "$P0.0" "R$P0.0" &&
+ git mv "$P0.1" "R$P1.0" &&
+ git mv "$P0.2" "R$P2.0" &&
+ git mv "$P0.3" "R$P3.0" &&
+ git mv "$P1.0" "R$P0.1" &&
+ git mv "$P1.2" "R$P2.1" &&
+ git mv "$P1.3" "R$P3.1" &&
+ :
+'
+
+cat >expect <<\EOF
+ rename pathname.1 => "Rpathname\twith HT.0" (100%)
+ rename pathname.3 => "Rpathname\nwith LF.0" (100%)
+ rename "pathname\twith HT.3" => "Rpathname\nwith LF.1" (100%)
+ rename pathname.2 => Rpathname with SP.0 (100%)
+ rename "pathname\twith HT.2" => Rpathname with SP.1 (100%)
+ rename pathname.0 => Rpathname.0 (100%)
+ rename "pathname\twith HT.0" => Rpathname.1 (100%)
+EOF
+test_expect_success 'git diff --summary -M HEAD' '
+ git diff --summary -M HEAD >actual &&
+ diff -u 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
+ 7 files changed, 0 insertions(+), 0 deletions(-)
+EOF
+test_expect_success 'git diff --stat -M HEAD' '
+ git diff --stat -M HEAD >actual &&
+ diff -u expect actual
+'
+
+test_done
diff --git a/t/t4102-apply-rename.sh b/t/t4102-apply-rename.sh
index 22da6a00cc..b4662b0364 100755
--- a/t/t4102-apply-rename.sh
+++ b/t/t4102-apply-rename.sh
@@ -31,7 +31,7 @@ test_expect_success setup \
test_expect_success apply \
'git-apply --index --stat --summary --apply test-patch'
-if [ "$(git repo-config --get core.filemode)" = false ]
+if [ "$(git config --get core.filemode)" = false ]
then
say 'filemode disabled on the filesystem'
else
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 74f5c2a575..aa2c869e0e 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -50,12 +50,12 @@ test_expect_success 'setup separate repository lacking postimage' '
git tar-tree initial initial | tar xf - &&
(
- cd initial && git init-db && git add .
+ cd initial && git init && git add .
) &&
git tar-tree second second | tar xf - &&
(
- cd second && git init-db && git add .
+ cd second && git init && git add .
)
'
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 5ee5b23095..c571a1bd74 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -113,41 +113,38 @@ mkdir $rr2
echo Hello > $rr2/preimage
case "$(date -d @11111111 +%s 2>/dev/null)" in
-[1-9]*)
- # it is a recent GNU date. good.
+11111111)
+ # 'date' must be able to take arbitrary input with @11111111 notation.
+ # for this test to succeed. We should fix this part using more
+ # portable script someday.
+
now=$(date +%s)
almost_15_days_ago=$(($now+60-15*86400))
just_over_15_days_ago=$(($now-1-15*86400))
almost_60_days_ago=$(($now+60-60*86400))
just_over_60_days_ago=$(($now-1-60*86400))
- predate1="$(date -d "@$almost_60_days_ago" +%c)"
- predate2="$(date -d "@$almost_15_days_ago" +%c)"
- postdate1="$(date -d "@$just_over_60_days_ago" +%c)"
- postdate2="$(date -d "@$just_over_15_days_ago" +%c)"
- ;;
-*)
- # it is not GNU date. oh, well.
- predate1="$(date)"
- predate2="$(date)"
- postdate1='1 Oct 2006 00:00:00'
- postdate2='1 Dec 2006 00:00:00'
-esac
+ predate1="$(date -d "@$almost_60_days_ago" +%Y%m%d%H%M.%S)"
+ predate2="$(date -d "@$almost_15_days_ago" +%Y%m%d%H%M.%S)"
+ postdate1="$(date -d "@$just_over_60_days_ago" +%Y%m%d%H%M.%S)"
+ postdate2="$(date -d "@$just_over_15_days_ago" +%Y%m%d%H%M.%S)"
-touch -m -d "$predate1" $rr/preimage
-touch -m -d "$predate2" $rr2/preimage
+ touch -m -t "$predate1" $rr/preimage
+ touch -m -t "$predate2" $rr2/preimage
-test_expect_success 'garbage collection (part1)' 'git rerere gc'
+ test_expect_success 'garbage collection (part1)' 'git rerere gc'
-test_expect_success 'young records still live' \
- "test -f $rr/preimage -a -f $rr2/preimage"
+ test_expect_success 'young records still live' \
+ "test -f $rr/preimage -a -f $rr2/preimage"
-touch -m -d "$postdate1" $rr/preimage
-touch -m -d "$postdate2" $rr2/preimage
+ touch -m -t "$postdate1" $rr/preimage
+ touch -m -t "$postdate2" $rr2/preimage
-test_expect_success 'garbage collection (part2)' 'git rerere gc'
+ test_expect_success 'garbage collection (part2)' 'git rerere gc'
-test_expect_success 'old records rest in peace' \
- "test ! -f $rr/preimage -a ! -f $rr2/preimage"
+ test_expect_success 'old records rest in peace' \
+ "test ! -f $rr/preimage -a ! -f $rr2/preimage"
+ ;;
+esac
test_done
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index cf08e9279c..ac835fe431 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -10,7 +10,7 @@ commit id embedding:
The contents of the repository is compared to the extracted tar
archive. The repository contains simple text files, symlinks and a
- binary file (/bin/sh). Only pathes shorter than 99 characters are
+ binary file (/bin/sh). Only paths shorter than 99 characters are
used.
git-tar-tree applies the commit date to every file in the archive it
diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh
index de45ac4e0f..f511547455 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -44,7 +44,7 @@ test_expect_success \
'unpack without delta' \
"GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
git-unpack-objects -n <test-1-${packname_1}.pack &&
git-unpack-objects <test-1-${packname_1}.pack"
@@ -75,7 +75,7 @@ test_expect_success \
'unpack with delta' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
git-unpack-objects -n <test-2-${packname_2}.pack &&
git-unpack-objects <test-2-${packname_2}.pack'
@@ -100,7 +100,7 @@ test_expect_success \
'use packed objects' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && {
git-diff-tree --root -p $commit &&
while read object
diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
index 5a7232a577..a6dbb04a86 100755
--- a/t/t5301-sliding-window.sh
+++ b/t/t5301-sliding-window.sh
@@ -30,19 +30,19 @@ test_expect_success \
test_expect_success \
'verify-pack -v, packedGitWindowSize == 1 page' \
- 'git-repo-config core.packedGitWindowSize 512 &&
+ 'git-config core.packedGitWindowSize 512 &&
git-verify-pack -v "$pack1"'
test_expect_success \
'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' \
- 'git-repo-config core.packedGitWindowSize 512 &&
- git-repo-config core.packedGitLimit 512 &&
+ 'git-config core.packedGitWindowSize 512 &&
+ git-config core.packedGitLimit 512 &&
git-verify-pack -v "$pack1"'
test_expect_success \
'repack -a -d, packedGit{WindowSize,Limit} == 1 page' \
- 'git-repo-config core.packedGitWindowSize 512 &&
- git-repo-config core.packedGitLimit 512 &&
+ 'git-config core.packedGitWindowSize 512 &&
+ git-config core.packedGitLimit 512 &&
commit2=`git-commit-tree $tree -p $commit1 </dev/null` &&
git-update-ref HEAD $commit2 &&
git-repack -a -d &&
@@ -53,8 +53,8 @@ test_expect_success \
test_expect_success \
'verify-pack -v, defaults' \
- 'git-repo-config --unset core.packedGitWindowSize &&
- git-repo-config --unset core.packedGitLimit &&
+ 'git-config --unset core.packedGitWindowSize &&
+ git-config --unset core.packedGitLimit &&
git-verify-pack -v "$pack2"'
test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 2c151912a3..7d93d0d7c9 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -106,7 +106,7 @@ export HOME ;# this way we force the victim/.git/config to be used.
test_expect_success \
'pushing with --force should be denied with denyNonFastforwards' '
cd victim &&
- git-repo-config receive.denyNonFastforwards true &&
+ git-config receive.denyNonFastforwards true &&
cd .. &&
git-update-ref refs/heads/master master^ &&
git-send-pack --force ./victim/.git/ master &&
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
index cd8cee6ae8..0514056ca6 100755
--- a/t/t5401-update-hooks.sh
+++ b/t/t5401-update-hooks.sh
@@ -23,7 +23,7 @@ test_expect_success setup '
cat >victim/.git/hooks/update <<'EOF'
#!/bin/sh
echo "$@" >$GIT_DIR/update.args
-read x; echo -n "$x" >$GIT_DIR/update.stdin
+read x; printf "$x" >$GIT_DIR/update.stdin
echo STDOUT update
echo STDERR update >&2
EOF
@@ -32,7 +32,7 @@ chmod u+x victim/.git/hooks/update
cat >victim/.git/hooks/post-update <<'EOF'
#!/bin/sh
echo "$@" >$GIT_DIR/post-update.args
-read x; echo -n "$x" >$GIT_DIR/post-update.stdin
+read x; printf "$x" >$GIT_DIR/post-update.stdin
echo STDOUT post-update
echo STDERR post-update >&2
EOF
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 77c3c575d8..48e3d1705f 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -63,13 +63,13 @@ pull_to_client () {
case "$heads" in *B*) echo $BTIP > .git/refs/heads/B;; esac
git-symbolic-ref HEAD refs/heads/`echo $heads | sed -e 's/^\(.\).*$/\1/'`
- test_expect_success "fsck" 'git-fsck-objects --full > fsck.txt 2>&1'
+ test_expect_success "fsck" 'git-fsck --full > fsck.txt 2>&1'
test_expect_success 'check downloaded results' \
'mv .git/objects/pack/pack-* . &&
p=`ls -1 pack-*.pack` &&
git-unpack-objects <$p &&
- git-fsck-objects --full'
+ git-fsck --full'
test_expect_success "new object count after $number pull" \
'idx=`echo pack-*.idx` &&
@@ -97,7 +97,8 @@ pull_to_client () {
(
mkdir client &&
cd client &&
- git-init-db 2>> log2.txt
+ git-init 2>> log2.txt &&
+ git config transfer.unpacklimit 0
)
add A1
@@ -144,7 +145,7 @@ test_expect_success "clone shallow object count (part 2)" '
'
test_expect_success "fsck in shallow repo" \
- "(cd shallow; git-fsck-objects --full)"
+ "(cd shallow; git-fsck --full)"
#test_done; exit
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 90eeeba2a3..50c64856f0 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -22,14 +22,14 @@ test_expect_success "clone and setup child repos" '
cd .. &&
git clone . two &&
cd two &&
- git repo-config branch.master.remote one &&
- git repo-config remote.one.url ../one/.git/ &&
- git repo-config remote.one.fetch refs/heads/master:refs/heads/one &&
+ git config branch.master.remote one &&
+ git config remote.one.url ../one/.git/ &&
+ git config remote.one.fetch refs/heads/master:refs/heads/one &&
cd .. &&
git clone . three &&
cd three &&
- git repo-config branch.master.remote two &&
- git repo-config branch.master.merge refs/heads/one &&
+ git config branch.master.remote two &&
+ git config branch.master.merge refs/heads/one &&
mkdir -p .git/remotes &&
{
echo "URL: ../two/.git/"
@@ -73,7 +73,7 @@ test_expect_success 'fetch following tags' '
mkdir four &&
cd four &&
- git init-db &&
+ git init &&
git fetch .. :track &&
git show-ref --verify refs/tags/anno &&
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index f841574573..7eb37838bb 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -17,7 +17,7 @@ test_expect_success setup '
test_expect_success 'pulling into void' '
mkdir cloned &&
cd cloned &&
- git init-db &&
+ git init &&
git pull ..
'
diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh
index 041be04f5c..1776b377f3 100755
--- a/t/t5600-clone-fail-cleanup.sh
+++ b/t/t5600-clone-fail-cleanup.sh
@@ -36,7 +36,7 @@ test_expect_success \
'git-clone foo bar'
test_expect_success \
- 'successfull clone must leave the directory' \
+ 'successful clone must leave the directory' \
'cd bar'
test_done
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index dd9caad1c2..6d43252593 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -26,7 +26,7 @@ git prune'
cd "$base_dir"
-test_expect_success 'cloning with reference' \
+test_expect_success 'cloning with reference (-l -s)' \
'git clone -l -s --reference B A C'
cd "$base_dir"
@@ -50,6 +50,28 @@ diff expected current'
cd "$base_dir"
+test_expect_success 'cloning with reference (no -l -s)' \
+'git clone --reference B A D'
+
+cd "$base_dir"
+
+test_expect_success 'existence of info/alternates' \
+'test `wc -l <D/.git/objects/info/alternates` = 1'
+
+cd "$base_dir"
+
+test_expect_success 'pulling from reference' \
+'cd D && git pull ../B'
+
+cd "$base_dir"
+
+test_expect_success 'that reference gets used' \
+'cd D && echo "0 objects, 0 kilobytes" > expected &&
+git count-objects > current &&
+diff expected current'
+
+cd "$base_dir"
+
test_expect_success 'updating origin' \
'cd A &&
echo third > file3 &&
@@ -75,4 +97,20 @@ diff expected current'
cd "$base_dir"
+test_expect_success 'pulling changes from origin' \
+'cd D &&
+git pull origin'
+
+cd "$base_dir"
+
+# the 5 local objects are expected; file3 blob, commit in A to add it
+# and its tree, and 2 are our tree and the merge commit.
+test_expect_success 'check objects expected to exist locally' \
+'cd D &&
+echo "5 objects" > expected &&
+git count-objects | cut -d, -f1 > current &&
+diff expected current'
+
+cd "$base_dir"
+
test_done
diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh
index b9f6d96363..2f8e97cb7e 100755
--- a/t/t5710-info-alternate.sh
+++ b/t/t5710-info-alternate.sh
@@ -17,7 +17,7 @@ reachable_via() {
}
test_valid_repo() {
- git fsck-objects --full > fsck.log &&
+ git fsck --full > fsck.log &&
test `wc -l < fsck.log` = 0
}
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 1c21d8c986..f3cd3dba4d 100644
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -52,7 +52,7 @@ super aquam refectionis educavit me;
animam meam convertit,
deduxit me super semitas jusitiae,
EOF
-echo -n "propter nomen suum." >> new4.txt
+printf "propter nomen suum." >> new4.txt
cp new1.txt test.txt
test_expect_success "merge without conflict" \
diff --git a/t/t6023-merge-rename-nocruft.sh b/t/t6023-merge-rename-nocruft.sh
index 69c66cf6fa..65be95fbaa 100755
--- a/t/t6023-merge-rename-nocruft.sh
+++ b/t/t6023-merge-rename-nocruft.sh
@@ -45,6 +45,7 @@ git add A M &&
git commit -m "initial has A and M" &&
git branch white &&
git branch red &&
+git branch blue &&
git checkout white &&
sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
@@ -58,6 +59,13 @@ echo created by red >R &&
git update-index --add R &&
git commit -m "red creates R" &&
+git checkout blue &&
+sed -e "/^o /s/.*/g : blue changes a line/" <A >B &&
+rm -f A &&
+mv B A &&
+git update-index A &&
+git commit -m "blue modify A" &&
+
git checkout master'
# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
@@ -94,4 +102,38 @@ test_expect_success 'merge white into red (A->B,M->N)' \
return 0
'
+# This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9
+test_expect_success 'merge blue into white (A->B, mod A, A untracked)' \
+'
+ git checkout -b white-blue white &&
+ echo dirty >A &&
+ git merge blue &&
+ git write-tree >/dev/null || {
+ echo "BAD: merge did not complete"
+ return 1
+ }
+
+ test -f A || {
+ echo "BAD: A does not exist in working directory"
+ return 1
+ }
+ test `cat A` = dirty || {
+ echo "BAD: A content is wrong"
+ return 1
+ }
+ test -f B || {
+ echo "BAD: B does not exist in working directory"
+ return 1
+ }
+ test -f N || {
+ echo "BAD: N does not exist in working directory"
+ return 1
+ }
+ test -f M && {
+ echo "BAD: M still exists in working directory"
+ return 1
+ }
+ return 0
+'
+
test_done
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
new file mode 100755
index 0000000000..3e9edda1ca
--- /dev/null
+++ b/t/t6120-describe.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+
+test_description='test describe
+
+ B
+ .--------------o----o----o----x
+ / / /
+ o----o----o----o----o----. /
+ \ A c /
+ .------------o---o---o
+ D e
+'
+. ./test-lib.sh
+
+check_describe () {
+ expect="$1"
+ shift
+ R=$(git describe "$@") &&
+ test_expect_success "describe $*" '
+ case "$R" in
+ $expect) echo happy ;;
+ *) echo "Oops - $R is not $expect";
+ false ;;
+ esac
+ '
+}
+
+test_expect_success setup '
+
+ test_tick &&
+ echo one >file && git-add file && git-commit -m initial &&
+ one=$(git-rev-parse HEAD) &&
+
+ test_tick &&
+ echo two >file && git-add file && git-commit -m second &&
+ two=$(git-rev-parse HEAD) &&
+
+ test_tick &&
+ echo three >file && git-add file && git-commit -m third &&
+
+ test_tick &&
+ echo A >file && git-add file && git-commit -m A &&
+ test_tick &&
+ git-tag -a -m A A &&
+
+ test_tick &&
+ echo c >file && git-add file && git-commit -m c &&
+ test_tick &&
+ git-tag c &&
+
+ git reset --hard $two &&
+ test_tick &&
+ echo B >side && git-add side && git-commit -m B &&
+ test_tick &&
+ git-tag -a -m B B &&
+
+ test_tick &&
+ git-merge -m Merged c &&
+ merged=$(git-rev-parse HEAD) &&
+
+ git reset --hard $two &&
+ test_tick &&
+ echo D >another && git-add another && git-commit -m D &&
+ test_tick &&
+ git-tag -a -m D D &&
+
+ test_tick &&
+ echo DD >another && git commit -a -m another &&
+
+ test_tick &&
+ git-tag e &&
+
+ test_tick &&
+ echo DDD >another && git commit -a -m "yet another" &&
+
+ test_tick &&
+ git-merge -m Merged $merged &&
+
+ test_tick &&
+ echo X >file && echo X >side && git-add file side &&
+ git-commit -m x
+
+'
+
+check_describe A-* HEAD
+check_describe A-* HEAD^
+check_describe D-* HEAD^^
+check_describe A-* HEAD^^2
+check_describe B HEAD^^2^
+
+check_describe A-* --tags HEAD
+check_describe A-* --tags HEAD^
+check_describe D-* --tags HEAD^^
+check_describe A-* --tags HEAD^^2
+check_describe B --tags HEAD^^2^
+
+test_done
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 63e49f310c..ea14023616 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -108,7 +108,7 @@ EOF
test_expect_success 'merge-msg test #3' '
- git repo-config merge.summary true &&
+ git config merge.summary true &&
git checkout master &&
setdate &&
@@ -138,7 +138,7 @@ EOF
test_expect_success 'merge-msg test #4' '
- git repo-config merge.summary true &&
+ git config merge.summary true &&
git checkout master &&
setdate &&
@@ -150,7 +150,7 @@ test_expect_success 'merge-msg test #4' '
test_expect_success 'merge-msg test #5' '
- git repo-config merge.summary yes &&
+ git config merge.summary yes &&
git checkout master &&
setdate &&
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 2f4ff82e14..344033249c 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -88,7 +88,7 @@ test_expect_success \
test_expect_success "Michael Cassar's test case" '
rm -fr .git papers partA &&
- git init-db &&
+ git init &&
mkdir -p papers/unsorted papers/all-papers partA &&
echo a > papers/unsorted/Thesis.pdf &&
echo b > partA/outline.txt &&
@@ -109,7 +109,7 @@ rm -fr papers partA path?
test_expect_success "Sergey Vlasov's test case" '
rm -fr .git &&
- git init-db &&
+ git init &&
mkdir ab &&
date >ab.c &&
date >ab/d &&
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 085d4a096b..867bbd26cb 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -14,15 +14,23 @@ fill () {
done
}
+
test_expect_success setup '
- fill 1 2 3 4 5 >one &&
+ fill 1 2 3 4 5 6 7 8 >one &&
fill a b c d e >two &&
git add one two &&
git commit -m "Initial A one, A two" &&
- git checkout -b side &&
- fill 1 2 3 >one &&
+ git checkout -b renamer &&
+ rm -f one &&
+ fill 1 3 4 5 6 7 8 >uno &&
+ git add uno &&
+ fill a b c d e f >two &&
+ git commit -a -m "Renamer R one->uno, M two" &&
+
+ git checkout -b side master &&
+ fill 1 2 3 4 5 6 7 >one &&
fill A B C D E >three &&
rm -f two &&
git update-index --add --remove one two three &&
@@ -42,7 +50,7 @@ test_expect_success "checkout from non-existing branch" '
test_expect_success "checkout with dirty tree without -m" '
- fill 0 1 2 3 4 5 >one &&
+ fill 0 1 2 3 4 5 6 7 8 >one &&
if git checkout side
then
echo Not happy
@@ -58,12 +66,10 @@ test_expect_success "checkout -m with dirty tree" '
git checkout -f master &&
git clean &&
- fill 0 1 2 3 4 5 >one &&
+ fill 0 1 2 3 4 5 6 7 8 >one &&
git checkout -m side &&
- fill " master" "* side" >expect.branch &&
- git branch >current.branch &&
- diff expect.branch current.branch &&
+ test "$(git symbolic-ref HEAD)" = "refs/heads/side" &&
fill "M one" "A three" "D two" >expect.master &&
git diff --name-status master >current.master &&
@@ -78,4 +84,49 @@ test_expect_success "checkout -m with dirty tree" '
diff expect.index current.index
'
+test_expect_success "checkout -m with dirty tree, renamed" '
+
+ git checkout -f master && git clean &&
+
+ fill 1 2 3 4 5 7 8 >one &&
+ if git checkout renamer
+ then
+ echo Not happy
+ false
+ else
+ echo "happy - failed correctly"
+ fi &&
+
+ git checkout -m renamer &&
+ fill 1 3 4 5 7 8 >expect &&
+ diff expect uno &&
+ ! test -f one &&
+ git diff --cached >current &&
+ ! test -s current
+
+'
+
+test_expect_success 'checkout -m with merge conflict' '
+
+ git checkout -f master && git clean &&
+
+ fill 1 T 3 4 5 6 S 8 >one &&
+ if git checkout renamer
+ then
+ echo Not happy
+ false
+ else
+ echo "happy - failed correctly"
+ fi &&
+
+ git checkout -m renamer &&
+
+ git diff master:one :3:uno |
+ sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
+ fill d2 aT d7 aS >expect &&
+ diff current expect &&
+ git diff --cached two >current &&
+ ! test -s current
+'
+
test_done
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index 46fcec50a5..e8133d81cb 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -56,11 +56,14 @@ 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 &&
+ poke kw.c &&
svn commit -m "Not yet an Id" &&
echo Hello world >> kw.c &&
+ poke kw.c &&
svn commit -m "Modified file, but still not yet an Id" &&
svn propset svn:keywords Id kw.c &&
- svn commit -m "Propset Id"
+ poke kw.c &&
+ svn commit -m "Propset Id" &&
cd ..'
test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
@@ -70,7 +73,7 @@ name='test svn:keywords ignoring'
test_expect_success "$name" \
'git checkout -b mybranch remotes/git-svn &&
echo Hi again >> kw.c &&
- git commit -a -m "test keywoards ignoring" &&
+ git commit -a -m "test keywords ignoring" &&
git-svn set-tree remotes/git-svn..mybranch &&
git pull . remotes/git-svn'
@@ -83,7 +86,7 @@ test_expect_success "propset CR on crlf files" \
svn propset svn:eol-style CR empty &&
svn propset svn:eol-style CR crlf &&
svn propset svn:eol-style CR ne_crlf &&
- svn commit -m "propset CR on crlf files"
+ svn commit -m "propset CR on crlf files" &&
cd ..'
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh
index 572aaedc06..4e0808380f 100755
--- a/t/t9102-git-svn-deep-rmdir.sh
+++ b/t/t9102-git-svn-deep-rmdir.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
test_description='git-svn rmdir'
. ./lib-git-svn.sh
diff --git a/t/t9103-git-svn-graft-branches.sh b/t/t9103-git-svn-graft-branches.sh
index b5f7677021..183ae3b1c2 100755
--- a/t/t9103-git-svn-graft-branches.sh
+++ b/t/t9103-git-svn-graft-branches.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
test_description='git-svn graft-branches'
. ./lib-git-svn.sh
@@ -15,6 +16,7 @@ test_expect_success 'initialize repo' "
svn co $svnrepo wc &&
cd wc &&
echo feedme >> branches/a/readme &&
+ poke branches/a/readme &&
svn commit -m hungry &&
cd trunk &&
svn merge -r3:4 $svnrepo/branches/a &&
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 400c21cd49..405b555368 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -16,10 +16,13 @@ test_expect_success 'initialize repo' "
svn co $svnrepo wc &&
cd wc &&
echo world >> trunk/readme &&
+ poke trunk/readme &&
svn commit -m 'another commit' &&
+ svn up &&
svn mv -m 'rename to thunk' trunk thunk &&
svn up &&
echo goodbye >> thunk/readme &&
+ poke thunk/readme &&
svn commit -m 'bye now' &&
cd ..
"
diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh
index 59b6425ce4..6f132f2419 100755
--- a/t/t9106-git-svn-commit-diff-clobber.sh
+++ b/t/t9106-git-svn-commit-diff-clobber.sh
@@ -18,6 +18,7 @@ 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' &&
cd .. &&
rm -rf t.svn
@@ -45,6 +46,7 @@ test_expect_failure 'dcommit fails to commit because of conflict' "
svn co $svnrepo t.svn &&
cd t.svn &&
echo fourth line from svn >> file &&
+ poke file &&
svn commit -m 'fourth line from svn' &&
cd .. &&
rm -rf t.svn &&
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
index 315119abff..4efa0c926c 100755
--- a/t/t9200-git-cvsexportcommit.sh
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Copyright (c) Robin Rosenberg
#
@@ -169,21 +169,35 @@ test_expect_success \
test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
)'
-# This test contains ISO-8859-1 characters
+# Some filesystems mangle pathnames with UTF-8 characters --
+# check and skip
+if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" &&
+ mkdir -p "tst/$p" &&
+ date >"tst/$p/day" &&
+ found=$(find tst -type f -print) &&
+ test "z$found" = "ztst/$p/day" &&
+ rm -fr tst
+then
+
+# This test contains UTF-8 characters
test_expect_success \
'File with non-ascii file name' \
- 'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
- echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
- git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
- cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
- git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
- git commit -a -m "Går det så går det" && \
+ 'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
+ echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+ git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
+ cp ../test9200a.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+ git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
+ git commit -a -m "Går det så går det" && \
id=$(git rev-list --max-count=1 HEAD) &&
(cd "$CVSWORK" &&
git-cvsexportcommit -v -c $id &&
- test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
+ test "$(echo $(sort Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/CVS/Entries|cut -d/ -f2,3,5))" = "gårdetsågårdet.png/1.1/-kb gårdetsågårdet.txt/1.1/"
)'
+fi
+
+rm -fr tst
+
test_expect_success \
'Mismatching patch should fail' \
'date >>"E/newfile5.txt" &&
@@ -197,6 +211,10 @@ test_expect_success \
! git-cvsexportcommit -c $id
)'
+case "$(git repo-config --bool core.filemode)" in
+false)
+ ;;
+*)
test_expect_success \
'Retain execute bit' \
'mkdir G &&
@@ -211,5 +229,7 @@ test_expect_success \
test -x G/on &&
! test -x G/off
)'
+ ;;
+esac
test_done
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
new file mode 100755
index 0000000000..970d683650
--- /dev/null
+++ b/t/t9300-fast-import.sh
@@ -0,0 +1,496 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Shawn Pearce
+#
+
+test_description='test git-fast-import utility'
+. ./test-lib.sh
+. ../diff-lib.sh ;# test-lib chdir's into trash
+
+file2_data='file2
+second line of EOF'
+
+file3_data='EOF
+in 3rd file
+ END'
+
+file4_data=abcd
+file4_len=4
+
+file5_data='an inline file.
+ we should see it later.'
+
+file6_data='#!/bin/sh
+echo "$@"'
+
+###
+### series A
+###
+
+test_tick
+cat >input <<INPUT_END
+blob
+mark :2
+data <<EOF
+$file2_data
+EOF
+
+blob
+mark :3
+data <<END
+$file3_data
+END
+
+blob
+mark :4
+data $file4_len
+$file4_data
+commit refs/heads/master
+mark :5
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+initial
+COMMIT
+
+M 644 :2 file2
+M 644 :3 file3
+M 755 :4 file4
+
+INPUT_END
+test_expect_success \
+ 'A: create pack from stdin' \
+ 'git-fast-import --export-marks=marks.out <input &&
+ git-whatchanged master'
+test_expect_success \
+ 'A: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+initial
+EOF
+test_expect_success \
+ 'A: verify commit' \
+ 'git-cat-file commit master | sed 1d >actual &&
+ diff -u expect actual'
+
+cat >expect <<EOF
+100644 blob file2
+100644 blob file3
+100755 blob file4
+EOF
+test_expect_success \
+ 'A: verify tree' \
+ 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
+ diff -u expect actual'
+
+echo "$file2_data" >expect
+test_expect_success \
+ 'A: verify file2' \
+ 'git-cat-file blob master:file2 >actual && diff -u expect actual'
+
+echo "$file3_data" >expect
+test_expect_success \
+ 'A: verify file3' \
+ 'git-cat-file blob master:file3 >actual && diff -u expect actual'
+
+printf "$file4_data" >expect
+test_expect_success \
+ 'A: verify file4' \
+ 'git-cat-file blob master:file4 >actual && diff -u expect actual'
+
+cat >expect <<EOF
+:2 `git-rev-parse --verify master:file2`
+:3 `git-rev-parse --verify master:file3`
+:4 `git-rev-parse --verify master:file4`
+:5 `git-rev-parse --verify master^0`
+EOF
+test_expect_success \
+ 'A: verify marks output' \
+ 'diff -u expect marks.out'
+
+###
+### series B
+###
+
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+mark :1
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+corrupt
+COMMIT
+
+from refs/heads/master
+M 755 0000000000000000000000000000000000000001 zero1
+
+INPUT_END
+test_expect_failure \
+ 'B: fail on invalid blob sha1' \
+ 'git-fast-import <input'
+rm -f .git/objects/pack_* .git/objects/index_*
+
+###
+### series C
+###
+
+newf=`echo hi newf | git-hash-object -w --stdin`
+oldf=`git-rev-parse --verify master:file2`
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+second
+COMMIT
+
+from refs/heads/master
+M 644 $oldf file2/oldf
+M 755 $newf file2/newf
+D file3
+
+INPUT_END
+test_expect_success \
+ 'C: incremental import create pack from stdin' \
+ 'git-fast-import <input &&
+ git-whatchanged branch'
+test_expect_success \
+ 'C: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+test_expect_success \
+ 'C: validate reuse existing blob' \
+ 'test $newf = `git-rev-parse --verify branch:file2/newf`
+ test $oldf = `git-rev-parse --verify branch:file2/oldf`'
+
+cat >expect <<EOF
+parent `git-rev-parse --verify master^0`
+author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+second
+EOF
+test_expect_success \
+ 'C: verify commit' \
+ 'git-cat-file commit branch | sed 1d >actual &&
+ diff -u expect actual'
+
+cat >expect <<EOF
+:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
+:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
+:100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
+EOF
+git-diff-tree -M -r master branch >actual
+test_expect_success \
+ 'C: validate rename result' \
+ 'compare_diff_raw expect actual'
+
+###
+### series D
+###
+
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+third
+COMMIT
+
+from refs/heads/branch^0
+M 644 inline newdir/interesting
+data <<EOF
+$file5_data
+EOF
+
+M 755 inline newdir/exec.sh
+data <<EOF
+$file6_data
+EOF
+
+INPUT_END
+test_expect_success \
+ 'D: inline data in commit' \
+ 'git-fast-import <input &&
+ git-whatchanged branch'
+test_expect_success \
+ 'D: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+:000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
+:000000 100644 0000000000000000000000000000000000000000 046d0371e9220107917db0d0e030628de8a1de9b A newdir/interesting
+EOF
+git-diff-tree -M -r branch^ branch >actual
+test_expect_success \
+ 'D: validate new files added' \
+ 'compare_diff_raw expect actual'
+
+echo "$file5_data" >expect
+test_expect_success \
+ 'D: verify file5' \
+ 'git-cat-file blob branch:newdir/interesting >actual &&
+ diff -u expect actual'
+
+echo "$file6_data" >expect
+test_expect_success \
+ 'D: verify file6' \
+ 'git-cat-file blob branch:newdir/exec.sh >actual &&
+ diff -u expect actual'
+
+###
+### series E
+###
+
+cat >input <<INPUT_END
+commit refs/heads/branch
+author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
+data <<COMMIT
+RFC 2822 type date
+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=rfc2822' \
+ 'git-fast-import --date-format=rfc2822 <input'
+test_expect_success \
+ 'E: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
+
+RFC 2822 type date
+EOF
+test_expect_success \
+ 'E: verify commit' \
+ 'git-cat-file commit branch | sed 1,2d >actual &&
+ diff -u expect actual'
+
+###
+### series F
+###
+
+old_branch=`git-rev-parse --verify branch^0`
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+losing things already?
+COMMIT
+
+from refs/heads/branch~1
+
+reset refs/heads/other
+from refs/heads/branch
+
+INPUT_END
+test_expect_success \
+ 'F: non-fast-forward update skips' \
+ 'if git-fast-import <input
+ then
+ echo BAD gfi did not fail
+ return 1
+ else
+ if test $old_branch = `git-rev-parse --verify branch^0`
+ then
+ : branch unaffected and failure returned
+ return 0
+ else
+ echo BAD gfi changed branch $old_branch
+ return 1
+ fi
+ fi
+ '
+test_expect_success \
+ 'F: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+tree `git-rev-parse branch~1^{tree}`
+parent `git-rev-parse branch~1`
+author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+losing things already?
+EOF
+test_expect_success \
+ 'F: verify other commit' \
+ 'git-cat-file commit other >actual &&
+ diff -u expect actual'
+
+###
+### series G
+###
+
+old_branch=`git-rev-parse --verify branch^0`
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+losing things already?
+COMMIT
+
+from refs/heads/branch~1
+
+INPUT_END
+test_expect_success \
+ 'G: non-fast-forward update forced' \
+ 'git-fast-import --force <input'
+test_expect_success \
+ 'G: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+test_expect_success \
+ 'G: branch changed, but logged' \
+ 'test $old_branch != `git-rev-parse --verify branch^0` &&
+ test $old_branch = `git-rev-parse --verify branch@{1}`'
+
+###
+### series H
+###
+
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/H
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+third
+COMMIT
+
+from refs/heads/branch^0
+M 644 inline i-will-die
+data <<EOF
+this file will never exist.
+EOF
+
+deleteall
+M 644 inline h/e/l/lo
+data <<EOF
+$file5_data
+EOF
+
+INPUT_END
+test_expect_success \
+ 'H: deletall, add 1' \
+ 'git-fast-import <input &&
+ git-whatchanged H'
+test_expect_success \
+ 'H: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
+:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
+:100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
+:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
+:100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
+EOF
+git-diff-tree -M -r H^ H >actual
+test_expect_success \
+ 'H: validate old files removed, new files added' \
+ 'compare_diff_raw expect actual'
+
+echo "$file5_data" >expect
+test_expect_success \
+ 'H: verify file' \
+ 'git-cat-file blob H:h/e/l/lo >actual &&
+ diff -u expect actual'
+
+###
+### series I
+###
+
+cat >input <<INPUT_END
+commit refs/heads/export-boundary
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+we have a border. its only 40 characters wide.
+COMMIT
+
+from refs/heads/branch
+
+INPUT_END
+test_expect_success \
+ 'I: export-pack-edges' \
+ 'git-fast-import --export-pack-edges=edges.list <input'
+
+cat >expect <<EOF
+.git/objects/pack/pack-.pack: `git-rev-parse --verify export-boundary`
+EOF
+test_expect_success \
+ 'I: verify edge list' \
+ 'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
+ diff -u expect actual'
+
+###
+### series J
+###
+
+cat >input <<INPUT_END
+commit refs/heads/J
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+create J
+COMMIT
+
+from refs/heads/branch
+
+reset refs/heads/J
+
+commit refs/heads/J
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+initialize J
+COMMIT
+
+INPUT_END
+test_expect_success \
+ 'J: reset existing branch creates empty commit' \
+ 'git-fast-import <input'
+test_expect_success \
+ 'J: branch has 1 commit, empty tree' \
+ 'test 1 = `git-rev-list J | wc -l` &&
+ test 0 = `git ls-tree J | wc -l`'
+
+###
+### series K
+###
+
+cat >input <<INPUT_END
+commit refs/heads/K
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+create K
+COMMIT
+
+from refs/heads/branch
+
+commit refs/heads/K
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+redo K
+COMMIT
+
+from refs/heads/branch^1
+
+INPUT_END
+test_expect_success \
+ 'K: reinit branch with from' \
+ 'git-fast-import <input'
+test_expect_success \
+ 'K: verify K^1 = branch^1' \
+ 'test `git-rev-parse --verify branch^1` \
+ = `git-rev-parse --verify K^1`'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 72ea2b2598..37822fc13d 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -30,6 +30,8 @@ unset GIT_INDEX_FILE
unset GIT_OBJECT_DIRECTORY
unset SHA1_FILE_DIRECTORIES
unset SHA1_FILE_DIRECTORY
+GIT_MERGE_VERBOSITY=5
+export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR VISUAL
@@ -220,8 +222,8 @@ test_create_repo () {
repo="$1"
mkdir "$repo"
cd "$repo" || error "Cannot setup test environment"
- "$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
- error "cannot run git init-db -- have you built things yet?"
+ "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
+ error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
cd "$owd"
}
diff --git a/templates/Makefile b/templates/Makefile
index 9e1ae1a4e0..0eeee43feb 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -6,7 +6,7 @@ prefix ?= $(HOME)
template_dir ?= $(prefix)/share/git-core/templates/
# DESTDIR=
-# Shell quote (do not use $(call) to accomodate ancient setups);
+# Shell quote (do not use $(call) to accommodate ancient setups);
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
template_dir_SQ = $(subst ','\'',$(template_dir))
diff --git a/templates/hooks--update b/templates/hooks--update
index 9863a800c8..e8c536fb61 100644
--- a/templates/hooks--update
+++ b/templates/hooks--update
@@ -1,89 +1,285 @@
#!/bin/sh
#
# An example hook script to mail out commit update information.
-# It also blocks tags that aren't annotated.
+# It can also blocks tags that aren't annotated.
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
#
-# To enable this hook:
-# (1) change the recipient e-mail address
-# (2) make this file executable by "chmod +x update".
+# To enable this hook, make this file executable by "chmod +x update".
#
+# Config
+# ------
+# hooks.mailinglist
+# This is the list that all pushes will go to; leave it blank to not send
+# emails frequently. The log email will list every log entry in full between
+# the old ref value and the new ref value.
+# hooks.announcelist
+# This is the list that all pushes of annotated tags will go to. Leave it
+# blank to just use the mailinglist field. The announce emails list the
+# short log summary of the changes since the last annotated tag
+# hooks.allowunannotated
+# This boolean sets whether unannotated tags will be allowed into the
+# repository. By default they won't be.
+#
+# Notes
+# -----
+# All emails have their subjects prefixed with "[SCM]" to aid filtering.
+# All emails include the headers "X-Git-Refname", "X-Git-Oldrev",
+# "X-Git-Newrev", and "X-Git-Reftype" to enable fine tuned filtering and info.
-project=$(cat $GIT_DIR/description)
-recipients="commit-list@somewhere.com commit-list@somewhereelse.com"
-
-ref_type=$(git cat-file -t "$3")
-
-# Only allow annotated tags in a shared repo
-# Remove this code to treat dumb tags the same as everything else
-case "$1","$ref_type" in
-refs/tags/*,commit)
- echo "*** Un-annotated tags are not allowed in this repo" >&2
- echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
- exit 1;;
-refs/tags/*,tag)
- echo "### Pushing version '${1##refs/tags/}' to the masses" >&2
- # recipients="release-announce@somwehere.com announce@somewhereelse.com"
- ;;
-esac
+# --- Constants
+EMAILPREFIX="[SCM] "
+LOGBEGIN="- Log -----------------------------------------------------------------"
+LOGEND="-----------------------------------------------------------------------"
+DATEFORMAT="%F %R %z"
+
+# --- Command line
+refname="$1"
+oldrev="$2"
+newrev="$3"
+
+# --- Safety check
+if [ -z "$GIT_DIR" ]; then
+ echo "Don't run this script from the command line." >&2
+ echo " (if you want, you could supply GIT_DIR then run" >&2
+ echo " $0 <ref> <oldrev> <newrev>)" >&2
+ exit 1
+fi
+
+if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
+ echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
+ exit 1
+fi
+
+# --- Config
+projectdesc=$(cat $GIT_DIR/description)
+recipients=$(git-repo-config hooks.mailinglist)
+announcerecipients=$(git-repo-config hooks.announcelist)
+allowunannotated=$(git-repo-config --bool hooks.allowunannotated)
-# set this to 'cat' to get a very detailed listing.
-# short only kicks in when an annotated tag is added
-short='git shortlog'
-
-# see 'date --help' for info on how to write this
-# The default is a human-readable iso8601-like format with minute
-# precision ('2006-01-25 15:58 +0100' for example)
-date_format="%F %R %z"
-
-(if expr "$2" : '0*$' >/dev/null
-then
- # new ref
- case "$1" in
- refs/tags/*)
- # a pushed and annotated tag (usually) means a new version
- tag="${1##refs/tags/}"
- if [ "$ref_type" = tag ]; then
- eval $(git cat-file tag $3 | \
- sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p')
- date=$(date --date="1970-01-01 00:00:00 $ts seconds" +"$date_format")
- echo "Tag '$tag' created by $tagger at $date"
- git cat-file tag $3 | sed -n '5,$p'
- echo
+# --- Check types
+newrev_type=$(git-cat-file -t "$newrev")
+
+case "$refname","$newrev_type" in
+ refs/tags/*,commit)
+ # un-annotated tag
+ refname_type="tag"
+ short_refname=${refname##refs/tags/}
+ if [ $allowunannotated != "true" ]; then
+ echo "*** The un-annotated tag, $short_refname is not allowed in this repository" >&2
+ echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
+ exit 1
fi
- prev=$(git describe "$3^" | sed 's/-g.*//')
- # the first tag in a repo will yield no $prev
- if [ -z "$prev" ]; then
- echo "Changes since the dawn of time:"
- git rev-list --pretty $3 | $short
- else
- echo "Changes since $prev:"
- git rev-list --pretty $prev..$3 | $short
- echo ---
- git diff --stat $prev..$3
- echo ---
+ ;;
+ refs/tags/*,tag)
+ # annotated tag
+ refname_type="annotated tag"
+ short_refname=${refname##refs/tags/}
+ # change recipients
+ if [ -n "$announcerecipients" ]; then
+ recipients="$announcerecipients"
fi
;;
+ refs/heads/*,commit)
+ # branch
+ refname_type="branch"
+ short_refname=${refname##refs/heads/}
+ ;;
+ refs/remotes/*,commit)
+ # tracking branch
+ refname_type="tracking branch"
+ short_refname=${refname##refs/remotes/}
+ # Should this even be allowed?
+ echo "*** Push-update of tracking branch, $refname. No email generated." >&2
+ exit 0
+ ;;
+ *)
+ # Anything else (is there anything else?)
+ echo "*** Update hook: unknown type of update, \"$newrev_type\", to ref $refname" >&2
+ exit 1
+ ;;
+esac
+
+# Check if we've got anyone to send to
+if [ -z "$recipients" ]; then
+ # If the email isn't sent, then at least give the user some idea of what command
+ # would generate the email at a later date
+ echo "*** No recipients found - no email will be sent, but the push will continue" >&2
+ echo "*** for $0 $1 $2 $3" >&2
+ exit 0
+fi
+
+# --- Email parameters
+committer=$(git show --pretty=full -s $newrev | grep "^Commit: " | sed -e "s/^Commit: //")
+describe=$(git describe $newrev 2>/dev/null)
+if [ -z "$describe" ]; then
+ describe=$newrev
+fi
- refs/heads/*)
- branch="${1##refs/heads/}"
- echo "New branch '$branch' available with the following commits:"
- git-rev-list --pretty "$3" $(git-rev-parse --not --all)
+# --- Email (all stdout will be the email)
+(
+# Generate header
+cat <<-EOF
+From: $committer
+To: $recipients
+Subject: ${EMAILPREFIX}$projectdesc $refname_type, $short_refname now at $describe
+X-Git-Refname: $refname
+X-Git-Reftype: $refname_type
+X-Git-Oldrev: $oldrev
+X-Git-Newrev: $newrev
+
+Hello,
+
+This is an automated email from the git hooks/update script, it was
+generated because a ref change was pushed to the repository.
+
+Updating $refname_type, $short_refname,
+EOF
+
+case "$refname_type" in
+ "tracking branch"|branch)
+ if expr "$oldrev" : '0*$' >/dev/null
+ then
+ # If the old reference is "0000..0000" then this is a new branch
+ # and so oldrev is not valid
+ echo " as a new $refname_type"
+ echo " to $newrev ($newrev_type)"
+ echo ""
+ echo $LOGBEGIN
+ # This shows all log entries that are not already covered by
+ # another ref - i.e. commits that are now accessible from this
+ # ref that were previously not accessible
+ git-rev-parse --not --all | git-rev-list --stdin --pretty $newref
+ echo $LOGEND
+ else
+ # oldrev is valid
+ oldrev_type=$(git-cat-file -t "$oldrev")
+
+ # Now the problem is for cases like this:
+ # * --- * --- * --- * (oldrev)
+ # \
+ # * --- * --- * (newrev)
+ # i.e. there is no guarantee that newrev is a strict subset
+ # of oldrev - (would have required a force, but that's allowed).
+ # So, we can't simply say rev-list $oldrev..$newrev. Instead
+ # we find the common base of the two revs and list from there
+ baserev=$(git-merge-base $oldrev $newrev)
+
+ # Commit with a parent
+ for rev in $(git-rev-list $newrev ^$baserev)
+ do
+ revtype=$(git-cat-file -t "$rev")
+ echo " via $rev ($revtype)"
+ done
+ if [ "$baserev" = "$oldrev" ]; then
+ echo " from $oldrev ($oldrev_type)"
+ else
+ echo " based on $baserev"
+ echo " from $oldrev ($oldrev_type)"
+ echo ""
+ echo "This ref update crossed a branch point; i.e. the old rev is not a strict subset"
+ echo "of the new rev. This occurs, when you --force push a change in a situation"
+ echo "like this:"
+ echo ""
+ echo " * -- * -- B -- O -- O -- O ($oldrev)"
+ echo " \\"
+ echo " N -- N -- N ($newrev)"
+ echo ""
+ echo "Therefore, we assume that you've already had alert emails for all of the O"
+ echo "revisions, and now give you all the revisions in the N branch from the common"
+ echo "base, B ($baserev), up to the new revision."
+ fi
+ echo ""
+ echo $LOGBEGIN
+ git-rev-list --pretty $newrev ^$baserev
+ echo $LOGEND
+ echo ""
+ echo "Diffstat:"
+ git-diff-tree --no-color --stat -M -C --find-copies-harder $newrev ^$baserev
+ fi
;;
- esac
-else
- base=$(git-merge-base "$2" "$3")
- case "$base" in
- "$2")
- git diff --stat "$3" "^$base"
- echo
- echo "New commits:"
+ "annotated tag")
+ # Should we allow changes to annotated tags?
+ if expr "$oldrev" : '0*$' >/dev/null
+ then
+ # If the old reference is "0000..0000" then this is a new atag
+ # and so oldrev is not valid
+ echo " to $newrev ($newrev_type)"
+ else
+ echo " to $newrev ($newrev_type)"
+ echo " from $oldrev"
+ fi
+
+ # If this tag succeeds another, then show which tag it replaces
+ prevtag=$(git describe $newrev^ 2>/dev/null | sed 's/-g.*//')
+ if [ -n "$prevtag" ]; then
+ echo " replaces $prevtag"
+ fi
+
+ # Read the tag details
+ eval $(git cat-file tag $newrev | \
+ sed -n '4s/tagger \([^>]*>\)[^0-9]*\([0-9]*\).*/tagger="\1" ts="\2"/p')
+ tagged=$(date --date="1970-01-01 00:00:00 +0000 $ts seconds" +"$DATEFORMAT")
+
+ echo " tagged by $tagger"
+ echo " on $tagged"
+
+ echo ""
+ echo $LOGBEGIN
+ echo ""
+
+ if [ -n "$prevtag" ]; then
+ git rev-list --pretty=short "$prevtag..$newrev" | git shortlog
+ else
+ git rev-list --pretty=short $newrev | git shortlog
+ fi
+
+ echo $LOGEND
+ echo ""
;;
*)
- echo "Rebased ref, commits from common ancestor:"
+ # By default, unannotated tags aren't allowed in; if
+ # they are though, it's debatable whether we would even want an
+ # email to be generated; however, I don't want to add another config
+ # option just for that.
+ #
+ # Unannotated tags are more about marking a point than releasing
+ # a version; therefore we don't do the shortlog summary that we
+ # do for annotated tags above - we simply show that the point has
+ # been marked, and print the log message for the marked point for
+ # reference purposes
+ #
+ # Note this section also catches any other reference type (although
+ # there aren't any) and deals with them in the same way.
+ if expr "$oldrev" : '0*$' >/dev/null
+ then
+ # If the old reference is "0000..0000" then this is a new tag
+ # and so oldrev is not valid
+ echo " as a new $refname_type"
+ echo " to $newrev ($newrev_type)"
+ else
+ echo " to $newrev ($newrev_type)"
+ echo " from $oldrev"
+ fi
+ echo ""
+ echo $LOGBEGIN
+ git-show --no-color --root -s $newrev
+ echo $LOGEND
+ echo ""
;;
- esac
- git-rev-list --pretty "$3" "^$base"
-fi) |
-mail -s "$project: Changes to '${1##refs/heads/}'" $recipients
+esac
+
+# Footer
+cat <<-EOF
+
+hooks/update
+---
+Git Source Code Management System
+$0 $1 \\
+ $2 \\
+ $3
+EOF
+#) | cat >&2
+) | /usr/sbin/sendmail -t
+
+# --- Finished
exit 0
diff --git a/upload-pack.c b/upload-pack.c
index 3a466c6a3e..3648aae1a7 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -672,7 +672,8 @@ int main(int argc, char **argv)
if (!enter_repo(dir, strict))
die("'%s': unable to chdir or not a git archive", dir);
-
+ if (is_repository_shallow())
+ die("attempt to fetch/clone from a shallow repository");
upload_pack();
return 0;
}
diff --git a/var.c b/var.c
index 39977b949a..e585e59d31 100644
--- a/var.c
+++ b/var.c
@@ -56,7 +56,6 @@ int main(int argc, char **argv)
}
setup_git_directory();
- setup_ident();
val = NULL;
if (strcmp(argv[1], "-l") == 0) {
diff --git a/write_or_die.c b/write_or_die.c
index a119e1d208..5c4bc8515a 100644
--- a/write_or_die.c
+++ b/write_or_die.c
@@ -4,16 +4,11 @@ int read_in_full(int fd, void *buf, size_t count)
{
char *p = buf;
ssize_t total = 0;
- ssize_t loaded = 0;
while (count > 0) {
- loaded = xread(fd, p, count);
- if (loaded <= 0) {
- if (total)
- return total;
- else
- return loaded;
- }
+ ssize_t loaded = xread(fd, p, count);
+ if (loaded <= 0)
+ return total ? total : loaded;
count -= loaded;
p += loaded;
total += loaded;
@@ -22,30 +17,18 @@ int read_in_full(int fd, void *buf, size_t count)
return total;
}
-void read_or_die(int fd, void *buf, size_t count)
-{
- ssize_t loaded;
-
- loaded = read_in_full(fd, buf, count);
- if (loaded == 0)
- die("unexpected end of file");
- else if (loaded < 0)
- die("read error (%s)", strerror(errno));
-}
-
int write_in_full(int fd, const void *buf, size_t count)
{
const char *p = buf;
ssize_t total = 0;
- ssize_t written = 0;
while (count > 0) {
- written = xwrite(fd, p, count);
- if (written <= 0) {
- if (total)
- return total;
- else
- return written;
+ ssize_t written = xwrite(fd, p, count);
+ if (written < 0)
+ return -1;
+ if (!written) {
+ errno = ENOSPC;
+ return -1;
}
count -= written;
p += written;
@@ -57,12 +40,7 @@ int write_in_full(int fd, const void *buf, size_t count)
void write_or_die(int fd, const void *buf, size_t count)
{
- ssize_t written;
-
- written = write_in_full(fd, buf, count);
- if (written == 0)
- die("disk full?");
- else if (written < 0) {
+ if (write_in_full(fd, buf, count) < 0) {
if (errno == EPIPE)
exit(0);
die("write error (%s)", strerror(errno));
@@ -71,14 +49,7 @@ void write_or_die(int fd, const void *buf, size_t count)
int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
{
- ssize_t written;
-
- written = write_in_full(fd, buf, count);
- if (written == 0) {
- fprintf(stderr, "%s: disk full?\n", msg);
- return 0;
- }
- else if (written < 0) {
+ if (write_in_full(fd, buf, count) < 0) {
if (errno == EPIPE)
exit(0);
fprintf(stderr, "%s: write error (%s)\n",
@@ -91,14 +62,7 @@ int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
{
- ssize_t written;
-
- written = write_in_full(fd, buf, count);
- if (written == 0) {
- fprintf(stderr, "%s: disk full?\n", msg);
- return 0;
- }
- else if (written < 0) {
+ if (write_in_full(fd, buf, count) < 0) {
fprintf(stderr, "%s: write error (%s)\n",
msg, strerror(errno));
return 0;
diff --git a/wt-status.c b/wt-status.c
index c48127daca..2879c3d5ec 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -15,7 +15,13 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[31m", /* WT_STATUS_CHANGED: red */
"\033[31m", /* WT_STATUS_UNTRACKED: red */
};
-static const char* use_add_msg = "use \"git add <file>...\" to incrementally add content to commit";
+
+static const char use_add_msg[] =
+"use \"git add <file>...\" to update what will be committed";
+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";
static int parse_status_slot(const char *var, int offset)
{
@@ -41,16 +47,10 @@ void wt_status_prepare(struct wt_status *s)
unsigned char sha1[20];
const char *head;
+ memset(s, 0, sizeof(*s));
head = resolve_ref("HEAD", sha1, 0, NULL);
s->branch = head ? xstrdup(head) : NULL;
-
s->reference = "HEAD";
- s->amend = 0;
- s->verbose = 0;
- s->commitable = 0;
- s->untracked = 0;
-
- s->workdir_clean = 1;
}
static void wt_status_print_cached_header(const char *reference)
@@ -176,8 +176,14 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
struct wt_status *s = data;
int i;
if (q->nr) {
- s->workdir_clean = 0;
- wt_status_print_header("Changed but not added", use_add_msg);
+ const char *msg = use_add_msg;
+ s->workdir_dirty = 1;
+ for (i = 0; i < q->nr; i++)
+ if (q->queue[i]->status == DIFF_STATUS_DELETED) {
+ msg = use_add_rm_msg;
+ break;
+ }
+ wt_status_print_header("Changed but not updated", msg);
}
for (i = 0; i < q->nr; i++)
wt_status_print_filepair(WT_STATUS_CHANGED, q->queue[i]);
@@ -263,8 +269,9 @@ static void wt_status_print_untracked(struct wt_status *s)
continue;
}
if (!shown_header) {
- s->workdir_clean = 0;
- wt_status_print_header("Untracked files", use_add_msg);
+ s->workdir_untracked = 1;
+ wt_status_print_header("Untracked files",
+ use_add_to_include_msg);
shown_header = 1;
}
color_printf(color(WT_STATUS_HEADER), "#\t");
@@ -288,9 +295,18 @@ void wt_status_print(struct wt_status *s)
unsigned char sha1[20];
s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
- if (s->branch)
+ if (s->branch) {
+ const char *on_what = "On branch ";
+ const char *branch_name = s->branch;
+ if (!strncmp(branch_name, "refs/heads/", 11))
+ branch_name += 11;
+ else if (!strcmp(branch_name, "HEAD")) {
+ branch_name = "";
+ on_what = "Not currently on any branch.";
+ }
color_printf_ln(color(WT_STATUS_HEADER),
- "# On branch %s", s->branch);
+ "# %s%s", on_what, branch_name);
+ }
if (s->is_initial) {
color_printf_ln(color(WT_STATUS_HEADER), "#");
@@ -311,12 +327,14 @@ void wt_status_print(struct wt_status *s)
if (!s->commitable) {
if (s->amend)
printf("# No changes\n");
- else if (s->workdir_clean)
- printf(s->is_initial
- ? "nothing to commit\n"
- : "nothing to commit (working directory matches HEAD)\n");
+ else if (s->workdir_dirty)
+ printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
+ else if (s->workdir_untracked)
+ printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
+ else if (s->is_initial)
+ printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
else
- printf("no changes added to commit (use \"git add\" and/or \"git commit [-a|-i|-o]\")\n");
+ printf("nothing to commit (working directory clean)\n");
}
}
@@ -326,7 +344,7 @@ int git_status_config(const char *k, const char *v)
wt_status_use_color = git_config_colorbool(k, v);
return 0;
}
- if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status", 13)) {
+ if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status.", 13)) {
int slot = parse_status_slot(k, 13);
color_parse(v, k, wt_status_colors[slot]);
}
diff --git a/wt-status.h b/wt-status.h
index 892a86c76a..cfea4ae688 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -12,11 +12,13 @@ struct wt_status {
int is_initial;
char *branch;
const char *reference;
- int commitable;
int verbose;
int amend;
int untracked;
- int workdir_clean;
+ /* These are computed during processing of the individual sections */
+ int commitable;
+ int workdir_dirty;
+ int workdir_untracked;
};
int git_status_config(const char *var, const char *value);