From a1845d219aa71e1b679d9d97be41366ddd478cb1 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 7 Mar 2010 18:57:55 -0800 Subject: [PATCH] Fix `git remote add -f user` --- HISTORY.md | 4 ++++ lib/hub/commands.rb | 8 +++++--- test/hub_test.rb | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 60a1fea92..dc6a6c09e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +## 1.0.2 (2010-03-07) + +* Bugfix: `hub remote -f name` (for real this time) + ## 1.0.1 (2010-03-05) * Bugfix: `hub remote -f name` diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index ed316666f..25da6dce5 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -119,7 +119,9 @@ def remote(args) if args.words[-2] == args.words[1] # rtomayko/tilt => rtomayko - args[-1] = user + # Make sure you dance around flags. + idx = args.index( args.words[-1] ) + args[idx] = user else # They're specifying the remote name manually (e.g. # git remote add blah rtomayko/tilt), so just drop the last @@ -129,7 +131,7 @@ def remote(args) args << url % [ user, repo ] elsif args.last !~ /:|\// - if args[2] == 'origin' && args[3].nil? + if args.words[2] == 'origin' && args.words[3].nil? # Origin special case. user = github_user else @@ -137,7 +139,7 @@ def remote(args) user = args.last end - if args[-2] != args[1] + if args.words[-2] != args.words[1] # They're specifying the remote name manually (e.g. # git remote add blah rtomayko), so just drop the last # argument. diff --git a/test/hub_test.rb b/test/hub_test.rb index 6681a37f8..ff4ee03c6 100644 --- a/test/hub_test.rb +++ b/test/hub_test.rb @@ -117,6 +117,12 @@ def test_public_remote assert_command input, command end + def test_public_remote_f + input = "remote add -f rtomayko" + command = "git remote add -f rtomayko git://github.com/rtomayko/hub.git" + assert_command input, command + end + def test_named_public_remote input = "remote add origin rtomayko" command = "git remote add origin git://github.com/rtomayko/hub.git"