From: Stephen Haberman Date: Sun, 24 Aug 2008 03:32:24 +0000 (-0500) Subject: Trying a gc prefix. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dfbf3ca90e423b284a3bdc38730718f52c9159b0;p=git-central.git Trying a gc prefix. --- diff --git a/scripts/add b/scripts/add deleted file mode 100644 index 9260eac..0000000 --- a/scripts/add +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -git ls-files -d | xargs -r git rm -git ls-files -m | xargs -r git add -git ls-files -o --exclude-standard | xargs -r git add - diff --git a/scripts/checkout b/scripts/checkout deleted file mode 100644 index b8c5ee9..0000000 --- a/scripts/checkout +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -branch_name=$1 -exists_local=$(git branch | grep -x " $branch_name" | wc -l) -exists_remote=$(git branch | grep -x " origin/$branch_name" | wc -l) - -if [[ $exists_remote -eq 0 ]] ; then - # Make sure we have the latest origin/stable to branch - git fetch - # Specifying stable to get the last released code - git checkout -b "$branch_name" origin/stable - # Go ahead and put the branch out on the server - git push origin "$branch_name" - # Setup the merge property so that pulls come from the right place (instead of stable) - git config --replace-all "branch.$branch_name.merge" "refs/heads/$branch_name" -else - if [[ $exists_local -eq 0 ]] ; then - # Make sure we have the latest origin/$branch_name to branch - git fetch - # Do the checkout - git checkout -b "$branch_name" "origin/$branch_name" - else - # Just checkout - git checkout "$branch_name" - fi -fi - diff --git a/scripts/gc-add b/scripts/gc-add new file mode 100644 index 0000000..9260eac --- /dev/null +++ b/scripts/gc-add @@ -0,0 +1,6 @@ +#!/bin/sh + +git ls-files -d | xargs -r git rm +git ls-files -m | xargs -r git add +git ls-files -o --exclude-standard | xargs -r git add + diff --git a/scripts/gc-checkout b/scripts/gc-checkout new file mode 100644 index 0000000..b8c5ee9 --- /dev/null +++ b/scripts/gc-checkout @@ -0,0 +1,27 @@ +#!/bin/sh + +branch_name=$1 +exists_local=$(git branch | grep -x " $branch_name" | wc -l) +exists_remote=$(git branch | grep -x " origin/$branch_name" | wc -l) + +if [[ $exists_remote -eq 0 ]] ; then + # Make sure we have the latest origin/stable to branch + git fetch + # Specifying stable to get the last released code + git checkout -b "$branch_name" origin/stable + # Go ahead and put the branch out on the server + git push origin "$branch_name" + # Setup the merge property so that pulls come from the right place (instead of stable) + git config --replace-all "branch.$branch_name.merge" "refs/heads/$branch_name" +else + if [[ $exists_local -eq 0 ]] ; then + # Make sure we have the latest origin/$branch_name to branch + git fetch + # Do the checkout + git checkout -b "$branch_name" "origin/$branch_name" + else + # Just checkout + git checkout "$branch_name" + fi +fi + diff --git a/scripts/gc-pull b/scripts/gc-pull new file mode 100644 index 0000000..325eb2d --- /dev/null +++ b/scripts/gc-pull @@ -0,0 +1,4 @@ +#!/bin/sh + +git pull --rebase + diff --git a/scripts/gc-push b/scripts/gc-push new file mode 100644 index 0000000..32952b1 --- /dev/null +++ b/scripts/gc-push @@ -0,0 +1,11 @@ +#!/bin/sh + +branch_name=$(git-symbolic-ref HEAD) + +git push origin $branch_name +if [[ $? -ne 0 ]] ; then + exit $? +fi + +# ...tags... + diff --git a/scripts/gc-remerge b/scripts/gc-remerge new file mode 100644 index 0000000..99d868b --- /dev/null +++ b/scripts/gc-remerge @@ -0,0 +1,25 @@ +#!/bin/sh + +git rev-list --first-parent "origin/stable..HEAD" | while read commit ; do + number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) + if [[ $number_of_parents > 1 ]] ; then + # For each parent + git rev-list --no-walk --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do + echo "merge=$commit parent=$parent" + # Does this parent have any children besides us? + # + # List the parents of all branch commits (after stable/parent), find + # those that include our parent, get their sha1, remove our merge + git rev-list --parents --branches ^stable "^$parent" | grep $parent | gawk '{print $1}' | grep -v $commit | while read child ; do + echo "child $child" + git rev-list "$child" "^$commit" + done + # Find any commits in the parent (and another branch) but not us--that means we need it + # number_missing=$(git rev-list "$parent" --branches "^HEAD" | wc -l) + # if [[ $number_missing > 0 ]] ; then + # git rev-list "$parent" --branches "^HEAD" | xargs git name-rev + # fi + done + fi +done + diff --git a/scripts/pull b/scripts/pull deleted file mode 100644 index 325eb2d..0000000 --- a/scripts/pull +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -git pull --rebase - diff --git a/scripts/push b/scripts/push deleted file mode 100644 index 32952b1..0000000 --- a/scripts/push +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -branch_name=$(git-symbolic-ref HEAD) - -git push origin $branch_name -if [[ $? -ne 0 ]] ; then - exit $? -fi - -# ...tags... - diff --git a/scripts/remerge b/scripts/remerge deleted file mode 100644 index 99d868b..0000000 --- a/scripts/remerge +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -git rev-list --first-parent "origin/stable..HEAD" | while read commit ; do - number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) - if [[ $number_of_parents > 1 ]] ; then - # For each parent - git rev-list --no-walk --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do - echo "merge=$commit parent=$parent" - # Does this parent have any children besides us? - # - # List the parents of all branch commits (after stable/parent), find - # those that include our parent, get their sha1, remove our merge - git rev-list --parents --branches ^stable "^$parent" | grep $parent | gawk '{print $1}' | grep -v $commit | while read child ; do - echo "child $child" - git rev-list "$child" "^$commit" - done - # Find any commits in the parent (and another branch) but not us--that means we need it - # number_missing=$(git rev-list "$parent" --branches "^HEAD" | wc -l) - # if [[ $number_missing > 0 ]] ; then - # git rev-list "$parent" --branches "^HEAD" | xargs git name-rev - # fi - done - fi -done - diff --git a/tests/t5000-script-checkout.sh b/tests/t5000-script-checkout.sh index 937143d..56fb794 100644 --- a/tests/t5000-script-checkout.sh +++ b/tests/t5000-script-checkout.sh @@ -18,7 +18,7 @@ test_expect_success 'setup' ' ' test_expect_success 'checkout a new branch clones stable' ' - checkout topic1 && + gc-checkout topic1 && git branch | grep topic1 && git branch -r | grep origin/topic1 && git config --list | grep "branch.topic1.merge=refs/heads/topic1" @@ -31,14 +31,14 @@ test_expect_success 'checkout an existing remote branch' ' git commit -a -m "Made topic2 on server" && cd .. && - checkout topic2 + gc-checkout topic2 git branch | grep topic2 git branch -r | grep origin/topic2 git config --list | grep "branch.topic2.merge=refs/heads/topic2" ' test_expect_success 'checkout an existing local branch' ' - checkout topic1 + gc-checkout topic1 ' test_done diff --git a/tests/t5100-script-push.sh b/tests/t5100-script-push.sh index 49e1027..7ca75e8 100644 --- a/tests/t5100-script-push.sh +++ b/tests/t5100-script-push.sh @@ -22,17 +22,17 @@ test_expect_success 'setup' ' ' test_expect_success 'push only does one branch' ' - checkout topic1 && + gc-checkout topic1 && echo "$test_name" >a && git commit -a -m "move topic1" && git rev-parse HEAD >head.topic1 && - checkout topic2 && + gc-checkout topic2 && echo "$test_name" >a && git commit -a -m "move topic2" && git rev-parse HEAD >head.topic2 && - push && + gc-push && git rev-parse origin/topic2 >head.origin.topic2 && git rev-parse origin/topic1 >head.origin.topic1 && diff --git a/tests/t5200-script-pull.sh b/tests/t5200-script-pull.sh index 7ecbe47..3bfd5e4 100644 --- a/tests/t5200-script-pull.sh +++ b/tests/t5200-script-pull.sh @@ -18,7 +18,7 @@ test_expect_success 'setup' ' ' test_expect_success 'pull does a rebase' ' - checkout topic1 && + gc-checkout topic1 && echo "$test_name" >a.topic1 && git add a.topic1 && git commit -m "move topic1" && @@ -31,13 +31,13 @@ test_expect_success 'pull does a rebase' ' cd .. && # Only one parent - pull && + gc-pull && git cat-file commit $(git rev-parse HEAD) | grep parent | wc -l | grep 1 ' #test_expect_success 'pull does a rebase but does not fuck up merges' ' # # Change "a" itself so we will eventually conflict -# checkout topic2 && +# gc-checkout topic2 && # echo "$test_name on topic2" >a && # git commit -a -m "move topic2" && # @@ -70,7 +70,7 @@ test_expect_success 'pull does a rebase' ' # git merge origin/stable # # # Now pull and see what happens -# # pull +# # gc-pull #' test_done diff --git a/tests/t5300-script-add.sh b/tests/t5300-script-add.sh index 82ed134..76fdca2 100644 --- a/tests/t5300-script-add.sh +++ b/tests/t5300-script-add.sh @@ -19,19 +19,19 @@ test_expect_success 'setup' ' test_expect_success 'add picks up new files' ' echo "$test_name" >a.new && - add && + gc-add && git commit -m "add" ' test_expect_success 'add picks up changed files' ' echo "$test_name" >a.new && - add && + gc-add && git commit -m "change" ' test_expect_success 'add picks up removed files' ' rm a.new && - add && + gc-add && git commit -m "remove" '