From 1ed87d37f22ff90823cd1fd719193a3d9a279cbb Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 5 Feb 2007 17:07:42 -0800 Subject: [PATCH 1/4] receive-pack.c: fix mismerge. Commit 29d231eb mismerged to introduce style breakage. Signed-off-by: Junio C Hamano --- receive-pack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receive-pack.c b/receive-pack.c index c51f417aed..7311c822dd 100644 --- a/receive-pack.c +++ b/receive-pack.c @@ -423,7 +423,7 @@ int main(int argc, char **argv) if (!dir) usage(receive_pack_usage); - if(!enter_repo(dir, 0)) + if (!enter_repo(dir, 0)) die("'%s': unable to chdir or not a git archive", dir); if (is_repository_shallow()) From 8101270a3f1ac743b665b0bd93564316f71d1923 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Feb 2007 19:37:40 -0800 Subject: [PATCH 2/4] Revert "in_merge_bases(): optimization" This reverts commit dc3806d39698899fe81e55c0daa5bd9d30d13d9c. --- commit.c | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/commit.c b/commit.c index bbb9840c48..b37e3dd0ad 100644 --- a/commit.c +++ b/commit.c @@ -1063,7 +1063,7 @@ static struct commit *interesting(struct commit_list *list) return NULL; } -static struct commit_list *base_traverse(struct commit_list *list, struct commit *stop) +static struct commit_list *base_traverse(struct commit_list *list) { struct commit_list *result = NULL; @@ -1097,20 +1097,10 @@ static struct commit_list *base_traverse(struct commit_list *list, struct commit p->object.flags |= flags; insert_by_date(p, &list); } - if (stop && (stop->object.flags & PARENT2)) { - free_commit_list(list); - list = NULL; - insert_by_date(stop, &list); - return list; - } } /* Clean up the result to remove stale ones */ free_commit_list(list); - - if (stop) - return NULL; - list = result; result = NULL; while (list) { struct commit_list *n = list->next; @@ -1140,7 +1130,7 @@ static struct commit_list *merge_bases(struct commit *one, struct commit *two) insert_by_date(one, &list); insert_by_date(two, &list); - return base_traverse(list, NULL); + return base_traverse(list); } struct commit_list *get_merge_bases(struct commit *one, @@ -1205,30 +1195,20 @@ struct commit_list *get_merge_bases(struct commit *one, int in_merge_bases(struct commit *commit, struct commit **reference, int num) { - struct commit_list *result, *list; - int i, ret; + struct commit_list *bases, *b; + int ret = 0; - list = NULL; - parse_commit(commit); - commit->object.flags |= PARENT1; - insert_by_date(commit, &list); - - for (i = 0; i < num; i++) { - struct commit *two = reference[i]; - parse_commit(two); - if (!(two->object.flags & PARENT2)) { - two->object.flags |= PARENT2; - insert_by_date(two, &list); + if (num == 1) + bases = get_merge_bases(commit, *reference, 1); + else + die("not yet"); + for (b = bases; b; b = b->next) { + if (!hashcmp(commit->object.sha1, b->item->object.sha1)) { + ret = 1; + break; } } - result = base_traverse(list, commit); - ret = !!result; - free_commit_list(result); - clear_commit_marks(commit, all_flags); - for (i = 0; i < num; i++) { - struct commit *two = reference[i]; - clear_commit_marks(two, all_flags); - } + free_commit_list(bases); return ret; } From 5e52001ae27ba4c1b3b86864819a5fe895a0c32e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Feb 2007 19:37:46 -0800 Subject: [PATCH 3/4] Revert "merge_base(): move traversal into a separate function." This reverts commit 40e0e66bb00646fbdc998c4fe01280470489d0e5. --- commit.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/commit.c b/commit.c index b37e3dd0ad..8d279b0b63 100644 --- a/commit.c +++ b/commit.c @@ -1063,10 +1063,25 @@ static struct commit *interesting(struct commit_list *list) return NULL; } -static struct commit_list *base_traverse(struct commit_list *list) +static struct commit_list *merge_bases(struct commit *one, struct commit *two) { + struct commit_list *list = NULL; struct commit_list *result = NULL; + if (one == two) + /* We do not mark this even with RESULT so we do not + * have to clean it up. + */ + return commit_list_insert(one, &result); + + parse_commit(one); + parse_commit(two); + + one->object.flags |= PARENT1; + two->object.flags |= PARENT2; + insert_by_date(one, &list); + insert_by_date(two, &list); + while (interesting(list)) { struct commit *commit; struct commit_list *parents; @@ -1112,27 +1127,6 @@ static struct commit_list *base_traverse(struct commit_list *list) return result; } -static struct commit_list *merge_bases(struct commit *one, struct commit *two) -{ - struct commit_list *list = NULL; - - if (one == two) - /* We do not mark this even with RESULT so we do not - * have to clean it up. - */ - return commit_list_insert(one, &list); - - parse_commit(one); - parse_commit(two); - - one->object.flags |= PARENT1; - two->object.flags |= PARENT2; - insert_by_date(one, &list); - insert_by_date(two, &list); - - return base_traverse(list); -} - struct commit_list *get_merge_bases(struct commit *one, struct commit *two, int cleanup) From 079f7cb27b6636f9153c24a82f3d5d74a7b0b6b1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 13 Feb 2007 19:44:24 -0800 Subject: [PATCH 4/4] Revert jc/3way topic altogether. Signed-off-by: Junio C Hamano --- git-checkout.sh | 7 ------- git-merge.sh | 47 +---------------------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/git-checkout.sh b/git-checkout.sh index 3e09f4d92b..14835a4aa9 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -191,9 +191,6 @@ else exit 1 ;; esac - # First stash away the local changes - git diff-index --binary -p HEAD >"$GIT_DIR"/LOCAL_DIFF - # Match the index to the working tree, and do a three-way. git diff-files --name-only | git update-index --remove --stdin && work=`git write-tree` && @@ -218,10 +215,6 @@ else sed -e 's/^[0-7]* [0-9a-f]* /'"0 $z40 /" echo "$unmerged" ) | git update-index --index-info - - echo >&2 "Conflicts in locally modified files:" - git diff --name-only --diff-filter=U >&2 - echo >&2 "Your local changes are found in $GIT_DIR/LOCAL_DIFF" ;; esac exit 0 diff --git a/git-merge.sh b/git-merge.sh index b0f4c67bf8..04a5eb0f29 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -97,51 +97,6 @@ finish () { esac } -merge_local_changes () { - merge_error=$(git-read-tree -m -u --exclude-per-directory=.gitignore $1 $2 2>&1) || ( - - # First stash away the local changes - git diff-index --binary -p HEAD >"$GIT_DIR"/LOCAL_DIFF - - # Match the index to the working tree, and do a three-way. - git diff-files --name-only | - git update-index --remove --stdin && - work=`git write-tree` && - git read-tree --reset -u $2 && - git read-tree -m -u --aggressive --exclude-per-directory=.gitignore $1 $2 $work || exit - - echo >&2 "Carrying local changes forward." - if result=`git write-tree 2>/dev/null` - then - echo >&2 "Trivially automerged." - else - git merge-index -o git-merge-one-file -a - fi - - # Do not register the cleanly merged paths in the index - # yet; this is not a real merge before committing, but - # just carrying the working tree changes along. - unmerged=`git ls-files -u` - git read-tree --reset $2 - case "$unmerged" in - '') ;; - *) - ( - z40=0000000000000000000000000000000000000000 - echo "$unmerged" | - sed -e 's/^[0-7]* [0-9a-f]* /'"0 $z40 /" - echo "$unmerged" - ) | git update-index --index-info - - echo >&2 "Conflicts in locally modified files:" - git diff --name-only --diff-filter=U >&2 - echo >&2 "Your local changes are found in $GIT_DIR/LOCAL_DIFF" - ;; - esac - exit 0 - ) -} - merge_name () { remote="$1" rh=$(git-rev-parse --verify "$remote^0" 2>/dev/null) || return @@ -335,7 +290,7 @@ f,*) echo "Updating $(git-rev-parse --short $head)..$(git-rev-parse --short $1)" git-update-index --refresh 2>/dev/null new_head=$(git-rev-parse --verify "$1^0") && - merge_local_changes $head $new_head && + git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" && finish "$new_head" "Fast forward" dropsave exit 0