Skip to content

Commit b56e1b1

Browse files
committed
Merge pull request #755 from bwijen/master
Prevent child processes from inheriting a handle to index.lock
2 parents 9d55783 + c2d3c98 commit b56e1b1

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

compat/mingw.h

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ typedef int pid_t;
6767
#define F_SETFD 2
6868
#define FD_CLOEXEC 0x1
6969

70+
#if !defined O_CLOEXEC && defined O_NOINHERIT
71+
#define O_CLOEXEC O_NOINHERIT
72+
#endif
73+
7074
#ifndef EAFNOSUPPORT
7175
#define EAFNOSUPPORT WSAEAFNOSUPPORT
7276
#endif

t/t6026-merge-attr.sh

+15
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,19 @@ test_expect_success 'up-to-date merge without common ancestor' '
181181
)
182182
'
183183

184+
test_expect_success 'custom merge does not lock index' '
185+
git reset --hard anchor &&
186+
187+
write_script sleep-one-second.sh <<-\EOF &&
188+
sleep 1 &
189+
EOF
190+
191+
printf "* merge=ours\ntext merge=sleep-one-second\n" >.gitattributes &&
192+
193+
git config merge.ours.driver "true" &&
194+
git config merge.sleep-one-second.driver "./sleep-one-second.sh" &&
195+
196+
git merge master
197+
'
198+
184199
test_done

tempfile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int create_tempfile(struct tempfile *tempfile, const char *path)
120120
prepare_tempfile_object(tempfile);
121121

122122
strbuf_add_absolute_path(&tempfile->filename, path);
123-
tempfile->fd = open(tempfile->filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666);
123+
tempfile->fd = open(tempfile->filename.buf, O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, 0666);
124124
if (tempfile->fd < 0) {
125125
strbuf_reset(&tempfile->filename);
126126
return -1;

0 commit comments

Comments
 (0)