{"thread":{"id":"34455","subject":"[StGit PATCH] Fix dirty index errors when resolving conflicts","startedAt":"2013-07-17T13:57:10Z","lastAt":"2013-07-17T21:23:37Z","messageCount":3,"participants":["Zane Bitter","Keller, Jacob E","Waskiewicz Jr, Peter P"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"223585","messageId":"20130717135454.16504.69116.stgit@zbitter.fedora","threadId":"34455","inReplyTo":null,"subject":"[StGit PATCH] Fix dirty index errors when resolving conflicts","fromName":"Zane Bitter","fromEmail":"zbitter@redhat.com","sentAt":"2013-07-17T13:57:10Z","receivedAt":"2013-07-17T13:57:10Z","isPatch":true,"sender":{"key":"zbitter@redhat.com","avatar":"https://gravatar.com/avatar/82937236ef892b1a9a2604edaf6c427f8329111bbeecea763a5bf8f5273e63d9?d=mp&s=160"},"body":"The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit to raise\n\"warnings\" (actually: errors) in the event that there are changes staged in\nthe index and a refresh is performed without specifying either --index or\n--force. This is great for preventing an entire class of common mistakes,\nbut is also a giant pain when resolving conflicts after a pull/rebase.\nDepending on the workflow in use, this may occur with a frequency anywhere\nbetween \"never\" and \"mulitple times on every pull\".\n\nThis patch removes the pain by:\n - Reporting unresolved conflicts *before* complaining about staged\n   changes, since it goes without saying that, when present, these are the\n   main problem.\n - Not complaining about staged changes if there are no unstaged changes in\n   the working directory, since the presence of --index is immaterial in\n   this case.\n\nSigned-off-by: Zane Bitter <zbitter@redhat.com>\n---\n stgit/commands/refresh.py |   13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\nindex a2bab42..331c18d 100644\n--- a/stgit/commands/refresh.py\n+++ b/stgit/commands/refresh.py\n@@ -247,18 +247,19 @@ def func(parser, options, args):\n     patch_name = get_patch(stack, options.patch)\n     paths = list_files(stack, patch_name, args, options.index, options.update)\n \n-    # Make sure the index is clean before performing a full refresh\n-    if not options.index and not options.force:\n-        if not stack.repository.default_index.is_clean(stack.head):\n-            raise common.CmdException(\n-                'The index is dirty. Did you mean --index? To force a full refresh use --force.')\n-\n     # Make sure there are no conflicts in the files we want to\n     # refresh.\n     if stack.repository.default_index.conflicts() & paths:\n         raise common.CmdException(\n             'Cannot refresh -- resolve conflicts first')\n \n+    # Make sure the index is clean before performing a full refresh\n+    if not options.index and not options.force:\n+        if not (stack.repository.default_index.is_clean(stack.head) or\n+                stack.repository.default_iw.worktree_clean()):\n+            raise common.CmdException(\n+                'The index is dirty. Did you mean --index? To force a full refresh use --force.')\n+\n     # Commit index to temp patch, and absorb it into the target patch.\n     retval, temp_name = make_temp_patch(\n         stack, patch_name, paths, temp_index = path_limiting)\n"},{"id":"223608","messageId":"02874ECE860811409154E81DA85FBB585658699B@ORSMSX104.amr.corp.intel.com","threadId":"34455","inReplyTo":"20130717135454.16504.69116.stgit@zbitter.fedora","subject":"RE: [StGit PATCH] Fix dirty index errors when resolving conflicts","fromName":"Keller, Jacob E","fromEmail":"jacob.e.keller@intel.com","sentAt":"2013-07-17T20:59:31Z","receivedAt":"2013-07-17T20:59:31Z","isPatch":true,"sender":{"key":"jacob.e.keller@intel.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"> -----Original Message-----\n> From: Zane Bitter [mailto:zbitter@redhat.com]\n> Sent: Wednesday, July 17, 2013 6:57 AM\n> To: git@vger.kernel.org\n> Cc: Keller, Jacob E; Waskiewicz Jr, Peter P; catalin.marinas@gmail.com\n> Subject: [StGit PATCH] Fix dirty index errors when resolving conflicts\n> \n> The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit\n> to raise\n> \"warnings\" (actually: errors) in the event that there are changes staged in\n> the index and a refresh is performed without specifying either --index or\n> --force. This is great for preventing an entire class of common mistakes,\n> but is also a giant pain when resolving conflicts after a pull/rebase.\n> Depending on the workflow in use, this may occur with a frequency\n> anywhere\n> between \"never\" and \"mulitple times on every pull\".\n> \n> This patch removes the pain by:\n>  - Reporting unresolved conflicts *before* complaining about staged\n>    changes, since it goes without saying that, when present, these are the\n>    main problem.\n>  - Not complaining about staged changes if there are no unstaged changes\n> in\n>    the working directory, since the presence of --index is immaterial in\n>    this case.\n> \n> Signed-off-by: Zane Bitter <zbitter@redhat.com>\n> ---\n>  stgit/commands/refresh.py |   13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\n> index a2bab42..331c18d 100644\n> --- a/stgit/commands/refresh.py\n> +++ b/stgit/commands/refresh.py\n> @@ -247,18 +247,19 @@ def func(parser, options, args):\n>      patch_name = get_patch(stack, options.patch)\n>      paths = list_files(stack, patch_name, args, options.index,\n> options.update)\n> \n> -    # Make sure the index is clean before performing a full refresh\n> -    if not options.index and not options.force:\n> -        if not stack.repository.default_index.is_clean(stack.head):\n> -            raise common.CmdException(\n> -                'The index is dirty. Did you mean --index? To force a full refresh\n> use --force.')\n> -\n>      # Make sure there are no conflicts in the files we want to\n>      # refresh.\n>      if stack.repository.default_index.conflicts() & paths:\n>          raise common.CmdException(\n>              'Cannot refresh -- resolve conflicts first')\n> \n> +    # Make sure the index is clean before performing a full refresh\n> +    if not options.index and not options.force:\n> +        if not (stack.repository.default_index.is_clean(stack.head) or\n> +                stack.repository.default_iw.worktree_clean()):\n> +            raise common.CmdException(\n> +                'The index is dirty. Did you mean --index? To force a full refresh\n> use --force.')\n> +\n>      # Commit index to temp patch, and absorb it into the target patch.\n>      retval, temp_name = make_temp_patch(\n>          stack, patch_name, paths, temp_index = path_limiting)\n\nACK. This looks great. Thanks for noticing!\n\n- Jake\n\n"},{"id":"223609","messageId":"1374096215.9814.3.camel@ppwaskie-mobl2.jf.intel.com","threadId":"34455","inReplyTo":"20130717135454.16504.69116.stgit@zbitter.fedora","subject":"Re: [StGit PATCH] Fix dirty index errors when resolving conflicts","fromName":"Waskiewicz Jr, Peter P","fromEmail":"peter.p.waskiewicz.jr@intel.com","sentAt":"2013-07-17T21:23:37Z","receivedAt":"2013-07-17T21:23:37Z","isPatch":true,"sender":{"key":"peter.p.waskiewicz.jr@intel.com","avatar":null},"body":"On Wed, 2013-07-17 at 15:57 +0200, Zane Bitter wrote:\n> The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit to raise\n> \"warnings\" (actually: errors) in the event that there are changes staged in\n> the index and a refresh is performed without specifying either --index or\n> --force. This is great for preventing an entire class of common mistakes,\n> but is also a giant pain when resolving conflicts after a pull/rebase.\n> Depending on the workflow in use, this may occur with a frequency anywhere\n> between \"never\" and \"mulitple times on every pull\".\n\nI actually had someone else mention this problem to me last week.  This\nlooks good, I'll be applying this later today.\n\nCheers,\n-PJ\n\n> \n> This patch removes the pain by:\n>  - Reporting unresolved conflicts *before* complaining about staged\n>    changes, since it goes without saying that, when present, these are the\n>    main problem.\n>  - Not complaining about staged changes if there are no unstaged changes in\n>    the working directory, since the presence of --index is immaterial in\n>    this case.\n> \n> Signed-off-by: Zane Bitter <zbitter@redhat.com>\n> ---\n>  stgit/commands/refresh.py |   13 +++++++------\n>  1 file changed, 7 insertions(+), 6 deletions(-)\n> \n> diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\n> index a2bab42..331c18d 100644\n> --- a/stgit/commands/refresh.py\n> +++ b/stgit/commands/refresh.py\n> @@ -247,18 +247,19 @@ def func(parser, options, args):\n>      patch_name = get_patch(stack, options.patch)\n>      paths = list_files(stack, patch_name, args, options.index, options.update)\n>  \n> -    # Make sure the index is clean before performing a full refresh\n> -    if not options.index and not options.force:\n> -        if not stack.repository.default_index.is_clean(stack.head):\n> -            raise common.CmdException(\n> -                'The index is dirty. Did you mean --index? To force a full refresh use --force.')\n> -\n>      # Make sure there are no conflicts in the files we want to\n>      # refresh.\n>      if stack.repository.default_index.conflicts() & paths:\n>          raise common.CmdException(\n>              'Cannot refresh -- resolve conflicts first')\n>  \n> +    # Make sure the index is clean before performing a full refresh\n> +    if not options.index and not options.force:\n> +        if not (stack.repository.default_index.is_clean(stack.head) or\n> +                stack.repository.default_iw.worktree_clean()):\n> +            raise common.CmdException(\n> +                'The index is dirty. Did you mean --index? To force a full refresh use --force.')\n> +\n>      # Commit index to temp patch, and absorb it into the target patch.\n>      retval, temp_name = make_temp_patch(\n>          stack, patch_name, paths, temp_index = path_limiting)\n> \n\n"}]}