Merge branch 'nm/submodule-update-force'
authorJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2011 22:58:36 +0000 (15:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2011 22:58:36 +0000 (15:58 -0700)
* nm/submodule-update-force:
submodule: Add --force option for git submodule update

Conflicts:
t/t7406-submodule-update.sh

1  2 
Documentation/git-submodule.txt
git-submodule.sh
t/t7406-submodule-update.sh
Simple merge
Simple merge
index bf7c788735d6e3e0ecf56e7a2f82826701ee1789,5d24d9ff74595174a4549bb165fcc8a0800d8120..4f16fcce2bfcb63f437fa6b495fdb5c4370fccc1
@@@ -74,26 -74,29 +74,49 @@@ test_expect_success 'submodule update d
        )
  '
  
 +apos="'";
 +test_expect_success 'submodule update does not fetch already present commits' '
 +      (cd submodule &&
 +        echo line3 >> file &&
 +        git add file &&
 +        test_tick &&
 +        git commit -m "upstream line3"
 +      ) &&
 +      (cd super/submodule &&
 +        head=$(git rev-parse --verify HEAD) &&
 +        echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
 +        git reset --hard HEAD~1
 +      ) &&
 +      (cd super &&
 +        git submodule update > ../actual 2> ../actual.err
 +      ) &&
 +      test_cmp expected actual &&
 +      ! test -s actual.err
 +'
 +
+ test_expect_success 'submodule update should fail due to local changes' '
+       (cd super/submodule &&
+        git reset --hard HEAD~1 &&
+        echo "local change" > file
+       ) &&
+       (cd super &&
+        (cd submodule &&
+         compare_head
+        ) &&
+        test_must_fail git submodule update submodule
+       )
+ '
+ test_expect_success 'submodule update should throw away changes with --force ' '
+       (cd super &&
+        (cd submodule &&
+         compare_head
+        ) &&
+        git submodule update --force submodule &&
+        cd submodule &&
+        ! compare_head
+       )
+ '
  test_expect_success 'submodule update --rebase staying on master' '
        (cd super/submodule &&
          git checkout master