* [StGit PATCH] Fix dirty index errors when resolving conflicts
@ 2013-07-17 13:57 Zane Bitter
2013-07-17 20:59 ` Keller, Jacob E
2013-07-17 21:23 ` Waskiewicz Jr, Peter P
0 siblings, 2 replies; 3+ messages in thread
From: Zane Bitter @ 2013-07-17 13:57 UTC (permalink / raw)
To: git; +Cc: jacob.e.keller, peter.p.waskiewicz.jr, catalin.marinas
The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit to raise
"warnings" (actually: errors) in the event that there are changes staged in
the index and a refresh is performed without specifying either --index or
--force. This is great for preventing an entire class of common mistakes,
but is also a giant pain when resolving conflicts after a pull/rebase.
Depending on the workflow in use, this may occur with a frequency anywhere
between "never" and "mulitple times on every pull".
This patch removes the pain by:
- Reporting unresolved conflicts *before* complaining about staged
changes, since it goes without saying that, when present, these are the
main problem.
- Not complaining about staged changes if there are no unstaged changes in
the working directory, since the presence of --index is immaterial in
this case.
Signed-off-by: Zane Bitter <zbitter@redhat.com>
---
stgit/commands/refresh.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
index a2bab42..331c18d 100644
--- a/stgit/commands/refresh.py
+++ b/stgit/commands/refresh.py
@@ -247,18 +247,19 @@ def func(parser, options, args):
patch_name = get_patch(stack, options.patch)
paths = list_files(stack, patch_name, args, options.index, options.update)
- # Make sure the index is clean before performing a full refresh
- if not options.index and not options.force:
- if not stack.repository.default_index.is_clean(stack.head):
- raise common.CmdException(
- 'The index is dirty. Did you mean --index? To force a full refresh use --force.')
-
# Make sure there are no conflicts in the files we want to
# refresh.
if stack.repository.default_index.conflicts() & paths:
raise common.CmdException(
'Cannot refresh -- resolve conflicts first')
+ # Make sure the index is clean before performing a full refresh
+ if not options.index and not options.force:
+ if not (stack.repository.default_index.is_clean(stack.head) or
+ stack.repository.default_iw.worktree_clean()):
+ raise common.CmdException(
+ 'The index is dirty. Did you mean --index? To force a full refresh use --force.')
+
# Commit index to temp patch, and absorb it into the target patch.
retval, temp_name = make_temp_patch(
stack, patch_name, paths, temp_index = path_limiting)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [StGit PATCH] Fix dirty index errors when resolving conflicts
2013-07-17 13:57 [StGit PATCH] Fix dirty index errors when resolving conflicts Zane Bitter
@ 2013-07-17 20:59 ` Keller, Jacob E
2013-07-17 21:23 ` Waskiewicz Jr, Peter P
1 sibling, 0 replies; 3+ messages in thread
From: Keller, Jacob E @ 2013-07-17 20:59 UTC (permalink / raw)
To: Zane Bitter, git; +Cc: Waskiewicz Jr, Peter P, catalin.marinas
> -----Original Message-----
> From: Zane Bitter [mailto:zbitter@redhat.com]
> Sent: Wednesday, July 17, 2013 6:57 AM
> To: git@vger.kernel.org
> Cc: Keller, Jacob E; Waskiewicz Jr, Peter P; catalin.marinas@gmail.com
> Subject: [StGit PATCH] Fix dirty index errors when resolving conflicts
>
> The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit
> to raise
> "warnings" (actually: errors) in the event that there are changes staged in
> the index and a refresh is performed without specifying either --index or
> --force. This is great for preventing an entire class of common mistakes,
> but is also a giant pain when resolving conflicts after a pull/rebase.
> Depending on the workflow in use, this may occur with a frequency
> anywhere
> between "never" and "mulitple times on every pull".
>
> This patch removes the pain by:
> - Reporting unresolved conflicts *before* complaining about staged
> changes, since it goes without saying that, when present, these are the
> main problem.
> - Not complaining about staged changes if there are no unstaged changes
> in
> the working directory, since the presence of --index is immaterial in
> this case.
>
> Signed-off-by: Zane Bitter <zbitter@redhat.com>
> ---
> stgit/commands/refresh.py | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
> index a2bab42..331c18d 100644
> --- a/stgit/commands/refresh.py
> +++ b/stgit/commands/refresh.py
> @@ -247,18 +247,19 @@ def func(parser, options, args):
> patch_name = get_patch(stack, options.patch)
> paths = list_files(stack, patch_name, args, options.index,
> options.update)
>
> - # Make sure the index is clean before performing a full refresh
> - if not options.index and not options.force:
> - if not stack.repository.default_index.is_clean(stack.head):
> - raise common.CmdException(
> - 'The index is dirty. Did you mean --index? To force a full refresh
> use --force.')
> -
> # Make sure there are no conflicts in the files we want to
> # refresh.
> if stack.repository.default_index.conflicts() & paths:
> raise common.CmdException(
> 'Cannot refresh -- resolve conflicts first')
>
> + # Make sure the index is clean before performing a full refresh
> + if not options.index and not options.force:
> + if not (stack.repository.default_index.is_clean(stack.head) or
> + stack.repository.default_iw.worktree_clean()):
> + raise common.CmdException(
> + 'The index is dirty. Did you mean --index? To force a full refresh
> use --force.')
> +
> # Commit index to temp patch, and absorb it into the target patch.
> retval, temp_name = make_temp_patch(
> stack, patch_name, paths, temp_index = path_limiting)
ACK. This looks great. Thanks for noticing!
- Jake
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [StGit PATCH] Fix dirty index errors when resolving conflicts
2013-07-17 13:57 [StGit PATCH] Fix dirty index errors when resolving conflicts Zane Bitter
2013-07-17 20:59 ` Keller, Jacob E
@ 2013-07-17 21:23 ` Waskiewicz Jr, Peter P
1 sibling, 0 replies; 3+ messages in thread
From: Waskiewicz Jr, Peter P @ 2013-07-17 21:23 UTC (permalink / raw)
To: Zane Bitter; +Cc: git, Keller, Jacob E, catalin.marinas
On Wed, 2013-07-17 at 15:57 +0200, Zane Bitter wrote:
> The patch 6e8fdc58c786a45d7a63c5edf9c702f1874a7a19 causes StGit to raise
> "warnings" (actually: errors) in the event that there are changes staged in
> the index and a refresh is performed without specifying either --index or
> --force. This is great for preventing an entire class of common mistakes,
> but is also a giant pain when resolving conflicts after a pull/rebase.
> Depending on the workflow in use, this may occur with a frequency anywhere
> between "never" and "mulitple times on every pull".
I actually had someone else mention this problem to me last week. This
looks good, I'll be applying this later today.
Cheers,
-PJ
>
> This patch removes the pain by:
> - Reporting unresolved conflicts *before* complaining about staged
> changes, since it goes without saying that, when present, these are the
> main problem.
> - Not complaining about staged changes if there are no unstaged changes in
> the working directory, since the presence of --index is immaterial in
> this case.
>
> Signed-off-by: Zane Bitter <zbitter@redhat.com>
> ---
> stgit/commands/refresh.py | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
> index a2bab42..331c18d 100644
> --- a/stgit/commands/refresh.py
> +++ b/stgit/commands/refresh.py
> @@ -247,18 +247,19 @@ def func(parser, options, args):
> patch_name = get_patch(stack, options.patch)
> paths = list_files(stack, patch_name, args, options.index, options.update)
>
> - # Make sure the index is clean before performing a full refresh
> - if not options.index and not options.force:
> - if not stack.repository.default_index.is_clean(stack.head):
> - raise common.CmdException(
> - 'The index is dirty. Did you mean --index? To force a full refresh use --force.')
> -
> # Make sure there are no conflicts in the files we want to
> # refresh.
> if stack.repository.default_index.conflicts() & paths:
> raise common.CmdException(
> 'Cannot refresh -- resolve conflicts first')
>
> + # Make sure the index is clean before performing a full refresh
> + if not options.index and not options.force:
> + if not (stack.repository.default_index.is_clean(stack.head) or
> + stack.repository.default_iw.worktree_clean()):
> + raise common.CmdException(
> + 'The index is dirty. Did you mean --index? To force a full refresh use --force.')
> +
> # Commit index to temp patch, and absorb it into the target patch.
> retval, temp_name = make_temp_patch(
> stack, patch_name, paths, temp_index = path_limiting)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-17 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-17 13:57 [StGit PATCH] Fix dirty index errors when resolving conflicts Zane Bitter
2013-07-17 20:59 ` Keller, Jacob E
2013-07-17 21:23 ` Waskiewicz Jr, Peter P
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.