Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 1 | # |
Vincent Driessen | 6c2d30b | 2010-01-26 22:18:36 +0100 | [diff] [blame] | 2 | # git-flow -- A collection of Git extensions to provide high-level |
| 3 | # repository operations for Vincent Driessen's branching model. |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 4 | # |
| 5 | # Original blog post presenting this model is found at: |
| 6 | # http://nvie.com/archives/323 |
| 7 | # |
| 8 | # Feel free to contribute to this project at: |
| 9 | # http://github.com/nvie/gitflow |
| 10 | # |
| 11 | # Copyright (c) 2010 by Vincent Driessen |
| 12 | # Copyright (c) 2010 by Benedikt Böhm |
| 13 | # |
| 14 | |
Benedikt Böhm | 49dd62b | 2010-01-28 00:51:15 +0100 | [diff] [blame] | 15 | PREFIX=$(git config --get gitflow.prefix.feature || echo feature/) |
| 16 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 17 | usage() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 18 | echo "usage: git flow feature [list]" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 19 | echo " git flow feature start <name> [<base>]" |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 20 | echo " git flow feature finish <name|nameprefix> [<base>]" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 21 | echo " git flow feature publish <name>" |
| 22 | echo " git flow feature track <name>" |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 23 | echo " git flow feature diff <name|nameprefix>" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 24 | # TODO |
| 25 | #echo "" |
| 26 | #echo "options:" |
| 27 | #echo "--option Explanation" |
| 28 | #echo "" |
| 29 | #echo "start-only options:" |
| 30 | #echo "--option Explanation" |
| 31 | #echo "" |
| 32 | #echo "finish-only options:" |
| 33 | #echo "--rebase Rebases the feature branch on top of develop, instead of merging" |
| 34 | #echo "--squash Squashes all commits of the feature branch into a single commit" |
| 35 | #echo " on develop" |
| 36 | #echo "--push Push to the origin repo when finished" |
| 37 | } |
| 38 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 39 | cmd_default() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 40 | cmd_list "$@" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 41 | } |
| 42 | |
Vincent Driessen | 1adbc3e | 2010-01-30 16:28:20 +0100 | [diff] [blame] | 43 | max() { if [ "$1" -gt "$2" ]; then echo "$1"; else echo "$2"; fi; } |
| 44 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 45 | cmd_list() { |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 46 | DEFINE_boolean verbose 0 'verbose (more) output' v |
| 47 | parse_args "$@" |
| 48 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 49 | FEATURE_BRANCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX")" |
| 50 | if [ -z "$FEATURE_BRANCHES" ]; then |
| 51 | warn "No feature branches exist." |
| 52 | exit 0 |
| 53 | fi |
Vincent Driessen | f2536f4 | 2010-02-01 15:57:48 +0100 | [diff] [blame] | 54 | |
Vincent Driessen | aa6d016 | 2010-02-01 19:43:46 +0100 | [diff] [blame^] | 55 | CURRENT_BRANCH=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') |
Vincent Driessen | f2536f4 | 2010-02-01 15:57:48 +0100 | [diff] [blame] | 56 | SHORT_NAMES=$(echo "$FEATURE_BRANCHES" | sed "s?^$PREFIX??g") |
Vincent Driessen | aa6d016 | 2010-02-01 19:43:46 +0100 | [diff] [blame^] | 57 | # determine column width first |
| 58 | width=0 |
| 59 | for branch in $SHORT_NAMES; do |
| 60 | len=$(($(echo "$branch" | wc -c) - 1)) |
| 61 | width=$(max $width $len) |
| 62 | done |
| 63 | width=$(($width + 3)) |
Vincent Driessen | 1adbc3e | 2010-01-30 16:28:20 +0100 | [diff] [blame] | 64 | |
Vincent Driessen | aa6d016 | 2010-02-01 19:43:46 +0100 | [diff] [blame^] | 65 | for branch in $SHORT_NAMES; do |
| 66 | fullname="$PREFIX$branch" |
| 67 | base=$(git merge-base "$fullname" "$DEVELOP_BRANCH") |
| 68 | develop_sha=$(git rev-parse "$DEVELOP_BRANCH") |
| 69 | branch_sha=$(git rev-parse "$fullname") |
| 70 | if [ "$fullname" = "$CURRENT_BRANCH" ]; then |
| 71 | printf "* " |
| 72 | else |
| 73 | printf " " |
| 74 | fi |
| 75 | if [ $FLAGS_verbose -eq 1 ]; then |
Vincent Driessen | 1adbc3e | 2010-01-30 16:28:20 +0100 | [diff] [blame] | 76 | printf "%-${width}s" "$branch" |
Vincent Driessen | f2536f4 | 2010-02-01 15:57:48 +0100 | [diff] [blame] | 77 | if [ "$branch_sha" = "$develop_sha" ]; then |
| 78 | printf "(no commits yet)" |
| 79 | elif [ "$base" = "$branch_sha" ]; then |
| 80 | printf "(is behind develop, may ff)" |
| 81 | elif [ "$base" = "$develop_sha" ]; then |
| 82 | printf "(based on latest develop)" |
| 83 | else |
| 84 | printf "(may be rebased)" |
| 85 | fi |
Vincent Driessen | aa6d016 | 2010-02-01 19:43:46 +0100 | [diff] [blame^] | 86 | else |
| 87 | printf "%s" "$branch" |
| 88 | fi |
| 89 | echo |
| 90 | done |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 93 | cmd_help() { |
| 94 | usage |
| 95 | exit 0 |
| 96 | } |
| 97 | |
Vincent Driessen | 22ef21a | 2010-01-29 16:43:37 +0100 | [diff] [blame] | 98 | resolve_name_by_prefix() { |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 99 | # first, check if there is a perfect match |
Vincent Driessen | 22ef21a | 2010-01-29 16:43:37 +0100 | [diff] [blame] | 100 | if has "$LOCAL_BRANCHES" "$PREFIX$1"; then |
| 101 | echo "$1" |
| 102 | return 0 |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 103 | fi |
| 104 | |
| 105 | MATCHES="$(echo "$LOCAL_BRANCHES" | grep "^$PREFIX$1")" |
| 106 | NUM_MATCHES=$(echo "$MATCHES" | wc -l) |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 107 | if [ -z "$MATCHES" ]; then |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 108 | # no prefix match, so take it literally |
| 109 | echo "$1" |
| 110 | else |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 111 | if [ $NUM_MATCHES -eq 1 ]; then |
| 112 | # sed arg looks a bit weird, but $PREFIX should not contain spaces, |
| 113 | # so this one is safe |
| 114 | echo "$MATCHES" | sed "s $PREFIX g" |
| 115 | else |
| 116 | # multiple matches, cannot decide |
| 117 | warn "Multiple branches match for prefix '$1':" |
| 118 | for match in $MATCHES; do |
| 119 | warn "- $match" |
| 120 | done |
| 121 | die "Aborting. Use an unambiguous prefix." |
| 122 | fi |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 123 | fi |
| 124 | } |
| 125 | |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 126 | require_name() { |
| 127 | if [ "$NAME" = "" ]; then |
| 128 | echo "Missing argument <name>" |
| 129 | usage |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 130 | exit 1 |
| 131 | fi |
| 132 | } |
| 133 | |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 134 | expand_name_arg_prefix() { |
| 135 | require_name |
| 136 | NAME=$(resolve_name_by_prefix "$NAME") |
| 137 | if echo "$NAME" | grep -q "^[ \t\n\r]+$"; then |
Vincent Driessen | 2e1856b | 2010-01-29 15:18:13 +0100 | [diff] [blame] | 138 | exit 1 |
| 139 | fi |
| 140 | BRANCH=$PREFIX$NAME |
| 141 | } |
| 142 | |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 143 | parse_args() { |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 144 | # parse options |
| 145 | FLAGS "$@" || exit $? |
| 146 | eval set -- "${FLAGS_ARGV}" |
| 147 | |
| 148 | # read arguments into global variables |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 149 | NAME="$1" |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 150 | BASE="${2:-$DEVELOP_BRANCH}" |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 151 | } |
| 152 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 153 | cmd_start() { |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 154 | DEFINE_boolean fetch 0 'fetch from origin before performing local operation' F |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 155 | parse_args "$@" |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 156 | require_name |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 157 | |
| 158 | # sanity checks |
Vincent Driessen | 4838644 | 2010-01-29 10:30:40 +0100 | [diff] [blame] | 159 | gitflow_require_clean_working_tree |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 160 | gitflow_require_branch_absent $BRANCH |
Vincent Driessen | e034e4a | 2010-01-29 12:10:44 +0100 | [diff] [blame] | 161 | |
| 162 | # update the local repo with remote changes, if asked |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 163 | if [ $FLAGS_fetch -eq 1 ]; then |
Benedikt Böhm | 4d22227 | 2010-01-26 14:46:56 +0100 | [diff] [blame] | 164 | git fetch -q $ORIGIN $DEVELOP_BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 165 | fi |
| 166 | |
Vincent Driessen | e034e4a | 2010-01-29 12:10:44 +0100 | [diff] [blame] | 167 | gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH |
| 168 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 169 | # create branch |
| 170 | git checkout -b $BRANCH $BASE |
| 171 | |
| 172 | echo |
| 173 | echo "Summary of actions:" |
| 174 | echo "- A new branch '$BRANCH' was created, based on '$BASE'" |
| 175 | echo "- You are now on branch '$BRANCH'" |
| 176 | echo "" |
| 177 | echo "Now, start committing on your feature. When done, use:" |
| 178 | echo "" |
| 179 | echo " git flow finish feature $NAME" |
| 180 | echo |
| 181 | } |
| 182 | |
| 183 | cmd_finish() { |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 184 | DEFINE_boolean fetch 0 'fetch from origin before performing local operation' F |
| 185 | DEFINE_boolean rebase 0 'rebase instead of merge' r |
| 186 | DEFINE_boolean squash 0 'squash all commits when rebasing (implies --rebase)' s |
| 187 | parse_args "$@" |
| 188 | expand_name_arg_prefix |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 189 | |
| 190 | # sanity checks |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 191 | gitflow_require_branch $BRANCH |
Vincent Driessen | e034e4a | 2010-01-29 12:10:44 +0100 | [diff] [blame] | 192 | |
Vincent Driessen | 49c7d02 | 2010-01-28 12:40:33 +0100 | [diff] [blame] | 193 | # detect if we're restoring from a merge conflict |
| 194 | if [ -f "$GIT_DIR/.gitflow/MERGE_BASE" ]; then |
| 195 | # |
| 196 | # TODO: detect that we're working on the correct branch here! |
| 197 | # The user need not necessarily have given the same $NAME twice here |
| 198 | # (although he/she should). |
| 199 | # |
Vincent Driessen | f6f152f | 2010-01-29 10:28:08 +0100 | [diff] [blame] | 200 | |
| 201 | # TODO: gitflow_test_clean_working_tree() should provide an alternative |
| 202 | # exit code for "unmerged changes in working tree", which we should |
| 203 | # actually be testing for here |
| 204 | if gitflow_test_clean_working_tree; then |
| 205 | FINISH_BASE="$(cat "$GIT_DIR/.gitflow/MERGE_BASE")" |
| 206 | |
| 207 | # Since the working tree is now clean, either the user did a |
| 208 | # succesfull merge manually, or the merge was cancelled. |
| 209 | # We detect this using gitflow_is_branch_merged_into() |
| 210 | if gitflow_is_branch_merged_into $BRANCH $FINISH_BASE; then |
| 211 | rm -f "$GIT_DIR/.gitflow/MERGE_BASE" |
| 212 | helper_finish_cleanup |
| 213 | exit 0 |
| 214 | else |
| 215 | # If the user cancelled the merge and decided to wait until later, |
| 216 | # that's fine. But we have to acknowledge this by removing the |
| 217 | # MERGE_BASE file and continuing normal execution of the finish |
| 218 | rm -f "$GIT_DIR/.gitflow/MERGE_BASE" |
| 219 | fi |
Vincent Driessen | 49c7d02 | 2010-01-28 12:40:33 +0100 | [diff] [blame] | 220 | else |
| 221 | echo |
| 222 | echo "Merge conflicts not resolved yet, use:" |
| 223 | echo " git mergetool" |
| 224 | echo " git commit" |
| 225 | echo |
| 226 | echo "You can then complete the finish by running it again:" |
| 227 | echo " git flow feature finish $NAME" |
| 228 | echo |
| 229 | exit 1 |
| 230 | fi |
| 231 | fi |
| 232 | |
Vincent Driessen | f6f152f | 2010-01-29 10:28:08 +0100 | [diff] [blame] | 233 | # sanity checks |
| 234 | gitflow_require_clean_working_tree |
| 235 | |
Vincent Driessen | e034e4a | 2010-01-29 12:10:44 +0100 | [diff] [blame] | 236 | # update local repo with remote changes first, if asked |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 237 | if [ $FLAGS_fetch -eq 1 ]; then |
Vincent Driessen | e034e4a | 2010-01-29 12:10:44 +0100 | [diff] [blame] | 238 | git fetch -q $ORIGIN $BRANCH |
| 239 | fi |
| 240 | |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 241 | if has $ORIGIN/$BRANCH $REMOTE_BRANCHES; then |
| 242 | gitflow_require_branches_equal $BRANCH $ORIGIN/$BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 243 | fi |
Benedikt Böhm | 4a864fb | 2010-01-26 12:59:27 +0100 | [diff] [blame] | 244 | if [ "$BASE" = "$DEVELOP_BRANCH" ]; then |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 245 | gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 246 | fi |
| 247 | |
| 248 | # merge into BASE |
| 249 | git checkout $BASE |
| 250 | if [ "$(git rev-list -n2 $BASE..$BRANCH | wc -l)" = "1" ]; then |
| 251 | git merge --ff $BRANCH |
| 252 | else |
| 253 | git merge --no-ff $BRANCH |
| 254 | fi |
| 255 | |
Vincent Driessen | 49c7d02 | 2010-01-28 12:40:33 +0100 | [diff] [blame] | 256 | if [ $? -ne 0 ]; then |
| 257 | # oops.. we have a merge conflict! |
| 258 | # write the given $BASE to a temporary file (we need it later) |
Vincent Driessen | f6f152f | 2010-01-29 10:28:08 +0100 | [diff] [blame] | 259 | mkdir -p "$GIT_DIR/.gitflow" |
Vincent Driessen | 49c7d02 | 2010-01-28 12:40:33 +0100 | [diff] [blame] | 260 | echo "$BASE" > "$GIT_DIR/.gitflow/MERGE_BASE" |
| 261 | echo |
| 262 | echo "There were merge conflicts. To resolve the merge conflict manually, use:" |
| 263 | echo " git mergetool" |
| 264 | echo " git commit" |
| 265 | echo |
| 266 | echo "You can then complete the finish by running it again:" |
| 267 | echo " git flow feature finish $NAME" |
| 268 | echo |
| 269 | exit 1 |
| 270 | fi |
| 271 | |
| 272 | # when no merge conflict is detected, just clean up the feature branch |
| 273 | helper_finish_cleanup |
| 274 | } |
| 275 | |
| 276 | helper_finish_cleanup() { |
Vincent Driessen | f6f152f | 2010-01-29 10:28:08 +0100 | [diff] [blame] | 277 | # sanity checks |
| 278 | gitflow_require_branch $BRANCH |
Vincent Driessen | 1ee37e7 | 2010-01-29 17:36:21 +0100 | [diff] [blame] | 279 | gitflow_require_clean_working_tree |
Vincent Driessen | f6f152f | 2010-01-29 10:28:08 +0100 | [diff] [blame] | 280 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 281 | # delete branch |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 282 | git push $ORIGIN :refs/heads/$BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 283 | git branch -d $BRANCH |
| 284 | |
| 285 | echo |
| 286 | echo "Summary of actions:" |
| 287 | echo "- The feature branch '$BRANCH' was merged into '$BASE'" |
| 288 | #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported |
| 289 | echo "- Feature branch '$BRANCH' has been removed" |
| 290 | echo "- You are now on branch '$BASE'" |
| 291 | echo |
| 292 | } |
| 293 | |
| 294 | cmd_publish() { |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 295 | parse_args "$@" |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 296 | expand_name_arg_prefix |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 297 | |
| 298 | # sanity checks |
Vincent Driessen | 4838644 | 2010-01-29 10:30:40 +0100 | [diff] [blame] | 299 | gitflow_require_clean_working_tree |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 300 | gitflow_require_branch $BRANCH |
Benedikt Böhm | 4d22227 | 2010-01-26 14:46:56 +0100 | [diff] [blame] | 301 | git fetch -q $ORIGIN |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 302 | gitflow_require_branch_absent $ORIGIN/$BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 303 | |
| 304 | # create remote branch |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 305 | git push $ORIGIN $BRANCH:refs/heads/$BRANCH |
Benedikt Böhm | 4d22227 | 2010-01-26 14:46:56 +0100 | [diff] [blame] | 306 | git fetch -q $ORIGIN |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 307 | |
| 308 | # configure remote tracking |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 309 | git config branch.$BRANCH.remote $ORIGIN |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 310 | git config branch.$BRANCH.merge refs/heads/$BRANCH |
| 311 | git checkout $BRANCH |
| 312 | |
| 313 | echo |
| 314 | echo "Summary of actions:" |
| 315 | echo "- A new remote branch '$BRANCH' was created" |
| 316 | echo "- The local branch '$BRANCH' was configured to track the remote branch" |
| 317 | echo "- You are now on branch '$BRANCH'" |
| 318 | echo |
| 319 | } |
| 320 | |
| 321 | cmd_track() { |
Vincent Driessen | ea60895 | 2010-01-29 16:56:29 +0100 | [diff] [blame] | 322 | parse_args "$@" |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 323 | require_name |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 324 | |
| 325 | # sanity checks |
Vincent Driessen | 4838644 | 2010-01-29 10:30:40 +0100 | [diff] [blame] | 326 | gitflow_require_clean_working_tree |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 327 | gitflow_require_branch_absent $BRANCH |
Benedikt Böhm | 4d22227 | 2010-01-26 14:46:56 +0100 | [diff] [blame] | 328 | git fetch -q $ORIGIN |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 329 | gitflow_require_branch $ORIGIN/$BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 330 | |
| 331 | # create tracking branch |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 332 | git checkout -b $BRANCH $ORIGIN/$BRANCH |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 333 | |
| 334 | echo |
| 335 | echo "Summary of actions:" |
| 336 | echo "- A new remote tracking branch '$BRANCH' was created" |
| 337 | echo "- You are now on branch '$BRANCH'" |
| 338 | echo |
| 339 | } |
Vincent Driessen | bd4f095 | 2010-01-27 13:57:15 +0100 | [diff] [blame] | 340 | |
Vincent Driessen | bd4f095 | 2010-01-27 13:57:15 +0100 | [diff] [blame] | 341 | cmd_diff() { |
Vincent Driessen | 1b81923 | 2010-02-01 15:51:43 +0100 | [diff] [blame] | 342 | parse_args "$@" |
| 343 | expand_name_arg_prefix |
| 344 | |
Vincent Driessen | bd4f095 | 2010-01-27 13:57:15 +0100 | [diff] [blame] | 345 | # TODO: if this feature has been based on a non-develop branch, we really |
| 346 | # should not be comparing to $DEVELOP. How to deal with this? |
Vincent Driessen | 278884b | 2010-01-28 16:29:34 +0100 | [diff] [blame] | 347 | git diff $DEVELOP_BRANCH..$BRANCH |
Vincent Driessen | bd4f095 | 2010-01-27 13:57:15 +0100 | [diff] [blame] | 348 | } |