diff options
-rw-r--r-- | Documentation/RelNotes/2.4.6.txt | 23 | ||||
-rw-r--r-- | Documentation/git-describe.txt | 2 | ||||
-rw-r--r-- | Documentation/git-format-patch.txt | 2 | ||||
-rw-r--r-- | Documentation/git.txt | 3 | ||||
-rwxr-xr-x | GIT-VERSION-GEN | 2 | ||||
l--------- | RelNotes | 2 | ||||
-rw-r--r-- | builtin/fsck.c | 34 | ||||
-rw-r--r-- | builtin/index-pack.c | 2 | ||||
-rw-r--r-- | builtin/log.c | 12 | ||||
-rw-r--r-- | builtin/rev-list.c | 2 | ||||
-rw-r--r-- | cache.h | 11 | ||||
-rw-r--r-- | config.c | 3 | ||||
-rw-r--r-- | contrib/completion/git-completion.tcsh | 2 | ||||
-rw-r--r-- | contrib/completion/git-prompt.sh | 4 | ||||
-rwxr-xr-x | contrib/hooks/pre-auto-gc-battery | 2 | ||||
-rw-r--r-- | ewah/bitmap.c | 24 | ||||
-rw-r--r-- | ewah/ewah_bitmap.c | 22 | ||||
-rw-r--r-- | ewah/ewok.h | 2 | ||||
-rw-r--r-- | fetch-pack.c | 2 | ||||
-rw-r--r-- | git-rebase--am.sh | 2 | ||||
-rw-r--r-- | pack-bitmap.c | 10 | ||||
-rw-r--r-- | sha1_file.c | 14 | ||||
-rwxr-xr-x | t/t0302-credential-store.sh | 2 | ||||
-rwxr-xr-x | t/t4014-format-patch.sh | 8 | ||||
-rwxr-xr-x | t/t5310-pack-bitmaps.sh | 6 | ||||
-rw-r--r-- | t/test-lib.sh | 99 | ||||
-rw-r--r-- | utf8.h | 4 |
27 files changed, 184 insertions, 117 deletions
diff --git a/Documentation/RelNotes/2.4.6.txt b/Documentation/RelNotes/2.4.6.txt new file mode 100644 index 0000000000..b53f353939 --- /dev/null +++ b/Documentation/RelNotes/2.4.6.txt @@ -0,0 +1,23 @@ +Git v2.4.6 Release Notes +======================== + +Fixes since v2.4.5 +------------------ + + * "git fetch --depth=<depth>" and "git clone --depth=<depth>" issued + a shallow transfer request even to an upload-pack that does not + support the capability. + + * "git fsck" used to ignore missing or invalid objects recorded in reflog. + + * The tcsh completion writes a bash scriptlet but that would have + failed for users with noclobber set. + + * Recent Mac OS X updates breaks the logic to detect that the machine + is on the AC power in the sample pre-auto-gc script. + + * "git format-patch --ignore-if-upstream A..B" did not like to be fed + tags as boundary commits. + +Also contains typofixes, documentation updates and trivial code +clean-ups. diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt index d20ca402a1..e045fc73f8 100644 --- a/Documentation/git-describe.txt +++ b/Documentation/git-describe.txt @@ -3,7 +3,7 @@ git-describe(1) NAME ---- -git-describe - Show the most recent tag that is reachable from a commit +git-describe - Describe a commit using the most recent tag reachable from it SYNOPSIS diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index bb3ea9372f..0dac4e9b86 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -170,7 +170,7 @@ will want to ensure that threading is disabled for `git send-email`. -v <n>:: --reroll-count=<n>:: Mark the series as the <n>-th iteration of the topic. The - output filenames have `v<n>` pretended to them, and the + output filenames have `v<n>` prepended to them, and the subject prefix ("PATCH" by default, but configurable via the `--subject-prefix` option) has ` v<n>` appended to it. E.g. `--reroll-count=4` may produce `v4-0001-add-makefile.patch` diff --git a/Documentation/git.txt b/Documentation/git.txt index a4a4cf39b2..35bd3b58b8 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.4.5/git.html[documentation for release 2.4.5] +* link:v2.4.6/git.html[documentation for release 2.4.6] * release notes for + link:RelNotes/2.4.6.txt[2.4.6], link:RelNotes/2.4.5.txt[2.4.5], link:RelNotes/2.4.4.txt[2.4.4], link:RelNotes/2.4.3.txt[2.4.3], diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 159d52645b..7a6c205542 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v2.4.5 +DEF_VER=v2.4.6 LF=' ' @@ -1 +1 @@ -Documentation/RelNotes/2.4.5.txt
\ No newline at end of file +Documentation/RelNotes/2.4.6.txt
\ No newline at end of file diff --git a/builtin/fsck.c b/builtin/fsck.c index 0c757862e8..6b6f31997c 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -451,34 +451,40 @@ static void fsck_dir(int i, char *path) static int default_refs; +static void fsck_handle_reflog_sha1(const char *refname, unsigned char *sha1) +{ + struct object *obj; + + if (!is_null_sha1(sha1)) { + obj = lookup_object(sha1); + if (obj) { + obj->used = 1; + mark_object_reachable(obj); + } else { + error("%s: invalid reflog entry %s", refname, sha1_to_hex(sha1)); + errors_found |= ERROR_REACHABLE; + } + } +} + static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, const char *email, unsigned long timestamp, int tz, const char *message, void *cb_data) { - struct object *obj; + const char *refname = cb_data; if (verbose) fprintf(stderr, "Checking reflog %s->%s\n", sha1_to_hex(osha1), sha1_to_hex(nsha1)); - if (!is_null_sha1(osha1)) { - obj = lookup_object(osha1); - if (obj) { - obj->used = 1; - mark_object_reachable(obj); - } - } - obj = lookup_object(nsha1); - if (obj) { - obj->used = 1; - mark_object_reachable(obj); - } + fsck_handle_reflog_sha1(refname, osha1); + fsck_handle_reflog_sha1(refname, nsha1); return 0; } static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data) { - for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL); + for_each_reflog_ent(logname, fsck_handle_reflog_ent, (void *)logname); return 0; } diff --git a/builtin/index-pack.c b/builtin/index-pack.c index cf654df09b..723fe8e11d 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -730,7 +730,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, assert(data || obj_entry); read_lock(); - collision_test_needed = has_sha1_file(sha1); + collision_test_needed = has_sha1_file_with_flags(sha1, HAS_SHA1_QUICK); read_unlock(); if (collision_test_needed && !data) { diff --git a/builtin/log.c b/builtin/log.c index 4c4e6be28c..7b343c1aaf 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -795,7 +795,7 @@ static int reopen_stdout(struct commit *commit, const char *subject, static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) { struct rev_info check_rev; - struct commit *commit; + struct commit *commit, *c1, *c2; struct object *o1, *o2; unsigned flags1, flags2; @@ -803,9 +803,11 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) die(_("Need exactly one range.")); o1 = rev->pending.objects[0].item; - flags1 = o1->flags; o2 = rev->pending.objects[1].item; + flags1 = o1->flags; flags2 = o2->flags; + c1 = lookup_commit_reference(o1->sha1); + c2 = lookup_commit_reference(o2->sha1); if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING)) die(_("Not a range.")); @@ -827,10 +829,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids) } /* reset for next revision walk */ - clear_commit_marks((struct commit *)o1, - SEEN | UNINTERESTING | SHOWN | ADDED); - clear_commit_marks((struct commit *)o2, - SEEN | UNINTERESTING | SHOWN | ADDED); + clear_commit_marks(c1, SEEN | UNINTERESTING | SHOWN | ADDED); + clear_commit_marks(c2, SEEN | UNINTERESTING | SHOWN | ADDED); o1->flags = flags1; o2->flags = flags2; } diff --git a/builtin/rev-list.c b/builtin/rev-list.c index ff84a825ff..88eddbd53a 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -355,7 +355,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) if (bisect_list) revs.limited = 1; - if (use_bitmap_index) { + if (use_bitmap_index && !revs.prune) { if (revs.count && !revs.left_right && !revs.cherry_mark) { uint32_t commit_count; if (!prepare_bitmap_walk(&revs)) { @@ -901,8 +901,17 @@ extern int has_sha1_pack(const unsigned char *sha1); * Return true iff we have an object named sha1, whether local or in * an alternate object database, and whether packed or loose. This * function does not respect replace references. + * + * If the QUICK flag is set, do not re-check the pack directory + * when we cannot find the object (this means we may give a false + * negative answer if another process is simultaneously repacking). */ -extern int has_sha1_file(const unsigned char *sha1); +#define HAS_SHA1_QUICK 0x1 +extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags); +static inline int has_sha1_file(const unsigned char *sha1) +{ + return has_sha1_file_with_flags(sha1, 0); +} /* * Return true iff an alternate object database has a loose object @@ -2116,6 +2116,9 @@ int git_config_set_multivar_in_file(const char *config_filename, contents_sz - copy_begin) < contents_sz - copy_begin) goto write_err_out; + + munmap(contents, contents_sz); + contents = NULL; } if (commit_lock_file(lock) < 0) { diff --git a/contrib/completion/git-completion.tcsh b/contrib/completion/git-completion.tcsh index 6104a42a23..4a790d8f4e 100644 --- a/contrib/completion/git-completion.tcsh +++ b/contrib/completion/git-completion.tcsh @@ -41,7 +41,7 @@ if ( ! -e ${__git_tcsh_completion_original_script} ) then exit endif -cat << EOF > ${__git_tcsh_completion_script} +cat << EOF >! ${__git_tcsh_completion_script} #!bash # # This script is GENERATED and will be overwritten automatically. diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh index f18aedc73b..366f0bc1e9 100644 --- a/contrib/completion/git-prompt.sh +++ b/contrib/completion/git-prompt.sh @@ -66,6 +66,10 @@ # git always compare HEAD to @{upstream} # svn always compare HEAD to your SVN upstream # +# You can change the separator between the branch name and the above +# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator +# is SP. +# # By default, __git_ps1 will compare HEAD to your SVN upstream if it can # find one, or @{upstream} otherwise. Once you have set # GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery index 9d0c2d1990..6a2cdebdb7 100755 --- a/contrib/hooks/pre-auto-gc-battery +++ b/contrib/hooks/pre-auto-gc-battery @@ -33,7 +33,7 @@ elif grep -q "AC Power \+: 1" /proc/pmu/info 2>/dev/null then exit 0 elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt | - grep -q "Currently drawing from 'AC Power'" + grep -q "drawing from 'AC Power'" then exit 0 fi diff --git a/ewah/bitmap.c b/ewah/bitmap.c index 710e58c1bf..47ad6747c4 100644 --- a/ewah/bitmap.c +++ b/ewah/bitmap.c @@ -20,8 +20,8 @@ #include "git-compat-util.h" #include "ewok.h" -#define MASK(x) ((eword_t)1 << (x % BITS_IN_WORD)) -#define BLOCK(x) (x / BITS_IN_WORD) +#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD)) +#define EWAH_BLOCK(x) (x / BITS_IN_EWORD) struct bitmap *bitmap_new(void) { @@ -33,7 +33,7 @@ struct bitmap *bitmap_new(void) void bitmap_set(struct bitmap *self, size_t pos) { - size_t block = BLOCK(pos); + size_t block = EWAH_BLOCK(pos); if (block >= self->word_alloc) { size_t old_size = self->word_alloc; @@ -45,22 +45,22 @@ void bitmap_set(struct bitmap *self, size_t pos) (self->word_alloc - old_size) * sizeof(eword_t)); } - self->words[block] |= MASK(pos); + self->words[block] |= EWAH_MASK(pos); } void bitmap_clear(struct bitmap *self, size_t pos) { - size_t block = BLOCK(pos); + size_t block = EWAH_BLOCK(pos); if (block < self->word_alloc) - self->words[block] &= ~MASK(pos); + self->words[block] &= ~EWAH_MASK(pos); } int bitmap_get(struct bitmap *self, size_t pos) { - size_t block = BLOCK(pos); + size_t block = EWAH_BLOCK(pos); return block < self->word_alloc && - (self->words[block] & MASK(pos)) != 0; + (self->words[block] & EWAH_MASK(pos)) != 0; } struct ewah_bitmap *bitmap_to_ewah(struct bitmap *bitmap) @@ -127,7 +127,7 @@ void bitmap_and_not(struct bitmap *self, struct bitmap *other) void bitmap_or_ewah(struct bitmap *self, struct ewah_bitmap *other) { size_t original_size = self->word_alloc; - size_t other_final = (other->bit_size / BITS_IN_WORD) + 1; + size_t other_final = (other->bit_size / BITS_IN_EWORD) + 1; size_t i = 0; struct ewah_iterator it; eword_t word; @@ -155,17 +155,17 @@ void bitmap_each_bit(struct bitmap *self, ewah_callback callback, void *data) uint32_t offset; if (word == (eword_t)~0) { - for (offset = 0; offset < BITS_IN_WORD; ++offset) + for (offset = 0; offset < BITS_IN_EWORD; ++offset) callback(pos++, data); } else { - for (offset = 0; offset < BITS_IN_WORD; ++offset) { + for (offset = 0; offset < BITS_IN_EWORD; ++offset) { if ((word >> offset) == 0) break; offset += ewah_bit_ctz64(word >> offset); callback(pos + offset, data); } - pos += BITS_IN_WORD; + pos += BITS_IN_EWORD; } } } diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c index fccb42b52c..b522437c0a 100644 --- a/ewah/ewah_bitmap.c +++ b/ewah/ewah_bitmap.c @@ -102,7 +102,7 @@ size_t ewah_add_empty_words(struct ewah_bitmap *self, int v, size_t number) if (number == 0) return 0; - self->bit_size += number * BITS_IN_WORD; + self->bit_size += number * BITS_IN_EWORD; return add_empty_words(self, v, number); } @@ -152,7 +152,7 @@ void ewah_add_dirty_words( self->buffer_size += can_add; } - self->bit_size += can_add * BITS_IN_WORD; + self->bit_size += can_add * BITS_IN_EWORD; if (number - can_add == 0) break; @@ -197,7 +197,7 @@ static size_t add_empty_word(struct ewah_bitmap *self, int v) size_t ewah_add(struct ewah_bitmap *self, eword_t word) { - self->bit_size += BITS_IN_WORD; + self->bit_size += BITS_IN_EWORD; if (word == 0) return add_empty_word(self, 0); @@ -211,8 +211,8 @@ size_t ewah_add(struct ewah_bitmap *self, eword_t word) void ewah_set(struct ewah_bitmap *self, size_t i) { const size_t dist = - (i + BITS_IN_WORD) / BITS_IN_WORD - - (self->bit_size + BITS_IN_WORD - 1) / BITS_IN_WORD; + (i + BITS_IN_EWORD) / BITS_IN_EWORD - + (self->bit_size + BITS_IN_EWORD - 1) / BITS_IN_EWORD; assert(i >= self->bit_size); @@ -222,19 +222,19 @@ void ewah_set(struct ewah_bitmap *self, size_t i) if (dist > 1) add_empty_words(self, 0, dist - 1); - add_literal(self, (eword_t)1 << (i % BITS_IN_WORD)); + add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD)); return; } if (rlw_get_literal_words(self->rlw) == 0) { rlw_set_running_len(self->rlw, rlw_get_running_len(self->rlw) - 1); - add_literal(self, (eword_t)1 << (i % BITS_IN_WORD)); + add_literal(self, (eword_t)1 << (i % BITS_IN_EWORD)); return; } self->buffer[self->buffer_size - 1] |= - ((eword_t)1 << (i % BITS_IN_WORD)); + ((eword_t)1 << (i % BITS_IN_EWORD)); /* check if we just completed a stream of 1s */ if (self->buffer[self->buffer_size - 1] == (eword_t)(~0)) { @@ -255,11 +255,11 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo eword_t *word = &self->buffer[pointer]; if (rlw_get_run_bit(word)) { - size_t len = rlw_get_running_len(word) * BITS_IN_WORD; + size_t len = rlw_get_running_len(word) * BITS_IN_EWORD; for (k = 0; k < len; ++k, ++pos) callback(pos, payload); } else { - pos += rlw_get_running_len(word) * BITS_IN_WORD; + pos += rlw_get_running_len(word) * BITS_IN_EWORD; } ++pointer; @@ -268,7 +268,7 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo int c; /* todo: zero count optimization */ - for (c = 0; c < BITS_IN_WORD; ++c, ++pos) { + for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) { if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0) callback(pos, payload); } diff --git a/ewah/ewok.h b/ewah/ewok.h index 13c6e20412..16b7a795a0 100644 --- a/ewah/ewok.h +++ b/ewah/ewok.h @@ -31,7 +31,7 @@ #endif typedef uint64_t eword_t; -#define BITS_IN_WORD (sizeof(eword_t) * 8) +#define BITS_IN_EWORD (sizeof(eword_t) * 8) /** * Do not use __builtin_popcountll. The GCC implementation diff --git a/fetch-pack.c b/fetch-pack.c index 48526aa54b..849a9d6275 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -790,7 +790,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, sort_ref_list(&ref, ref_compare_name); qsort(sought, nr_sought, sizeof(*sought), cmp_ref_by_name); - if (is_repository_shallow() && !server_supports("shallow")) + if ((args->depth > 0 || is_repository_shallow()) && !server_supports("shallow")) die("Server does not support shallow clients"); if (server_supports("multi_ack_detailed")) { if (args->verbose) diff --git a/git-rebase--am.sh b/git-rebase--am.sh index f923732333..9ae898bc1d 100644 --- a/git-rebase--am.sh +++ b/git-rebase--am.sh @@ -78,7 +78,7 @@ else As a result, git cannot rebase them. EOF - return $? + return $ret fi git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \ diff --git a/pack-bitmap.c b/pack-bitmap.c index 2b3ff23797..637770af81 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -622,7 +622,7 @@ static void show_objects_for_type( while (i < objects->word_alloc && ewah_iterator_next(&filter, &it)) { eword_t word = objects->words[i] & filter; - for (offset = 0; offset < BITS_IN_WORD; ++offset) { + for (offset = 0; offset < BITS_IN_EWORD; ++offset) { const unsigned char *sha1; struct revindex_entry *entry; uint32_t hash = 0; @@ -644,7 +644,7 @@ static void show_objects_for_type( show_reach(sha1, object_type, 0, hash, bitmap_git.pack, entry->offset); } - pos += BITS_IN_WORD; + pos += BITS_IN_EWORD; i++; } } @@ -776,7 +776,7 @@ int reuse_partial_packfile_from_bitmap(struct packed_git **packfile, break; } - reuse_objects += BITS_IN_WORD; + reuse_objects += BITS_IN_EWORD; } #ifdef GIT_BITMAP_DEBUG @@ -1001,7 +1001,7 @@ static int rebuild_bitmap(uint32_t *reposition, while (ewah_iterator_next(&word, &it)) { uint32_t offset, bit_pos; - for (offset = 0; offset < BITS_IN_WORD; ++offset) { + for (offset = 0; offset < BITS_IN_EWORD; ++offset) { if ((word >> offset) == 0) break; @@ -1014,7 +1014,7 @@ static int rebuild_bitmap(uint32_t *reposition, return -1; } - pos += BITS_IN_WORD; + pos += BITS_IN_EWORD; } return 0; } diff --git a/sha1_file.c b/sha1_file.c index 56c69cebc8..a68ae18dd8 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -443,6 +443,7 @@ void prepare_alt_odb(void) read_info_alternates(get_object_directory(), 0); } +/* Returns 1 if we have successfully freshened the file, 0 otherwise. */ static int freshen_file(const char *fn) { struct utimbuf t; @@ -450,11 +451,18 @@ static int freshen_file(const char *fn) return !utime(fn, &t); } +/* + * All of the check_and_freshen functions return 1 if the file exists and was + * freshened (if freshening was requested), 0 otherwise. If they return + * 0, you should not assume that it is safe to skip a write of the object (it + * either does not exist on disk, or has a stale mtime and may be subject to + * pruning). + */ static int check_and_freshen_file(const char *fn, int freshen) { if (access(fn, F_OK)) return 0; - if (freshen && freshen_file(fn)) + if (freshen && !freshen_file(fn)) return 0; return 1; } @@ -3084,7 +3092,7 @@ int has_sha1_pack(const unsigned char *sha1) return find_pack_entry(sha1, &e); } -int has_sha1_file(const unsigned char *sha1) +int has_sha1_file_with_flags(const unsigned char *sha1, int flags) { struct pack_entry e; @@ -3092,6 +3100,8 @@ int has_sha1_file(const unsigned char *sha1) return 1; if (has_loose_object(sha1)) return 1; + if (flags & HAS_SHA1_QUICK) + return 0; reprepare_packed_git(); return find_pack_entry(sha1, &e); } diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh index 0979df93a1..1d8d1f210b 100755 --- a/t/t0302-credential-store.sh +++ b/t/t0302-credential-store.sh @@ -75,7 +75,7 @@ test_expect_success 'get: use xdg file if home file has no matches' ' EOF ' -test_expect_success POSIXPERM 'get: use xdg file if home file is unreadable' ' +test_expect_success POSIXPERM,SANITY 'get: use xdg file if home file is unreadable' ' echo "https://home-user:home-pass@example.com" >"$HOME/.git-credentials" && chmod -r "$HOME/.git-credentials" && mkdir -p "$HOME/.config/git" && diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index c39e50028f..890db1174f 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -57,6 +57,14 @@ test_expect_success "format-patch --ignore-if-in-upstream" ' ' +test_expect_success "format-patch --ignore-if-in-upstream handles tags" ' + git tag -a v1 -m tag side && + git tag -a v2 -m tag master && + git format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 && + cnt=$(grep "^From " patch1 | wc -l) && + test $cnt = 2 +' + test_expect_success "format-patch doesn't consider merge commits" ' git checkout -b slave master && diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 6003490192..d446706e94 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -53,6 +53,12 @@ rev_list_tests() { test_cmp expect actual ' + test_expect_success "counting commits with limiting ($state)" ' + git rev-list --count HEAD -- 1.t >expect && + git rev-list --use-bitmap-index --count HEAD -- 1.t >actual && + test_cmp expect actual + ' + test_expect_success "enumerate --objects ($state)" ' git rev-list --objects --use-bitmap-index HEAD >tmp && cut -d" " -f1 <tmp >tmp2 && diff --git a/t/test-lib.sh b/t/test-lib.sh index 4ea99a209d..05efbad71c 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -15,9 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/ . -# Keep the original TERM for say_color -ORIGINAL_TERM=$TERM - # Test the binaries we have just built. The tests are kept in # t/ subdirectory and are run in 'trash directory' subdirectory. if test -z "$TEST_DIRECTORY" @@ -68,12 +65,12 @@ done,*) esac # For repeatability, reset the environment to known value. +# TERM is sanitized below, after saving color control sequences. LANG=C LC_ALL=C PAGER=cat TZ=UTC -TERM=dumb -export LANG LC_ALL PAGER TERM TZ +export LANG LC_ALL PAGER TZ EDITOR=: # A call to "unset" with no arguments causes at least Solaris 10 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets @@ -181,8 +178,14 @@ export _x05 _x40 _z40 LF u200c # This test checks if command xyzzy does the right thing... # ' # . ./test-lib.sh +test "x$TERM" != "xdumb" && ( + test -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 @@ -253,6 +256,44 @@ then verbose=t fi +if test -n "$color" +then + # Save the color control sequences now rather than run tput + # each time say_color() is called. This is done for two + # reasons: + # * TERM will be changed to dumb + # * HOME will be changed to a temporary directory and tput + # might need to read ~/.terminfo from the original HOME + # directory to get the control sequences + # Note: This approach assumes the control sequences don't end + # in a newline for any terminal of interest (command + # substitutions strip trailing newlines). Given that most + # (all?) terminals in common use are related to ECMA-48, this + # shouldn't be a problem. + say_color_error=$(tput bold; tput setaf 1) # bold red + say_color_skip=$(tput setaf 4) # blue + say_color_warn=$(tput setaf 3) # brown/yellow + say_color_pass=$(tput setaf 2) # green + say_color_info=$(tput setaf 6) # cyan + say_color_reset=$(tput sgr0) + say_color_="" # no formatting for normal text + say_color () { + test -z "$1" && test -n "$quiet" && return + eval "say_color_color=\$say_color_$1" + shift + printf "%s\\n" "$say_color_color$*$say_color_reset" + } +else + say_color() { + test -z "$1" && test -n "$quiet" && return + shift + printf "%s\n" "$*" + } +fi + +TERM=dumb +export TERM + error () { say_color error "error: $*" GIT_EXIT_OK=t @@ -829,52 +870,6 @@ 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" @@ -31,7 +31,9 @@ char *reencode_string_len(const char *in, int insz, const char *in_encoding, int *outsz); #else -#define reencode_string_len(a,b,c,d,e) NULL +static inline char *reencode_string_len(const char *a, int b, + const char *c, const char *d, int *e) +{ if (e) *e = 0; return NULL; } #endif static inline char *reencode_string(const char *in, |