Code

git.git
12 years agoMerge branch 'jc/checkout-out-of-unborn' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:18:06 +0000 (14:18 -0800)]
Merge branch 'jc/checkout-out-of-unborn' into maint

* jc/checkout-out-of-unborn:
  git checkout -b: allow switching out of an unborn branch

12 years agoMerge branch 'jc/maint-mailmap-output' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:18:03 +0000 (14:18 -0800)]
Merge branch 'jc/maint-mailmap-output' into maint

* jc/maint-mailmap-output:
  mailmap: always return a plain mail address from map_user()

12 years agoMerge branch 'jk/prompt-fallback-to-tty' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:18:00 +0000 (14:18 -0800)]
Merge branch 'jk/prompt-fallback-to-tty' into maint

* jk/prompt-fallback-to-tty:
  prompt: fall back to terminal if askpass fails
  prompt: clean up strbuf usage

12 years agoMerge branch 'jn/gitweb-search-utf-8' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:17:58 +0000 (14:17 -0800)]
Merge branch 'jn/gitweb-search-utf-8' into maint

* jn/gitweb-search-utf-8:
  gitweb: Allow UTF-8 encoded CGI query parameters and path_info

12 years agoMerge branch 'jc/maint-commit-ignore-i-t-a' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:08:00 +0000 (14:08 -0800)]
Merge branch 'jc/maint-commit-ignore-i-t-a' into maint

* jc/maint-commit-ignore-i-t-a:
  commit: ignore intent-to-add entries instead of refusing

Conflicts:
cache-tree.c

12 years agoMerge branch 'mm/empty-loose-error-message' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:00:25 +0000 (14:00 -0800)]
Merge branch 'mm/empty-loose-error-message' into maint

* mm/empty-loose-error-message:
  fsck: give accurate error message on empty loose object files

12 years agoMerge branch 'nk/ctype-for-perf' into maint
Junio C Hamano [Thu, 16 Feb 2012 22:00:16 +0000 (14:00 -0800)]
Merge branch 'nk/ctype-for-perf' into maint

* nk/ctype-for-perf:
  ctype: implement islower/isupper macro
  ctype.c only wants git-compat-util.h

12 years agoMerge branch 'jx/i18n-more-marking' into maint
Junio C Hamano [Thu, 16 Feb 2012 21:59:53 +0000 (13:59 -0800)]
Merge branch 'jx/i18n-more-marking' into maint

* jx/i18n-more-marking:
  i18n: format_tracking_info "Your branch is behind" message
  i18n: git-commit whence_s "merge/cherry-pick" message

12 years agoman: rearrange git synopsis to fit in 80 lines
Zbigniew Jędrzejewski-Szmek [Tue, 14 Feb 2012 23:54:21 +0000 (00:54 +0100)]
man: rearrange git synopsis to fit in 80 lines

