Git development
 help / color / mirror / Atom feed
* [PATCH 8/8] reftable/stack: fix stale lock when dying
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 4515 bytes --]

When starting a transaction via `reftable_stack_init_addition()`, we
create a lockfile for the reftable stack itself which we'll write the
new list of tables to. But if we terminate abnormally e.g. via a call to
`die()`, then we do not remove the lockfile. Subsequent executions of
Git which try to modify references will thus fail with an out-of-date
error.

Fix this bug by registering the lock as a `struct tempfile`, which
ensures automatic cleanup for us.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack.c | 47 +++++++++++++++--------------------------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/reftable/stack.c b/reftable/stack.c
index 2dd2373360..2f1494aef2 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -17,6 +17,8 @@ license that can be found in the LICENSE file or at
 #include "reftable-merged.h"
 #include "writer.h"
 
+#include "tempfile.h"
+
 static int stack_try_add(struct reftable_stack *st,
 			 int (*write_table)(struct reftable_writer *wr,
 					    void *arg),
@@ -440,8 +442,7 @@ static void format_name(struct strbuf *dest, uint64_t min, uint64_t max)
 }
 
 struct reftable_addition {
-	int lock_file_fd;
-	struct strbuf lock_file_name;
+	struct tempfile *lock_file;
 	struct reftable_stack *stack;
 
 	char **new_tables;
@@ -449,24 +450,19 @@ struct reftable_addition {
 	uint64_t next_update_index;
 };
 
-#define REFTABLE_ADDITION_INIT                \
-	{                                     \
-		.lock_file_name = STRBUF_INIT \
-	}
+#define REFTABLE_ADDITION_INIT {0}
 
 static int reftable_stack_init_addition(struct reftable_addition *add,
 					struct reftable_stack *st)
 {
+	struct strbuf lock_file_name = STRBUF_INIT;
 	int err = 0;
 	add->stack = st;
 
-	strbuf_reset(&add->lock_file_name);
-	strbuf_addstr(&add->lock_file_name, st->list_file);
-	strbuf_addstr(&add->lock_file_name, ".lock");
+	strbuf_addf(&lock_file_name, "%s.lock", st->list_file);
 
-	add->lock_file_fd = open(add->lock_file_name.buf,
-				 O_EXCL | O_CREAT | O_WRONLY, 0666);
-	if (add->lock_file_fd < 0) {
+	add->lock_file = create_tempfile(lock_file_name.buf);
+	if (!add->lock_file) {
 		if (errno == EEXIST) {
 			err = REFTABLE_LOCK_ERROR;
 		} else {
@@ -475,7 +471,7 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
 		goto done;
 	}
 	if (st->config.default_permissions) {
-		if (chmod(add->lock_file_name.buf, st->config.default_permissions) < 0) {
+		if (chmod(lock_file_name.buf, st->config.default_permissions) < 0) {
 			err = REFTABLE_IO_ERROR;
 			goto done;
 		}
@@ -495,6 +491,7 @@ static int reftable_stack_init_addition(struct reftable_addition *add,
 	if (err) {
 		reftable_addition_close(add);
 	}
+	strbuf_release(&lock_file_name);
 	return err;
 }
 
@@ -512,15 +509,7 @@ static void reftable_addition_close(struct reftable_addition *add)
 	add->new_tables = NULL;
 	add->new_tables_len = 0;
 
-	if (add->lock_file_fd > 0) {
-		close(add->lock_file_fd);
-		add->lock_file_fd = 0;
-	}
-	if (add->lock_file_name.len > 0) {
-		unlink(add->lock_file_name.buf);
-		strbuf_release(&add->lock_file_name);
-	}
-
+	delete_tempfile(&add->lock_file);
 	strbuf_release(&nm);
 }
 
@@ -536,8 +525,10 @@ void reftable_addition_destroy(struct reftable_addition *add)
 int reftable_addition_commit(struct reftable_addition *add)
 {
 	struct strbuf table_list = STRBUF_INIT;
+	int lock_file_fd = get_tempfile_fd(add->lock_file);
 	int i = 0;
 	int err = 0;
+
 	if (add->new_tables_len == 0)
 		goto done;
 
@@ -550,28 +541,20 @@ int reftable_addition_commit(struct reftable_addition *add)
 		strbuf_addstr(&table_list, "\n");
 	}
 
-	err = write_in_full(add->lock_file_fd, table_list.buf, table_list.len);
+	err = write_in_full(lock_file_fd, table_list.buf, table_list.len);
 	strbuf_release(&table_list);
 	if (err < 0) {
 		err = REFTABLE_IO_ERROR;
 		goto done;
 	}
 
-	err = close(add->lock_file_fd);
-	add->lock_file_fd = 0;
-	if (err < 0) {
-		err = REFTABLE_IO_ERROR;
-		goto done;
-	}
-
-	err = rename(add->lock_file_name.buf, add->stack->list_file);
+	err = rename_tempfile(&add->lock_file, add->stack->list_file);
 	if (err < 0) {
 		err = REFTABLE_IO_ERROR;
 		goto done;
 	}
 
 	/* success, no more state to clean up. */
-	strbuf_release(&add->lock_file_name);
 	for (i = 0; i < add->new_tables_len; i++) {
 		reftable_free(add->new_tables[i]);
 	}
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 7/8] reftable/merged: reuse buffer to compute record keys
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 2100 bytes --]

When iterating over entries in the merged iterator's queue, we compute
the key of each of the entries and write it into a buffer. We do not
reuse the buffer though and thus re-allocate it on every iteration,
which is wasteful given that we never transfer ownership of the
allocated bytes outside of the loop.

Refactor the code to reuse the buffer. This also fixes a potential
memory leak when `merged_iter_advance_subiter()` returns an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/merged.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/reftable/merged.c b/reftable/merged.c
index 5ded470c08..cd03f6da13 100644
--- a/reftable/merged.c
+++ b/reftable/merged.c
@@ -85,7 +85,7 @@ static int merged_iter_advance_subiter(struct merged_iter *mi, size_t idx)
 static int merged_iter_next_entry(struct merged_iter *mi,
 				  struct reftable_record *rec)
 {
-	struct strbuf entry_key = STRBUF_INIT;
+	struct strbuf entry_key = STRBUF_INIT, k = STRBUF_INIT;
 	struct pq_entry entry = { 0 };
 	int err = 0;
 
@@ -108,30 +108,28 @@ static int merged_iter_next_entry(struct merged_iter *mi,
 	reftable_record_key(&entry.rec, &entry_key);
 	while (!merged_iter_pqueue_is_empty(mi->pq)) {
 		struct pq_entry top = merged_iter_pqueue_top(mi->pq);
-		struct strbuf k = STRBUF_INIT;
-		int err = 0, cmp = 0;
+		int cmp = 0;
 
 		reftable_record_key(&top.rec, &k);
 
 		cmp = strbuf_cmp(&k, &entry_key);
-		strbuf_release(&k);
-
-		if (cmp > 0) {
+		if (cmp > 0)
 			break;
-		}
 
 		merged_iter_pqueue_remove(&mi->pq);
 		err = merged_iter_advance_subiter(mi, top.index);
-		if (err < 0) {
-			return err;
-		}
+		if (err < 0)
+			goto done;
 		reftable_record_release(&top.rec);
 	}
 
 	reftable_record_copy_from(rec, &entry.rec, hash_size(mi->hash_id));
+
+done:
 	reftable_record_release(&entry.rec);
 	strbuf_release(&entry_key);
-	return 0;
+	strbuf_release(&k);
+	return err;
 }
 
 static int merged_iter_next(struct merged_iter *mi, struct reftable_record *rec)
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 6/8] reftable/stack: reuse buffers when reloading stack
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 2328 bytes --]

In `reftable_stack_reload_once()` we iterate over all the tables added
to the stack in order to figure out whether any of the tables needs to
be reloaded. We use a set of buffers in this context to compute the
paths of these tables, but discard those buffers on every iteration.
This is quite wasteful given that we do not need to transfer ownership
of the allocated buffer outside of the loop.

Refactor the code to instead reuse the buffers to reduce the number of
allocations we need to do.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/reftable/stack.c b/reftable/stack.c
index f5d18a842a..2dd2373360 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -204,6 +204,7 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
 		reftable_calloc(sizeof(struct reftable_table) * names_len);
 	int new_readers_len = 0;
 	struct reftable_merged_table *new_merged = NULL;
+	struct strbuf table_path = STRBUF_INIT;
 	int i;
 
 	while (*names) {
@@ -223,13 +224,10 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
 
 		if (!rd) {
 			struct reftable_block_source src = { NULL };
-			struct strbuf table_path = STRBUF_INIT;
 			stack_filename(&table_path, st, name);
 
 			err = reftable_block_source_from_file(&src,
 							      table_path.buf);
-			strbuf_release(&table_path);
-
 			if (err < 0)
 				goto done;
 
@@ -267,16 +265,13 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
 	for (i = 0; i < cur_len; i++) {
 		if (cur[i]) {
 			const char *name = reader_name(cur[i]);
-			struct strbuf filename = STRBUF_INIT;
-			stack_filename(&filename, st, name);
+			stack_filename(&table_path, st, name);
 
 			reader_close(cur[i]);
 			reftable_reader_free(cur[i]);
 
 			/* On Windows, can only unlink after closing. */
-			unlink(filename.buf);
-
-			strbuf_release(&filename);
+			unlink(table_path.buf);
 		}
 	}
 
@@ -288,6 +283,7 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
 	reftable_free(new_readers);
 	reftable_free(new_tables);
 	reftable_free(cur);
+	strbuf_release(&table_path);
 	return err;
 }
 
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 5/8] reftable/stack: perform auto-compaction with transactional interface
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 4295 bytes --]

Whenever updating references or reflog entries in the reftable stack, we
need to add a new table to the stack, thus growing the stack's length by
one. It can thus happen quite fast that the stack grows very long, which
results in performance issues when trying to read records. But besides
performance issues, this can also lead to exhaustion of file descriptors
very rapidly as every single table requires a separate descriptor when
opening the stack.

While git-pack-refs(1) fixes this issue for us by merging the tables, it
runs too irregularly to keep the length of the stack within reasonable
limits. This is why the reftable stack has an auto-compaction mechanism:
`reftable_stack_add()` will call `reftable_stack_auto_compact()` after
its added the new table, which will auto-compact the stack as required.

But while this logic works alright for `reftable_stack_add()`, we do not
do the same in `reftable_addition_commit()`, which is the transactional
equivalent to the former function that allows us to write multiple
updates to the stack atomically. Consequentially, we will easily run
into file descriptor exhaustion in code paths that use many separate
transactions like e.g. non-atomic fetches.

Fix this issue by calling `reftable_stack_auto_compact()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack.c      |  6 +++++
 reftable/stack_test.c | 56 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/reftable/stack.c b/reftable/stack.c
index f0cadad490..f5d18a842a 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -584,6 +584,12 @@ int reftable_addition_commit(struct reftable_addition *add)
 	add->new_tables_len = 0;
 
 	err = reftable_stack_reload(add->stack);
+	if (err)
+		goto done;
+
+	if (!add->stack->disable_auto_compact)
+		err = reftable_stack_auto_compact(add->stack);
+
 done:
 	reftable_addition_close(add);
 	return err;
diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index c979d177c2..4c2f794c49 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -289,6 +289,61 @@ static void test_reftable_stack_transaction_api(void)
 	clear_dir(dir);
 }
 
+static void test_reftable_stack_transaction_api_performs_auto_compaction(void)
+{
+	char *dir = get_tmp_dir(__LINE__);
+	struct reftable_write_options cfg = {0};
+	struct reftable_addition *add = NULL;
+	struct reftable_stack *st = NULL;
+	int i, n = 20, err;
+
+	err = reftable_new_stack(&st, dir, cfg);
+	EXPECT_ERR(err);
+
+	for (i = 0; i <= n; i++) {
+		struct reftable_ref_record ref = {
+			.update_index = reftable_stack_next_update_index(st),
+			.value_type = REFTABLE_REF_SYMREF,
+			.value.symref = "master",
+		};
+		char name[100];
+
+		snprintf(name, sizeof(name), "branch%04d", i);
+		ref.refname = name;
+
+		/*
+		 * Disable auto-compaction for all but the last runs. Like this
+		 * we can ensure that we indeed honor this setting and have
+		 * better control over when exactly auto compaction runs.
+		 */
+		st->disable_auto_compact = i != n;
+
+		err = reftable_stack_new_addition(&add, st);
+		EXPECT_ERR(err);
+
+		err = reftable_addition_add(add, &write_test_ref, &ref);
+		EXPECT_ERR(err);
+
+		err = reftable_addition_commit(add);
+		EXPECT_ERR(err);
+
+		reftable_addition_destroy(add);
+
+		/*
+		 * The stack length should grow continuously for all runs where
+		 * auto compaction is disabled. When enabled, we should merge
+		 * all tables in the stack.
+		 */
+		if (i != n)
+			EXPECT(st->merged->stack_len == i + 1);
+		else
+			EXPECT(st->merged->stack_len == 1);
+	}
+
+	reftable_stack_destroy(st);
+	clear_dir(dir);
+}
+
 static void test_reftable_stack_validate_refname(void)
 {
 	struct reftable_write_options cfg = { 0 };
@@ -1014,6 +1069,7 @@ int stack_test_main(int argc, const char *argv[])
 	RUN_TEST(test_reftable_stack_log_normalize);
 	RUN_TEST(test_reftable_stack_tombstone);
 	RUN_TEST(test_reftable_stack_transaction_api);
+	RUN_TEST(test_reftable_stack_transaction_api_performs_auto_compaction);
 	RUN_TEST(test_reftable_stack_update_index_check);
 	RUN_TEST(test_reftable_stack_uptodate);
 	RUN_TEST(test_reftable_stack_validate_refname);
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 4/8] reftable/stack: verify that `reftable_stack_add()` uses auto-compaction
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 2503 bytes --]

While we have several tests that check whether we correctly perform
auto-compaction when manually calling `reftable_stack_auto_compact()`,
we don't have any tests that verify whether `reftable_stack_add()` does
call it automatically. Add one.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack_test.c | 47 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index 0644c8ad2e..c979d177c2 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -850,6 +850,52 @@ static void test_reftable_stack_auto_compaction(void)
 	clear_dir(dir);
 }
 
+static void test_reftable_stack_add_performs_auto_compaction(void)
+{
+	struct reftable_write_options cfg = { 0 };
+	struct reftable_stack *st = NULL;
+	char *dir = get_tmp_dir(__LINE__);
+	int err, i, n = 20;
+
+	err = reftable_new_stack(&st, dir, cfg);
+	EXPECT_ERR(err);
+
+	for (i = 0; i <= n; i++) {
+		struct reftable_ref_record ref = {
+			.update_index = reftable_stack_next_update_index(st),
+			.value_type = REFTABLE_REF_SYMREF,
+			.value.symref = "master",
+		};
+		char name[100];
+
+		/*
+		 * Disable auto-compaction for all but the last runs. Like this
+		 * we can ensure that we indeed honor this setting and have
+		 * better control over when exactly auto compaction runs.
+		 */
+		st->disable_auto_compact = i != n;
+
+		snprintf(name, sizeof(name), "branch%04d", i);
+		ref.refname = name;
+
+		err = reftable_stack_add(st, &write_test_ref, &ref);
+		EXPECT_ERR(err);
+
+		/*
+		 * The stack length should grow continuously for all runs where
+		 * auto compaction is disabled. When enabled, we should merge
+		 * all tables in the stack.
+		 */
+		if (i != n)
+			EXPECT(st->merged->stack_len == i + 1);
+		else
+			EXPECT(st->merged->stack_len == 1);
+	}
+
+	reftable_stack_destroy(st);
+	clear_dir(dir);
+}
+
 static void test_reftable_stack_compaction_concurrent(void)
 {
 	struct reftable_write_options cfg = { 0 };
@@ -960,6 +1006,7 @@ int stack_test_main(int argc, const char *argv[])
 	RUN_TEST(test_reftable_stack_add);
 	RUN_TEST(test_reftable_stack_add_one);
 	RUN_TEST(test_reftable_stack_auto_compaction);
+	RUN_TEST(test_reftable_stack_add_performs_auto_compaction);
 	RUN_TEST(test_reftable_stack_compaction_concurrent);
 	RUN_TEST(test_reftable_stack_compaction_concurrent_clean);
 	RUN_TEST(test_reftable_stack_hash_id);
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 3/8] reftable: handle interrupted writes
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

There are calls to write(3P) where we don't properly handle interrupts.
Convert them to use `write_in_full()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack.c      | 6 +++---
 reftable/stack_test.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/reftable/stack.c b/reftable/stack.c
index ed108a929b..f0cadad490 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -42,7 +42,7 @@ static void stack_filename(struct strbuf *dest, struct reftable_stack *st,
 static ssize_t reftable_fd_write(void *arg, const void *data, size_t sz)
 {
 	int *fdp = (int *)arg;
-	return write(*fdp, data, sz);
+	return write_in_full(*fdp, data, sz);
 }
 
 int reftable_new_stack(struct reftable_stack **dest, const char *dir,
@@ -554,7 +554,7 @@ int reftable_addition_commit(struct reftable_addition *add)
 		strbuf_addstr(&table_list, "\n");
 	}
 
-	err = write(add->lock_file_fd, table_list.buf, table_list.len);
+	err = write_in_full(add->lock_file_fd, table_list.buf, table_list.len);
 	strbuf_release(&table_list);
 	if (err < 0) {
 		err = REFTABLE_IO_ERROR;
@@ -1024,7 +1024,7 @@ static int stack_compact_range(struct reftable_stack *st, int first, int last,
 		strbuf_addstr(&ref_list_contents, "\n");
 	}
 
-	err = write(lock_file_fd, ref_list_contents.buf, ref_list_contents.len);
+	err = write_in_full(lock_file_fd, ref_list_contents.buf, ref_list_contents.len);
 	if (err < 0) {
 		err = REFTABLE_IO_ERROR;
 		unlink(new_table_path.buf);
diff --git a/reftable/stack_test.c b/reftable/stack_test.c
index d0b717510f..0644c8ad2e 100644
--- a/reftable/stack_test.c
+++ b/reftable/stack_test.c
@@ -78,7 +78,7 @@ static void test_read_file(void)
 	int i = 0;
 
 	EXPECT(fd > 0);
-	n = write(fd, out, strlen(out));
+	n = write_in_full(fd, out, strlen(out));
 	EXPECT(n == strlen(out));
 	err = close(fd);
 	EXPECT(err >= 0);
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 2/8] reftable: handle interrupted reads
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]

There are calls to pread(3P) and read(3P) where we don't properly handle
interrupts. Convert them to use `pread_in_full()` and `read_in_full()`,
respectively.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/blocksource.c | 2 +-
 reftable/stack.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/reftable/blocksource.c b/reftable/blocksource.c
index 8331b34e82..a1ea304429 100644
--- a/reftable/blocksource.c
+++ b/reftable/blocksource.c
@@ -109,7 +109,7 @@ static int file_read_block(void *v, struct reftable_block *dest, uint64_t off,
 	struct file_block_source *b = v;
 	assert(off + size <= b->size);
 	dest->data = reftable_malloc(size);
-	if (pread(b->fd, dest->data, size, off) != size)
+	if (pread_in_full(b->fd, dest->data, size, off) != size)
 		return -1;
 	dest->len = size;
 	return size;
diff --git a/reftable/stack.c b/reftable/stack.c
index ddbdf1b9c8..ed108a929b 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -92,7 +92,7 @@ static int fd_read_lines(int fd, char ***namesp)
 	}
 
 	buf = reftable_malloc(size + 1);
-	if (read(fd, buf, size) != size) {
+	if (read_in_full(fd, buf, size) != size) {
 		err = REFTABLE_IO_ERROR;
 		goto done;
 	}
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* [PATCH 0/8] reftable: small set of fixes
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder

[-- Attachment #1: Type: text/plain, Size: 2095 bytes --]

Hi,

while working on the reftable backend I've hit several smaller issues in
the reftable library, which this patch series addresses.

We probably want to refactor t0032-reftable-unittest.sh to plug into the
new unit test architecture eventually, but for now I refrained from
doing so. I care more about getting things to a working state right now,
but I or somebody else from the Gitaly team will probably pick this
topic up later in this release cycle.

One issue I had was that this patch series starts to use more of the Git
infrastructure. Back when the library was introduced that there was some
discussion around whether it should work standalone or not, but if I
remember correctly the outcome was that it's okay to use internals like
e.g. `strbuf`. And while things like `read_in_full()` and related are
trivial wrappers, this patch series start to hook into the tempfiles
interface which I really didn't want to reimplement.

It's a bit unfortunate that we don't yet have good test coverage as
there are no end-to-end tests, and most of the changes I did are not
easily testable in unit tests. So until the reftable backend gets
submitted you'll have to trust my reasoning as layed out in the commit
messages that the changes actually improve things.

Patrick

Patrick Steinhardt (8):
  reftable: wrap EXPECT macros in do/while
  reftable: handle interrupted reads
  reftable: handle interrupted writes
  reftable/stack: verify that `reftable_stack_add()` uses
    auto-compaction
  reftable/stack: perform auto-compaction with transactional interface
  reftable/stack: reuse buffers when reloading stack
  reftable/merged: reuse buffer to compute record keys
  reftable/stack: fix stale lock when dying

 reftable/blocksource.c    |   2 +-
 reftable/merged.c         |  20 ++++----
 reftable/stack.c          |  71 ++++++++++----------------
 reftable/stack_test.c     | 105 +++++++++++++++++++++++++++++++++++++-
 reftable/test_framework.h |  58 +++++++++++----------
 5 files changed, 174 insertions(+), 82 deletions(-)

-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply

* [PATCH 1/8] reftable: wrap EXPECT macros in do/while
From: Patrick Steinhardt @ 2023-11-21  7:04 UTC (permalink / raw)
  To: git; +Cc: Han-Wen Nienhuys, Jonathan Nieder
In-Reply-To: <cover.1700549493.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 4427 bytes --]

The `EXPECT` macros used by the reftable test framework are all using a
single `if` statement with the actual condition. This results in weird
syntax when using them in if/else statements like the following:

```
if (foo)
	EXPECT(foo == 2)
else
	EXPECT(bar == 2)
```

Note that there need not be a trailing semicolon. Furthermore, it is not
immediately obvious whether the else now belongs to the `if (foo)` or
whether it belongs to the expanded `if (foo == 2)` from the macro.

Fix this by wrapping the macros in a do/while loop.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/test_framework.h | 58 +++++++++++++++++++++------------------
 1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/reftable/test_framework.h b/reftable/test_framework.h
index 774cb275bf..ee44f735ae 100644
--- a/reftable/test_framework.h
+++ b/reftable/test_framework.h
@@ -12,32 +12,38 @@ license that can be found in the LICENSE file or at
 #include "system.h"
 #include "reftable-error.h"
 
-#define EXPECT_ERR(c)                                                  \
-	if (c != 0) {                                                  \
-		fflush(stderr);                                        \
-		fflush(stdout);                                        \
-		fprintf(stderr, "%s: %d: error == %d (%s), want 0\n",  \
-			__FILE__, __LINE__, c, reftable_error_str(c)); \
-		abort();                                               \
-	}
-
-#define EXPECT_STREQ(a, b)                                               \
-	if (strcmp(a, b)) {                                              \
-		fflush(stderr);                                          \
-		fflush(stdout);                                          \
-		fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \
-			__LINE__, #a, a, #b, b);                         \
-		abort();                                                 \
-	}
-
-#define EXPECT(c)                                                          \
-	if (!(c)) {                                                        \
-		fflush(stderr);                                            \
-		fflush(stdout);                                            \
-		fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \
-			__LINE__, #c);                                     \
-		abort();                                                   \
-	}
+#define EXPECT_ERR(c)                                                          \
+	do {                                                                   \
+		if (c != 0) {                                                  \
+			fflush(stderr);                                        \
+			fflush(stdout);                                        \
+			fprintf(stderr, "%s: %d: error == %d (%s), want 0\n",  \
+				__FILE__, __LINE__, c, reftable_error_str(c)); \
+			abort();                                               \
+		}                                                              \
+	} while (0)
+
+#define EXPECT_STREQ(a, b)                                                       \
+	do {                                                                     \
+		if (strcmp(a, b)) {                                              \
+			fflush(stderr);                                          \
+			fflush(stdout);                                          \
+			fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \
+				__LINE__, #a, a, #b, b);                         \
+			abort();                                                 \
+		}                                                                \
+	} while (0)
+
+#define EXPECT(c)                                                                  \
+	do {                                                                       \
+		if (!(c)) {                                                        \
+			fflush(stderr);                                            \
+			fflush(stdout);                                            \
+			fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \
+				__LINE__, #c);                                     \
+			abort();                                                   \
+		}                                                                  \
+	} while (0)
 
 #define RUN_TEST(f)                          \
 	fprintf(stderr, "running %s\n", #f); \
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* KONFIDENCIALITĀTE
From: tele  Silvana Tenreyro @ 2023-11-20 21:06 UTC (permalink / raw)
  To: git

FYI: uz jūsu vārda ir nepieprasīti līdzekļi. Lūdzu, sazinieties 
ar S Tenreyro, rakstot uz e-pastu Silvanatenreyro@instaddr.uk, 
norādot savu pilnu vārdu un uzvārdu pretenzijai.

^ permalink raw reply

* Re: [PATCH 2/2] pretty: add '%aA' to show domain-part of email addresses
From: Junio C Hamano @ 2023-11-20 20:21 UTC (permalink / raw)
  To: Jeff King; +Cc: Kousik Sanagavarapu, Liam Beguin, git
In-Reply-To: <xmqqv8apgf4y.fsf@gitster.g>

Junio C Hamano <gitster@pobox.com> writes:

> Another line of thought is perhaps it is potentially useful to teach
> the --format= machinery to be a bit more programmable, e.g. allowing
> to compute a substring of an existing field %{%aE#*@} without having
> to waste a letter each for the local part and domain part.  But as I
> already said, we are now talking about "postprocessing", and adding
> complexity to our codebase only to have incomplete flexibility may
> not be worth it.  A more specific %(authoremail:localpart) and its
> domain counterpart may be easier to explain and understand.
>
> In any case, it is a bit too late to say "let's not waste the
> precious single letter namespace to add useless features", as we
> have come way too far, so I do not mind too much using a currently
> unused letter $X for yet another author and committer trait.

When I wrote the above, I somehow forgot the existing work in the
ref-filter (aka "for-each-ref") placeholders, where we have support
to a lot more flexible way to customize these things.

For example, "%(authoremail:mailmap,localpart)" can be used to say,
instead of wasting two letters 'l' and 'L' out of precious 52, that
we want e-mail address honoring the mailmap, and take only the local
part.  And the support for the host part of the address that this
topic discussed should be implementable fairly easily (just adding
EO_HOSTPART bit to the email_option structure would be sufficient)
on the ref-filter side.

We saw efforts from time to time to give "log --pretty=format:" more
of the good things from the "for-each-ref --format=" placeholders
(and vice versa), and it may give us a good way forward.


^ permalink raw reply

* [PATCH v2] merge-file: add --diff-algorithm option
From: Antonin Delpeuch via GitGitGadget @ 2023-11-20 19:18 UTC (permalink / raw)
  To: git; +Cc: Phillip Wood, Antonin Delpeuch, Antonin Delpeuch
In-Reply-To: <pull.1606.git.git.1699480494355.gitgitgadget@gmail.com>

From: Antonin Delpeuch <antonin@delpeuch.eu>

This makes it possible to use other diff algorithms than the 'myers'
default algorithm, when using the 'git merge-file' command. This helps
avoid spurious conflicts by selecting a more recent algorithm such as
'histogram', for instance when using 'git merge-file' as part of a custom
merge driver.

Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
Reviewed-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
    merge-file: add --diff-algorithm option
    
    Changes since v1:
    
     * improve commit message to mention the use case of custom merge
       drivers
     * improve documentation to show available options and recommend
       switching to "histogram"
     * add tests
    
    I have left out:
    
     * switching the default to "histogram", because it should only be done
       in a subsequent release
     * adding a configuration variable to control this option, because I was
       not sure how to call it. Perhaps "merge-file.diffAlgorithm"?

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1606%2Fwetneb%2Fmerge_file_configurable_diff_algorithm-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1606/wetneb/merge_file_configurable_diff_algorithm-v2
Pull-Request: https://github.com/git/git/pull/1606

Range-diff vs v1:

 1:  4aa453e30be ! 1:  842b5abf33c merge-file: add --diff-algorithm option
     @@ Commit message
          merge-file: add --diff-algorithm option
      
          This makes it possible to use other diff algorithms than the 'myers'
     -    default algorithm, when using the 'git merge-file' command.
     +    default algorithm, when using the 'git merge-file' command. This helps
     +    avoid spurious conflicts by selecting a more recent algorithm such as
     +    'histogram', for instance when using 'git merge-file' as part of a custom
     +    merge driver.
      
          Signed-off-by: Antonin Delpeuch <antonin@delpeuch.eu>
     +    Reviewed-by: Phillip Wood <phillip.wood@dunelm.org.uk>
      
       ## Documentation/git-merge-file.txt ##
      @@ Documentation/git-merge-file.txt: object store and the object ID of its blob is written to standard output.
       	Instead of leaving conflicts in the file, resolve conflicts
       	favouring our (or their or both) side of the lines.
       
     -+--diff-algorithm <algorithm>::
     -+	Use a different diff algorithm while merging, which can help
     ++--diff-algorithm={patience|minimal|histogram|myers}::
     ++	Use a different diff algorithm while merging. The current default is "myers",
     ++	but selecting more recent algorithm such as "histogram" can help
      +	avoid mismerges that occur due to unimportant matching lines
     -+	(such as braces from distinct functions).  See also
     ++	(such as braces from distinct functions). See also
      +	linkgit:git-diff[1] `--diff-algorithm`.
       
       EXAMPLES
     @@ builtin/merge-file.c: int cmd_merge_file(int argc, const char **argv, const char
       		OPT_INTEGER(0, "marker-size", &xmp.marker_size,
       			    N_("for conflicts, use this marker size")),
       		OPT__QUIET(&quiet, N_("do not warn about conflicts")),
     +
     + ## t/t6403-merge-file.sh ##
     +@@ t/t6403-merge-file.sh: test_expect_success 'setup' '
     + 	deduxit me super semitas jusitiae,
     + 	EOF
     + 
     +-	printf "propter nomen suum." >>new4.txt
     ++	printf "propter nomen suum." >>new4.txt &&
     ++
     ++	cat >base.c <<-\EOF &&
     ++	int f(int x, int y)
     ++	{
     ++		if (x == 0)
     ++		{
     ++			return y;
     ++		}
     ++		return x;
     ++	}
     ++
     ++	int g(size_t u)
     ++	{
     ++		while (u < 30)
     ++		{
     ++			u++;
     ++		}
     ++		return u;
     ++	}
     ++	EOF
     ++
     ++	cat >ours.c <<-\EOF &&
     ++	int g(size_t u)
     ++	{
     ++		while (u < 30)
     ++		{
     ++			u++;
     ++		}
     ++		return u;
     ++	}
     ++
     ++	int h(int x, int y, int z)
     ++	{
     ++		if (z == 0)
     ++		{
     ++			return x;
     ++		}
     ++		return y;
     ++	}
     ++	EOF
     ++
     ++	cat >theirs.c <<-\EOF
     ++	int f(int x, int y)
     ++	{
     ++		if (x == 0)
     ++		{
     ++			return y;
     ++		}
     ++		return x;
     ++	}
     ++
     ++	int g(size_t u)
     ++	{
     ++		while (u > 34)
     ++		{
     ++			u--;
     ++		}
     ++		return u;
     ++	}
     ++	EOF
     + '
     + 
     + test_expect_success 'merge with no changes' '
     +@@ t/t6403-merge-file.sh: test_expect_success '--object-id fails without repository' '
     + 	grep "not a git repository" err
     + '
     + 
     ++test_expect_success 'merging C files with "myers" diff algorithm creates some spurious conflicts' '
     ++	cat >expect.c <<-\EOF &&
     ++	int g(size_t u)
     ++	{
     ++		while (u < 30)
     ++		{
     ++			u++;
     ++		}
     ++		return u;
     ++	}
     ++
     ++	int h(int x, int y, int z)
     ++	{
     ++	<<<<<<< ours.c
     ++		if (z == 0)
     ++	||||||| base.c
     ++		while (u < 30)
     ++	=======
     ++		while (u > 34)
     ++	>>>>>>> theirs.c
     ++		{
     ++	<<<<<<< ours.c
     ++			return x;
     ++	||||||| base.c
     ++			u++;
     ++	=======
     ++			u--;
     ++	>>>>>>> theirs.c
     ++		}
     ++		return y;
     ++	}
     ++	EOF
     ++
     ++	test_must_fail git merge-file -p --diff3 --diff-algorithm myers ours.c base.c theirs.c >myers_output.c &&
     ++	test_cmp expect.c myers_output.c
     ++'
     ++
     ++test_expect_success 'merging C files with "histogram" diff algorithm avoids some spurious conflicts' '
     ++	cat >expect.c <<-\EOF &&
     ++	int g(size_t u)
     ++	{
     ++		while (u > 34)
     ++		{
     ++			u--;
     ++		}
     ++		return u;
     ++	}
     ++
     ++	int h(int x, int y, int z)
     ++	{
     ++		if (z == 0)
     ++		{
     ++			return x;
     ++		}
     ++		return y;
     ++	}
     ++	EOF
     ++
     ++	git merge-file -p --diff3 --diff-algorithm histogram ours.c base.c theirs.c >histogram_output.c &&
     ++	test_cmp expect.c histogram_output.c
     ++'
     ++
     + test_done


 Documentation/git-merge-file.txt |   6 ++
 builtin/merge-file.c             |  28 +++++++
 t/t6403-merge-file.sh            | 124 ++++++++++++++++++++++++++++++-
 3 files changed, 157 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-merge-file.txt b/Documentation/git-merge-file.txt
index 6a081eacb72..71915a00fa4 100644
--- a/Documentation/git-merge-file.txt
+++ b/Documentation/git-merge-file.txt
@@ -92,6 +92,12 @@ object store and the object ID of its blob is written to standard output.
 	Instead of leaving conflicts in the file, resolve conflicts
 	favouring our (or their or both) side of the lines.
 
+--diff-algorithm={patience|minimal|histogram|myers}::
+	Use a different diff algorithm while merging. The current default is "myers",
+	but selecting more recent algorithm such as "histogram" can help
+	avoid mismerges that occur due to unimportant matching lines
+	(such as braces from distinct functions). See also
+	linkgit:git-diff[1] `--diff-algorithm`.
 
 EXAMPLES
 --------
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 832c93d8d54..1f987334a31 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "diff.h"
 #include "hex.h"
 #include "object-name.h"
 #include "object-store.h"
@@ -28,6 +29,30 @@ static int label_cb(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
+static int set_diff_algorithm(xpparam_t *xpp,
+			      const char *alg)
+{
+	long diff_algorithm = parse_algorithm_value(alg);
+	if (diff_algorithm < 0)
+		return -1;
+	xpp->flags = (xpp->flags & ~XDF_DIFF_ALGORITHM_MASK) | diff_algorithm;
+	return 0;
+}
+
+static int diff_algorithm_cb(const struct option *opt,
+				const char *arg, int unset)
+{
+	xpparam_t *xpp = opt->value;
+
+	BUG_ON_OPT_NEG(unset);
+
+	if (set_diff_algorithm(xpp, arg))
+		return error(_("option diff-algorithm accepts \"myers\", "
+			       "\"minimal\", \"patience\" and \"histogram\""));
+
+	return 0;
+}
+
 int cmd_merge_file(int argc, const char **argv, const char *prefix)
 {
 	const char *names[3] = { 0 };
@@ -48,6 +73,9 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
 			    XDL_MERGE_FAVOR_THEIRS),
 		OPT_SET_INT(0, "union", &xmp.favor, N_("for conflicts, use a union version"),
 			    XDL_MERGE_FAVOR_UNION),
+		OPT_CALLBACK_F(0, "diff-algorithm", &xmp.xpp, N_("<algorithm>"),
+			     N_("choose a diff algorithm"),
+			     PARSE_OPT_NONEG, diff_algorithm_cb),
 		OPT_INTEGER(0, "marker-size", &xmp.marker_size,
 			    N_("for conflicts, use this marker size")),
 		OPT__QUIET(&quiet, N_("do not warn about conflicts")),
diff --git a/t/t6403-merge-file.sh b/t/t6403-merge-file.sh
index 2c92209ecab..fb872c5a113 100755
--- a/t/t6403-merge-file.sh
+++ b/t/t6403-merge-file.sh
@@ -56,7 +56,67 @@ test_expect_success 'setup' '
 	deduxit me super semitas jusitiae,
 	EOF
 
-	printf "propter nomen suum." >>new4.txt
+	printf "propter nomen suum." >>new4.txt &&
+
+	cat >base.c <<-\EOF &&
+	int f(int x, int y)
+	{
+		if (x == 0)
+		{
+			return y;
+		}
+		return x;
+	}
+
+	int g(size_t u)
+	{
+		while (u < 30)
+		{
+			u++;
+		}
+		return u;
+	}
+	EOF
+
+	cat >ours.c <<-\EOF &&
+	int g(size_t u)
+	{
+		while (u < 30)
+		{
+			u++;
+		}
+		return u;
+	}
+
+	int h(int x, int y, int z)
+	{
+		if (z == 0)
+		{
+			return x;
+		}
+		return y;
+	}
+	EOF
+
+	cat >theirs.c <<-\EOF
+	int f(int x, int y)
+	{
+		if (x == 0)
+		{
+			return y;
+		}
+		return x;
+	}
+
+	int g(size_t u)
+	{
+		while (u > 34)
+		{
+			u--;
+		}
+		return u;
+	}
+	EOF
 '
 
 test_expect_success 'merge with no changes' '
@@ -447,4 +507,66 @@ test_expect_success '--object-id fails without repository' '
 	grep "not a git repository" err
 '
 
+test_expect_success 'merging C files with "myers" diff algorithm creates some spurious conflicts' '
+	cat >expect.c <<-\EOF &&
+	int g(size_t u)
+	{
+		while (u < 30)
+		{
+			u++;
+		}
+		return u;
+	}
+
+	int h(int x, int y, int z)
+	{
+	<<<<<<< ours.c
+		if (z == 0)
+	||||||| base.c
+		while (u < 30)
+	=======
+		while (u > 34)
+	>>>>>>> theirs.c
+		{
+	<<<<<<< ours.c
+			return x;
+	||||||| base.c
+			u++;
+	=======
+			u--;
+	>>>>>>> theirs.c
+		}
+		return y;
+	}
+	EOF
+
+	test_must_fail git merge-file -p --diff3 --diff-algorithm myers ours.c base.c theirs.c >myers_output.c &&
+	test_cmp expect.c myers_output.c
+'
+
+test_expect_success 'merging C files with "histogram" diff algorithm avoids some spurious conflicts' '
+	cat >expect.c <<-\EOF &&
+	int g(size_t u)
+	{
+		while (u > 34)
+		{
+			u--;
+		}
+		return u;
+	}
+
+	int h(int x, int y, int z)
+	{
+		if (z == 0)
+		{
+			return x;
+		}
+		return y;
+	}
+	EOF
+
+	git merge-file -p --diff3 --diff-algorithm histogram ours.c base.c theirs.c >histogram_output.c &&
+	test_cmp expect.c histogram_output.c
+'
+
 test_done

base-commit: 98009afd24e2304bf923a64750340423473809ff
-- 
gitgitgadget

^ permalink raw reply related

* [ANNOUNCE] Git for Windows 2.43.0
From: Johannes Schindelin @ 2023-11-20 19:01 UTC (permalink / raw)
  To: git-for-windows, git, git-packagers; +Cc: Johannes Schindelin

Dear Git users,

I hereby announce that Git for Windows 2.43.0 is available from:

    https://gitforwindows.org/

Changes since Git for Windows v2.42.0(2) (August 30th 2023)

As announced previously, Git for Windows will drop support for Windows
7 and for Windows 8 in one of the next versions, following Cygwin's and
MSYS2's lead (Git for Windows relies on MSYS2 for components such as
Bash and Perl).

Following the footsteps of the MSYS2 and Cygwin projects on which Git
for Windows depends, the 32-bit variant of Git for Windows is being
phased out.

New Features

  * Comes with Git v2.43.0.
  * Comes with MSYS2 runtime v3.4.9.
  * Comes with GNU TLS v3.8.1.
  * When installing into a Windows setup with Mandatory Address Space
    Layout Randomization (ASLR) enabled, which is incompatible with the
    MSYS2 runtime powering Git Bash, SSH and some other programs
    distributed with Git for Windows, the Git for Windows installer now
    offers to add exceptions that will allow those programs to work as
    expected.
  * Comes with OpenSSH v9.5.P1.
  * Comes with cURL v8.4.0.
  * Comes with OpenSSL v3.1.4.
  * Comes with Git Credential Manager v2.4.1.
  * Comes with Bash v5.2.21.
  * Comes with MinTTY v3.7.0.

Bug Fixes

  * Symbolic links whose target is an absolute path without the drive
    prefix accidentally had a drive prefix added when checked out,
    rendering them "eternally modified". This bug has been fixed.
  * Git for Windows's installer is no longer confused by global GIT_*
    environment variables.
  * The installer no longer claims that "fast-forward or merge" is the
    default git pull behavior: The default behavior has changed in Git
    a while ago, to "fast-forward only".

Git-2.43.0-64-bit.exe | a6058d7c4c16bfa5bcd6fde051a92de8c68535fd7ebade55fc0ab1c41be3c8d5
Git-2.43.0-32-bit.exe | aee1587a4004c6a57b614c81fdc2ae1fa33de0daaf6b650cf6467e4253e024a9
PortableGit-2.43.0-64-bit.7z.exe | c76216d032685fa972d129eca30f8c9fb957eb9f46ccbce954e70e07d6211961
PortableGit-2.43.0-32-bit.7z.exe | c33f9aa7bf9c59e24db71b65e9d75b1e8532562175afef380119aa1eee90afd1
MinGit-2.43.0-64-bit.zip | 1905d93068e986258fafc69517df8fddff829bb2a289c1fa4dcc6cdf720ddf36
MinGit-2.43.0-32-bit.zip | d46fac9c17b55627f714aefa36c3b00d81651d2bb4076a12b4455b5f841f1a9e
MinGit-2.43.0-busybox-64-bit.zip | 2bd705f2c378ccbbf25a9095432aada3ac9dd2d963eff51421944beaccdc3e0c
MinGit-2.43.0-busybox-32-bit.zip | 70799d1f5b9d2469f44299ff33461efd7814531dd9bfb7ae912d1cbf83478162
Git-2.43.0-64-bit.tar.bz2 | 4c19cc73003e55ec71d6f1ce4a961ab32ca22f9c57217d224982535161123f79
Git-2.43.0-32-bit.tar.bz2 | 192f58080247f1eea2845fb61e37e91c05a89b44260c7e045b936ca3e45ac7f6

Ciao,
Johannes

^ permalink raw reply

* Re: [PATCH] object-name: reject too-deep recursive ancestor queries
From: Junio C Hamano @ 2023-11-20 17:14 UTC (permalink / raw)
  To: Taylor Blau
  Cc: git, Jeff King, Patrick Steinhardt,
	Carlos Andrés Ramírez Cataño
In-Reply-To: <57c0b30ddfe7c0ae78069682ff8454791e54469f.1700496801.git.me@ttaylorr.com>

Taylor Blau <me@ttaylorr.com> writes:

> Since this is a local-only exploit, a user would have to be tricked into
> running such a query by an adversary. Even if they were successfully
> tricked into running the malicious query, the blast radius is limited to
> a local stack overflow, which does not have meaningful paths to remote
> code execution, arbitrary memory reads, or any more grave security
> concerns.
> ...

So the difference in practice is if we make a controlled call to
die() or just let it crash?  It still does sound worthwhile thing to
do to make sure we make a controlled death.  But ...

> +static int get_nth_ancestor_max_depth = 4096;
> +static int get_nth_ancestor_curr_depth;

... do we have a lock at a much higher level that prevents multiple
name-to-oid look-ups from running simultaneously, or something
similar, to make use of this static counter safe?  I am not offhand
sure how safe it is to assume that we'd always be single-threaded.
This variable leaves a bad taste in my mouth.

I am not offhand sure how hard it is to count the depth per
callpath; get_oid_1() is the sole caller of get_nth_ancestor(), so
if you rename the former into a separate helper with a new
"recursion_depth" parameter, create a thin wrapper around it that
starts the recursion at depth 0 and have everybody else (i.e.,
peel_onion() and get_oid_with_context_1()) call it, and have
get_nth_ancestor increment (and die as needed) the counter, would
that be sufficient to ensure that we count the depth per call
invocation?

Thanks.

^ permalink raw reply

* What's cooking in git.git (Nov 2023, #08; Mon, 20)
From: Junio C Hamano @ 2023-11-20 17:01 UTC (permalink / raw)
  To: git

Here are the topics that have been cooking in my tree.  Commits
prefixed with '+' are in 'next' (being in 'next' is a sign that a
topic is stable enough to be used and are candidate to be in a
future release).  Commits prefixed with '-' are only in 'seen', and
aren't considered "accepted" at all and may be annotated with an URL
to a message that raises issues but they are no means exhaustive.  A
topic without enough support may be discarded after a long period of
no activity (of course they can be resubmit when new interests
arise).

Git 2.43 has been tagged.  With many folks are away from the
keyboard for vacation, I would expect it will be a very slow week.
I'll be taking a few weeks off, too, so please enjoy this release ;-).

Copies of the source code to Git live in many repositories, and the
following is a list of the ones I push into or their mirrors.  Some
repositories have only a subset of branches.

With maint, master, next, seen, todo:

	git://git.kernel.org/pub/scm/git/git.git/
	git://repo.or.cz/alt-git.git/
	https://kernel.googlesource.com/pub/scm/git/git/
	https://github.com/git/git/
	https://gitlab.com/git-vcs/git/

With all the integration branches and topics broken out:

	https://github.com/gitster/git/

Even though the preformatted documentation in HTML and man format
are not sources, they are published in these repositories for
convenience (replace "htmldocs" with "manpages" for the manual
pages):

	git://git.kernel.org/pub/scm/git/git-htmldocs.git/
	https://github.com/gitster/git-htmldocs.git/

Release tarballs are available at:

	https://www.kernel.org/pub/software/scm/git/

--------------------------------------------------
[Graduated to 'master']

* tz/send-email-helpfix (2023-11-16) 1 commit
  (merged to 'next' on 2023-11-17 at 8422271795)
 + send-email: remove stray characters from usage

 Typoes in "git send-email -h" have been corrected.
 source: <20231115173952.339303-3-tmz@pobox.com>


* vd/glossary-dereference-peel (2023-11-14) 1 commit
  (merged to 'next' on 2023-11-17 at bac3ab0c0b)
 + glossary: add definitions for dereference & peel

 "To dereference" and "to peel" were sometimes used in in-code
 comments and documentation but without description in the glossary.
 source: <pull.1610.v2.git.1699917471769.gitgitgadget@gmail.com>

--------------------------------------------------
[New Topics]

* ac/fuzz-show-date (2023-11-20) 1 commit
 - fuzz: add new oss-fuzz fuzzer for date.c / date.h

 Subject approxidate() and show_date() macchinery to OSS-Fuzz.

 Will merge to 'next'?
 source: <pull.1612.v4.git.1700243267653.gitgitgadget@gmail.com>


* js/packfile-h-typofix (2023-11-20) 1 commit
 - packfile.c: fix a typo in `each_file_in_pack_dir_fn()`'s declaration

 Typofix.

 Will merge to 'next'.
 source: <pull.1614.git.1700226915859.gitgitgadget@gmail.com>

--------------------------------------------------
[Stalled]

* pw/rebase-sigint (2023-09-07) 1 commit
 - rebase -i: ignore signals when forking subprocesses

 If the commit log editor or other external programs (spawned via
 "exec" insn in the todo list) receive internactive signal during
 "git rebase -i", it caused not just the spawned program but the
 "Git" process that spawned them, which is often not what the end
 user intended.  "git" learned to ignore SIGINT and SIGQUIT while
 waiting for these subprocesses.

 Expecting a reroll.
 cf. <12c956ea-330d-4441-937f-7885ab519e26@gmail.com>
 source: <pull.1581.git.1694080982621.gitgitgadget@gmail.com>


* tk/cherry-pick-sequence-requires-clean-worktree (2023-06-01) 1 commit
 - cherry-pick: refuse cherry-pick sequence if index is dirty

 "git cherry-pick A" that replays a single commit stopped before
 clobbering local modification, but "git cherry-pick A..B" did not,
 which has been corrected.

 Expecting a reroll.
 cf. <999f12b2-38d6-f446-e763-4985116ad37d@gmail.com>
 source: <pull.1535.v2.git.1685264889088.gitgitgadget@gmail.com>


* jc/diff-cached-fsmonitor-fix (2023-09-15) 3 commits
 - diff-lib: fix check_removed() when fsmonitor is active
 - Merge branch 'jc/fake-lstat' into jc/diff-cached-fsmonitor-fix
 - Merge branch 'js/diff-cached-fsmonitor-fix' into jc/diff-cached-fsmonitor-fix
 (this branch uses jc/fake-lstat.)

 The optimization based on fsmonitor in the "diff --cached"
 codepath is resurrected with the "fake-lstat" introduced earlier.

 It is unknown if the optimization is worth resurrecting, but in case...
 source: <xmqqr0n0h0tw.fsf@gitster.g>

--------------------------------------------------
[Cooking]

* jw/builtin-objectmode-attr (2023-11-16) 2 commits
 - SQUASH???
 - attr: add builtin objectmode values support

 The builtin_objectmode attribute is populated for each path
 without adding anything in .gitattributes files, which would be
 useful in magic pathspec, e.g., ":(attr:builtin_objectmode=100755)"
 to limit to executables.
 source: <20231116054437.2343549-1-jojwang@google.com>


* ps/ref-deletion-updates (2023-11-17) 4 commits
 - refs: remove `delete_refs` callback from backends
 - refs: deduplicate code to delete references
 - refs/files: use transactions to delete references
 - t5510: ensure that the packed-refs file needs locking

 Simplify API implementation to delete references by eliminating
 duplication.

 Will merge to 'next'.
 source: <cover.1699951815.git.ps@pks.im>


* tz/send-email-negatable-options (2023-11-17) 2 commits
  (merged to 'next' on 2023-11-17 at f09e533e43)
 + send-email: avoid duplicate specification warnings
 + perl: bump the required Perl version to 5.8.1 from 5.8.0

 Newer versions of Getopt::Long started giving warnings against our
 (ab)use of it in "git send-email".  Bump the minimum version
 requirement for Perl to 5.8.1 (from September 2002) to allow
 simplifying our implementation.

 Will cook in 'next'.
 source: <20231116193014.470420-1-tmz@pobox.com>


* js/ci-discard-prove-state (2023-11-14) 1 commit
  (merged to 'next' on 2023-11-14 at fade3ba143)
 + ci: avoid running the test suite _twice_
 (this branch uses ps/ci-gitlab.)

 The way CI testing used "prove" could lead to running the test
 suite twice needlessly, which has been corrected.

 Will cook in 'next'.
 source: <pull.1613.git.1699894837844.gitgitgadget@gmail.com>


* jk/chunk-bounds-more (2023-11-09) 9 commits
  (merged to 'next' on 2023-11-13 at 3df4b18bea)
 + commit-graph: mark chunk error messages for translation
 + commit-graph: drop verify_commit_graph_lite()
 + commit-graph: check order while reading fanout chunk
 + commit-graph: use fanout value for graph size
 + commit-graph: abort as soon as we see a bogus chunk
 + commit-graph: clarify missing-chunk error messages
 + commit-graph: drop redundant call to "lite" verification
 + midx: check consistency of fanout table
 + commit-graph: handle overflow in chunk_size checks
 (this branch is used by tb/pair-chunk-expect.)

 Code clean-up for jk/chunk-bounds topic.

 Will cook in 'next'.
 source: <20231109070310.GA2697602@coredump.intra.peff.net>


* ps/httpd-tests-on-nixos (2023-11-11) 3 commits
  (merged to 'next' on 2023-11-13 at 81bd6f5334)
 + t9164: fix inability to find basename(1) in Subversion hooks
 + t/lib-httpd: stop using legacy crypt(3) for authentication
 + t/lib-httpd: dynamically detect httpd and modules path

 Portability tweak.

 Will cook in 'next'.
 source: <cover.1699596457.git.ps@pks.im>


* ss/format-patch-use-encode-headers-for-cover-letter (2023-11-10) 1 commit
  (merged to 'next' on 2023-11-14 at 1a4bd59e15)
 + format-patch: fix ignored encode_email_headers for cover letter

 "git format-patch --encode-email-headers" ignored the option when
 preparing the cover letter, which has been corrected.

 Will cook in 'next'.
 source: <20231109111950.387219-1-contact@emersion.fr>


* ps/ban-a-or-o-operator-with-test (2023-11-11) 4 commits
  (merged to 'next' on 2023-11-14 at d84471baab)
 + Makefile: stop using `test -o` when unlinking duplicate executables
 + contrib/subtree: convert subtree type check to use case statement
 + contrib/subtree: stop using `-o` to test for number of args
 + global: convert trivial usages of `test <expr> -a/-o <expr>`

 Test and shell scripts clean-up.

 Will cook in 'next'.
 source: <cover.1699609940.git.ps@pks.im>


* ak/rebase-autosquash (2023-11-16) 3 commits
  (merged to 'next' on 2023-11-17 at 3ed6e79445)
 + rebase: rewrite --(no-)autosquash documentation
 + rebase: support --autosquash without -i
 + rebase: fully ignore rebase.autoSquash without -i

 "git rebase --autosquash" is now enabled for non-interactive rebase,
 but it is still incompatible with the apply backend.

 Will cook in 'next'.
 source: <20231114214339.10925-1-andy.koppe@gmail.com>


* vd/for-each-ref-unsorted-optimization (2023-11-16) 10 commits
  (merged to 'next' on 2023-11-17 at ff99420bf6)
 + t/perf: add perf tests for for-each-ref
 + ref-filter.c: use peeled tag for '*' format fields
 + for-each-ref: clean up documentation of --format
 + ref-filter.c: filter & format refs in the same callback
 + ref-filter.c: refactor to create common helper functions
 + ref-filter.c: rename 'ref_filter_handler()' to 'filter_one()'
 + ref-filter.h: add functions for filter/format & format-only
 + ref-filter.h: move contains caches into filter
 + ref-filter.h: add max_count and omit_empty to ref_format
 + ref-filter.c: really don't sort when using --no-sort

 "git for-each-ref --no-sort" still sorted the refs alphabetically
 which paid non-trivial cost.  It has been redefined to show output
 in an unspecified order, to allow certain optimizations to take
 advantage of.

 Will cook in 'next'.
 source: <pull.1609.v2.git.1699991638.gitgitgadget@gmail.com>


* jw/git-add-attr-pathspec (2023-11-04) 1 commit
  (merged to 'next' on 2023-11-13 at b61be94e4d)
 + attr: enable attr pathspec magic for git-add and git-stash

 "git add" and "git stash" learned to support the ":(attr:...)"
 magic pathspec.

 Will cook in 'next'.
 source: <20231103163449.1578841-1-jojwang@google.com>


* ps/ci-gitlab (2023-11-09) 8 commits
  (merged to 'next' on 2023-11-10 at ea7ed67945)
 + ci: add support for GitLab CI
 + ci: install test dependencies for linux-musl
 + ci: squelch warnings when testing with unusable Git repo
 + ci: unify setup of some environment variables
 + ci: split out logic to set up failed test artifacts
 + ci: group installation of Docker dependencies
 + ci: make grouping setup more generic
 + ci: reorder definitions for grouping functions
 (this branch is used by js/ci-discard-prove-state.)

 Add support for GitLab CI.

 Will cook in 'next'.
 source: <cover.1699514143.git.ps@pks.im>


* ps/ref-tests-update (2023-11-03) 10 commits
  (merged to 'next' on 2023-11-13 at dc26e55d6f)
 + t: mark several tests that assume the files backend with REFFILES
 + t7900: assert the absence of refs via git-for-each-ref(1)
 + t7300: assert exact states of repo
 + t4207: delete replace references via git-update-ref(1)
 + t1450: convert tests to remove worktrees via git-worktree(1)
 + t: convert tests to not access reflog via the filesystem
 + t: convert tests to not access symrefs via the filesystem
 + t: convert tests to not write references via the filesystem
 + t: allow skipping expected object ID in `ref-store update-ref`
 + Merge branch 'ps/show-ref' into ps/ref-tests-update

 Update ref-related tests.

 Will cook in 'next'.
 source: <cover.1698914571.git.ps@pks.im>


* jx/fetch-atomic-error-message-fix (2023-10-19) 2 commits
 - fetch: no redundant error message for atomic fetch
 - t5574: test porcelain output of atomic fetch

 "git fetch --atomic" issued an unnecessary empty error message,
 which has been corrected.

 Expecting an update.
 cf. <ZTjQIrCgSANAT8wR@tanuki>
 source: <ced46baeb1c18b416b4b4cc947f498bea2910b1b.1697725898.git.zhiyou.jx@alibaba-inc.com>


* js/bugreport-in-the-same-minute (2023-10-16) 1 commit
 - bugreport: include +i in outfile suffix as needed

 Instead of auto-generating a filename that is already in use for
 output and fail the command, `git bugreport` learned to fuzz the
 filename to avoid collisions with existing files.

 Expecting a reroll.
 cf. <ZTtZ5CbIGETy1ucV.jacob@initialcommit.io>
 source: <20231016214045.146862-2-jacob@initialcommit.io>


* kh/t7900-cleanup (2023-10-17) 9 commits
 - t7900: fix register dependency
 - t7900: factor out packfile dependency
 - t7900: fix `print-args` dependency
 - t7900: fix `pfx` dependency
 - t7900: factor out common schedule setup
 - t7900: factor out inheritance test dependency
 - t7900: create commit so that branch is born
 - t7900: setup and tear down clones
 - t7900: remove register dependency

 Test clean-up.

 Perhaps discard?
 cf. <655ca147-c214-41be-919d-023c1b27b311@app.fastmail.com>
 source: <cover.1697319294.git.code@khaugsbakk.name>


* tb/merge-tree-write-pack (2023-10-23) 5 commits
 - builtin/merge-tree.c: implement support for `--write-pack`
 - bulk-checkin: introduce `index_tree_bulk_checkin_incore()`
 - bulk-checkin: introduce `index_blob_bulk_checkin_incore()`
 - bulk-checkin: generify `stream_blob_to_pack()` for arbitrary types
 - bulk-checkin: extract abstract `bulk_checkin_source`

 "git merge-tree" learned "--write-pack" to record its result
 without creating loose objects.

 Broken when an object created during a merge is needed to continue merge
 cf. <CABPp-BEfy9VOvimP9==ry_rZXu=metOQ8s=_-XiG_Pdx9c06Ww@mail.gmail.com>
 source: <cover.1698101088.git.me@ttaylorr.com>


* tb/pair-chunk-expect (2023-11-10) 8 commits
 - midx: read `OOFF` chunk with `pair_chunk_expect()`
 - midx: read `OIDL` chunk with `pair_chunk_expect()`
 - commit-graph: read `BIDX` chunk with `pair_chunk_expect()`
 - commit-graph: read `GDAT` chunk with `pair_chunk_expect()`
 - commit-graph: read `CDAT` chunk with `pair_chunk_expect()`
 - commit-graph: read `OIDL` chunk with `pair_chunk_expect()`
 - chunk-format: introduce `pair_chunk_expect()` helper
 - Merge branch 'jk/chunk-bounds-more' into HEAD
 (this branch uses jk/chunk-bounds-more.)

 Further code clean-up.

 Needs review.
 source: <cover.1699569246.git.me@ttaylorr.com>


* tb/path-filter-fix (2023-10-18) 17 commits
 - bloom: introduce `deinit_bloom_filters()`
 - commit-graph: reuse existing Bloom filters where possible
 - object.h: fix mis-aligned flag bits table
 - commit-graph: drop unnecessary `graph_read_bloom_data_context`
 - commit-graph.c: unconditionally load Bloom filters
 - bloom: prepare to discard incompatible Bloom filters
 - bloom: annotate filters with hash version
 - commit-graph: new filter ver. that fixes murmur3
 - repo-settings: introduce commitgraph.changedPathsVersion
 - t4216: test changed path filters with high bit paths
 - t/helper/test-read-graph: implement `bloom-filters` mode
 - bloom.h: make `load_bloom_filter_from_graph()` public
 - t/helper/test-read-graph.c: extract `dump_graph_info()`
 - gitformat-commit-graph: describe version 2 of BDAT
 - commit-graph: ensure Bloom filters are read with consistent settings
 - revision.c: consult Bloom filters for root commits
 - t/t4216-log-bloom.sh: harden `test_bloom_filters_not_used()`

 The Bloom filter used for path limited history traversal was broken
 on systems whose "char" is unsigned; update the implementation and
 bump the format version to 2.

 Needs (hopefully final and quick) review.
 source: <cover.1697653929.git.me@ttaylorr.com>


* cc/git-replay (2023-11-16) 14 commits
 - replay: stop assuming replayed branches do not diverge
 - replay: add --contained to rebase contained branches
 - replay: add --advance or 'cherry-pick' mode
 - replay: use standard revision ranges
 - replay: make it a minimal server side command
 - replay: remove HEAD related sanity check
 - replay: remove progress and info output
 - replay: add an important FIXME comment about gpg signing
 - replay: change rev walking options
 - replay: introduce pick_regular_commit()
 - replay: die() instead of failing assert()
 - replay: start using parse_options API
 - replay: introduce new builtin
 - t6429: remove switching aspects of fast-rebase

 Introduce "git replay", a tool meant on the server side without
 working tree to recreate a history.
 source: <20231115143327.2441397-1-christian.couder@gmail.com>


* ak/color-decorate-symbols (2023-10-23) 7 commits
 - log: add color.decorate.pseudoref config variable
 - refs: exempt pseudorefs from pattern prefixing
 - refs: add pseudorefs array and iteration functions
 - log: add color.decorate.ref config variable
 - log: add color.decorate.symbol config variable
 - log: use designated inits for decoration_colors
 - config: restructure color.decorate documentation

 A new config for coloring.

 Needs review.
 source: <20231023221143.72489-1-andy.koppe@gmail.com>


* js/update-urls-in-doc-and-comment (2023-09-26) 4 commits
 - doc: refer to internet archive
 - doc: update links for andre-simon.de
 - doc: update links to current pages
 - doc: switch links to https

 Stale URLs have been updated to their current counterparts (or
 archive.org) and HTTP links are replaced with working HTTPS links.

 Needs review.
 source: <pull.1589.v2.git.1695553041.gitgitgadget@gmail.com>


* la/trailer-cleanups (2023-10-20) 3 commits
 - trailer: use offsets for trailer_start/trailer_end
 - trailer: find the end of the log message
 - commit: ignore_non_trailer computes number of bytes to ignore

 Code clean-up.

 Comments?
 source: <pull.1563.v5.git.1697828495.gitgitgadget@gmail.com>


* eb/hash-transition (2023-10-02) 30 commits
 - t1016-compatObjectFormat: add tests to verify the conversion between objects
 - t1006: test oid compatibility with cat-file
 - t1006: rename sha1 to oid
 - test-lib: compute the compatibility hash so tests may use it
 - builtin/ls-tree: let the oid determine the output algorithm
 - object-file: handle compat objects in check_object_signature
 - tree-walk: init_tree_desc take an oid to get the hash algorithm
 - builtin/cat-file: let the oid determine the output algorithm
 - rev-parse: add an --output-object-format parameter
 - repository: implement extensions.compatObjectFormat
 - object-file: update object_info_extended to reencode objects
 - object-file-convert: convert commits that embed signed tags
 - object-file-convert: convert commit objects when writing
 - object-file-convert: don't leak when converting tag objects
 - object-file-convert: convert tag objects when writing
 - object-file-convert: add a function to convert trees between algorithms
 - object: factor out parse_mode out of fast-import and tree-walk into in object.h
 - cache: add a function to read an OID of a specific algorithm
 - tag: sign both hashes
 - commit: export add_header_signature to support handling signatures on tags
 - commit: convert mergetag before computing the signature of a commit
 - commit: write commits for both hashes
 - object-file: add a compat_oid_in parameter to write_object_file_flags
 - object-file: update the loose object map when writing loose objects
 - loose: compatibilty short name support
 - loose: add a mapping between SHA-1 and SHA-256 for loose objects
 - repository: add a compatibility hash algorithm
 - object-names: support input of oids in any supported hash
 - oid-array: teach oid-array to handle multiple kinds of oids
 - object-file-convert: stubs for converting from one object format to another

 Teach a repository to work with both SHA-1 and SHA-256 hash algorithms.

 Needs review.
 source: <878r8l929e.fsf@gmail.froward.int.ebiederm.org>


* jx/remote-archive-over-smart-http (2023-10-04) 4 commits
 - archive: support remote archive from stateless transport
 - transport-helper: call do_take_over() in connect_helper
 - transport-helper: call do_take_over() in process_connect
 - transport-helper: no connection restriction in connect_helper

 "git archive --remote=<remote>" learned to talk over the smart
 http (aka stateless) transport.

 Needs review.
 source: <cover.1696432593.git.zhiyou.jx@alibaba-inc.com>


* jx/sideband-chomp-newline-fix (2023-10-04) 3 commits
 - pkt-line: do not chomp newlines for sideband messages
 - pkt-line: memorize sideband fragment in reader
 - test-pkt-line: add option parser for unpack-sideband

 Sideband demultiplexer fixes.

 Needs review.
 source: <cover.1696425168.git.zhiyou.jx@alibaba-inc.com>


* js/config-parse (2023-09-21) 5 commits
 - config-parse: split library out of config.[c|h]
 - config.c: accept config_parse_options in git_config_from_stdin
 - config: report config parse errors using cb
 - config: split do_event() into start and flush operations
 - config: split out config_parse_options

 The parsing routines for the configuration files have been split
 into a separate file.

 Needs review.
 source: <cover.1695330852.git.steadmon@google.com>


* jc/fake-lstat (2023-09-15) 1 commit
 - cache: add fake_lstat()
 (this branch is used by jc/diff-cached-fsmonitor-fix.)

 A new helper to let us pretend that we called lstat() when we know
 our cache_entry is up-to-date via fsmonitor.

 Needs review.
 source: <xmqqcyykig1l.fsf@gitster.g>


* js/doc-unit-tests (2023-11-10) 3 commits
  (merged to 'next' on 2023-11-10 at 7d00ffd06b)
 + ci: run unit tests in CI
 + unit tests: add TAP unit test framework
 + unit tests: add a project plan document
 (this branch is used by js/doc-unit-tests-with-cmake.)

 Process to add some form of low-level unit tests has started.

 Will cook in 'next'.
 source: <cover.1699555664.git.steadmon@google.com>


* js/doc-unit-tests-with-cmake (2023-11-10) 7 commits
  (merged to 'next' on 2023-11-10 at b4503c9c8c)
 + cmake: handle also unit tests
 + cmake: use test names instead of full paths
 + cmake: fix typo in variable name
 + artifacts-tar: when including `.dll` files, don't forget the unit-tests
 + unit-tests: do show relative file paths
 + unit-tests: do not mistake `.pdb` files for being executable
 + cmake: also build unit tests
 (this branch uses js/doc-unit-tests.)

 Update the base topic to work with CMake builds.

 Will cook in 'next'.
 source: <pull.1579.v3.git.1695640836.gitgitgadget@gmail.com>


* jc/rerere-cleanup (2023-08-25) 4 commits
 - rerere: modernize use of empty strbuf
 - rerere: try_merge() should use LL_MERGE_ERROR when it means an error
 - rerere: fix comment on handle_file() helper
 - rerere: simplify check_one_conflict() helper function

 Code clean-up.

 Not ready to be reviewed yet.
 source: <20230824205456.1231371-1-gitster@pobox.com>


* rj/status-bisect-while-rebase (2023-10-16) 1 commit
 - status: fix branch shown when not only bisecting

 "git status" is taught to show both the branch being bisected and
 being rebased when both are in effect at the same time.

 Needs review.
 source: <2e24ca9b-9c5f-f4df-b9f8-6574a714dfb2@gmail.com>

--------------------------------------------------
[Discarded]

* jc/strbuf-comment-line-char (2023-11-01) 4 commits
 . strbuf: move env-using functions to environment.c
 . strbuf: make add_lines() public
 . strbuf_add_commented_lines(): drop the comment_line_char parameter
 . strbuf_commented_addf(): drop the comment_line_char parameter

 Code simplification that goes directly against a past libification
 topic.  It is hard to judge because the "libification" is done
 piecewise without seemingly clear design principle.

 Will discard.
 source: <cover.1698791220.git.jonathantanmy@google.com>

^ permalink raw reply

* [ANNOUNCE] Git v2.43.0
From: Junio C Hamano @ 2023-11-20 17:01 UTC (permalink / raw)
  To: git; +Cc: Linux Kernel, git-packagers

The latest feature release Git v2.43.0 is now available at the
usual places.  It is comprised of 464 non-merge commits since
v2.42.0, contributed by 80 people, 17 of which are new faces [*].

The tarballs are found at:

    https://www.kernel.org/pub/software/scm/git/

The following public repositories all have a copy of the 'v2.43.0'
tag and the 'master' branch that the tag points at:

  url = https://git.kernel.org/pub/scm/git/git
  url = https://kernel.googlesource.com/pub/scm/git/git
  url = git://repo.or.cz/alt-git.git
  url = https://github.com/gitster/git

New contributors whose contributions weren't in v2.42.0 are as follows.
Welcome to the Git development community!

  Aditya Neelamraju, Alyssa Ross, Caleb Hill, Dorcas AnonoLitunya,
  Dragan Simic, Isoken June Ibizugbe, Jan Alexander Steffens
  (heftig), Javier Mora, ks1322 ks1322, Mark Ruvald Pedersen,
  Matthew McClain, Naomi Ibe, Romain Chossart, Tang Yuyi, Vipul
  Kumar, 王常新, and 谢致邦 (XIE Zhibang).

Returning contributors who helped this release are as follows.
Thanks for your continued support.

  Ævar Arnfjörð Bjarmason, Alexander Shopov, Andrei Rybak,
  Andy Koppe, Arkadii Yakovets, Bagas Sanjaya, Beat Bolli, brian
  m. carlson, Calvin Wan, Christian Couder, Christian Hesse,
  Derrick Stolee, Drew DeVault, Elijah Newren, Emily Shaffer,
  Emir SARI, Eric W. Biederman, Eric Wong, Evan Gates, Han Young,
  Hariom Verma, Jacob Abel, Jacob Stopak, Jason Hatton, Jean-Noël
  Avila, Jeff King, Johannes Schindelin, John Cai, Jordi Mas,
  Josh Soref, Josip Sokcevic, Junio C Hamano, Karthik Nayak,
  Kate Golovanova, Kousik Sanagavarapu, Kristoffer Haugsbakk,
  Linus Arver, Mark Levedahl, Martin Ågren, Martin Storsjö,
  M Hickford, Michael Strawbridge, Michal Suchanek, Oswald
  Buddenhagen, Patrick Steinhardt, Peter Krefting, Philippe Blain,
  Phillip Wood, Ralf Thielow, Randall S. Becker, René Scharfe,
  Robert Coup, Rubén Justo, Sergey Organov, Shuqi Liang, Stefan
  Haller, Štěpán Němec, Taylor Blau, Teng Long, Todd Zullinger,
  Victoria Dye, Wesley Schwengle, and Yi-Jyun Pan.

[*] We are counting not just the authorship contribution but issue
    reporting, mentoring, helping and reviewing that are recorded in
    the commit trailers.

----------------------------------------------------------------

Git v2.43 Release Notes
=======================

Backward Compatibility Notes

 * The "--rfc" option of "git format-patch" used to be a valid way to
   override an earlier "--subject-prefix=<something>" on the command
   line and replace it with "[RFC PATCH]", but from this release, it
   merely prefixes the string "RFC " in front of the given subject
   prefix.  If you are negatively affected by this change, please use
   "--subject-prefix=PATCH --rfc" as a replacement.

 * In Git 2.42, "git rev-list --stdin" learned to take non-revisions
   (like "--not") from the standard input, but the way such a "--not" was
   handled was quite confusing, which has been rethought.  The updated
   rule is that "--not" given from the command line only affects revs
   given from the command line that comes but not revs read from the
   standard input, and "--not" read from the standard input affects
   revs given from the standard input and not revs given from the
   command line.

UI, Workflows & Features

 * A message written in olden time prevented a branch from getting
   checked out, saying it is already checked out elsewhere. But these
   days, we treat a branch that is being bisected or rebased just like
   a branch that is checked out and protect it from getting modified
   with the same codepath.  The message has been rephrased to say that
   the branch is "in use" to avoid confusion.

 * Hourly and other schedules of "git maintenance" jobs are randomly
   distributed now.

 * "git cmd -h" learned to signal which options can be negated by
   listing such options like "--[no-]opt".

 * The way authentication related data other than passwords (e.g.,
   oauth token and password expiration data) are stored in libsecret
   keyrings has been rethought.

 * Update the libsecret and wincred credential helpers to correctly
   match which credential to erase; they erased the wrong entry in
   some cases.

 * Git GUI updates.

 * "git format-patch" learned a new "--description-file" option that
   lets cover letter description to be fed; this can be used on
   detached HEAD where there is no branch description available, and
   also can override the branch description if there is one.

 * Use of the "--max-pack-size" option to allow multiple packfiles to
   be created is now supported even when we are sending unreachable
   objects to cruft packs.

 * "git format-patch --rfc --subject-prefix=<foo>" used to ignore the
   "--subject-prefix" option and used "[RFC PATCH]"; now we will add
   "RFC" prefix to whatever subject prefix is specified.

 * "git log --format" has been taught the %(decorate) placeholder for
   further customization over what the "--decorate" option offers.

 * The default log message created by "git revert", when reverting a
   commit that records a revert, has been tweaked, to encourage people
   to describe complex "revert of revert of revert" situations better in
   their own words.

 * The command-line completion support (in contrib/) learned to
   complete "git commit --trailer=" for possible trailer keys.

 * "git update-index" learned the "--show-index-version" option to
   inspect the index format version used by the on-disk index file.

 * "git diff" learned the "diff.statNameWidth" configuration variable,
   to give the default width for the name part in the "--stat" output.

 * "git range-diff --notes=foo" compared "log --notes=foo --notes" of
   the two ranges, instead of using just the specified notes tree,
   which has been corrected to use only the specified notes tree.

 * The command line completion script (in contrib/) can be told to
   complete aliases by including ": git <cmd> ;" in the alias to tell
   it that the alias should be completed in a similar way to how "git
   <cmd>" is completed.  The parsing code for the alias has been
   loosened to allow ';' without an extra space before it.

 * "git for-each-ref" and friends learned to apply mailmap to
   authorname and other fields in a more flexible way than using
   separate placeholder letters like %a[eElL] every time we want to
   come up with small variants.

 * "git repack" machinery learned to pay attention to the "--filter="
   option.

 * "git repack" learned the "--max-cruft-size" option to prevent cruft
   packs from growing without bounds.

 * "git merge-tree" learned to take strategy backend specific options
   via the "-X" option, like "git merge" does.

 * "git log" and friends learned the "--dd" option that is a
   short-hand for "--diff-merges=first-parent -p".

 * The attribute subsystem learned to honor the "attr.tree"
   configuration variable that specifies which tree to read the
   .gitattributes files from.

 * "git merge-file" learns a mode to read three variants of the
   contents to be merged from blob objects.


Performance, Internal Implementation, Development Support etc.

 * "git check-attr" has been taught to work better with sparse-index.

 * It may be tempting to leave the help text NULL for a command line
   option that is either hidden or too obvious, but "git subcmd -h"
   and "git subcmd --help-all" would have segfaulted if done so.  Now
   the help text is truly optional.

 * Tests that are known to pass with LSan are now marked as such.

 * Flaky "git p4" tests, as well as "git svn" tests, are now skipped
   in the (rather expensive) sanitizer CI job.

 * Tests with LSan from time to time seem to emit harmless messages
   that make our tests unnecessarily flaky; we work around it by
   filtering the uninteresting output.

 * Unused parameters to functions are marked as such, and/or removed,
   in order to bring us closer to "-Wunused-parameter" clean.

 * The code to keep track of existing packs in the repository while
   repacking has been refactored.

 * The "streaming" interface used for bulk-checkin codepath has been
   narrowed to take only blob objects for now, with no real loss of
   functionality.

 * GitHub CI workflow has learned to trigger Coverity check.

 * Test coverage for trailers has been improved.

 * The code to iterate over loose references has been optimized to
   reduce the number of lstat() system calls.

 * The codepaths that read "chunk" formatted files have been corrected
   to pay attention to the chunk size and notice broken files.

 * Replace macos-12 used at GitHub CI with macos-13.
   (merge 682a868f67 js/ci-use-macos-13 later to maint).


Fixes since v2.42
-----------------

 * Overly long label names used in the sequencer machinery are now
   chopped to fit under filesystem limitation.

 * Scalar updates.

 * Tweak GitHub Actions CI so that pushing the same commit to multiple
   branch tips at the same time will not waste building and testing
   the same thing twice.

 * The commit-graph verification code that detects a mixture of zero and
   non-zero generation numbers has been updated.

 * "git diff -w --exit-code" with various options did not work
   correctly, which has been corrected.

 * The "transfer.unpackLimit" configuration variable ought to be used
   as a fallback, but overrode the more specific "fetch.unpackLimit"
   and "receive.unpackLimit" configuration variables by mistake, which
   has been corrected.

 * The use of API between two calls to require_clean_work_tree() from
   the sequencer code has been cleaned up for consistency.

 * "git diff --no-such-option" and other corner cases around the exit
   status of the "diff" command have been corrected.

 * "git for-each-ref --sort='contents:size'" sorted the refs according
   to size numerically, giving a ref that points at a blob twelve-byte
   (12) long before showing a blob hundred-byte (100) long, which has
   been corrected.

 * We now limit the depth of the tree objects and maximum length of
   pathnames recorded in tree objects.
   (merge 4d5693ba05 jk/tree-name-and-depth-limit later to maint).

 * Various fixes to the behavior of "rebase -i", when the command got
   interrupted by conflicting changes, have been made.

 * References from a description of the `--patch` option in various
   manual pages have been simplified and improved.

 * "git grep -e A --no-or -e B" is accepted, even though the negation
   of the "--or" option did not mean anything, which has been tightened.

 * The completion script (in contrib/) has been taught to treat the
   "-t" option to "git checkout" and "git switch" just like the
   "--track" option, to complete remote-tracking branches.

 * "git diff --no-index -R <(one) <(two)" did not work correctly,
   which has been corrected.

 * "git maintenance" timers' implementation has been updated, based on
   systemd timers, to work with WSL.

 * "git diff --cached" codepath did not fill the necessary stat
   information for a file when fsmonitor knows it is clean and ended
   up behaving as if it were not clean, which has been corrected.

 * How "alias.foo = : git cmd ; aliased-command-string" should be
   spelled with necessary whitespace around punctuation marks to work
   has been more clearly documented (but this will be moot with newer
   versions of Git where the parsing rules have been improved).

 * HTTP Header redaction code has been adjusted for a newer version of
   cURL library that shows its traces differently from earlier
   versions.

 * An error message given by "git send-email", when given a malformed
   address, did not show the offending address, which has been corrected.

 * UBSan options were not propagated through the test framework to git
   run via the httpd, unlike ASan options, which has been corrected.

 * "checkout --merge -- path" and "update-index --unresolve path" did
   not resurrect conflicted state that was resolved to remove path,
   but now they do.
   (merge 5bdedac3c7 jc/unresolve-removal later to maint).

 * The display width table for unicode characters has been updated for
   Unicode 15.1
   (merge 872976c37e bb/unicode-width-table-15 later to maint).

 * Update mailmap entry for Derrick.
   (merge 6e5457d8c7 ds/mailmap-entry-update later to maint).

 * In the ".gitmodules" files, submodules are keyed by their names,
   and the path to the submodule whose name is $name is specified by
   the submodule.$name.path variable.  There were a few codepaths that
   mixed the name and path up when consulting the submodule database,
   which have been corrected.  It took long for these bugs to be found
   as the name of a submodule initially is the same as its path, and
   the problem does not surface until it is moved to a different path,
   which apparently happens very rarely.

 * "git diff --merge-base X other args..." insisted that X must be a
   commit and errored out when given an annotated tag that peels to a
   commit, but we only need it to be a committish.  This has been
   corrected.
   (merge 4adceb5a29 ar/diff-index-merge-base-fix later to maint).

 * "git merge-tree" used to segfault when the "--attr-source"
   option is used, which has been corrected.
   (merge e95bafc52f jc/merge-ort-attr-index-fix later to maint).

 * Unlike "git log --pretty=%D", "git log --pretty="%(decorate)" did
   not auto-initialize the decoration subsystem, which has been
   corrected.

 * Feeding "git stash store" with a random commit that was not created
   by "git stash create" now errors out.
   (merge d9b6634589 jc/fail-stash-to-store-non-stash later to maint).

 * The index file has room only for the lower 32-bit of the file size in
   the cached stat information, which means cached stat information
   will have 0 in its sd_size member for a file whose size is a multiple
   of 4GiB.  This is mistaken for a racily clean path.  Avoid it by
   storing a bogus sd_size value instead for such files.
   (merge 5143ac07b1 bc/racy-4gb-files later to maint).

 * "git p4" tried to store symlinks to LFS when told, but has been
   fixed not to do so, because it does not make sense.
   (merge 10c89a02b0 mm/p4-symlink-with-lfs later to maint).

 * The codepath to handle recipient addresses `git send-email
   --compose` learns from the user was completely broken, which has
   been corrected.
   (merge 3ec6167567 jk/send-email-fix-addresses-from-composed-messages later to maint).

 * "cd sub && git grep -f patterns" tried to read "patterns" file at
   the top level of the working tree; it has been corrected to read
   "sub/patterns" instead.

 * "git reflog expire --single-worktree" has been broken for the past
   20 months or so, which has been corrected.

 * "git send-email" did not have certain pieces of data computed yet
   when it tried to validate the outgoing messages and its recipient
   addresses, which has been sorted out.

 * "git bugreport" learned to complain when it received a command line
   argument that it will not use.

 * The codepath to traverse the commit-graph learned to notice that a
   commit is missing (e.g., corrupt repository lost an object), even
   though it knows something about the commit (like its parents) from
   what is in commit-graph.
   (merge 7a5d604443 ps/do-not-trust-commit-graph-blindly-for-existence later to maint).

 * "git rev-list --missing" did not work for missing commit objects,
   which has been corrected.

 * "git rev-list --unpacked --objects" failed to exclude packed
   non-commit objects, which has been corrected.
   (merge 7b3c8e9f38 tb/rev-list-unpacked-fix later to maint).

 * "To dereference" and "to peel" were sometimes used in in-code
   comments and documentation but without description in the glossary.
   (merge 893dce2ffb vd/glossary-dereference-peel later to maint).

 * Other code cleanup, docfix, build fix, etc.
   (merge c2c349a15c xz/commit-title-soft-limit-doc later to maint).
   (merge 1bd809938a tb/format-pack-doc-update later to maint).
   (merge 8f81532599 an/clang-format-typofix later to maint).
   (merge 3ca86adc2d la/strvec-header-fix later to maint).
   (merge 6789275d37 jc/test-i18ngrep later to maint).
   (merge 9972cd6004 ps/leakfixes later to maint).
   (merge 46edab516b tz/send-email-helpfix later to maint).

----------------------------------------------------------------

Changes since v2.42.0 are as follows:

Aditya Neelamraju (1):
      clang-format: fix typo in comment

Alexander Shopov (1):
      l10n: bg.po: Updated Bulgarian translation (5579t)

Alyssa Ross (1):
      diff: fix --merge-base with annotated tags

Andrei Rybak (1):
      SubmittingPatches: call gitk's command "Copy commit reference"

Andy Koppe (8):
      pretty-formats: enclose options in angle brackets
      decorate: refactor format_decorations()
      decorate: avoid some unnecessary color overhead
      decorate: color each token separately
      pretty: add %(decorate[:<options>]) format
      pretty: add pointer and tag options to %(decorate)
      decorate: use commit color for HEAD arrow
      pretty: fix ref filtering for %(decorate) formats

Arkadii Yakovets (1):
      l10n: update uk localization for v2.43

Bagas Sanjaya (1):
      l10n: po-id for 2.43 (round 1)

Beat Bolli (1):
      unicode: update the width tables to Unicode 15.1

Caleb Hill (1):
      git-clean doc: fix "without do cleaning" typo

Calvin Wan (4):
      hex-ll: separate out non-hash-algo functions
      wrapper: reduce scope of remove_or_warn()
      config: correct bad boolean env value error message
      parse: separate out parsing functions from config.h

Christian Couder (9):
      pack-objects: allow `--filter` without `--stdout`
      t/helper: add 'find-pack' test-tool
      repack: refactor finishing pack-objects command
      repack: refactor finding pack prefix
      pack-bitmap-write: rebuild using new bitmap when remapping
      repack: add `--filter=<filter-spec>` option
      gc: add `gc.repackFilter` config option
      repack: implement `--filter-to` for storing filtered out objects
      gc: add `gc.repackFilterTo` config option

Christian Hesse (2):
      t/lib-gpg: forcibly run a trustdb update
      t/t6300: drop magic filtering

Derrick Stolee (13):
      upload-pack: fix race condition in error messages
      maintenance: add get_random_minute()
      maintenance: use random minute in launchctl scheduler
      maintenance: use random minute in Windows scheduler
      maintenance: use random minute in cron scheduler
      maintenance: swap method locations
      maintenance: use random minute in systemd scheduler
      maintenance: fix systemd schedule overlaps
      maintenance: update schedule before config
      scalar: add --[no-]src option
      setup: add discover_git_directory_reason()
      scalar reconfigure: help users remove buggy repos
      mailmap: change primary address for Derrick Stolee

Dorcas AnonoLitunya (1):
      t7601: use "test_path_is_file" etc. instead of "test -f"

Dragan Simic (2):
      diff --stat: add config option to limit filename width
      diff --stat: set the width defaults in a helper function

Drew DeVault (1):
      format-patch: --rfc honors what --subject-prefix sets

Elijah Newren (26):
      documentation: wording improvements
      documentation: fix small error
      documentation: fix typos
      documentation: fix apostrophe usage
      documentation: add missing words
      documentation: remove extraneous words
      documentation: fix subject/verb agreement
      documentation: employ consistent verb tense for a list
      documentation: fix verb tense
      documentation: fix adjective vs. noun
      documentation: fix verb vs. noun
      documentation: fix singular vs. plural
      documentation: whitespace is already generally plural
      documentation: fix choice of article
      documentation: add missing article
      documentation: remove unnecessary hyphens
      documentation: add missing hyphens
      documentation: use clearer prepositions
      documentation: fix punctuation
      documentation: fix capitalization
      documentation: fix whitespace issues
      documentation: add some commas where they are helpful
      documentation: add missing fullstops
      documentation: add missing quotes
      documentation: add missing parenthesis
      RelNotes: minor wording fixes in 2.43.0 release notes

Emily Shaffer (2):
      t0091-bugreport: stop using i18ngrep
      bugreport: reject positional arguments

Emir SARI (1):
      l10n: tr: v2.43.0

Eric W. Biederman (1):
      bulk-checkin: only support blobs in index_bulk_checkin

Eric Wong (1):
      treewide: fix various bugs w/ OpenSSL 3+ EVP API

Evan Gates (1):
      git-config: fix misworded --type=path explanation

Han Young (1):
      show doc: redirect user to git log manual instead of git diff-tree

Isoken June Ibizugbe (1):
      builtin/branch.c: adjust error messages to coding guidelines

Jacob Abel (1):
      builtin/worktree.c: fix typo in "forgot fetch" msg

Jacob Stopak (1):
      Include gettext.h in MyFirstContribution tutorial

Jan Alexander Steffens (heftig) (6):
      submodule--helper: use submodule_from_path in set-{url,branch}
      submodule--helper: return error from set-url when modifying failed
      t7419: actually test the branch switching
      t7419, t7420: use test_cmp_config instead of grepping .gitmodules
      t7419: test that we correctly handle renamed submodules
      t7420: test that we correctly handle renamed submodules

Jason Hatton (1):
      Prevent git from rehashing 4GiB files

Javier Mora (2):
      git-status.txt: fix minor asciidoc format issue
      doc/git-bisect: clarify `git bisect run` syntax

Jean-Noël Avila (1):
      l10n: fr: v2.43.0 rnd 2

Jeff King (114):
      hashmap: use expected signatures for comparison functions
      diff-files: avoid negative exit value
      diff: show usage for unknown builtin_diff_files() options
      diff: die when failing to read index in git-diff builtin
      diff: drop useless return from run_diff_{files,index} functions
      diff: drop useless return values in git-diff helpers
      diff: drop useless "status" parameter from diff_result_code()
      commit-graph: verify swapped zero/non-zero generation cases
      test-lib: ignore uninteresting LSan output
      sequencer: use repository parameter in short_commit_name()
      sequencer: mark repository argument as unused
      ref-filter: mark unused parameters in parser callbacks
      pack-bitmap: mark unused parameters in show_object callback
      worktree: mark unused parameters in each_ref_fn callback
      commit-graph: mark unused data parameters in generation callbacks
      ls-tree: mark unused parameter in callback
      stash: mark unused parameter in diff callback
      trace2: mark unused us_elapsed_absolute parameters
      trace2: mark unused config callback parameter
      test-trace2: mark unused argv/argc parameters
      grep: mark unused parameter in output function
      add-interactive: mark unused callback parameters
      negotiator/noop: mark unused callback parameters
      worktree: mark unused parameters in noop repair callback
      imap-send: mark unused parameters with NO_OPENSSL
      grep: mark unused parmaeters in pcre fallbacks
      credential: mark unused parameter in urlmatch callback
      fetch: mark unused parameter in ref_transaction callback
      bundle-uri: mark unused parameters in callbacks
      gc: mark unused descriptors in scheduler callbacks
      update-ref: mark unused parameter in parser callbacks
      ci: allow branch selection through "vars"
      ci: deprecate ci/config/allow-ref script
      merge: make xopts a strvec
      merge: simplify parsing of "-n" option
      format-patch: use OPT_STRING_LIST for to/cc options
      tree-walk: reduce stack size for recursive functions
      tree-walk: drop MAX_TRAVERSE_TREES macro
      tree-walk: rename "error" variable
      fsck: detect very large tree pathnames
      add core.maxTreeDepth config
      traverse_trees(): respect max_allowed_tree_depth
      read_tree(): respect max_allowed_tree_depth
      list-objects: respect max_allowed_tree_depth
      tree-diff: respect max_allowed_tree_depth
      lower core.maxTreeDepth default to 2048
      checkout-index: delay automatic setting of to_tempfile
      parse-options: prefer opt->value to globals in callbacks
      parse-options: mark unused "opt" parameter in callbacks
      merge: do not pass unused opt->value parameter
      parse-options: add more BUG_ON() annotations
      interpret-trailers: mark unused "unset" parameters in option callbacks
      parse-options: mark unused parameters in noop callback
      merge-ort: drop custom err() function
      merge-ort: stop passing "opt" to read_oid_strbuf()
      merge-ort: drop unused parameters from detect_and_process_renames()
      merge-ort: drop unused "opt" parameter from merge_check_renames_reusable()
      http: factor out matching of curl http/2 trace lines
      http: update curl http/2 info matching for curl 8.3.0
      merge-ort: lowercase a few error messages
      fsmonitor: prefer repo_git_path() to git_pathdup()
      fsmonitor/win32: drop unused parameters
      fsmonitor: mark some maybe-unused parameters
      fsmonitor/win32: mark unused parameter in fsm_os__incompatible()
      fsmonitor: mark unused parameters in stub functions
      fsmonitor/darwin: mark unused parameters in system callback
      fsmonitor: mark unused hashmap callback parameters
      run-command: mark unused parameters in start_bg_wait callbacks
      test-lib: set UBSAN_OPTIONS to match ASan
      commit-graph: factor out chain opening function
      commit-graph: check mixed generation validation when loading chain file
      t5324: harmonize sha1/sha256 graph chain corruption
      commit-graph: detect read errors when verifying graph chain
      commit-graph: tighten chain size check
      commit-graph: report incomplete chains during verification
      t6700: mark test as leak-free
      commit-reach: free temporary list in get_octopus_merge_bases()
      merge: free result of repo_get_merge_bases()
      commit-graph: move slab-clearing to close_commit_graph()
      commit-graph: free all elements of graph chain
      commit-graph: delay base_graph assignment in add_graph_to_chain()
      commit-graph: free graph struct that was not added to chain
      commit-graph: free write-context entries before overwriting
      commit-graph: free write-context base_graph_name during cleanup
      commit-graph: clear oidset after finishing write
      decorate: add clear_decoration() function
      revision: clear decoration structs during release_revisions()
      daemon: free listen_addr before returning
      repack: free existing_cruft array after use
      chunk-format: note that pair_chunk() is unsafe
      t: add library for munging chunk-format files
      midx: stop ignoring malformed oid fanout chunk
      commit-graph: check size of oid fanout chunk
      midx: check size of oid lookup chunk
      commit-graph: check consistency of fanout table
      midx: check size of pack names chunk
      midx: enforce chunk alignment on reading
      midx: check size of object offset chunk
      midx: bounds-check large offset chunk
      midx: check size of revindex chunk
      commit-graph: check size of commit data chunk
      commit-graph: detect out-of-bounds extra-edges pointers
      commit-graph: bounds-check base graphs chunk
      commit-graph: check size of generations chunk
      commit-graph: bounds-check generation overflow chunk
      commit-graph: check bounds when accessing BDAT chunk
      commit-graph: check bounds when accessing BIDX chunk
      commit-graph: detect out-of-order BIDX offsets
      chunk-format: drop pair_chunk_unsafe()
      t5319: make corrupted large-offset test more robust
      doc/send-email: mention handling of "reply-to" with --compose
      Revert "send-email: extract email-parsing code into a subroutine"
      send-email: handle to/cc/bcc from --compose message
      t: avoid perl's pack/unpack "Q" specifier

Johannes Schindelin (19):
      windows: ignore empty `PATH` elements
      is_Cygwin: avoid `exec`ing anything
      Move is_<platform> functions to the beginning
      Move the `_which` function (almost) to the top
      Work around Tcl's default `PATH` lookup
      rebase: allow overriding the maximal length of the generated labels
      ci: avoid building from the same commit in parallel
      ci(linux-asan-ubsan): let's save some time
      var: avoid a segmentation fault when `HOME` is unset
      completion(switch/checkout): treat --track and -t the same
      maintenance(systemd): support the Windows Subsystem for Linux
      ci: add a GitHub workflow to submit Coverity scans
      coverity: cache the Coverity Build Tool
      coverity: allow overriding the Coverity project
      coverity: support building on Windows
      coverity: allow running on macOS
      coverity: detect and report when the token or project is incorrect
      max_tree_depth: lower it for MSVC to avoid stack overflows
      ci: upgrade to using macos-13

John Cai (3):
      merge-ort: initialize repo in index state
      attr: read attributes from HEAD when bare repo
      attr: add attr.tree for setting the treeish to read attributes from

Jordi Mas (1):
      l10n: Update Catalan translation

Josh Soref (1):
      Documentation/git-status: add missing line breaks

Josip Sokcevic (1):
      diff-lib: fix check_removed when fsmonitor is on

Junio C Hamano (57):
      update-index: do not read HEAD and MERGE_HEAD unconditionally
      resolve-undo: allow resurrecting conflicted state that resolved to deletion
      update-index: use unmerge_index_entry() to support removal
      update-index: remove stale fallback code for "--unresolve"
      checkout/restore: refuse unmerging paths unless checking out of the index
      checkout/restore: add basic tests for --merge
      checkout: allow "checkout -m path" to unmerge removed paths
      mv: fix error for moving directory to another
      diff: move the fallback "--exit-code" code down
      diff: mode-only change should be noticed by "--patch -w --exit-code"
      diff: teach "--stat -w --exit-code" to notice differences
      t4040: remove test that succeeded for a wrong reason
      pretty-formats: define "literal formatting code"
      diff: spell DIFF_INDEX_CACHED out when calling run_diff_index()
      diff: the -w option breaks --exit-code for --raw and other output modes
      transfer.unpackLimit: fetch/receive.unpackLimit takes precedence
      Start the 2.43 cycle
      The second batch for 2.43
      The extra batch to update credenthal helpers
      The third batch
      The fourth batch
      The fifth batch
      The sixth batch
      The seventh batch
      update-index doc: v4 is OK with JGit and libgit2
      update-index: add --show-index-version
      test-tool: retire "index-version"
      The eighth batch
      The ninth batch
      The tenth batch
      The eleventh batch
      completion: loosen and document the requirement around completing alias
      The twelfth batch
      The thirteenth batch
      The fourteenth batch
      The fifteenth batch
      doc: update list archive reference to use lore.kernel.org
      The sixteenth batch
      merge: introduce {copy|clear}_merge_options()
      stash: be careful what we store
      grep: -f <path> is relative to $cwd
      The seventeenth batch
      The eighteenth batch
      commit: do not use cryptic "new_index" in end-user facing messages
      The nineteenth batch
      am: align placeholder for --whitespace option with apply
      The twentieth batch
      The twenty-first batch
      The twenty-second batch
      test framework: further deprecate test_i18ngrep
      Git 2.42.1
      tests: teach callers of test_i18ngrep to use test_grep
      A bit more before -rc1
      Prepare for -rc1
      Git 2.43-rc1
      Git 2.43-rc2
      Git 2.43

Karthik Nayak (3):
      revision: rename bit to `do_not_die_on_missing_objects`
      rev-list: move `show_commit()` to the bottom
      rev-list: add commit object support in `--missing` option

Kousik Sanagavarapu (4):
      ref-filter: sort numerically when ":size" is used
      t/t6300: cleanup test_atom
      t/t6300: introduce test_bad_atom
      ref-filter: add mailmap support

Kristoffer Haugsbakk (2):
      range-diff: treat notes like `log`
      grep: die gracefully when outside repository

Linus Arver (17):
      trailer tests: make test cases self-contained
      trailer test description: this tests --where=after, not --where=before
      trailer: add tests to check defaulting behavior with --no-* flags
      trailer doc: narrow down scope of --where and related flags
      trailer: trailer location is a place, not an action
      trailer --no-divider help: describe usual "---" meaning
      trailer --parse help: expose aliased options
      trailer --only-input: prefer "configuration variables" over "rules"
      trailer --parse docs: add explanation for its usefulness
      trailer --unfold help: prefer "reformat" over "join"
      trailer doc: emphasize the effect of configuration variables
      trailer doc: separator within key suppresses default separator
      trailer doc: <token> is a <key> or <keyAlias>, not both
      trailer: separate public from internal portion of trailer_iterator
      trailer: split process_input_file into separate pieces
      trailer: split process_command_line_args into separate functions
      strvec: drop unnecessary include of hex.h

M Hickford (3):
      credential/libsecret: store new attributes
      credential/libsecret: erase matching creds only
      credential/wincred: erase matching creds only

Mark Levedahl (6):
      git gui Makefile - remove Cygwin modifications
      git-gui - remove obsolete Cygwin specific code
      git-gui - use cygstart to browse on Cygwin
      git-gui - use mkshortcut on Cygwin
      git-gui - re-enable use of hook scripts
      git-gui - use git-hook, honor core.hooksPath

Mark Ruvald Pedersen (1):
      sequencer: truncate labels to accommodate loose refs

Martin Ågren (1):
      git-merge-file doc: drop "-file" from argument placeholders

Matthew McClain (1):
      git-p4 shouldn't attempt to store symlinks in LFS

Michael Strawbridge (1):
      send-email: move validation code below process_address_list

Michal Suchanek (1):
      git-push doc: more visibility for -q option

Naomi Ibe (1):
      builtin/add.c: clean up die() messages

Oswald Buddenhagen (16):
      t/lib-rebase: set_fake_editor(): fix recognition of reset's short command
      t/lib-rebase: set_fake_editor(): handle FAKE_LINES more consistently
      sequencer: simplify allocation of result array in todo_list_rearrange_squash()
      t/lib-rebase: improve documentation of set_fake_editor()
      t9001: fix indentation in test_no_confirm()
      format-patch: add --description-file option
      sequencer: rectify empty hint in call of require_clean_work_tree()
      sequencer: beautify subject of reverts of reverts
      git-revert.txt: add discussion
      sequencer: fix error message on failure to copy SQUASH_MSG
      t3404-rebase-interactive.sh: fix typos in title of a rewording test
      sequencer: remove unreachable exit condition in pick_commits()
      am: fix error message in parse_opt_show_current_patch()
      rebase: simplify code related to imply_merge()
      rebase: handle --strategy via imply_merge() as well
      rebase: move parse_opt_keep_empty() down

Patrick Steinhardt (23):
      upload-pack: fix exit code when denying fetch of unreachable object ID
      revision: make pseudo-opt flags read via stdin behave consistently
      doc/git-worktree: mention "refs/rewritten" as per-worktree refs
      doc/git-repack: fix syntax for `-g` shorthand option
      doc/git-repack: don't mention nonexistent "--unpacked" option
      commit-graph: introduce envvar to disable commit existence checks
      commit: detect commits that exist in commit-graph but not in the ODB
      builtin/show-ref: convert pattern to a local variable
      builtin/show-ref: split up different subcommands
      builtin/show-ref: fix leaking string buffer
      builtin/show-ref: fix dead code when passing patterns
      builtin/show-ref: refactor `--exclude-existing` options
      builtin/show-ref: stop using global variable to count matches
      builtin/show-ref: stop using global vars for `show_one()`
      builtin/show-ref: refactor options for patterns subcommand
      builtin/show-ref: ensure mutual exclusiveness of subcommands
      builtin/show-ref: explicitly spell out different modes in synopsis
      builtin/show-ref: add new mode to check for reference existence
      t: use git-show-ref(1) to check for ref existence
      test-bloom: stop setting up Git directory twice
      shallow: fix memory leak when registering shallow roots
      setup: refactor `upgrade_repository_format()` to have common exit
      setup: fix leaking repository format

Peter Krefting (1):
      l10n: sv.po: Update Swedish translation (5579t)

Philippe Blain (3):
      completion: commit: complete configured trailer tokens
      completion: commit: complete trailers tokens more robustly
      completion: improve doc for complex aliases

Phillip Wood (7):
      rebase -i: move unlink() calls
      rebase -i: remove patch file after conflict resolution
      sequencer: use rebase_path_message()
      sequencer: factor out part of pick_commits()
      rebase: fix rewritten list for failed pick
      rebase --continue: refuse to commit after failed command
      rebase -i: fix adding failed command to the todo list

Ralf Thielow (1):
      l10n: Update German translation

René Scharfe (18):
      subtree: disallow --no-{help,quiet,debug,branch,message}
      t1502, docs: disallow --no-help
      t1502: move optionspec help output to a file
      t1502: test option negation
      parse-options: show negatability of options in short help
      parse-options: factor out usage_indent() and usage_padding()
      parse-options: no --[no-]no-...
      parse-options: simplify usage_padding()
      parse-options: allow omitting option help text
      name-rev: use OPT_HIDDEN_BOOL for --peel-tag
      grep: use OPT_INTEGER_F for --max-depth
      grep: reject --no-or
      diff --no-index: fix -R with stdin
      parse-options: drop unused parse_opt_ctx_t member
      parse-options: make CMDMODE errors more precise
      am: simplify --show-current-patch handling
      am, rebase: fix arghelp syntax of --empty
      reflog: fix expire --single-worktree

Robert Coup (1):
      upload-pack: add tracing for fetches

Rubén Justo (2):
      branch: error message deleting a branch in use
      branch: error message checking out a branch in use

Sergey Organov (4):
      doc/diff-options: fix link to generating patch section
      diff-merges: improve --diff-merges documentation
      diff-merges: introduce '--dd' option
      completion: complete '--dd'

Shuqi Liang (3):
      t1092: add tests for 'git check-attr'
      attr.c: read attributes in a sparse directory
      check-attr: integrate with sparse-index

Tang Yuyi (1):
      merge-tree: add -X strategy option

Taylor Blau (28):
      repack: move `pack_geometry` struct to the stack
      commit-graph: introduce `commit_graph_generation_from_graph()`
      t/t5318-commit-graph.sh: test generation zero transitions during fsck
      commit-graph: avoid repeated mixed generation number warnings
      leak tests: mark a handful of tests as leak-free
      leak tests: mark t3321-notes-stripspace.sh as leak-free
      leak tests: mark t5583-push-branches.sh as leak-free
      builtin/pack-objects.c: remove unnecessary strbuf_reset()
      builtin/pack-objects.c: support `--max-pack-size` with `--cruft`
      Documentation/gitformat-pack.txt: remove multi-cruft packs alternative
      Documentation/gitformat-pack.txt: drop mixed version section
      builtin/repack.c: extract structure to store existing packs
      builtin/repack.c: extract marking packs for deletion
      builtin/repack.c: extract redundant pack cleanup for --geometric
      builtin/repack.c: extract redundant pack cleanup for existing packs
      builtin/repack.c: extract `has_existing_non_kept_packs()`
      builtin/repack.c: store existing cruft packs separately
      builtin/repack.c: avoid directly inspecting "util"
      builtin/repack.c: extract common cruft pack loop
      git-send-email.perl: avoid printing undef when validating addresses
      t7700: split cruft-related tests to t7704
      builtin/repack.c: parse `--max-pack-size` with OPT_MAGNITUDE
      builtin/repack.c: implement support for `--max-cruft-size`
      builtin/repack.c: avoid making cruft packs preferred
      Documentation/gitformat-pack.txt: fix typo
      Documentation/gitformat-pack.txt: fix incorrect MIDX documentation
      list-objects: drop --unpacked non-commit objects from results
      pack-bitmap: drop --unpacked non-commit objects from results

Teng Long (1):
      l10n: zh_CN: for git 2.43.0-rc1

Todd Zullinger (3):
      RelNotes: minor typo fixes in 2.43.0 draft
      RelNotes: improve wording of credential helper notes
      send-email: remove stray characters from usage

Victoria Dye (5):
      ref-cache.c: fix prefix matching in ref iteration
      dir.[ch]: expose 'get_dtype'
      dir.[ch]: add 'follow_symlink' arg to 'get_dtype'
      files-backend.c: avoid stat in 'loose_fill_ref_dir'
      glossary: add definitions for dereference & peel

Vipul Kumar (1):
      git-gui: Fix a typo in README

Wesley Schwengle (2):
      git-push.txt: fix grammar
      git-svn: drop FakeTerm hack

Yi-Jyun Pan (1):
      l10n: zh-TW: Git 2.43.0-rc1

brian m. carlson (2):
      t: add a test helper to truncate files
      merge-file: add an option to process object IDs

Ævar Arnfjörð Bjarmason (1):
      Makefiles: change search through $(MAKEFLAGS) for GNU make 4.4

Štěpán Němec (6):
      doc: fix some typos, grammar and wording issues
      doc/diff-options: improve wording of the log.diffMerges mention
      git-jump: admit to passing merge mode args to ls-files
      doc/gitk: s/sticked/stuck/
      t/README: fix multi-prerequisite example
      doc/cat-file: make synopsis and description less confusing

王常新 (1):
      merge-ort.c: fix typo 'neeed' to 'needed'

谢致邦 (XIE Zhibang) (2):
      doc: correct the 50 characters soft limit
      doc: correct the 50 characters soft limit (+)


^ permalink raw reply

* [PATCH] object-name: reject too-deep recursive ancestor queries
From: Taylor Blau @ 2023-11-20 16:13 UTC (permalink / raw)
  To: git
  Cc: Jeff King, Patrick Steinhardt, Junio C Hamano,
	Carlos Andrés Ramírez Cataño

When trying to resolve a revision query like "HEAD~~~~~", our call
pattern looks something like:

  - object-name.c::get_oid_with_context()
  - object-name.c::get_oid_1()
  - object-name.c::get_nth_ancestor()
  - object-name.c::get_oid_1()
  - ...

With `get_nth_ancestor()` and `get_oid_1()` mutually recurring, popping
one '~' off of the revision query for each round of the recursion.

Since this recursive behavior is unbounded, having too many "~"'s
contained in a revision query will cause us to blow the stack.
Generating a message like this when compiled under SANITIZE=address:

    $ valgrind git rev-parse "HEAD$(perl -e "print \"~\" x 1000000000000")"
    ==597453== Memcheck, a memory error detector
    ==597453== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
    ==597453== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
    ==597453== Command: /home/ttaylorr/local/bin/git.compile diff HEAD~~~~~~~~~~~~[...]
    ==597453==
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==597453==ERROR: AddressSanitizer: stack-overflow on address 0x7fffdd838ff8 (pc 0x7f2726082748 bp 0x7fffdd839110 sp 0x7fffdd839000 T0)
        #0 0x7f2726082748 in __asan::GetTLSFakeStack() ../../../../src/libsanitizer/asan/asan_fake_stack.cpp:176
        #1 0x7f2726082748 in GetFakeStackFast ../../../../src/libsanitizer/asan/asan_fake_stack.cpp:193
        #2 0x7f27260833de in OnMalloc ../../../../src/libsanitizer/asan/asan_fake_stack.cpp:207
        #3 0x7f27260833de in __asan_stack_malloc_1 ../../../../src/libsanitizer/asan/asan_fake_stack.cpp:256
        #4 0x563f9077d9d8 in get_nth_ancestor /home/ttaylorr/src/git/object-name.c:1087
        #5 0x563f9077e957 in get_oid_1 /home/ttaylorr/src/git/object-name.c:1295
        #6 0x563f9077da64 in get_nth_ancestor /home/ttaylorr/src/git/object-name.c:1092
        #7 0x563f9077e957 in get_oid_1 /home/ttaylorr/src/git/object-name.c:1295
        #8 0x563f9077da64 in get_nth_ancestor /home/ttaylorr/src/git/object-name.c:1092
        [...]
        #247 0x563f9077e957 in get_oid_1 /home/ttaylorr/src/git/object-name.c:1295
        #248 0x563f9077da64 in get_nth_ancestor /home/ttaylorr/src/git/object-name.c:1092

    SUMMARY: AddressSanitizer: stack-overflow ../../../../src/libsanitizer/asan/asan_fake_stack.cpp:176 in __asan::GetTLSFakeStack()
    ==597453==ABORTING

(Note that the actual stack is much deeper. GDB reports that the bottom
of the stack looks something like the following):

    #54866 0x0000555555c6d3bf in get_oid_with_context_1 (repo=0x5555563849a0 <the_repo>, name=0x7fffffff4be5 "HEAD", '~' <repeats 196 times>..., flags=128, prefix=0x0, oid=0x7ffff5713d40, oc=0x7ffff5713d90) at object-name.c:1947
    #54867 0x0000555555c6e2fa in get_oid_with_context (repo=0x5555563849a0 <the_repo>, str=0x7fffffff4be5 "HEAD", '~' <repeats 196 times>..., flags=128, oid=0x7ffff5713d40, oc=0x7ffff5713d90) at object-name.c:2096
    #54868 0x0000555555d8eed8 in handle_revision_arg_1 (arg_=0x7fffffff4be5 "HEAD", '~' <repeats 196 times>..., revs=0x7ffff5b000d0, flags=0, revarg_opt=0) at revision.c:2174
    #54869 0x0000555555d8f1a9 in handle_revision_arg (arg=0x7fffffff4be5 "HEAD", '~' <repeats 196 times>..., revs=0x7ffff5b000d0, flags=0, revarg_opt=0) at revision.c:2189
    #54870 0x0000555555d97ca9 in setup_revisions (argc=2, argv=0x7fffffff4970, revs=0x7ffff5b000d0, opt=0x0) at revision.c:2932
    #54871 0x00005555557d6a63 in cmd_diff (argc=2, argv=0x7fffffff4970, prefix=0x0) at builtin/diff.c:502
    #54872 0x00005555557367bf in run_builtin (p=0x5555561c4c30 <commands+816>, argc=2, argv=0x7fffffff4970) at git.c:469
    #54873 0x000055555573716b in handle_builtin (argc=2, argv=0x7fffffff4970) at git.c:723
    #54874 0x000055555573785a in run_argv (argcp=0x7ffff56028b0, argv=0x7ffff56028e0) at git.c:787
    #54875 0x0000555555738626 in cmd_main (argc=2, argv=0x7fffffff4970) at git.c:922
    #54876 0x00005555559d3fdd in main (argc=3, argv=0x7fffffff4968) at common-main.c:62

Fortunately, we can impose a limit on the maximum recursion depth we're
willing to accept when resolving queries like the above without
significantly impeding users. This patch sets the limit at 4096, though
we could probably increase that limit depending on the size of each
frame.

The limit introduced here is large enough that any reasonable query
should still run to completion, but small enough that if the frame size
were to significantly increase, our protection would still be effective.

The change here is straightforward: each call to get_nth_ancestor()
increases a counter, and then decrements that counter before returning.

The diff is a little noisy since there are a handful of return paths
from `get_nth_ancestor()`, all of which need to decrement the depth
variable.

Since this is a local-only exploit, a user would have to be tricked into
running such a query by an adversary. Even if they were successfully
tricked into running the malicious query, the blast radius is limited to
a local stack overflow, which does not have meaningful paths to remote
code execution, arbitrary memory reads, or any more grave security
concerns.

Reported-by: Carlos Andrés Ramírez Cataño <antaigroupltda@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
---
 object-name.c                  | 26 ++++++++++++++++++++------
 t/t1506-rev-parse-diagnosis.sh |  5 +++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/object-name.c b/object-name.c
index 0bfa29dbbf..675e0a759e 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1080,6 +1080,9 @@ static enum get_oid_result get_parent(struct repository *r,
 	return MISSING_OBJECT;
 }
 
+static int get_nth_ancestor_max_depth = 4096;
+static int get_nth_ancestor_curr_depth;
+
 static enum get_oid_result get_nth_ancestor(struct repository *r,
 					    const char *name, int len,
 					    struct object_id *result,
@@ -1089,20 +1092,31 @@ static enum get_oid_result get_nth_ancestor(struct repository *r,
 	struct commit *commit;
 	int ret;
 
+	if (++get_nth_ancestor_curr_depth > get_nth_ancestor_max_depth)
+		 return error(_("exceeded maximum ancestor depth"));
+
 	ret = get_oid_1(r, name, len, &oid, GET_OID_COMMITTISH);
 	if (ret)
-		return ret;
+		goto done;
 	commit = lookup_commit_reference(r, &oid);
-	if (!commit)
-		return MISSING_OBJECT;
+	if (!commit) {
+		ret = MISSING_OBJECT;
+		goto done;
+	}
 
 	while (generation--) {
-		if (repo_parse_commit(r, commit) || !commit->parents)
-			return MISSING_OBJECT;
+		if (repo_parse_commit(r, commit) || !commit->parents) {
+			ret = MISSING_OBJECT;
+			goto done;
+		}
 		commit = commit->parents->item;
 	}
 	oidcpy(result, &commit->object.oid);
-	return FOUND;
+
+	ret = FOUND;
+done:
+	get_nth_ancestor_curr_depth--;
+	return ret;
 }
 
 struct object *repo_peel_to_type(struct repository *r, const char *name, int namelen,
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index ef40511d89..b3b9f6c8c5 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -244,6 +244,11 @@ test_expect_success 'reject Nth ancestor if N is too high' '
 	test_must_fail git rev-parse HEAD~100000000000000000000000000000000
 '
 
+test_expect_success 'reject too-deep recursive ancestor queries' '
+	test_must_fail git rev-parse "HEAD$(perl -e "print \"~\" x 4097")" 2>err &&
+	grep "error: exceeded maximum ancestor depth" err
+'
+
 test_expect_success 'pathspecs with wildcards are not ambiguous' '
 	echo "*.c" >expect &&
 	git rev-parse "*.c" >actual &&

base-commit: cfb8a6e9a93adbe81efca66e6110c9b4d2e57169
-- 
2.43.0.rc2.19.geadd45bf00

^ permalink raw reply related

* [PATCH v2] commit-graph: disable GIT_COMMIT_GRAPH_PARANOIA by default
From: Patrick Steinhardt @ 2023-11-20 11:01 UTC (permalink / raw)
  To: git; +Cc: Taylor Blau, Jeff King, Junio C Hamano
In-Reply-To: <7e2d300c4af9a7853201121d66f982afa421bbba.1699957350.git.ps@pks.im>

[-- Attachment #1: Type: text/plain, Size: 8228 bytes --]

In 7a5d604443 (commit: detect commits that exist in commit-graph but not
in the ODB, 2023-10-31), we have introduced a new object existence check
into `repo_parse_commit_internal()` so that we do not parse commits via
the commit-graph that don't have a corresponding object in the object
database. This new check of course comes with a performance penalty,
which the commit put at around 30% for `git rev-list --topo-order`. But
there are in fact scenarios where the performance regression is even
higher. The following benchmark against linux.git with a fully-build
commit-graph:

  Benchmark 1: git.v2.42.1 rev-list --count HEAD
    Time (mean ± σ):     658.0 ms ±   5.2 ms    [User: 613.5 ms, System: 44.4 ms]
    Range (min … max):   650.2 ms … 666.0 ms    10 runs

  Benchmark 2: git.v2.43.0-rc1 rev-list --count HEAD
    Time (mean ± σ):      1.333 s ±  0.019 s    [User: 1.263 s, System: 0.069 s]
    Range (min … max):    1.302 s …  1.361 s    10 runs

  Summary
    git.v2.42.1 rev-list --count HEAD ran
      2.03 ± 0.03 times faster than git.v2.43.0-rc1 rev-list --count HEAD

While it's a noble goal to ensure that results are the same regardless
of whether or not we have a potentially stale commit-graph, taking twice
as much time is a tough sell. Furthermore, we can generally assume that
the commit-graph will be updated by git-gc(1) or git-maintenance(1) as
required so that the case where the commit-graph is stale should not at
all be common.

With that in mind, default-disable GIT_COMMIT_GRAPH_PARANOIA and restore
the behaviour and thus performance previous to the mentioned commit. In
order to not be inconsistent, also disable this behaviour by default in
`lookup_commit_in_graph()`, where the object existence check has been
introduced right at its inception via f559d6d45e (revision: avoid
hitting packfiles when commits are in commit-graph, 2021-08-09).

This results in another speedup in commands that end up calling this
function, even though it's less pronounced compared to the above
benchmark. The following has been executed in linux.git with ~1.2
million references:

  Benchmark 1: GIT_COMMIT_GRAPH_PARANOIA=true git rev-list --all --no-walk=unsorted
    Time (mean ± σ):      2.947 s ±  0.003 s    [User: 2.412 s, System: 0.534 s]
    Range (min … max):    2.943 s …  2.949 s    3 runs

  Benchmark 2: GIT_COMMIT_GRAPH_PARANOIA=false git rev-list --all --no-walk=unsorted
    Time (mean ± σ):      2.724 s ±  0.030 s    [User: 2.207 s, System: 0.514 s]
    Range (min … max):    2.704 s …  2.759 s    3 runs

  Summary
    GIT_COMMIT_GRAPH_PARANOIA=false git rev-list --all --no-walk=unsorted ran
      1.08 ± 0.01 times faster than GIT_COMMIT_GRAPH_PARANOIA=true git rev-list --all --no-walk=unsorted

So whereas 7a5d604443 initially introduced the logic to start doing an
object existence check in `repo_parse_commit_internal()` by default, the
updated logic will now instead cause `lookup_commit_in_graph()` to stop
doing the check by default. This behaviour continues to be tweakable by
the user via the GIT_COMMIT_GRAPH_PARANOIA environment variable.

Note that this requires us to amend some tests to manually turn on the
paranoid checks again. This is because we cause repository corruption by
manually deleting objects which are part of the commit graph already.
These circumstances shouldn't usually happen in repositories.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/git.txt       | 6 +++---
 commit-graph.c              | 2 +-
 commit.c                    | 2 +-
 t/t5318-commit-graph.sh     | 8 ++++----
 t/t6022-rev-list-missing.sh | 5 +++++
 t/t7700-repack.sh           | 2 +-
 6 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 2535a30194..6c19fd1d76 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -917,9 +917,9 @@ for full details.
 	avoid issues with stale commit-graphs that contain references to
 	already-deleted commits, but comes with a performance penalty.
 +
-The default is "true", which enables the aforementioned behavior.
-Setting this to "false" disables the existence check. This can lead to
-a performance improvement at the cost of consistency.
+The default is "false", which disables the aforementioned behavior.
+Setting this to "true" enables the existence check so that stale commits
+will never be returned from the commit-graph at the cost of performance.
 
 `GIT_ALLOW_PROTOCOL`::
 	If set to a colon-separated list of protocols, behave as if
diff --git a/commit-graph.c b/commit-graph.c
index acac9bf6e1..6fad9d195d 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1005,7 +1005,7 @@ struct commit *lookup_commit_in_graph(struct repository *repo, const struct obje
 	uint32_t pos;
 
 	if (commit_graph_paranoia == -1)
-		commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);
+		commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
 
 	if (!prepare_commit_graph(repo))
 		return NULL;
diff --git a/commit.c b/commit.c
index 8405d7c3fc..37956b836c 100644
--- a/commit.c
+++ b/commit.c
@@ -577,7 +577,7 @@ int repo_parse_commit_internal(struct repository *r,
 		static int commit_graph_paranoia = -1;
 
 		if (commit_graph_paranoia == -1)
-			commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);
+			commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0);
 
 		if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
 			unparse_commit(r, &item->object.oid);
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 7fe7c72a87..a2b4442660 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -911,10 +911,10 @@ test_expect_success 'stale commit cannot be parsed when given directly' '
 
 		# Verify that it is possible to read the commit from the
 		# commit graph when not being paranoid, ...
-		GIT_COMMIT_GRAPH_PARANOIA=false git rev-list B &&
+		git rev-list B &&
 		# ... but parsing the commit when double checking that
 		# it actually exists in the object database should fail.
-		test_must_fail git rev-list -1 B
+		test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git rev-list -1 B
 	)
 '
 
@@ -938,9 +938,9 @@ test_expect_success 'stale commit cannot be parsed when traversing graph' '
 
 		# Again, we should be able to parse the commit when not
 		# being paranoid about commit graph staleness...
-		GIT_COMMIT_GRAPH_PARANOIA=false git rev-parse HEAD~2 &&
+		git rev-parse HEAD~2 &&
 		# ... but fail when we are paranoid.
-		test_must_fail git rev-parse HEAD~2 2>error &&
+		test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git rev-parse HEAD~2 2>error &&
 		grep "error: commit $oid exists in commit-graph but not in the object database" error
 	)
 '
diff --git a/t/t6022-rev-list-missing.sh b/t/t6022-rev-list-missing.sh
index 40265a4f66..1ca4eb5a36 100755
--- a/t/t6022-rev-list-missing.sh
+++ b/t/t6022-rev-list-missing.sh
@@ -13,6 +13,11 @@ test_expect_success 'create repository and alternate directory' '
 	test_commit 3
 '
 
+# We manually corrupt the repository, which means that the commit-graph may
+# contain references to already-deleted objects. We thus need to enable
+# commit-graph paranoia to not returned these deleted commits from the graph.
+export GIT_COMMIT_GRAPH_PARANOIA=true
+
 for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
 do
 	test_expect_success "rev-list --missing=error fails with missing object $obj" '
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index d2975e6c93..94f9f4a1da 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -271,7 +271,7 @@ test_expect_success 'repacking fails when missing .pack actually means missing o
 		ls .git/objects/pack/*.pack >before-pack-dir &&
 
 		test_must_fail git fsck &&
-		test_must_fail git repack --cruft -d 2>err &&
+		test_must_fail env GIT_COMMIT_GRAPH_PARANOIA=true git repack --cruft -d 2>err &&
 		grep "bad object" err &&
 
 		# Before failing, the repack did not modify the
-- 
2.42.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related

* Re: [PATCH] setup: recognize bare repositories with packed-refs
From: Adam Majer @ 2023-11-20  9:43 UTC (permalink / raw)
  To: Junio C Hamano, Glen Choo, Josh Steadmon; +Cc: git
In-Reply-To: <xmqqbkbppbrd.fsf@gitster.g>

On 11/20/23 00:24, Junio C Hamano wrote:
> Adam Majer <adamm@zombino.com> writes:
> 
>> In a garbage collected bare git repository, the refs/ subdirectory is
>> empty.  In use-cases when such a repository is directly added into
>> another repository, it no longer is detected as valid.
> 
> Josh & Glen [*], isn't this a layout that we  explicitly discourage and
> eventually plan to forbid anyway?
> 
> *1* who worked on e35f202b (setup: trace bare repository setups, 2023-05-01)

This is fair enough. Completely removing embedded git repos would cause 
some pain in test suites as it was discussed in the thread for that 
commit[1]. Gitea (for example) has a few dozen embedded bare 
repositories for tests.

In either case, running `git gc` on a bare repository makes it no longer 
detectable as a git repository after checkout, GIT_DIR or not. This 
seems to be unintentional and not linked to the other discussion.

- Adam

^ permalink raw reply

* Re: [PATCH] setup: recognize bare repositories with packed-refs
From: Glen Choo @ 2023-11-20  9:31 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Josh Steadmon, git, Adam Majer
In-Reply-To: <xmqqbkbppbrd.fsf@gitster.g>

On Mon, Nov 20, 2023 at 7:24 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Adam Majer <adamm@zombino.com> writes:
>
> > In a garbage collected bare git repository, the refs/ subdirectory is
> > empty.  In use-cases when such a repository is directly added into
> > another repository, it no longer is detected as valid.
>
> Josh & Glen [*], isn't this a layout that we  explicitly discourage and
> eventually plan to forbid anyway?

If my recollection of [1] serves me correctly, we didn't come to a
strong conclusion on whether or not to forbid bare repositories in the
working tree, particularly because it would leave existing repos (like
Git LFS) high and dry. Though personally, I'd be happy to see a
version of Git that forbade bare repositories in the working tree.

I don't really recall the bare repo tracing bits, so I'll leave that to Josh.

[1] https://lore.kernel.org/git/kl6lsfqpygsj.fsf@chooglen-macbookpro.roam.corp.google.com/

^ permalink raw reply

* Re: bugreport
From: Thomas Guyot @ 2023-11-20  8:36 UTC (permalink / raw)
  To: galo joel, git
In-Reply-To: <CAKh3n_qqMiJL-Mn2MxBmG5MRL36w+v-kxjqb8wUv1i7KOEVaDw@mail.gmail.com>


Hi Joel,

I'm copying your attachment in-line for simplicity...

On 2023-10-24 16:40, galo joel wrote:
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> execute as admin git bash and,(in cmd W10, same. open git-bash.exe as system-32).
> try chmod 755, 777... does not work 'cause im user ($) and not admin (#)
>
> Wha did you expect to happen? (Expected behavior)
>
> change .sh to chmod 755 for execute bash
>
> What happened instead? (Actual behavior)
>
> nothing ._.
>
> What's different between what you expected and what actually happened?
>
> i expected a good sript in bash. now i'm sad
>
> Anything else you want to add:
>
> Please tell me what happen, maybe i'm wrong but chatGPT also no have idea why
> i cannot be admin in my own laptop xD, or maybe i need some libraries that i didnot
> install. I sell all my information so please help me to understand why does not work :)
>
> Please review the rest of the bug report below.
> You can delete any lines you don't wish to share.
>
>
> [System Info]
> git version:
> git version 2.42.0.windows.2
> cpu: x86_64
> built from commit: 2f819d1670fff9a1818f63b6722e9959405378e3
> sizeof-long: 4
> sizeof-size_t: 8
> shell-path: /bin/sh
> feature: fsmonitor--daemon
> uname: Windows 10.0 19045
> compiler info: gnuc: 13.2
> libc info: no libc information available
> $SHELL (typically, interactive shell): C:\Program Files\Git\usr\bin\bash.exe
>
>
> [Enabled Hooks]
> not run from a git repository - no hooks to show
>

You don't need admin to use git on Window. OTOH Windows has no concept 
of POSIX file permissions, and this is the reason you cannot set file 
permissions using chmod under git bash.

This Stackoverflow question has the answer you're most likely looking for:

https://stackoverflow.com/questions/21691202/how-to-create-file-execute-mode-permissions-in-git-on-windows

Regards,

--

Thomas

^ permalink raw reply

* Re: [GIT PULL] l10n updates for 2.43.0 round 2
From: Junio C Hamano @ 2023-11-20  1:29 UTC (permalink / raw)
  To: Jiang Xin
  Cc: Git l10n discussion group, Alexander Shopov, Arkadii Yakovets,
	Bagas Sanjaya, Emir SARI, Jean-Noël Avila, Jordi Mas,
	Peter Krefting, Ralf Thielow, Teng Long, Yi-Jyun Pan, Git List
In-Reply-To: <20231120001309.24434-1-worldhello.net@gmail.com>

Jiang Xin <worldhello.net@gmail.com> writes:

> Hi Junio,
>
> Please pull the following l10n updates for Git 2.43.0.
>
> The following changes since commit cfb8a6e9a93adbe81efca66e6110c9b4d2e57169:
>
>   Git 2.43-rc2 (2023-11-14 15:14:45 +0900)
>
> are available in the Git repository at:
>
>   git@github.com:git-l10n/git-po.git tags/l10n-2.43.0-rnd2
>
> for you to fetch changes up to d30343266793525abd82c15fcb246d892f474d92:
>
>   Merge branch 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po (2023-11-20 07:57:09 +0800)

Thanks.  Will do.

^ permalink raw reply

* [GIT PULL] l10n updates for 2.43.0 round 2
From: Jiang Xin @ 2023-11-20  0:13 UTC (permalink / raw)
  To: Junio C Hamano, Git l10n discussion group, Alexander Shopov,
	Arkadii Yakovets, Bagas Sanjaya, Emir SARI, Jean-Noël Avila,
	Jiang Xin, Jordi Mas, Peter Krefting, Ralf Thielow, Teng Long,
	Yi-Jyun Pan
  Cc: Git List

Hi Junio,

Please pull the following l10n updates for Git 2.43.0.

The following changes since commit cfb8a6e9a93adbe81efca66e6110c9b4d2e57169:

  Git 2.43-rc2 (2023-11-14 15:14:45 +0900)

are available in the Git repository at:

  git@github.com:git-l10n/git-po.git tags/l10n-2.43.0-rnd2

for you to fetch changes up to d30343266793525abd82c15fcb246d892f474d92:

  Merge branch 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po (2023-11-20 07:57:09 +0800)

----------------------------------------------------------------
l10n-2.43.0-rnd2
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE37vMEzKDqYvVxs51k24VDd1FMtUFAmVaodkACgkQk24VDd1F
MtUXAxAAqkzi6QOAXCdCFylSP/zSHGoOdY1zpOZxKcQbfmfY6FBUVAW31c3nCg6h
7OIXmreS2sMY+nIhvowSQO/Azn7Ka/kglB3MaOu5EcfO9SEbAGmT4JtvDOSLdUZS
kZytWwvFY83l3aJGCPmz5FDc6upo3v9b2aSrbiYv3o7A+r3YSwTtLqKeoXZnRyg9
ACh2fq2PVJV/LkPXbbg6xcwsiKSOL71hUBH/OfZrPuEIXQUJZXgUQySopu2R4HX2
UPyP2uhg5XncoN4oCgkFTX/tO+lIzdnREzCVQGlmHI4v0WFOIPKP9bgMQHi4qRi7
SMwCW+su8vFPCucNgeM8xh6NYg7UBCR3RXq8tRw7WCct3Hz3FHVS5HI/zCg/lCD8
4YS3CcCokGggif4ONV0qrQQih3QXv4mwmtzGy7y6t+4Qi0XKV17yJb5d6Es+/7YT
/CTM3JQNguiejNzNjrvMg6LOBBYr32dULnH8+E8ZYaG8wZY4ZI8gwR4p0BUNvE6K
Sxa+/2sdskaNL+h4vhT+dq3skDqxfy2gLc6UavTLkxwEzRLMlqD9h4SbXyJKl2ur
VH7A/KoypdrMoRcYeDtM00kMONxQmVXhLWE0PHdUIHnj3Bt4skMWEJCI5Xc5oQIE
uoNUYDhs9mDbQybJU/1Sak7f5C0qwqMjp5QczyTWgEGrUdqnPLs=
=XEYO
-----END PGP SIGNATURE-----

----------------------------------------------------------------
Alexander Shopov (1):
      l10n: bg.po: Updated Bulgarian translation (5579t)

Arkadii Yakovets (1):
      l10n: update uk localization for v2.43

Bagas Sanjaya (1):
      l10n: po-id for 2.43 (round 1)

Emir SARI (1):
      l10n: tr: v2.43.0

Jean-Noël Avila (1):
      l10n: fr: v2.43.0 rnd 2

Jiang Xin (8):
      Merge branch 'master' of github.com:nafmo/git-l10n-sv
      Merge branch 'po-id' of github.com:bagasme/git-po
      Merge branch 'fr_v2.43.0' of github.com:jnavila/git
      Merge branch 'tr-l10n' of github.com:bitigchi/git-po
      Merge branch 'catalan' of github.com:Softcatala/git-po
      Merge branch '2.43-uk-update' of github.com:arkid15r
      Merge branch 'master' of github.com:alshopov/git-po
      Merge branch 'l10n/zh-TW/2023-11-19' of github.com:l10n-tw/git-po

Jordi Mas (1):
      l10n: Update Catalan translation

Peter Krefting (1):
      l10n: sv.po: Update Swedish translation (5579t)

Ralf Thielow (1):
      l10n: Update German translation

Teng Long (1):
      l10n: zh_CN: for git 2.43.0-rc1

Yi-Jyun Pan (1):
      l10n: zh-TW: Git 2.43.0-rc1

 po/bg.po    | 1448 ++++++++++++++----------
 po/ca.po    |  691 +++++++-----
 po/de.po    |  571 ++++++----
 po/fr.po    |  640 +++++++----
 po/id.po    |  674 ++++++-----
 po/sv.po    | 3569 ++++++++++++++++++++++++++++++-----------------------------
 po/tr.po    |  529 +++++----
 po/uk.po    |  625 ++++++-----
 po/zh_CN.po |  602 ++++++----
 po/zh_TW.po | 1116 +++++++------------
 10 files changed, 5712 insertions(+), 4753 deletions(-)

--
Jiang Xin

^ permalink raw reply

* Re: [PATCH] merge-file: add --diff-algorithm option
From: Junio C Hamano @ 2023-11-19 23:30 UTC (permalink / raw)
  To: Phillip Wood; +Cc: Antonin Delpeuch, git, Elijah Newren
In-Reply-To: <de04aec0-a195-45da-8951-bb30f2a629a3@gmail.com>

Phillip Wood <phillip.wood123@gmail.com> writes:

> I can see there's an argument for changing the default algorithm of
> "git merge-file" to match what "ort" uses. I know Elijah found the
> histogram algorithm gave better results in his testing when he was
> developing "ort". While it would be a breaking change if on the
> average the new default gives better conflicts it might be worth
> it. This patch would mean that someone wanting to use the "myers"
> algorithm could still do so.

Sounds like a sensible thing to do.  First allow to configure the
custom algorithm from the command line option (and optionally via a
configuration variable) and ship it in a release, start giving a
warning if the using script did not specify the configuration or the
command line option and used the current default and ship it in the
next release, wait for a few releases and then finally flip the
default, or something like that.

Thanks.

^ permalink raw reply

* Re: [PATCH] setup: recognize bare repositories with packed-refs
From: Junio C Hamano @ 2023-11-19 23:24 UTC (permalink / raw)
  To: Glen Choo, Josh Steadmon; +Cc: git, Adam Majer
In-Reply-To: <20231117203253.21143-1-adamm@zombino.com>

Adam Majer <adamm@zombino.com> writes:

> In a garbage collected bare git repository, the refs/ subdirectory is
> empty.  In use-cases when such a repository is directly added into
> another repository, it no longer is detected as valid.

Josh & Glen [*], isn't this a layout that we  explicitly discourage and
eventually plan to forbid anyway?

*1* who worked on e35f202b (setup: trace bare repository setups, 2023-05-01)

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox