* [PATCH] mergetool: clean up temp files when aborted
@ 2013-01-24 18:23 Phil Hord
2013-01-24 19:54 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Phil Hord @ 2013-01-24 18:23 UTC (permalink / raw)
To: git; +Cc: phil.hord, Theodore Ts'o, Junio C Hamano, Phil Hord
When handling a symlink conflict or a deleted-file conflict, mergetool
stops to ask the user what to do. If the user chooses any option besides
"(a)bort", then the temporary files which mergetool created in
preparation for handling the conflict are removed. But these temporary
files are not removed when the user chooses to abort the operation.
$ git cherry-pick other/branch
error: could not apply 4e43581... Fix foo.c
$ git status --short
DU foo.c
$ git mergetool
Merging:
foo.c
Deleted merge conflict for 'foo.c':
{local}: deleted
{remote}: modified file
Use (m)odified or (d)eleted file, or (a)bort? a
Continue merging other unresolved paths (y/n) ? n
$ git status --short
DU foo.c
?? foo.c.BACKUP.16929.c
?? foo.c.BASE.16929.c
?? foo.c.LOCAL.16929.c
?? foo.c.REMOTE.16929.c
These temporary files should not remain after the mergetool operation is
completed.
Remove the temporary files by calling the cleanup_temp_files when the
user chooses to abort the mergetool operation.
It looks like 'cleanup_temp_files' without the --save-backups option is
the correct thing to do, and this is how this commit is implemented. But
some other paths do use --save-backups resulting in a foo.c.orig file
being left behind. That seems to be a different bug, though.
Signed-off-by: Phil Hord <hordp@cisco.com>
---
git-mergetool.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index c50e18a..bb93b70 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -90,6 +90,7 @@ resolve_symlink_merge () {
return 0
;;
[aA]*)
+ cleanup_temp_files
return 1
;;
esac
@@ -118,6 +119,7 @@ resolve_deleted_merge () {
return 0
;;
[aA]*)
+ cleanup_temp_files
return 1
;;
esac
--
1.8.1.1.ga649ac9.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mergetool: clean up temp files when aborted
2013-01-24 18:23 [PATCH] mergetool: clean up temp files when aborted Phil Hord
@ 2013-01-24 19:54 ` Junio C Hamano
2013-01-24 21:16 ` Phil Hord
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2013-01-24 19:54 UTC (permalink / raw)
To: Phil Hord; +Cc: git, phil.hord, Theodore Ts'o
Phil Hord <hordp@cisco.com> writes:
> When handling a symlink conflict or a deleted-file conflict, mergetool
> stops to ask the user what to do. If the user chooses any option besides
> "(a)bort", then the temporary files which mergetool created in
> preparation for handling the conflict are removed. But these temporary
> files are not removed when the user chooses to abort the operation.
>
> $ git cherry-pick other/branch
> error: could not apply 4e43581... Fix foo.c
>
> $ git status --short
> DU foo.c
>
> $ git mergetool
> Merging:
> foo.c
>
> Deleted merge conflict for 'foo.c':
> {local}: deleted
> {remote}: modified file
> Use (m)odified or (d)eleted file, or (a)bort? a
> Continue merging other unresolved paths (y/n) ? n
>
> $ git status --short
> DU foo.c
> ?? foo.c.BACKUP.16929.c
> ?? foo.c.BASE.16929.c
> ?? foo.c.LOCAL.16929.c
> ?? foo.c.REMOTE.16929.c
>
> These temporary files should not remain after the mergetool operation is
> completed.
Aren't there cases where people "abort" so that they can have a
chance inspect them outside mergetool program? If there are no such
cases, then I would agree with your claim "should not remain", but
the proposed log message does not explay why it is sure that there
are no such use cases.
>
> Remove the temporary files by calling the cleanup_temp_files when the
> user chooses to abort the mergetool operation.
>
> It looks like 'cleanup_temp_files' without the --save-backups option is
> the correct thing to do, and this is how this commit is implemented. But
> some other paths do use --save-backups resulting in a foo.c.orig file
> being left behind. That seems to be a different bug, though.
>
> Signed-off-by: Phil Hord <hordp@cisco.com>
> ---
> git-mergetool.sh | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/git-mergetool.sh b/git-mergetool.sh
> index c50e18a..bb93b70 100755
> --- a/git-mergetool.sh
> +++ b/git-mergetool.sh
> @@ -90,6 +90,7 @@ resolve_symlink_merge () {
> return 0
> ;;
> [aA]*)
> + cleanup_temp_files
> return 1
> ;;
> esac
> @@ -118,6 +119,7 @@ resolve_deleted_merge () {
> return 0
> ;;
> [aA]*)
> + cleanup_temp_files
> return 1
> ;;
> esac
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mergetool: clean up temp files when aborted
2013-01-24 19:54 ` Junio C Hamano
@ 2013-01-24 21:16 ` Phil Hord
2013-01-24 21:41 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Phil Hord @ 2013-01-24 21:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Phil Hord, git@vger.kernel.org, Theodore Ts'o
On Thu, Jan 24, 2013 at 2:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Phil Hord <hordp@cisco.com> writes:
>
>> When handling a symlink conflict or a deleted-file conflict, mergetool
>> stops to ask the user what to do. If the user chooses any option besides
>> "(a)bort", then the temporary files which mergetool created in
>> preparation for handling the conflict are removed. But these temporary
>> files are not removed when the user chooses to abort the operation.
>>
>> $ git cherry-pick other/branch
>> error: could not apply 4e43581... Fix foo.c
>>
>> $ git status --short
>> DU foo.c
>>
>> $ git mergetool
>> Merging:
>> foo.c
>>
>> Deleted merge conflict for 'foo.c':
>> {local}: deleted
>> {remote}: modified file
>> Use (m)odified or (d)eleted file, or (a)bort? a
>> Continue merging other unresolved paths (y/n) ? n
>>
>> $ git status --short
>> DU foo.c
>> ?? foo.c.BACKUP.16929.c
>> ?? foo.c.BASE.16929.c
>> ?? foo.c.LOCAL.16929.c
>> ?? foo.c.REMOTE.16929.c
>>
>> These temporary files should not remain after the mergetool operation is
>> completed.
>
> Aren't there cases where people "abort" so that they can have a
> chance inspect them outside mergetool program? If there are no such
> cases, then I would agree with your claim "should not remain", but
> the proposed log message does not explay why it is sure that there
> are no such use cases.
You may be right about other people's workflows which I forgot to
consider. I have noticed a lot of inconsistency in this tool wrt to
mergetool.keepBackup and mergetool.keepTemporaries. Perhaps this
change should hinge on the latter.
Would you agree with this rephrased statement (accompanied by matching logic)?
When mergetool.keepTemporaries is false or not set, these temporary files
should not remain when the mergetool operation is aborted.
Here is the wording from git help config:
mergetool.keepBackup
After performing a merge, the original file with conflict
markers can be saved as a file with a .orig extension. If this
variable is set to false then this file
is not preserved. Defaults to true (i.e. keep the backup files).
mergetool.keepTemporaries
When invoking a custom merge tool, git uses a set of
temporary files to pass to the tool. If the tool returns an error and
this variable is set to true, then
these temporary files will be preserved, otherwise they
will be removed after the tool has exited. Defaults to false.
I have another commit in the works to clean up consistency around the
keepBackup. I'll re-roll this one at the same time.
Phil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mergetool: clean up temp files when aborted
2013-01-24 21:16 ` Phil Hord
@ 2013-01-24 21:41 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2013-01-24 21:41 UTC (permalink / raw)
To: Phil Hord; +Cc: Phil Hord, git@vger.kernel.org, Theodore Ts'o
Phil Hord <phil.hord@gmail.com> writes:
> On Thu, Jan 24, 2013 at 2:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Phil Hord <hordp@cisco.com> writes:
>> ...
>>> These temporary files should not remain after the mergetool operation is
>>> completed.
>>
>> Aren't there cases where people "abort" so that they can have a
>> chance inspect them outside mergetool program? If there are no such
>> cases, then I would agree with your claim "should not remain", but
>> the proposed log message does not explay why it is sure that there
>> are no such use cases.
>
> You may be right about other people's workflows which I forgot to
> consider. I have noticed a lot of inconsistency in this tool wrt to
> mergetool.keepBackup and mergetool.keepTemporaries. Perhaps this
> change should hinge on the latter.
>
> Would you agree with this rephrased statement (accompanied by matching logic)?
>
> When mergetool.keepTemporaries is false or not set, these temporary files
> should not remain when the mergetool operation is aborted.
That is perfectly sensible (and should apply equally to non-"abort"
cases, I think).
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-24 21:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-24 18:23 [PATCH] mergetool: clean up temp files when aborted Phil Hord
2013-01-24 19:54 ` Junio C Hamano
2013-01-24 21:16 ` Phil Hord
2013-01-24 21:41 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).