* Improve git pull --quiet behaviour
@ 2008-03-08 23:52 Iustin Pop
2008-03-08 23:52 ` [PATCH 1/2] Add a quiet option to git merge Iustin Pop
2008-03-08 23:52 ` [PATCH 2/2] Fix git pull handling of the quiet option Iustin Pop
0 siblings, 2 replies; 7+ messages in thread
From: Iustin Pop @ 2008-03-08 23:52 UTC (permalink / raw)
To: git
While trying to cleanup some cron jobs that do "git pull", I found out
that "-q" doesn't behave as expected. The following two small patches
improve the handling of this option.
My tests show that now 'git pull -q' when there are no changes is silent
as expected and plain 'git pull' has the previous behaviour. I hope that
I followed the code style correctly while modifying the files.
Overall diff stats:
Documentation/git-merge.txt | 2 +-
Documentation/merge-options.txt | 4 ++++
git-merge.sh | 19 +++++++++++++------
git-pull.sh | 8 +++++---
4 files changed, 23 insertions(+), 10 deletions(-)
regards,
iustin
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Add a quiet option to git merge
2008-03-08 23:52 Improve git pull --quiet behaviour Iustin Pop
@ 2008-03-08 23:52 ` Iustin Pop
2008-03-09 12:18 ` [PATCH] " Iustin Pop
2008-03-08 23:52 ` [PATCH 2/2] Fix git pull handling of the quiet option Iustin Pop
1 sibling, 1 reply; 7+ messages in thread
From: Iustin Pop @ 2008-03-08 23:52 UTC (permalink / raw)
To: git; +Cc: Iustin Pop
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] Fix git pull handling of the quiet option
2008-03-08 23:52 Improve git pull --quiet behaviour Iustin Pop
2008-03-08 23:52 ` [PATCH 1/2] Add a quiet option to git merge Iustin Pop
@ 2008-03-08 23:52 ` Iustin Pop
2008-03-09 4:04 ` Junio C Hamano
1 sibling, 1 reply; 7+ messages in thread
From: Iustin Pop @ 2008-03-08 23:52 UTC (permalink / raw)
To: git; +Cc: Iustin Pop
Although git pull has a documented quiet option, currently it doesn't
handle this option at all, and this results in it terminating the
handling of command line options when this particular option is met.
More exactly, it will cause the following invocation:
git pull --quiet --no-commit
to fail with:
error: unknown option `no-commit'
usage: git-fetch [options] [<repository> <refspec>...]
because it will not look at anything after quiet (and no-commit and
other options should not be passed to git fetch).
This patch adds the handling of this option, and passes it correctly to
both git fetch and git merge (and therefore needs to be applied on top
of patched git merge).
---
git-pull.sh | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 3ce32b5..2201ca0 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,7 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
-strategy_args= no_summary= no_commit= squash= no_ff=
+strategy_args= no_summary= no_commit= squash= no_ff= quiet=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
rebase=$(git config --bool branch.$curr_branch_short.rebase)
@@ -61,6 +61,8 @@ do
--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
rebase=false
;;
+ -q|--q|--qui|--quie|--quiet)
+ quiet=--quiet ;;
-h|--h|--he|--hel|--help)
usage
;;
@@ -116,7 +118,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git-fetch --update-head-ok "$@" || exit 1
+git-fetch $quiet --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -177,4 +179,4 @@ test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \
- "$merge_name" HEAD $merge_head
+ $quiet "$merge_name" HEAD $merge_head
--
1.5.4.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Fix git pull handling of the quiet option
2008-03-08 23:52 ` [PATCH 2/2] Fix git pull handling of the quiet option Iustin Pop
@ 2008-03-09 4:04 ` Junio C Hamano
2008-03-09 10:31 ` Iustin Pop
2008-03-09 22:31 ` [PATCH] " Iustin Pop
0 siblings, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2008-03-09 4:04 UTC (permalink / raw)
To: Iustin Pop; +Cc: git
Iustin Pop <iusty@k1024.org> writes:
> Although git pull has a documented quiet option,...
I think that is a documentation bug. pull accepts all options for fetch
for the sole purpose of passing them intact to underlying fetch, and some
options to fetch does not even make much sense in the context of pull.
Also options to pull needs to come first; the options pull does not know
about is a signal for pull that the rest is for consumption of underlying
fetch.
If you want to teach --quiet to pull, however, your patch is the right
approach. pull would eat --quiet and make a note for itself, and passes
that to underlying fetch (and perhaps merge).
You also need to sign-off your patch and add tests to make sure that other
people will not break your enhancement in the future.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] Fix git pull handling of the quiet option
2008-03-09 4:04 ` Junio C Hamano
@ 2008-03-09 10:31 ` Iustin Pop
2008-03-09 22:31 ` [PATCH] " Iustin Pop
1 sibling, 0 replies; 7+ messages in thread
From: Iustin Pop @ 2008-03-09 10:31 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Sat, Mar 08, 2008 at 08:04:26PM -0800, Junio C Hamano wrote:
> Iustin Pop <iusty@k1024.org> writes:
>
> > Although git pull has a documented quiet option,...
>
> I think that is a documentation bug. pull accepts all options for fetch
> for the sole purpose of passing them intact to underlying fetch, and some
> options to fetch does not even make much sense in the context of pull.
>
> Also options to pull needs to come first; the options pull does not know
> about is a signal for pull that the rest is for consumption of underlying
> fetch.
Ah, I see. This is indeed not clear from the documentation.
> If you want to teach --quiet to pull, however, your patch is the right
> approach. pull would eat --quiet and make a note for itself, and passes
> that to underlying fetch (and perhaps merge).
>
> You also need to sign-off your patch and add tests to make sure that other
> people will not break your enhancement in the future.
Thanks, so the approach would be:
- resend git merge patch including tests
- and then resend git pull patch, again including tests.
Thanks for the feedback, I will try to see how the unittests are written
and hopefully come back with some more patches.
iustin
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add a quiet option to git merge
2008-03-08 23:52 ` [PATCH 1/2] Add a quiet option to git merge Iustin Pop
@ 2008-03-09 12:18 ` Iustin Pop
0 siblings, 0 replies; 7+ messages in thread
From: Iustin Pop @ 2008-03-09 12:18 UTC (permalink / raw)
To: git
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. It also adds a test for this new
option.
Signed-off-by: Iustin Pop <iusty@k1024.org>
---
This new version has a test too for this option but I'm not sure if
it's the right place to add it.
Documentation/git-merge.txt | 2 +-
Documentation/merge-options.txt | 4 ++++
git-merge.sh | 19 +++++++++++++------
t/t7600-merge.sh | 5 +++++
4 files changed, 23 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 ;;
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 5d16628..cb7e2e4 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -247,6 +247,11 @@ test_expect_success 'test option parsing' '
then
echo "[OOPS] missing commit references accepted"
false
+ fi &&
+ if ! git merge --quiet c1
+ then
+ echo "[OOPS] quiet not accepted"
+ false
fi
'
--
1.5.4.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Fix git pull handling of the quiet option
2008-03-09 4:04 ` Junio C Hamano
2008-03-09 10:31 ` Iustin Pop
@ 2008-03-09 22:31 ` Iustin Pop
1 sibling, 0 replies; 7+ messages in thread
From: Iustin Pop @ 2008-03-09 22:31 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Although git pull has a documented quiet option, currently it doesn't
handle this option at all, and this results in it terminating the
handling of command line options when this particular option is met.
More exactly, it will cause the following invocation:
git pull --quiet --no-commit
to fail with:
error: unknown option `no-commit'
usage: git-fetch [options] [<repository> <refspec>...]
because it will not look at anything after quiet (and no-commit and
other options should not be passed to git fetch).
This patch adds the handling of this option, and passes it correctly to
both git fetch and git merge (and therefore needs to be applied on top
of patched git merge).
The patch also adds a small test for making sure that the quiet option
works.
Signed-off-by: Iustin Pop <iusty@k1024.org>
---
This is an updated version which includes a small test for the quiet option.
git-pull.sh | 8 +++++---
t/t5520-pull.sh | 8 ++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 3ce32b5..2201ca0 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -16,7 +16,7 @@ cd_to_toplevel
test -z "$(git ls-files -u)" ||
die "You are in the middle of a conflicted merge."
-strategy_args= no_summary= no_commit= squash= no_ff=
+strategy_args= no_summary= no_commit= squash= no_ff= quiet=
curr_branch=$(git symbolic-ref -q HEAD)
curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
rebase=$(git config --bool branch.$curr_branch_short.rebase)
@@ -61,6 +61,8 @@ do
--no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
rebase=false
;;
+ -q|--q|--qui|--quie|--quiet)
+ quiet=--quiet ;;
-h|--h|--he|--hel|--help)
usage
;;
@@ -116,7 +118,7 @@ test true = "$rebase" && {
"refs/remotes/$origin/$reflist" 2>/dev/null)"
}
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
-git-fetch --update-head-ok "$@" || exit 1
+git-fetch $quiet --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
if test "$curr_head" != "$orig_head"
@@ -177,4 +179,4 @@ test true = "$rebase" &&
exec git-rebase $strategy_args --onto $merge_head \
${oldremoteref:-$merge_head}
exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \
- "$merge_name" HEAD $merge_head
+ $quiet "$merge_name" HEAD $merge_head
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 9484129..6e36c00 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -21,6 +21,14 @@ test_expect_success 'pulling into void' '
git pull ..
'
+test_expect_success 'quiet pull' '
+ git pull --quiet .. &&
+ if test -n "`git pull --quiet ..`"; then
+ echo "[OOPS] quiet pull is not quiet"
+ false
+ fi
+'
+
cd "$D"
test_expect_success 'checking the results' '
--
1.5.4.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-03-09 22:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-08 23:52 Improve git pull --quiet behaviour Iustin Pop
2008-03-08 23:52 ` [PATCH 1/2] Add a quiet option to git merge Iustin Pop
2008-03-09 12:18 ` [PATCH] " Iustin Pop
2008-03-08 23:52 ` [PATCH 2/2] Fix git pull handling of the quiet option Iustin Pop
2008-03-09 4:04 ` Junio C Hamano
2008-03-09 10:31 ` Iustin Pop
2008-03-09 22:31 ` [PATCH] " Iustin Pop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).