Skip to content

Fast track bug fix to merge-recursive #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -3043,10 +3043,26 @@ static int merge_content(struct merge_options *o,
if (mfi.clean &&
was_tracked_and_matches(o, path, &mfi.oid, mfi.mode) &&
!df_conflict_remains) {
int pos;
struct cache_entry *ce;

output(o, 3, _("Skipped %s (merged same as existing)"), path);
if (add_cacheinfo(o, mfi.mode, &mfi.oid, path,
0, (!o->call_depth && !is_dirty), 0))
return -1;
/*
* However, add_cacheinfo() will delete the old cache entry
* and add a new one. We need to copy over any skip_worktree
* flag to avoid making the file appear as if it were
* deleted by the user.
*/
pos = index_name_pos(&o->orig_index, path, strlen(path));
ce = o->orig_index.cache[pos];
if (ce_skip_worktree(ce)) {
pos = index_name_pos(&the_index, path, strlen(path));
ce = the_index.cache[pos];
ce->ce_flags |= CE_SKIP_WORKTREE;
}
return mfi.clean;
}

Expand Down
14 changes: 14 additions & 0 deletions t/t3507-cherry-pick-conflict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,18 @@ test_expect_success 'commit --amend -s places the sign-off at the right place' '
test_cmp expect actual
'

test_expect_success 'cherry-pick preserves sparse-checkout' '
pristine_detach initial &&
git config core.sparseCheckout true &&
echo /unrelated >.git/info/sparse-checkout &&
git read-tree --reset -u HEAD &&
test_must_fail git cherry-pick -Xours picked>actual &&
test "$(git ls-files -t foo)" = "S foo" &&
test_i18ngrep ! "Changes not staged for commit:" actual &&
echo "/*" >.git/info/sparse-checkout &&
git read-tree --reset -u HEAD &&
git config core.sparseCheckout false &&
rm .git/info/sparse-checkout
'

test_done