Thread (33 messages) 33 messages, 2 authors, 2025-11-04
STALE245d
Revisions (2)
  1. v4 [diff vs current]
  2. v5 current

[PATCH v5 10/29] rebase: inline trailer state paths

From: Li Chen <hidden>
Date: 2025-10-22 05:42:01
Subsystem: the rest · Maintainer: Linus Torvalds

Simplified read_basic_state() by dropping the
temporary trailer path variables and calling
state_dir_path("trailer", opts) directly when
loading trailer arguments.

Signed-off-by: Li Chen <redacted>
---
 builtin/rebase.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 3db1439b52..b0f547ef2b 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -442,8 +442,6 @@ static int read_basic_state(struct rebase_options *opts)
 	struct strbuf head_name = STRBUF_INIT;
 	struct strbuf buf = STRBUF_INIT;
 	struct object_id oid;
-	const char trailer_state_name[] = "trailer";
-	const char *path = state_dir_path(trailer_state_name, opts);
 
 	if (!read_oneliner(&head_name, state_dir_path("head-name", opts),
 			   READ_ONELINER_WARN_MISSING) ||
@@ -512,7 +510,7 @@ static int read_basic_state(struct rebase_options *opts)
 
 	strbuf_release(&buf);
 
-	if (strbuf_read_file(&buf, path, 0) >= 0) {
+	if (strbuf_read_file(&buf, state_dir_path("trailer", opts), 0) >= 0) {
 		const char *p = buf.buf, *end = buf.buf + buf.len;
 
 		while (p < end) {
@@ -535,8 +533,6 @@ static int read_basic_state(struct rebase_options *opts)
 
 static int rebase_write_basic_state(struct rebase_options *opts)
 {
-	const char trailer_state_name[] = "trailer";
-
 	write_file(state_dir_path("head-name", opts), "%s",
 		   opts->head_name ? opts->head_name : "detached HEAD");
 	write_file(state_dir_path("onto", opts), "%s",
@@ -568,7 +564,7 @@ static int rebase_write_basic_state(struct rebase_options *opts)
 				strbuf_addstr(&buf, opts->trailer_args.v[i]);
 				strbuf_addch(&buf, '\n');
 		}
-		write_file(state_dir_path(trailer_state_name, opts),
+		write_file(state_dir_path("trailer", opts),
 				   "%s", buf.buf);
 		strbuf_release(&buf);
 	}
-- 
2.51.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help