Skip to content

Commit 9116d80

Browse files
committed
Merge branch 'mr/merge-file-object-id-worktree-fix' into seen
* mr/merge-file-object-id-worktree-fix: merge-file: fix BUG when --object-id is used in a worktree
2 parents db5d1b9 + 57246b7 commit 9116d80

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

builtin/merge-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ int cmd_merge_file(int argc,
108108
return error_errno("failed to redirect stderr to /dev/null");
109109
}
110110

111-
if (object_id)
111+
if (!repo && object_id)
112+
/* emit the correct "not a git repo" error in this case */
112113
setup_git_directory();
113114

114115
for (i = 0; i < 3; i++) {

t/t6403-merge-file.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,15 @@ test_expect_success '--object-id fails without repository' '
542542
grep "not a git repository" err
543543
'
544544

545+
test_expect_success 'run in a linked worktree with --object-id' '
546+
empty="$(test_oid empty_blob)" &&
547+
git worktree add work &&
548+
git -C work merge-file --object-id $empty $empty $empty >actual &&
549+
git worktree remove work &&
550+
git merge-file --object-id $empty $empty $empty >expected &&
551+
test_cmp actual expected
552+
'
553+
545554
test_expect_success 'merging C files with "myers" diff algorithm creates some spurious conflicts' '
546555
cat >expect.c <<-\EOF &&
547556
int g(size_t u)

0 commit comments

Comments
 (0)