Skip to content

Commit 0901d5a

Browse files
committed
Merge branch 'maint'
* maint: am: remove rebase-apply directory before gc rerere: fix memory leak if rerere images can't be read Documentation: mention conflict marker size argument (%L) for merge driver
2 parents 241b925 + 29b6754 commit 0901d5a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ command to run to merge ancestor's version (`%O`), current
511511
version (`%A`) and the other branches' version (`%B`). These
512512
three tokens are replaced with the names of temporary files that
513513
hold the contents of these versions when the command line is
514-
built.
514+
built. Additionally, %L will be replaced with the conflict marker
515+
size (see below).
515516

516517
The merge driver is expected to leave the result of the merge in
517518
the file named with `%A` by overwriting it, and exit with zero

git-am.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,5 @@ do
776776
go_next
777777
done
778778

779-
git gc --auto
780-
781779
rm -fr "$dotest"
780+
git gc --auto

rerere.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,18 @@ static int find_conflict(struct string_list *conflict)
364364
static int merge(const char *name, const char *path)
365365
{
366366
int ret;
367-
mmfile_t cur, base, other;
367+
mmfile_t cur = {NULL, 0}, base = {NULL, 0}, other = {NULL, 0};
368368
mmbuffer_t result = {NULL, 0};
369369

370370
if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
371371
return 1;
372372

373373
if (read_mmfile(&cur, rerere_path(name, "thisimage")) ||
374374
read_mmfile(&base, rerere_path(name, "preimage")) ||
375-
read_mmfile(&other, rerere_path(name, "postimage")))
376-
return 1;
375+
read_mmfile(&other, rerere_path(name, "postimage"))) {
376+
ret = 1;
377+
goto out;
378+
}
377379
ret = ll_merge(&result, path, &base, &cur, "", &other, "", 0);
378380
if (!ret) {
379381
FILE *f = fopen(path, "w");
@@ -387,6 +389,7 @@ static int merge(const char *name, const char *path)
387389
strerror(errno));
388390
}
389391

392+
out:
390393
free(cur.ptr);
391394
free(base.ptr);
392395
free(other.ptr);

0 commit comments

Comments
 (0)