git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 4/4] rebase -i: simplify get_revision_ranges()

From
PGPhillip Wood via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 4, 2020, 15:29 UTC
Message-ID
<faae3ccff53b83aac3b8998fc5259f319fd80fc4.1604503780.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.773.v2.git.1604503780.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

Now that all the external users of head_hash have been converted to use a opts->orig_head instead we can stop returning head_hash from get_revision_ranges().

Because we want to pass the full object names back to the caller in `revisions` the find_unique_abbrev_r() call that was used to initialize `head_hash` is replaced with oid_to_hex().

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 builtin/rebase.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 28e7b7f5ce..17450e9d9e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -270,15 +270,14 @@ static int edit_todo_file(unsigned flags)
 }
 
 static int get_revision_ranges(struct commit *upstream, struct commit *onto,
-			       struct object_id *orig_head, char *head_hash,
-			       char **revisions, char **shortrevisions)
+			       struct object_id *orig_head, char **revisions,
+			       char **shortrevisions)
 {
 	struct commit *base_rev = upstream ? upstream : onto;
 	const char *shorthead;
 
-	find_unique_abbrev_r(head_hash, orig_head, GIT_MAX_HEXSZ);
 	*revisions = xstrfmt("%s...%s", oid_to_hex(&base_rev->object.oid),
-						   head_hash);
+			     oid_to_hex(orig_head));
 
 	shorthead = find_unique_abbrev(orig_head, DEFAULT_ABBREV);
 
@@ -328,7 +327,6 @@ static void split_exec_commands(const char *cmd, struct string_list *commands)
 static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 {
 	int ret;
-	char head_hash[GIT_MAX_HEXSZ];
 	char *revisions = NULL, *shortrevisions = NULL;
 	struct strvec make_script_args = STRVEC_INIT;
 	struct todo_list todo_list = TODO_LIST_INIT;
@@ -336,7 +334,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
 	struct string_list commands = STRING_LIST_INIT_DUP;
 
 	if (get_revision_ranges(opts->upstream, opts->onto, &opts->orig_head,
-				head_hash, &revisions, &shortrevisions))
+				&revisions, &shortrevisions))
 		return -1;
 
 	if (init_basic_state(&replay,
-- 
gitgitgadget
Previous: Phillip Wood via GitGitGadgetNext: Phillip Wood via GitGitGadget
Message 14 of 15 in “rebase -i: fix ORIG_HEAD handling”
  1. 0/4 rebase -i: fix ORIG_HEAD handlingPhillip Wood via GitGitGadget, Oct 27, 2020
  2. 4/4 rebase -i: simplify get_revision_ranges()Phillip Wood via GitGitGadget, Oct 27, 2020
  3. 3/4 rebase -i: use struct object_id when writing statePhillip Wood via GitGitGadget, Oct 27, 2020
  4. 1/4 rebase -i: stop overwriting ORIG_HEAD bufferPhillip Wood via GitGitGadget, Oct 27, 2020
  5. Junio C HamanoOct 27, 2020
  6. Phillip WoodOct 31, 2020
  7. herr.kasteNov 2, 2020
  8. Junio C HamanoNov 3, 2020
  9. herr.kasteNov 3, 2020
  10. 2/4 rebase -i: use struct object_id rather than looking up commitPhillip Wood via GitGitGadget, Oct 27, 2020
  11. 0/4 rebase -i: fix ORIG_HEAD handlingPhillip Wood via GitGitGadget, Nov 4, 2020
  12. 1/4 rebase -i: stop overwriting ORIG_HEAD bufferPhillip Wood via GitGitGadget, Nov 4, 2020
  13. 3/4 rebase -i: use struct object_id when writing statePhillip Wood via GitGitGadget, Nov 4, 2020
  14. 4/4 rebase -i: simplify get_revision_ranges()Phillip Wood via GitGitGadget, Nov 4, 2020
  15. 2/4 rebase -i: use struct object_id rather than looking up commitPhillip Wood via GitGitGadget, Nov 4, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.