git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 5/6] transport-helper.c::push_refs(): ignore helper-reported status if ref is not to be pushed

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jan 8, 2010, 02:12 UTC
Message-ID
<1262916765-3728-6-git-send-email-rctay89@gmail.com>
In-Reply-To
<1262916765-3728-5-git-send-email-rctay89@gmail.com>

If the status of a ref is REF_STATUS_NONE, the remote helper will not be told to push the ref (via a 'push' command).

However, the remote helper may still act on these refs.

If the helper does act on the ref, and prints a status for it, ignore the report (ie. don't overwrite the status of the ref with it, nor the message in the remote_status member) if the reported status is 'no match'.

This allows the user to be alerted to more "interesting" ref statuses, like REF_STATUS_NONFASTFORWARD.

Cc: Jeff King <peff@peff.net>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
Changed from v3:
 - consider a ref as marked not for pushing if its status is _not_
   none, rather than checking if the status is nonff or uptodate.
 - ignore ref status reported by remote helper only if it reported 'no
   match'
 t/t5541-http-push.sh |    2 +-
 transport-helper.c   |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 979624d..83a8e14 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -111,7 +111,7 @@ Merge the remote changes before pushing again.  See the '"'non-fast-forward'"'
 section of '"'git push --help'"' for details." output
 '

-test_expect_failure 'push fails for non-fast-forward refs unmatched by remote helper' '
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' '
 	# create a dissimilarly-named remote ref so that git is unable to match the
 	# two refs (viz. local, remote) unless an explicit refspec is provided.
 	git push origin master:retsam
diff --git a/transport-helper.c b/transport-helper.c
index 7c9b569..71a1e50 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -430,6 +430,15 @@ static int push_refs(struct transport *transport,
 			continue;
 		}

+		if (ref->status != REF_STATUS_NONE) {
+			/*
+			 * Earlier, the ref was marked not to be pushed, so ignore the ref
+			 * status reported by the remote helper if the latter is 'no match'.
+			 */
+			if (status == REF_STATUS_NONE)
+				continue;
+		}
+
 		ref->status = status;
 		ref->remote_status = msg;
 	}
--
1.6.6.341.ga7aec
Previous: Tay Ray ChuanNext: Tay Ray Chuan
Message 11 of 12 in “transport: catch non-fast-forwards”
  1. 0/3 transport: catch non-fast-forwardsTay Ray Chuan, Dec 4, 2009
  2. 1/3 refactor ref status logic for pushingTay Ray Chuan, Dec 4, 2009
  3. 2/3 transport-helper.c::push_refs(): know more about refs before pushingTay Ray Chuan, Dec 4, 2009
  4. 3/3 transport.c::transport_push(): make ref status affect return valueTay Ray Chuan, Dec 4, 2009
  5. Jeff KingDec 4, 2009
  6. 0/6 transport: catch non-fast forwardsTay Ray Chuan, Jan 8, 2010
  7. 1/6 t5541-http-push.sh: add tests for non-fast-forward pushesTay Ray Chuan, Jan 8, 2010
  8. 2/6 t5541-http-push.sh: add test for unmatched, non-fast-forwarded refsTay Ray Chuan, Jan 8, 2010
  9. 3/6 refactor ref status logic for pushingTay Ray Chuan, Jan 8, 2010
  10. 4/6 transport.c::transport_push(): make ref status affect return valueTay Ray Chuan, Jan 8, 2010
  11. 5/6 transport-helper.c::push_refs(): ignore helper-reported status if ref is not to be pushedTay Ray Chuan, Jan 8, 2010
  12. 6/6 transport-helper.c::push_refs(): emit "no refs" error messageTay Ray Chuan, Jan 8, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.