The line was extended in 2dd8c3 ('git: add --info-path and --man-path
options'), and the formatted man output stopped fitting into the 80
column window.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: --list option for git-branch
Ralf Thielow [Wed, 15 Feb 2012 20:36:58 +0000 (21:36 +0100)]
completion: --list option for git-branch

Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMerge branch 'rt/completion-branch-edit-desc' into maint
Junio C Hamano [Thu, 16 Feb 2012 20:33:46 +0000 (12:33 -0800)]
Merge branch 'rt/completion-branch-edit-desc' into maint

* rt/completion-branch-edit-desc:
  completion: --edit-description option for git-branch

12 years agodiff --stat: show bars of same length for paths with same amount of changes
Junio C Hamano [Tue, 14 Feb 2012 21:49:11 +0000 (13:49 -0800)]
diff --stat: show bars of same length for paths with same amount of changes

When commit 3ed74e6 (diff --stat: ensure at least one '-' for deletions,
and one '+' for additions, 2006-09-28) improved the output for files with
tiny modifications, we accidentally broke the logic to ensure that two
equal sized changes are shown with the bars of the same length, even when
rounding errors exist.

Compute the length of the graph bars, using the same "non-zero changes is
shown with at least one column" scaling logic, but by scaling the sum of
additions and deletions to come up with the total length of the bar (this
ensures that two equal sized changes result in bars of the same length),
and then scaling the smaller of the additions or deletions. The other side
is computed as the difference between the two.

This makes the apportioning between additions and deletions less accurate
due to rounding errors, but it is much less noticeable than two files with
the same amount of change showing bars of different length.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoGit 1.7.9.1 v1.7.9.1
Junio C Hamano [Tue, 14 Feb 2012 17:53:38 +0000 (09:53 -0800)]
Git 1.7.9.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMerge branch 'jk/maint-tag-show-fixes' into maint
Junio C Hamano [Tue, 14 Feb 2012 07:31:27 +0000 (23:31 -0800)]
Merge branch 'jk/maint-tag-show-fixes' into maint

* jk/maint-tag-show-fixes:
  tag: do not show non-tag contents with "-n"
  tag: die when listing missing or corrupt objects
  tag: fix output of "tag -n" when errors occur

Conflicts:
t/t7004-tag.sh

12 years agoMerge branch 'bw/inet-pton-ntop-compat' into maint
Junio C Hamano [Tue, 14 Feb 2012 07:26:31 +0000 (23:26 -0800)]
Merge branch 'bw/inet-pton-ntop-compat' into maint

* bw/inet-pton-ntop-compat:
  Drop system includes from inet_pton/inet_ntop compatibility wrappers

12 years agoMerge branch 'mp/make-cleanse-x-for-exe' into maint
Junio C Hamano [Tue, 14 Feb 2012 07:26:25 +0000 (23:26 -0800)]
Merge branch 'mp/make-cleanse-x-for-exe' into maint

* mp/make-cleanse-x-for-exe:
  Explicitly set X to avoid potential build breakage

12 years agoMerge branch 'jn/merge-no-edit-fix' into maint
Junio C Hamano [Tue, 14 Feb 2012 07:24:02 +0000 (23:24 -0800)]
Merge branch 'jn/merge-no-edit-fix' into maint

* jn/merge-no-edit-fix:
  merge: do not launch an editor on "--no-edit $tag"

12 years agopager: find out the terminal width before spawning the pager
Zbigniew Jędrzejewski-Szmek [Sun, 12 Feb 2012 14:12:32 +0000 (15:12 +0100)]
pager: find out the terminal width before spawning the pager

term_columns() checks for terminal width via ioctl(2) on the standard
output, but we spawn the pager too early for this check to be useful.

The effect of this buglet can be observed by opening a wide terminal and
running "git -p help --all", which still shows 80-column output, while
"git help --all" uses the full terminal width. Run the check before we
spawn the pager to fix this.

While at it, move term_columns() to pager.c and export it from cache.h so
that callers other than the help subsystem can use it.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agodo not override receive-pack errors
Clemens Buchacher [Mon, 13 Feb 2012 20:17:12 +0000 (21:17 +0100)]
do not override receive-pack errors

Receive runs rev-list --verify-objects in order to detect missing
objects. However, such errors are ignored and overridden later.
Instead, consequently ignore all update commands for which an error has
already been detected.

Some tests in t5504 are obsoleted by this change, because invalid
objects are detected even if fsck is not enabled. Instead, they now test
for different error messages depending on whether or not fsck is turned
on. A better fix would be to force a corruption that will be detected by
fsck but not by rev-list.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agot5541: check error message against the real port number used
Clemens Buchacher [Mon, 13 Feb 2012 20:17:14 +0000 (21:17 +0100)]
t5541: check error message against the real port number used

Otherwise the test cannot be run with custom port set to LIB_HTTPD_PORT.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agopush/fetch/clone --no-progress suppresses progress output
Clemens Buchacher [Mon, 13 Feb 2012 20:17:15 +0000 (21:17 +0100)]
push/fetch/clone --no-progress suppresses progress output

By default, progress output is disabled if stderr is not a terminal.
The --progress option can be used to force progress output anyways.
Conversely, --no-progress does not force progress output. In particular,
if stderr is a terminal, progress output is enabled.

This is unintuitive. Change --no-progress to force output off.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogit rev-list: fix invalid typecast
Clemens Buchacher [Mon, 13 Feb 2012 20:17:11 +0000 (21:17 +0100)]
git rev-list: fix invalid typecast

git rev-list passes rev_list_info, not rev_list objects. Without this
fix, rev-list enables or disables the --verify-objects option depending
on a read from an undefined memory location.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoUpdate draft release notes to 1.7.9.1
Junio C Hamano [Mon, 13 Feb 2012 19:46:47 +0000 (11:46 -0800)]
Update draft release notes to 1.7.9.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMerge branch 'js/add-e-submodule-fix' into maint
Junio C Hamano [Mon, 13 Feb 2012 19:42:18 +0000 (11:42 -0800)]
Merge branch 'js/add-e-submodule-fix' into maint

* js/add-e-submodule-fix:
  add -e: do not show difference in a submodule that is merely dirty

12 years agoMerge branch 'jc/parse-date-raw' into maint
Junio C Hamano [Mon, 13 Feb 2012 19:42:15 +0000 (11:42 -0800)]
Merge branch 'jc/parse-date-raw' into maint

* jc/parse-date-raw:
  parse_date(): '@' prefix forces git-timestamp
  parse_date(): allow ancient git-timestamp

12 years agoMerge branch 'jc/merge-ff-only-stronger-than-signed-merge' into maint
Junio C Hamano [Mon, 13 Feb 2012 19:42:11 +0000 (11:42 -0800)]
Merge branch 'jc/merge-ff-only-stronger-than-signed-merge' into maint

* jc/merge-ff-only-stronger-than-signed-merge:
  merge: do not create a signed tag merge under --ff-only option

12 years agoMerge branch 'jc/branch-desc-typoavoidance' into maint
Junio C Hamano [Mon, 13 Feb 2012 19:42:07 +0000 (11:42 -0800)]
Merge branch 'jc/branch-desc-typoavoidance' into maint

* jc/branch-desc-typoavoidance:
  branch --edit-description: protect against mistyped branch name
  tests: add write_script helper function

12 years agoMerge branch 'jn/rpm-spec' into maint
Junio C Hamano [Mon, 13 Feb 2012 19:42:04 +0000 (11:42 -0800)]
Merge branch 'jn/rpm-spec' into maint

* jn/rpm-spec:
  git.spec: Workaround localized messages not put in any RPM

12 years agot: use sane_unset instead of unset
Ævar Arnfjörð Bjarmason [Sun, 12 Feb 2012 01:05:12 +0000 (01:05 +0000)]
t: use sane_unset instead of unset

Change several tests to use the sane_unset function introduced in
v1.7.3.1-35-g00648ba instead of the built-in unset function.

This fixes a failure I was having on t9130-git-svn-authors-file.sh on
Solaris, and prevents several other issues from occurring.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoRemove Git's support for smoke testing
Ævar Arnfjörð Bjarmason [Fri, 23 Dec 2011 17:08:18 +0000 (17:08 +0000)]
Remove Git's support for smoke testing

I'm no longer running the Git smoke testing service at
smoke.git.nix.is due to Smolder being a fragile piece of software not
having time to follow through on making it easy for third parties to
run and submit their own smoke tests.

So remove the support in Git for sending smoke tests to
smoke.git.nix.is, it's still easy to modify the test suite to submit
smokes somewhere else.

This reverts the following commits:

    Revert "t/README: Add SMOKE_{COMMENT,TAGS}= to smoke_report target" -- e38efac87d
    Revert "t/README: Document the Smoke testing" -- d15e9ebc5c
    Revert "t/Makefile: Create test-results dir for smoke target" -- 617344d77b
    Revert "tests: Infrastructure for Git smoke testing" -- b6b84d1b74

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMakefile: Change the default compiler from "gcc" to "cc"
Ævar Arnfjörð Bjarmason [Tue, 20 Dec 2011 23:40:47 +0000 (23:40 +0000)]
Makefile: Change the default compiler from "gcc" to "cc"

Ever since the very first commit to git.git we've been setting CC to
"gcc". Presumably this is behavior that Linus copied from the Linux
Makefile.

However unlike Linux Git is written in ANSI C and supports a multitude
of compilers, including Clang, Sun Studio, xlc etc. On my Linux box
"cc" is a symlink to clang, and on a Solaris box I have access to "cc"
is Sun Studio's CC.

Both of these are perfectly capable of compiling Git, and it's
annoying to have to specify CC=cc on the command-line when compiling
Git when that's the default behavior of most other portable programs.

So change the default to "cc". Users who want to compile with GCC can
still add "CC=gcc" to the make(1) command-line, but those users who
don't have GCC as their "cc" will see expected behavior, and as a
bonus we'll be more likely to smoke out new compilation warnings from
our distributors since they'll me using a more varied set of compilers
by default.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMakefile: introduce CHARSET_LIB to link with -lcharset
Дилян Палаузов [Sun, 12 Feb 2012 16:23:36 +0000 (17:23 +0100)]
Makefile: introduce CHARSET_LIB to link with -lcharset

On some systems, the function locale_charset() may not be exported from
libiconv but is available from libcharset, and we need -lcharset when
linking.

Introduce a make variable CHARSET_LIB that can be set to -lcharsetlib
on such systems.  Also autodetect this in the configure script by first
looking for the symbol in libiconv, and then libcharset.

Signed-off-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
12 years agomergetools/meld: Use --help output to detect --output support
Jonathan Nieder [Fri, 10 Feb 2012 21:57:55 +0000 (15:57 -0600)]
mergetools/meld: Use --help output to detect --output support

In v1.7.7-rc0~3^2 (2011-08-19), git mergetool's "meld" support learned
to use the --output option when calling versions of meld that are
detected to support it (1.5.0 and newer, hopefully).

Alas, it misdetects old versions (before 1.1.5, 2006-06-11) of meld as
supporting the option, so on systems with such meld, instead of
getting a nice merge helper, the operator gets a dialog box with the
text "Wrong number of arguments (Got 5)".  (Version 1.1.5 is when meld
switched to using optparse.  One consequence of that change was that
errors in usage are detected and signalled through the exit status
even when --help was passed.)

Luckily there is a simpler check that is more reliable: the usage
string printed by "meld --help" reliably reflects whether --output is
supported in a given version.  Use it.

Reported-by: Jeff Epler <jepler@unpythonic.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoUpdate draft release notes to 1.7.9.1
Junio C Hamano [Fri, 10 Feb 2012 22:04:20 +0000 (14:04 -0800)]
Update draft release notes to 1.7.9.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMerge branch 'jc/maint-request-pull-for-tag' into maint
Junio C Hamano [Fri, 10 Feb 2012 21:59:02 +0000 (13:59 -0800)]
Merge branch 'jc/maint-request-pull-for-tag' into maint

* jc/maint-request-pull-for-tag:
  request-pull: explicitly ask tags/$name to be pulled

12 years agoMerge branch 'tr/grep-l-with-decoration' into maint
Junio C Hamano [Fri, 10 Feb 2012 21:59:02 +0000 (13:59 -0800)]
Merge branch 'tr/grep-l-with-decoration' into maint

* tr/grep-l-with-decoration:
  grep: fix -l/-L interaction with decoration lines

12 years agoMerge branch 'jl/submodule-re-add' into maint
Junio C Hamano [Fri, 10 Feb 2012 21:59:01 +0000 (13:59 -0800)]
Merge branch 'jl/submodule-re-add' into maint

* jl/submodule-re-add:
  submodule add: fix breakage when re-adding a deep submodule

12 years agoMerge branch 'da/maint-mergetool-twoway' into maint
Junio C Hamano [Fri, 10 Feb 2012 21:59:01 +0000 (13:59 -0800)]
Merge branch 'da/maint-mergetool-twoway' into maint

* da/maint-mergetool-twoway:
  mergetool: Provide an empty file when needed

12 years agoctype: implement islower/isupper macro
Namhyung Kim [Fri, 10 Feb 2012 02:13:31 +0000 (11:13 +0900)]
ctype: implement islower/isupper macro

"perf" uses a the forked copy of this file, and wants to use these two
macros.

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoctype.c only wants git-compat-util.h
Namhyung Kim [Fri, 10 Feb 2012 02:13:30 +0000 (11:13 +0900)]
ctype.c only wants git-compat-util.h

The implementation of sane ctype macros only depends on symbols in
git-compat-util.h not cache.h

Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoExplicitly set X to avoid potential build breakage
Michael Palimaka [Wed, 8 Feb 2012 10:59:04 +0000 (21:59 +1100)]
Explicitly set X to avoid potential build breakage

$X is appended to binary names for Windows builds (ie. git.exe).
Pollution from the environment can inadvertently trigger this behaviour,
resulting in 'git' turning into 'gitwhatever' without warning.

Signed-off-by: Michael Palimaka <kensington@astralcloak.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agomerge: do not launch an editor on "--no-edit $tag"
Junio C Hamano [Thu, 9 Feb 2012 21:30:52 +0000 (13:30 -0800)]
merge: do not launch an editor on "--no-edit $tag"

When the user explicitly asked us not to, don't launch an editor.

But do everything else the same way as the "edit" case, i.e. leave the
comment with verification result in the log template and record the
mergesig in the resulting merge commit for later inspection.

Based on initiail analysis by Jonathan Nieder.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMakefile: fix syntax for older make
Johannes Sixt [Thu, 9 Feb 2012 08:22:26 +0000 (09:22 +0100)]
Makefile: fix syntax for older make

It is necessary to write the else branch as a nested conditional. Also,
write the conditions with parentheses because we use them throughout the
Makefile.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agotag: do not show non-tag contents with "-n"
Junio C Hamano [Mon, 6 Feb 2012 18:13:27 +0000 (10:13 -0800)]
tag: do not show non-tag contents with "-n"

"git tag -n" did not check the type of the object it is reading the top n
lines from. At least, avoid showing the beginning of trees and blobs when
dealing with lightweight tags that point at them.

As the payload of a tag and a commit look similar in that they both start
with a header block, which is skipped for the purpose of "-n" output,
followed by human readable text, allow the message of commit objects to be
shown just like the contents of tag objects. This avoids regression for
people who have been using "tag -n" to show the log messages of commits
that are pointed at by lightweight tags.

Test script is from Jeff King.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocommit: ignore intent-to-add entries instead of refusing
Junio C Hamano [Tue, 7 Feb 2012 19:55:48 +0000 (11:55 -0800)]
commit: ignore intent-to-add entries instead of refusing

Originally, "git add -N" was introduced to help users from forgetting to
add new files to the index before they ran "git commit -a".  As an attempt
to help them further so that they do not forget to say "-a", "git commit"
to commit the index as-is was taught to error out, reminding the user that
they may have forgotten to add the final contents of the paths before
running the command.

This turned out to be a false "safety" that is useless.  If the user made
changes to already tracked paths and paths added with "git add -N", and
then ran "git add" to register the final contents of the paths added with
"git add -N", "git commit" will happily create a commit out of the index,
without including the local changes made to the already tracked paths. It
was not a useful "safety" measure to prevent "forgetful" mistakes from
happening.

It turns out that this behaviour is not just a useless false "safety", but
actively hurts use cases of "git add -N" that were discovered later and
have become popular, namely, to tell Git to be aware of these paths added
by "git add -N", so that commands like "git status" and "git diff" would
include them in their output, even though the user is not interested in
including them in the next commit they are going to make.

Fix this ancient UI mistake, and instead make a commit from the index
ignoring the paths added by "git add -N" without adding real contents.

Based on the work by Nguyễn Thái Ngọc Duy, and helped by injection of
sanity from Jonathan Nieder and others on the Git mailing list.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoadd -e: do not show difference in a submodule that is merely dirty
Johannes Schindelin [Tue, 7 Feb 2012 04:05:48 +0000 (05:05 +0100)]
add -e: do not show difference in a submodule that is merely dirty

When the HEAD of the submodule matches what is recorded in the index of
the superproject, and it has local changes or untracked files, the patch
offered by "git add -e" for editing shows a diff like this:

    diff --git a/submodule b/submodule
    <header>
    -deadbeef...
    +deadbeef...-dirty

Because applying such a patch has no effect to the index, this is a
useless noise.  Generate the patch with IGNORE_DIRTY_SUBMODULES flag to
prevent such a change from getting reported.

This patch also loses the "-dirty" suffix from the output when the HEAD of
the submodule is different from what is in the index of the superproject.
As such dirtiness expressed by the suffix does not affect the result of
the patch application at all, there is no information lost if we remove
it. The user could still run "git status" before "git add -e" if s/he
cares about the dirtiness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogit checkout -b: allow switching out of an unborn branch
Junio C Hamano [Mon, 30 Jan 2012 20:10:08 +0000 (12:10 -0800)]
git checkout -b: allow switching out of an unborn branch

Running "git checkout -b another" immediately after "git init" when you do
not even have a commit on 'master' fails with:

    $ git checkout -b another
    fatal: You are on a branch yet to be born

This is unnecessary, if we redefine "git checkout -b $name" that does not
take any $start_point (which has to be a commit) as "I want to check out a
new branch $name from the state I am in".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: simplify __gitcomp and __gitcomp_nl implementations
Felipe Contreras [Thu, 2 Feb 2012 19:48:08 +0000 (11:48 -0800)]
completion: simplify __gitcomp and __gitcomp_nl implementations

These shell functions are written in an unnecessarily verbose way;
simplify their "conditionally use $<number> after checking $# against
<number>" logic by using shell's built-in conditional substitution
facilities.

Also remove the first of the two assignments to IFS in __gitcomp_nl
that does not have any effect.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: use ls -1 instead of rolling a loop to do that ourselves
Felipe Contreras [Thu, 2 Feb 2012 09:05:29 +0000 (03:05 -0600)]
completion: use ls -1 instead of rolling a loop to do that ourselves

This simplifies the code a great deal.  In particular, it allows us to
get rid of __git_shopt, which is used only in this fuction to enable
'nullglob' in zsh.

[jn: squashed with a patch that actually gets rid of __git_shopt]

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: work around zsh option propagation bug
Felipe Contreras [Thu, 2 Feb 2012 19:26:15 +0000 (11:26 -0800)]
completion: work around zsh option propagation bug

When listing commands in zsh (git <TAB><TAB>), all of them will show up,
instead of only porcelain ones.

The root cause of this is because zsh versions from 4.3.0 to present
(4.3.15) do not correctly propagate the SH_WORD_SPLIT option into the
subshell in ${foo:=$(bar)} expressions. Because of this bug, the list of
all commands was treated as a single word in __git_list_porcelain_commands
and did not match any of the patterns that would usually cause plumbing to
be excluded.

With problematic versions of zsh, after running

emulate sh
fn () {
var='one two'
for v in $var; do echo $v; done
}
x=$(fn)
: ${y=$(fn)}

printing "$x" results in two lines as expected, but printing "$y" results
in a single line because $var is expanded as a single word when evaluating
fn to compute y.

So avoid the construct, and use an explicit 'test -n "$foo" || foo=$(bar)'
instead.

[jn: clarified commit message, indentation style fix]

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agomailmap: always return a plain mail address from map_user()
Junio C Hamano [Mon, 6 Feb 2012 01:31:51 +0000 (17:31 -0800)]
mailmap: always return a plain mail address from map_user()

The callers of map_user() give email and name to it, and expect to get the
up-to-date email and/or name to be used in their output. The function
rewrites the given buffers in place. To optimize the majority of cases,
the function returns 0 when it did not do anything, and it returns 1 when
the caller should use the updated contents.

The 'email' input to the function is terminated by '>' or a NUL (whichever
comes first) for historical reasons, but when a rewrite happens, the value
is replaced with the mailbox inside the <> pair.  However, it failed to
meet this expectation when it only rewrote the name part without rewriting
the email part, and the email in the input was terminated by '>'.

This causes an extra '>' to appear in the output of "blame -e", because the
caller does send in '>'-terminated email, and when the function returned 1
to tell it that rewriting happened, it appends '>' that is necessary when
the email part was rewritten.

The patch looks bigger than it actually is, because this change makes a
variable that points at the end of the email part in the input 'p' live
much longer than it used to, deserving a more descriptive name.

Noticed and diagnosed by Felipe Contreras and Jeff King.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agofsck: give accurate error message on empty loose object files
Matthieu Moy [Mon, 6 Feb 2012 16:24:52 +0000 (17:24 +0100)]
fsck: give accurate error message on empty loose object files

Since 3ba7a065527a (A loose object is not corrupt if it
cannot be read due to EMFILE), "git fsck" on a repository with an empty
loose object file complains with the error message

  fatal: failed to read object <sha1>: Invalid argument

This comes from a failure of mmap on this empty file, which sets errno to
EINVAL. Instead of calling xmmap on empty file, we display a clean error
message ourselves, and return a NULL pointer. The new message is

  error: object file .git/objects/09/<rest-of-sha1> is empty
  fatal: loose object <sha1> (stored in .git/objects/09/<rest-of-sha1>) is corrupt

The second line was already there before the regression in 3ba7a065527a,
and the first is an additional message, that should help diagnosing the
problem for the user.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agotag: die when listing missing or corrupt objects
Jeff King [Mon, 6 Feb 2012 08:13:42 +0000 (03:13 -0500)]
tag: die when listing missing or corrupt objects

We don't usually bother looking at tagged objects at all
when listing. However, if "-n" is specified, we open the
objects to read the annotations of the tags.  If we fail to
read an object, or if the object has zero length, we simply
silently return.

The first case is an indication of a broken or corrupt repo,
and we should notify the user of the error.

The second case is OK to silently ignore; however, the
existing code leaked the buffer returned by read_sha1_file.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agotag: fix output of "tag -n" when errors occur
Jeff King [Mon, 6 Feb 2012 08:13:12 +0000 (03:13 -0500)]
tag: fix output of "tag -n" when errors occur

When "git tag" is instructed to print lines from annotated
tags via "-n", it first prints the tag name, then attempts
to parse and print the lines of the tag object, and then
finally adds a trailing newline.

If an error occurs, we return early from the function and
never print the newline, screwing up the output for the next
tag. Let's factor the line-printing into its own function so
we can manage the early returns better, and make sure that
we always terminate the line.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoFix build problems related to profile-directed optimization
Theodore Ts'o [Mon, 6 Feb 2012 06:00:17 +0000 (01:00 -0500)]
Fix build problems related to profile-directed optimization

There was a number of problems I ran into when trying the
profile-directed optimizations added by Andi Kleen in git commit
7ddc2710b9.  (This was using gcc 4.4 found on many enterprise
distros.)

1) The -fprofile-generate and -fprofile-use commands are incompatible
with ccache; the code ends up looking in the wrong place for the gcda
files based on the ccache object names.

