threads / patch / 2883

patchcg-seek should not complain if run twice

Subject: [PATCH] cg-seek should not complain if run twice

## tl;dr

4 messages between Dec 20, 2005 and Jan 15, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Pavel Roskin· Dec 20, 2005, 04:55 UTC · lore
cg-seek complains if run without arguments in a non-seeked repository:

rm: cannot remove `.git/refs/heads/cg-seek-point': No such file or directory rm: cannot remove `.git/head-name': No such file or directory

In fact, it's OK for those files not to exist, so they should be removed silently.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Show changes to cg-seek +1 −1
diff --git a/cg-seek b/cg-seek
index 942267f..8356593 100755
--- a/cg-seek
+++ b/cg-seek
@@ -60,7 +60,7 @@ if [ "$seek_mode" = "away" ]; then
 	git-symbolic-ref HEAD "refs/heads/cg-seek-point"
 else
 	git-symbolic-ref HEAD "refs/heads/$_git_head"
-	rm "$_git/refs/heads/cg-seek-point" "$_git/head-name"
+	rm -f "$_git/refs/heads/cg-seek-point" "$_git/head-name"
 	rm -f "$_git/blocked"
 fi
 
-- 
Regards,
Pavel Roskin
Petr Baudis· Jan 14, 2006, 23:30 UTC · re: Pavel Roskin · lore

Re: [PATCH] cg-seek should not complain if run twice

Dear diary, on Tue, Dec 20, 2005 at 05:55:36AM CET, I got a letter where Pavel Roskin <proski@gnu.org> said that...

Show 9 quoted lines
> cg-seek complains if run without arguments in a non-seeked repository:
> 
> rm: cannot remove `.git/refs/heads/cg-seek-point': No such file or directory
> rm: cannot remove `.git/head-name': No such file or directory
> 
> In fact, it's OK for those files not to exist, so they should be removed
> silently.
> 
> Signed-off-by: Pavel Roskin <proski@gnu.org>

It seems cleaner to just make cg-seek fail with a sensible error message if it's already unseeked.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Of the 3 great composers Mozart tells us what it's like to be human,
Beethoven tells us what it's like to be Beethoven and Bach tells us
what it's like to be the universe.  -- Douglas Adams
Pavel Roskin· Jan 15, 2006, 06:03 UTC · re: Petr Baudis · lore

Re: [PATCH] cg-seek should not complain if run twice

Hello, Petr!
Quoting Petr Baudis <pasky@suse.cz>:
> It seems cleaner to just make cg-seek fail with a sensible error message
> if it's already unseeked.

I don't like this. What if "cvs up -A" would fail if run twice? What if cg-clean would fail if there was nothing to clean? What if sync would fail if it didn't cause a single disk write? Idempotent operations are easier to work with. Please see http://en.wikipedia.org/wiki/Idempotent_(software)

I could make an exception for the case when the command invocation indicates that the user is unaware of something, and that it would endanger the user's data. But it's not the case for cg-seek without arguments on non-seeked repository. The intention is clear, and the knowledge of the current state of the repository doesn't matter, since there will be no merge or something.

-- Regards, Pavel Roskin

Petr Baudis· Jan 15, 2006, 23:59 UTC · re: Pavel Roskin · lore

Re: [PATCH] cg-seek should not complain if run twice

  Hello,

Dear diary, on Sun, Jan 15, 2006 at 07:03:35AM CET, I got a letter where Pavel Roskin <proski@gnu.org> said that...

Show 15 quoted lines
> Quoting Petr Baudis <pasky@suse.cz>:
> 
> > It seems cleaner to just make cg-seek fail with a sensible error message
> > if it's already unseeked.
> 
> I don't like this.  What if "cvs up -A" would fail if run twice?  What if
> cg-clean would fail if there was nothing to clean?  What if sync would fail if
> it didn't cause a single disk write?  Idempotent operations are easier to work
> with.  Please see http://en.wikipedia.org/wiki/Idempotent_(software)
> 
> I could make an exception for the case when the command invocation indicates
> that the user is unaware of something, and that it would endanger the user's
> data.  But it's not the case for cg-seek without arguments on non-seeked
> repository.  The intention is clear, and the knowledge of the current state of
> the repository doesn't matter, since there will be no merge or something.
  I have my reservations to this argumentation in the specific cg-seek
case, but it's very subjective, unclear, and I personally really don't
care. So let it be your way. ;-)
  Thanks for your opinion,
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Of the 3 great composers Mozart tells us what it's like to be human,
Beethoven tells us what it's like to be Beethoven and Bach tells us
what it's like to be the universe.  -- Douglas Adams

← back to recent threads