summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2006-05-09 19:32:08 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-05-09 19:32:08 -0700
commit7278a29a277750e9e3cccce3cfb751d6171b1a43 (patch)
treed15df79e0893f45c099867a513e3969d5f9659c9
parentMerge branch 'jc/grep' into next (diff)
parentMerge branch 'fix' (diff)
downloadtgif-7278a29a277750e9e3cccce3cfb751d6171b1a43.tar.xz
Merge branch 'master' into next
* master: checkout: use --aggressive when running a 3-way merge (-m). revert/cherry-pick: use aggressive merge. read-cache.c: use xcalloc() not calloc() apply: fix infinite loop with multiple patches with --index
-rw-r--r--apply.c18
-rwxr-xr-xgit-checkout.sh2
-rwxr-xr-xgit-revert.sh2
-rw-r--r--read-cache.c2
4 files changed, 12 insertions, 12 deletions
diff --git a/apply.c b/apply.c
index 88d2a3206b..ea6fb4c880 100644
--- a/apply.c
+++ b/apply.c
@@ -21,6 +21,7 @@
//
static const char *prefix;
static int prefix_length = -1;
+static int newfd = -1;
static int p_value = 1;
static int allow_binary_replacement = 0;
@@ -2051,7 +2052,6 @@ static int use_patch(struct patch *p)
static int apply_patch(int fd, const char *filename)
{
- int newfd;
unsigned long offset, size;
char *buffer = read_patch_file(fd, &size);
struct patch *list = NULL, **listp = &list;
@@ -2082,12 +2082,11 @@ static int apply_patch(int fd, const char *filename)
size -= nr;
}
- newfd = -1;
if (whitespace_error && (new_whitespace == error_on_whitespace))
apply = 0;
write_index = check_index && apply;
- if (write_index)
+ if (write_index && newfd < 0)
newfd = hold_index_file_for_update(&cache_file, get_index_file());
if (check_index) {
if (read_cache() < 0)
@@ -2100,12 +2099,6 @@ static int apply_patch(int fd, const char *filename)
if (apply)
write_out_results(list, skipped_patch);
- if (write_index) {
- if (write_cache(newfd, active_cache, active_nr) ||
- commit_index_file(&cache_file))
- die("Unable to write new cachefile");
- }
-
if (show_index_info)
show_index_list(list);
@@ -2264,5 +2257,12 @@ int main(int argc, char **argv)
whitespace_error == 1 ? "" : "s",
whitespace_error == 1 ? "s" : "");
}
+
+ if (write_index) {
+ if (write_cache(newfd, active_cache, active_nr) ||
+ commit_index_file(&cache_file))
+ die("Unable to write new cachefile");
+ }
+
return 0;
}
diff --git a/git-checkout.sh b/git-checkout.sh
index 463ed2eaff..a11c939c30 100755
--- a/git-checkout.sh
+++ b/git-checkout.sh
@@ -144,7 +144,7 @@ else
work=`git write-tree` &&
git read-tree --reset $new &&
git checkout-index -f -u -q -a &&
- git read-tree -m -u $old $new $work || exit
+ git read-tree -m -u --aggressive $old $new $work || exit
if result=`git write-tree 2>/dev/null`
then
diff --git a/git-revert.sh b/git-revert.sh
index c19d3a6916..de8b5f0f0f 100755
--- a/git-revert.sh
+++ b/git-revert.sh
@@ -137,7 +137,7 @@ esac >.msg
# $prev and $commit on top of us (when cherry-picking or replaying).
echo >&2 "First trying simple merge strategy to $me."
-git-read-tree -m -u $base $head $next &&
+git-read-tree -m -u --aggressive $base $head $next &&
result=$(git-write-tree 2>/dev/null) || {
echo >&2 "Simple $me fails; trying Automatic $me."
git-merge-index -o git-merge-one-file -a || {
diff --git a/read-cache.c b/read-cache.c
index 1f71d12578..ed0da38e07 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -583,7 +583,7 @@ int read_cache(void)
active_nr = ntohl(hdr->hdr_entries);
active_alloc = alloc_nr(active_nr);
- active_cache = calloc(active_alloc, sizeof(struct cache_entry *));
+ active_cache = xcalloc(active_alloc, sizeof(struct cache_entry *));
offset = sizeof(*hdr);
for (i = 0; i < active_nr; i++) {