2) If the makefile notices that CFLAGS are different, it will rebuild
all of the binaries.  Hence the recipe originally specified by the
INSTALL file ("make profile-all" followed by "make install") doesn't
work.  It will appear to work, but the binaries will end up getting
built with no optimization.

This patch fixes this by using an explicit set of options passed via
the PROFILE variable then using this to directly manipulate CFLAGS and
EXTLIBS.

The developer can run "make PROFILE=BUILD all ; sudo make
PROFILE=BUILD install" automatically run a two-pass build with the
test suite run in between as the sample workload for the purpose of
recording profiling information to do the profile-directed
optimization.

Alternatively, the profiling version of binaries can be built using:

make PROFILE=GEN PROFILE_DIR=/var/cache/profile all
make PROFILE=GEN install

and then after git has been used for a while, the optimized version of
the binary can be built as follows:

make PROFILE=USE PROFILE_DIR=/var/cache/profile all
make PROFILE=USE install

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoPrepare for 1.7.9.1
Junio C Hamano [Mon, 6 Feb 2012 08:03:18 +0000 (00:03 -0800)]
Prepare for 1.7.9.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: --edit and --no-edit for git-merge
Adrian Weimann [Mon, 30 Jan 2012 19:29:33 +0000 (20:29 +0100)]
completion: --edit and --no-edit for git-merge

