Commit graph

9320 commits

Author SHA1 Message Date
Junio C Hamano efee5981d3 t0302: "unreadable" test needs POSIXPERM
Noticed and fixed by Eric Sunshine, confirmed by Johannes Sixt.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-25 13:23:21 -07:00
Paul Tan 7e314539d6 t0302: test credential-store support for XDG_CONFIG_HOME
t0302 now tests git-credential-store's support for the XDG user-specific
configuration file $XDG_CONFIG_HOME/git/credentials. Specifically:

* Ensure that the XDG file is strictly opt-in. It should not be created
  by git at all times if it does not exist.

* Conversely, if the XDG file exists, ~/.git-credentials should
  not be created at all times.

* If both the XDG file and ~/.git-credentials exists, then both files
  should be used for credential lookups. However, credentials should
  only be written to ~/.git-credentials.

* Credentials must be erased from both files.

* $XDG_CONFIG_HOME can be a custom directory set by the user as per the
  XDG base directory specification. Test that git-credential-store
  respects that, but defaults to "~/.config/git/credentials" if it does
  not exist or is empty.

Helped-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-24 08:08:10 -07:00
Junio C Hamano 76afe74b10 Merge branch 'js/t1050'
* js/t1050:
  t1050-large: generate large files without dd
2015-01-22 13:46:45 -08:00
Junio C Hamano ee443cf236 Merge branch 'jh/empty-notes'
* jh/empty-notes:
  Fix unclosed here document in t3301.sh
2015-01-22 13:42:37 -08:00
Kacper Kornet 85cb1d0ba8 Fix unclosed here document in t3301.sh
Commit 908a320363 introduced  indentation
to here documents in t3301.sh. However in one place <<-EOF was missing
-, which broke this test when run with mksh-50d. This commit fixes it.

Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
Acked-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-22 12:23:42 -08:00
Junio C Hamano d06ce4a508 Merge branch 'jk/colors'
* jk/colors:
  parse_color: fix return value for numeric color values 0-8
2015-01-20 15:57:22 -08:00
Jeff King 3759d27aca parse_color: fix return value for numeric color values 0-8
When commit 695d95d refactored the color parsing, it missed
a "return 0" when parsing literal numbers 0-8 (which
represent basic ANSI colors), leading us to report these
colors as an error.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-20 15:56:03 -08:00
Johannes Sixt d0a042a186 t1050-large: generate large files without dd
For some unknown reason, the dd on my Windows box segfaults randomly,
but since recently, it does so much more often than it used to, which
makes running the test suite burdensome.

Use printf to write large files instead of dd. To emphasize that three
of the large blobs are exact copies, use cp to allocate them.

The new code makes the files a bit smaller, and they are not sparse
anymore, but the tests do not depend on these properties. We do not want
to use test-genrandom here (which is used to generate large files
elsewhere in t1050), so that the files can be compressed well (which
keeps the run-time short).

The files are now large text files, not binary files. But since they
are larger than core.bigfilethreshold they are diagnosed as binary
by Git. For this reason, the 'git diff' tests that check the output
for "Binary files differ" still pass.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-14 13:08:12 -08:00
Junio C Hamano 401a317aae Merge branch 'rc/for-each-ref-tracking'
* rc/for-each-ref-tracking:
  for-each-ref: always check stat_tracking_info()'s return value
2015-01-14 12:39:02 -08:00
Junio C Hamano 601ca9287d Merge branch 'rh/test-color-avoid-terminfo-in-original-home'
We try to see if "tput" gives a useful result before switching TERM
to dumb and moving HOME to point to our fake location for stability
of the tests, and then use the command when coloring the output
from the tests, but there is no guarantee "tput" works after
switching HOME.

* rh/test-color-avoid-terminfo-in-original-home:
  test-lib.sh: do tests for color support after changing HOME
  test-lib: use 'test ...' instead of '[ ... ]'
2015-01-14 12:36:45 -08:00
Junio C Hamano e1ef7d177c Merge branch 'rh/hide-prompt-in-ignored-directory'
* rh/hide-prompt-in-ignored-directory:
  git-prompt.sh: allow to hide prompt for ignored pwd
  git-prompt.sh: if pc mode, immediately set PS1 to a plain prompt
2015-01-14 12:34:01 -08:00
Junio C Hamano 6d9f0c7c0d Merge branch 'jk/prune-packed-server-info'
Fix recent breakage in Git 2.2 that started creating info/refs and
objects/info/packs files with permission bits tighter than user's
umask.

