{"thread":{"id":"29801","subject":"Bug: no-op \"rebase -i\" failures (easily reproduceable)","startedAt":"2012-03-01T18:47:08Z","lastAt":"2012-03-01T20:18:28Z","messageCount":3,"participants":["Luiz-Otavio Zorzella","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"185838","messageId":"CAFjr8EukvC6zsa2vzUWL+YDNLMUh5apmwGQZ1s5WkHg-bC17Kw@mail.gmail.com","threadId":"29801","inReplyTo":null,"subject":"Bug: no-op \"rebase -i\" failures (easily reproduceable)","fromName":"Luiz-Otavio Zorzella","fromEmail":"zorzella@gmail.com","sentAt":"2012-03-01T18:47:08Z","receivedAt":"2012-03-01T18:47:08Z","isPatch":false,"sender":{"key":"zorzella@gmail.com","avatar":null},"body":"I'm having problems with running commands like \"git rebase -i HEAD~40\"\nin my codebase. With git's own git repo, and I got a different error,\nbut I think it's related: I start with a clean tree and issue a no-op\ngit rebase which fails.\n\n$ git --version\ngit version 1.7.7.3\n\n$ git clone git://github.com/gitster/git.git\nCloning into 'git'...\nremote: Counting objects: 129018, done.\nremote: Compressing objects: 100% (41859/41859), done.\nremote: Total 129018 (delta 94779), reused 118799 (delta 85455)\nReceiving objects: 100% (129018/129018), 28.21 MiB | 252 KiB/s, done.\nResolving deltas: 100% (94779/94779), done.\n\n$ cd git\n\n$ git checkout -b blow\nSwitched to a new branch 'blow'\n\n$ git branch\n* blow\n  master\n\n$ EDITOR=echo git rebase -i HEAD~40\n/usr/local/google/z/gitblow/git/.git/rebase-merge/git-rebase-todo\nerror: could not apply ec7ff5b... make lineno_width() from blame\nreusable for others\n\nWhen you have resolved this problem run \"git rebase --continue\".\nIf you would prefer to skip this patch, instead run \"git rebase --skip\".\nTo check out the original branch and stop rebasing run \"git rebase --abort\".\nCould not apply ec7ff5b... make lineno_width() from blame reusable for others\n\n******************************************\n\nZorzella\n"},{"id":"185845","messageId":"7vboogm7g3.fsf@alter.siamese.dyndns.org","threadId":"29801","inReplyTo":"CAFjr8EukvC6zsa2vzUWL+YDNLMUh5apmwGQZ1s5WkHg-bC17Kw@mail.gmail.com","subject":"Re: Bug: no-op \"rebase -i\" failures (easily reproduceable)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-01T19:45:16Z","receivedAt":"2012-03-01T19:45:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luiz-Otavio Zorzella <zorzella@gmail.com> writes:\n\n> $ EDITOR=echo git rebase -i HEAD~40\n> /usr/local/google/z/gitblow/git/.git/rebase-merge/git-rebase-todo\n> error: could not apply ec7ff5b... make lineno_width() from blame\n> reusable for others\n>\n> When you have resolved this problem run \"git rebase --continue\".\n> If you would prefer to skip this patch, instead run \"git rebase --skip\".\n> To check out the original branch and stop rebasing run \"git rebase --abort\".\n> Could not apply ec7ff5b... make lineno_width() from blame reusable for others\n\nThat is hardly surprising, given that you asked to flatten the history\nsince the 40 commits before the tip of your history, and it is done out of\na history that is full of merges from side branches.\n\nAnd it is not even an error, let alone a bug.  The command is asking you\nto resolve conflict it cannot resolve mechanically.  If you do as you are\nasked, you will do just fine.\n\nIt is expected that you will see conflicts in such a rebase, because by\nattempting to flatten the history you are telling Git to replay a commit\nto a context that is different from its original context.\n\nA conflict resolution to replay that particular commit to flatten a recent\nhistory might look like this, but it depends on where in the history you\nstart the rebase from.\n\ndiff --cc cache.h\nindex 3a8e125,24732e6..0000000\n--- a/cache.h\n+++ b/cache.h\n@@@ -1177,7 -1176,7 +1177,8 @@@ extern void setup_pager(void)\n  extern const char *pager_program;\n  extern int pager_in_use(void);\n  extern int pager_use_color;\n +extern int term_columns(void);\n+ extern int decimal_width(int);\n  \n  extern const char *editor_program;\n  extern const char *askpass_program;\ndiff --cc pager.c\nindex b790967,96c07ba..0000000\n--- a/pager.c\n+++ b/pager.c\n@@@ -118,32 -112,13 +118,44 @@@ int pager_in_use(void\n  }\n  \n  /*\n + * Return cached value (if set) or $COLUMNS environment variable (if\n + * set and positive) or ioctl(1, TIOCGWINSZ).ws_col (if positive),\n + * and default to 80 if all else fails.\n + */\n +int term_columns(void)\n +{\n +\tstatic int term_columns_at_startup;\n +\n +\tchar *col_string;\n +\tint n_cols;\n +\n +\tif (term_columns_at_startup)\n +\t\treturn term_columns_at_startup;\n +\n +\tterm_columns_at_startup = 80;\n +\n +\tcol_string = getenv(\"COLUMNS\");\n +\tif (col_string && (n_cols = atoi(col_string)) > 0)\n +\t\tterm_columns_at_startup = n_cols;\n +#ifdef TIOCGWINSZ\n +\telse {\n +\t\tstruct winsize ws;\n +\t\tif (!ioctl(1, TIOCGWINSZ, &ws) && ws.ws_col)\n +\t\t\tterm_columns_at_startup = ws.ws_col;\n +\t}\n +#endif\n +\n +\treturn term_columns_at_startup;\n +}\n++\n++/*\n+  * How many columns do we need to show this number in decimal?\n+  */\n+ int decimal_width(int number)\n+ {\n+ \tint i, width;\n+ \n+ \tfor (width = 1, i = 10; i <= number; width++)\n+ \t\ti *= 10;\n+ \treturn width;\n+ }\n"},{"id":"185848","messageId":"7v399sm5wr.fsf@alter.siamese.dyndns.org","threadId":"29801","inReplyTo":"7vboogm7g3.fsf@alter.siamese.dyndns.org","subject":"Re: Bug: no-op \"rebase -i\" failures (easily reproduceable)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-01T20:18:28Z","receivedAt":"2012-03-01T20:18:28Z","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> Luiz-Otavio Zorzella <zorzella@gmail.com> writes:\n>\n>> $ EDITOR=echo git rebase -i HEAD~40\n>> /usr/local/google/z/gitblow/git/.git/rebase-merge/git-rebase-todo\n>> error: could not apply ec7ff5b... make lineno_width() from blame\n>> reusable for others\n>>\n>> When you have resolved this problem run \"git rebase --continue\".\n>> If you would prefer to skip this patch, instead run \"git rebase --skip\".\n>> To check out the original branch and stop rebasing run \"git rebase --abort\".\n>> Could not apply ec7ff5b... make lineno_width() from blame reusable for others\n>\n> That is hardly surprising, given that you asked to flatten the history\n> since the 40 commits before the tip of your history, and it is done out of\n> a history that is full of merges from side branches.\n>\n> And it is not even an error, let alone a bug.  The command is asking you\n> to resolve conflict it cannot resolve mechanically.  If you do as you are\n> asked, you will do just fine.\n>\n> It is expected that you will see conflicts in such a rebase, because by\n> attempting to flatten the history you are telling Git to replay a commit\n> to a context that is different from its original context.\n\nJust for fun, I tried this experiment to completion, starting at f051ad6\n(Update draft release notes to 1.7.10, 2012-02-28)\n\n    $ git checkout f051ad6\n    $ git rebase -i HEAD~40\n\nwhich pulls in 89 commits to be rebased (that is the number of commits not\nin HEAD~40 and in HEAD).  After resolving and issuing \"rebase --continue\"\nseveral times [*1*], the resulting tree mostly matched the tree I started\nfrom.\n\nAn interesting thing to notice is that I just said \"mostly\".  It misses\nthe change made with an evil merge at 8080906 (Merge branch 'maint',\n2012-02-26) that removes a couple of items out of the \"fixed bugs\" section\nin the 1.7.10 draft release notes, as they already appear in the 1.7.9.x\nrelease notes.  Perhaps I should try to refrain from making these \"Sync\nwith maint, its release notes have \"fixed\" items that we have in 1.7.10\nrelease notes so remove them from the latter\" evil merges.\n\n\n[Footnote]\n\n*1* This is fairly easy for me to do, as my rerere database already knows\nmost of the conflicts this rebase would see---they are the ones I resolved\nmanually when the topics first hit 'next' or even 'pu'.\n"}]}