Signed-off-by: Adrian Weimann <adrian.weimann@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoMerge branch 'sp/smart-http-failure-to-push' into maint
Junio C Hamano [Mon, 6 Feb 2012 07:58:43 +0000 (23:58 -0800)]
Merge branch 'sp/smart-http-failure-to-push' into maint

* sp/smart-http-failure-to-push:
  remote-curl: Fix push status report when all branches fail

12 years agoMerge branch 'jc/maint-log-first-parent-pathspec' into maint
Junio C Hamano [Mon, 6 Feb 2012 07:58:42 +0000 (23:58 -0800)]
Merge branch 'jc/maint-log-first-parent-pathspec' into maint

* jc/maint-log-first-parent-pathspec:
  Making pathspec limited log play nicer with --first-parent

12 years agoMerge branch 'cb/push-quiet' into maint
Junio C Hamano [Mon, 6 Feb 2012 07:58:42 +0000 (23:58 -0800)]
Merge branch 'cb/push-quiet' into maint

* cb/push-quiet:
  t5541: avoid TAP test miscounting
  fix push --quiet: add 'quiet' capability to receive-pack
  server_supports(): parse feature list more carefully

12 years agoMerge branch 'cb/maint-kill-subprocess-upon-signal' into maint
Junio C Hamano [Mon, 6 Feb 2012 07:58:42 +0000 (23:58 -0800)]
Merge branch 'cb/maint-kill-subprocess-upon-signal' into maint

