[PATCH 1/2] Add a quiet option to git merge
From: Iustin Pop <hidden>
Date: 2016-06-15 22:44:21
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
Currently it's not possible to do quiet merges in case of no changes because git merge always outputs the 'Already up to date' message. This small patch adds a quiet option to git merge that in this case will skip the output of this message. --- Documentation/git-merge.txt | 2 +- Documentation/merge-options.txt | 4 ++++ git-merge.sh | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index c136b10..0c4cd19 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt@@ -9,7 +9,7 @@ git-merge - Join two or more development histories together SYNOPSIS -------- [verse] -'git-merge' [-n] [--summary] [--no-commit] [--squash] [-s <strategy>]... +'git-merge' [-n] [-q] [--summary] [--no-commit] [--squash] [-s <strategy>]... [-m <msg>] <remote> <remote>... 'git-merge' <msg> HEAD <remote>...
diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt
index 9f1fc82..dbedf40 100644
--- a/Documentation/merge-options.txt
+++ b/Documentation/merge-options.txt@@ -5,6 +5,10 @@ -n, \--no-summary:: Do not show diffstat at the end of the merge. +-q, \--quiet:: + Supress the 'Already up to date' message if no merge is + needed. + --no-commit:: Perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and
diff --git a/git-merge.sh b/git-merge.sh
index 7dbbb1d..625457e 100755
--- a/git-merge.sh
+++ b/git-merge.sh@@ -15,6 +15,7 @@ commit perform a commit if the merge sucesses (default) ff allow fast forward (default) s,strategy= merge strategy to use m,message= message to be used for the merge commit (if any) +q,quiet suppress some default messages " SUBDIRECTORY_OK=Yes
@@ -38,6 +39,7 @@ use_strategies= allow_fast_forward=t allow_trivial_merge=t squash= no_commit= +quiet= dropsave() { rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
@@ -59,12 +61,15 @@ restorestate() { } finish_up_to_date () { - case "$squash" in - t) - echo "$1 (nothing to squash)" ;; - '') - echo "$1" ;; - esac + if test -z "$quiet" + then + case "$squash" in + t) + echo "$1 (nothing to squash)" ;; + '') + echo "$1" ;; + esac + fi dropsave }
@@ -182,6 +187,8 @@ parse_config () { merge_msg="$1" have_message=t ;; + -q|--quiet) + quiet=t ;; --) shift break ;;
--
1.5.4.3