From 2be8edfa9fe6bea7a2780fe86c96c25f82f13009 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 21 Apr 2014 01:21:49 -0400 Subject: [PATCH] Update README; --preserve-merges as promised. --- README.md | 29 ++++++++++++++++++----------- gitup/script.py | 2 +- gitup/update.py | 12 +++++++++--- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3709582..a6f6cdf 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ __gitup__ (the _git-repo-updater_) -gitup is a tool designed to pull to a large number of git repositories at once. -It is smart enough to ignore repos with dirty working directories, and provides -a (hopefully) great way to get everything up-to-date for those short periods of -internet access between long periods of none. +gitup is a tool designed to update a large number of git repositories at once. +It is smart enough to handle multiple remotes, branches, dirty working +directories, and more, hopefully providing a great way to get everything +up-to-date for short periods of internet access between long periods of none. gitup should work on OS X, Linux, and Windows. You should have the latest version of git and at least Python 2.7 installed. @@ -40,9 +40,8 @@ For example: gitup ~/repos/foo ~/repos/bar ~/repos/baz -will automatically pull to the `foo`, `bar`, and `baz` git repositories if -their working directories are clean (to avoid merge conflicts). Additionally, -you can just type: +will automatically pull to the `foo`, `bar`, and `baz` git repositories. +Additionally, you can just type: gitup ~/repos @@ -53,15 +52,15 @@ To add a bookmark (or bookmarks), either of these will work: gitup --add ~/repos/foo ~/repos/bar ~/repos/baz gitup --add ~/repos -Then, to update (pull to) all of your bookmarks, just run gitup without args: +Then, to update all of your bookmarks, just run gitup without args: gitup -Deleting a bookmark is as easy as adding one: +Delete a bookmark: gitup --delete ~/repos -Want to view your current bookmarks? Simple: +View your current bookmarks: gitup --list @@ -72,10 +71,18 @@ You can mix and match bookmarks and command arguments: gitup # update 'foo' and 'bar' only gitup ~/repos/baz --update # update all three! -Want to update all git repositories in your current directory? +Update all git repositories in your current directory: gitup . +By default, gitup will fetch all remotes in a repository. Pass `--current-only` +(or `-c`) to make it only fetch the remote tracked by the current branch. + +gitup will _merge_ upstream branches by default unless `pull.rebase` or +`branch..rebase` is specified in git's config. Pass `--rebase` or `-r` to +make it always _rebase_ (like doing `git pull --rebase=preserve`). Pass +`--merge` or `-m` to make it always merge. + For a list of all command arguments and abbreviations: gitup --help diff --git a/gitup/script.py b/gitup/script.py index 61f9d44..a29982f 100644 --- a/gitup/script.py +++ b/gitup/script.py @@ -36,7 +36,7 @@ def main(): '-u', '--update', action="store_true", help="""update all bookmarks (default behavior when called without arguments)""") group_u.add_argument( - '-c', '--current-only', action="store_true", help="""only pull the + '-c', '--current-only', action="store_true", help="""only fetch the remote tracked by the current branch instead of all remotes""") rebase_or_merge.add_argument( '-r', '--rebase', action="store_true", help="""always rebase upstream diff --git a/gitup/update.py b/gitup/update.py index f851b40..9ef7d42 100644 --- a/gitup/update.py +++ b/gitup/update.py @@ -117,9 +117,11 @@ def _rebase(repo, name): """Rebase the current HEAD of *repo* onto the branch *name*.""" print(GREEN + "rebasing...", end="") try: - res = repo.git.rebase(name) + res = repo.git.rebase(name, "--preserve-merges") except exc.GitCommandError as err: msg = err.stderr.replace("\n", " ").strip() + if not msg.endswith("."): + msg += "." if "unstaged changes" in msg: print(RED + " error:", "unstaged changes.") elif "uncommitted changes" in msg: @@ -129,7 +131,8 @@ def _rebase(repo, name): repo.git.rebase("--abort") except exc.GitCommandError: pass - print(RED + " error:", msg if msg else "rebase conflict.") + print(RED + " error:", msg if msg else "rebase conflict.", + "Aborted.") else: print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=".\n") @@ -140,6 +143,8 @@ def _merge(repo, name): repo.git.merge(name) except exc.GitCommandError as err: msg = err.stderr.replace("\n", " ").strip() + if not msg.endswith("."): + msg += "." if "local changes" in msg and "would be overwritten" in msg: print(RED + " error:", "uncommitted changes.") else: @@ -147,7 +152,8 @@ def _merge(repo, name): repo.git.merge("--abort") except exc.GitCommandError: pass - print(RED + " error:", msg if msg else "merge conflict.") + print(RED + " error:", msg if msg else "merge conflict.", + "Aborted.") else: print("\b" * 6 + " " * 6 + "\b" * 6 + GREEN + "ed", end=".\n")