difftool: parse options using Getopt::Long

Replace custom option/argument parser with standard Getopt::Long
module.  This shortens the code and makes it easier to understand.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: add '--no-gui' option

This commit teaches difftool to handle the '--no-gui' option. This option
negates the existing '--gui' option. The last setting given on the command
line wins.

This allows a user to configure "[alias] mdt = difftool --gui", but still
have the ability to override the setting without error:

$ git mdt --no-gui

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: exit(0) when usage is printed

Prior to this commit, the script exited with an error whenever the
usage string was printed, regardless of the reason it was done. In
cases where usage was printed due to a user request (e.g. '-h'
option), the script should exit without error (exit 0).

This commit adds an argument to the usage function that allows the
exit code to be specified when the function is called.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: remove explicit change of PATH

Adding the script directory to PATH is not needed. The script is
located at '$(git --exec-path)', which is already on the PATH.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: stop appending '.exe' to git

The system call to Git works the same whether or not ".exe" is
appended to "git". The extra code is not necessary.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: eliminate setup_environment function

Removing this function shortens the code and makes it easier to read.
Now all environment variables are set as part of procedural operation.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
l10n: Updated pt_PT language
l10n: New da.po file with 0 translations
l10n: Add Danish team (da) to list of teams
difftool: teach difftool to handle directory diffs

When 'difftool' is called to compare a range of commits that modify
more than one file, it opens a separate instance of the diff tool for
each file that changed.

The new '--dir-diff' option copies all the modified files to a temporary
location and runs a directory diff on them in a single instance of the
diff tool.

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
difftool: print list of valid tools with '--tool-help'

Since bc7a96a (mergetool--lib: Refactor tools into separate files,
2011-08-18), it is possible to add a new diff tool by creating a simple
script in the '$(git --exec-path)/mergetools' directory.  Updating the
difftool help text is still a manual process, and the documentation can
easily go out of sync.

This commit teaches difftool the '--tool-help' option, which:
  - Reads the list of valid tools from 'mergetools/*'
  - Determines which of them are actually installed
  - Determines which are capable of diffing (i.e. not just a merge tool)
  - Prints the resulting list for the user

Signed-off-by: Tim Henigan <tim.henigan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
l10n: Add the German translation team and initialize de.po

Signed-off-by: Ralf Thielow <ralf.thielow@googlemail.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Merge master branch for tracking l10n updates of next release

Use master branch to track l10n updates for git next release, while
use maint branch to track l10n updates for git stable version.
l10n: Update git.pot (33 new, 24 deleted messages)

Changes of po/git.pot from v1.7.10 to v1.7.10-382-g62bc8

 * 33 new l10n messages at lines:
   401, 406, 411, 416, 1602, 1780, 2753, 2766, 2774, 2782, 3403, 3408,
   3423, 3428, 3433, 3438, 3443, 3448, 3453, 3458, 3463, 3468, 3473,
   3480, 3485, 3490, 3495, 3500, 3505, 3510, 3515, 3520, 3525

 * 24 deleted l10n messages at lines:
   2740, 3351, 3356, 3371, 3376, 3381, 3386, 3391, 3396, 3401, 3406,
   3411, 3416, 3421, 3428, 3433, 3438, 3443, 3448, 3453, 3458, 3463,
   3468, 3473

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Merge maint branch for tracking l10n updates of git stable version

Use master branch to track l10n updates for git next release, while
use maint branch to track l10n updates for git stable version.
l10n: Update git.pot (2 new messages)

Changes of po/git.pot from v1.7.10 to v1.7.10-55-g868d6

 * 2 new l10n messages at lines: 1583, 2730

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
l10n: Update Simplified Chinese translation

Translate 2 new messages come from git maint branch.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Merge branch 'maint'

By Jiang Xin
* maint:
  l10n: Update Simplified Chinese translation
  l10n: Update git.pot (2 new messages)
l10n: Update Simplified Chinese translation

Translate new messages for git master branch.

 - sha1_name.c: 4 new messages.
 - builtin/push.c: 3 new messages.
 - git-submodule.sh: variable name changed from '$path' to '$sm_path'.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
diff --stat: use less columns for change counts

Number of columns required for change counts is now computed based on
the maximum number of changed lines instead of being fixed. This means
that usually a few more columns will be available for the filenames
and the graph.

The graph width logic is also modified to include enough space for
"Bin XXX -> YYY bytes".

If changes to binary files are mixed with changes to text files,
change counts are padded to take at least three columns. And the other
way around, if change counts require more than three columns, then
"Bin"s are padded to align with the change count. This way, the +-
part starts in the same column as "XXX -> YYY" part for binary files.
This makes the graph easier to parse visually thanks to the empty
column. This mimics the layout of diff --stat before this change.

Tests and the tutorial are updated to reflect the new --stat output.
This means either the removal of extra padding and/or the addition of
up to three extra characters to truncated filenames. One test is added
to check the graph alignment when a binary file change and text file
change of more than 999 lines are committed together.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>