* cb/maint-kill-subprocess-upon-signal:
  dashed externals: kill children on exit
  run-command: optionally kill children on exit

12 years agoSync with 1.7.6.6
Junio C Hamano [Mon, 6 Feb 2012 07:53:21 +0000 (23:53 -0800)]
Sync with 1.7.6.6

* maint-1.7.8:
  Git 1.7.6.6
  imap-send: remove dead code

12 years agoSync with 1.7.6.6
Junio C Hamano [Mon, 6 Feb 2012 07:52:53 +0000 (23:52 -0800)]
Sync with 1.7.6.6

* maint-1.7.7:
  Git 1.7.6.6
  imap-send: remove dead code

12 years agoSync with 1.7.6.6
Junio C Hamano [Mon, 6 Feb 2012 07:52:25 +0000 (23:52 -0800)]
Sync with 1.7.6.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoGit 1.7.6.6 v1.7.6.6
Junio C Hamano [Mon, 6 Feb 2012 07:46:44 +0000 (23:46 -0800)]
Git 1.7.6.6

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoimap-send: remove dead code
Jeff King [Mon, 6 Feb 2012 06:29:37 +0000 (01:29 -0500)]
imap-send: remove dead code

The imap-send code was adapted from another project, and
still contains many unused bits of code. One of these bits
contains a type "struct string_list" which bears no
resemblence to the "struct string_list" we use elsewhere in
git. This causes the compiler to complain if git's
string_list ever becomes part of cache.h.

Let's just drop the dead code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agobranch --edit-description: protect against mistyped branch name
Junio C Hamano [Mon, 6 Feb 2012 01:13:36 +0000 (17:13 -0800)]
branch --edit-description: protect against mistyped branch name

It is very easy to mistype the branch name when editing its description,
e.g.

$ git checkout -b my-topic master
: work work work
: now we are at a good point to switch working something else
$ git checkout master
: ah, let's write it down before we forget what we were doing
$ git branch --edit-description my-tpoic

The command does not notice that branch 'my-tpoic' does not exist.  It is
not lost (it becomes description of an unborn my-tpoic branch), but is not
very useful.  So detect such a case and error out to reduce the grief
factor from this common mistake.

This incidentally also errors out --edit-description when the HEAD points
at an unborn branch (immediately after "init", or "checkout --orphan"),
because at that point, you do not even have any commit that is part of
your history and there is no point in describing how this particular
branch is different from the branch it forked off of, which is the useful
bit of information the branch description is designed to capture.

We may want to special case the unborn case later, but that is outside the
scope of this patch to prevent more common mistakes before 1.7.9 series
gains too much widespread use.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoDrop system includes from inet_pton/inet_ntop compatibility wrappers
Ben Walton [Sun, 5 Feb 2012 22:32:21 +0000 (17:32 -0500)]
Drop system includes from inet_pton/inet_ntop compatibility wrappers

As both of these compatibility wrappers include git-compat-utils.h,
all of the system includes were redundant.

Dropping these system includes also makes git-compat-utils.h the first
include which avoids a compiler warning on Solaris due to the
redefinition of _FILE_OFFSET_BITS.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agomerge: do not create a signed tag merge under --ff-only option
Junio C Hamano [Mon, 6 Feb 2012 00:22:12 +0000 (16:22 -0800)]
merge: do not create a signed tag merge under --ff-only option

Starting at release v1.7.9, if you ask to merge a signed tag, "git merge"
always creates a merge commit, even when the tag points at a commit that
happens to be a descendant of your current commit.

Unfortunately, this interacts rather badly for people who use --ff-only to
make sure that their branch is free of local developments. It used to be
possible to say:

$ git checkout -b frotz v1.7.9~30
        $ git merge --ff-only v1.7.9

and expect that the resulting tip of frotz branch matches v1.7.9^0 (aka
the commit tagged as v1.7.9), but this fails with the updated Git with:

fatal: Not possible to fast-forward, aborting.

because a merge that merges v1.7.9 tag to v1.7.9~30 cannot be created by
fast forwarding.

We could teach users that now they have to do

$ git merge --ff-only v1.7.9^0

but it is far more pleasant for users if we DWIMmed this ourselves.

When an integrator pulls in a topic from a lieutenant via a signed tag,
even when the work done by the lieutenant happens to fast-forward, the
integrator wants to have a merge record, so the integrator will not be
asking for --ff-only when running "git pull" in such a case. Therefore,
this change should not regress the support for the use case v1.7.9 wanted
to add.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoUse correct grammar in diffstat summary line
Nguyễn Thái Ngọc Duy [Wed, 1 Feb 2012 12:55:07 +0000 (19:55 +0700)]
Use correct grammar in diffstat summary line

"git diff --stat" and "git apply --stat" now learn to print the line
"%d files changed, %d insertions(+), %d deletions(-)" in singular form
whenever applicable. "0 insertions" and "0 deletions" are also omitted
unless they are both zero.

This matches how versions of "diffstat" that are not prehistoric produced
their output, and also makes this line translatable.

