Created
June 2, 2010 04:14
-
-
Save DimaD/421919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!common) | |
; /* No common ancestors found. We need a real merge. */ | |
else if (!remoteheads->next && !common->next && | |
common->item == remoteheads->item) { | |
/* | |
* If head can reach all the merge then we are up to date. | |
* but first the most common case of merging one remote. | |
*/ | |
finish_up_to_date("Already up-to-date."); | |
return 0; | |
} else if (allow_fast_forward && !remoteheads->next && | |
!common->next && | |
!hashcmp(common->item->object.sha1, head)) { | |
/* Again the most common case of merging one remote. */ | |
struct strbuf msg = STRBUF_INIT; | |
struct object *o; | |
char hex[41]; | |
strcpy(hex, find_unique_abbrev(head, DEFAULT_ABBREV)); | |
if (verbosity >= 0) | |
printf("Updating %s..%s\n", | |
hex, | |
find_unique_abbrev(remoteheads->item->object.sha1, | |
DEFAULT_ABBREV)); | |
strbuf_addstr(&msg, "Fast-forward"); | |
if (have_message) | |
strbuf_addstr(&msg, | |
" (no commit created; -m option ignored)"); | |
o = peel_to_type(sha1_to_hex(remoteheads->item->object.sha1), | |
0, NULL, OBJ_COMMIT); | |
if (!o) | |
return 1; | |
if (checkout_fast_forward(head, remoteheads->item->object.sha1)) | |
return 1; | |
finish(o->sha1, msg.buf); | |
drop_save(); | |
return 0; | |
} else if (!remoteheads->next && common->next) | |
; | |
/* | |
* We are not doing octopus and not fast-forward. Need | |
* a real merge. | |
*/ | |
else if (!remoteheads->next && !common->next && option_commit) { | |
/* | |
* We are not doing octopus, not fast-forward, and have | |
* only one common. | |
*/ | |
refresh_cache(REFRESH_QUIET); | |
if (allow_trivial && !fast_forward_only) { | |
/* See if it is really trivial. */ | |
git_committer_info(IDENT_ERROR_ON_NO_NAME); | |
printf("Trying really trivial in-index merge...\n"); | |
if (!read_tree_trivial(common->item->object.sha1, | |
head, remoteheads->item->object.sha1)) | |
return merge_trivial(); | |
printf("Nope.\n"); | |
} | |
} else { | |
/* | |
* An octopus. If we can reach all the remote we are up | |
* to date. | |
*/ | |
int up_to_date = 1; | |
struct commit_list *j; | |
for (j = remoteheads; j; j = j->next) { | |
struct commit_list *common_one; | |
/* | |
* Here we *have* to calculate the individual | |
* merge_bases again, otherwise "git merge HEAD^ | |
* HEAD^^" would be missed. | |
*/ | |
common_one = get_merge_bases(lookup_commit(head), | |
j->item, 1); | |
if (hashcmp(common_one->item->object.sha1, | |
j->item->object.sha1)) { | |
up_to_date = 0; | |
break; | |
} | |
} | |
if (up_to_date) { | |
finish_up_to_date("Already up-to-date. Yeeah!"); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment