diff options
44 files changed, 768 insertions, 431 deletions
diff --git a/Documentation/RelNotes/2.2.2.txt b/Documentation/RelNotes/2.2.2.txt index 29e1a3b324..b19a35d94f 100644 --- a/Documentation/RelNotes/2.2.2.txt +++ b/Documentation/RelNotes/2.2.2.txt @@ -30,4 +30,34 @@ Fixes since v2.2.1 * The build procedure did not bother fixing perl and python scripts when NO_PERL and NO_PYTHON build-time configuration changed. + * The code that reads the reflog from the newer to the older entries + did not handle an entry that crosses a boundary of block it uses to + read them correctly. + + * "git apply" was described in the documentation to take --ignore-date + option, which it does not. + + * 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. + This heuristics has been loosened to allow people to express future + dates (most notably, --until=<date> may want to be far in the + future) and we no longer 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. + + Git may still have to use the heuristics to tiebreak between dd/mm/yy + and mm/dd/yy, though. + + * The code to abbreviate an object name to its short unique prefix + has been optimized when no abbreviation was requested. + + * "git add --ignore-errors ..." did not ignore an error to + give a file that did not exist. + + * Git did not correctly read an overlong refname from a packed refs + file. + Also contains typofixes, documentation updates and trivial code clean-ups. diff --git a/Documentation/RelNotes/2.3.0.txt b/Documentation/RelNotes/2.3.0.txt index 1b1dcbb584..72db8d211f 100644 --- a/Documentation/RelNotes/2.3.0.txt +++ b/Documentation/RelNotes/2.3.0.txt @@ -26,9 +26,19 @@ UI, Workflows & Features * "git am" learned "--message-id" option to copy the message ID of the incoming e-mail to the log message of resulting commit. + * "git clone --reference=<over there>" learned the "--dissociate" + option to go with it; it borrows objects from the reference object + store while cloning only to reduce network traffic and then + dissociates the resulting clone from the reference by performing + local copies of borrowed objects. + * "git send-email" learned "--transfer-encoding" option to force a non-fault Content-Transfer-Encoding header (e.g. base64). + * "git send-email" normally identifies itself via X-Mailer: header in + the message it sends out. A new command line flag --no-xmailer + allows the user to squelch the header. + * "git push" into a repository with a working tree normally refuses to modify the branch that is checked out. The command learned to optionally do an equivalent of "git reset --hard" only when there @@ -53,9 +63,31 @@ UI, Workflows & Features * "diff-highlight" filter (in contrib/) allows its color output to be customized via configuration variables. + * "git imap-send" learned to take "-v" (verbose) and "-q" (quiet) + command line options. + + * "git imap-send" now can be built to use cURL library to talk to + IMAP servers (if the library is recent enough, of course). + This allows you to use authenticate method other than CRAM-MD5, + among other things. + Performance, Internal Implementation, Development Support etc. + * Earlier we made "rev-list --object-edge" more aggressively list the + objects at the edge commits, in order to reduce number of objects + fetched into a shallow repository, but the change affected cases + other than "fetching into a shallow repository" and made it + unusably slow (e.g. fetching into a normal repository should not + have to suffer the overhead from extra processing). Limit it to a + more specific case by introducing --objects-edge-aggressive, a new + option to rev-list. + + * Squelched useless compiler warnings on Mac OS X regarding the + crypto API. + + * The procedure to generate unicode table has been simplified. + * Some filesystems assign filemodes in a strange way, fooling then automatic "filemode trustability" check done during a new repository creation. The initialization codepath has been hardened @@ -64,6 +96,9 @@ Performance, Internal Implementation, Development Support etc. * The codepath in "git remote update --prune" to drop many refs has been optimized. + * The API into get_merge_bases*() family of functions was easy to + misuse, which has been corrected to make it harder to do so. + * Long overdue departure from the assumption that S_IFMT is shared by everybody made in 2005, which was necessary to port to z/OS. @@ -87,10 +122,49 @@ Unless otherwise noted, all the fixes since v2.2 in the maintenance track are contained in this release (see the maintenance releases' notes for details). + * The logic in "git bisect bad HEAD" etc. to avoid forcing the test + of the common ancestor of bad and good commits was broken. + (merge 07913d5 cc/bisect-rev-parsing later to maint). + + * "git checkout-index --temp=$target $path" did not work correctly + for paths outside the current subdirectory in the project. + (merge 74c4de5 es/checkout-index-temp later to maint). + + * 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. + (merge 05e7368 jc/checkout-local-track-report later to maint). + + * With The git-prompt support (in contrib/), using the exit status of + the last command in the prompt, e.g. PS1='$(__git_ps1) $? ', did + not work well, because the helper function stomped on the exit + status. + (merge eb443e3 tf/prompt-preserve-exit-status later to maint). + + * Recent update to "git commit" broke amending an existing commit with bogus author/committer lines without a valid e-mail address. (merge c83a509 jk/commit-date-approxidate later to maint). + * The lockfile API used to get confused which file to clean up when + the process moved the $cwd after creating a lockfile. + (merge fa137f6 nd/lockfile-absolute later to maint). + + * 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. + This heuristics has been loosened to allow people to express future + dates (most notably, --until=<date> may want to be far in the + future) and we no longer 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. + + Git may still have to use the heuristics to tiebreak between dd/mm/yy + and mm/dd/yy, though. + (merge d372395 jk/approxidate-avoid-y-d-m-over-future-dates later to maint). + * Git did not correctly read an overlong refname from a packed refs file. (merge ea41783 jk/read-packed-refs-without-path-max later to maint). @@ -99,6 +173,14 @@ notes for details). option, which it does not. (merge 0cef4e7 rw/apply-does-not-take-ignore-date later to maint). + * "git add -i" did not notice when the interactive command input + stream went away and kept asking the same question. + (merge a8bec7a jk/add-i-read-error later to maint). + + * "git send-email" did not handle RFC 2047 encoded headers quite + right. + (merge ab47e2a rd/send-email-2047-fix later to maint). + * New tag object format validation added in 2.2 showed garbage after a tagname it reported in its error message. (merge a1e920a js/fsck-tag-validation later to maint). @@ -108,6 +190,23 @@ notes for details). read them correctly. (merge 69216bf jk/for-each-reflog-ent-reverse later to maint). + * "git diff -B -M" after making a new copy B out of an existing file + A and then editing A extensively ought to report that B was created + by copying A and A was modified, which is what "git diff -C" + reports, but it instead said A was renamed to B and A was edited + heavily in place. This was not just incoherent but also failed to + apply with "git apply". The report has been corrected to match what + "git diff -C" produces for this case. + (merge 6936b58 jc/diff-b-m later to maint). + + * In files we pre-populate for the user to edit with commented hints, + a line of hint that is indented with a tab used to show as '#' (or + any comment char), ' ' (space), and then the hint text that began + with the tab, which some editors flag as an indentation error (tab + following space). We now omit the space after the comment char in + such a case. + (merge d55aeb7 jc/strbuf-add-lines-avoid-sp-ht-sequence later to maint). + * "git ls-tree" does not support path selection based on negative pathspecs, but did not error out when negative pathspecs are given. (merge f1f6224 nd/ls-tree-pathspec later to maint). diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index e3c942e579..ef0eeb40cd 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -176,8 +176,11 @@ message starts, you can put a "From: " line to name that person. You often want to add additional explanation about the patch, other than the commit message itself. Place such "cover letter" -material between the three dash lines and the diffstat. Git-notes -can also be inserted using the `--notes` option. +material between the three-dash line and the diffstat. For +patches requiring multiple iterations of review and discussion, +an explanation of changes between each iteration can be kept in +Git-notes and inserted automatically following the three-dash +line via `git format-patch --notes`. Do not attach the patch as a MIME attachment, compressed or not. Do not let your e-mail client send quoted-printable. Do not let @@ -255,15 +258,15 @@ pretty simple: if you can certify the below: person who certified (a), (b) or (c) and I have not modified it. - (d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with - this project or the open source license(s) involved. + (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. then you just add a line saying - Signed-off-by: Random J Developer <random@developer.example.org> + Signed-off-by: Random J Developer <random@developer.example.org> This line can be automatically added by Git if you run the git-commit command with the -s option. diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 9631526110..1c74907dd4 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -8,7 +8,7 @@ git-add - Add file contents to the index SYNOPSIS -------- [verse] -'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p] +'git add' [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p] [--edit | -e] [--[no-]all | --[no-]ignore-removal | [--update | -u]] [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--] [<pathspec>...] diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt index d2d8f4792a..c2f76fb1ea 100644 --- a/Documentation/git-pack-objects.txt +++ b/Documentation/git-pack-objects.txt @@ -13,7 +13,7 @@ SYNOPSIS [--no-reuse-delta] [--delta-base-offset] [--non-empty] [--local] [--incremental] [--window=<n>] [--depth=<n>] [--revs [--unpacked | --all]] [--stdout | base-name] - [--keep-true-parents] < object-list + [--shallow] [--keep-true-parents] < object-list DESCRIPTION @@ -190,6 +190,11 @@ required objects and is thus unusable by Git without making it self-contained. Use `git index-pack --fix-thin` (see linkgit:git-index-pack[1]) to restore the self-contained property. +--shallow:: + Optimize a pack that will be provided to a client with a shallow + repository. This option, combined with \--thin, can result in a + smaller pack at the cost of speed. + --delta-base-offset:: A packed archive can express the base object of a delta as either a 20-byte object name or as an offset in the diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index fd7f8b5bc1..5b119220bf 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -46,7 +46,8 @@ SYNOPSIS [ \--extended-regexp | -E ] [ \--fixed-strings | -F ] [ \--date=(local|relative|default|iso|iso-strict|rfc|short) ] - [ [\--objects | \--objects-edge] [ \--unpacked ] ] + [ [ \--objects | \--objects-edge | \--objects-edge-aggressive ] + [ \--unpacked ] ] [ \--pretty | \--header ] [ \--bisect ] [ \--bisect-vars ] diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt index e04849e396..f248a8665e 100644 --- a/Documentation/git-send-email.txt +++ b/Documentation/git-send-email.txt @@ -214,10 +214,15 @@ must be used for each option. Legacy alias for '--smtp-encryption ssl'. --smtp-ssl-cert-path:: - Path to ca-certificates (either a directory or a single file). - Set it to an empty string to disable certificate verification. - Defaults to the value set to the 'sendemail.smtpsslcertpath' - configuration variable, if set, or `/etc/ssl/certs` otherwise. + Path to a store of trusted CA certificates for SMTP SSL/TLS + certificate validation (either a directory that has been processed + by 'c_rehash', or a single file containing one or more PEM format + certificates concatenated together: see verify(1) -CAfile and + -CApath for more information on these). Set it to an empty string + to disable certificate verification. Defaults to the value of the + 'sendemail.smtpsslcertpath' configuration variable, if set, or the + backing SSL library's compiled-in default otherwise (which should + be the best choice on most platforms). --smtp-user=<user>:: Username for SMTP-AUTH. Default is the value of 'sendemail.smtpuser'; diff --git a/Documentation/git.txt b/Documentation/git.txt index 179615195f..9d33431427 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -43,9 +43,10 @@ unreleased) version of Git, that is available from the 'master' branch of the `git.git` repository. Documentation for older releases are available here: -* link:v2.2.1/git.html[documentation for release 2.2.1] +* link:v2.2.2/git.html[documentation for release 2.2.2] * release notes for + link:RelNotes/2.2.2.txt[2.2.2], link:RelNotes/2.2.1.txt[2.2.1], link:RelNotes/2.2.0.txt[2.2]. diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index afccfdc23a..2984f407a9 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -653,10 +653,15 @@ These options are mostly targeted for packing of Git repositories. --objects-edge:: Similar to `--objects`, but also print the IDs of excluded commits prefixed with a ``-'' character. This is used by - linkgit:git-pack-objects[1] to build ``thin'' pack, which records + linkgit:git-pack-objects[1] to build a ``thin'' pack, which records objects in deltified form based on objects contained in these excluded commits to reduce network traffic. +--objects-edge-aggressive:: + Similar to `--objects-edge`, but it tries harder to find excluded + commits at the cost of increased time. This is used instead of + `--objects-edge` to build ``thin'' packs for shallow repositories. + --unpacked:: Only useful with `--objects`; print the object IDs that are not in packs. diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 53dd6b3285..57dc9635aa 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v2.2.0.GIT +DEF_VER=v2.3.0-rc0 LF=' ' diff --git a/builtin/cat-file.c b/builtin/cat-file.c index f8d81291b9..750b5a24b4 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -4,12 +4,8 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" -#include "exec_cmd.h" -#include "tag.h" -#include "tree.h" #include "builtin.h" #include "parse-options.h" -#include "diff.h" #include "userdiff.h" #include "streaming.h" diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 383dccf93e..031780f49e 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -18,7 +18,7 @@ static char topath[4][TEMPORARY_FILENAME_LENGTH + 1]; static struct checkout state; -static void write_tempfile_record(const char *name, int prefix_length) +static void write_tempfile_record(const char *name, const char *prefix) { int i; @@ -35,14 +35,14 @@ static void write_tempfile_record(const char *name, int prefix_length) fputs(topath[checkout_stage], stdout); putchar('\t'); - write_name_quoted(name + prefix_length, stdout, line_termination); + write_name_quoted_relative(name, prefix, stdout, line_termination); for (i = 0; i < 4; i++) { topath[i][0] = 0; } } -static int checkout_file(const char *name, int prefix_length) +static int checkout_file(const char *name, const char *prefix) { int namelen = strlen(name); int pos = cache_name_pos(name, namelen); @@ -71,7 +71,7 @@ static int checkout_file(const char *name, int prefix_length) if (did_checkout) { if (to_tempfile) - write_tempfile_record(name, prefix_length); + write_tempfile_record(name, prefix); return errs > 0 ? -1 : 0; } @@ -106,7 +106,7 @@ static void checkout_all(const char *prefix, int prefix_length) if (last_ce && to_tempfile) { if (ce_namelen(last_ce) != ce_namelen(ce) || memcmp(last_ce->name, ce->name, ce_namelen(ce))) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, prefix); } if (checkout_entry(ce, &state, to_tempfile ? topath[ce_stage(ce)] : NULL) < 0) @@ -114,7 +114,7 @@ static void checkout_all(const char *prefix, int prefix_length) last_ce = ce; } if (last_ce && to_tempfile) - write_tempfile_record(last_ce->name, prefix_length); + write_tempfile_record(last_ce->name, prefix); if (errs) /* we have already done our error reporting. * exit with the same code as die(). @@ -248,7 +248,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) if (read_from_stdin) die("git checkout-index: don't mix '--stdin' and explicit filenames"); p = prefix_path(prefix, prefix_length, arg); - checkout_file(p, prefix_length); + checkout_file(p, prefix); if (p < arg || p > arg + strlen(arg)) free((char *)p); } @@ -268,7 +268,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) strbuf_swap(&buf, &nbuf); } p = prefix_path(prefix, prefix_length, buf.buf); - checkout_file(p, prefix_length); + checkout_file(p, prefix); if (p < buf.buf || p > buf.buf + buf.len) free((char *)p); } diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 8a66c74e0f..25aa2cdef3 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -66,10 +66,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) continue; } - if (!memcmp(arg, "-S", 2)) { - sign_commit = arg + 2; + if (skip_prefix(arg, "-S", &sign_commit)) continue; - } if (!strcmp(arg, "--no-gpg-sign")) { sign_commit = NULL; diff --git a/builtin/log.c b/builtin/log.c index f2a9f0156d..923ffe72ce 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -38,8 +38,8 @@ static const char *fmt_patch_subject_prefix = "PATCH"; static const char *fmt_pretty; static const char * const builtin_log_usage[] = { - N_("git log [<options>] [<revision range>] [[--] <path>...]\n") - N_(" or: git show [options] <object>..."), + N_("git log [<options>] [<revision range>] [[--] <path>...]"), + N_("git show [options] <object>..."), NULL }; diff --git a/builtin/merge.c b/builtin/merge.c index 9effed7ff1..c638fd5a9a 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -894,6 +894,7 @@ static int suggest_conflicts(void) append_conflicts_hint(&msgbuf); fputs(msgbuf.buf, fp); + strbuf_release(&msgbuf); fclose(fp); rerere(allow_rerere_auto); printf(_("Automatic merge failed; " diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 3f9f5c7760..d8165878e1 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2613,6 +2613,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) { int use_internal_rev_list = 0; int thin = 0; + int shallow = 0; int all_progress_implied = 0; struct argv_array rp = ARGV_ARRAY_INIT; int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0; @@ -2677,6 +2678,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) PARSE_OPT_OPTARG, option_parse_unpack_unreachable }, OPT_BOOL(0, "thin", &thin, N_("create thin packs")), + OPT_BOOL(0, "shallow", &shallow, + N_("create packs suitable for shallow fetches")), OPT_BOOL(0, "honor-pack-keep", &ignore_packed_keep, N_("ignore packs that have companion .keep file")), OPT_INTEGER(0, "compression", &pack_compression_level, @@ -2711,7 +2714,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) argv_array_push(&rp, "pack-objects"); if (thin) { use_internal_rev_list = 1; - argv_array_push(&rp, "--objects-edge"); + argv_array_push(&rp, shallow + ? "--objects-edge-aggressive" + : "--objects-edge"); } else argv_array_push(&rp, "--objects"); diff --git a/builtin/remote.c b/builtin/remote.c index 46ecfd9f7b..b4ff468977 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -180,7 +180,9 @@ static int add(int argc, const char **argv) url = argv[1]; remote = remote_get(name); - if (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) || + if (remote && (remote->url_nr > 1 || + (strcmp(name, remote->url[0]) && + strcmp(url, remote->url[0])) || remote->fetch_refspec_nr)) die(_("remote %s already exists."), name); diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 270e39c6c1..691eeda345 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -6,7 +6,10 @@ #include "parse-options.h" static const char* show_branch_usage[] = { - N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"), + N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order]\n" + " [--current] [--color[=<when>] | --no-color] [--sparse]\n" + " [--more=<n> | --list | --independent | --merge-base]\n" + " [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"), N_("git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]"), NULL }; diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cd765795ae..8cfee95f88 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1693,6 +1693,7 @@ _git_rebase () --committer-date-is-author-date --ignore-date --ignore-whitespace --whitespace= --autosquash --fork-point --no-fork-point + --autostash " return diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index 729f769479..214e859f99 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -84,6 +84,11 @@ # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on # the colored output of "git status -sb" and are available only when # using __git_ps1 for PROMPT_COMMAND or precmd. +# +# If you would like __git_ps1 to do nothing in the case when the current +# directory is set up to be ignored by git, then set +# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the +# repository level by setting bash.hideIfPwdIgnored to "false". # check whether printf supports -v __git_printf_supports_v= @@ -288,6 +293,8 @@ __git_eread () # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true __git_ps1 () { + # preserve exit status + local exit=$? local pcmode=no local detached=no local ps1pc_start='\u@\h:\w ' @@ -299,10 +306,14 @@ __git_ps1 () ps1pc_start="$1" ps1pc_end="$2" printf_format="${3:-$printf_format}" + # set PS1 to a plain prompt so that we can + # simply return early if the prompt should not + # be decorated + PS1="$ps1pc_start$ps1pc_end" ;; 0|1) printf_format="${1:-$printf_format}" ;; - *) return + *) return $exit ;; esac @@ -350,11 +361,7 @@ __git_ps1 () rev_parse_exit_code="$?" if [ -z "$repo_info" ]; then - if [ $pcmode = yes ]; then - #In PC mode PS1 always needs to be set - PS1="$ps1pc_start$ps1pc_end" - fi - return + return $exit fi local short_sha @@ -369,6 +376,14 @@ __git_ps1 () local inside_gitdir="${repo_info##*$'\n'}" local g="${repo_info%$'\n'*}" + if [ "true" = "$inside_worktree" ] && + [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && + [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && + git check-ignore -q . + then + return $exit + fi + local r="" local b="" local step="" @@ -412,10 +427,7 @@ __git_ps1 () else local head="" if ! __git_eread "$g/HEAD" head; then - if [ $pcmode = yes ]; then - PS1="$ps1pc_start$ps1pc_end" - fi - return + return $exit fi # is it a symbolic ref? b="${head#ref: }" @@ -511,4 +523,6 @@ __git_ps1 () else printf -- "$printf_format" "$gitstring" fi + + return $exit } diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt index 8272100ff5..54e4b4a243 100644 --- a/contrib/subtree/git-subtree.txt +++ b/contrib/subtree/git-subtree.txt @@ -81,12 +81,11 @@ merge:: changes into the latest <commit>. With '--squash', creates only one commit that contains all the changes, rather than merging in the entire history. - - If you use '--squash', the merge direction doesn't - always have to be forward; you can use this command to - go back in time from v2.5 to v2.4, for example. If your - merge introduces a conflict, you can resolve it in the - usual ways. ++ +If you use '--squash', the merge direction doesn't always have to be +forward; you can use this command to go back in time from v2.5 to v2.4, +for example. If your merge introduces a conflict, you can resolve it in +the usual ways. pull:: Exactly like 'merge', but parallels 'git pull' in that @@ -107,21 +106,19 @@ split:: contents of <prefix> at the root of the project instead of in a subdirectory. Thus, the newly created history is suitable for export as a separate git repository. - - After splitting successfully, a single commit id is - printed to stdout. This corresponds to the HEAD of the - newly created tree, which you can manipulate however you - want. - - Repeated splits of exactly the same history are - guaranteed to be identical (i.e. to produce the same - commit ids). Because of this, if you add new commits - and then re-split, the new commits will be attached as - commits on top of the history you generated last time, - so 'git merge' and friends will work as expected. - - Note that if you use '--squash' when you merge, you - should usually not just '--rejoin' when you split. ++ +After splitting successfully, a single commit id is printed to stdout. +This corresponds to the HEAD of the newly created tree, which you can +manipulate however you want. ++ +Repeated splits of exactly the same history are guaranteed to be +identical (i.e. to produce the same commit ids). Because of this, if +you add new commits and then re-split, the new commits will be attached +as commits on top of the history you generated last time, so 'git merge' +and friends will work as expected. ++ +Note that if you use '--squash' when you merge, you should usually not +just '--rejoin' when you split. OPTIONS @@ -151,109 +148,96 @@ OPTIONS FOR add, merge, push, pull --squash:: This option is only valid for add, merge, push and pull commands. - - Instead of merging the entire history from the subtree - project, produce only a single commit that contains all - the differences you want to merge, and then merge that - new commit into your project. - - Using this option helps to reduce log clutter. People - rarely want to see every change that happened between - v1.0 and v1.1 of the library they're using, since none of the - interim versions were ever included in their application. - - Using '--squash' also helps avoid problems when the same - subproject is included multiple times in the same - project, or is removed and then re-added. In such a - case, it doesn't make sense to combine the histories - anyway, since it's unclear which part of the history - belongs to which subtree. - - Furthermore, with '--squash', you can switch back and - forth between different versions of a subtree, rather - than strictly forward. 'git subtree merge --squash' - always adjusts the subtree to match the exactly - specified commit, even if getting to that commit would - require undoing some changes that were added earlier. - - Whether or not you use '--squash', changes made in your - local repository remain intact and can be later split - and send upstream to the subproject. ++ +Instead of merging the entire history from the subtree project, produce +only a single commit that contains all the differences you want to +merge, and then merge that new commit into your project. ++ +Using this option helps to reduce log clutter. People rarely want to see +every change that happened between v1.0 and v1.1 of the library they're +using, since none of the interim versions were ever included in their +application. ++ +Using '--squash' also helps avoid problems when the same subproject is +included multiple times in the same project, or is removed and then +re-added. In such a case, it doesn't make sense to combine the +histories anyway, since it's unclear which part of the history belongs +to which subtree. ++ +Furthermore, with '--squash', you can switch back and forth between +different versions of a subtree, rather than strictly forward. 'git +subtree merge --squash' always adjusts the subtree to match the exactly +specified commit, even if getting to that commit would require undoing +some changes that were added earlier. ++ +Whether or not you use '--squash', changes made in your local repository +remain intact and can be later split and send upstream to the +subproject. OPTIONS FOR split ----------------- --annotate=<annotation>:: This option is only valid for the split command. - - When generating synthetic history, add <annotation> as a - prefix to each commit message. Since we're creating new - commits with the same commit message, but possibly - different content, from the original commits, this can help - to differentiate them and avoid confusion. - - Whenever you split, you need to use the same - <annotation>, or else you don't have a guarantee that - the new re-created history will be identical to the old - one. That will prevent merging from working correctly. - git subtree tries to make it work anyway, particularly - if you use --rejoin, but it may not always be effective. ++ +When generating synthetic history, add <annotation> as a prefix to each +commit message. Since we're creating new commits with the same commit +message, but possibly different content, from the original commits, this +can help to differentiate them and avoid confusion. ++ +Whenever you split, you need to use the same <annotation>, or else you +don't have a guarantee that the new re-created history will be identical +to the old one. That will prevent merging from working correctly. git +subtree tries to make it work anyway, particularly if you use --rejoin, +but it may not always be effective. -b <branch>:: --branch=<branch>:: This option is only valid for the split command. - - After generating the synthetic history, create a new - branch called <branch> that contains the new history. - This is suitable for immediate pushing upstream. - <branch> must not already exist. ++ +After generating the synthetic history, create a new branch called +<branch> that contains the new history. This is suitable for immediate +pushing upstream. <branch> must not already exist. --ignore-joins:: This option is only valid for the split command. - - If you use '--rejoin', git subtree attempts to optimize - its history reconstruction to generate only the new - commits since the last '--rejoin'. '--ignore-join' - disables this behaviour, forcing it to regenerate the - entire history. In a large project, this can take a - long time. ++ +If you use '--rejoin', git subtree attempts to optimize its history +reconstruction to generate only the new commits since the last +'--rejoin'. '--ignore-join' disables this behaviour, forcing it to +regenerate the entire history. In a large project, this can take a long +time. --onto=<onto>:: This option is only valid for the split command. - - If your subtree was originally imported using something - other than git subtree, its history may not match what - git subtree is expecting. In that case, you can specify - the commit id <onto> that corresponds to the first - revision of the subproject's history that was imported - into your project, and git subtree will attempt to build - its history from there. - - If you used 'git subtree add', you should never need - this option. ++ +If your subtree was originally imported using something other than git +subtree, its history may not match what git subtree is expecting. In +that case, you can specify the commit id <onto> that corresponds to the +first revision of the subproject's history that was imported into your +project, and git subtree will attempt to build its history from there. ++ +If you used 'git subtree add', you should never need this option. --rejoin:: This option is only valid for the split command. - - After splitting, merge the newly created synthetic - history back into your main project. That way, future - splits can search only the part of history that has - been added since the most recent --rejoin. - - If your split commits end up merged into the upstream - subproject, and then you want to get the latest upstream - version, this will allow git's merge algorithm to more - intelligently avoid conflicts (since it knows these - synthetic commits are already part of the upstream - repository). - - Unfortunately, using this option results in 'git log' - showing an extra copy of every new commit that was - created (the original, and the synthetic one). - - If you do all your merges with '--squash', don't use - '--rejoin' when you split, because you don't want the - subproject's history to be part of your project anyway. ++ +After splitting, merge the newly created synthetic history back into +your main project. That way, future splits can search only the part of +history that has been added since the most recent --rejoin. ++ +If your split commits end up merged into the upstream subproject, and +then you want to get the latest upstream version, this will allow git's +merge algorithm to more intelligently avoid conflicts (since it knows +these synthetic commits are already part of the upstream repository). ++ +Unfortunately, using this option results in 'git log' showing an extra +copy of every new commit that was created (the original, and the +synthetic one). ++ +If you do all your merges with '--squash', don't use '--rejoin' when you +split, because you don't want the subproject's history to be part of +your project anyway. EXAMPLE 1. Add command diff --git a/git-bisect.sh b/git-bisect.sh index 6cda2b5a60..2fc07acb0f 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -237,15 +237,18 @@ bisect_state() { check_expected_revs "$rev" ;; 2,bad|*,good|*,skip) shift - eval='' + hash_list='' for rev in "$@" do sha=$(git rev-parse --verify "$rev^{commit}") || die "$(eval_gettext "Bad rev input: \$rev")" - eval="$eval bisect_write '$state' '$sha'; " + hash_list="$hash_list $sha" done - eval "$eval" - check_expected_revs "$@" ;; + for rev in $hash_list + do + bisect_write "$state" "$rev" + done + check_expected_revs $hash_list ;; *,bad) die "$(gettext "'git bisect bad' can take only one argument.")" ;; *) diff --git a/git-compat-util.h b/git-compat-util.h index 09ccebbd49..eb9b0ff328 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -212,8 +212,12 @@ extern char *gitbasename(char *); #endif #ifndef NO_OPENSSL +#define __AVAILABILITY_MACROS_USES_AVAILABILITY 0 +#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6 #include <openssl/ssl.h> #include <openssl/err.h> +#undef MAC_OS_X_VERSION_MIN_REQUIRED +#undef __AVAILABILITY_MACROS_USES_AVAILABILITY #ifdef NO_HMAC_CTX_CLEANUP #define HMAC_CTX_cleanup HMAC_cleanup #endif @@ -1,10 +1,7 @@ #include "builtin.h" -#include "cache.h" #include "exec_cmd.h" #include "help.h" -#include "quote.h" #include "run-command.h" -#include "commit.h" const char git_usage_string[] = "git [--version] [--help] [-C <path>] [-c name=value]\n" diff --git a/imap-send.c b/imap-send.c index 4dfe4c25d7..d69887da5a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -1421,8 +1421,8 @@ static CURL *setup_curl(struct imap_server_conf *srvc) strbuf_release(&auth); } - if (server.use_ssl) - curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL); + if (!server.use_ssl) + curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_TRY); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, server.ssl_verify); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, server.ssl_verify); @@ -1431,7 +1431,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc) curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - if (0 < verbosity) + if (0 < verbosity || getenv("GIT_CURL_VERBOSE")) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); return curl; diff --git a/list-objects.c b/list-objects.c index 2910becd6c..2a139b6ced 100644 --- a/list-objects.c +++ b/list-objects.c @@ -157,7 +157,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge) if (commit->object.flags & UNINTERESTING) { mark_tree_uninteresting(commit->tree); - if (revs->edge_hint && !(commit->object.flags & SHOWN)) { + if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) { commit->object.flags |= SHOWN; show_edge(commit); } @@ -165,7 +165,7 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge) } mark_edge_parents_uninteresting(commit, revs, show_edge); } - if (revs->edge_hint) { + if (revs->edge_hint_aggressive) { for (i = 0; i < revs->cmdline.nr; i++) { struct object *obj = revs->cmdline.rev[i].item; struct commit *commit = (struct commit *)obj; @@ -2334,7 +2334,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname, struct strbuf err = STRBUF_INIT; unable_to_lock_message(ref_file, errno, &err); error("%s", err.buf); - strbuf_reset(&err); + strbuf_release(&err); goto error_return; } } diff --git a/revision.c b/revision.c index 14e0e0358c..86406a26a2 100644 --- a/revision.c +++ b/revision.c @@ -1853,6 +1853,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->tree_objects = 1; revs->blob_objects = 1; revs->edge_hint = 1; + } else if (!strcmp(arg, "--objects-edge-aggressive")) { + revs->tag_objects = 1; + revs->tree_objects = 1; + revs->blob_objects = 1; + revs->edge_hint = 1; + revs->edge_hint_aggressive = 1; } else if (!strcmp(arg, "--verify-objects")) { revs->tag_objects = 1; revs->tree_objects = 1; diff --git a/revision.h b/revision.h index 9cb5adc4ea..033a24460e 100644 --- a/revision.h +++ b/revision.h @@ -93,6 +93,7 @@ struct rev_info { blob_objects:1, verify_objects:1, edge_hint:1, + edge_hint_aggressive:1, limited:1, unpacked:1, boundary:2, diff --git a/send-pack.c b/send-pack.c index 949cb61aa0..25947d7df9 100644 --- a/send-pack.c +++ b/send-pack.c @@ -47,6 +47,7 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru NULL, NULL, NULL, + NULL, }; struct child_process po = CHILD_PROCESS_INIT; int i; @@ -60,6 +61,8 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru argv[i++] = "-q"; if (args->progress) argv[i++] = "--progress"; + if (is_repository_shallow()) + argv[i++] = "--shallow"; po.argv = argv; po.in = -1; po.out = args->stateless_rpc ? -1 : fd; diff --git a/server-info.c b/server-info.c index 31f4a749fb..34b0253177 100644 --- a/server-info.c +++ b/server-info.c @@ -17,7 +17,7 @@ static int update_info_file(char *path, int (*generate)(FILE *)) FILE *fp = NULL; safe_create_leading_directories(path); - fd = mkstemp(tmp); + fd = git_mkstemp_mode(tmp, 0666); if (fd < 0) goto out; fp = fdopen(fd, "w"); diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index 067f4c6e52..601d02d71f 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -22,7 +22,7 @@ generate_expected_cache_tree_rec () { # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) && - subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 {++c} END {print c}') && + subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && entries=$(git ls-files|wc -l) && printf "SHA $dir (%d entries, %d subtrees)\n" "$entries" "$subtree_count" && for subtree in $subtrees diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index de42d21c92..7eecfb836a 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -111,7 +111,18 @@ do done +test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' ' + rm -f .git/info/refs && + test_unconfig core.sharedrepository && + umask 002 && + git update-server-info && + echo "-rw-rw-r--" >expect && + modebits .git/info/refs >actual && + test_cmp expect actual +' + test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' + umask 077 && git config core.sharedRepository group && git reflog expire --all && actual="$(ls -l .git/logs/refs/heads/master)" && diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 1f04b8aa3f..cfb32b6242 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -349,6 +349,21 @@ dot-backslash-case .\\\\.GIT\\\\foobar dotgit-case-backslash .git\\\\foobar EOF +test_expect_success 'fsck allows .Ňit' ' + ( + git init not-dotgit && + cd not-dotgit && + echo content >file && + git add file && + git commit -m base && + blob=$(git rev-parse :file) && + printf "100644 blob $blob\t.\\305\\207it" >tree && + tree=$(git mktree <tree) && + git fsck 2>err && + test_line_count = 0 err + ) +' + # create a static test repo which is broken by omitting # one particular object ($1, which is looked up via rev-parse # in the new repository). diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh index f171a5578b..a12afe93f3 100755 --- a/t/t2004-checkout-cache-temp.sh +++ b/t/t2004-checkout-cache-temp.sh @@ -10,202 +10,212 @@ rather than the tracked path.' . ./test-lib.sh -test_expect_success \ -'preparation' ' -mkdir asubdir && -echo tree1path0 >path0 && -echo tree1path1 >path1 && -echo tree1path3 >path3 && -echo tree1path4 >path4 && -echo tree1asubdir/path5 >asubdir/path5 && -git update-index --add path0 path1 path3 path4 asubdir/path5 && -t1=$(git write-tree) && -rm -f path* .merge_* out .git/index && -echo tree2path0 >path0 && -echo tree2path1 >path1 && -echo tree2path2 >path2 && -echo tree2path4 >path4 && -git update-index --add path0 path1 path2 path4 && -t2=$(git write-tree) && -rm -f path* .merge_* out .git/index && -echo tree2path0 >path0 && -echo tree3path1 >path1 && -echo tree3path2 >path2 && -echo tree3path3 >path3 && -git update-index --add path0 path1 path2 path3 && -t3=$(git write-tree)' - -test_expect_success \ -'checkout one stage 0 to temporary file' ' -rm -f path* .merge_* out .git/index && -git read-tree $t1 && -git checkout-index --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = tree1path1' - -test_expect_success \ -'checkout all stage 0 to temporary files' ' -rm -f path* .merge_* out .git/index && -git read-tree $t1 && -git checkout-index -a --temp >out && -test_line_count = 5 out && -for f in path0 path1 path3 path4 asubdir/path5 -do - test $(grep $f out | cut "-d " -f2) = $f && - p=$(grep $f out | cut "-d " -f1) && +test_expect_success 'setup' ' + mkdir asubdir && + echo tree1path0 >path0 && + echo tree1path1 >path1 && + echo tree1path3 >path3 && + echo tree1path4 >path4 && + echo tree1asubdir/path5 >asubdir/path5 && + git update-index --add path0 path1 path3 path4 asubdir/path5 && + t1=$(git write-tree) && + rm -f path* .merge_* actual .git/index && + echo tree2path0 >path0 && + echo tree2path1 >path1 && + echo tree2path2 >path2 && + echo tree2path4 >path4 && + git update-index --add path0 path1 path2 path4 && + t2=$(git write-tree) && + rm -f path* .merge_* actual .git/index && + echo tree2path0 >path0 && + echo tree3path1 >path1 && + echo tree3path2 >path2 && + echo tree3path3 >path3 && + git update-index --add path0 path1 path2 path3 && + t3=$(git write-tree) +' + +test_expect_success 'checkout one stage 0 to temporary file' ' + rm -f path* .merge_* actual .git/index && + git read-tree $t1 && + git checkout-index --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + p=$(cut "-d " -f1 actual) && test -f $p && - test $(cat $p) = tree1$f -done' - -test_expect_success \ -'prepare 3-way merge' ' -rm -f path* .merge_* out .git/index && -git read-tree -m $t1 $t2 $t3' - -test_expect_success \ -'checkout one stage 2 to temporary file' ' -rm -f path* .merge_* out && -git checkout-index --stage=2 --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = tree2path1' - -test_expect_success \ -'checkout all stage 2 to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --all --stage=2 --temp >out && -test_line_count = 3 out && -for f in path1 path2 path4 -do - test $(grep $f out | cut "-d " -f2) = $f && - p=$(grep $f out | cut "-d " -f1) && + test $(cat $p) = tree1path1 +' + +test_expect_success 'checkout all stage 0 to temporary files' ' + rm -f path* .merge_* actual .git/index && + git read-tree $t1 && + git checkout-index -a --temp >actual && + test_line_count = 5 actual && + for f in path0 path1 path3 path4 asubdir/path5 + do + test $(grep $f actual | cut "-d " -f2) = $f && + p=$(grep $f actual | cut "-d " -f1) && + test -f $p && + test $(cat $p) = tree1$f + done +' + +test_expect_success 'setup 3-way merge' ' + rm -f path* .merge_* actual .git/index && + git read-tree -m $t1 $t2 $t3 +' + +test_expect_success 'checkout one stage 2 to temporary file' ' + rm -f path* .merge_* actual && + git checkout-index --stage=2 --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + p=$(cut "-d " -f1 actual) && test -f $p && - test $(cat $p) = tree2$f -done' - -test_expect_success \ -'checkout all stages/one file to nothing' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path0 >out && -test_line_count = 0 out' - -test_expect_success \ -'checkout all stages/one file to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path1 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path1 && -cut "-d " -f1 out | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test -f $s3 && -test $(cat $s1) = tree1path1 && -test $(cat $s2) = tree2path1 && -test $(cat $s3) = tree3path1)' - -test_expect_success \ -'checkout some stages/one file to temporary files' ' -rm -f path* .merge_* out && -git checkout-index --stage=all --temp -- path2 >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = path2 && -cut "-d " -f1 out | (read s1 s2 s3 && -test $s1 = . && -test -f $s2 && -test -f $s3 && -test $(cat $s2) = tree2path2 && -test $(cat $s3) = tree3path2)' - -test_expect_success \ -'checkout all stages/all files to temporary files' ' -rm -f path* .merge_* out && -git checkout-index -a --stage=all --temp >out && -test_line_count = 5 out' - -test_expect_success \ -'-- path0: no entry' ' -test x$(grep path0 out | cut "-d " -f2) = x' - -test_expect_success \ -'-- path1: all 3 stages' ' -test $(grep path1 out | cut "-d " -f2) = path1 && -grep path1 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test -f $s3 && -test $(cat $s1) = tree1path1 && -test $(cat $s2) = tree2path1 && -test $(cat $s3) = tree3path1)' - -test_expect_success \ -'-- path2: no stage 1, have stage 2 and 3' ' -test $(grep path2 out | cut "-d " -f2) = path2 && -grep path2 out | cut "-d " -f1 | (read s1 s2 s3 && -test $s1 = . && -test -f $s2 && -test -f $s3 && -test $(cat $s2) = tree2path2 && -test $(cat $s3) = tree3path2)' - -test_expect_success \ -'-- path3: no stage 2, have stage 1 and 3' ' -test $(grep path3 out | cut "-d " -f2) = path3 && -grep path3 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test $s2 = . && -test -f $s3 && -test $(cat $s1) = tree1path3 && -test $(cat $s3) = tree3path3)' - -test_expect_success \ -'-- path4: no stage 3, have stage 1 and 3' ' -test $(grep path4 out | cut "-d " -f2) = path4 && -grep path4 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test -f $s2 && -test $s3 = . && -test $(cat $s1) = tree1path4 && -test $(cat $s2) = tree2path4)' - -test_expect_success \ -'-- asubdir/path5: no stage 2 and 3 have stage 1' ' -test $(grep asubdir/path5 out | cut "-d " -f2) = asubdir/path5 && -grep asubdir/path5 out | cut "-d " -f1 | (read s1 s2 s3 && -test -f $s1 && -test $s2 = . && -test $s3 = . && -test $(cat $s1) = tree1asubdir/path5)' - -test_expect_success \ -'checkout --temp within subdir' ' -(cd asubdir && - git checkout-index -a --stage=all >out && - test_line_count = 1 out && - test $(grep path5 out | cut "-d " -f2) = path5 && - grep path5 out | cut "-d " -f1 | (read s1 s2 s3 && - test -f ../$s1 && - test $s2 = . && - test $s3 = . && - test $(cat ../$s1) = tree1asubdir/path5) -)' - -test_expect_success \ -'checkout --temp symlink' ' -rm -f path* .merge_* out .git/index && -test_ln_s_add b a && -t4=$(git write-tree) && -rm -f .git/index && -git read-tree $t4 && -git checkout-index --temp -a >out && -test_line_count = 1 out && -test $(cut "-d " -f2 out) = a && -p=$(cut "-d " -f1 out) && -test -f $p && -test $(cat $p) = b' + test $(cat $p) = tree2path1 +' + +test_expect_success 'checkout all stage 2 to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --all --stage=2 --temp >actual && + test_line_count = 3 actual && + for f in path1 path2 path4 + do + test $(grep $f actual | cut "-d " -f2) = $f && + p=$(grep $f actual | cut "-d " -f1) && + test -f $p && + test $(cat $p) = tree2$f + done +' + +test_expect_success 'checkout all stages/one file to nothing' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path0 >actual && + test_line_count = 0 actual +' + +test_expect_success 'checkout all stages/one file to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path1 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path1 && + cut "-d " -f1 actual | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test -f $s3 && + test $(cat $s1) = tree1path1 && + test $(cat $s2) = tree2path1 && + test $(cat $s3) = tree3path1) +' + +test_expect_success 'checkout some stages/one file to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index --stage=all --temp -- path2 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path2 && + cut "-d " -f1 actual | (read s1 s2 s3 && + test $s1 = . && + test -f $s2 && + test -f $s3 && + test $(cat $s2) = tree2path2 && + test $(cat $s3) = tree3path2) +' + +test_expect_success 'checkout all stages/all files to temporary files' ' + rm -f path* .merge_* actual && + git checkout-index -a --stage=all --temp >actual && + test_line_count = 5 actual +' + +test_expect_success '-- path0: no entry' ' + test x$(grep path0 actual | cut "-d " -f2) = x +' + +test_expect_success '-- path1: all 3 stages' ' + test $(grep path1 actual | cut "-d " -f2) = path1 && + grep path1 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test -f $s3 && + test $(cat $s1) = tree1path1 && + test $(cat $s2) = tree2path1 && + test $(cat $s3) = tree3path1) +' + +test_expect_success '-- path2: no stage 1, have stage 2 and 3' ' + test $(grep path2 actual | cut "-d " -f2) = path2 && + grep path2 actual | cut "-d " -f1 | (read s1 s2 s3 && + test $s1 = . && + test -f $s2 && + test -f $s3 && + test $(cat $s2) = tree2path2 && + test $(cat $s3) = tree3path2) +' + +test_expect_success '-- path3: no stage 2, have stage 1 and 3' ' + test $(grep path3 actual | cut "-d " -f2) = path3 && + grep path3 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test $s2 = . && + test -f $s3 && + test $(cat $s1) = tree1path3 && + test $(cat $s3) = tree3path3) +' + +test_expect_success '-- path4: no stage 3, have stage 1 and 3' ' + test $(grep path4 actual | cut "-d " -f2) = path4 && + grep path4 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test -f $s2 && + test $s3 = . && + test $(cat $s1) = tree1path4 && + test $(cat $s2) = tree2path4) +' + +test_expect_success '-- asubdir/path5: no stage 2 and 3 have stage 1' ' + test $(grep asubdir/path5 actual | cut "-d " -f2) = asubdir/path5 && + grep asubdir/path5 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f $s1 && + test $s2 = . && + test $s3 = . && + test $(cat $s1) = tree1asubdir/path5) +' + +test_expect_success 'checkout --temp within subdir' ' + ( + cd asubdir && + git checkout-index -a --stage=all >actual && + test_line_count = 1 actual && + test $(grep path5 actual | cut "-d " -f2) = path5 && + grep path5 actual | cut "-d " -f1 | (read s1 s2 s3 && + test -f ../$s1 && + test $s2 = . && + test $s3 = . && + test $(cat ../$s1) = tree1asubdir/path5) + ) +' + +test_expect_success 'checkout --temp symlink' ' + rm -f path* .merge_* actual .git/index && + test_ln_s_add path7 path6 && + git checkout-index --temp -a >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = path6 && + p=$(cut "-d " -f1 actual) && + test -f $p && + test $(cat $p) = path7 +' + +test_expect_success 'emit well-formed relative path' ' + rm -f path* .merge_* actual .git/index && + >path0123456789 && + git update-index --add path0123456789 && + ( + cd asubdir && + git checkout-index --temp -- ../path0123456789 >actual && + test_line_count = 1 actual && + test $(cut "-d " -f2 actual) = ../path0123456789 + ) +' test_done diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index ac79dd915d..17c6330f98 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -1113,4 +1113,9 @@ test_extra_arg set-url origin newurl oldurl # prune takes any number of args # update takes any number of args +test_expect_success 'add remote matching the "insteadOf" URL' ' + git config url.xyz@example.com.insteadOf backup && + git remote add backup xyz@example.com +' + test_done diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 064f5cefeb..e6abe65d5c 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -779,4 +779,13 @@ test_expect_success 'bisect log: only skip commits left' ' git bisect reset ' +test_expect_success '"git bisect bad HEAD" behaves as "git bisect bad"' ' + git checkout parallel && + git bisect start HEAD $HASH1 && + git bisect good HEAD && + git bisect bad HEAD && + test "$HASH6" = $(git rev-parse --verify HEAD) && + git bisect reset +' + test_done diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh index 9150984184..51ecd3e4c1 100755 --- a/t/t9903-bash-prompt.sh +++ b/t/t9903-bash-prompt.sh @@ -35,6 +35,8 @@ test_expect_success 'setup for prompt tests' ' git commit -m "another b2" file && echo 000 >file && git commit -m "yet another b2" file && + mkdir ignored_dir && + echo "ignored_dir/" >>.gitignore && git checkout master ' @@ -588,4 +590,108 @@ test_expect_success 'prompt - zsh color pc mode' ' test_cmp expected "$actual" ' +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset' ' + printf " (master)" >expected && + ( + cd ignored_dir && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var unset, config unset, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + ( + cd ignored_dir && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled' ' + printf " (master)" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config disabled, pc mode' ' + printf "BEFORE: (\${__git_ps1_branch_name}):AFTER" >expected && + test_config bash.hideIfPwdIgnored false && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset' ' + printf "" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - env var set, config unset, pc mode' ' + printf "BEFORE::AFTER" >expected && + ( + cd ignored_dir && + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + __git_ps1 "BEFORE:" ":AFTER" && + printf "%s" "$PS1" >"$actual" + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stdout)' ' + printf " (GIT_DIR!)" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >"$actual" 2>/dev/null + ) && + test_cmp expected "$actual" +' + +test_expect_success 'prompt - hide if pwd ignored - inside gitdir (stderr)' ' + printf "" >expected && + ( + GIT_PS1_HIDE_IF_PWD_IGNORED=y && + cd .git && + __git_ps1 >/dev/null 2>"$actual" + ) && + test_cmp expected "$actual" +' + test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index 9acdc8826f..bb1402de94 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -184,16 +184,8 @@ export _x05 _x40 _z40 LF u200c # This test checks if command xyzzy does the right thing... # ' # . ./test-lib.sh -[ "x$ORIGINAL_TERM" != "xdumb" ] && ( - TERM=$ORIGINAL_TERM && - export TERM && - [ -t 1 ] && - tput bold >/dev/null 2>&1 && - tput setaf 1 >/dev/null 2>&1 && - tput sgr0 >/dev/null 2>&1 - ) && - color=t +unset color while test "$#" -ne 0 do case "$1" in @@ -258,40 +250,6 @@ then verbose=t fi -if test -n "$color" -then - say_color () { - ( - TERM=$ORIGINAL_TERM - export TERM - case "$1" in - error) - tput bold; tput setaf 1;; # bold red - skip) - tput setaf 4;; # blue - warn) - tput setaf 3;; # brown/yellow - pass) - tput setaf 2;; # green - info) - tput setaf 6;; # cyan - *) - test -n "$quiet" && return;; - esac - shift - printf "%s" "$*" - tput sgr0 - echo - ) - } -else - say_color() { - test -z "$1" && test -n "$quiet" && return - shift - printf "%s\n" "$*" - } -fi - error () { say_color error "error: $*" GIT_EXIT_OK=t @@ -684,7 +642,7 @@ test_done () { then error "Can't use skip_all after running some tests" fi - [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" + test -z "$skip_all" || skip_all=" # SKIP $skip_all" if test $test_external_has_tap -eq 0 then @@ -857,6 +815,52 @@ HOME="$TRASH_DIRECTORY" GNUPGHOME="$HOME/gnupg-home-not-used" export HOME GNUPGHOME +# run the tput tests *after* changing HOME (in case ncurses needs +# ~/.terminfo for $TERM) +test -n "${color+set}" || test "x$ORIGINAL_TERM" != "xdumb" && ( + TERM=$ORIGINAL_TERM && + export TERM && + test -t 1 && + tput bold >/dev/null 2>&1 && + tput setaf 1 >/dev/null 2>&1 && + tput sgr0 >/dev/null 2>&1 + ) && + color=t + +if test -n "$color" +then + say_color () { + ( + TERM=$ORIGINAL_TERM + export TERM + case "$1" in + error) + tput bold; tput setaf 1;; # bold red + skip) + tput setaf 4;; # blue + warn) + tput setaf 3;; # brown/yellow + pass) + tput setaf 2;; # green + info) + tput setaf 6;; # cyan + *) + test -n "$quiet" && return;; + esac + shift + printf "%s" "$*" + tput sgr0 + echo + ) + } +else + say_color() { + test -z "$1" && test -n "$quiet" && return + shift + printf "%s\n" "$*" + } +fi + if test -z "$TEST_NO_CREATE_REPO" then test_create_repo "$TRASH_DIRECTORY" diff --git a/templates/hooks--pre-push.sample b/templates/hooks--pre-push.sample index 69e3c67b00..6187dbf439 100755 --- a/templates/hooks--pre-push.sample +++ b/templates/hooks--pre-push.sample @@ -24,7 +24,6 @@ url="$2" z40=0000000000000000000000000000000000000000 -IFS=' ' while read local_ref local_sha remote_ref remote_sha do if [ "$local_sha" = $z40 ] diff --git a/transport.c b/transport.c index 70d38e4c4b..08bcd3a4eb 100644 --- a/transport.c +++ b/transport.c @@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote, const char *url) } else { /* Unknown protocol in URL. Pass to external handler. */ int len = external_specification_len(url); - char *handler = xmalloc(len + 1); - handler[len] = 0; - strncpy(handler, url, len); + char *handler = xmemdupz(url, len); transport_helper_init(ret, handler); } diff --git a/update_unicode.sh b/update_unicode.sh index 000b937e68..27af77c7df 100755 --- a/update_unicode.sh +++ b/update_unicode.sh @@ -27,11 +27,14 @@ fi && fi && make ) && - echo "static const struct interval zero_width[] = {" >$UNICODEWIDTH_H && - UNICODE_DIR=. ./uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | - grep -v plane >>$UNICODEWIDTH_H && - echo "};" >>$UNICODEWIDTH_H && - echo "static const struct interval double_width[] = {" >>$UNICODEWIDTH_H && - UNICODE_DIR=. ./uniset/uniset --32 eaw:F,W >>$UNICODEWIDTH_H && - echo "};" >>$UNICODEWIDTH_H + UNICODE_DIR=. && export UNICODE_DIR && + cat >$UNICODEWIDTH_H <<-EOF + static const struct interval zero_width[] = { + $(uniset/uniset --32 cat:Me,Mn,Cf + U+1160..U+11FF - U+00AD | + grep -v plane) + }; + static const struct interval double_width[] = { + $(uniset/uniset --32 eaw:F,W) + }; + EOF ) diff --git a/upload-pack.c b/upload-pack.c index ac9ac1592d..b531a325d2 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -86,7 +86,7 @@ static void create_pack_file(void) "corruption on the remote side."; int buffered = -1; ssize_t sz; - const char *argv[12]; + const char *argv[13]; int i, arg = 0; FILE *pipe_fd; @@ -100,6 +100,8 @@ static void create_pack_file(void) argv[arg++] = "--thin"; argv[arg++] = "--stdout"; + if (shallow_nr) + argv[arg++] = "--shallow"; if (!no_progress) argv[arg++] = "--progress"; if (use_ofs_delta) @@ -563,8 +563,8 @@ int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding) } /* - * Pick the next char from the stream, folding as an HFS+ filename comparison - * would. Note that this is _not_ complete by any means. It's just enough + * Pick the next char from the stream, ignoring codepoints an HFS+ would. + * Note that this is _not_ complete by any means. It's just enough * to make is_hfs_dotgit() work, and should not be used otherwise. */ static ucs_char_t next_hfs_char(const char **in) @@ -601,12 +601,7 @@ static ucs_char_t next_hfs_char(const char **in) continue; } - /* - * there's a great deal of other case-folding that occurs, - * but this is enough to catch anything that will convert - * to ".git" - */ - return tolower(out); + return out; } } @@ -614,10 +609,23 @@ int is_hfs_dotgit(const char *path) { ucs_char_t c; - if (next_hfs_char(&path) != '.' || - next_hfs_char(&path) != 'g' || - next_hfs_char(&path) != 'i' || - next_hfs_char(&path) != 't') + c = next_hfs_char(&path); + if (c != '.') + return 0; + c = next_hfs_char(&path); + + /* + * there's a great deal of other case-folding that occurs + * in HFS+, but this is enough to catch anything that will + * convert to ".git" + */ + if (c != 'g' && c != 'G') + return 0; + c = next_hfs_char(&path); + if (c != 'i' && c != 'I') + return 0; + c = next_hfs_char(&path); + if (c != 't' && c != 'T') return 0; c = next_hfs_char(&path); if (c && !is_dir_sep(c)) |