[jc: with help from Thomas Dickey in archaeology of "diffstat"]
[jc: squashed Jonathan's updates to illustrations in tutorials and a test]

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoparse_date(): '@' prefix forces git-timestamp
Junio C Hamano [Thu, 2 Feb 2012 21:41:43 +0000 (13:41 -0800)]
parse_date(): '@' prefix forces git-timestamp

The only place that the issue this series addresses was observed
where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE
in order to replay a commit with an ancient timestamp.

With the previous patch alone, "git commit --date='20100917 +0900'"
can be misinterpreted to mean an ancient timestamp, not September in
year 2010.  Guard this codepath by requring an extra '@' in front of
the raw git timestamp on the parsing side. This of course needs to
be compensated by updating get_author_ident_from_commit and the code
for "git commit --amend" to prepend '@' to the string read from the
existing commit in the GIT_AUTHOR_DATE environment variable.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoparse_date(): allow ancient git-timestamp
Junio C Hamano [Thu, 2 Feb 2012 21:41:42 +0000 (13:41 -0800)]
parse_date(): allow ancient git-timestamp

The date-time parser parses out a human-readble datestring piece by
piece, so that it could even parse a string in a rather strange
notation like 'noon november 11, 2005', but restricts itself from
parsing strings in "<seconds since epoch> <timezone>" format only
for reasonably new timestamps (like 1974 or newer) with 10 or more
digits. This is to prevent a string like "20100917" from getting
interpreted as seconds since epoch (we want to treat it as September
17, 2010 instead) while doing so.

The same codepath is used to read back the timestamp that we have
already recorded in the headers of commit and tag objects; because
of this, such a commit with timestamp "0 +0000" cannot be rebased or
amended very easily.

Teach parse_date() codepath to special case a string of the form
"<digits> +<4-digits>" to work this issue around, but require that
there is no other cruft around the string when parsing a timestamp
of this format for safety.

Note that this has a slight backward incompatibility implications.

If somebody writes "git commit --date='20100917 +0900'" and wants it
to mean a timestamp in September 2010 in Japan, this change will
break such a use case.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogit.spec: Workaround localized messages not put in any RPM
Jakub Narebski [Fri, 3 Feb 2012 21:49:07 +0000 (22:49 +0100)]
git.spec: Workaround localized messages not put in any RPM

Currently building git RPM from tarball results in the following
error:

  RPM build errors:
     Installed (but unpackaged) file(s) found:
     /usr/share/locale/is/LC_MESSAGES/git.mo

This is caused by the fact that localized messages do not have their
place in some RPM package.  Let's postpone decision where they should
be put (be it git-i18n-Icelandic, or git-i18n, or git package itself)
for later by removing locale files at the end of install phase.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agotests: add write_script helper function
Junio C Hamano [Sat, 4 Feb 2012 06:29:01 +0000 (01:29 -0500)]
tests: add write_script helper function

Many of the scripts in the test suite write small helper
shell scripts to disk. It's best if these shell scripts
start with "#!$SHELL_PATH" rather than "#!/bin/sh", because
/bin/sh on some platforms is too buggy to be used.

However, it can be cumbersome to expand $SHELL_PATH, because
the usual recipe for writing a script is:

cat >foo.sh <<-\EOF
#!/bin/sh
echo my arguments are "$@"
EOF

To expand $SHELL_PATH, you have to either interpolate the
here-doc (which would require quoting "\$@"), or split the
creation into two commands (interpolating the $SHELL_PATH
line, but not the rest of the script). Let's provide a
helper function that makes that less syntactically painful.

While we're at it, this helper can also take care of the
"chmod +x" that typically comes after the creation of such a
script, saving the caller a line.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoprompt: fall back to terminal if askpass fails
Jeff King [Fri, 3 Feb 2012 22:16:02 +0000 (17:16 -0500)]
prompt: fall back to terminal if askpass fails

The current askpass code simply dies if calling an askpass
helper fails. Worse, in some failure modes it doesn't even
print an error (if start_command fails, then it prints its
own error; if reading fails, we print an error; but if the
command exits non-zero, finish_command fails and we print
nothing!).

Let's be more kind to the user by printing an error message
when askpass doesn't work out, and then falling back to the
terminal (which also may fail, of course, but we die already
there with a nice message).

While we're at it, let's clean up the existing error
messages a bit.  Now that our prompts are very long and
contain quotes and colons themselves, our error messages are
hard to read.

So the new failure modes look like:

  [before, with a terminal]
  $ GIT_ASKPASS=false git push
  $ echo $?
  128

  [before, with no terminal, and we must give up]
  $ setsid git push
  fatal: could not read 'Password for 'https://peff@github.com': ': No such device or address

  [after, with a terminal]
  $ GIT_ASKPASS=false git push
  error: unable to read askpass response from 'false'
  Password for 'https://peff@github.com':

  [after, with no terminal, and we must give up]
  $ GIT_ASKPASS=false setsid git push
  error: unable to read askpass response from 'false'
  fatal: could not read Password for 'https://peff@github.com': No such device or address

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoprompt: clean up strbuf usage
Jeff King [Fri, 3 Feb 2012 22:14:11 +0000 (17:14 -0500)]
prompt: clean up strbuf usage

The do_askpass function inherited a few bad habits from the
original git_getpass. One, there's no need to strbuf_reset a
buffer which was just initialized. And two, it's a good
habit to use strbuf_detach to claim ownership of a buffer's
string (even though in this case the owning buffer goes out
of scope, so it's effectively the same thing).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogitweb: Allow UTF-8 encoded CGI query parameters and path_info
Jakub Narebski [Fri, 3 Feb 2012 12:44:54 +0000 (13:44 +0100)]
gitweb: Allow UTF-8 encoded CGI query parameters and path_info

Gitweb forgot to turn query parameters into UTF-8. This results in a bug
that one cannot search for a string with characters outside US-ASCII.  For
example searching for "Michał Kiedrowicz" (containing letter 'ł' - LATIN
SMALL LETTER L WITH STROKE, with Unicode codepoint U+0142, represented
with 0xc5 0x82 bytes in UTF-8 and percent-encoded as %C5%82) result in the
following incorrect data in search field

MichaÅ\202 Kiedrowicz

This is caused by CGI by default treating '0xc5 0x82' bytes as two
characters in Perl legacy encoding latin-1 (iso-8859-1), because 's'
query parameter is not processed explicitly as UTF-8 encoded string.

The solution used here follows "Using Unicode in a Perl CGI script"
article on http://www.lemoda.net/cgi/perl-unicode/index.html:

use CGI;
use Encode 'decode_utf8;
my $value = params('input');
$value = decode_utf8($value);

Decoding UTF-8 is done when filling %input_params hash and $path_info
variable; the former requires to move from explicit $cgi->param(<label>)
to $input_params{<name>} in a few places, which is a good idea anyway.

Also add -override=>1 parameter to $cgi->textfield() invocation in search
form.  Otherwise CGI would use values from query string if it is present,
filling value from $cgi->param... without decode_utf8().  As we are using
value of appropriate parameter anyway, -override=>1 doesn't change the
situation but makes gitweb fill search field correctly.

We could simply use the '-utf8' pragma (via "use CGI '-utf8';") to solve
this, but according to CGI.pm documentation, it may cause problems with
POST requests containing binary files, and it requires CGI 3.31 (I think),
released with perl v5.8.9.

Reported-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Jakub Narębski <jnareb@gmail.com>
Tested-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agostandardize and improve lookup rules for external local repos
Jeff King [Thu, 2 Feb 2012 21:59:13 +0000 (16:59 -0500)]
standardize and improve lookup rules for external local repos

When you specify a local repository on the command line of
clone, ls-remote, upload-pack, receive-pack, or upload-archive,
or in a request to git-daemon, we perform a little bit of
lookup magic, doing things like looking in working trees for
.git directories and appending ".git" for bare repos.

For clone, this magic happens in get_repo_path. For
everything else, it happens in enter_repo. In both cases,
there are some ambiguous or confusing cases that aren't
handled well, and there is one case that is not handled the
same by both methods.

This patch tries to provide (and test!) standard, sensible
lookup rules for both code paths. The intended changes are:

  1. When looking up "foo", we have always preferred
     a working tree "foo" (containing "foo/.git" over the
     bare "foo.git". But we did not prefer a bare "foo" over
     "foo.git". With this patch, we do so.

  2. We would select directories that existed but didn't
     actually look like git repositories. With this patch,
     we make sure a selected directory looks like a git
     repo. Not only is this more sensible in general, but it
     will help anybody who is negatively affected by change
     (1) negatively (e.g., if they had "foo.git" next to its
     separate work tree "foo", and expect to keep finding
     "foo.git" when they reference "foo").

  3. The enter_repo code path would, given "foo", look for
     "foo.git/.git" (i.e., do the ".git" append magic even
     for a repo with working tree). The clone code path did
     not; with this patch, they now behave the same.

In the unlikely case of a working tree overlaying a bare
repo (i.e., a ".git" directory _inside_ a bare repo), we
continue to treat it as a working tree (prefering the
"inner" .git over the bare repo). This is mainly because the
combination seems nonsensical, and I'd rather stick with
existing behavior on the off chance that somebody is relying
on it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: pre-load userdiff drivers when threaded
Jeff King [Thu, 2 Feb 2012 08:24:28 +0000 (03:24 -0500)]
grep: pre-load userdiff drivers when threaded

The low-level grep_source code will automatically load the
userdiff driver to see whether a file is binary. However,
when we are threaded, it will load the drivers in a
non-deterministic order, handling each one as its assigned
thread happens to be scheduled.

Meanwhile, the attribute lookup code (which underlies the
userdiff driver lookup) is optimized to handle paths in
sequential order (because they tend to share the same
gitattributes files). Multi-threading the lookups destroys
the locality and makes this optimization less effective.

We can fix this by pre-loading the userdiff driver in the
main thread, before we hand off the file to a worker thread.
My best-of-five for "git grep foo" on the linux-2.6
repository went from:

  real    0m0.391s
  user    0m1.708s
  sys     0m0.584s

to:

  real    0m0.360s
  user    0m1.576s
  sys     0m0.572s

Not a huge speedup, but it's quite easy to do. The only
trick is that we shouldn't perform this optimization if "-a"
was used, in which case we won't bother checking whether
the files are binary at all.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: load file data after checking binary-ness
Jeff King [Thu, 2 Feb 2012 08:21:11 +0000 (03:21 -0500)]
grep: load file data after checking binary-ness

Usually we load each file to grep into memory, check whether
it's binary, and then either grep it (the default) or not
(if "-I" was given).

In the "-I" case, we can skip loading the file entirely if
it is marked as binary via gitattributes. On my giant
3-gigabyte media repository, doing "git grep -I foo" went
from:

  real    0m0.712s
  user    0m0.044s
  sys     0m4.780s

to:

  real    0m0.026s
  user    0m0.016s
  sys     0m0.020s

Obviously this is an extreme example. The repo is almost
entirely binary files, and you can see that we spent all of
our time asking the kernel to read() the data. However, with
a cold disk cache, even avoiding a few binary files can have
an impact.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: respect diff attributes for binary-ness
Jeff King [Thu, 2 Feb 2012 08:21:02 +0000 (03:21 -0500)]
grep: respect diff attributes for binary-ness

There is currently no way for users to tell git-grep that a
particular path is or is not a binary file; instead, grep
always relies on its auto-detection (or the user specifying
"-a" to treat all binary-looking files like text).

This patch teaches git-grep to use the same attribute lookup
that is used by git-diff. We could add a new "grep" flag,
but that is unnecessarily complex and unlikely to be useful.
Despite the name, the "-diff" attribute (or "diff=foo" and
the associated diff.foo.binary config option) are really
about describing the contents of the path. It's simply
historical that diff was the only thing that cared about
these attributes in the past.

And if this simple approach turns out to be insufficient, we
still have a backwards-compatible path forward: we can add a
separate "grep" attribute, and fall back to respecting
"diff" if it is unset.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: cache userdiff_driver in grep_source
Jeff King [Thu, 2 Feb 2012 08:20:43 +0000 (03:20 -0500)]
grep: cache userdiff_driver in grep_source

Right now, grep only uses the userdiff_driver for one thing:
looking up funcname patterns for "-p" and "-W".  As new uses
for userdiff drivers are added to the grep code, we want to
minimize attribute lookups, which can be expensive.

It might seem at first that this would also optimize multiple
lookups when the funcname pattern for a file is needed
multiple times. However, the compiled funcname pattern is
already cached in struct grep_opt's "priv" member, so
multiple lookups are already suppressed.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: drop grep_buffer's "name" parameter
Jeff King [Thu, 2 Feb 2012 08:20:10 +0000 (03:20 -0500)]
grep: drop grep_buffer's "name" parameter

Before the grep_source interface existed, grep_buffer was
used by two types of callers:

  1. Ones which pulled a file into a buffer, and then wanted
     to supply the file's name for the output (i.e.,
     git grep).

  2. Ones which really just wanted to grep a buffer (i.e.,
     git log --grep).

Callers in set (1) should now be using grep_source. Callers
in set (2) always pass NULL for the "name" parameter of
grep_buffer. We can therefore get rid of this now-useless
parameter.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoconvert git-grep to use grep_source interface
Jeff King [Thu, 2 Feb 2012 08:19:37 +0000 (03:19 -0500)]
convert git-grep to use grep_source interface

The grep_source interface (as opposed to grep_buffer) will
eventually gives us a richer interface for telling the
low-level grep code about our buffers. Eventually this will
lead to things like better binary-file handling. For now, it
lets us drop a lot of now-redundant code.

The conversion is mostly straight-forward. One thing to note
is that the memory ownership rules for "struct grep_source"
are different than the "struct work_item" found here (the
former will copy things like the filename, rather than
taking ownership). Therefore you will also see some slight
tweaking of when filename buffers are released.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: refactor the concept of "grep source" into an object
Jeff King [Thu, 2 Feb 2012 08:19:28 +0000 (03:19 -0500)]
grep: refactor the concept of "grep source" into an object

The main interface to the low-level grep code is
grep_buffer, which takes a pointer to a buffer and a size.
This is convenient and flexible (we use it to grep commit
bodies, files on disk, and blobs by sha1), but it makes it
hard to pass extra information about what we are grepping
(either for correctness, like overriding binary
auto-detection, or for optimizations, like lazily loading
blob contents).

Instead, let's encapsulate the idea of a "grep source",
including the buffer, its size, and where the data is coming
from. This is similar to the diff_filespec structure used by
the diff code (unsurprising, since future patches will
implement some of the same optimizations found there).

The diffstat is slightly scarier than the actual patch
content. Most of the modified lines are simply replacing
access to raw variables with their counterparts that are now
in a "struct grep_source". Most of the added lines were
taken from builtin/grep.c, which partially abstracted the
idea of grep sources (for file vs sha1 sources).

Instead of dropping the now-redundant code, this patch
leaves builtin/grep.c using the traditional grep_buffer
interface (which now wraps the grep_source interface). That
makes it easy to test that there is no change of behavior
(yet).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: move sha1-reading mutex into low-level code
Jeff King [Thu, 2 Feb 2012 08:18:41 +0000 (03:18 -0500)]
grep: move sha1-reading mutex into low-level code

The multi-threaded git-grep code needs to serialize access
to the thread-unsafe read_sha1_file call. It does this with
a mutex that is local to builtin/grep.c.

Let's instead push this down into grep.c, where it can be
used by both builtin/grep.c and grep.c. This will let us
safely teach the low-level grep.c code tricks that involve
reading from the object db.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogrep: make locking flag global
Jeff King [Thu, 2 Feb 2012 08:18:29 +0000 (03:18 -0500)]
grep: make locking flag global

The low-level grep code traditionally didn't care about
threading, as it doesn't do any threading itself and didn't
call out to other non-thread-safe code.  That changed with
0579f91 (grep: enable threading with -p and -W using lazy
attribute lookup, 2011-12-12), which pushed the lookup of
funcname attributes (which is not thread-safe) into the
low-level grep code.

As a result, the low-level code learned about a new global
"grep_attr_mutex" to serialize access to the attribute code.
A multi-threaded caller (e.g., builtin/grep.c) is expected
to initialize the mutex and set "use_threads" in the
grep_opt structure. The low-level code only uses the lock if
use_threads is set.

However, putting the use_threads flag into the grep_opt
struct is not the most logical place. Whether threading is
in use is not something that matters for each call to
grep_buffer, but is instead global to the whole program
(i.e., if any thread is doing multi-threaded grep, every
other thread, even if it thinks it is doing its own
single-threaded grep, would need to use the locking).  In
practice, this distinction isn't a problem for us, because
the only user of multi-threaded grep is "git-grep", which
does nothing except call grep.

This patch turns the opt->use_threads flag into a global
flag. More important than the nit-picking semantic argument
above is that this means that the locking functions don't
need to actually have access to a grep_opt to know whether
to lock. Which in turn can make adding new locks simpler, as
we don't need to pass around a grep_opt.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoi18n: format_tracking_info "Your branch is behind" message
Jiang Xin [Thu, 2 Feb 2012 02:02:23 +0000 (10:02 +0800)]
i18n: format_tracking_info "Your branch is behind" message

Function format_tracking_info in remote.c is called by
wt_status_print_tracking in wt-status.c, which will print
branch tracking message in git-status. git-checkout also
show these messages through it's report_tracking function.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoi18n: git-commit whence_s "merge/cherry-pick" message
Jiang Xin [Wed, 1 Feb 2012 17:20:30 +0000 (01:20 +0800)]
i18n: git-commit whence_s "merge/cherry-pick" message

Mark the "merge/cherry-pick" messages in whence_s for translation.
These messages returned from whence_s function are used as argument
to build other messages.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agofind_pack_entry(): do not keep packed_git pointer locally
Nguyễn Thái Ngọc Duy [Wed, 1 Feb 2012 13:48:55 +0000 (20:48 +0700)]
find_pack_entry(): do not keep packed_git pointer locally

Commit f7c22cc (always start looking up objects in the last used pack
first - 2007-05-30) introduce a static packed_git* pointer as an
optimization.  The kept pointer however may become invalid if
free_pack_by_name() happens to free that particular pack.

Current code base does not access packs after calling
free_pack_by_name() so it should not be a problem. Anyway, move the
pointer out so that free_pack_by_name() can reset it to avoid running
into troubles in future.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agosha1_file.c: move the core logic of find_pack_entry() into fill_pack_entry()
Nguyễn Thái Ngọc Duy [Wed, 1 Feb 2012 13:48:54 +0000 (20:48 +0700)]
sha1_file.c: move the core logic of find_pack_entry() into fill_pack_entry()

The new helper function implements the logic to find the offset for the
object in one pack and fill a pack_entry structure. The next patch will
restructure the loop and will call the helper from two places.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Acked-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agorequest-pull: explicitly ask tags/$name to be pulled
Junio C Hamano [Wed, 1 Feb 2012 05:06:06 +0000 (21:06 -0800)]
request-pull: explicitly ask tags/$name to be pulled

When asking for a tag to be pulled, disambiguate by leaving tags/ prefix
in front of the name of the tag. E.g.

    ... in the git repository at:

      git://example.com/git/git.git/ tags/v1.2.3

    for you to fetch changes up to 123456...

This way, older versions of "git pull" can be used to respond to such a
request more easily, as "git pull $URL v1.2.3" did not DWIM to fetch
v1.2.3 tag in older versions. Also this makes it clearer for humans that
the pull request is made for a tag and he should anticipate a signed one.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agomerge: add instructions to the commit message when editing
Thomas Rast [Mon, 30 Jan 2012 20:25:30 +0000 (21:25 +0100)]
merge: add instructions to the commit message when editing

Before f824628 (merge: use editor by default in interactive sessions,
2012-01-10), git-merge only started an editor if the user explicitly
asked for it with --edit.  Thus it seemed unlikely that the user would
need extra guidance.

After f824628 the _normal_ thing is to start an editor.  Give at least
an indication of why we are doing it.

The sentence about justification is one of the few things about
standard git that are not agnostic to the workflow that the user
chose.  However, f824628 was proposed by Linus specifically to
discourage users from merging unrelated upstream progress into topic
branches.  So we may as well take another step in the same direction.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agocompletion: --edit-description option for git-branch
Ralf Thielow [Sun, 29 Jan 2012 12:55:33 +0000 (13:55 +0100)]
completion: --edit-description option for git-branch

Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoGit 1.7.9 v1.7.9
Junio C Hamano [Fri, 27 Jan 2012 19:31:02 +0000 (11:31 -0800)]
Git 1.7.9

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agoINSTALL: warn about recent Fedora breakage
Junio C Hamano [Fri, 27 Jan 2012 05:48:33 +0000 (21:48 -0800)]
INSTALL: warn about recent Fedora breakage

Recent releases of Redhat/Fedora are reported to ship Perl binary package
with some core modules stripped away (see http://lwn.net/Articles/477234/)
against the upstream Perl5 people's wishes. The Time::HiRes module used by
gitweb one of them.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agogit-completion: workaround zsh COMPREPLY bug
Felipe Contreras [Wed, 25 Jan 2012 01:37:02 +0000 (03:37 +0200)]
git-completion: workaround zsh COMPREPLY bug

zsh adds a backslash (foo\ ) for each item in the COMPREPLY array if IFS
doesn't contain spaces. This issue has been reported[1], but there is no
solution yet.

This wasn't a problem due to another bug[2], which was fixed in zsh
version 4.3.12. After this change, 'git checkout ma<tab>' would resolve
to 'git checkout master\ '.

Aditionally, the introduction of __gitcomp_nl in commit a31e626
(completion: optimize refs completion) in git also made the problem
apparent, as Matthieu Moy reported.

The simplest and most generic solution is to hide all the changes we do
to IFS, so that "foo \nbar " is recognized by zsh as "foo bar". This
works on versions of git before and after the introduction of
__gitcomp_nl (a31e626), and versions of zsh before and after 4.3.12.

Once zsh is fixed, we should conditionally disable this workaround to
have the same benefits as bash users.

[1] http://www.zsh.org/mla/workers/2012/msg00053.html
[2] http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=commitdiff;h=2e25dfb8fd38dbef0a306282ffab1d343ce3ad8d

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agodocs: minor grammar fixes for v1.7.9 release notes
Jeff King [Wed, 25 Jan 2012 22:20:03 +0000 (17:20 -0500)]
docs: minor grammar fixes for v1.7.9 release notes

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agosubmodule add: fix breakage when re-adding a deep submodule
Jens Lehmann [Tue, 24 Jan 2012 21:49:56 +0000 (22:49 +0100)]
submodule add: fix breakage when re-adding a deep submodule

Since recently a submodule with name <name> has its git directory in the
.git/modules/<name> directory of the superproject while the work tree
contains a gitfile pointing there.

When the same submodule is added on a branch where it wasn't present so
far (it is not found in the .gitmodules file), the name is not initialized
from the path as it should. This leads to a wrong path entered in the
gitfile when the .git/modules/<name> directory is found, as this happily
uses the - now empty - name. It then always points only a single directory
up, even if we have a path deeper in the directory hierarchy.

Fix that by initializing the name of the submodule early in module_clone()
if module_name() returned an empty name and add a test to catch that bug.

Reported-by: Jehan Bing <jehan@orb.com>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 years agomergetool: Provide an empty file when needed
David Aguilar [Fri, 20 Jan 2012 07:47:35 +0000 (23:47 -0800)]
mergetool: Provide an empty file when needed

Some merge tools cannot cope when $LOCAL, $BASE, or $REMOTE are missing.
$BASE can be missing when two branches independently add the same
filename.

Provide an empty file to make these tools happy.

When a delete/modify conflict occurs, $LOCAL and $REMOTE can also be
missing. We have special case code to handle such case so this change
may not affect that codepath, but try to be consistent and create an
empty file for them anyway.

Reported-by: Jason Wenger <jcwenger@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>