* [PATCH 0/4] ld/push-porcelain
@ 2010-02-26 19:50 Larry D'Anna
0 siblings, 0 replies; 8+ messages in thread
From: Larry D'Anna @ 2010-02-26 19:50 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
I'm reposing this series to restart discussion on it. It's currently listed as
stalled. The only change versus what's in pu is that this one doesn't mess with
the semantics of --quiet.
So, what does it need?
Larry D'Anna (4):
git-push: fix an error message so it goes to stderr
git-push: squelch advice message if in --porcelain mode
git-push: send "To <remoteurl>" messages to the standard output in
--porcelain mode
git-push: make git push --dry-run --porcelain exit with status 0 even
if updates will be rejected
builtin-push.c | 11 ++++++++---
builtin-send-pack.c | 4 ++++
send-pack.h | 1 +
transport.c | 6 ++++--
4 files changed, 17 insertions(+), 5 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/4] ld/push-porcelain
@ 2010-02-27 3:59 Larry D'Anna
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
0 siblings, 1 reply; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 3:59 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
Changes since last version:
* instead of messing with the exit status git push --porcelain will now print
"Done" if nothing untowrd happned (ie all the error messages are in the ref
status lines)
* added tests for git push --porcelain
Larry D'Anna (4):
git-push: fix an advice message so it goes to stderr
git-push: send "To <remoteurl>" messages to the standard output in
--porcelain mode
git-push: make git push --porcelain print "Done"
git-push: add tests for git push --porcelain
builtin-push.c | 6 +++---
builtin-send-pack.c | 4 ++++
send-pack.h | 1 +
t/t5516-fetch-push.sh | 35 +++++++++++++++++++++++++++++++++++
transport.c | 17 +++++++++++------
5 files changed, 54 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/4] git-push: fix an advice message so it goes to stderr
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
@ 2010-02-27 3:59 ` Larry D'Anna
2010-02-27 3:59 ` [PATCH 2/4] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode Larry D'Anna
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 3:59 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
These sort of messages typically go to the standard error.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
builtin-push.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 5633f0a..0a27072 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -124,9 +124,9 @@ static int push_with_options(struct transport *transport, int flags)
return 0;
if (nonfastforward && advice_push_nonfastforward) {
- printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
- "Merge the remote changes before pushing again. See the 'Note about\n"
- "fast-forwards' section of 'git push --help' for details.\n");
+ fprintf(stderr, "To prevent you from losing history, non-fast-forward updates were rejected\n"
+ "Merge the remote changes before pushing again. See the 'Note about\n"
+ "fast-forwards' section of 'git push --help' for details.\n");
}
return 1;
--
1.7.0.rc2.40.g7d8aa
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
2010-02-27 3:59 ` [PATCH 1/4] git-push: fix an advice message so it goes to stderr Larry D'Anna
@ 2010-02-27 3:59 ` Larry D'Anna
2010-02-27 3:59 ` [PATCH 3/4] git-push: make git push --porcelain print "Done" Larry D'Anna
2010-02-27 3:59 ` [PATCH 4/4] git-push: add tests for git push --porcelain Larry D'Anna
3 siblings, 0 replies; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 3:59 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
git-push prints the line "To <remoteurl>" before above each of the ref status
lines. In --porcelain mode, these "To <remoteurl>" lines go to the standard
error, but the ref status lines go to the standard output. This makes it
difficult for the process reading standard output to know which ref status lines
correspond to which remote. This patch sends the "To <remoteurl>" lines to the
the standard output instead.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
transport.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/transport.c b/transport.c
index 08e4fa0..32885f7 100644
--- a/transport.c
+++ b/transport.c
@@ -675,7 +675,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)
{
if (!count)
- fprintf(stderr, "To %s\n", dest);
+ fprintf(porcelain ? stdout : stderr, "To %s\n", dest);
switch(ref->status) {
case REF_STATUS_NONE:
--
1.7.0.rc2.40.g7d8aa
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/4] git-push: make git push --porcelain print "Done"
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
2010-02-27 3:59 ` [PATCH 1/4] git-push: fix an advice message so it goes to stderr Larry D'Anna
2010-02-27 3:59 ` [PATCH 2/4] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode Larry D'Anna
@ 2010-02-27 3:59 ` Larry D'Anna
2010-02-27 4:19 ` Tay Ray Chuan
2010-02-27 3:59 ` [PATCH 4/4] git-push: add tests for git push --porcelain Larry D'Anna
3 siblings, 1 reply; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 3:59 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
The script calling git push --porcelain can see clearly from the output if an
update was rejected. However, it will probably need to distinguish this
condition from the push failing for other reasons, such as the remote not being
reachable.
This patch modifies git push --porcelain to print "Done" after the rest of its
output unless any errors have occurred which were not reported in the ref status
lines.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
builtin-send-pack.c | 4 ++++
send-pack.h | 1 +
transport.c | 15 ++++++++++-----
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 2183a47..87795f5 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -510,6 +510,10 @@ int send_pack(struct send_pack_args *args,
if (ret < 0)
return ret;
+
+ if (args->porcelain)
+ return 0;
+
for (ref = remote_refs; ref; ref = ref->next) {
switch (ref->status) {
case REF_STATUS_NONE:
diff --git a/send-pack.h b/send-pack.h
index 28141ac..60b4ba6 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -4,6 +4,7 @@
struct send_pack_args {
unsigned verbose:1,
quiet:1,
+ porcelain:1,
send_mirror:1,
force_update:1,
use_thin_pack:1,
diff --git a/transport.c b/transport.c
index 32885f7..5b880d7 100644
--- a/transport.c
+++ b/transport.c
@@ -791,6 +791,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
+ args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
ret = send_pack(&args, data->fd, data->conn, remote_refs,
&data->extra_have);
@@ -1055,8 +1056,6 @@ int transport_push(struct transport *transport,
ret = transport->push_refs(transport, remote_refs, flags);
err = push_had_errors(remote_refs);
- ret |= err;
-
if (!quiet || err)
print_push_status(transport->url, remote_refs,
verbose | porcelain, porcelain,
@@ -1071,9 +1070,15 @@ int transport_push(struct transport *transport,
update_tracking_ref(transport->remote, ref, verbose);
}
- if (!quiet && !ret && !refs_pushed(remote_refs))
- fprintf(stderr, "Everything up-to-date\n");
- return ret;
+
+ if (porcelain) {
+ if (ret==0)
+ fprintf (stdout, "Done\n");
+ } else
+ if (!quiet && !ret && !refs_pushed(remote_refs))
+ fprintf(stderr, "Everything up-to-date\n");
+
+ return ret | err;
}
return 1;
}
--
1.7.0.rc2.40.g7d8aa
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] git-push: add tests for git push --porcelain
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
` (2 preceding siblings ...)
2010-02-27 3:59 ` [PATCH 3/4] git-push: make git push --porcelain print "Done" Larry D'Anna
@ 2010-02-27 3:59 ` Larry D'Anna
3 siblings, 0 replies; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 3:59 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
Verify that the output format is correct for successful, rejected, and
flagrantly erroneous pushes.
Signed-off-by: Larry D'Anna <larry@elder-gods.org>
---
t/t5516-fetch-push.sh | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 0f04b2e..f3f113f 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -660,4 +660,39 @@ test_expect_success 'push with branches containing #' '
git checkout master
'
+test_expect_success 'push --porcelain' '
+ mk_empty &&
+ echo >.git/foo "To testrepo" &&
+ echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
+ echo >>.git/foo "Done" &&
+ git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
+ (
+ cd testrepo &&
+ r=$(git show-ref -s --verify refs/remotes/origin/master) &&
+ test "z$r" = "z$the_commit" &&
+ test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
+ ) &&
+ diff -q .git/foo .git/bar
+'
+
+test_expect_success 'push --porcelain bad url' '
+ mk_empty &&
+ test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
+ test_must_fail grep -q Done .git/bar
+'
+
+test_expect_success 'push --porcelain rejected' '
+ mk_empty &&
+ git push testrepo refs/heads/master:refs/remotes/origin/master &&
+ (cd testrepo &&
+ git reset --hard origin/master^
+ git config receive.denyCurrentBranch true) &&
+
+ echo >.git/foo "To testrepo" &&
+ echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
+
+ test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
+ diff -q .git/foo .git/bar
+'
+
test_done
--
1.7.0.rc2.40.g7d8aa
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/4] git-push: make git push --porcelain print "Done"
2010-02-27 3:59 ` [PATCH 3/4] git-push: make git push --porcelain print "Done" Larry D'Anna
@ 2010-02-27 4:19 ` Tay Ray Chuan
0 siblings, 0 replies; 8+ messages in thread
From: Tay Ray Chuan @ 2010-02-27 4:19 UTC (permalink / raw)
To: Larry D'Anna; +Cc: git
Hi,
On Sat, Feb 27, 2010 at 11:59 AM, Larry D'Anna <larry@elder-gods.org> wrote:
> diff --git a/transport.c b/transport.c
> index 32885f7..5b880d7 100644
> --- a/transport.c
> +++ b/transport.c
> [snip]
This hunk:
> @@ -1055,8 +1056,6 @@ int transport_push(struct transport *transport,
> ret = transport->push_refs(transport, remote_refs, flags);
> err = push_had_errors(remote_refs);
>
> - ret |= err;
> -
> if (!quiet || err)
> print_push_status(transport->url, remote_refs,
> verbose | porcelain, porcelain,
and this hunk:
> @@ -1071,9 +1070,15 @@ int transport_push(struct transport *transport,
> update_tracking_ref(transport->remote, ref, verbose);
> }
>
> - if (!quiet && !ret && !refs_pushed(remote_refs))
> - fprintf(stderr, "Everything up-to-date\n");
> - return ret;
> +
> + if (porcelain) {
> + if (ret==0)
> + fprintf (stdout, "Done\n");
> + } else
> + if (!quiet && !ret && !refs_pushed(remote_refs))
> + fprintf(stderr, "Everything up-to-date\n");
> +
> + return ret | err;
> }
> return 1;
> }
slightly changes the conditions under which "Everything up-to-date" is
printed, since you did away with "ret |= err". I guess you can
mitigate this by adding "!err" to the list of operands:
if (!quiet && !ret && !err && !refs_pushed(remote_refs))
....
Even better, create yet another temporary variable:
push_ret = transport->push_refs(transport, remote_refs, flags);
err = push_had_errors(remote_refs);
ret = push_ret | err;
That way, you can access transport->push_refs() status (what you
want), without messing with the other parts of the code and their
assumptions.
One last thing: could the if statements towards the end be "flattened"?
if (porcelain && ret == 0)
fprintf(stdout, "Done\n");
else if (!quiet && !ret && !refs_pushed(remote_refs))
fprintf(stderr, "Everything up-to-date\n");
(sorry about the lack of tabs, gmail doesn't let me type those easily.)
--
Cheers,
Ray Chuan
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/4] ld/push-porcelain
@ 2010-02-27 4:52 Larry D'Anna
0 siblings, 0 replies; 8+ messages in thread
From: Larry D'Anna @ 2010-02-27 4:52 UTC (permalink / raw)
To: git; +Cc: Larry D'Anna
changes since last version:
* clarified the commit message for 3/4
* added one more test case
* incorporated Tay's changes
Larry D'Anna (4):
git-push: fix an advice message so it goes to stderr
git-push: send "To <remoteurl>" messages to the standard output in
--porcelain mode
git-push: make git push --porcelain print "Done"
git-push: add tests for git push --porcelain
builtin-push.c | 6 ++--
builtin-send-pack.c | 4 +++
send-pack.h | 1 +
t/t5516-fetch-push.sh | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
transport.c | 15 ++++++++-----
5 files changed, 67 insertions(+), 9 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-02-27 4:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-27 3:59 [PATCH 0/4] ld/push-porcelain Larry D'Anna
[not found] ` <cover.1267243044.git.larry@elder-gods.org>
2010-02-27 3:59 ` [PATCH 1/4] git-push: fix an advice message so it goes to stderr Larry D'Anna
2010-02-27 3:59 ` [PATCH 2/4] git-push: send "To <remoteurl>" messages to the standard output in --porcelain mode Larry D'Anna
2010-02-27 3:59 ` [PATCH 3/4] git-push: make git push --porcelain print "Done" Larry D'Anna
2010-02-27 4:19 ` Tay Ray Chuan
2010-02-27 3:59 ` [PATCH 4/4] git-push: add tests for git push --porcelain Larry D'Anna
-- strict thread matches above, loose matches on Subject: below --
2010-02-27 4:52 [PATCH 0/4] ld/push-porcelain Larry D'Anna
2010-02-26 19:50 Larry D'Anna
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).