* jk/prune-packed-server-info:
  update-server-info: create info/* with mode 0666
  t1301: set umask in reflog sharedrepository=group test
2015-01-14 12:30:27 -08:00
Junio C Hamano 7fd92d9ed0 Merge branch 'js/remote-add-with-insteadof'
"git remote add $name $URL" is now allowed when "url.$URL.insteadOf"
is already defined.

* js/remote-add-with-insteadof:
  Add a regression test for 'git remote add <existing> <same-url>'
  git remote: allow adding remotes agreeing with url.<...>.insteadOf
2015-01-14 12:29:47 -08:00
Raphael Kubo da Costa b6160d950c for-each-ref: always check stat_tracking_info()'s return value
The code handling %(upstream:track) and %(upstream:trackshort)
assumed that it always had a valid branch that had been sanitized
earlier in populate_value(), and thus did not check the return value
of the call to stat_tracking_info().

While there is indeed some sanitization code that basically
corresponds to stat_tracking_info() returning 0 (no base branch
set), the function can also return -1 when the base branch did exist
but has since then been deleted.

In this case, num_ours and num_theirs had undefined values and a
call to `git for-each-ref --format="%(upstream:track)"` could print
spurious values such as

  [behind -111794512]
  [ahead 38881640, behind 5103867]

even for repositories with one single commit.

Verify stat_tracking_info()'s return value and do not print anything
if it returns -1. This behavior also matches the documentation ("has
no effect if the ref does not have tracking information associated
with it").

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-12 15:10:46 -08:00
Junio C Hamano d0879b33a6 Merge branch 'mg/add-ignore-errors' into maint
* mg/add-ignore-errors:
  add: ignore only ignored files
2015-01-12 14:02:19 -08:00
Junio C Hamano 9ea21fa89c Merge branch 'jk/approxidate-avoid-y-d-m-over-future-dates' into maint
* jk/approxidate-avoid-y-d-m-over-future-dates:
  approxidate: allow ISO-like dates far in the future
  pass TIME_DATE_NOW to approxidate future-check
2015-01-12 14:01:18 -08:00
Junio C Hamano 417a5b226c Merge branch 'jk/for-each-reflog-ent-reverse' into maint
* jk/for-each-reflog-ent-reverse:
  for_each_reflog_ent_reverse: turn leftover check into assertion
  for_each_reflog_ent_reverse: fix newlines on block boundaries
2015-01-12 12:19:17 -08:00
Junio C Hamano c00e1c59d8 Merge branch 'es/checkout-index-temp'
"git checkout-index --temp=$target $path" did not work correctly
for paths outside the current subdirectory in the project.

* es/checkout-index-temp:
  checkout-index: fix --temp relative path mangling
  t2004: demonstrate broken relative path printing
  t2004: standardize file naming in symlink test
  t2004: drop unnecessary write-tree/read-tree
  t2004: modernize style
2015-01-12 11:38:28 -08:00
Junio C Hamano 42618bc34e Merge branch 'cc/bisect-rev-parsing'
The logic in "git bisect bad HEAD" etc. to avoid forcing the test
of the common ancestor of bad and good commits was broken.

* cc/bisect-rev-parsing:
  bisect: add test to check that revs are properly parsed
  bisect: parse revs before passing them to check_expected_revs()
2015-01-12 11:38:19 -08:00
Junio C Hamano ee6e4c70f1 Merge branch 'maint'
* maint:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:28:29 -08:00
Junio C Hamano 7ba46269a0 Merge branch 'maint-2.1' into maint
* maint-2.1:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:28:10 -08:00
Junio C Hamano 3c84ac86fc Merge branch 'maint-2.0' into maint-2.1
* maint-2.0:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:27:56 -08:00
Junio C Hamano 282616c72d Merge branch 'maint-1.9' into maint-2.0
* maint-1.9:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:27:19 -08:00
Junio C Hamano 64a03e970a Merge branch 'maint-1.8.5' into maint-1.9
* maint-1.8.5:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:27:13 -08:00
Junio C Hamano 3d8a54eb37 Merge branch 'jk/dotgit-case-maint-1.8.5' into maint-1.8.5
* jk/dotgit-case-maint-1.8.5:
  is_hfs_dotgit: loosen over-eager match of \u{..47}
2015-01-07 13:26:35 -08:00
Junio C Hamano 40d2f38635 Merge branch 'bw/maint-0090-awk-tweak'
* bw/maint-0090-awk-tweak:
  t0090: tweak awk statement for Solaris /usr/xpg4/bin/awk
2015-01-07 13:10:44 -08:00
Junio C Hamano 3d2c1bf2d4 Merge branch 'sb/t5400-remove-unused'
* sb/t5400-remove-unused:
  t5400: remove dead code
2015-01-07 13:08:27 -08:00
Junio C Hamano 5095fa61e3 Merge branch 'lh/send-email-hide-x-mailer'
"git send-email" normally identifies itself via X-Mailer: header
in the message it sends out.  A new command line flag allows the
user to squelch the header.

* lh/send-email-hide-x-mailer:
  test/send-email: --[no-]xmailer tests
  send-email: add --[no-]xmailer option
2015-01-07 13:07:27 -08:00
Junio C Hamano 948e81408d Merge branch 'rd/send-email-2047-fix'
"git send-email" did not handle RFC 2047 encoded headers quite
right.

* rd/send-email-2047-fix:
  send-email: handle adjacent RFC 2047-encoded words properly
  send-email: align RFC 2047 decoding more closely with the spec
2015-01-07 13:06:47 -08:00
Junio C Hamano 04950c7141 Merge branch 'jk/approxidate-avoid-y-d-m-over-future-dates'
Traditionally we tried to avoid interpreting date strings given by
the user as future dates, e.g. GIT_COMMITTER_DATE=2014-12-10 when
used early November 2014 was taken as "October 12, 2014" because it
is likely that a date in the future, December 10, is a mistake.

Loosen this and do not tiebreak by future-ness of the date when

(1) ISO-like format is used, and
(2) the string can make sense interpreted as both y-m-d and y-d-m.

* jk/approxidate-avoid-y-d-m-over-future-dates:
  approxidate: allow ISO-like dates far in the future
  pass TIME_DATE_NOW to approxidate future-check
2015-01-07 13:01:16 -08:00
Junio C Hamano bb86a40e06 Merge branch 'nd/lockfile-absolute'
The lockfile API can get confused which file to clean up when the
process moved the $cwd after creating a lockfile.

* nd/lockfile-absolute:
  lockfile.c: store absolute path
2015-01-07 12:56:01 -08:00
Junio C Hamano 58e0362edd Merge branch 'jc/strbuf-add-lines-avoid-sp-ht-sequence'
The commented output used to blindly add a SP before the payload
line, resulting in "# \t<indented text>\n" when the payload began
with a HT.  Instead, produce "#\t<indented text>\n".

* jc/strbuf-add-lines-avoid-sp-ht-sequence:
  strbuf_add_commented_lines(): avoid SP-HT sequence in commented lines
2015-01-07 12:49:19 -08:00
Junio C Hamano f41157e649 Merge branch 'jc/diff-b-m'
Fix long-standing bug in "diff -B -M" output.

* jc/diff-b-m:
  diff -B -M: fix output for "copy and then rewrite" case
2015-01-07 12:44:42 -08:00
Junio C Hamano d35c802793 Merge branch 'jc/clone-borrow'
Allow "git clone --reference" to be used more safely.

* jc/clone-borrow:
  clone: --dissociate option to mark that reference is only temporary
2015-01-07 12:42:13 -08:00
Junio C Hamano da178ac793 Merge branch 'jc/checkout-local-track-report'
The report from "git checkout" on a branch that builds on another
local branch by setting its branch.*.merge to branch name (not a
full refname) incorrectly said that the upstream is gone.

* jc/checkout-local-track-report:
  checkout: report upstream correctly even with loosely defined branch.*.merge
2015-01-07 12:41:00 -08:00
Richard Hansen 102fc80d32 test-lib.sh: do tests for color support after changing HOME
If ncurses needs ~/.terminfo for the current $TERM, then tput will
succeed before changing HOME to $TRASH_DIRECTORY but fail afterward.
Move the tests that determine whether there is color support after
changing HOME so that color=t is set if and only if tput would succeed
when say_color() is run.

Note that color=t is now set after --no-color is processed, so the
condition to set color=t has changed:  it is now set only if
color has not already been set to the empty string by --no-color.

This disables color support for those that need ~/.terminfo for
their TERM, but it's better than filling the screen with:

    tput: unknown terminal "custom-terminal-name-here"

An alternative would be to symlink or copy the user's terminfo
database into $TRASH_DIRECTORY, but this is tricky due to the lack of
a standard name for the terminfo database (for example, instead of a
~/.terminfo directory, NetBSD uses a ~/.terminfo.cdb database file).

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07 10:38:01 -08:00
Richard Hansen 46f32a99b8 test-lib: use 'test ...' instead of '[ ... ]'
(see Documentation/CodingGuidelines)

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07 10:36:42 -08:00
Jess Austin 0120b8c85c git-prompt.sh: allow to hide prompt for ignored pwd
Optionally set __git_ps1 to display nothing when present working
directory is ignored, triggered by the new environment variable
GIT_PS1_HIDE_IF_PWD_IGNORED. This environment variable may be
overridden on any repository by setting bash.hideIfPwdIgnored to
"false". In the absence of GIT_PS1_HIDE_IF_PWD_IGNORED this change
has no effect.

Many people manage e.g. dotfiles in their home directory with git.
This causes the prompt generated by __git_ps1 to refer to that "top
level" repo while working in any descendant directory. That can be
distracting, so this patch helps one shut off that noise.

Signed-off-by: Jess Austin <jess.austin@gmail.com>
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Reviewed-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07 10:30:30 -08:00
Jeff King d91175b212 update-server-info: create info/* with mode 0666
Prior to d38379e (make update-server-info more robust, 2014-09-13),
we used a straight "fopen" to create the info/refs and
objects/info/packs files, which creates the file using mode 0666
(less the default umask).

In d38379e, we switched to creating the file with mkstemp to get a
unique filename. But mkstemp also uses the more restrictive 0600
mode to create the file. This was an unintended side effect that we
did not want, and causes problems when the repository is served by a
different user than the one running update-server-info (it is not
readable by a dumb http server running as `www`, for example).

We can fix this by using git_mkstemp_mode and specifying 0666 to
make sure that the umask is honored.

Note that we could also say "just use core.sharedrepository", as we
do call adjust_shared_perm on the result before renaming it into
place.  But that should not be necessary as long as everybody
involved is using permissive umask to allow HTTP server to read
necessary files.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-06 13:46:52 -08:00
Jeff King d05c77cca2 t1301: set umask in reflog sharedrepository=group test
The t1301 script sets the umask globally before many of the
tests. Most of the tests that care about the umask then set
it explicitly at the start of the test. However, one test
does not, and relies on the 077 umask setting from earlier
tests. This is fragile and can break if another test is
added in between. Let's be more explicit.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-06 11:20:45 -08:00
Jeff King 6aaf956b08 is_hfs_dotgit: loosen over-eager match of \u{..47}
Our is_hfs_dotgit function relies on the hackily-implemented
next_hfs_char to give us the next character that an HFS+
filename comparison would look at. It's hacky because it
doesn't implement the full case-folding table of HFS+; it
gives us just enough to see if the path matches ".git".

At the end of next_hfs_char, we use tolower() to convert our
32-bit code point to lowercase. Our tolower() implementation
only takes an 8-bit char, though; it throws away the upper
24 bits. This means we can't have any false negatives for
is_hfs_dotgit. We only care about matching 7-bit ASCII
characters in ".git", and we will correctly process 'G' or
'g'.

However, we _can_ have false positives. Because we throw
away the upper bits, code point \u{0147} (for example) will
look like 'G' and get downcased to 'g'. It's not known
whether a sequence of code points whose truncation ends up
as ".git" is meaningful in any language, but it does not
hurt to be more accurate here. We can just pass out the full
32-bit code point, and compare it manually to the upper and
lowercase characters we care about.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 12:06:27 -08:00
Christian Couder 07913d5ae1 bisect: add test to check that revs are properly parsed
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 11:34:05 -08:00
Eric Sunshine 74c4de5832 checkout-index: fix --temp relative path mangling
checkout-index --temp only properly prints relative paths which are
descendants of the current directory. Paths in ancestor or sibling
directories (or their children) are often printed in mangled form. For
example:

    mkdir a bbb &&
    >file &&
    >bbb/file &&
    git update-index --add file bbb/file &&
    cd a &&
    git checkout-index --temp ../file ../bbb/file

prints:

    .merge_file_ooblek  le
    .merge_file_igloo0  b/file

rather than the correct:

    .merge_file_ooblek  ../file
    .merge_file_igloo0  ../bbb/file

Internally, given the above example, checkout-index prefixes each input
argument with the name of the current directory ("a/", in this case),
and then assumes that it can simply skip forward by strlen("a/") bytes
to recover the original name. This works for files in the current
directory or its descendants, but fails for files in ancestors or
siblings (or their children) due to path normalization.

For instance, given "../file", "a/" is prepended, giving "a/../file".
Path normalization folds out "a/../", resulting in "file". Attempting
to recover the original name by skipping strlen("a/") bytes gives the
incorrect "le" rather than the desired "../file".

Fix this by taking advantage of write_name_quoted_relative() to recover
the original name properly, rather than assuming that it can be
recovered by skipping strlen(prefix) bytes.

As a bonus, this also fixes a bug in which checkout-index --temp
accessed and printed memory beyond the end-of-string. For instance,
within a subdirectory named "subdirectory", and given argument
"../file", prefixing would give "subdirectory/../file", which would
become "file" after normalization. checkout-index would then attempt to
recover the original name by skipping strlen("subdirectory/") bytes of
"file", which placed it well beyond end-of-string. Despite this error,
it often appeared to give the correct result, but only due to an
accident of implementation which left an apparently correct copy of the
path in memory following the normalized value. In particular, handed
"subdirectory/../file", in-place processing by normalize_path_copy_len()
resulted in "file\0rectory/../file". When checkout-index skipped
strlen("subdirectory/") bytes, it ended up back at "../file" and thus
appeared to give the correct answer, despite being past end-of-string.

Reported-by: Russ Cox <rsc@golang.org>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 10:58:45 -08:00
Eric Sunshine 052b2551ad t2004: demonstrate broken relative path printing
checkout-index --temp only properly prints relative paths which are
descendants of the current directory. Paths in ancestor or sibling
directories (or their children) are often printed in mangled form. For
example:

    mkdir a bbb &&
    >file &&
    >bbb/file &&
    git update-index --add file bbb/file &&
    cd a &&
    git checkout-index --temp ../file ../bbb/file

prints:

    .merge_file_ooblek  le
    .merge_file_igloo0  b/file

rather than the correct:

    .merge_file_ooblek  ../file
    .merge_file_igloo0  ../bbb/file

Unfortunately, testing is complicated slightly by relative paths
sometimes _appearing_ to be printed correctly, but this is an accident
of implementation in which a "correct" copy of the string exists in
memory beyond the end of the real string, and that "correct" copy gets
printed. This test takes care to avoid the accidentally "correct"
behavior by testing with a filename longer than the directory name in
which checkout-index is invoked.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 10:56:14 -08:00
Eric Sunshine 66e28e93bb t2004: standardize file naming in symlink test
Update "symlink" test to use the common file naming scheme so that its
temporary files can be cleaned up by the "rm -f path*" idiom employed by
other tests in this script.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 10:54:42 -08:00
Eric Sunshine 0bbc971ab5 t2004: drop unnecessary write-tree/read-tree
Unlike earlier tests which reference several trees prepared by "setup",
no other tests utilize the tree from the "symlink" test, so there is no
need to write it (or read it back immediately).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 10:54:20 -08:00
Eric Sunshine 9fb7b57f82 t2004: modernize style
In particular:

* indent test body
* place test description on same line as test_expect_*
* place closing quote on its own line
* name output file "actual" rather than "out"
* name setup test "setup" rather than "preparation"

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-29 10:52:43 -08:00
Junio C Hamano c5b9256360 Merge branch 'for-junio' of git://bogomips.org/git-svn
* 'for-junio' of git://bogomips.org/git-svn:
  git-svn: support for git-svn propset
2014-12-29 10:15:22 -08:00
Junio C Hamano 4395b21424 Merge branch 'jc/t9001-modernise'
* jc/t9001-modernise:
  t9001: style modernisation phase #5
  t9001: style modernisation phase #4
  t9001: style modernisation phase #3
  t9001: style modernisation phase #2
  t9001: style modernisation phase #1
2014-12-29 09:32:07 -08:00
Junio C Hamano cb71e73ade Merge branch 'mh/update-ref-verify'
"git update-ref --stdin"'s verify command did not work well when
<oldvalue>, which is documented as optional, was missing.

* mh/update-ref-verify:
  update-ref: fix "verify" command with missing <oldvalue>
  t1400: add some more tests of "update-ref --stdin"'s verify command
2014-12-29 09:30:56 -08:00