{"thread":{"id":"34284","subject":"[BUG] rebase should desambiguate abbreviated hashes before starting","startedAt":"2013-06-27T08:55:13Z","lastAt":"2013-06-27T17:16:06Z","messageCount":6,"participants":["Yann Dirson","David","Matthieu Moy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"222069","messageId":"20130627105513.6bf84060@chalon.bertin.fr","threadId":"34284","inReplyTo":null,"subject":"[BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"Yann Dirson","fromEmail":"dirson@bertin.fr","sentAt":"2013-06-27T08:55:13Z","receivedAt":"2013-06-27T08:55:13Z","isPatch":false,"sender":{"key":"dirson@bertin.fr","avatar":null},"body":"I just ran into a funny edge-case when doing a long rebase: one of\nthe rewritten commits got a sha1 starting with one of the abbreviated\nsha1's of a commit still to be applied.\n\nAs a result, the rebase stopped with a funny-looking \"short SHA1 ... was\nambiguous\", which would not have occured if the shortened sha1's presented\nto the user were expanded to full sha1's before starting the rebase.\n\n-- \nYann Dirson - Bertin Technologies\n"},{"id":"222070","messageId":"CAMPXz=pSseQKebNVPVYogTZ2FUc1LqubgmS+pN76sveV=eqC0A@mail.gmail.com","threadId":"34284","inReplyTo":"20130627105513.6bf84060@chalon.bertin.fr","subject":"Re: [BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"David","fromEmail":"bouncingcats@gmail.com","sentAt":"2013-06-27T09:38:04Z","receivedAt":"2013-06-27T09:38:04Z","isPatch":false,"sender":{"key":"bouncingcats@gmail.com","avatar":null},"body":"On 27 June 2013 18:55, Yann Dirson <dirson@bertin.fr> wrote:\n> I just ran into a funny edge-case when doing a long rebase: one of\n> the rewritten commits got a sha1 starting with one of the abbreviated\n> sha1's of a commit still to be applied.\n>\n> As a result, the rebase stopped with a funny-looking \"short SHA1 ... was\n> ambiguous\", which would not have occured if the shortened sha1's presented\n> to the user were expanded to full sha1's before starting the rebase.\n\nI do many large rebases, and I have experienced this about a dozen times\nin the last few years.\n\nI'm not sure that rebase could predict the new hashes without actually creating\nthe prior commits? So maybe the \"short\" SHA1 is \"too short\"?\n\nWhen the rebase stops with this message, my workaround is:\n\nThe last (failed) entry is in .git/rebase-merge/done\nThe next todo is the top entry in .git/rebase-merge/git-rebase-todo\nI enter the short SHA1 in gitk to find the long SHA1.\nI edit both the above files to move the failed entry back into the top\nof the todo file, with the long SHA1\nAnd then git rebase --continue\n"},{"id":"222072","messageId":"vpq1u7n3jdh.fsf@anie.imag.fr","threadId":"34284","inReplyTo":"CAMPXz=pSseQKebNVPVYogTZ2FUc1LqubgmS+pN76sveV=eqC0A@mail.gmail.com","subject":"Re: [BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-27T11:04:10Z","receivedAt":"2013-06-27T11:04:10Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"David <bouncingcats@gmail.com> writes:\n\n> I'm not sure that rebase could predict the new hashes without actually creating\n> the prior commits? So maybe the \"short\" SHA1 is \"too short\"?\n\nIt's OK to show the short sha1 to the user, but \"git rebase\" could and\nshould expand these to complete sha1 right after the editor is closed. I\nthink that's what Yann means.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"222073","messageId":"CAMPXz=pbdarPBPjVzLXdgN6rgqw9msoQcX44RqDFuH-d6KXHug@mail.gmail.com","threadId":"34284","inReplyTo":"vpq1u7n3jdh.fsf@anie.imag.fr","subject":"Re: [BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"David","fromEmail":"bouncingcats@gmail.com","sentAt":"2013-06-27T11:09:46Z","receivedAt":"2013-06-27T11:09:46Z","isPatch":false,"sender":{"key":"bouncingcats@gmail.com","avatar":null},"body":"On 27 June 2013 21:04, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> David <bouncingcats@gmail.com> writes:\n>\n>> I'm not sure that rebase could predict the new hashes without actually creating\n>> the prior commits? So maybe the \"short\" SHA1 is \"too short\"?\n>\n> It's OK to show the short sha1 to the user, but \"git rebase\" could and\n> should expand these to complete sha1 right after the editor is closed. I\n> think that's what Yann means.\n\nYes. I realised that just after clicking \"send\". Thanks :)\n"},{"id":"222098","messageId":"7vppv7trls.fsf@alter.siamese.dyndns.org","threadId":"34284","inReplyTo":"vpq1u7n3jdh.fsf@anie.imag.fr","subject":"Re: [BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-27T17:01:51Z","receivedAt":"2013-06-27T17:01:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> David <bouncingcats@gmail.com> writes:\n>\n>> I'm not sure that rebase could predict the new hashes without actually creating\n>> the prior commits? So maybe the \"short\" SHA1 is \"too short\"?\n>\n> It's OK to show the short sha1 to the user, but \"git rebase\" could and\n> should expand these to complete sha1 right after the editor is closed. I\n> think that's what Yann means.\n\nYes, any \"short\" is by definition \"too short\".  I agree that it is\nOK to show short one in \"rebase -i\" instruction sheet, as they are\nuniquely generated before the actual replaying of commits begins,\nand it is a sensible thing to do to convert them to the full form\nbefore starting to do the real work.\n\nIt could be something as simple like this (not tested).\n\n git-rebase--interactive.sh | 19 +++++++++++++++++++\n 1 file changed, 19 insertions(+)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f953d8d..6766b44 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -678,6 +678,23 @@ skip_unnecessary_picks () {\n \tdie \"Could not skip unnecessary pick commands\"\n }\n \n+# expand shortened commit object name to the full form\n+expand_todo_commit_names () {\n+\twhile read -r command rest\n+\tdo\n+\t\tcase \"$command\" in\n+\t\t'#'*)\n+\t\t\t;;\n+\t\t*)\n+\t\t\tsha1=$(git rev-parse --verify --quiet ${rest%% *})\n+\t\t\trest=\"$sha1 ${rest#* }\"\n+\t\t\t;;\n+\t\tesac\n+\t\tprintf '%s\\n' \"$command${rest:+ }$rest\"\n+\tdone <\"$todo\" >\"$todo.new\" &&\n+\tmv -f \"$todo.new\" \"$todo\"\n+}\n+\n # Rearrange the todo list that has both \"pick sha1 msg\" and\n # \"pick sha1 fixup!/squash! msg\" appears in it so that the latter\n # comes immediately after the former, and change \"pick\" to\n@@ -979,6 +996,8 @@ git_sequence_editor \"$todo\" ||\n has_action \"$todo\" ||\n \tdie_abort \"Nothing to do\"\n \n+expand_todo_commit_names\n+\n test -d \"$rewritten\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n output git checkout $onto || die_abort \"could not detach HEAD\"\n"},{"id":"222099","messageId":"7vhagjtqy1.fsf@alter.siamese.dyndns.org","threadId":"34284","inReplyTo":"7vppv7trls.fsf@alter.siamese.dyndns.org","subject":"Re: [BUG] rebase should desambiguate abbreviated hashes before starting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-27T17:16:06Z","receivedAt":"2013-06-27T17:16:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> It could be something as simple like this (not tested).\n>\n>  git-rebase--interactive.sh | 19 +++++++++++++++++++\n>  1 file changed, 19 insertions(+)\n>\n> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\n> index f953d8d..6766b44 100644\n> --- a/git-rebase--interactive.sh\n> +++ b/git-rebase--interactive.sh\n> @@ -678,6 +678,23 @@ skip_unnecessary_picks () {\n>  \tdie \"Could not skip unnecessary pick commands\"\n>  }\n>  \n> +# expand shortened commit object name to the full form\n> +expand_todo_commit_names () {\n> +\twhile read -r command rest\n> +\tdo\n> +\t\tcase \"$command\" in\n> +\t\t'#'*)\n> +\t\t\t;;\n> +\t\t*)\n> +\t\t\tsha1=$(git rev-parse --verify --quiet ${rest%% *})\n> +\t\t\trest=\"$sha1 ${rest#* }\"\n> +\t\t\t;;\n\nIn case somebody wants to polish it to a real patch, this part\nshould at least be:\n\n\t\tcase \"$command\" in\n\t\t'#'* | exec)\n\t\t\t# Be careful for oddball commands like 'exec'\n\t\t\t# that do not have a short-SHA-1 at the beginning\n\t\t\t# of $rest.\n\t\t\t;;\n\t\t*)\n\t\t\tsha1=$(git rev-parse --verify --quiet ${rest%% *}) &&\n\t\t\trest=\"$sha1 ${rest#* }\"\n\t\t\t;;\n"}]}