Re: [PATCH 14/22] sequencer: prepare for rebase -i's commit functionality
From: Junio C Hamano <hidden>
Date: 2016-08-29 21:32:57
Johannes Schindelin [off-list ref] writes:
+/* We will introduce the 'interactive rebase' mode later */ +#define IS_REBASE_I() 0
I do not see a point in naming this all caps. The use site would be a lot more pleasant to read when the reader does not have to care if this is implemented as a preprocessor macro or a helper function.
quoted hunk
@@ -377,20 +387,72 @@ static int is_index_unchanged(void) return !hashcmp(active_cache_tree->sha1, head_commit->tree->object.oid.hash); } +static char **read_author_script(void) +{ + struct strbuf script = STRBUF_INIT; + int i, count = 0; + char *p, *p2, **env; + size_t env_size; + + if (strbuf_read_file(&script, rebase_path_author_script(), 256) <= 0) + return NULL; + + for (p = script.buf; *p; p++) + if (skip_prefix(p, "'\\\\''", (const char **)&p2)) + strbuf_splice(&script, p - script.buf, p2 - p, "'", 1); + else if (*p == '\'') + strbuf_splice(&script, p-- - script.buf, 1, "", 0); + else if (*p == '\n') { + *p = '\0'; + count++; + }
Hmph. What is this loop doing? Is it decoding a sq-quoted buffer or something? Don't we have a helper function to do that?
+ env_size = (count + 1) * sizeof(*env);
+ strbuf_grow(&script, env_size);
+ memmove(script.buf + env_size, script.buf, script.len);
+ p = script.buf + env_size;
+ env = (char **)strbuf_detach(&script, NULL);
+
+ for (i = 0; i < count; i++) {
+ env[i] = p;
+ p += strlen(p) + 1;
+ }
+ env[count] = NULL;
+
+ return env;
+}
+
/*
* If we are cherry-pick, and if the merge did not result in
* hand-editing, we will hit this commit and inherit the original
* author date and name.
* If we are revert, or if our cherry-pick results in a hand merge,
- * we had better say that the current user is responsible for that.
+ * we had better say that the current user is responsible for that
+ * (except, of course, while running an interactive rebase).
*/The added "(except, ...)" reads as if "even if we are reverting, if that is done as part of an interactive rebase, the authorship rule for a revert does not apply". If that is not what you meant, i.e. if you did not mean to imply that "rebase -i" doing a revert is a normal thing, this needs to be rephrased to avoid the misinterpretation.