diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-04-16 19:28:06 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-16 19:28:06 +0900 |
commit | e197980eb2446da92a4e7d835c05adbc25c17ae0 (patch) | |
tree | 91d8b4f8cf948a59ed79d7010d7ccb1e2d0bf7a7 | |
parent | Merge branch 'dl/subtree-limit-to-one-rev' (diff) | |
parent | get_oid(): when an object was not found, try harder (diff) | |
download | tgif-e197980eb2446da92a4e7d835c05adbc25c17ae0.tar.xz |
Merge branch 'js/get-short-oid-drop-cache'
A corner-case object name ambiguity while the sequencer machinery
is working (e.g. "rebase -i -x") has been (half) fixed.
* js/get-short-oid-drop-cache:
get_oid(): when an object was not found, try harder
sequencer: move stale comment into correct location
sequencer: improve error message when an OID could not be parsed
rebase -i: demonstrate obscure loose object cache bug
-rw-r--r-- | sequencer.c | 5 | ||||
-rw-r--r-- | sha1-name.c | 12 | ||||
-rwxr-xr-x | t/t3429-rebase-edit-todo.sh | 22 |
3 files changed, 37 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c index 95dda23eee..79a046d748 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2137,7 +2137,8 @@ static int parse_insn_line(struct repository *r, struct todo_item *item, item->arg_len = (int)(eol - item->arg); if (status < 0) - return -1; + return error(_("could not parse '%.*s'"), + (int)(end_of_object_name - bol), bol); item->commit = lookup_commit_reference(r, &commit_oid); return !item->commit; @@ -3640,7 +3641,6 @@ static int pick_commits(struct repository *r, res = do_exec(r, item->arg); *end_of_arg = saved; - /* Reread the todo file if it has changed. */ if (res) { if (opts->reschedule_failed_exec) reschedule = 1; @@ -3648,6 +3648,7 @@ static int pick_commits(struct repository *r, res = error_errno(_("could not stat '%s'"), get_todo_path(opts)); else if (match_stat_data(&todo_list->stat, &st)) { + /* Reread the todo file if it has changed. */ todo_list_release(todo_list); if (read_populate_todo(r, todo_list, opts)) res = -1; /* message was printed */ diff --git a/sha1-name.c b/sha1-name.c index 6dda2c16df..cfe5c874b6 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -442,6 +442,18 @@ static enum get_oid_result get_short_oid(const char *name, int len, find_short_packed_object(&ds); status = finish_object_disambiguation(&ds, oid); + /* + * If we didn't find it, do the usual reprepare() slow-path, + * since the object may have recently been added to the repository + * or migrated from loose to packed. + */ + if (status == MISSING_OBJECT) { + reprepare_packed_git(the_repository); + find_short_object_filename(&ds); + find_short_packed_object(&ds); + status = finish_object_disambiguation(&ds, oid); + } + if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) { struct oid_array collect = OID_ARRAY_INIT; diff --git a/t/t3429-rebase-edit-todo.sh b/t/t3429-rebase-edit-todo.sh index b9292dfc2a..76f6d306ea 100755 --- a/t/t3429-rebase-edit-todo.sh +++ b/t/t3429-rebase-edit-todo.sh @@ -11,4 +11,26 @@ test_expect_success 'rebase exec modifies rebase-todo' ' test -e F ' +test_expect_success SHA1 'loose object cache vs re-reading todo list' ' + GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo && + export GIT_REBASE_TODO && + write_script append-todo.sh <<-\EOS && + # For values 5 and 6, this yields SHA-1s with the same first two digits + echo "pick $(git rev-parse --short \ + $(printf "%s\\n" \ + "tree $EMPTY_TREE" \ + "author A U Thor <author@example.org> $1 +0000" \ + "committer A U Thor <author@example.org> $1 +0000" \ + "" \ + "$1" | + git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO + + shift + test -z "$*" || + echo "exec $0 $*" >>$GIT_REBASE_TODO + EOS + + git rebase HEAD -x "./append-todo.sh 5 6" +' + test_done |